@wildo-ai/saas-frontend-lib 1.1.16 → 1.1.17
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/dist/esm/components/compliance/EmbeddedSigningFrame.d.ts.map +1 -1
- package/dist/esm/components/compliance/EmbeddedSigningFrame.js +17 -6
- package/dist/esm/components/compliance/EmbeddedSigningFrame.js.map +1 -1
- package/dist/esm/components/data-display/approval-seal.d.ts +7 -5
- package/dist/esm/components/data-display/approval-seal.d.ts.map +1 -1
- package/dist/esm/components/data-display/approval-seal.js +10 -4
- package/dist/esm/components/data-display/approval-seal.js.map +1 -1
- package/dist/esm/components/data-display/signature-requests.d.ts +81 -0
- package/dist/esm/components/data-display/signature-requests.d.ts.map +1 -0
- package/dist/esm/components/data-display/signature-requests.js +123 -0
- package/dist/esm/components/data-display/signature-requests.js.map +1 -0
- package/dist/esm/components/flows-actors/approval.d.ts.map +1 -1
- package/dist/esm/components/flows-actors/approval.js +8 -15
- package/dist/esm/components/flows-actors/approval.js.map +1 -1
- package/dist/esm/components/form/automated/ResourceAutomatedForm.d.ts.map +1 -1
- package/dist/esm/components/form/automated/ResourceAutomatedForm.js +44 -29
- package/dist/esm/components/form/automated/ResourceAutomatedForm.js.map +1 -1
- package/dist/esm/components/navigation/NavigationItemBadge.d.ts +16 -0
- package/dist/esm/components/navigation/NavigationItemBadge.d.ts.map +1 -1
- package/dist/esm/components/navigation/NavigationItemBadge.js +14 -2
- package/dist/esm/components/navigation/NavigationItemBadge.js.map +1 -1
- package/dist/esm/components/navigation/app-level/ApplicationLevel_NavigationBack.d.ts +3 -3
- package/dist/esm/components/navigation/app-level/ApplicationLevel_NavigationBack.js +3 -3
- package/dist/esm/components/navigation/app-level/ApplicationLevel_NavigationBack.js.map +1 -1
- package/dist/esm/components/navigation/app-level/SidebarResourceBrowser.d.ts +5 -13
- package/dist/esm/components/navigation/app-level/SidebarResourceBrowser.d.ts.map +1 -1
- package/dist/esm/components/navigation/app-level/SidebarResourceBrowser.js +30 -255
- package/dist/esm/components/navigation/app-level/SidebarResourceBrowser.js.map +1 -1
- package/dist/esm/components/navigation/app-level/useCommandMenuBehavior.d.ts +22 -1
- package/dist/esm/components/navigation/app-level/useCommandMenuBehavior.d.ts.map +1 -1
- package/dist/esm/components/navigation/app-level/useCommandMenuBehavior.js +57 -26
- package/dist/esm/components/navigation/app-level/useCommandMenuBehavior.js.map +1 -1
- package/dist/esm/components/navigation/app-level/useMenuBarBehavior.d.ts +1 -1
- package/dist/esm/components/navigation/app-level/useMenuBarBehavior.d.ts.map +1 -1
- package/dist/esm/components/navigation/app-level/useMenuBarBehavior.js +35 -1
- package/dist/esm/components/navigation/app-level/useMenuBarBehavior.js.map +1 -1
- package/dist/esm/components/navigation/app-level/useMenuUserOrgBehavior.d.ts +1 -1
- package/dist/esm/components/navigation/app-level/useMenuUserOrgBehavior.d.ts.map +1 -1
- package/dist/esm/components/navigation/app-level/useMenuUserOrgBehavior.js +26 -4
- package/dist/esm/components/navigation/app-level/useMenuUserOrgBehavior.js.map +1 -1
- package/dist/esm/components/navigation/app-level/useNavigationBackBehavior.d.ts +31 -0
- package/dist/esm/components/navigation/app-level/useNavigationBackBehavior.d.ts.map +1 -0
- package/dist/esm/components/navigation/app-level/useNavigationBackBehavior.js +42 -0
- package/dist/esm/components/navigation/app-level/useNavigationBackBehavior.js.map +1 -0
- package/dist/esm/components/navigation/app-level/useSidebarResourceBrowser.d.ts +76 -0
- package/dist/esm/components/navigation/app-level/useSidebarResourceBrowser.d.ts.map +1 -0
- package/dist/esm/components/navigation/app-level/useSidebarResourceBrowser.js +268 -0
- package/dist/esm/components/navigation/app-level/useSidebarResourceBrowser.js.map +1 -0
- package/dist/esm/components/navigation/command.d.ts +5 -0
- package/dist/esm/components/navigation/command.d.ts.map +1 -1
- package/dist/esm/components/navigation/command.js.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_DangerZone.d.ts.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_DangerZone.js +5 -2
- package/dist/esm/components/resources/ResourceLayout_DangerZone.js.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_InsertedViews.d.ts.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_InsertedViews.js +5 -1
- package/dist/esm/components/resources/ResourceLayout_InsertedViews.js.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_List.d.ts.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_List.js +4 -1
- package/dist/esm/components/resources/ResourceLayout_List.js.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_RecordSharing.d.ts.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_RecordSharing.js +4 -1
- package/dist/esm/components/resources/ResourceLayout_RecordSharing.js.map +1 -1
- package/dist/esm/components/resources/collection/board/ResourceCollectionBody_Board.d.ts.map +1 -1
- package/dist/esm/components/resources/collection/board/ResourceCollectionBody_Board.js +4 -1
- package/dist/esm/components/resources/collection/board/ResourceCollectionBody_Board.js.map +1 -1
- package/dist/esm/components/resources/collection/calendar/ResourceCollectionBody_Calendar.d.ts.map +1 -1
- package/dist/esm/components/resources/collection/calendar/ResourceCollectionBody_Calendar.js +4 -1
- package/dist/esm/components/resources/collection/calendar/ResourceCollectionBody_Calendar.js.map +1 -1
- package/dist/esm/components/resources/collection/timeline/ResourceCollectionBody_Timeline.d.ts.map +1 -1
- package/dist/esm/components/resources/collection/timeline/ResourceCollectionBody_Timeline.js +4 -1
- package/dist/esm/components/resources/collection/timeline/ResourceCollectionBody_Timeline.js.map +1 -1
- package/dist/esm/components/resources/skeleton/Group.d.ts.map +1 -1
- package/dist/esm/components/resources/skeleton/Group.js +4 -1
- package/dist/esm/components/resources/skeleton/Group.js.map +1 -1
- package/dist/esm/components/sections/ContentSectionContainer.d.ts.map +1 -1
- package/dist/esm/components/sections/ContentSectionContainer.js +11 -7
- package/dist/esm/components/sections/ContentSectionContainer.js.map +1 -1
- package/dist/esm/components/sections/content-section.d.ts +1 -3
- package/dist/esm/components/sections/content-section.d.ts.map +1 -1
- package/dist/esm/components/sections/content-section.js.map +1 -1
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.d.ts.map +1 -1
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.js +2 -1
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.js.map +1 -1
- package/dist/esm/components/settings/AppPage_ConnectedAccountsSettings.d.ts +12 -0
- package/dist/esm/components/settings/AppPage_ConnectedAccountsSettings.d.ts.map +1 -1
- package/dist/esm/components/settings/AppPage_ConnectedAccountsSettings.js +28 -6
- package/dist/esm/components/settings/AppPage_ConnectedAccountsSettings.js.map +1 -1
- package/dist/esm/components/typography/document-heading-level.d.ts +28 -0
- package/dist/esm/components/typography/document-heading-level.d.ts.map +1 -0
- package/dist/esm/components/typography/document-heading-level.js +63 -0
- package/dist/esm/components/typography/document-heading-level.js.map +1 -0
- package/dist/esm/components/views/chart-view/ChartView.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/ChartView.js +20 -16
- package/dist/esm/components/views/chart-view/ChartView.js.map +1 -1
- package/dist/esm/components/views/chart-view/ChartView.labels.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/ChartView.labels.js +7 -0
- package/dist/esm/components/views/chart-view/ChartView.labels.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builder-utils.d.ts +12 -3
- package/dist/esm/components/views/chart-view/option-builder/builder-utils.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builder-utils.js +18 -11
- package/dist/esm/components/views/chart-view/option-builder/builder-utils.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/bar-family.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/bar-family.builder.js +2 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/bar-family.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/funnel.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/funnel.builder.js +7 -3
- package/dist/esm/components/views/chart-view/option-builder/builders/funnel.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/gauge.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/gauge.builder.js +6 -2
- package/dist/esm/components/views/chart-view/option-builder/builders/gauge.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/heatmap.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/heatmap.builder.js +7 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/heatmap.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/hierarchical-family.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/hierarchical-family.builder.js +13 -9
- package/dist/esm/components/views/chart-view/option-builder/builders/hierarchical-family.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/line-family.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/line-family.builder.js +2 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/line-family.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/parallel.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/parallel.builder.js +2 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/parallel.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/pie-family.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/pie-family.builder.js +4 -3
- package/dist/esm/components/views/chart-view/option-builder/builders/pie-family.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/radar.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/radar.builder.js +2 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/radar.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/sankey.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/sankey.builder.js +5 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/sankey.builder.js.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/statistical-family.builder.d.ts.map +1 -1
- package/dist/esm/components/views/chart-view/option-builder/builders/statistical-family.builder.js +4 -3
- package/dist/esm/components/views/chart-view/option-builder/builders/statistical-family.builder.js.map +1 -1
- package/dist/esm/core/app-shell/app-shell.schemas.d.ts +87 -16
- package/dist/esm/core/app-shell/app-shell.schemas.d.ts.map +1 -1
- package/dist/esm/core/app-shell/app-shell.schemas.js +16 -0
- package/dist/esm/core/app-shell/app-shell.schemas.js.map +1 -1
- package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.d.ts +39 -4
- package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.d.ts.map +1 -1
- package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.js +33 -1
- package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.js.map +1 -1
- package/dist/esm/core/resources/hooks/useOperationEnabled.d.ts.map +1 -1
- package/dist/esm/core/resources/hooks/useOperationEnabled.js +41 -3
- package/dist/esm/core/resources/hooks/useOperationEnabled.js.map +1 -1
- package/dist/esm/core/search/command-score.d.ts +33 -0
- package/dist/esm/core/search/command-score.d.ts.map +1 -0
- package/dist/esm/core/search/command-score.js +109 -0
- package/dist/esm/core/search/command-score.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +6 -6
|
@@ -20,6 +20,7 @@ import { useAuthedFileObjectUrl } from '../../../core/resources/useAuthedFileObj
|
|
|
20
20
|
import { CoreResourceType, isRelationshipMembership } from '@wildo-ai/saas-models';
|
|
21
21
|
import { envLoader } from '../../../core/runtime/env-variable-loader.frontend.service.js';
|
|
22
22
|
import { CommonRoutePaths } from '../../../core/runtime/routes.frontend.definitions.js';
|
|
23
|
+
import { OrganizationSwitcherGroupKind } from '../../../core/app-shell/app-shell.schemas.js';
|
|
23
24
|
/**
|
|
24
25
|
* Stable empty entries, shared by both read sites.
|
|
25
26
|
*
|
|
@@ -214,6 +215,26 @@ export function useMenuUserOrgBehavior(containerType, containerPlacement) {
|
|
|
214
215
|
}
|
|
215
216
|
return byOrganization;
|
|
216
217
|
}, [user?.organizationMembers]);
|
|
218
|
+
const listedOrganizations = useMemo(() => (organizations ?? []).map(org => {
|
|
219
|
+
const viaOrganizationName = representingNameByOrganizationId.get(String(org._id));
|
|
220
|
+
return { _id: org._id, name: org.name, ...(viaOrganizationName ? { viaOrganizationName } : {}) };
|
|
221
|
+
}), [organizations, representingNameByOrganizationId]);
|
|
222
|
+
/*
|
|
223
|
+
* The switcher's groups (#1828), decided here so every renderer groups alike. While a search applies its answer
|
|
224
|
+
* replaces the list: every result is one of the person's own organizations, so they stand in one group (a granting
|
|
225
|
+
* organization found this way is not told apart: its representing organization's name comes from a membership row the
|
|
226
|
+
* user context does not carry). Otherwise the person's own organizations, then the granting ones, each only when it
|
|
227
|
+
* holds one.
|
|
228
|
+
*/
|
|
229
|
+
const organizationGroups = useMemo(() => {
|
|
230
|
+
if (organizationSearch.results !== null) {
|
|
231
|
+
return [{ kind: OrganizationSwitcherGroupKind.SEARCH_RESULTS, organizations: organizationSearch.results }];
|
|
232
|
+
}
|
|
233
|
+
return [
|
|
234
|
+
{ kind: OrganizationSwitcherGroupKind.OWN, organizations: listedOrganizations.filter(org => !org.viaOrganizationName) },
|
|
235
|
+
{ kind: OrganizationSwitcherGroupKind.GRANTING, organizations: listedOrganizations.filter(org => Boolean(org.viaOrganizationName)) },
|
|
236
|
+
].filter(group => group.organizations.length > 0);
|
|
237
|
+
}, [organizationSearch.results, listedOrganizations]);
|
|
217
238
|
return {
|
|
218
239
|
isOpen,
|
|
219
240
|
setIsOpen,
|
|
@@ -223,10 +244,11 @@ export function useMenuUserOrgBehavior(containerType, containerPlacement) {
|
|
|
223
244
|
email,
|
|
224
245
|
avatarUrl,
|
|
225
246
|
currentOrganization: currentOrganization ? { _id: currentOrganization._id, name: currentOrganization.name } : undefined,
|
|
226
|
-
organizations:
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
247
|
+
organizations: listedOrganizations,
|
|
248
|
+
organizationGroups,
|
|
249
|
+
// A person in more organizations than the user context carries (#2452) is offered the switcher even when only one
|
|
250
|
+
// of them is listed: the rest are found by search.
|
|
251
|
+
hasMultipleOrganizations: listedOrganizations.length > 1 || unlistedOrganizationCount > 0,
|
|
230
252
|
unlistedOrganizationCount,
|
|
231
253
|
organizationSearchQuery: organizationSearch.query,
|
|
232
254
|
setOrganizationSearchQuery: organizationSearch.setQuery,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMenuUserOrgBehavior.js","sourceRoot":"","sources":["../../../../../src/components/navigation/app-level/useMenuUserOrgBehavior.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,6BAA6B,EAAE,MAAM,uEAAuE,CAAC;AACtH,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EACL,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,oEAAoE,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAqB,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,qCAAqC,EAAE,MAAM,mEAAmE,CAAC;AAC1H,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iEAAiE,CAAC;AACzG,OAAO,EAAE,cAAc,EAAiC,MAAM,yDAAyD,CAAC;AACxH,OAAO,EAAE,4BA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c,CAAC;IACxB,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAEhC,OAAO;QACL,MAAM;QACN,SAAS;QACT,mBAAmB,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC,IAAI;QAChD,YAAY;QACZ,WAAW;QACX,KAAK;QACL,SAAS;QACT,mBAAmB,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,mBAAmB,CAAC,GAAG,EAAE,IAAI,EAAE,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS;QACvH,aAAa,EAAE,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YAC7C,MAAM,mBAAmB,GAAG,gCAAgC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAClF,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;QACnG,CAAC,CAAC;QACF,yBAAyB;QACzB,uBAAuB,EAAE,kBAAkB,CAAC,KAAK;QACjD,0BAA0B,EAAE,kBAAkB,CAAC,QAAQ;QACvD,yBAAyB,EAAE,kBAAkB,CAAC,OAAO;QACrD,wBAAwB,EAAE,kBAAkB,CAAC,WAAW;QACxD,wBAAwB,EAAE,kBAAkB,CAAC,MAAM;QACnD,QAAQ;QACR,aAAa;QACb,eAAe;QACf,UAAU;QACV,cAAc;QACd,eAAe;QACf,cAAc;QACd,YAAY;QACZ,eAAe;QACf,8BAA8B;KAC/B,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport { useNavigate } from 'react-router';\n\nimport { ApplicationLevelComponentType } from '~wildo-frontend-lib/core/config/app-level-components.frontend.schemas';\nimport { HorizontalPlacement, VerticalPlacement } from '@wildo-ai/presets-components-models';\nimport {\n UserDropdownAvatarDisplay,\n UserDropdownSection,\n} from '~wildo-frontend-lib/core/config/app-configuration-frontend.schemas';\nimport { HorizontalAlign, type FileMetadata } from '@wildo-ai/zod-decorators';\nimport { PlacementSide } from '@wildo-ai/presets-components-models';\nimport { useLauncherRuntimeAvailabilityContext } from '~wildo-frontend-lib/core/navigation/launcher-runtime-availability';\nimport { useUI } from '~wildo-frontend-lib/core/ui/useUI';\nimport { LauncherItemTargetKind } from '~wildo-frontend-lib/core/config/launcher-items.frontend.schemas';\nimport { resolveItemRef, type ResolvedNavigationTarget } from '~wildo-frontend-lib/core/navigation/launcher-resolution';\nimport { useLauncherResolutionContext } from '~wildo-frontend-lib/core/navigation/useLauncherResolutionContext';\nimport { useUserOrgs } from '~wildo-frontend-lib/core/security/useUserOrgs';\nimport { accessProfileSwitchableOrganizationIds } from '~wildo-frontend-lib/core/security/effective-permissions.frontend.utils';\nimport { useOwnOrganizationSearch } from './useOwnOrganizationSearch';\nimport { useResourceRegistry } from '~wildo-frontend-lib/core/resources/useResourceRegistry';\nimport { FrontendResourceUtils } from '~wildo-frontend-lib/core/resources/frontend-resource.utils';\nimport { buildResourceFileServeBaseUrl, buildFileServeThumbnailUrl } from '~wildo-frontend-lib/core/resources/file-serve-url.frontend.utils';\nimport { useAuthedFileObjectUrl } from '~wildo-frontend-lib/core/resources/useAuthedFileObjectUrl.frontend.hook';\nimport { CoreResourceType, isRelationshipMembership } from '@wildo-ai/saas-models';\nimport { envLoader } from '~wildo-frontend-lib/core/runtime/env-variable-loader.frontend.service';\nimport { CommonRoutePaths } from '~wildo-frontend-lib/core/runtime/routes.frontend.definitions';\n\nimport type { MenuUserOrgBehavior } from '~wildo-frontend-lib/core/app-shell/app-shell.schemas';\n\n/** Dropdown config shape extracted from component config (avatarDisplay, sections, etc.). */\ninterface UserDropdownConfiguration {\n avatarDisplay?: UserDropdownAvatarDisplay;\n /**\n * `PREFERENCES` and `SETTINGS` currently affect the same effective settings\n * block. `PREFERENCES` changes labeling when `SETTINGS` is absent; it does not\n * introduce a second independent destination.\n */\n sections?: UserDropdownSection[];\n showOrgSwitcher?: boolean;\n showLogout?: boolean;\n /**\n * Settings-hub section refs to surface inline in the dropdown, in order.\n *\n * Names the SETTINGS vocabulary directly. The previous design took a SIDEBAR\n * section ref and string-matched it (`s.ref === settingsSectionRef`), which\n * made the dropdown's contents a side effect of how the sidebar happened to be\n * arranged — two separate vocabularies joined by a magic string, so moving a\n * sidebar section silently emptied the dropdown.\n *\n * Empty or omitted renders the single \"Settings\" button that opens the hub.\n * There is deliberately no separate `mergeSettings` flag: the presence of\n * entries IS the intent, and a boolean beside a list can only ever disagree\n * with it.\n */\n settingsEntries?: readonly string[];\n}\n\n/**\n * Stable empty entries, shared by both read sites.\n *\n * A literal `?? []` allocates a NEW array on every render, and `settingsTargets`\n * memoizes on this value — so an application that configures `USER_DROPDOWN` as a\n * plain boolean (no config object, so `dropdownConfig` is undefined) would churn\n * the `settingsTargets` memo and every consumer of the returned\n * behavior, forever. The code this replaced depended on a boolean and a string,\n * which are stable by construction; an array is not.\n */\nconst NO_SETTINGS_ENTRIES: readonly string[] = Object.freeze([]);\n\nfunction isUserDropdownConfigObject(config: unknown): config is UserDropdownConfiguration {\n return typeof config === 'object' && config !== null;\n}\n\nconst DEFAULT_SECTIONS: UserDropdownSection[] = [\n UserDropdownSection.USER_INFO,\n UserDropdownSection.ORG_SWITCHER,\n UserDropdownSection.SETTINGS,\n UserDropdownSection.LOGOUT,\n];\n\n\n/**\n * Behavior hook for MenuUserOrg — manages user/org data, dropdown config\n * resolution, popup alignment computation, and navigation handlers.\n */\nexport function useMenuUserOrgBehavior(\n containerType?: ApplicationLevelComponentType,\n containerPlacement?: HorizontalPlacement | VerticalPlacement\n): MenuUserOrgBehavior {\n const { appComponentsConfiguration } = useUI();\n const {\n user,\n organizations,\n getCurrentOrganization,\n setCurrentOrganization,\n logout,\n isAuthenticated,\n permissions,\n } = useUserOrgs();\n const { registry } = useResourceRegistry();\n const resolutionCtx = useLauncherResolutionContext();\n const routerNavigate = useNavigate();\n const runtimeAvailabilityContext = useLauncherRuntimeAvailabilityContext();\n\n const [isOpen, setIsOpen] = useState(false);\n\n const config = appComponentsConfiguration?.[ApplicationLevelComponentType.USER_DROPDOWN];\n\n const dropdownConfig = useMemo((): UserDropdownConfiguration | undefined => {\n const componentConfig = isUserDropdownConfigObject(config) ? config : undefined;\n\n if (!componentConfig) {\n return undefined;\n }\n\n return {\n avatarDisplay: componentConfig.avatarDisplay ?? UserDropdownAvatarDisplay.AVATAR_ONLY,\n sections: componentConfig.sections ?? DEFAULT_SECTIONS,\n showOrgSwitcher: componentConfig.showOrgSwitcher ?? true,\n showLogout: componentConfig.showLogout ?? true,\n settingsEntries: componentConfig.settingsEntries ?? NO_SETTINGS_ENTRIES,\n };\n }, [config]);\n\n const currentOrganization = getCurrentOrganization();\n\n const sections = dropdownConfig?.sections ?? DEFAULT_SECTIONS;\n const avatarDisplay = dropdownConfig?.avatarDisplay ?? UserDropdownAvatarDisplay.AVATAR_ONLY;\n const showOrgSwitcher = dropdownConfig?.showOrgSwitcher !== false;\n const showLogout = dropdownConfig?.showLogout !== false;\n const settingsEntries = dropdownConfig?.settingsEntries ?? NO_SETTINGS_ENTRIES;\n const activeMode = runtimeAvailabilityContext.activeMode;\n const availableModes = runtimeAvailabilityContext.availableModes;\n const allScopeValues = runtimeAvailabilityContext.allScopeValues;\n\n const popupAlignment = useMemo(() => {\n if (containerType === ApplicationLevelComponentType.MENUBAR) {\n if (containerPlacement === HorizontalPlacement.END) {\n return { align: HorizontalAlign.END, side: PlacementSide.BOTTOM };\n }\n return { align: HorizontalAlign.START, side: PlacementSide.BOTTOM };\n }\n\n if (containerType === ApplicationLevelComponentType.SIDEBAR) {\n if (containerPlacement === VerticalPlacement.BOTTOM) {\n return { align: HorizontalAlign.END, side: PlacementSide.END };\n }\n return { align: HorizontalAlign.START, side: PlacementSide.END };\n }\n\n return { align: HorizontalAlign.END, side: PlacementSide.BOTTOM };\n }, [containerType, containerPlacement]);\n\n\n /**\n * Resolve each authored settings-hub section ref to a navigation target.\n *\n * Every entry converges on the unified Settings Hub through the existing\n * typed `SETTINGS_SECTION` launcher ref, so the dropdown gains no navigation\n * semantics of its own — it just names sections. An entry the hub does not\n * declare still resolves: its row reads its section's label key, which then shows\n * as the missing key it is. The DEV-startup verifier is where an author is told.\n */\n const settingsTargets = useMemo((): ResolvedNavigationTarget[] => {\n if (!resolutionCtx) return [];\n\n return settingsEntries.flatMap(sectionRef => {\n const resolved = resolveItemRef(\n { kind: LauncherItemTargetKind.SETTINGS_SECTION, sectionRef },\n resolutionCtx,\n );\n return resolved ? [resolved] : [];\n });\n }, [resolutionCtx, settingsEntries]);\n\n /**\n * The hub ITSELF — always, whatever shortcuts the application authored.\n *\n * It used to be the first authored entry, so an application that added a Profile shortcut lost the way into the rest\n * of Settings from the identity menu, which is where settings live now that no preset puts them in the sidebar.\n * Authored entries are shortcuts INTO the hub; this is the hub.\n */\n const settingsTarget = useMemo((): ResolvedNavigationTarget | null => {\n if (!resolutionCtx) {\n return null;\n }\n return resolveItemRef({ kind: LauncherItemTargetKind.SETTINGS_SECTION }, resolutionCtx);\n }, [resolutionCtx]);\n\n const userProfile = user?.userSelfProfile;\n\n const userInitials = useMemo(() => {\n if (!userProfile) {\n return user?.email?.charAt(0).toUpperCase() || '?';\n }\n const firstName = userProfile.firstName ?? '';\n const lastName = userProfile.lastName ?? '';\n return `${firstName.charAt(0)}${lastName.charAt(0)}`.toUpperCase() || user?.email?.charAt(0).toUpperCase() || '?';\n }, [user, userProfile]);\n\n const displayName = useMemo(() => {\n if (!user) return '';\n if (userProfile?.firstName && userProfile?.lastName) {\n return `${userProfile.firstName} ${userProfile.lastName}`;\n }\n return user.email ?? '';\n }, [user, userProfile]);\n\n // The person's organizations the list does not hold (#2452): the user context carries only the newest 20\n // memberships. Counted from the access profile's organization-wide entries — the population the search returns.\n const unlistedOrganizationCount = useMemo(() => {\n const listed = new Set((organizations ?? []).map((organization) => String(organization._id)));\n return accessProfileSwitchableOrganizationIds(permissions?.accessProfile)\n .filter((organizationId) => !listed.has(organizationId)).length;\n }, [organizations, permissions?.accessProfile]);\n // Searching applies only while the menu is open and something is unlisted; closing it clears the query.\n const organizationSearch = useOwnOrganizationSearch(isOpen && unlistedOrganizationCount > 0);\n\n const handleLogout = useCallback(() => {\n setIsOpen(false);\n logout();\n }, [logout]);\n\n const handleSwitchOrg = useCallback((orgId: string) => {\n setIsOpen(false);\n setCurrentOrganization(orgId);\n }, [setCurrentOrganization]);\n\n const handleNavigateToSettingsTarget = useCallback((target: ResolvedNavigationTarget) => {\n setIsOpen(false);\n // Every settings entry converges on the unified Settings Hub. The hub is\n // URL-driven (`useSettingsHubOverlaySync` reconstructs it from `/settings`),\n // so navigate by URL only — do NOT push content into PRIMARY, which would\n // double-render the section's panel behind the hub overlay.\n routerNavigate(target.urlPath || CommonRoutePaths.settings);\n }, [routerNavigate]);\n\n // Avatar image for the nav. `avatar` is a `z_file()` ref/metadata carrying `fileId`,\n // but its bytes live behind the AUTHENTICATED resource-integrated serve route (an\n // `<img>` can't send the bearer, and the persisted `url`/`thumbnailUrl` are unused).\n // So build the same serve URL the profile display uses — for the CURRENT user's own\n // profile: `/user-user-self/{userId}/user-self-profile/{profileId}/files/avatar/{fileId}`\n // — then fetch the bytes → object URL. Falls back to `undefined` (→ initials) when the\n // avatar is unset or the route can't be resolved.\n const avatarFile = userProfile?.avatar as unknown as FileMetadata | undefined;\n const avatarServeUrl = useMemo<string | null>(() => {\n const userId = String((userProfile as Record<string, unknown> | undefined)?.userId ?? (user as Record<string, unknown> | undefined)?._id ?? '');\n const profileId = String((userProfile as Record<string, unknown> | undefined)?._id ?? '');\n const avatarFileId = avatarFile?.fileId;\n if (!registry || !userId || !profileId || !avatarFileId) return null;\n const resourceConfig = registry.resourceConfigurations?.[CoreResourceType.USER_SELF_PROFILES];\n const readOp = FrontendResourceUtils.resolveSingleResourceReadOperation(CoreResourceType.USER_SELF_PROFILES, registry);\n if (!resourceConfig || !readOp) return null;\n const contextResourceIdentifiers = { [CoreResourceType.USER_SELF]: userId };\n const serveBase = buildResourceFileServeBaseUrl({\n registry,\n resourceConfig,\n operation: readOp,\n resourceType: CoreResourceType.USER_SELF_PROFILES,\n fieldName: 'avatar',\n recordId: profileId,\n contextResourceIdentifiers,\n contextualParameters: FrontendResourceUtils.buildContextualParameters(contextResourceIdentifiers, registry),\n apiBaseUrl: envLoader.getApiUrl(),\n });\n if (!serveBase) return null;\n // The nav avatar is tiny — request the downscaled `?variant=thumbnail` rendition\n // rather than pulling the original bytes.\n return buildFileServeThumbnailUrl(`${serveBase}/${encodeURIComponent(avatarFileId)}`);\n }, [registry, user, userProfile, avatarFile?.fileId]);\n const avatarUrl = useAuthedFileObjectUrl(avatarServeUrl) ?? undefined;\n const email = user?.email ?? '';\n // The granting organizations this person works in through a representing organization (#1597), keyed to the\n // representing organization's name the membership recorded. Read from the memberships the user context already\n // carries — no request.\n const representingNameByOrganizationId = useMemo(() => {\n const byOrganization = new Map<string, string>();\n for (const membership of user?.organizationMembers ?? []) {\n if (!isRelationshipMembership(membership)) continue;\n const representingName = (membership as { representingOrganizationName?: unknown }).representingOrganizationName;\n if (typeof representingName === 'string' && representingName.length > 0) byOrganization.set(String(membership.organizationId), representingName);\n }\n return byOrganization;\n }, [user?.organizationMembers]);\n\n return {\n isOpen,\n setIsOpen,\n isUserAuthenticated: isAuthenticated() && !!user,\n userInitials,\n displayName,\n email,\n avatarUrl,\n currentOrganization: currentOrganization ? { _id: currentOrganization._id, name: currentOrganization.name } : undefined,\n organizations: (organizations ?? []).map(org => {\n const viaOrganizationName = representingNameByOrganizationId.get(String(org._id));\n return { _id: org._id, name: org.name, ...(viaOrganizationName ? { viaOrganizationName } : {}) };\n }),\n unlistedOrganizationCount,\n organizationSearchQuery: organizationSearch.query,\n setOrganizationSearchQuery: organizationSearch.setQuery,\n organizationSearchResults: organizationSearch.results,\n isSearchingOrganizations: organizationSearch.isSearching,\n organizationSearchFailed: organizationSearch.failed,\n sections,\n avatarDisplay,\n showOrgSwitcher,\n showLogout,\n settingsTarget,\n settingsTargets,\n popupAlignment,\n handleLogout,\n handleSwitchOrg,\n handleNavigateToSettingsTarget,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useMenuUserOrgBehavior.js","sourceRoot":"","sources":["../../../../../src/components/navigation/app-level/useMenuUserOrgBehavior.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,6BAA6B,EAAE,MAAM,uEAAuE,CAAC;AACtH,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EACL,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,oEAAoE,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAqB,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,qCAAqC,EAAE,MAAM,mEAAmE,CAAC;AAC1H,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iEAAiE,CAAC;AACzG,OAAO,EAAE,cAAc,EAAiC,MAAM,yDAAyD,CAAC;AACxH,OAAO,EAAE,4BAA4B,EAAE,MAAM,kEAAkE,CAAC;AAChH,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAC5E,OAAO,EAAE,sCAAsC,EAAE,MAAM,wEAAwE,CAAC;AAChI,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAC7F,OAA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QACX,KAAK;QACL,SAAS;QACT,mBAAmB,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,mBAAmB,CAAC,GAAG,EAAE,IAAI,EAAE,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS;QACvH,aAAa,EAAE,mBAAmB;QAClC,kBAAkB;QAClB,kHAAkH;QAClH,mDAAmD;QACnD,wBAAwB,EAAE,mBAAmB,CAAC,MAAM,GAAG,CAAC,IAAI,yBAAyB,GAAG,CAAC;QACzF,yBAAyB;QACzB,uBAAuB,EAAE,kBAAkB,CAAC,KAAK;QACjD,0BAA0B,EAAE,kBAAkB,CAAC,QAAQ;QACvD,yBAAyB,EAAE,kBAAkB,CAAC,OAAO;QACrD,wBAAwB,EAAE,kBAAkB,CAAC,WAAW;QACxD,wBAAwB,EAAE,kBAAkB,CAAC,MAAM;QACnD,QAAQ;QACR,aAAa;QACb,eAAe;QACf,UAAU;QACV,cAAc;QACd,eAAe;QACf,cAAc;QACd,YAAY;QACZ,eAAe;QACf,8BAA8B;KAC/B,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport { useNavigate } from 'react-router';\n\nimport { ApplicationLevelComponentType } from '~wildo-frontend-lib/core/config/app-level-components.frontend.schemas';\nimport { HorizontalPlacement, VerticalPlacement } from '@wildo-ai/presets-components-models';\nimport {\n UserDropdownAvatarDisplay,\n UserDropdownSection,\n} from '~wildo-frontend-lib/core/config/app-configuration-frontend.schemas';\nimport { HorizontalAlign, type FileMetadata } from '@wildo-ai/zod-decorators';\nimport { PlacementSide } from '@wildo-ai/presets-components-models';\nimport { useLauncherRuntimeAvailabilityContext } from '~wildo-frontend-lib/core/navigation/launcher-runtime-availability';\nimport { useUI } from '~wildo-frontend-lib/core/ui/useUI';\nimport { LauncherItemTargetKind } from '~wildo-frontend-lib/core/config/launcher-items.frontend.schemas';\nimport { resolveItemRef, type ResolvedNavigationTarget } from '~wildo-frontend-lib/core/navigation/launcher-resolution';\nimport { useLauncherResolutionContext } from '~wildo-frontend-lib/core/navigation/useLauncherResolutionContext';\nimport { useUserOrgs } from '~wildo-frontend-lib/core/security/useUserOrgs';\nimport { accessProfileSwitchableOrganizationIds } from '~wildo-frontend-lib/core/security/effective-permissions.frontend.utils';\nimport { useOwnOrganizationSearch } from './useOwnOrganizationSearch';\nimport { useResourceRegistry } from '~wildo-frontend-lib/core/resources/useResourceRegistry';\nimport { FrontendResourceUtils } from '~wildo-frontend-lib/core/resources/frontend-resource.utils';\nimport { buildResourceFileServeBaseUrl, buildFileServeThumbnailUrl } from '~wildo-frontend-lib/core/resources/file-serve-url.frontend.utils';\nimport { useAuthedFileObjectUrl } from '~wildo-frontend-lib/core/resources/useAuthedFileObjectUrl.frontend.hook';\nimport { CoreResourceType, isRelationshipMembership } from '@wildo-ai/saas-models';\nimport { envLoader } from '~wildo-frontend-lib/core/runtime/env-variable-loader.frontend.service';\nimport { CommonRoutePaths } from '~wildo-frontend-lib/core/runtime/routes.frontend.definitions';\n\nimport { OrganizationSwitcherGroupKind, type MenuUserOrgBehavior, type OrganizationSwitcherGroup } from '~wildo-frontend-lib/core/app-shell/app-shell.schemas';\n\n/** Dropdown config shape extracted from component config (avatarDisplay, sections, etc.). */\ninterface UserDropdownConfiguration {\n avatarDisplay?: UserDropdownAvatarDisplay;\n /**\n * `PREFERENCES` and `SETTINGS` currently affect the same effective settings\n * block. `PREFERENCES` changes labeling when `SETTINGS` is absent; it does not\n * introduce a second independent destination.\n */\n sections?: UserDropdownSection[];\n showOrgSwitcher?: boolean;\n showLogout?: boolean;\n /**\n * Settings-hub section refs to surface inline in the dropdown, in order.\n *\n * Names the SETTINGS vocabulary directly. The previous design took a SIDEBAR\n * section ref and string-matched it (`s.ref === settingsSectionRef`), which\n * made the dropdown's contents a side effect of how the sidebar happened to be\n * arranged — two separate vocabularies joined by a magic string, so moving a\n * sidebar section silently emptied the dropdown.\n *\n * Empty or omitted renders the single \"Settings\" button that opens the hub.\n * There is deliberately no separate `mergeSettings` flag: the presence of\n * entries IS the intent, and a boolean beside a list can only ever disagree\n * with it.\n */\n settingsEntries?: readonly string[];\n}\n\n/**\n * Stable empty entries, shared by both read sites.\n *\n * A literal `?? []` allocates a NEW array on every render, and `settingsTargets`\n * memoizes on this value — so an application that configures `USER_DROPDOWN` as a\n * plain boolean (no config object, so `dropdownConfig` is undefined) would churn\n * the `settingsTargets` memo and every consumer of the returned\n * behavior, forever. The code this replaced depended on a boolean and a string,\n * which are stable by construction; an array is not.\n */\nconst NO_SETTINGS_ENTRIES: readonly string[] = Object.freeze([]);\n\nfunction isUserDropdownConfigObject(config: unknown): config is UserDropdownConfiguration {\n return typeof config === 'object' && config !== null;\n}\n\nconst DEFAULT_SECTIONS: UserDropdownSection[] = [\n UserDropdownSection.USER_INFO,\n UserDropdownSection.ORG_SWITCHER,\n UserDropdownSection.SETTINGS,\n UserDropdownSection.LOGOUT,\n];\n\n\n/**\n * Behavior hook for MenuUserOrg — manages user/org data, dropdown config\n * resolution, popup alignment computation, and navigation handlers.\n */\nexport function useMenuUserOrgBehavior(\n containerType?: ApplicationLevelComponentType,\n containerPlacement?: HorizontalPlacement | VerticalPlacement\n): MenuUserOrgBehavior {\n const { appComponentsConfiguration } = useUI();\n const {\n user,\n organizations,\n getCurrentOrganization,\n setCurrentOrganization,\n logout,\n isAuthenticated,\n permissions,\n } = useUserOrgs();\n const { registry } = useResourceRegistry();\n const resolutionCtx = useLauncherResolutionContext();\n const routerNavigate = useNavigate();\n const runtimeAvailabilityContext = useLauncherRuntimeAvailabilityContext();\n\n const [isOpen, setIsOpen] = useState(false);\n\n const config = appComponentsConfiguration?.[ApplicationLevelComponentType.USER_DROPDOWN];\n\n const dropdownConfig = useMemo((): UserDropdownConfiguration | undefined => {\n const componentConfig = isUserDropdownConfigObject(config) ? config : undefined;\n\n if (!componentConfig) {\n return undefined;\n }\n\n return {\n avatarDisplay: componentConfig.avatarDisplay ?? UserDropdownAvatarDisplay.AVATAR_ONLY,\n sections: componentConfig.sections ?? DEFAULT_SECTIONS,\n showOrgSwitcher: componentConfig.showOrgSwitcher ?? true,\n showLogout: componentConfig.showLogout ?? true,\n settingsEntries: componentConfig.settingsEntries ?? NO_SETTINGS_ENTRIES,\n };\n }, [config]);\n\n const currentOrganization = getCurrentOrganization();\n\n const sections = dropdownConfig?.sections ?? DEFAULT_SECTIONS;\n const avatarDisplay = dropdownConfig?.avatarDisplay ?? UserDropdownAvatarDisplay.AVATAR_ONLY;\n const showOrgSwitcher = dropdownConfig?.showOrgSwitcher !== false;\n const showLogout = dropdownConfig?.showLogout !== false;\n const settingsEntries = dropdownConfig?.settingsEntries ?? NO_SETTINGS_ENTRIES;\n const activeMode = runtimeAvailabilityContext.activeMode;\n const availableModes = runtimeAvailabilityContext.availableModes;\n const allScopeValues = runtimeAvailabilityContext.allScopeValues;\n\n const popupAlignment = useMemo(() => {\n if (containerType === ApplicationLevelComponentType.MENUBAR) {\n if (containerPlacement === HorizontalPlacement.END) {\n return { align: HorizontalAlign.END, side: PlacementSide.BOTTOM };\n }\n return { align: HorizontalAlign.START, side: PlacementSide.BOTTOM };\n }\n\n if (containerType === ApplicationLevelComponentType.SIDEBAR) {\n if (containerPlacement === VerticalPlacement.BOTTOM) {\n return { align: HorizontalAlign.END, side: PlacementSide.END };\n }\n return { align: HorizontalAlign.START, side: PlacementSide.END };\n }\n\n return { align: HorizontalAlign.END, side: PlacementSide.BOTTOM };\n }, [containerType, containerPlacement]);\n\n\n /**\n * Resolve each authored settings-hub section ref to a navigation target.\n *\n * Every entry converges on the unified Settings Hub through the existing\n * typed `SETTINGS_SECTION` launcher ref, so the dropdown gains no navigation\n * semantics of its own — it just names sections. An entry the hub does not\n * declare still resolves: its row reads its section's label key, which then shows\n * as the missing key it is. The DEV-startup verifier is where an author is told.\n */\n const settingsTargets = useMemo((): ResolvedNavigationTarget[] => {\n if (!resolutionCtx) return [];\n\n return settingsEntries.flatMap(sectionRef => {\n const resolved = resolveItemRef(\n { kind: LauncherItemTargetKind.SETTINGS_SECTION, sectionRef },\n resolutionCtx,\n );\n return resolved ? [resolved] : [];\n });\n }, [resolutionCtx, settingsEntries]);\n\n /**\n * The hub ITSELF — always, whatever shortcuts the application authored.\n *\n * It used to be the first authored entry, so an application that added a Profile shortcut lost the way into the rest\n * of Settings from the identity menu, which is where settings live now that no preset puts them in the sidebar.\n * Authored entries are shortcuts INTO the hub; this is the hub.\n */\n const settingsTarget = useMemo((): ResolvedNavigationTarget | null => {\n if (!resolutionCtx) {\n return null;\n }\n return resolveItemRef({ kind: LauncherItemTargetKind.SETTINGS_SECTION }, resolutionCtx);\n }, [resolutionCtx]);\n\n const userProfile = user?.userSelfProfile;\n\n const userInitials = useMemo(() => {\n if (!userProfile) {\n return user?.email?.charAt(0).toUpperCase() || '?';\n }\n const firstName = userProfile.firstName ?? '';\n const lastName = userProfile.lastName ?? '';\n return `${firstName.charAt(0)}${lastName.charAt(0)}`.toUpperCase() || user?.email?.charAt(0).toUpperCase() || '?';\n }, [user, userProfile]);\n\n const displayName = useMemo(() => {\n if (!user) return '';\n if (userProfile?.firstName && userProfile?.lastName) {\n return `${userProfile.firstName} ${userProfile.lastName}`;\n }\n return user.email ?? '';\n }, [user, userProfile]);\n\n // The person's organizations the list does not hold (#2452): the user context carries only the newest 20\n // memberships. Counted from the access profile's organization-wide entries — the population the search returns.\n const unlistedOrganizationCount = useMemo(() => {\n const listed = new Set((organizations ?? []).map((organization) => String(organization._id)));\n return accessProfileSwitchableOrganizationIds(permissions?.accessProfile)\n .filter((organizationId) => !listed.has(organizationId)).length;\n }, [organizations, permissions?.accessProfile]);\n // Searching applies only while the menu is open and something is unlisted; closing it clears the query.\n const organizationSearch = useOwnOrganizationSearch(isOpen && unlistedOrganizationCount > 0);\n\n const handleLogout = useCallback(() => {\n setIsOpen(false);\n logout();\n }, [logout]);\n\n const handleSwitchOrg = useCallback((orgId: string) => {\n setIsOpen(false);\n setCurrentOrganization(orgId);\n }, [setCurrentOrganization]);\n\n const handleNavigateToSettingsTarget = useCallback((target: ResolvedNavigationTarget) => {\n setIsOpen(false);\n // Every settings entry converges on the unified Settings Hub. The hub is\n // URL-driven (`useSettingsHubOverlaySync` reconstructs it from `/settings`),\n // so navigate by URL only — do NOT push content into PRIMARY, which would\n // double-render the section's panel behind the hub overlay.\n routerNavigate(target.urlPath || CommonRoutePaths.settings);\n }, [routerNavigate]);\n\n // Avatar image for the nav. `avatar` is a `z_file()` ref/metadata carrying `fileId`,\n // but its bytes live behind the AUTHENTICATED resource-integrated serve route (an\n // `<img>` can't send the bearer, and the persisted `url`/`thumbnailUrl` are unused).\n // So build the same serve URL the profile display uses — for the CURRENT user's own\n // profile: `/user-user-self/{userId}/user-self-profile/{profileId}/files/avatar/{fileId}`\n // — then fetch the bytes → object URL. Falls back to `undefined` (→ initials) when the\n // avatar is unset or the route can't be resolved.\n const avatarFile = userProfile?.avatar as unknown as FileMetadata | undefined;\n const avatarServeUrl = useMemo<string | null>(() => {\n const userId = String((userProfile as Record<string, unknown> | undefined)?.userId ?? (user as Record<string, unknown> | undefined)?._id ?? '');\n const profileId = String((userProfile as Record<string, unknown> | undefined)?._id ?? '');\n const avatarFileId = avatarFile?.fileId;\n if (!registry || !userId || !profileId || !avatarFileId) return null;\n const resourceConfig = registry.resourceConfigurations?.[CoreResourceType.USER_SELF_PROFILES];\n const readOp = FrontendResourceUtils.resolveSingleResourceReadOperation(CoreResourceType.USER_SELF_PROFILES, registry);\n if (!resourceConfig || !readOp) return null;\n const contextResourceIdentifiers = { [CoreResourceType.USER_SELF]: userId };\n const serveBase = buildResourceFileServeBaseUrl({\n registry,\n resourceConfig,\n operation: readOp,\n resourceType: CoreResourceType.USER_SELF_PROFILES,\n fieldName: 'avatar',\n recordId: profileId,\n contextResourceIdentifiers,\n contextualParameters: FrontendResourceUtils.buildContextualParameters(contextResourceIdentifiers, registry),\n apiBaseUrl: envLoader.getApiUrl(),\n });\n if (!serveBase) return null;\n // The nav avatar is tiny — request the downscaled `?variant=thumbnail` rendition\n // rather than pulling the original bytes.\n return buildFileServeThumbnailUrl(`${serveBase}/${encodeURIComponent(avatarFileId)}`);\n }, [registry, user, userProfile, avatarFile?.fileId]);\n const avatarUrl = useAuthedFileObjectUrl(avatarServeUrl) ?? undefined;\n const email = user?.email ?? '';\n // The granting organizations this person works in through a representing organization (#1597), keyed to the\n // representing organization's name the membership recorded. Read from the memberships the user context already\n // carries — no request.\n const representingNameByOrganizationId = useMemo(() => {\n const byOrganization = new Map<string, string>();\n for (const membership of user?.organizationMembers ?? []) {\n if (!isRelationshipMembership(membership)) continue;\n const representingName = (membership as { representingOrganizationName?: unknown }).representingOrganizationName;\n if (typeof representingName === 'string' && representingName.length > 0) byOrganization.set(String(membership.organizationId), representingName);\n }\n return byOrganization;\n }, [user?.organizationMembers]);\n\n const listedOrganizations = useMemo(() => (organizations ?? []).map(org => {\n const viaOrganizationName = representingNameByOrganizationId.get(String(org._id));\n return { _id: org._id, name: org.name, ...(viaOrganizationName ? { viaOrganizationName } : {}) };\n }), [organizations, representingNameByOrganizationId]);\n\n /*\n * The switcher's groups (#1828), decided here so every renderer groups alike. While a search applies its answer\n * replaces the list: every result is one of the person's own organizations, so they stand in one group (a granting\n * organization found this way is not told apart: its representing organization's name comes from a membership row the\n * user context does not carry). Otherwise the person's own organizations, then the granting ones, each only when it\n * holds one.\n */\n const organizationGroups = useMemo((): OrganizationSwitcherGroup[] => {\n if (organizationSearch.results !== null) {\n return [{ kind: OrganizationSwitcherGroupKind.SEARCH_RESULTS, organizations: organizationSearch.results }];\n }\n return [\n { kind: OrganizationSwitcherGroupKind.OWN, organizations: listedOrganizations.filter(org => !org.viaOrganizationName) },\n { kind: OrganizationSwitcherGroupKind.GRANTING, organizations: listedOrganizations.filter(org => Boolean(org.viaOrganizationName)) },\n ].filter(group => group.organizations.length > 0);\n }, [organizationSearch.results, listedOrganizations]);\n\n return {\n isOpen,\n setIsOpen,\n isUserAuthenticated: isAuthenticated() && !!user,\n userInitials,\n displayName,\n email,\n avatarUrl,\n currentOrganization: currentOrganization ? { _id: currentOrganization._id, name: currentOrganization.name } : undefined,\n organizations: listedOrganizations,\n organizationGroups,\n // A person in more organizations than the user context carries (#2452) is offered the switcher even when only one\n // of them is listed: the rest are found by search.\n hasMultipleOrganizations: listedOrganizations.length > 1 || unlistedOrganizationCount > 0,\n unlistedOrganizationCount,\n organizationSearchQuery: organizationSearch.query,\n setOrganizationSearchQuery: organizationSearch.setQuery,\n organizationSearchResults: organizationSearch.results,\n isSearchingOrganizations: organizationSearch.isSearching,\n organizationSearchFailed: organizationSearch.failed,\n sections,\n avatarDisplay,\n showOrgSwitcher,\n showLogout,\n settingsTarget,\n settingsTargets,\n popupAlignment,\n handleLogout,\n handleSwitchOrg,\n handleNavigateToSettingsTarget,\n };\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { NavigationZone } from '../../../core/navigation/navigation.schemas';
|
|
2
|
+
import type { NavigationBackBehavior } from '../../../core/app-shell/app-shell.schemas';
|
|
3
|
+
export interface UseNavigationBackBehaviorOptions {
|
|
4
|
+
/** The zone the control walks back; absent, the focused zone when it holds content, else PRIMARY. */
|
|
5
|
+
navigationZone?: NavigationZone;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Behavior hook for the navigation-back control (#1828): which zone it walks back, whether it is shown at all, and the
|
|
9
|
+
* gesture. Data only, so a renderer that is not the DOM decides visibility exactly as the preset does.
|
|
10
|
+
*
|
|
11
|
+
* ─── Hidden when the gesture would do NOTHING ───────────────────────────────────────────────────
|
|
12
|
+
*
|
|
13
|
+
* In the PRIMARY zone there is nothing to walk back to below the first entry, so the control hides.
|
|
14
|
+
*
|
|
15
|
+
* In an ADJACENT zone — a hosted pane beside a page — a single entry is still something to leave: `goBack` on a
|
|
16
|
+
* structural zone with nothing beneath is the controller's own way of closing it, and without that a one-entry pane had
|
|
17
|
+
* no close control at all (the workbench's conversation found it, 2026-09-22). The label stays "back": the gesture
|
|
18
|
+
* returns the page to what it was.
|
|
19
|
+
*
|
|
20
|
+
* ── The OVERLAY layer is neither of those, and folding it into "not primary" shipped a DEAD CONTROL (2026-09-25). ──
|
|
21
|
+
*
|
|
22
|
+
* A scoped controller — the settings hub is the live one — hosts its own section stack inside an overlay and answers
|
|
23
|
+
* `canGoBack` from its own depth. At a section ROOT that is `false`, and its `goBack` dispatches a pop its reducer returns
|
|
24
|
+
* unchanged. The guard tested `=== PRIMARY`, so an OVERLAY zone fell through it: the root of every settings section
|
|
25
|
+
* rendered an enabled, focusable back arrow that did nothing on click.
|
|
26
|
+
*
|
|
27
|
+
* A structural PANE is the only case where "nothing beneath" still means something to do, because closing the pane is
|
|
28
|
+
* that something. An overlay has its own dismiss chrome.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useNavigationBackBehavior({ navigationZone }?: UseNavigationBackBehaviorOptions): NavigationBackBehavior;
|
|
31
|
+
//# sourceMappingURL=useNavigationBackBehavior.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNavigationBackBehavior.d.ts","sourceRoot":"","sources":["../../../../../src/components/navigation/app-level/useNavigationBackBehavior.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAC;AAGxF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sDAAsD,CAAC;AAGnG,MAAM,WAAW,gCAAgC;IAC/C,qGAAqG;IACrG,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,yBAAyB,CAAC,EAAE,cAAc,EAAE,GAAE,gCAAqC,GAAG,sBAAsB,CAY3H"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { NavigationZoneName } from '@wildo-ai/saas-models';
|
|
3
|
+
import { NavigationZone } from '../../../core/navigation/navigation.schemas.js';
|
|
4
|
+
import { useNavigationController } from '../../../core/navigation/useNavigationController.js';
|
|
5
|
+
import { useNavigationState } from '../../../core/navigation/useNavigationState.js';
|
|
6
|
+
import { resolveApplicationLevelNavigationBackZone } from './ApplicationLevel_NavigationBack.js';
|
|
7
|
+
/**
|
|
8
|
+
* Behavior hook for the navigation-back control (#1828): which zone it walks back, whether it is shown at all, and the
|
|
9
|
+
* gesture. Data only, so a renderer that is not the DOM decides visibility exactly as the preset does.
|
|
10
|
+
*
|
|
11
|
+
* ─── Hidden when the gesture would do NOTHING ───────────────────────────────────────────────────
|
|
12
|
+
*
|
|
13
|
+
* In the PRIMARY zone there is nothing to walk back to below the first entry, so the control hides.
|
|
14
|
+
*
|
|
15
|
+
* In an ADJACENT zone — a hosted pane beside a page — a single entry is still something to leave: `goBack` on a
|
|
16
|
+
* structural zone with nothing beneath is the controller's own way of closing it, and without that a one-entry pane had
|
|
17
|
+
* no close control at all (the workbench's conversation found it, 2026-09-22). The label stays "back": the gesture
|
|
18
|
+
* returns the page to what it was.
|
|
19
|
+
*
|
|
20
|
+
* ── The OVERLAY layer is neither of those, and folding it into "not primary" shipped a DEAD CONTROL (2026-09-25). ──
|
|
21
|
+
*
|
|
22
|
+
* A scoped controller — the settings hub is the live one — hosts its own section stack inside an overlay and answers
|
|
23
|
+
* `canGoBack` from its own depth. At a section ROOT that is `false`, and its `goBack` dispatches a pop its reducer returns
|
|
24
|
+
* unchanged. The guard tested `=== PRIMARY`, so an OVERLAY zone fell through it: the root of every settings section
|
|
25
|
+
* rendered an enabled, focusable back arrow that did nothing on click.
|
|
26
|
+
*
|
|
27
|
+
* A structural PANE is the only case where "nothing beneath" still means something to do, because closing the pane is
|
|
28
|
+
* that something. An overlay has its own dismiss chrome.
|
|
29
|
+
*/
|
|
30
|
+
export function useNavigationBackBehavior({ navigationZone } = {}) {
|
|
31
|
+
const { focusedZone, getZoneDepth } = useNavigationState();
|
|
32
|
+
const { goBack, canGoBack } = useNavigationController();
|
|
33
|
+
const resolvedZone = resolveApplicationLevelNavigationBackZone(navigationZone, focusedZone, getZoneDepth(focusedZone) > 0);
|
|
34
|
+
const zoneClosesOnBack = resolvedZone !== NavigationZoneName.PRIMARY && resolvedZone !== NavigationZone.OVERLAY;
|
|
35
|
+
const walkBack = useCallback(() => goBack(resolvedZone), [goBack, resolvedZone]);
|
|
36
|
+
return {
|
|
37
|
+
resolvedZone,
|
|
38
|
+
isVisible: canGoBack(resolvedZone) || zoneClosesOnBack,
|
|
39
|
+
goBack: walkBack,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=useNavigationBackBehavior.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNavigationBackBehavior.js","sourceRoot":"","sources":["../../../../../src/components/navigation/app-level/useNavigationBackBehavior.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6DAA6D,CAAC;AACtG,OAAO,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAE5F,OAAO,EAAE,yCAAyC,EAAE,MAAM,mCAAmC,CAAC;AAO9F;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,yBAAyB,CAAC,EAAE,cAAc,KAAuC,EAAE;IACjG,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,kBAAkB,EAAE,CAAC;IAC3D,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,uBAAuB,EAAE,CAAC;IACxD,MAAM,YAAY,GAAG,yCAAyC,CAAC,cAAc,EAAE,WAAW,EAAE,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3H,MAAM,gBAAgB,GAAG,YAAY,KAAK,kBAAkB,CAAC,OAAO,IAAI,YAAY,KAAK,cAAc,CAAC,OAAO,CAAC;IAChH,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IAEjF,OAAO;QACL,YAAY;QACZ,SAAS,EAAE,SAAS,CAAC,YAAY,CAAC,IAAI,gBAAgB;QACtD,MAAM,EAAE,QAAQ;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback } from 'react';\n\nimport { NavigationZoneName } from '@wildo-ai/saas-models';\n\nimport { NavigationZone } from '~wildo-frontend-lib/core/navigation/navigation.schemas';\nimport { useNavigationController } from '~wildo-frontend-lib/core/navigation/useNavigationController';\nimport { useNavigationState } from '~wildo-frontend-lib/core/navigation/useNavigationState';\nimport type { NavigationBackBehavior } from '~wildo-frontend-lib/core/app-shell/app-shell.schemas';\nimport { resolveApplicationLevelNavigationBackZone } from './ApplicationLevel_NavigationBack';\n\nexport interface UseNavigationBackBehaviorOptions {\n /** The zone the control walks back; absent, the focused zone when it holds content, else PRIMARY. */\n navigationZone?: NavigationZone;\n}\n\n/**\n * Behavior hook for the navigation-back control (#1828): which zone it walks back, whether it is shown at all, and the\n * gesture. Data only, so a renderer that is not the DOM decides visibility exactly as the preset does.\n *\n * ─── Hidden when the gesture would do NOTHING ───────────────────────────────────────────────────\n *\n * In the PRIMARY zone there is nothing to walk back to below the first entry, so the control hides.\n *\n * In an ADJACENT zone — a hosted pane beside a page — a single entry is still something to leave: `goBack` on a\n * structural zone with nothing beneath is the controller's own way of closing it, and without that a one-entry pane had\n * no close control at all (the workbench's conversation found it, 2026-09-22). The label stays \"back\": the gesture\n * returns the page to what it was.\n *\n * ── The OVERLAY layer is neither of those, and folding it into \"not primary\" shipped a DEAD CONTROL (2026-09-25). ──\n *\n * A scoped controller — the settings hub is the live one — hosts its own section stack inside an overlay and answers\n * `canGoBack` from its own depth. At a section ROOT that is `false`, and its `goBack` dispatches a pop its reducer returns\n * unchanged. The guard tested `=== PRIMARY`, so an OVERLAY zone fell through it: the root of every settings section\n * rendered an enabled, focusable back arrow that did nothing on click.\n *\n * A structural PANE is the only case where \"nothing beneath\" still means something to do, because closing the pane is\n * that something. An overlay has its own dismiss chrome.\n */\nexport function useNavigationBackBehavior({ navigationZone }: UseNavigationBackBehaviorOptions = {}): NavigationBackBehavior {\n const { focusedZone, getZoneDepth } = useNavigationState();\n const { goBack, canGoBack } = useNavigationController();\n const resolvedZone = resolveApplicationLevelNavigationBackZone(navigationZone, focusedZone, getZoneDepth(focusedZone) > 0);\n const zoneClosesOnBack = resolvedZone !== NavigationZoneName.PRIMARY && resolvedZone !== NavigationZone.OVERLAY;\n const walkBack = useCallback(() => goBack(resolvedZone), [goBack, resolvedZone]);\n\n return {\n resolvedZone,\n isVisible: canGoBack(resolvedZone) || zoneClosesOnBack,\n goBack: walkBack,\n };\n}\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { FrontendComponentType } from '@wildo-ai/presets-components-models';
|
|
2
|
+
import { type IconRequest_Resources } from '../../../core/icons/icon-registry.frontend.schemas';
|
|
3
|
+
import type { ResourceBrowserClickContext } from '../../../core/config/launcher-items.frontend.schemas';
|
|
4
|
+
import type { LoadingScope } from '../../../core/loading/loading-types.frontend.schemas';
|
|
5
|
+
/** Both bundles this browser reads: its own words, and the generic list's `noItems` empty-state default. */
|
|
6
|
+
export declare const SIDEBAR_RESOURCE_BROWSER_LABEL_COMPONENTS: FrontendComponentType[];
|
|
7
|
+
/** What a sidebar resource browser is showing, decided once here so every renderer shows the same thing (#1828). */
|
|
8
|
+
export declare enum SidebarResourceBrowserState {
|
|
9
|
+
/** The resource type is not registered. The words are `unavailableLabel`; the identifier is logged. */
|
|
10
|
+
UNREGISTERED = "unregistered",
|
|
11
|
+
/** The declared operation does not resolve on the resource: a configuration problem, `unavailableLabel` too. */
|
|
12
|
+
OPERATION_UNRESOLVABLE = "operation_unresolvable",
|
|
13
|
+
/** The FIRST read is in flight: nothing has been read yet. A re-read keeps the state its data gives (see `isLoading`). */
|
|
14
|
+
LOADING = "loading",
|
|
15
|
+
/** The read failed; `errorMessage` says why, in the person's words. */
|
|
16
|
+
FAILED = "failed",
|
|
17
|
+
/** The read answered no instance (after `instanceFilter`); the words are `emptyLabel`. */
|
|
18
|
+
EMPTY = "empty",
|
|
19
|
+
/** `instances` holds what to show. */
|
|
20
|
+
READY = "ready"
|
|
21
|
+
}
|
|
22
|
+
/** One instance the browser lists: its name, and what selecting it does. */
|
|
23
|
+
export interface SidebarResourceBrowserInstance {
|
|
24
|
+
/** A stable render key: the record's id, else its position. */
|
|
25
|
+
key: string;
|
|
26
|
+
/** The record's id, as the click context and the navigation carry it (`''` when the record has none). */
|
|
27
|
+
id: string;
|
|
28
|
+
/** The record's name, through the shared label resolver. */
|
|
29
|
+
label: string;
|
|
30
|
+
/** The record as read, for an `onInstanceClick` that needs more than its id. */
|
|
31
|
+
data: Record<string, unknown>;
|
|
32
|
+
/** The authored `onInstanceClick`, else navigation to the record. */
|
|
33
|
+
onSelect: () => void;
|
|
34
|
+
}
|
|
35
|
+
export interface UseSidebarResourceBrowserOptions {
|
|
36
|
+
resourceType: string;
|
|
37
|
+
operation?: string;
|
|
38
|
+
operationVariant?: string;
|
|
39
|
+
navigateOperation?: string;
|
|
40
|
+
navigateOperationVariant?: string;
|
|
41
|
+
instanceFilter?: (instance: Record<string, unknown>) => boolean;
|
|
42
|
+
onInstanceClick?: (context: ResourceBrowserClickContext) => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The DATA of a sidebar resource browser (#1828): which instances to list, named, with what selecting each does, and the
|
|
46
|
+
* state that decides what is shown. Data only, as the app-level behavior hooks are (`app-shell.schemas.ts`): no element,
|
|
47
|
+
* no class, and the icon as a REFERENCE, so a renderer that is not the DOM lists the same instances.
|
|
48
|
+
*
|
|
49
|
+
* Reads the instances through `doOperation` with scope-aware `contextualParameters` (the bound operation defaults to
|
|
50
|
+
* `LIST`), applies `instanceFilter` client-side, and navigates to an instance through `READ` unless `navigateOperation`
|
|
51
|
+
* or a non-LIST `operation` names another.
|
|
52
|
+
*/
|
|
53
|
+
export interface SidebarResourceBrowserBehavior {
|
|
54
|
+
state: SidebarResourceBrowserState;
|
|
55
|
+
/**
|
|
56
|
+
* A read is in flight, the first or a re-read. A re-read keeps the instances already read, and the state they give, until
|
|
57
|
+
* it answers (#1828 review F1): a browser that blanked its list on every re-read would flash its empty text.
|
|
58
|
+
*/
|
|
59
|
+
isLoading: boolean;
|
|
60
|
+
instances: SidebarResourceBrowserInstance[];
|
|
61
|
+
/** The failure in the person's words, when `state` is `FAILED`. */
|
|
62
|
+
errorMessage: string | null;
|
|
63
|
+
/** The resource's icon, as a reference; the renderer draws it. */
|
|
64
|
+
resourceIconReference: IconRequest_Resources;
|
|
65
|
+
/** The list's accessible name: the resource's title. */
|
|
66
|
+
listAriaLabel: string;
|
|
67
|
+
/** What an EMPTY browser says. */
|
|
68
|
+
emptyLabel: string;
|
|
69
|
+
/** What an UNREGISTERED or OPERATION_UNRESOLVABLE browser says. */
|
|
70
|
+
unavailableLabel: string;
|
|
71
|
+
/** The label bundles the browser's words come from, and the loading scope of its read, for a loading gate. */
|
|
72
|
+
i18nKeys: string[];
|
|
73
|
+
loadingScopes: LoadingScope[];
|
|
74
|
+
}
|
|
75
|
+
export declare function useSidebarResourceBrowser({ resourceType, operation, operationVariant, navigateOperation, navigateOperationVariant, instanceFilter, onInstanceClick, }: UseSidebarResourceBrowserOptions): SidebarResourceBrowserBehavior;
|
|
76
|
+
//# sourceMappingURL=useSidebarResourceBrowser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSidebarResourceBrowser.d.ts","sourceRoot":"","sources":["../../../../../src/components/navigation/app-level/useSidebarResourceBrowser.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAY5E,OAAO,EAAgB,KAAK,qB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OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,8BAA8B,EAAE,CAAC;IAC5C,mEAAmE;IACnE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,kEAAkE;IAClE,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,wDAAwD;IACxD,aAAa,EAAE,MAAM,CAAC;IACtB,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,gBAAgB,EAAE,MAAM,CAAC;IACzB,8GAA8G;IAC9G,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,EAAE,YAAY,EAAE,CAAC;CAC/B;AAED,wBAAgB,yBAAyB,CAAC,EACxC,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACxB,cAAc,EACd,eAAe,GAChB,EAAE,gCAAgC,GAAG,8BAA8B,CAiQnE"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { useEffect, useState, useRef, useCallback, useMemo } from 'react';
|
|
2
|
+
import { CoreResourceOperation, ResourcesConfig_OperationPathUtils, } from '@wildo-ai/saas-models';
|
|
3
|
+
import { FrontendComponentType } from '@wildo-ai/presets-components-models';
|
|
4
|
+
import { ApplicationLevelComponentType } from '../../../core/config/app-level-components.frontend.schemas.js';
|
|
5
|
+
import { ScopeUtilsService } from '../../../core/scope/scope.utils.frontend.service.js';
|
|
6
|
+
import { useAppScopeSafe } from '../../../core/scope/useAppScope.js';
|
|
7
|
+
import { useResourceRegistry } from '../../../core/resources/useResourceRegistry.js';
|
|
8
|
+
import { frontendResourceUtils, FrontendResourceUtils } from '../../../core/resources/frontend-resource.utils.js';
|
|
9
|
+
import { useI18n } from '../../../core/i18n/useI18n.js';
|
|
10
|
+
import { resolveResourceHeaderLabel } from '../../../core/i18n/component-label-resolution.utils.js';
|
|
11
|
+
import { resolveSidebarBrowserEmptyLabel } from '../../../components/navigation/app-level/sidebar-resource-browser-empty-label.js';
|
|
12
|
+
import { NavigationUtils } from '../../../core/navigation/navigation.utils.js';
|
|
13
|
+
import { useNavigationController } from '../../../core/navigation/useNavigationController.js';
|
|
14
|
+
import { IconCategory } from '../../../core/icons/icon-registry.frontend.schemas.js';
|
|
15
|
+
import { LoggerFrontendService } from '../../../core/monitoring/logger.frontend.service.js';
|
|
16
|
+
import { useUserFacingErrorMessage } from '../../../core/errors/useUserFacingErrorMessage.js';
|
|
17
|
+
import { resolveSidebarResourceBrowserOperation } from '../../../core/navigation/sidebar-resource-browser-operation.js';
|
|
18
|
+
import { buildResourceLoadingScope } from '../../../core/loading/loading-scope.frontend.utils.js';
|
|
19
|
+
const logger = LoggerFrontendService.getLogger();
|
|
20
|
+
const logDebug = logger.debugByType('sidebar-resource-browser');
|
|
21
|
+
logger.setDebugTypeLogging('sidebar-resource-browser', false);
|
|
22
|
+
/** Both bundles this browser reads: its own words, and the generic list's `noItems` empty-state default. */
|
|
23
|
+
export const SIDEBAR_RESOURCE_BROWSER_LABEL_COMPONENTS = [
|
|
24
|
+
FrontendComponentType.APPLICATION_LEVEL_SIDEBAR,
|
|
25
|
+
FrontendComponentType.RESOURCES_LAYOUTS_LIST,
|
|
26
|
+
];
|
|
27
|
+
/** What a sidebar resource browser is showing, decided once here so every renderer shows the same thing (#1828). */
|
|
28
|
+
export var SidebarResourceBrowserState;
|
|
29
|
+
(function (SidebarResourceBrowserState) {
|
|
30
|
+
/** The resource type is not registered. The words are `unavailableLabel`; the identifier is logged. */
|
|
31
|
+
SidebarResourceBrowserState["UNREGISTERED"] = "unregistered";
|
|
32
|
+
/** The declared operation does not resolve on the resource: a configuration problem, `unavailableLabel` too. */
|
|
33
|
+
SidebarResourceBrowserState["OPERATION_UNRESOLVABLE"] = "operation_unresolvable";
|
|
34
|
+
/** The FIRST read is in flight: nothing has been read yet. A re-read keeps the state its data gives (see `isLoading`). */
|
|
35
|
+
SidebarResourceBrowserState["LOADING"] = "loading";
|
|
36
|
+
/** The read failed; `errorMessage` says why, in the person's words. */
|
|
37
|
+
SidebarResourceBrowserState["FAILED"] = "failed";
|
|
38
|
+
/** The read answered no instance (after `instanceFilter`); the words are `emptyLabel`. */
|
|
39
|
+
SidebarResourceBrowserState["EMPTY"] = "empty";
|
|
40
|
+
/** `instances` holds what to show. */
|
|
41
|
+
SidebarResourceBrowserState["READY"] = "ready";
|
|
42
|
+
})(SidebarResourceBrowserState || (SidebarResourceBrowserState = {}));
|
|
43
|
+
export function useSidebarResourceBrowser({ resourceType, operation, operationVariant, navigateOperation, navigateOperationVariant, instanceFilter, onInstanceClick, }) {
|
|
44
|
+
const { registry, doOperation } = useResourceRegistry();
|
|
45
|
+
const { navigateToResource } = useNavigationController();
|
|
46
|
+
const appScope = useAppScopeSafe();
|
|
47
|
+
const { tResourceHeader, tResourceEmptyState, t, tComponent, formatDate, formatDateTime } = useI18n({ resource: resourceType, component: SIDEBAR_RESOURCE_BROWSER_LABEL_COMPONENTS });
|
|
48
|
+
// Stable identity, so the fetch effect below may call it without listing it.
|
|
49
|
+
const toUserFacingErrorMessage = useUserFacingErrorMessage();
|
|
50
|
+
const [instances, setInstances] = useState([]);
|
|
51
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
52
|
+
const [error, setError] = useState(null);
|
|
53
|
+
// A configuration problem, not a caught error: its words are a label.
|
|
54
|
+
const [operationUnresolvable, setOperationUnresolvable] = useState(false);
|
|
55
|
+
const doOperationRef = useRef(doOperation);
|
|
56
|
+
doOperationRef.current = doOperation;
|
|
57
|
+
const resourceConfig = registry.resourceConfigurations[resourceType];
|
|
58
|
+
const boundOperation = useMemo(() => {
|
|
59
|
+
if (!resourceConfig)
|
|
60
|
+
return undefined;
|
|
61
|
+
return resolveSidebarResourceBrowserOperation(resourceConfig, operation ?? CoreResourceOperation.LIST, operationVariant);
|
|
62
|
+
}, [resourceConfig, operation, operationVariant]);
|
|
63
|
+
const navigationOperationResolved = useMemo(() => {
|
|
64
|
+
if (!resourceConfig)
|
|
65
|
+
return undefined;
|
|
66
|
+
if (navigateOperation) {
|
|
67
|
+
return resolveSidebarResourceBrowserOperation(resourceConfig, navigateOperation, navigateOperationVariant);
|
|
68
|
+
}
|
|
69
|
+
if (operation && operation !== CoreResourceOperation.LIST) {
|
|
70
|
+
return resolveSidebarResourceBrowserOperation(resourceConfig, operation, operationVariant);
|
|
71
|
+
}
|
|
72
|
+
return (resolveSidebarResourceBrowserOperation(resourceConfig, CoreResourceOperation.READ) ??
|
|
73
|
+
boundOperation);
|
|
74
|
+
}, [resourceConfig, navigateOperation, navigateOperationVariant, operation, operationVariant, boundOperation]);
|
|
75
|
+
const scopedContextIdentifiers = useMemo(() => {
|
|
76
|
+
if (!resourceConfig)
|
|
77
|
+
return {};
|
|
78
|
+
const primaryScopeInitiatorIds = ScopeUtilsService.buildInitiatorIds({
|
|
79
|
+
userId: appScope?.currentUserId,
|
|
80
|
+
organizationId: appScope?.currentOrganizationId,
|
|
81
|
+
applicationId: appScope?.currentApplicationId,
|
|
82
|
+
anonymousUserId: appScope?.currentAnonymousUserId,
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
...ScopeUtilsService.primaryScopeToContextIdentifiers(primaryScopeInitiatorIds, resourceConfig.resourcePrimaryScope),
|
|
86
|
+
...(appScope?.buildContextResourceIdentifiers() ?? {}),
|
|
87
|
+
};
|
|
88
|
+
}, [
|
|
89
|
+
resourceConfig,
|
|
90
|
+
appScope?.currentUserId,
|
|
91
|
+
appScope?.currentOrganizationId,
|
|
92
|
+
appScope?.currentApplicationId,
|
|
93
|
+
appScope?.currentAnonymousUserId,
|
|
94
|
+
appScope,
|
|
95
|
+
]);
|
|
96
|
+
const operationPathKey = useMemo(() => {
|
|
97
|
+
if (!boundOperation)
|
|
98
|
+
return null;
|
|
99
|
+
return ResourcesConfig_OperationPathUtils.createOperationPathKeyFromOperation(boundOperation);
|
|
100
|
+
}, [boundOperation]);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
setOperationUnresolvable(Boolean(resourceConfig) && !operationPathKey);
|
|
103
|
+
if (!operationPathKey || !resourceConfig) {
|
|
104
|
+
setInstances([]);
|
|
105
|
+
if (resourceConfig && !operationPathKey) {
|
|
106
|
+
const message = `Sidebar resource browser cannot resolve operation "${operation ?? CoreResourceOperation.LIST}" on resource "${resourceType}".`;
|
|
107
|
+
setError(null);
|
|
108
|
+
logger.warn(message, {
|
|
109
|
+
resourceType,
|
|
110
|
+
operationIdentifier: operation ?? CoreResourceOperation.LIST,
|
|
111
|
+
operationVariant,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
if (!resourceConfig) {
|
|
116
|
+
// The person reads the `resourceBrowserUnavailable` label; the identifier belongs in the log.
|
|
117
|
+
logger.warn(`Sidebar resource browser: resource type "${resourceType}" is not registered.`, { resourceType });
|
|
118
|
+
}
|
|
119
|
+
setError(null);
|
|
120
|
+
}
|
|
121
|
+
setIsLoading(false);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
let cancelled = false;
|
|
125
|
+
const fetchInstances = async () => {
|
|
126
|
+
setIsLoading(true);
|
|
127
|
+
setError(null);
|
|
128
|
+
try {
|
|
129
|
+
logDebug('Fetching resource instances', { resourceType, operationPathKey });
|
|
130
|
+
const result = await doOperationRef.current(operationPathKey, {
|
|
131
|
+
contextualParameters: scopedContextIdentifiers,
|
|
132
|
+
queryParameters: { limit: 100 },
|
|
133
|
+
});
|
|
134
|
+
if (cancelled)
|
|
135
|
+
return;
|
|
136
|
+
const items = Array.isArray(result) ? result : result?.data ?? [];
|
|
137
|
+
setInstances(items);
|
|
138
|
+
logDebug('Fetched instances', { count: items.length });
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
if (cancelled)
|
|
142
|
+
return;
|
|
143
|
+
// Shown to the person, so resolved to localized text — `extractErrorInfo(err).message` was the
|
|
144
|
+
// backend's i18n REFERENCE (#1160).
|
|
145
|
+
setError(toUserFacingErrorMessage(err));
|
|
146
|
+
logger.error('SidebarResourceBrowser fetch failed', { resourceType, error: err });
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
if (!cancelled)
|
|
150
|
+
setIsLoading(false);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
fetchInstances();
|
|
154
|
+
return () => { cancelled = true; };
|
|
155
|
+
}, [operationPathKey, resourceType, resourceConfig, scopedContextIdentifiers, operation, operationVariant]);
|
|
156
|
+
const filteredInstances = useMemo(() => {
|
|
157
|
+
if (!instanceFilter)
|
|
158
|
+
return instances;
|
|
159
|
+
return instances.filter(instanceFilter);
|
|
160
|
+
}, [instances, instanceFilter]);
|
|
161
|
+
const listAriaLabel = useMemo(() => resolveResourceHeaderLabel({
|
|
162
|
+
tResourceHeader,
|
|
163
|
+
resourceType,
|
|
164
|
+
key: 'title',
|
|
165
|
+
}), [resourceType, tResourceHeader]);
|
|
166
|
+
const handleInstanceClick = useCallback((instance) => {
|
|
167
|
+
const instanceId = (instance.id ?? instance._id ?? '');
|
|
168
|
+
if (onInstanceClick) {
|
|
169
|
+
onInstanceClick({
|
|
170
|
+
resourceType,
|
|
171
|
+
instanceId,
|
|
172
|
+
instanceData: instance,
|
|
173
|
+
});
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (resourceConfig && navigationOperationResolved) {
|
|
177
|
+
const contextIdentifiers = {
|
|
178
|
+
...scopedContextIdentifiers,
|
|
179
|
+
[resourceType]: instanceId,
|
|
180
|
+
};
|
|
181
|
+
const parentResourcesRequirements = frontendResourceUtils.buildParentResourcesRequirements(resourceType, contextIdentifiers, registry);
|
|
182
|
+
const resourceContext = frontendResourceUtils.createFrontendResourceOperationContextFromOperation({
|
|
183
|
+
resourceType: resourceType,
|
|
184
|
+
operation: navigationOperationResolved,
|
|
185
|
+
contextResourceIdentifiers: contextIdentifiers,
|
|
186
|
+
parentResourcesRequirements,
|
|
187
|
+
});
|
|
188
|
+
navigateToResource(resourceContext, NavigationUtils.createAppLevelInitiator(ApplicationLevelComponentType.SIDEBAR));
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
logger.warn('SidebarResourceBrowser navigation skipped: no navigation operation resolved', {
|
|
192
|
+
resourceType,
|
|
193
|
+
fetchOperationIdentifier: boundOperation?.operationIdentifier,
|
|
194
|
+
navigationOperationIdentifier: navigateOperation ?? CoreResourceOperation.READ,
|
|
195
|
+
navigationOperationVariant: navigateOperationVariant,
|
|
196
|
+
instanceId,
|
|
197
|
+
});
|
|
198
|
+
}, [
|
|
199
|
+
resourceType,
|
|
200
|
+
onInstanceClick,
|
|
201
|
+
resourceConfig,
|
|
202
|
+
navigationOperationResolved,
|
|
203
|
+
navigateOperation,
|
|
204
|
+
navigateOperationVariant,
|
|
205
|
+
scopedContextIdentifiers,
|
|
206
|
+
registry,
|
|
207
|
+
navigateToResource,
|
|
208
|
+
boundOperation,
|
|
209
|
+
]);
|
|
210
|
+
/*
|
|
211
|
+
* A record's name through the ONE shared resolver, like every other surface that names a record (#1851). This
|
|
212
|
+
* browser used to call the label callback itself with only `currentObject`, so a callback reading `t`, a date
|
|
213
|
+
* formatter or the resource type threw, and the catch fell back to `name`/`title`/`id` — a product showed its id
|
|
214
|
+
* here while its list row showed its word. The shared resolver's own fallback is the record's declared summary
|
|
215
|
+
* fields, then its id.
|
|
216
|
+
*/
|
|
217
|
+
const listedInstances = useMemo(() => filteredInstances.map((instance, index) => ({
|
|
218
|
+
key: String(instance.id ?? instance._id ?? `sidebar-resource-${index}`),
|
|
219
|
+
id: String(instance.id ?? instance._id ?? ''),
|
|
220
|
+
label: FrontendResourceUtils.computeFrontendResourceLabel({
|
|
221
|
+
resourceType,
|
|
222
|
+
registry,
|
|
223
|
+
currentObject: instance,
|
|
224
|
+
t,
|
|
225
|
+
formatDate,
|
|
226
|
+
formatDateTime,
|
|
227
|
+
}) ?? String(instance._id ?? ''),
|
|
228
|
+
data: instance,
|
|
229
|
+
onSelect: () => handleInstanceClick(instance),
|
|
230
|
+
})), [filteredInstances, resourceType, registry, t, formatDate, formatDateTime, handleInstanceClick]);
|
|
231
|
+
const loadingScopes = useMemo(() => {
|
|
232
|
+
if (!boundOperation)
|
|
233
|
+
return [];
|
|
234
|
+
return [
|
|
235
|
+
buildResourceLoadingScope({
|
|
236
|
+
resourceType,
|
|
237
|
+
operation: boundOperation.operationIdentifier,
|
|
238
|
+
}),
|
|
239
|
+
];
|
|
240
|
+
}, [resourceType, boundOperation]);
|
|
241
|
+
const i18nKeys = useMemo(() => [`resources.${resourceType}`], [resourceType]);
|
|
242
|
+
const resourceIconReference = useMemo(() => ({ category: IconCategory.RESOURCES, resourceType }), [resourceType]);
|
|
243
|
+
// A re-read keeps what was read: LOADING only while there is nothing yet, so the instances already shown stay drawn.
|
|
244
|
+
const state = !resourceConfig
|
|
245
|
+
? SidebarResourceBrowserState.UNREGISTERED
|
|
246
|
+
: operationUnresolvable
|
|
247
|
+
? SidebarResourceBrowserState.OPERATION_UNRESOLVABLE
|
|
248
|
+
: error !== null
|
|
249
|
+
? SidebarResourceBrowserState.FAILED
|
|
250
|
+
: listedInstances.length > 0
|
|
251
|
+
? SidebarResourceBrowserState.READY
|
|
252
|
+
: isLoading
|
|
253
|
+
? SidebarResourceBrowserState.LOADING
|
|
254
|
+
: SidebarResourceBrowserState.EMPTY;
|
|
255
|
+
return {
|
|
256
|
+
state,
|
|
257
|
+
isLoading,
|
|
258
|
+
instances: listedInstances,
|
|
259
|
+
errorMessage: error,
|
|
260
|
+
resourceIconReference,
|
|
261
|
+
listAriaLabel,
|
|
262
|
+
emptyLabel: resolveSidebarBrowserEmptyLabel({ resourceType, tResourceEmptyState, tComponent }),
|
|
263
|
+
unavailableLabel: tComponent(FrontendComponentType.APPLICATION_LEVEL_SIDEBAR, 'resourceBrowserUnavailable'),
|
|
264
|
+
i18nKeys,
|
|
265
|
+
loadingScopes,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=useSidebarResourceBrowser.js.map
|