@terreno/admin-frontend 57.3.0 → 57.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ai/guidelines/core.md +5 -1
- package/README.md +6 -4
- package/dist/AdminActionMenu.d.ts +1 -0
- package/dist/AdminActionMenu.d.ts.map +1 -0
- package/dist/AdminActionMenu.js +2 -2
- package/dist/AdminActionMenu.js.map +1 -1
- package/dist/AdminBreadcrumbs.d.ts +1 -0
- package/dist/AdminBreadcrumbs.d.ts.map +1 -0
- package/dist/AdminConflictSheet.d.ts +17 -0
- package/dist/AdminConflictSheet.d.ts.map +1 -0
- package/dist/AdminConflictSheet.js +52 -0
- package/dist/AdminConflictSheet.js.map +1 -0
- package/dist/AdminFieldRenderer.d.ts +1 -0
- package/dist/AdminFieldRenderer.d.ts.map +1 -0
- package/dist/AdminFieldRendererCore.d.ts +1 -0
- package/dist/AdminFieldRendererCore.d.ts.map +1 -0
- package/dist/AdminFieldRendererCore.js +15 -16
- package/dist/AdminFieldRendererCore.js.map +1 -1
- package/dist/AdminFilterDrawer.d.ts +1 -0
- package/dist/AdminFilterDrawer.d.ts.map +1 -0
- package/dist/AdminFilterDrawer.js +10 -12
- package/dist/AdminFilterDrawer.js.map +1 -1
- package/dist/AdminHome.d.ts +1 -0
- package/dist/AdminHome.d.ts.map +1 -0
- package/dist/AdminHome.js +11 -11
- package/dist/AdminHome.js.map +1 -1
- package/dist/AdminMigrations.d.ts +4 -0
- package/dist/AdminMigrations.d.ts.map +1 -0
- package/dist/AdminMigrations.js +19 -0
- package/dist/AdminMigrations.js.map +1 -0
- package/dist/AdminMigrationsView.d.ts +11 -0
- package/dist/AdminMigrationsView.d.ts.map +1 -0
- package/dist/AdminMigrationsView.js +92 -0
- package/dist/AdminMigrationsView.js.map +1 -0
- package/dist/AdminModelForm.d.ts +1 -0
- package/dist/AdminModelForm.d.ts.map +1 -0
- package/dist/AdminModelForm.js +208 -62
- package/dist/AdminModelForm.js.map +1 -1
- package/dist/AdminModelList.d.ts +1 -0
- package/dist/AdminModelList.d.ts.map +1 -0
- package/dist/AdminModelList.js +4 -8
- package/dist/AdminModelList.js.map +1 -1
- package/dist/AdminModelTable.d.ts +1 -0
- package/dist/AdminModelTable.d.ts.map +1 -0
- package/dist/AdminModelTable.js +321 -50
- package/dist/AdminModelTable.js.map +1 -1
- package/dist/AdminNestedArrayField.d.ts +1 -0
- package/dist/AdminNestedArrayField.d.ts.map +1 -0
- package/dist/AdminNestedArrayField.js +10 -5
- package/dist/AdminNestedArrayField.js.map +1 -1
- package/dist/AdminObjectPicker.d.ts +1 -0
- package/dist/AdminObjectPicker.d.ts.map +1 -0
- package/dist/AdminObjectPicker.js +35 -14
- package/dist/AdminObjectPicker.js.map +1 -1
- package/dist/AdminPrimitiveArrayField.d.ts +1 -0
- package/dist/AdminPrimitiveArrayField.d.ts.map +1 -0
- package/dist/AdminPrimitiveArrayField.js +2 -3
- package/dist/AdminPrimitiveArrayField.js.map +1 -1
- package/dist/AdminProvider.d.ts +7 -2
- package/dist/AdminProvider.d.ts.map +1 -0
- package/dist/AdminProvider.js +30 -9
- package/dist/AdminProvider.js.map +1 -1
- package/dist/AdminRefField.d.ts +1 -0
- package/dist/AdminRefField.d.ts.map +1 -0
- package/dist/AdminRolesField.d.ts +1 -0
- package/dist/AdminRolesField.d.ts.map +1 -0
- package/dist/AdminRolesField.js +1 -4
- package/dist/AdminRolesField.js.map +1 -1
- package/dist/AdminRolesList.d.ts +1 -0
- package/dist/AdminRolesList.d.ts.map +1 -0
- package/dist/AdminRolesList.js +17 -27
- package/dist/AdminRolesList.js.map +1 -1
- package/dist/AdminScreenPage.d.ts +1 -0
- package/dist/AdminScreenPage.d.ts.map +1 -0
- package/dist/AdminScreenPage.js +2 -14
- package/dist/AdminScreenPage.js.map +1 -1
- package/dist/AdminScreenRouter.d.ts +2 -1
- package/dist/AdminScreenRouter.d.ts.map +1 -0
- package/dist/AdminScreenRouter.js +8 -5
- package/dist/AdminScreenRouter.js.map +1 -1
- package/dist/AdminScriptList.d.ts +1 -0
- package/dist/AdminScriptList.d.ts.map +1 -0
- package/dist/AdminScriptList.js +15 -17
- package/dist/AdminScriptList.js.map +1 -1
- package/dist/AdminScriptRunModal.d.ts +1 -0
- package/dist/AdminScriptRunModal.d.ts.map +1 -0
- package/dist/AdminScriptRunModal.js +18 -25
- package/dist/AdminScriptRunModal.js.map +1 -1
- package/dist/AdminShell.d.ts +8 -3
- package/dist/AdminShell.d.ts.map +1 -0
- package/dist/AdminShell.js +59 -31
- package/dist/AdminShell.js.map +1 -1
- package/dist/AdminShellLayout.d.ts +1 -0
- package/dist/AdminShellLayout.d.ts.map +1 -0
- package/dist/AdminShellLayout.js +2 -14
- package/dist/AdminShellLayout.js.map +1 -1
- package/dist/AdminVersionConfig.d.ts +1 -0
- package/dist/AdminVersionConfig.d.ts.map +1 -0
- package/dist/AdminVersionConfig.js +34 -18
- package/dist/AdminVersionConfig.js.map +1 -1
- package/dist/AnnouncementEditor.d.ts +46 -0
- package/dist/AnnouncementEditor.d.ts.map +1 -0
- package/dist/AnnouncementEditor.js +367 -0
- package/dist/AnnouncementEditor.js.map +1 -0
- package/dist/AnnouncementList.d.ts +16 -0
- package/dist/AnnouncementList.d.ts.map +1 -0
- package/dist/AnnouncementList.js +96 -0
- package/dist/AnnouncementList.js.map +1 -0
- package/dist/AnnouncementOverview.d.ts +47 -0
- package/dist/AnnouncementOverview.d.ts.map +1 -0
- package/dist/AnnouncementOverview.js +98 -0
- package/dist/AnnouncementOverview.js.map +1 -0
- package/dist/AnnouncementOverviewScreenWidget.d.ts +5 -0
- package/dist/AnnouncementOverviewScreenWidget.d.ts.map +1 -0
- package/dist/AnnouncementOverviewScreenWidget.js +28 -0
- package/dist/AnnouncementOverviewScreenWidget.js.map +1 -0
- package/dist/CheckboxListEditor.d.ts +1 -0
- package/dist/CheckboxListEditor.d.ts.map +1 -0
- package/dist/CheckboxListEditor.js +2 -5
- package/dist/CheckboxListEditor.js.map +1 -1
- package/dist/ConfigurationScreen.d.ts +1 -0
- package/dist/ConfigurationScreen.d.ts.map +1 -0
- package/dist/ConfigurationScreen.js +16 -13
- package/dist/ConfigurationScreen.js.map +1 -1
- package/dist/ConsentFormEditor.d.ts +1 -0
- package/dist/ConsentFormEditor.d.ts.map +1 -0
- package/dist/ConsentFormEditor.js +46 -37
- package/dist/ConsentFormEditor.js.map +1 -1
- package/dist/ConsentFormList.d.ts +1 -0
- package/dist/ConsentFormList.d.ts.map +1 -0
- package/dist/ConsentFormList.js +4 -5
- package/dist/ConsentFormList.js.map +1 -1
- package/dist/ConsentHistory.d.ts +1 -0
- package/dist/ConsentHistory.d.ts.map +1 -0
- package/dist/ConsentHistory.js +5 -7
- package/dist/ConsentHistory.js.map +1 -1
- package/dist/ConsentResponseViewer.d.ts +1 -0
- package/dist/ConsentResponseViewer.d.ts.map +1 -0
- package/dist/ConsentResponseViewer.js +5 -6
- package/dist/ConsentResponseViewer.js.map +1 -1
- package/dist/Constants.d.ts +1 -0
- package/dist/Constants.d.ts.map +1 -0
- package/dist/DocumentStorageBrowser.d.ts +1 -0
- package/dist/DocumentStorageBrowser.d.ts.map +1 -0
- package/dist/DocumentStorageBrowser.js +11 -100
- package/dist/DocumentStorageBrowser.js.map +1 -1
- package/dist/LocaleContentEditor.d.ts +1 -0
- package/dist/LocaleContentEditor.d.ts.map +1 -0
- package/dist/LocaleContentEditor.js +6 -11
- package/dist/LocaleContentEditor.js.map +1 -1
- package/dist/adminApiQueryParams.d.ts +6 -0
- package/dist/adminApiQueryParams.d.ts.map +1 -0
- package/dist/adminApiQueryParams.js +25 -0
- package/dist/adminApiQueryParams.js.map +1 -0
- package/dist/adminConflictSheetStack.d.ts +18 -0
- package/dist/adminConflictSheetStack.d.ts.map +1 -0
- package/dist/adminConflictSheetStack.js +63 -0
- package/dist/adminConflictSheetStack.js.map +1 -0
- package/dist/adminContext.d.ts +4 -0
- package/dist/adminContext.d.ts.map +1 -0
- package/dist/adminContext.js +6 -0
- package/dist/adminContext.js.map +1 -0
- package/dist/adminModelListQueryParams.d.ts +4 -2
- package/dist/adminModelListQueryParams.d.ts.map +1 -0
- package/dist/adminModelListQueryParams.js +71 -27
- package/dist/adminModelListQueryParams.js.map +1 -1
- package/dist/adminPageAccess.d.ts +1 -0
- package/dist/adminPageAccess.d.ts.map +1 -0
- package/dist/adminRequest.d.ts +52 -0
- package/dist/adminRequest.d.ts.map +1 -0
- package/dist/adminRequest.js +165 -0
- package/dist/adminRequest.js.map +1 -0
- package/dist/adminRpc.d.ts +8 -0
- package/dist/adminRpc.d.ts.map +1 -0
- package/dist/adminRpc.js +21 -0
- package/dist/adminRpc.js.map +1 -0
- package/dist/adminShellNav.d.ts +18 -1
- package/dist/adminShellNav.d.ts.map +1 -0
- package/dist/adminShellNav.js +39 -12
- package/dist/adminShellNav.js.map +1 -1
- package/dist/adminWindowRefresh.d.ts +32 -0
- package/dist/adminWindowRefresh.d.ts.map +1 -0
- package/dist/adminWindowRefresh.js +48 -0
- package/dist/adminWindowRefresh.js.map +1 -0
- package/dist/adminWindowedTable.d.ts +14 -0
- package/dist/adminWindowedTable.d.ts.map +1 -0
- package/dist/adminWindowedTable.js +32 -0
- package/dist/adminWindowedTable.js.map +1 -0
- package/dist/comms/CommsDashboardScreen.d.ts +1 -0
- package/dist/comms/CommsDashboardScreen.d.ts.map +1 -0
- package/dist/comms/CommsDashboardScreen.js +37 -42
- package/dist/comms/CommsDashboardScreen.js.map +1 -1
- package/dist/comms/CommsDashboardScreenWidget.d.ts +1 -0
- package/dist/comms/CommsDashboardScreenWidget.d.ts.map +1 -0
- package/dist/comms/CommsMessageDetail.d.ts +1 -0
- package/dist/comms/CommsMessageDetail.d.ts.map +1 -0
- package/dist/comms/CommsMessageDetail.js +4 -8
- package/dist/comms/CommsMessageDetail.js.map +1 -1
- package/dist/comms/CommsStatCard.d.ts +1 -0
- package/dist/comms/CommsStatCard.d.ts.map +1 -0
- package/dist/comms/CommsStatusBadge.d.ts +1 -0
- package/dist/comms/CommsStatusBadge.d.ts.map +1 -0
- package/dist/comms/CommsStatusBadge.js +1 -2
- package/dist/comms/CommsStatusBadge.js.map +1 -1
- package/dist/comms/commsDashboardParams.d.ts +1 -4
- package/dist/comms/commsDashboardParams.d.ts.map +1 -0
- package/dist/comms/commsDashboardParams.js +5 -7
- package/dist/comms/commsDashboardParams.js.map +1 -1
- package/dist/comms/commsMessagePayload.d.ts +3 -1
- package/dist/comms/commsMessagePayload.d.ts.map +1 -0
- package/dist/comms/commsMessagePayload.js +3 -5
- package/dist/comms/commsMessagePayload.js.map +1 -1
- package/dist/comms/commsRetrySummary.d.ts +1 -0
- package/dist/comms/commsRetrySummary.d.ts.map +1 -0
- package/dist/comms/commsRetrySummary.js +1 -2
- package/dist/comms/commsRetrySummary.js.map +1 -1
- package/dist/comms/useCommsDashboardApi.d.ts +4 -3
- package/dist/comms/useCommsDashboardApi.d.ts.map +1 -0
- package/dist/comms/useCommsDashboardApi.js +41 -0
- package/dist/comms/useCommsDashboardApi.js.map +1 -1
- package/dist/comms/useCommsDashboardUrlFilters.d.ts +1 -0
- package/dist/comms/useCommsDashboardUrlFilters.d.ts.map +1 -0
- package/dist/comms/useCommsDashboardUrlFilters.js +1 -1
- package/dist/comms/useCommsDashboardUrlFilters.js.map +1 -1
- package/dist/dynamicHookApi.d.ts +1 -0
- package/dist/dynamicHookApi.d.ts.map +1 -0
- package/dist/generateConsentHistoryPdf.d.ts +1 -0
- package/dist/generateConsentHistoryPdf.d.ts.map +1 -0
- package/dist/generateConsentHistoryPdf.js +16 -22
- package/dist/generateConsentHistoryPdf.js.map +1 -1
- package/dist/generateConsentPdf.d.ts +1 -0
- package/dist/generateConsentPdf.d.ts.map +1 -0
- package/dist/generateConsentPdf.js +9 -10
- package/dist/generateConsentPdf.js.map +1 -1
- package/dist/index.d.ts +25 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/dist/isAuditLogModel.d.ts +3 -0
- package/dist/isAuditLogModel.d.ts.map +1 -0
- package/dist/isAuditLogModel.js +8 -0
- package/dist/isAuditLogModel.js.map +1 -0
- package/dist/jobs/JobsDashboardScreen.d.ts +11 -0
- package/dist/jobs/JobsDashboardScreen.d.ts.map +1 -0
- package/dist/jobs/JobsDashboardScreen.js +148 -0
- package/dist/jobs/JobsDashboardScreen.js.map +1 -0
- package/dist/jobs/JobsDashboardScreenWidget.d.ts +5 -0
- package/dist/jobs/JobsDashboardScreenWidget.d.ts.map +1 -0
- package/dist/jobs/JobsDashboardScreenWidget.js +11 -0
- package/dist/jobs/JobsDashboardScreenWidget.js.map +1 -0
- package/dist/jobs/JobsHomeWidget.d.ts +5 -0
- package/dist/jobs/JobsHomeWidget.d.ts.map +1 -0
- package/dist/jobs/JobsHomeWidget.js +20 -0
- package/dist/jobs/JobsHomeWidget.js.map +1 -0
- package/dist/jobs/JobsJobDetail.d.ts +9 -0
- package/dist/jobs/JobsJobDetail.d.ts.map +1 -0
- package/dist/jobs/JobsJobDetail.js +74 -0
- package/dist/jobs/JobsJobDetail.js.map +1 -0
- package/dist/jobs/JobsStatusBadge.d.ts +6 -0
- package/dist/jobs/JobsStatusBadge.d.ts.map +1 -0
- package/dist/jobs/JobsStatusBadge.js +15 -0
- package/dist/jobs/JobsStatusBadge.js.map +1 -0
- package/dist/jobs/jobPayload.d.ts +63 -0
- package/dist/jobs/jobPayload.d.ts.map +1 -0
- package/dist/jobs/jobPayload.js +52 -0
- package/dist/jobs/jobPayload.js.map +1 -0
- package/dist/jobs/jobsDashboardParams.d.ts +12 -0
- package/dist/jobs/jobsDashboardParams.d.ts.map +1 -0
- package/dist/jobs/jobsDashboardParams.js +69 -0
- package/dist/jobs/jobsDashboardParams.js.map +1 -0
- package/dist/jobs/useJobsDashboardApi.d.ts +61 -0
- package/dist/jobs/useJobsDashboardApi.d.ts.map +1 -0
- package/dist/jobs/useJobsDashboardApi.js +88 -0
- package/dist/jobs/useJobsDashboardApi.js.map +1 -0
- package/dist/jobs/useJobsDashboardUrlFilters.d.ts +6 -0
- package/dist/jobs/useJobsDashboardUrlFilters.d.ts.map +1 -0
- package/dist/jobs/useJobsDashboardUrlFilters.js +16 -0
- package/dist/jobs/useJobsDashboardUrlFilters.js.map +1 -0
- package/dist/orgs/OrgDirectoryScreen.d.ts +17 -0
- package/dist/orgs/OrgDirectoryScreen.d.ts.map +1 -0
- package/dist/orgs/OrgDirectoryScreen.js +78 -0
- package/dist/orgs/OrgDirectoryScreen.js.map +1 -0
- package/dist/orgs/OrgMembersScreen.d.ts +10 -0
- package/dist/orgs/OrgMembersScreen.d.ts.map +1 -0
- package/dist/orgs/OrgMembersScreen.js +114 -0
- package/dist/orgs/OrgMembersScreen.js.map +1 -0
- package/dist/orgs/OrgSettingsScreen.d.ts +10 -0
- package/dist/orgs/OrgSettingsScreen.d.ts.map +1 -0
- package/dist/orgs/OrgSettingsScreen.js +79 -0
- package/dist/orgs/OrgSettingsScreen.js.map +1 -0
- package/dist/orgs/OrgSwitcher.d.ts +9 -0
- package/dist/orgs/OrgSwitcher.d.ts.map +1 -0
- package/dist/orgs/OrgSwitcher.js +57 -0
- package/dist/orgs/OrgSwitcher.js.map +1 -0
- package/dist/orgs/adminModelEndpoints.d.ts +19 -0
- package/dist/orgs/adminModelEndpoints.d.ts.map +1 -0
- package/dist/orgs/adminModelEndpoints.js +76 -0
- package/dist/orgs/adminModelEndpoints.js.map +1 -0
- package/dist/orgs/normalizeListData.d.ts +10 -0
- package/dist/orgs/normalizeListData.d.ts.map +1 -0
- package/dist/orgs/normalizeListData.js +7 -0
- package/dist/orgs/normalizeListData.js.map +1 -0
- package/dist/orgs/organizationSettings.d.ts +18 -0
- package/dist/orgs/organizationSettings.d.ts.map +1 -0
- package/dist/orgs/organizationSettings.js +5 -0
- package/dist/orgs/organizationSettings.js.map +1 -0
- package/dist/orgs/shouldSkipOrgScopedAdminQuery.d.ts +5 -0
- package/dist/orgs/shouldSkipOrgScopedAdminQuery.d.ts.map +1 -0
- package/dist/orgs/shouldSkipOrgScopedAdminQuery.js +2 -0
- package/dist/orgs/shouldSkipOrgScopedAdminQuery.js.map +1 -0
- package/dist/orgs/sortOrganizations.d.ts +7 -0
- package/dist/orgs/sortOrganizations.d.ts.map +1 -0
- package/dist/orgs/sortOrganizations.js +9 -0
- package/dist/orgs/sortOrganizations.js.map +1 -0
- package/dist/orgs/useOrgContext.d.ts +21 -0
- package/dist/orgs/useOrgContext.d.ts.map +1 -0
- package/dist/orgs/useOrgContext.js +57 -0
- package/dist/orgs/useOrgContext.js.map +1 -0
- package/dist/orgs/useOrganizationsApi.d.ts +15 -0
- package/dist/orgs/useOrganizationsApi.d.ts.map +1 -0
- package/dist/orgs/useOrganizationsApi.js +103 -0
- package/dist/orgs/useOrganizationsApi.js.map +1 -0
- package/dist/pdfUtils.d.ts +1 -2
- package/dist/pdfUtils.d.ts.map +1 -0
- package/dist/pdfUtils.js +2 -2
- package/dist/pdfUtils.js.map +1 -1
- package/dist/scriptRunUtils.d.ts +1 -0
- package/dist/scriptRunUtils.d.ts.map +1 -0
- package/dist/scriptRunUtils.js +3 -5
- package/dist/scriptRunUtils.js.map +1 -1
- package/dist/types.d.ts +101 -4
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -3
- package/dist/types.js.map +1 -1
- package/dist/useAdminApi.d.ts +1 -0
- package/dist/useAdminApi.d.ts.map +1 -0
- package/dist/useAdminApi.js +6 -61
- package/dist/useAdminApi.js.map +1 -1
- package/dist/useAdminBackgroundTask.d.ts +2 -1
- package/dist/useAdminBackgroundTask.d.ts.map +1 -0
- package/dist/useAdminBackgroundTask.js +18 -3
- package/dist/useAdminBackgroundTask.js.map +1 -1
- package/dist/useAdminConfig.d.ts +1 -0
- package/dist/useAdminConfig.d.ts.map +1 -0
- package/dist/useAdminConfig.js +15 -1
- package/dist/useAdminConfig.js.map +1 -1
- package/dist/useAdminMigrations.d.ts +41 -0
- package/dist/useAdminMigrations.d.ts.map +1 -0
- package/dist/useAdminMigrations.js +43 -0
- package/dist/useAdminMigrations.js.map +1 -0
- package/dist/useAdminRoles.d.ts +2 -0
- package/dist/useAdminRoles.d.ts.map +1 -0
- package/dist/useAdminRoles.js +45 -10
- package/dist/useAdminRoles.js.map +1 -1
- package/dist/useAdminRpc.d.ts +29 -0
- package/dist/useAdminRpc.d.ts.map +1 -0
- package/dist/useAdminRpc.js +125 -0
- package/dist/useAdminRpc.js.map +1 -0
- package/dist/useAdminScripts.d.ts +1 -0
- package/dist/useAdminScripts.d.ts.map +1 -0
- package/dist/useAdminScripts.js +61 -9
- package/dist/useAdminScripts.js.map +1 -1
- package/dist/useConfigurationApi.d.ts +1 -0
- package/dist/useConfigurationApi.d.ts.map +1 -0
- package/dist/useConfigurationApi.js +23 -0
- package/dist/useConfigurationApi.js.map +1 -1
- package/dist/useConsentHistory.d.ts +1 -0
- package/dist/useConsentHistory.d.ts.map +1 -0
- package/dist/useConsentHistory.js +10 -3
- package/dist/useConsentHistory.js.map +1 -1
- package/dist/useDocumentStorageApi.d.ts +1 -0
- package/dist/useDocumentStorageApi.d.ts.map +1 -0
- package/dist/useDocumentStorageApi.js +73 -1
- package/dist/useDocumentStorageApi.js.map +1 -1
- package/dist/widgets/AIRequestsScreenWidget.d.ts +1 -0
- package/dist/widgets/AIRequestsScreenWidget.d.ts.map +1 -0
- package/dist/widgets/AIRequestsScreenWidget.js +19 -10
- package/dist/widgets/AIRequestsScreenWidget.js.map +1 -1
- package/dist/widgets/CustomScreensListWidget.d.ts +1 -0
- package/dist/widgets/CustomScreensListWidget.d.ts.map +1 -0
- package/dist/widgets/CustomScreensListWidget.js +2 -6
- package/dist/widgets/CustomScreensListWidget.js.map +1 -1
- package/dist/widgets/DocumentsScreenWidget.d.ts +1 -0
- package/dist/widgets/DocumentsScreenWidget.d.ts.map +1 -0
- package/dist/widgets/FeatureFlagsOverridesWidget.d.ts +1 -0
- package/dist/widgets/FeatureFlagsOverridesWidget.d.ts.map +1 -0
- package/dist/widgets/MissingWidget.d.ts +1 -0
- package/dist/widgets/MissingWidget.d.ts.map +1 -0
- package/dist/widgets/ModelsGridWidget.d.ts +1 -0
- package/dist/widgets/ModelsGridWidget.d.ts.map +1 -0
- package/dist/widgets/ModelsGridWidget.js +10 -4
- package/dist/widgets/ModelsGridWidget.js.map +1 -1
- package/dist/widgets/RecentActivityWidget.d.ts +1 -0
- package/dist/widgets/RecentActivityWidget.d.ts.map +1 -0
- package/dist/widgets/RecentActivityWidget.js +16 -11
- package/dist/widgets/RecentActivityWidget.js.map +1 -1
- package/dist/widgets/ScriptRunnerWidget.d.ts +1 -0
- package/dist/widgets/ScriptRunnerWidget.d.ts.map +1 -0
- package/dist/widgets/VersionConfigScreenWidget.d.ts +1 -0
- package/dist/widgets/VersionConfigScreenWidget.d.ts.map +1 -0
- package/dist/widgets/VersionConfigWidget.d.ts +1 -0
- package/dist/widgets/VersionConfigWidget.d.ts.map +1 -0
- package/dist/widgets/builtInFieldWidgets.d.ts +1 -0
- package/dist/widgets/builtInFieldWidgets.d.ts.map +1 -0
- package/dist/widgets/builtInFieldWidgets.js +3 -5
- package/dist/widgets/builtInFieldWidgets.js.map +1 -1
- package/dist/widgets/builtInWidgets.d.ts +1 -0
- package/dist/widgets/builtInWidgets.d.ts.map +1 -0
- package/dist/widgets/builtInWidgets.js +20 -5
- package/dist/widgets/builtInWidgets.js.map +1 -1
- package/dist/widgets/consentWidgets.d.ts +1 -0
- package/dist/widgets/consentWidgets.d.ts.map +1 -0
- package/dist/widgets/homeWidgetUtils.d.ts +1 -1
- package/dist/widgets/homeWidgetUtils.d.ts.map +1 -0
- package/dist/widgets/homeWidgetUtils.js +1 -9
- package/dist/widgets/homeWidgetUtils.js.map +1 -1
- package/package.json +9 -7
- package/src/AdminActionMenu.test.tsx +167 -0
- package/src/AdminBreadcrumbs.test.tsx +21 -1
- package/src/AdminConflictSheet.test.tsx +173 -0
- package/src/AdminConflictSheet.tsx +102 -0
- package/src/AdminHome.test.tsx +10 -11
- package/src/AdminHome.tsx +2 -4
- package/src/AdminMigrations.tsx +45 -0
- package/src/AdminMigrationsView.tsx +225 -0
- package/src/{AdminModelForm.test.tsx → AdminModelForm.isolated.tsx} +461 -154
- package/src/AdminModelForm.orgSkip.test.tsx +81 -0
- package/src/AdminModelForm.tsx +227 -56
- package/src/AdminModelForm.updateDepth.test.tsx +427 -0
- package/src/AdminModelList.test.tsx +12 -2
- package/src/AdminModelTable.test.tsx +560 -57
- package/src/AdminModelTable.tsx +430 -73
- package/src/AdminModelTable.windowed.test.tsx +897 -0
- package/src/AdminObjectPicker.tsx +32 -6
- package/src/AdminPrimitiveArrayField.test.tsx +178 -0
- package/src/AdminProvider.test.tsx +213 -3
- package/src/AdminProvider.tsx +39 -7
- package/src/AdminRolesList.test.tsx +197 -0
- package/src/AdminScreenRouter.test.tsx +393 -36
- package/src/AdminScreenRouter.tsx +6 -1
- package/src/AdminScriptList.test.tsx +180 -0
- package/src/AdminShell.test.tsx +595 -1
- package/src/AdminShell.tsx +110 -22
- package/src/AdminVersionConfig.tsx +31 -3
- package/src/AnnouncementEditor.test.tsx +603 -0
- package/src/AnnouncementEditor.tsx +673 -0
- package/src/AnnouncementList.test.tsx +198 -0
- package/src/AnnouncementList.tsx +214 -0
- package/src/AnnouncementOverview.test.tsx +325 -0
- package/src/AnnouncementOverview.tsx +325 -0
- package/src/AnnouncementOverviewScreenWidget.test.tsx +69 -0
- package/src/AnnouncementOverviewScreenWidget.tsx +51 -0
- package/src/CheckboxListEditor.test.tsx +8 -1
- package/src/ConsentFormEditor.test.tsx +28 -29
- package/src/ConsentFormEditor.tsx +27 -3
- package/src/ConsentFormList.test.tsx +12 -11
- package/src/ConsentResponseViewer.test.tsx +10 -11
- package/src/DocumentStorageBrowser.tsx +2 -139
- package/src/adminApiQueryParams.ts +33 -0
- package/src/adminConflictSheetStack.ts +87 -0
- package/src/adminContext.ts +8 -0
- package/src/adminModelListQueryParams.test.ts +60 -1
- package/src/adminModelListQueryParams.ts +89 -30
- package/src/adminRequest.test.ts +216 -0
- package/src/adminRequest.ts +213 -0
- package/src/adminRpc.test.ts +18 -0
- package/src/adminRpc.ts +31 -0
- package/src/adminScriptsHarness.test.ts +21 -0
- package/src/adminShellNav.test.ts +72 -6
- package/src/adminShellNav.ts +55 -10
- package/src/adminWindowRefresh.test.ts +65 -0
- package/src/adminWindowRefresh.ts +76 -0
- package/src/adminWindowedTable.test.ts +90 -0
- package/src/adminWindowedTable.ts +55 -0
- package/src/comms/CommsDashboardScreen.test.tsx +2 -2
- package/src/comms/commsDashboardParams.ts +1 -1
- package/src/comms/commsMessagePayload.ts +1 -1
- package/src/comms/useCommsDashboardApi.tsx +57 -4
- package/src/index.tsx +79 -1
- package/src/isAuditLogModel.test.ts +14 -0
- package/src/isAuditLogModel.ts +11 -0
- package/src/isolated/AIRequestsScreenWidget.isolated.tsx +84 -0
- package/src/isolated/AdminFieldRenderer.isolated.tsx +160 -0
- package/src/isolated/AdminFilterDrawer.isolated.tsx +215 -2
- package/src/isolated/AdminFilterDrawerMobile.isolated.tsx +172 -0
- package/src/isolated/AdminHomeWidgets.isolated.tsx +73 -0
- package/src/isolated/AdminObjectPicker.isolated.tsx +7 -0
- package/src/isolated/AdminScriptList.isolated.tsx +124 -0
- package/src/isolated/AdminScriptRunModal.isolated.tsx +274 -4
- package/src/isolated/DocumentStorageBrowser.isolated.tsx +13 -0
- package/src/isolated/RecentActivityWidget.isolated.tsx +138 -0
- package/src/isolated/adminWidgets.isolated.tsx +190 -0
- package/src/isolated/generateConsentHistoryPdf.isolated.ts +251 -0
- package/src/isolated/generateConsentPdfMobile.isolated.ts +87 -0
- package/src/isolated/generateConsentPdfsMobile.isolated.ts +129 -0
- package/src/isolated/hooks.isolated.tsx +245 -3
- package/src/isolated/rpcDualRun.isolated.tsx +449 -0
- package/src/isolated/useAdminScripts.isolated.tsx +156 -0
- package/src/isolated/useJobsDashboardApi.isolated.tsx +60 -0
- package/src/jobs/JobsDashboardScreen.test.tsx +310 -0
- package/src/jobs/JobsDashboardScreen.tsx +461 -0
- package/src/jobs/JobsDashboardScreenWidget.test.tsx +83 -0
- package/src/jobs/JobsDashboardScreenWidget.tsx +20 -0
- package/src/jobs/JobsHomeWidget.test.tsx +92 -0
- package/src/jobs/JobsHomeWidget.tsx +53 -0
- package/src/jobs/JobsJobDetail.test.tsx +253 -0
- package/src/jobs/JobsJobDetail.tsx +278 -0
- package/src/jobs/JobsStatusBadge.tsx +16 -0
- package/src/jobs/jobPayload.ts +114 -0
- package/src/jobs/jobsDashboardParams.test.ts +80 -0
- package/src/jobs/jobsDashboardParams.ts +84 -0
- package/src/jobs/useJobsDashboardApi.test.tsx +152 -0
- package/src/jobs/useJobsDashboardApi.tsx +132 -0
- package/src/jobs/useJobsDashboardUrlFilters.test.tsx +31 -0
- package/src/jobs/useJobsDashboardUrlFilters.tsx +31 -0
- package/src/orgs/OrgDirectoryScreen.test.tsx +184 -0
- package/src/orgs/OrgDirectoryScreen.tsx +200 -0
- package/src/orgs/OrgManagementScreens.test.tsx +270 -0
- package/src/orgs/OrgMembersScreen.tsx +254 -0
- package/src/orgs/OrgSettingsScreen.tsx +145 -0
- package/src/orgs/OrgSwitcher.test.tsx +145 -0
- package/src/orgs/OrgSwitcher.tsx +101 -0
- package/src/orgs/adminModelEndpoints.test.ts +156 -0
- package/src/orgs/adminModelEndpoints.ts +96 -0
- package/src/orgs/normalizeListData.test.ts +17 -0
- package/src/orgs/normalizeListData.ts +13 -0
- package/src/orgs/orgSwitcherOscillation.test.tsx +107 -0
- package/src/orgs/organizationSettings.test.ts +11 -0
- package/src/orgs/organizationSettings.ts +22 -0
- package/src/orgs/shouldSkipOrgScopedAdminQuery.test.ts +22 -0
- package/src/orgs/shouldSkipOrgScopedAdminQuery.ts +7 -0
- package/src/orgs/sortOrganizations.test.ts +13 -0
- package/src/orgs/sortOrganizations.ts +14 -0
- package/src/orgs/useOrgContext.test.tsx +94 -0
- package/src/orgs/useOrgContext.tsx +90 -0
- package/src/orgs/useOrganizationsApi.test.tsx +165 -0
- package/src/orgs/useOrganizationsApi.ts +118 -0
- package/src/pdfUtils.test.ts +37 -0
- package/src/pdfUtils.ts +2 -2
- package/src/testing/useAdminApiDouble.ts +70 -0
- package/src/types.ts +92 -4
- package/src/useAdminApi.test.ts +88 -0
- package/src/useAdminApi.ts +7 -65
- package/src/useAdminBackgroundTask.ts +20 -4
- package/src/useAdminConfig.ts +20 -2
- package/src/useAdminMigrations.test.tsx +75 -0
- package/src/useAdminMigrations.ts +77 -0
- package/src/useAdminRoles.test.ts +28 -0
- package/src/useAdminRoles.ts +40 -0
- package/src/useAdminRpc.test.tsx +250 -0
- package/src/useAdminRpc.ts +173 -0
- package/src/useAdminScripts.ts +67 -0
- package/src/useConfigurationApi.ts +24 -0
- package/src/useConsentHistory.ts +15 -2
- package/src/useDocumentStorageApi.ts +77 -0
- package/src/widgets/AIRequestsScreenWidget.test.tsx +154 -0
- package/src/widgets/AIRequestsScreenWidget.tsx +21 -7
- package/src/widgets/ModelsGridWidget.test.tsx +91 -0
- package/src/widgets/ModelsGridWidget.tsx +11 -1
- package/src/widgets/RecentActivityWidget.tsx +10 -3
- package/src/widgets/builtInFieldWidgets.test.tsx +166 -0
- package/src/widgets/builtInWidgets.ts +6 -0
- package/src/widgets/homeWidgetUtils.ts +0 -9
- package/src/widgets/pluginWidgets.test.tsx +10 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import {describe, it} from "bun:test";
|
|
2
|
+
import {assert} from "chai";
|
|
3
|
+
import type {EndpointBuilder} from "../types";
|
|
4
|
+
import {adminOrganizationHeaders, buildAdminModelEndpoints} from "./adminModelEndpoints";
|
|
5
|
+
|
|
6
|
+
interface EndpointDefinition {
|
|
7
|
+
invalidatesTags?: string[] | unknown;
|
|
8
|
+
providesTags?: unknown;
|
|
9
|
+
query: (args: unknown) => Record<string, unknown>;
|
|
10
|
+
serializeQueryArgs?: (args: {endpointName: string; queryArgs: unknown}) => string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const build = {
|
|
14
|
+
mutation: (definition: EndpointDefinition): EndpointDefinition => definition,
|
|
15
|
+
query: (definition: EndpointDefinition): EndpointDefinition => definition,
|
|
16
|
+
} as unknown as EndpointBuilder;
|
|
17
|
+
|
|
18
|
+
const buildFoodEndpoints = (organizationId: string | undefined) =>
|
|
19
|
+
buildAdminModelEndpoints(build, {
|
|
20
|
+
headers: adminOrganizationHeaders(organizationId),
|
|
21
|
+
modelName: "Food",
|
|
22
|
+
organizationId,
|
|
23
|
+
routePath: "/admin/foods",
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe("adminModelEndpoints", () => {
|
|
27
|
+
it("omits organization headers when no organization is selected", () => {
|
|
28
|
+
assert.isUndefined(adminOrganizationHeaders(undefined));
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("sends X-Organization-Id on list, read, and write endpoints", () => {
|
|
32
|
+
const endpoints = buildFoodEndpoints("org-1");
|
|
33
|
+
const list = endpoints.adminList_Food as EndpointDefinition;
|
|
34
|
+
const read = endpoints.adminRead_Food as EndpointDefinition;
|
|
35
|
+
const create = endpoints.adminCreate_Food as EndpointDefinition;
|
|
36
|
+
const update = endpoints.adminUpdate_Food as EndpointDefinition;
|
|
37
|
+
const deleteEndpoint = endpoints.adminDelete_Food as EndpointDefinition;
|
|
38
|
+
const bulkPatch = endpoints.adminBulkPatch_Food as EndpointDefinition;
|
|
39
|
+
|
|
40
|
+
assert.deepEqual(list.query(undefined).headers, {"X-Organization-Id": "org-1"});
|
|
41
|
+
assert.deepEqual(list.query({page: 1}).headers, {"X-Organization-Id": "org-1"});
|
|
42
|
+
assert.deepEqual(read.query("food-1").headers, {"X-Organization-Id": "org-1"});
|
|
43
|
+
assert.deepEqual(create.query({name: "Soup"}).headers, {"X-Organization-Id": "org-1"});
|
|
44
|
+
assert.deepEqual(update.query({body: {name: "Stew"}, id: "food-1"}).headers, {
|
|
45
|
+
"X-Organization-Id": "org-1",
|
|
46
|
+
});
|
|
47
|
+
assert.deepEqual(deleteEndpoint.query("food-1").headers, {"X-Organization-Id": "org-1"});
|
|
48
|
+
assert.deepEqual(bulkPatch.query({ids: ["food-1"], patch: {disabled: true}}).headers, {
|
|
49
|
+
"X-Organization-Id": "org-1",
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("builds every CRUD query and invalidates the collection or row tags", () => {
|
|
54
|
+
const endpoints = buildFoodEndpoints("org-1");
|
|
55
|
+
const list = endpoints.adminList_Food as EndpointDefinition;
|
|
56
|
+
const read = endpoints.adminRead_Food as EndpointDefinition;
|
|
57
|
+
const create = endpoints.adminCreate_Food as EndpointDefinition;
|
|
58
|
+
const update = endpoints.adminUpdate_Food as EndpointDefinition;
|
|
59
|
+
const deleteEndpoint = endpoints.adminDelete_Food as EndpointDefinition;
|
|
60
|
+
const bulkPatch = endpoints.adminBulkPatch_Food as EndpointDefinition;
|
|
61
|
+
|
|
62
|
+
assert.deepEqual(list.query(undefined), {
|
|
63
|
+
headers: {"X-Organization-Id": "org-1"},
|
|
64
|
+
method: "GET",
|
|
65
|
+
url: "/admin/foods",
|
|
66
|
+
});
|
|
67
|
+
assert.deepEqual(read.query("food-1"), {
|
|
68
|
+
headers: {"X-Organization-Id": "org-1"},
|
|
69
|
+
method: "GET",
|
|
70
|
+
url: "/admin/foods/food-1",
|
|
71
|
+
});
|
|
72
|
+
assert.deepEqual(create.query({name: "Soup"}), {
|
|
73
|
+
body: {name: "Soup"},
|
|
74
|
+
headers: {"X-Organization-Id": "org-1"},
|
|
75
|
+
method: "POST",
|
|
76
|
+
url: "/admin/foods",
|
|
77
|
+
});
|
|
78
|
+
assert.deepEqual(update.query({body: {name: "Stew"}, id: "food-1"}), {
|
|
79
|
+
body: {name: "Stew"},
|
|
80
|
+
headers: {"X-Organization-Id": "org-1"},
|
|
81
|
+
method: "PATCH",
|
|
82
|
+
url: "/admin/foods/food-1",
|
|
83
|
+
});
|
|
84
|
+
assert.deepEqual(deleteEndpoint.query("food-1"), {
|
|
85
|
+
headers: {"X-Organization-Id": "org-1"},
|
|
86
|
+
method: "DELETE",
|
|
87
|
+
url: "/admin/foods/food-1",
|
|
88
|
+
});
|
|
89
|
+
assert.deepEqual(bulkPatch.query({ids: ["food-1"], patch: {disabled: true}}), {
|
|
90
|
+
body: {ids: ["food-1"], patch: {disabled: true}},
|
|
91
|
+
headers: {"X-Organization-Id": "org-1"},
|
|
92
|
+
method: "POST",
|
|
93
|
+
url: "/admin/foods/bulk-patch",
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
assert.deepEqual(list.providesTags, ["admin_Food"]);
|
|
97
|
+
assert.deepEqual(create.invalidatesTags, ["admin_Food"]);
|
|
98
|
+
assert.deepEqual(deleteEndpoint.invalidatesTags, ["admin_Food"]);
|
|
99
|
+
assert.deepEqual(bulkPatch.invalidatesTags, ["admin_Food"]);
|
|
100
|
+
|
|
101
|
+
const readProvidesTags = read.providesTags as (
|
|
102
|
+
result: unknown,
|
|
103
|
+
error: unknown,
|
|
104
|
+
id: string
|
|
105
|
+
) => unknown;
|
|
106
|
+
assert.deepEqual(readProvidesTags(undefined, undefined, "food-1"), [
|
|
107
|
+
{id: "food-1", type: "admin_Food"},
|
|
108
|
+
]);
|
|
109
|
+
|
|
110
|
+
const updateInvalidatesTags = update.invalidatesTags as (
|
|
111
|
+
result: unknown,
|
|
112
|
+
error: unknown,
|
|
113
|
+
args: {id: string}
|
|
114
|
+
) => unknown;
|
|
115
|
+
assert.deepEqual(updateInvalidatesTags(undefined, undefined, {id: "food-1"}), [
|
|
116
|
+
{id: "food-1", type: "admin_Food"},
|
|
117
|
+
"admin_Food",
|
|
118
|
+
]);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("rebuilds list and read cache keys when the selected organization changes", () => {
|
|
122
|
+
const first = buildFoodEndpoints("org-1");
|
|
123
|
+
const second = buildFoodEndpoints("org-2");
|
|
124
|
+
const firstList = first.adminList_Food as EndpointDefinition;
|
|
125
|
+
const secondList = second.adminList_Food as EndpointDefinition;
|
|
126
|
+
const firstRead = first.adminRead_Food as EndpointDefinition;
|
|
127
|
+
const secondRead = second.adminRead_Food as EndpointDefinition;
|
|
128
|
+
|
|
129
|
+
assert.notEqual(
|
|
130
|
+
firstList.serializeQueryArgs?.({endpointName: "adminList_Food", queryArgs: {}}),
|
|
131
|
+
secondList.serializeQueryArgs?.({endpointName: "adminList_Food", queryArgs: {}})
|
|
132
|
+
);
|
|
133
|
+
assert.notEqual(
|
|
134
|
+
firstRead.serializeQueryArgs?.({endpointName: "adminRead_Food", queryArgs: "food-1"}),
|
|
135
|
+
secondRead.serializeQueryArgs?.({endpointName: "adminRead_Food", queryArgs: "food-1"})
|
|
136
|
+
);
|
|
137
|
+
assert.equal(
|
|
138
|
+
firstList.serializeQueryArgs?.({endpointName: "adminList_Food", queryArgs: undefined}),
|
|
139
|
+
"adminList_Food:org-1:{}"
|
|
140
|
+
);
|
|
141
|
+
assert.equal(
|
|
142
|
+
firstRead.serializeQueryArgs?.({endpointName: "adminRead_Food", queryArgs: "food-1"}),
|
|
143
|
+
"adminRead_Food:org-1:food-1"
|
|
144
|
+
);
|
|
145
|
+
assert.equal(
|
|
146
|
+
buildFoodEndpoints(undefined).adminList_Food.serializeQueryArgs?.({
|
|
147
|
+
endpointName: "adminList_Food",
|
|
148
|
+
queryArgs: undefined,
|
|
149
|
+
}),
|
|
150
|
+
"adminList_Food::{}"
|
|
151
|
+
);
|
|
152
|
+
assert.deepEqual((second.adminList_Food as EndpointDefinition).query({}).headers, {
|
|
153
|
+
"X-Organization-Id": "org-2",
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {buildAdminApiListQueryRequest} from "../adminApiQueryParams";
|
|
2
|
+
import type {EndpointBuilder} from "../types";
|
|
3
|
+
|
|
4
|
+
type AdminPayload = Record<string, unknown>;
|
|
5
|
+
type TagArg = unknown;
|
|
6
|
+
|
|
7
|
+
export interface AdminModelEndpointContext {
|
|
8
|
+
headers: Record<string, string> | undefined;
|
|
9
|
+
modelName: string;
|
|
10
|
+
organizationId: string | undefined;
|
|
11
|
+
routePath: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const adminOrganizationHeaders = (
|
|
15
|
+
organizationId: string | undefined
|
|
16
|
+
): Record<string, string> | undefined => {
|
|
17
|
+
if (!organizationId) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return {"X-Organization-Id": organizationId};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const buildAdminModelEndpoints = (
|
|
24
|
+
build: EndpointBuilder,
|
|
25
|
+
context: AdminModelEndpointContext
|
|
26
|
+
) => {
|
|
27
|
+
const listKey = `adminList_${context.modelName}`;
|
|
28
|
+
const readKey = `adminRead_${context.modelName}`;
|
|
29
|
+
const createKey = `adminCreate_${context.modelName}`;
|
|
30
|
+
const updateKey = `adminUpdate_${context.modelName}`;
|
|
31
|
+
const deleteKey = `adminDelete_${context.modelName}`;
|
|
32
|
+
const bulkPatchKey = `adminBulkPatch_${context.modelName}`;
|
|
33
|
+
const {headers, organizationId, routePath} = context;
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
[listKey]: build.query({
|
|
37
|
+
providesTags: [`admin_${context.modelName}`],
|
|
38
|
+
query: (params: Record<string, unknown> | undefined) => ({
|
|
39
|
+
...buildAdminApiListQueryRequest(routePath, params),
|
|
40
|
+
headers,
|
|
41
|
+
}),
|
|
42
|
+
serializeQueryArgs: ({endpointName, queryArgs}) =>
|
|
43
|
+
`${endpointName}:${organizationId ?? ""}:${JSON.stringify(queryArgs ?? {})}`,
|
|
44
|
+
}),
|
|
45
|
+
[readKey]: build.query({
|
|
46
|
+
providesTags: (_result: TagArg, _error: TagArg, id: string) => [
|
|
47
|
+
{id, type: `admin_${context.modelName}`},
|
|
48
|
+
],
|
|
49
|
+
query: (id: string) => ({
|
|
50
|
+
headers,
|
|
51
|
+
method: "GET",
|
|
52
|
+
url: `${routePath}/${id}`,
|
|
53
|
+
}),
|
|
54
|
+
serializeQueryArgs: ({endpointName, queryArgs}) =>
|
|
55
|
+
`${endpointName}:${organizationId ?? ""}:${String(queryArgs)}`,
|
|
56
|
+
}),
|
|
57
|
+
[createKey]: build.mutation({
|
|
58
|
+
invalidatesTags: [`admin_${context.modelName}`],
|
|
59
|
+
query: (body: AdminPayload) => ({
|
|
60
|
+
body,
|
|
61
|
+
headers,
|
|
62
|
+
method: "POST",
|
|
63
|
+
url: routePath,
|
|
64
|
+
}),
|
|
65
|
+
}),
|
|
66
|
+
[updateKey]: build.mutation({
|
|
67
|
+
invalidatesTags: (_result: TagArg, _error: TagArg, {id}: {id: string}) => [
|
|
68
|
+
{id, type: `admin_${context.modelName}`},
|
|
69
|
+
`admin_${context.modelName}`,
|
|
70
|
+
],
|
|
71
|
+
query: ({id, body}: {id: string; body: AdminPayload}) => ({
|
|
72
|
+
body,
|
|
73
|
+
headers,
|
|
74
|
+
method: "PATCH",
|
|
75
|
+
url: `${routePath}/${id}`,
|
|
76
|
+
}),
|
|
77
|
+
}),
|
|
78
|
+
[deleteKey]: build.mutation({
|
|
79
|
+
invalidatesTags: [`admin_${context.modelName}`],
|
|
80
|
+
query: (id: string) => ({
|
|
81
|
+
headers,
|
|
82
|
+
method: "DELETE",
|
|
83
|
+
url: `${routePath}/${id}`,
|
|
84
|
+
}),
|
|
85
|
+
}),
|
|
86
|
+
[bulkPatchKey]: build.mutation({
|
|
87
|
+
invalidatesTags: [`admin_${context.modelName}`],
|
|
88
|
+
query: ({ids, patch}: {ids: string[]; patch: Record<string, unknown>}) => ({
|
|
89
|
+
body: {ids, patch},
|
|
90
|
+
headers,
|
|
91
|
+
method: "POST",
|
|
92
|
+
url: `${routePath}/bulk-patch`,
|
|
93
|
+
}),
|
|
94
|
+
}),
|
|
95
|
+
};
|
|
96
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {describe, expect, it} from "bun:test";
|
|
2
|
+
import {normalizeListData} from "./normalizeListData";
|
|
3
|
+
|
|
4
|
+
describe("normalizeListData", () => {
|
|
5
|
+
it("returns a bare array from the RTK-unwrapped shape", () => {
|
|
6
|
+
expect(normalizeListData([{_id: "org-1"}])).toEqual([{_id: "org-1"}]);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("returns data from the JSON API envelope shape", () => {
|
|
10
|
+
expect(normalizeListData({data: [{_id: "org-1"}]})).toEqual([{_id: "org-1"}]);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("returns an empty array when data is missing", () => {
|
|
14
|
+
expect(normalizeListData(undefined)).toEqual([]);
|
|
15
|
+
expect(normalizeListData({})).toEqual([]);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@terreno/rtk`'s base query unwraps `{data}` for responses without pagination
|
|
3
|
+
* metadata (`more`), so list hooks may receive a bare array. Custom base queries
|
|
4
|
+
* may still pass the JSON API envelope.
|
|
5
|
+
*/
|
|
6
|
+
export type ListQueryData<T> = T[] | {data?: T[]} | undefined;
|
|
7
|
+
|
|
8
|
+
export const normalizeListData = <T>(data: ListQueryData<T>): T[] => {
|
|
9
|
+
if (Array.isArray(data)) {
|
|
10
|
+
return data;
|
|
11
|
+
}
|
|
12
|
+
return data?.data ?? [];
|
|
13
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {beforeEach, describe, expect, it, mock} from "bun:test";
|
|
2
|
+
import {act, fireEvent} from "@testing-library/react-native";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import {Text} from "react-native";
|
|
5
|
+
import {renderWithTheme} from "../../../ui/src/test-utils";
|
|
6
|
+
import {OrgSettingsScreen} from "./OrgSettingsScreen";
|
|
7
|
+
import {OrgSwitcher} from "./OrgSwitcher";
|
|
8
|
+
import {OrgContextProvider, useOrgContext} from "./useOrgContext";
|
|
9
|
+
|
|
10
|
+
const mineState: {data?: unknown; error?: unknown; isLoading: boolean} = {isLoading: false};
|
|
11
|
+
const readState: {
|
|
12
|
+
data?: unknown;
|
|
13
|
+
error?: unknown;
|
|
14
|
+
isFetching: boolean;
|
|
15
|
+
isLoading: boolean;
|
|
16
|
+
} = {
|
|
17
|
+
data: {_id: "org-alpha", name: "Alpha Workspace"},
|
|
18
|
+
isFetching: false,
|
|
19
|
+
isLoading: false,
|
|
20
|
+
};
|
|
21
|
+
const routerPush = mock(() => {});
|
|
22
|
+
|
|
23
|
+
mock.module("expo-router", () => ({router: {push: routerPush}}));
|
|
24
|
+
|
|
25
|
+
import type {AdminApi} from "../types";
|
|
26
|
+
|
|
27
|
+
const createApi = (): AdminApi => {
|
|
28
|
+
const api = {
|
|
29
|
+
enhanceEndpoints: () => api,
|
|
30
|
+
injectEndpoints: () => ({
|
|
31
|
+
useOrgMineQuery: () => mineState,
|
|
32
|
+
useOrgReadQuery: () => readState,
|
|
33
|
+
useOrgUpdateMutation: () => [mock(() => ({unwrap: async () => ({})})), {isLoading: false}],
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
36
|
+
return api as unknown as AdminApi;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const ContextProbe: React.FC = () => {
|
|
40
|
+
const {organization} = useOrgContext();
|
|
41
|
+
return <Text testID="org-context-probe">{organization?.name ?? "none"}</Text>;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
describe("org switcher oscillation", () => {
|
|
45
|
+
const api = createApi();
|
|
46
|
+
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
mineState.data = {
|
|
49
|
+
data: [
|
|
50
|
+
{_id: "org-alpha", name: "Alpha Workspace"},
|
|
51
|
+
{_id: "org-beta", name: "Beta Workspace"},
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
mineState.error = undefined;
|
|
55
|
+
mineState.isLoading = false;
|
|
56
|
+
readState.data = {_id: "org-alpha", name: "Alpha Workspace"};
|
|
57
|
+
readState.error = undefined;
|
|
58
|
+
readState.isFetching = false;
|
|
59
|
+
readState.isLoading = false;
|
|
60
|
+
routerPush.mockClear();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("keeps switcher selection when OrgSettingsScreen still serves the previous route org", async () => {
|
|
64
|
+
const screen = renderWithTheme(
|
|
65
|
+
<OrgContextProvider initialOrganization={{_id: "org-alpha", name: "Alpha Workspace"}}>
|
|
66
|
+
<OrgSwitcher api={api} routeBase="/admin" />
|
|
67
|
+
<OrgSettingsScreen api={api} organizationId="org-alpha" routeBase="/admin" />
|
|
68
|
+
<ContextProbe />
|
|
69
|
+
</OrgContextProvider>
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
await act(async () => {
|
|
73
|
+
fireEvent(screen.getByTestId("web_dropdown_option_org-beta"), "press");
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
expect(routerPush).toHaveBeenCalledWith("/admin/orgs/org-beta");
|
|
77
|
+
expect(screen.getByTestId("org-context-probe").props.children).toBe("Beta Workspace");
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("ignores stale RTK read data for a different route organization id", () => {
|
|
81
|
+
readState.data = {_id: "org-alpha", name: "Alpha Workspace"};
|
|
82
|
+
const screen = renderWithTheme(
|
|
83
|
+
<OrgContextProvider initialOrganization={{_id: "org-beta", name: "Beta Workspace"}}>
|
|
84
|
+
<OrgSwitcher api={api} routeBase="/admin" />
|
|
85
|
+
<OrgSettingsScreen api={api} organizationId="org-beta" routeBase="/admin" />
|
|
86
|
+
<ContextProbe />
|
|
87
|
+
</OrgContextProvider>
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
expect(screen.queryByTestId("org-settings-save")).toBeNull();
|
|
91
|
+
expect(screen.getByTestId("org-context-probe").props.children).toBe("Beta Workspace");
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("renders beta settings after the route-scoped read query catches up", async () => {
|
|
95
|
+
readState.data = {_id: "org-beta", name: "Beta Workspace"};
|
|
96
|
+
const screen = renderWithTheme(
|
|
97
|
+
<OrgContextProvider initialOrganization={{_id: "org-beta", name: "Beta Workspace"}}>
|
|
98
|
+
<OrgSwitcher api={api} routeBase="/admin" />
|
|
99
|
+
<OrgSettingsScreen api={api} organizationId="org-beta" routeBase="/admin" />
|
|
100
|
+
<ContextProbe />
|
|
101
|
+
</OrgContextProvider>
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
expect(screen.getByTestId("org-settings-save")).toBeTruthy();
|
|
105
|
+
expect(screen.getByTestId("org-context-probe").props.children).toBe("Beta Workspace");
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {describe, it} from "bun:test";
|
|
2
|
+
import {assert} from "chai";
|
|
3
|
+
|
|
4
|
+
import {organizationSettingsOf} from "./organizationSettings";
|
|
5
|
+
|
|
6
|
+
describe("organizationSettingsOf", () => {
|
|
7
|
+
it("returns {} when settings are missing and the stored object when present", () => {
|
|
8
|
+
assert.deepEqual(organizationSettingsOf({}), {});
|
|
9
|
+
assert.deepEqual(organizationSettingsOf({settings: {timezone: "UTC"}}), {timezone: "UTC"});
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App-defined organization settings. Augment this interface in the host app:
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* declare module "@terreno/admin-frontend" {
|
|
6
|
+
* interface OrganizationSettings {
|
|
7
|
+
* timezone?: string;
|
|
8
|
+
* }
|
|
9
|
+
* }
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
// biome-ignore lint/suspicious/noEmptyInterface: Declaration merging for consumer settings.
|
|
13
|
+
export interface OrganizationSettings {}
|
|
14
|
+
|
|
15
|
+
/** Read typed settings from an organization payload. */
|
|
16
|
+
export const organizationSettingsOf = <
|
|
17
|
+
TSettings extends OrganizationSettings = OrganizationSettings,
|
|
18
|
+
>(organization: {
|
|
19
|
+
settings?: TSettings | null;
|
|
20
|
+
}): TSettings => {
|
|
21
|
+
return (organization.settings ?? {}) as TSettings;
|
|
22
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {describe, expect, it} from "bun:test";
|
|
2
|
+
import {shouldSkipOrgScopedAdminQuery} from "./shouldSkipOrgScopedAdminQuery";
|
|
3
|
+
|
|
4
|
+
describe("shouldSkipOrgScopedAdminQuery", () => {
|
|
5
|
+
it("skips when the model is org-scoped and no organization is selected", () => {
|
|
6
|
+
expect(
|
|
7
|
+
shouldSkipOrgScopedAdminQuery({organizationId: undefined, organizationScoped: true})
|
|
8
|
+
).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("does not skip when organization context is present", () => {
|
|
12
|
+
expect(shouldSkipOrgScopedAdminQuery({organizationId: "org-1", organizationScoped: true})).toBe(
|
|
13
|
+
false
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("does not skip for non-org-scoped models", () => {
|
|
18
|
+
expect(
|
|
19
|
+
shouldSkipOrgScopedAdminQuery({organizationId: undefined, organizationScoped: false})
|
|
20
|
+
).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {describe, expect, it} from "bun:test";
|
|
2
|
+
import {sortOrganizations} from "./sortOrganizations";
|
|
3
|
+
|
|
4
|
+
describe("sortOrganizations", () => {
|
|
5
|
+
it("orders by name then id", () => {
|
|
6
|
+
const sorted = sortOrganizations([
|
|
7
|
+
{_id: "org-z", name: "Zulu"},
|
|
8
|
+
{_id: "org-b", name: "Alpha"},
|
|
9
|
+
{_id: "org-a", name: "Alpha"},
|
|
10
|
+
]);
|
|
11
|
+
expect(sorted.map((org) => org._id)).toEqual(["org-a", "org-b", "org-z"]);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface NamedOrganization {
|
|
2
|
+
_id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/** Stable ordering for deterministic default org selection (name, then id). */
|
|
7
|
+
export const sortOrganizations = <T extends NamedOrganization>(organizations: T[]): T[] =>
|
|
8
|
+
[...organizations].sort((left, right) => {
|
|
9
|
+
const byName = left.name.localeCompare(right.name);
|
|
10
|
+
if (byName !== 0) {
|
|
11
|
+
return byName;
|
|
12
|
+
}
|
|
13
|
+
return String(left._id).localeCompare(String(right._id));
|
|
14
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {describe, it} from "bun:test";
|
|
2
|
+
import {act} from "@testing-library/react-native";
|
|
3
|
+
import {assert} from "chai";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import {Text} from "react-native";
|
|
6
|
+
import {renderWithTheme} from "../../../ui/src/test-utils";
|
|
7
|
+
import {
|
|
8
|
+
OrgContextProvider,
|
|
9
|
+
organizationFromPath,
|
|
10
|
+
organizationIdFromPath,
|
|
11
|
+
organizationMatchesRoute,
|
|
12
|
+
useOrgContext,
|
|
13
|
+
} from "./useOrgContext";
|
|
14
|
+
|
|
15
|
+
const OrgIdProbe: React.FC = () => {
|
|
16
|
+
const {organizationId} = useOrgContext();
|
|
17
|
+
return <Text testID="org-id">{organizationId ?? "none"}</Text>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
describe("useOrgContext", () => {
|
|
21
|
+
it("derives organization context from admin organization paths", () => {
|
|
22
|
+
assert.equal(organizationIdFromPath("/admin/orgs/org-alpha"), "org-alpha");
|
|
23
|
+
assert.equal(organizationIdFromPath("/admin/orgs/org-alpha/members"), "org-alpha");
|
|
24
|
+
assert.isUndefined(organizationFromPath("/admin/orgs"));
|
|
25
|
+
assert.deepEqual(organizationFromPath("/admin/orgs/org-alpha"), {
|
|
26
|
+
_id: "org-alpha",
|
|
27
|
+
name: "org-alpha",
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("matches loaded organizations to the active route id", () => {
|
|
32
|
+
assert.isTrue(organizationMatchesRoute({_id: "org-1", name: "Acme"}, "org-1"));
|
|
33
|
+
assert.isFalse(organizationMatchesRoute({_id: "org-1", name: "Acme"}, "org-2"));
|
|
34
|
+
assert.isFalse(organizationMatchesRoute(undefined, "org-1"));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("throws outside OrgContextProvider", () => {
|
|
38
|
+
assert.throws(() => {
|
|
39
|
+
renderWithTheme(<OrgIdProbe />);
|
|
40
|
+
}, /useOrgContext must be used inside OrgContextProvider/);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("keeps the mounted organization when initialOrganization is omitted later", () => {
|
|
44
|
+
const screen = renderWithTheme(
|
|
45
|
+
<OrgContextProvider initialOrganization={{_id: "org-1", name: "Acme"}}>
|
|
46
|
+
<OrgIdProbe />
|
|
47
|
+
</OrgContextProvider>
|
|
48
|
+
);
|
|
49
|
+
assert.equal(screen.getByTestId("org-id").props.children, "org-1");
|
|
50
|
+
|
|
51
|
+
act(() => {
|
|
52
|
+
screen.rerender(
|
|
53
|
+
<OrgContextProvider>
|
|
54
|
+
<OrgIdProbe />
|
|
55
|
+
</OrgContextProvider>
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
assert.equal(screen.getByTestId("org-id").props.children, "org-1");
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("ignores a later initialOrganization with the same id", () => {
|
|
62
|
+
const screen = renderWithTheme(
|
|
63
|
+
<OrgContextProvider initialOrganization={{_id: "org-1", name: "Acme"}}>
|
|
64
|
+
<OrgIdProbe />
|
|
65
|
+
</OrgContextProvider>
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
act(() => {
|
|
69
|
+
screen.rerender(
|
|
70
|
+
<OrgContextProvider initialOrganization={{_id: "org-1", name: "Renamed"}}>
|
|
71
|
+
<OrgIdProbe />
|
|
72
|
+
</OrgContextProvider>
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
assert.equal(screen.getByTestId("org-id").props.children, "org-1");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("syncs context when the route-derived organization id changes", () => {
|
|
79
|
+
const screen = renderWithTheme(
|
|
80
|
+
<OrgContextProvider initialOrganization={{_id: "org-1", name: "Acme"}}>
|
|
81
|
+
<OrgIdProbe />
|
|
82
|
+
</OrgContextProvider>
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
act(() => {
|
|
86
|
+
screen.rerender(
|
|
87
|
+
<OrgContextProvider initialOrganization={{_id: "org-2", name: "Other"}}>
|
|
88
|
+
<OrgIdProbe />
|
|
89
|
+
</OrgContextProvider>
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
assert.equal(screen.getByTestId("org-id").props.children, "org-2");
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React, {createContext, useCallback, useContext, useEffect, useMemo, useState} from "react";
|
|
2
|
+
import type {OrganizationSummary} from "./OrgDirectoryScreen";
|
|
3
|
+
|
|
4
|
+
export interface OrgContextValue {
|
|
5
|
+
organization?: OrganizationSummary;
|
|
6
|
+
organizationId?: string;
|
|
7
|
+
selectOrganization: (organization: OrganizationSummary) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface OrgContextProviderProps {
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
initialOrganization?: OrganizationSummary;
|
|
13
|
+
onOrganizationChange?: (organization: OrganizationSummary) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const OrgContext = createContext<OrgContextValue | null>(null);
|
|
17
|
+
|
|
18
|
+
/** Extract `/orgs/:orgId` from an admin pathname. */
|
|
19
|
+
export const organizationIdFromPath = (pathname: string): string | undefined => {
|
|
20
|
+
const match = pathname.match(/\/orgs\/([^/]+)(?:\/|$)/);
|
|
21
|
+
return match?.[1];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const organizationMatchesRoute = (
|
|
25
|
+
organization: OrganizationSummary | undefined,
|
|
26
|
+
organizationId: string
|
|
27
|
+
): boolean => {
|
|
28
|
+
if (!organization) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return String(organization._id) === String(organizationId);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** Build the route-derived value for `OrgContextProvider.initialOrganization`. */
|
|
35
|
+
export const organizationFromPath = (pathname: string): OrganizationSummary | undefined => {
|
|
36
|
+
const organizationId = organizationIdFromPath(pathname);
|
|
37
|
+
if (!organizationId) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
return {_id: organizationId, name: organizationId};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const OrgContextProvider: React.FC<OrgContextProviderProps> = ({
|
|
44
|
+
children,
|
|
45
|
+
initialOrganization,
|
|
46
|
+
onOrganizationChange,
|
|
47
|
+
}) => {
|
|
48
|
+
const [organization, setOrganization] = useState<OrganizationSummary | undefined>(
|
|
49
|
+
initialOrganization
|
|
50
|
+
);
|
|
51
|
+
// Hosts pass route-derived org ids; sync only when the route id changes, not when
|
|
52
|
+
// OrgSwitcher has already moved context ahead of the URL during navigation.
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!initialOrganization) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
setOrganization((current) => {
|
|
58
|
+
if (current?._id === initialOrganization._id) {
|
|
59
|
+
return current;
|
|
60
|
+
}
|
|
61
|
+
return initialOrganization;
|
|
62
|
+
});
|
|
63
|
+
}, [initialOrganization]);
|
|
64
|
+
const selectOrganization = useCallback(
|
|
65
|
+
(nextOrganization: OrganizationSummary): void => {
|
|
66
|
+
setOrganization(nextOrganization);
|
|
67
|
+
onOrganizationChange?.(nextOrganization);
|
|
68
|
+
},
|
|
69
|
+
[onOrganizationChange]
|
|
70
|
+
);
|
|
71
|
+
const value = useMemo(
|
|
72
|
+
(): OrgContextValue => ({
|
|
73
|
+
organization,
|
|
74
|
+
organizationId: organization?._id,
|
|
75
|
+
selectOrganization,
|
|
76
|
+
}),
|
|
77
|
+
[organization, selectOrganization]
|
|
78
|
+
);
|
|
79
|
+
return <OrgContext.Provider value={value}>{children}</OrgContext.Provider>;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const useOptionalOrgContext = (): OrgContextValue | null => useContext(OrgContext);
|
|
83
|
+
|
|
84
|
+
export const useOrgContext = (): OrgContextValue => {
|
|
85
|
+
const context = useOptionalOrgContext();
|
|
86
|
+
if (!context) {
|
|
87
|
+
throw new Error("useOrgContext must be used inside OrgContextProvider");
|
|
88
|
+
}
|
|
89
|
+
return context;
|
|
90
|
+
};
|