From e6c37bf8c629d5ad54170cfdf9b45c4b0ff8446d Mon Sep 17 00:00:00 2001 From: John Duprey Date: Sun, 26 Jan 2025 16:45:04 -0500 Subject: [PATCH 1/2] tenant selector fix --- .../CippIntegrationTenantMapping.jsx | 61 ++++++++++--------- .../CippSettings/CippCustomRoles.jsx | 8 ++- src/pages/cipp/super-admin/sam-app-roles.js | 5 +- 3 files changed, 40 insertions(+), 34 deletions(-) diff --git a/src/components/CippIntegrations/CippIntegrationTenantMapping.jsx b/src/components/CippIntegrations/CippIntegrationTenantMapping.jsx index 4461db5a8bc9..8f1ecc67ec5c 100644 --- a/src/components/CippIntegrations/CippIntegrationTenantMapping.jsx +++ b/src/components/CippIntegrations/CippIntegrationTenantMapping.jsx @@ -22,6 +22,7 @@ import { CippFormTenantSelector } from "../CippComponents/CippFormTenantSelector import { Sync, SyncAlt } from "@mui/icons-material"; import { CippFormComponent } from "../CippComponents/CippFormComponent"; import { CippApiResults } from "../CippComponents/CippApiResults"; +import { ApiGetCallWithPagination } from "../../api/ApiCall"; const CippIntegrationSettings = ({ children }) => { const router = useRouter(); @@ -35,7 +36,7 @@ const CippIntegrationSettings = ({ children }) => { queryKey: `IntegrationTenantMapping-${router.query.id}`, }); - const tenantList = ApiGetCall({ + const tenantList = ApiGetCallWithPagination({ url: "/api/ListTenants", data: { AllTenantSelector: false }, queryKey: "ListTenants-notAllTenants", @@ -94,37 +95,37 @@ const CippIntegrationSettings = ({ children }) => { }; const handleAutoMap = () => { - const newTableData = []; - tenantList.data.forEach((tenant) => { - const matchingCompany = mappings.data.Companies.find( - (company) => company.name === tenant.displayName - ); - if ( - Array.isArray(tableData) && - tableData?.find((item) => item.TenantId === tenant.customerId) - ) - return; - if (matchingCompany) { - newTableData.push({ - TenantId: tenant.customerId, - Tenant: tenant.displayName, - IntegrationName: matchingCompany.name, - IntegrationId: matchingCompany.value, + const newTableData = []; + tenantList.data?.pages[0]?.forEach((tenant) => { + const matchingCompany = mappings.data.Companies.find( + (company) => company.name === tenant.displayName + ); + if ( + Array.isArray(tableData) && + tableData?.find((item) => item.TenantId === tenant.customerId) + ) + return; + if (matchingCompany) { + newTableData.push({ + TenantId: tenant.customerId, + Tenant: tenant.displayName, + IntegrationName: matchingCompany.name, + IntegrationId: matchingCompany.value, + }); + } + }); + if (Array.isArray(tableData)) { + setTableData([...tableData, ...newTableData]); + } else { + setTableData(newTableData); + } + if (extension.autoMapSyncApi) { + automapPostCall.mutate({ + url: `/api/ExecExtensionMapping?AutoMapping=${router.query.id}`, + queryKey: `IntegrationTenantMapping-${router.query.id}`, }); } - }); - if (Array.isArray(tableData)) { - setTableData([...tableData, ...newTableData]); - } else { - setTableData(newTableData); - } - if (extension.autoMapSyncApi) { - automapPostCall.mutate({ - url: `/api/ExecExtensionMapping?AutoMapping=${router.query.id}`, - queryKey: `IntegrationTenantMapping-${router.query.id}`, - }); - } - }; + }; const actions = [ { diff --git a/src/components/CippSettings/CippCustomRoles.jsx b/src/components/CippSettings/CippCustomRoles.jsx index 2f8ddd517dcc..6387ae339a4f 100644 --- a/src/components/CippSettings/CippCustomRoles.jsx +++ b/src/components/CippSettings/CippCustomRoles.jsx @@ -14,7 +14,7 @@ import { } from "@mui/material"; import Grid from "@mui/material/Grid2"; -import { ApiGetCall, ApiPostCall } from "../../api/ApiCall"; +import { ApiGetCall, ApiGetCallWithPagination, ApiPostCall } from "../../api/ApiCall"; import { CippOffCanvas } from "/src/components/CippComponents/CippOffCanvas"; import { CippFormTenantSelector } from "/src/components/CippComponents/CippFormTenantSelector"; import { Save } from "@mui/icons-material"; @@ -67,10 +67,14 @@ export const CippCustomRoles = () => { queryKey: "customRoleList", }); - const { data: tenants = [], isSuccess: tenantsSuccess } = ApiGetCall({ + const { + data: { pages = [] } = {}, + isSuccess: tenantsSuccess, + } = ApiGetCallWithPagination({ url: "/api/ListTenants?AllTenantSelector=true", queryKey: "ListTenants-AllTenantSelector", }); + const tenants = pages[0] || []; useEffect(() => { if (customRoleListSuccess && tenantsSuccess && selectedRole !== currentRole?.value) { diff --git a/src/pages/cipp/super-admin/sam-app-roles.js b/src/pages/cipp/super-admin/sam-app-roles.js index f038c60f8249..a5c0632206eb 100644 --- a/src/pages/cipp/super-admin/sam-app-roles.js +++ b/src/pages/cipp/super-admin/sam-app-roles.js @@ -5,7 +5,7 @@ import CippFormPage from "/src/components/CippFormPages/CippFormPage"; import { Alert, CardContent, Stack, Typography } from "@mui/material"; import { WarningAmberOutlined } from "@mui/icons-material"; import { useForm } from "react-hook-form"; -import { ApiGetCall } from "../../../api/ApiCall"; +import { ApiGetCall, ApiGetCallWithPagination } from "../../../api/ApiCall"; import { useEffect } from "react"; import CippFormComponent from "../../../components/CippComponents/CippFormComponent"; import GDAPRoles from "/src/data/GDAPRoles"; @@ -23,10 +23,11 @@ const Page = () => { queryKey: "ExecSAMRoles", }); - const { data: tenants = [], isSuccess: tenantsSuccess } = ApiGetCall({ + const { data: tenantsData = { pages: [] }, isSuccess: tenantsSuccess } = ApiGetCallWithPagination({ url: "/api/ListTenants?AllTenantSelector=true", queryKey: "ListTenants-AllTenantSelector", }); + const tenants = tenantsData?.pages?.[0] || []; useEffect(() => { if (execSAMRoles.isSuccess && tenantsSuccess) { From a3346a9e510eeab824030e3bb72eb53888c04dd8 Mon Sep 17 00:00:00 2001 From: John Duprey Date: Sun, 26 Jan 2025 17:00:36 -0500 Subject: [PATCH 2/2] up version --- public/version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/version.json b/public/version.json index b2e85d7083a9..fa68337146a1 100644 --- a/public/version.json +++ b/public/version.json @@ -1,3 +1,3 @@ { - "version": "7.1.0" + "version": "7.1.1" }