@collabdt/core 0.5.1 → 0.5.4
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/core/components/AppSidebarContent.d.ts +2 -3
- package/dist/core/components/AppSidebarContent.d.ts.map +1 -1
- package/dist/core/components/AppSidebarContent.js +10 -1
- package/dist/core/components/AppSidebarContent.js.map +1 -1
- package/dist/core/components/Toolbar.d.ts +2 -3
- package/dist/core/components/Toolbar.d.ts.map +1 -1
- package/dist/core/components/Toolbar.js.map +1 -1
- package/dist/core/components/ui/AppSidebar.d.ts +2 -2
- package/dist/core/components/ui/AppSidebar.d.ts.map +1 -1
- package/dist/core/components/ui/AppSidebar.js.map +1 -1
- package/dist/core/components/ui/Comments/CommentsSection.d.ts.map +1 -1
- package/dist/core/components/ui/Comments/CommentsSection.js +10 -9
- package/dist/core/components/ui/Comments/CommentsSection.js.map +1 -1
- package/dist/core/components/ui/Sensors/SensorsSection.d.ts.map +1 -1
- package/dist/core/components/ui/Sensors/SensorsSection.js +24 -23
- package/dist/core/components/ui/Sensors/SensorsSection.js.map +1 -1
- package/dist/core/components/ui/ViewerSidebar/Shell.js +1 -1
- package/dist/core/components/ui/ViewerSidebar/Shell.js.map +1 -1
- package/dist/core/components/ui/ViewerSidebar/TabStrip.d.ts +6 -5
- package/dist/core/components/ui/ViewerSidebar/TabStrip.d.ts.map +1 -1
- package/dist/core/components/ui/ViewerSidebar/TabStrip.js +6 -4
- package/dist/core/components/ui/ViewerSidebar/TabStrip.js.map +1 -1
- package/dist/core/components/ui/ViewerSidebar/sidebarTabs.d.ts +16 -9
- package/dist/core/components/ui/ViewerSidebar/sidebarTabs.d.ts.map +1 -1
- package/dist/core/components/ui/ViewerSidebar/sidebarTabs.js.map +1 -1
- package/dist/core/components/viewers/Viewer.d.ts.map +1 -1
- package/dist/core/components/viewers/Viewer.js +17 -8
- package/dist/core/components/viewers/Viewer.js.map +1 -1
- package/dist/core/components/viewers/bim/BimViewer.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/BimViewer.js +6 -1
- package/dist/core/components/viewers/bim/BimViewer.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/index.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/index.js +5 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/index.js.map +1 -1
- package/dist/core/components/viewers/bim/src/ElementAppearance.d.ts +10 -1
- package/dist/core/components/viewers/bim/src/ElementAppearance.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/ElementAppearance.js +36 -1
- package/dist/core/components/viewers/bim/src/ElementAppearance.js.map +1 -1
- package/dist/core/components/viewers/bim/src/ModelsSync.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/ModelsSync.js +6 -5
- package/dist/core/components/viewers/bim/src/ModelsSync.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.d.ts +12 -1
- package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.js +18 -2
- package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.js.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.d.ts.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.js +6 -3
- package/dist/core/components/viewers/map/MapViewer.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/index.js +5 -1
- package/dist/core/components/viewers/map/src/MapSidebar/index.js.map +1 -1
- package/dist/core/components/viewers/map/utils/stringToColour.d.ts +3 -0
- package/dist/core/components/viewers/map/utils/stringToColour.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/stringToColour.js +72 -70
- package/dist/core/components/viewers/map/utils/stringToColour.js.map +1 -1
- package/dist/core/components/viewers/plugins/src/PluginCard.d.ts.map +1 -1
- package/dist/core/components/viewers/plugins/src/PluginCard.js +8 -4
- package/dist/core/components/viewers/plugins/src/PluginCard.js.map +1 -1
- package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/index.d.ts.map +1 -1
- package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/index.js +5 -1
- package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/index.js.map +1 -1
- package/dist/core/components/viewers/shared/legends/ViewerLegendHost.d.ts +10 -0
- package/dist/core/components/viewers/shared/legends/ViewerLegendHost.d.ts.map +1 -0
- package/dist/core/components/viewers/{map/legends/MapLegendHost.js → shared/legends/ViewerLegendHost.js} +48 -8
- package/dist/core/components/viewers/shared/legends/ViewerLegendHost.js.map +1 -0
- package/dist/core/components/viewers/viewerAccess.d.ts +7 -0
- package/dist/core/components/viewers/viewerAccess.d.ts.map +1 -0
- package/dist/core/components/viewers/viewerAccess.js +9 -0
- package/dist/core/components/viewers/viewerAccess.js.map +1 -0
- package/dist/core/i18n/messages/en.json +5 -0
- package/dist/core/i18n/messages/es.json +5 -0
- package/dist/core/i18n/messages/fr.json +5 -0
- package/dist/core/plugins/hello-bim/components/SpaceDialog.d.ts +13 -0
- package/dist/core/plugins/hello-bim/components/SpaceDialog.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/components/SpaceDialog.js +80 -0
- package/dist/core/plugins/hello-bim/components/SpaceDialog.js.map +1 -0
- package/dist/core/plugins/hello-bim/components/SpacesLegend.d.ts +11 -0
- package/dist/core/plugins/hello-bim/components/SpacesLegend.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/components/SpacesLegend.js +16 -0
- package/dist/core/plugins/hello-bim/components/SpacesLegend.js.map +1 -0
- package/dist/core/plugins/hello-bim/components/SpacesTab.d.ts +4 -0
- package/dist/core/plugins/hello-bim/components/SpacesTab.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/components/SpacesTab.js +211 -0
- package/dist/core/plugins/hello-bim/components/SpacesTab.js.map +1 -0
- package/dist/core/plugins/hello-bim/components/SpacesTool.d.ts +8 -0
- package/dist/core/plugins/hello-bim/components/SpacesTool.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/components/SpacesTool.js +68 -0
- package/dist/core/plugins/hello-bim/components/SpacesTool.js.map +1 -0
- package/dist/core/plugins/hello-bim/components/icons.d.ts +13 -0
- package/dist/core/plugins/hello-bim/components/icons.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/components/icons.js +52 -0
- package/dist/core/plugins/hello-bim/components/icons.js.map +1 -0
- package/dist/core/plugins/hello-bim/index.d.ts +2 -6
- package/dist/core/plugins/hello-bim/index.d.ts.map +1 -1
- package/dist/core/plugins/hello-bim/index.js +27 -3
- package/dist/core/plugins/hello-bim/index.js.map +1 -1
- package/dist/core/plugins/hello-bim/manifest.json +97 -31
- package/dist/core/plugins/hello-bim/spaces.d.ts +57 -0
- package/dist/core/plugins/hello-bim/spaces.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/spaces.js +207 -0
- package/dist/core/plugins/hello-bim/spaces.js.map +1 -0
- package/dist/core/plugins/hello-map/components/MapTool.d.ts +9 -0
- package/dist/core/plugins/hello-map/components/MapTool.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/components/{HelloMapTool.js → MapTool.js} +30 -11
- package/dist/core/plugins/hello-map/components/MapTool.js.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkerDialog.d.ts +9 -0
- package/dist/core/plugins/hello-map/components/MarkerDialog.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkerDialog.js +47 -0
- package/dist/core/plugins/hello-map/components/MarkerDialog.js.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkersLayer.d.ts +8 -0
- package/dist/core/plugins/hello-map/components/MarkersLayer.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkersLayer.js +133 -0
- package/dist/core/plugins/hello-map/components/MarkersLayer.js.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkersLegend.d.ts +11 -0
- package/dist/core/plugins/hello-map/components/MarkersLegend.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkersLegend.js +20 -0
- package/dist/core/plugins/hello-map/components/MarkersLegend.js.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkersPage.d.ts +6 -0
- package/dist/core/plugins/hello-map/components/MarkersPage.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkersPage.js +40 -0
- package/dist/core/plugins/hello-map/components/MarkersPage.js.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkersTab.d.ts +4 -0
- package/dist/core/plugins/hello-map/components/MarkersTab.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkersTab.js +275 -0
- package/dist/core/plugins/hello-map/components/MarkersTab.js.map +1 -0
- package/dist/core/plugins/hello-map/index.d.ts +2 -5
- package/dist/core/plugins/hello-map/index.d.ts.map +1 -1
- package/dist/core/plugins/hello-map/index.js +43 -3
- package/dist/core/plugins/hello-map/index.js.map +1 -1
- package/dist/core/plugins/hello-map/manifest.json +85 -12
- package/dist/core/plugins/hello-map/markers.d.ts +32 -0
- package/dist/core/plugins/hello-map/markers.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/markers.js +143 -0
- package/dist/core/plugins/hello-map/markers.js.map +1 -0
- package/dist/core/plugins/host/PluginDataPageHost.d.ts +10 -0
- package/dist/core/plugins/host/PluginDataPageHost.d.ts.map +1 -0
- package/dist/core/plugins/host/PluginDataPageHost.js +142 -0
- package/dist/core/plugins/host/PluginDataPageHost.js.map +1 -0
- package/dist/core/plugins/host/PluginDialogHost.d.ts +7 -0
- package/dist/core/plugins/host/PluginDialogHost.d.ts.map +1 -0
- package/dist/core/plugins/host/PluginDialogHost.js +80 -0
- package/dist/core/plugins/host/PluginDialogHost.js.map +1 -0
- package/dist/core/plugins/host/PluginMapLayerHost.d.ts +6 -0
- package/dist/core/plugins/host/PluginMapLayerHost.d.ts.map +1 -0
- package/dist/core/plugins/host/PluginMapLayerHost.js +26 -0
- package/dist/core/plugins/host/PluginMapLayerHost.js.map +1 -0
- package/dist/core/plugins/host/dialogs.d.ts +25 -0
- package/dist/core/plugins/host/dialogs.d.ts.map +1 -0
- package/dist/core/plugins/host/dialogs.js +50 -0
- package/dist/core/plugins/host/dialogs.js.map +1 -0
- package/dist/core/plugins/host/host.d.ts.map +1 -1
- package/dist/core/plugins/host/host.js +2 -0
- package/dist/core/plugins/host/host.js.map +1 -1
- package/dist/core/plugins/host/pluginState.d.ts +28 -0
- package/dist/core/plugins/host/pluginState.d.ts.map +1 -0
- package/dist/core/plugins/host/pluginState.js +49 -0
- package/dist/core/plugins/host/pluginState.js.map +1 -0
- package/dist/core/plugins/host/pluginViewerKey.d.ts +13 -0
- package/dist/core/plugins/host/pluginViewerKey.d.ts.map +1 -0
- package/dist/core/plugins/host/pluginViewerKey.js +18 -0
- package/dist/core/plugins/host/pluginViewerKey.js.map +1 -0
- package/dist/core/plugins/host/provider.d.ts.map +1 -1
- package/dist/core/plugins/host/provider.js +2 -1
- package/dist/core/plugins/host/provider.js.map +1 -1
- package/dist/core/plugins/host/runtimeShims.d.ts.map +1 -1
- package/dist/core/plugins/host/runtimeShims.js +61 -1
- package/dist/core/plugins/host/runtimeShims.js.map +1 -1
- package/dist/core/plugins/host/usePluginDataPages.d.ts +15 -0
- package/dist/core/plugins/host/usePluginDataPages.d.ts.map +1 -0
- package/dist/core/plugins/host/usePluginDataPages.js +22 -0
- package/dist/core/plugins/host/usePluginDataPages.js.map +1 -0
- package/dist/core/plugins/host/usePluginViewerTabs.d.ts +11 -0
- package/dist/core/plugins/host/usePluginViewerTabs.d.ts.map +1 -0
- package/dist/core/plugins/host/usePluginViewerTabs.js +41 -0
- package/dist/core/plugins/host/usePluginViewerTabs.js.map +1 -0
- package/dist/core/plugins/sdk/bimViewer.d.ts +29 -13
- package/dist/core/plugins/sdk/bimViewer.d.ts.map +1 -1
- package/dist/core/plugins/sdk/bimViewer.js +17 -1
- package/dist/core/plugins/sdk/bimViewer.js.map +1 -1
- package/dist/core/plugins/sdk/index.d.ts +1 -0
- package/dist/core/plugins/sdk/index.d.ts.map +1 -1
- package/dist/core/plugins/sdk/index.js +4 -1
- package/dist/core/plugins/sdk/index.js.map +1 -1
- package/dist/core/plugins/sdk/messages.d.ts +6 -0
- package/dist/core/plugins/sdk/messages.d.ts.map +1 -1
- package/dist/core/plugins/sdk/messages.js +11 -0
- package/dist/core/plugins/sdk/messages.js.map +1 -1
- package/dist/core/plugins/sdk/state.d.ts +6 -0
- package/dist/core/plugins/sdk/state.d.ts.map +1 -0
- package/dist/core/plugins/sdk/state.js +30 -0
- package/dist/core/plugins/sdk/state.js.map +1 -0
- package/dist/core/plugins/sdk/types.d.ts +55 -10
- package/dist/core/plugins/sdk/types.d.ts.map +1 -1
- package/dist/core/plugins/sdk/types.js +7 -3
- package/dist/core/plugins/sdk/types.js.map +1 -1
- package/dist/core/plugins/sdk/ui.d.ts +12 -0
- package/dist/core/plugins/sdk/ui.d.ts.map +1 -0
- package/dist/core/plugins/sdk/ui.js +16 -0
- package/dist/core/plugins/sdk/ui.js.map +1 -0
- package/dist/core/store/CombineProviders.d.ts.map +1 -1
- package/dist/core/store/CombineProviders.js +6 -2
- package/dist/core/store/CombineProviders.js.map +1 -1
- package/dist/core/store/Menus/reducer.d.ts +5 -3
- package/dist/core/store/Menus/reducer.d.ts.map +1 -1
- package/dist/core/store/Menus/reducer.js.map +1 -1
- package/dist/core/types/dbTypes.d.ts +5 -0
- package/dist/core/types/dbTypes.d.ts.map +1 -1
- package/dist/core/types/dbTypes.js.map +1 -1
- package/package.json +3 -1
- package/dist/core/components/viewers/map/legends/MapLegendHost.d.ts +0 -10
- package/dist/core/components/viewers/map/legends/MapLegendHost.d.ts.map +0 -1
- package/dist/core/components/viewers/map/legends/MapLegendHost.js.map +0 -1
- package/dist/core/plugins/hello-bim/components/HelloBimTool.d.ts +0 -18
- package/dist/core/plugins/hello-bim/components/HelloBimTool.d.ts.map +0 -1
- package/dist/core/plugins/hello-bim/components/HelloBimTool.js +0 -142
- package/dist/core/plugins/hello-bim/components/HelloBimTool.js.map +0 -1
- package/dist/core/plugins/hello-map/components/HelloMapTool.d.ts +0 -14
- package/dist/core/plugins/hello-map/components/HelloMapTool.d.ts.map +0 -1
- package/dist/core/plugins/hello-map/components/HelloMapTool.js.map +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const handleChangeViewer: (viewer: ViewerNames, setSelectedItem: React.Dispatch<React.SetStateAction<any>>, setSelectedSite: React.Dispatch<React.SetStateAction<any>>, setSelectedFile: React.Dispatch<React.SetStateAction<any>>, setView: React.Dispatch<React.SetStateAction<"table" | "detail">>, menusDispatch: any) => void;
|
|
2
|
+
import type { Organization, ViewerKey } from '../types/dbTypes';
|
|
3
|
+
export declare const handleChangeViewer: (viewer: ViewerKey, setSelectedItem: React.Dispatch<React.SetStateAction<any>>, setSelectedSite: React.Dispatch<React.SetStateAction<any>>, setSelectedFile: React.Dispatch<React.SetStateAction<any>>, setView: React.Dispatch<React.SetStateAction<"table" | "detail">>, menusDispatch: any) => void;
|
|
5
4
|
interface AppSidebarProps {
|
|
6
5
|
organization: Organization;
|
|
7
6
|
countrySubdivisionsData?: Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppSidebarContent.d.ts","sourceRoot":"","sources":["../../../src/core/components/AppSidebarContent.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"AppSidebarContent.d.ts","sourceRoot":"","sources":["../../../src/core/components/AppSidebarContent.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAmC9B,OAAO,KAAK,EAAE,YAAY,EAAY,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAOzE,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,SAAS,EACjB,iBAAiB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,EAC1D,iBAAiB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,EAC1D,iBAAiB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,EAC1D,SAAS,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC,EACjE,eAAe,GAAG,SAYnB,CAAA;AAED,UAAU,eAAe;IACvB,YAAY,EAAE,YAAY,CAAA;IAC1B,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjD,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,YAAY,EAAE,uBAAuB,EAAE,YAAY,GAAG,EAAE,eAAe,qBA2W1G"}
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
useSidebar
|
|
19
19
|
} from "../components/ui/Sidebar";
|
|
20
20
|
import { useUserRole } from "../hooks/users/users";
|
|
21
|
+
import { usePluginDataPages } from "../plugins/host/usePluginDataPages";
|
|
21
22
|
import { AppConfigContext, MapContext, useMenusContext } from "../store";
|
|
22
23
|
import { ViewerNames } from "../types/";
|
|
23
24
|
import { resolveAppContent } from "../utils/appContent";
|
|
@@ -75,6 +76,7 @@ function AppSidebarContent({ organization, countrySubdivisionsData, minioBaseUrl
|
|
|
75
76
|
setBugReportOpen,
|
|
76
77
|
setFeatureRequestOpen
|
|
77
78
|
} = useSidebar();
|
|
79
|
+
const pluginPages = usePluginDataPages();
|
|
78
80
|
const changeViewer = (viewer) => {
|
|
79
81
|
handleChangeViewer(viewer, setSelectedItem, setSelectedSite, setSelectedFile, setView, menusDispatch);
|
|
80
82
|
setOpenInfo(false);
|
|
@@ -132,7 +134,14 @@ function AppSidebarContent({ organization, countrySubdivisionsData, minioBaseUrl
|
|
|
132
134
|
id: ViewerNames.infrastructure,
|
|
133
135
|
icon: LR.TrainTrack,
|
|
134
136
|
onClick: () => changeViewer(ViewerNames.infrastructure)
|
|
135
|
-
}
|
|
137
|
+
},
|
|
138
|
+
// In Datasets, so a contributed page reads as part of the platform.
|
|
139
|
+
...pluginPages.map((page) => ({
|
|
140
|
+
title: page.title,
|
|
141
|
+
id: page.id,
|
|
142
|
+
icon: page.icon,
|
|
143
|
+
onClick: () => changeViewer(page.id)
|
|
144
|
+
}))
|
|
136
145
|
];
|
|
137
146
|
const managementItems = [
|
|
138
147
|
// {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/components/AppSidebarContent.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as LR from 'lucide-react'\r\nimport { useSession } from 'next-auth/react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from 'react'\r\n\r\n// Dependencies\r\nimport { SupportMenu } from \"../components/support/SupportMenu\"\r\nimport {\r\n SidebarContent,\r\n SidebarGroup,\r\n SidebarGroupContent,\r\n SidebarGroupLabel,\r\n SidebarMenu,\r\n SidebarMenuButton,\r\n SidebarMenuItem,\r\n SidebarHeader,\r\n SidebarFooter,\r\n useSidebar,\r\n} from '../components/ui/Sidebar'\r\nimport { useUserRole } from '../hooks/users/users'\r\nimport { AppConfigContext, MapContext, useMenusContext } from '../store'\r\nimport { ViewerNames } from '../types/'\r\nimport { resolveAppContent } from '../utils/appContent'\r\n\r\n// Shadcn Components\r\n\r\nimport LanguageSwitch from './LanguageSwitch'\r\nimport { Logo } from './Logo'\r\nimport { Button } from './ui/Button'\r\n\r\n// Custom Components\r\n\r\n// Icons\r\n\r\nimport { Separator } from './ui/Separator'\r\n\r\n\r\nimport type { Organization, Language } from '../types/dbTypes'\r\nimport type { RoleNames } from '../types/global'\r\n\r\n\r\n\r\n\r\n\r\nexport const handleChangeViewer = (\r\n viewer: ViewerNames,\r\n setSelectedItem: React.Dispatch<React.SetStateAction<any>>,\r\n setSelectedSite: React.Dispatch<React.SetStateAction<any>>,\r\n setSelectedFile: React.Dispatch<React.SetStateAction<any>>,\r\n setView: React.Dispatch<React.SetStateAction<'table' | 'detail'>>,\r\n menusDispatch: any,\r\n) => {\r\n // Reset selected item, file, & view when changing viewer\r\n setSelectedItem(null)\r\n setSelectedSite(null)\r\n setSelectedFile(null)\r\n setView('table')\r\n\r\n menusDispatch({\r\n type: 'SET_VIEWER',\r\n payload: { currentViewer: viewer },\r\n })\r\n}\r\n\r\ninterface AppSidebarProps {\r\n organization: Organization\r\n countrySubdivisionsData?: Record<string, string>;\r\n minioBaseUrl?: string\r\n}\r\n\r\nexport function AppSidebarContent({ organization, countrySubdivisionsData, minioBaseUrl, }: AppSidebarProps) {\r\n // Translations\r\n const t = useTranslations('AppSidebar')\r\n\r\n const { dispatch: appConfigDispatch } = React.useContext(AppConfigContext)\r\n const { dispatch: mapDispatch } = React.useContext(MapContext)\r\n\r\n\r\n\r\n React.useEffect(() => {\r\n appConfigDispatch({\r\n type: 'SET_ORGANIZATION',\r\n payload: { organization },\r\n })\r\n }, [organization, appConfigDispatch])\r\n\r\n React.useEffect(() => {\r\n if (countrySubdivisionsData) {\r\n mapDispatch({\r\n type: 'SET_COUNTRY_SUBDIVISIONS',\r\n payload: { countrySubdivisionsData, organizationCountry: organization.country },\r\n })\r\n }\r\n }, [countrySubdivisionsData, mapDispatch, organization.country])\r\n\r\n const sidebarTitle = organization?.title ?? organization.name ?? 'CDT Platform'\r\n\r\n // Shared with the map popover's tool row, so a viewer hidden here is not reachable from there.\r\n const appContent = resolveAppContent(organization)\r\n\r\n const logoKey = organization?.logoKey\r\n const logoUrl = minioBaseUrl && logoKey\r\n ? `${minioBaseUrl}/org-logos/${logoKey}`\r\n : '/images/cdt-logo-stroke.svg'\r\n\r\n\r\n const { dispatch: menusDispatch, state: menusState } = useMenusContext()\r\n const { setSelectedItem, setSelectedSite, setSelectedFile, setView } = useMenusContext()\r\n\r\n const { data: session } = useSession()\r\n const { userRole } = useUserRole(session?.user?.id || '')\r\n const normalizedUserRoles = React.useMemo(\r\n () => new Set(userRole?.name ? [userRole.name.trim().toLowerCase()] : []),\r\n [userRole]\r\n )\r\n\r\n const {\r\n sidebarState, setOpenInfo, isMobile, openMobile, setOpenMobile,\r\n setBugReportOpen, setFeatureRequestOpen,\r\n } = useSidebar()\r\n\r\n const changeViewer = (viewer: ViewerNames) => {\r\n handleChangeViewer(viewer, setSelectedItem, setSelectedSite, setSelectedFile, setView, menusDispatch)\r\n setOpenInfo(false)\r\n }\r\n\r\n const handleMapClick = () => {\r\n changeViewer(ViewerNames.map)\r\n }\r\n\r\n interface MenuItem {\r\n title: string\r\n id: ViewerNames | string\r\n icon: React.ElementType\r\n onClick?: () => void\r\n accessibleTo?: RoleNames[],\r\n url?: string\r\n tooltip?: string\r\n }\r\n\r\n // Sidebar menu items\r\n const viewerItems: MenuItem[] = [\r\n {\r\n title: t('mapTitle'),\r\n id: ViewerNames.map,\r\n icon: LR.Map,\r\n onClick: handleMapClick,\r\n },\r\n {\r\n title: t('bimTitle'),\r\n id: ViewerNames.bim,\r\n icon: LR.Box,\r\n onClick: () => changeViewer(ViewerNames.bim),\r\n },\r\n {\r\n title: t('pointCloudTitle'),\r\n id: ViewerNames.pointcloud,\r\n icon: LR.Grip,\r\n onClick: () => changeViewer(ViewerNames.pointcloud),\r\n }\r\n ]\r\n\r\n const datasetItems: MenuItem[] = [\r\n {\r\n title: t('siteTitle'),\r\n id: ViewerNames.sites,\r\n onClick: () => changeViewer(ViewerNames.sites),\r\n icon: LR.BoxSelect,\r\n },\r\n {\r\n title: t('buildingsTitle'),\r\n id: ViewerNames.buildings,\r\n icon: LR.Building2,\r\n onClick: () => changeViewer(ViewerNames.buildings),\r\n },\r\n {\r\n title: t('filesTitle'),\r\n id: ViewerNames.files,\r\n icon: LR.GalleryVerticalEnd,\r\n onClick: () => changeViewer(ViewerNames.files),\r\n },\r\n // {\r\n // title: t('landTitle'),\r\n // id: ViewerNames.land,\r\n // icon: LR.Mountain,\r\n // onClick: () => changeViewer(ViewerNames.land),\r\n // },\r\n {\r\n title: t('infrastructureTitle'),\r\n id: ViewerNames.infrastructure,\r\n icon: LR.TrainTrack,\r\n onClick: () => changeViewer(ViewerNames.infrastructure),\r\n },\r\n\r\n ]\r\n\r\n const managementItems: MenuItem[] = [\r\n // {\r\n // title: t('users'),\r\n // id: ViewerNames.users,\r\n // onClick: () => changeViewer(ViewerNames.users),\r\n // icon: LR.Users,\r\n // accessibleTo: [RoleNames.admin],\r\n // },\r\n {\r\n title: t('addPlugins'),\r\n id: ViewerNames.extensions,\r\n icon: LR.Blocks,\r\n onClick: () => changeViewer(ViewerNames.extensions),\r\n }\r\n ]\r\n\r\n // Sidebar footer items\r\n const serviceItems: MenuItem[] = [\r\n {\r\n title: t('support'),\r\n id: 'support',\r\n url: 'mailto:info@collabdt.org?subject=Support Request - CDT Platform',\r\n icon: LR.LifeBuoy,\r\n tooltip: t('contact')\r\n },\r\n // {\r\n // title: t('feedback'),\r\n // url: 'mailto:info@collabdt.org?subject=Feedback - CDT Platform',\r\n // icon: LR.Send,\r\n // },\r\n ]\r\n const { currentViewer } = menusState.menus\r\n\r\n // On mobile, treat the sheet open as expanded so labels render when the drawer is visible\r\n const isCollapsed = isMobile ? !openMobile : sidebarState === 'collapsed'\r\n\r\n const buildBtnClass = (active: boolean) => [\r\n 'text-sm flex items-center gap-2 w-full cursor-pointer transition-colors rounded-md',\r\n isCollapsed ? 'justify-center p-2' : 'justify-start p-2',\r\n active ? 'bg-primary/5 hover:bg-primary/10 border border-primary/15' : 'hover:bg-muted/50',\r\n ].join(' ')\r\n\r\n const buildIconClass = (active: boolean) => [\r\n 'h-4 w-4 shrink-0',\r\n active ? 'text-primary stroke-2' : 'text-muted-foreground'\r\n ].join(' ')\r\n\r\n const canRenderItem = React.useCallback((item: MenuItem) => {\r\n if (item.accessibleTo == null) return true\r\n return item.accessibleTo.some(role => normalizedUserRoles.has(role.toLowerCase()))\r\n }, [normalizedUserRoles])\r\n\r\n const visibleDatasetItems = datasetItems\r\n .filter(item => !appContent || appContent.includes(item.id as ViewerNames))\r\n .filter(canRenderItem)\r\n\r\n // BugReportDialog/FeatureRequestDialog are rendered by AppSidebar, outside\r\n // the mobile Sheet's subtree — see the SidebarContext fields for why: this\r\n // component (AppSidebarContent) is itself the Sheet's children on mobile,\r\n // so a dialog rendered here would get unmounted along with the Sheet\r\n // shortly after closing it, right after it opens.\r\n // On mobile, also close the sidebar Sheet first so it doesn't end up behind\r\n // the dialog (e.g. visible in a \"Capture Screenshot\").\r\n const openBugDialog = () => {\r\n if (isMobile) setOpenMobile(false)\r\n setBugReportOpen(true)\r\n }\r\n const openFeatureDialog = () => {\r\n if (isMobile) setOpenMobile(false)\r\n setFeatureRequestOpen(true)\r\n }\r\n\r\n return (\r\n <>\r\n <SidebarContent className='overflow-hidden'>\r\n <SidebarHeader className={`w-full pt-7 flex items-center justify-center ${isCollapsed ? 'items-center' : 'px-2 items-start'}`}>\r\n <div className='flex flex-row items-center gap-3'>\r\n <Logo image={logoUrl} />\r\n {sidebarState === 'expanded'\r\n && <h1 className=\"text-sm font-bold max-w-36\">{sidebarTitle}</h1>}\r\n </div>\r\n </SidebarHeader>\r\n {isCollapsed && <Separator className=\"z-30 w-2/3 mx-auto\" />}\r\n\r\n <div className='overflow-y-auto overflow-x-hidden'>\r\n <SidebarGroup>\r\n <SidebarGroupLabel>{t('3dViewer')}</SidebarGroupLabel>\r\n <SidebarGroupContent>\r\n <SidebarMenu>\r\n {viewerItems.filter(item => !appContent || appContent.includes(item.id as ViewerNames))\r\n .filter(canRenderItem)\r\n .map(item => {\r\n const active = item.id === currentViewer;\r\n return (\r\n <SidebarMenuItem key={item.title}>\r\n <SidebarMenuButton asChild>\r\n <Button\r\n onClick={item.onClick}\r\n title={isCollapsed ? item.title : undefined}\r\n className={buildBtnClass(active)}\r\n variant=\"ghost\"\r\n >\r\n <item.icon className={buildIconClass(active)} />\r\n <span className={`${isCollapsed ? 'hidden' : 'inline'} ${active ? 'font-bold text-primary' : ''}`}>{item.title}</span>\r\n </Button>\r\n </SidebarMenuButton>\r\n </SidebarMenuItem>\r\n );\r\n })\r\n }\r\n </SidebarMenu>\r\n </SidebarGroupContent>\r\n </SidebarGroup>\r\n\r\n\r\n {visibleDatasetItems.length > 0 && (\r\n <>\r\n {isCollapsed && <Separator className=\"z-30 w-2/3 mx-auto\" />}\r\n\r\n <SidebarGroup>\r\n <SidebarGroupLabel>{t('data')}</SidebarGroupLabel>\r\n\r\n <SidebarGroupContent>\r\n <SidebarMenu>\r\n {visibleDatasetItems.map(item => {\r\n const active = item.id === currentViewer\r\n\r\n return (\r\n <SidebarMenuItem key={item.title}>\r\n <SidebarMenuButton asChild>\r\n <Button\r\n onClick={item.onClick}\r\n title={isCollapsed ? item.title : undefined}\r\n className={buildBtnClass(active)}\r\n variant=\"ghost\"\r\n >\r\n <item.icon className={buildIconClass(active)} />\r\n <span\r\n className={`${isCollapsed ? 'hidden' : 'inline'} ${active ? 'font-bold text-primary' : ''\r\n }`}\r\n >\r\n {item.title}\r\n </span>\r\n </Button>\r\n </SidebarMenuButton>\r\n </SidebarMenuItem>\r\n )\r\n })}\r\n </SidebarMenu>\r\n </SidebarGroupContent>\r\n </SidebarGroup>\r\n </>\r\n )}\r\n {isCollapsed && <Separator className=\"z-30 w-2/3 mx-auto\" />}\r\n <SidebarGroup>\r\n <SidebarGroupLabel>{t('plugins')}</SidebarGroupLabel>\r\n <SidebarGroupContent>\r\n <SidebarMenu>\r\n {managementItems.filter(canRenderItem).map(item => {\r\n const active = item.id === currentViewer\r\n return (\r\n <SidebarMenuItem key={item.title}>\r\n <SidebarMenuButton asChild>\r\n <Button\r\n onClick={item.onClick}\r\n title={isCollapsed ? item.title : undefined}\r\n className={buildBtnClass(active)}\r\n variant=\"ghost\"\r\n >\r\n <item.icon className={buildIconClass(active)} />\r\n <span className={`${isCollapsed ? 'hidden' : 'inline'} ${active ? 'font-bold text-primary' : ''}`}>{item.title}</span>\r\n </Button>\r\n </SidebarMenuButton>\r\n </SidebarMenuItem>\r\n )\r\n })}\r\n </SidebarMenu>\r\n </SidebarGroupContent>\r\n </SidebarGroup>\r\n </div>\r\n </SidebarContent>\r\n {/* Footer Content - only show when not in BIM mode or when collapsed */}\r\n <SidebarFooter className={`w-full flex flex-col gap-4 ${isCollapsed ? 'items-center justify-center px-0 pb-4' : 'items-start justify-start px-2 pb-4'}`}>\r\n {/* Preferences */}\r\n {organization.languages?.length > 1 && (\r\n <SidebarGroup>\r\n <SidebarGroupLabel>{t('preferences')}</SidebarGroupLabel>\r\n <SidebarMenu>\r\n <SidebarMenuItem>\r\n <LanguageSwitch showLabel={sidebarState === 'expanded'} languages={organization.languages as Language[]} />\r\n </SidebarMenuItem>\r\n </SidebarMenu>\r\n </SidebarGroup>\r\n )}\r\n {/* Services */}\r\n <SidebarGroup>\r\n <SidebarGroupLabel>{t('service')}</SidebarGroupLabel>\r\n <SidebarMenu>\r\n {serviceItems.map((item, index) => (\r\n <SidebarMenuItem key={index}>\r\n {item.id === \"support\" ? (\r\n <SupportMenu\r\n isCollapsed={isCollapsed}\r\n item={item}\r\n onOpenBug={openBugDialog}\r\n onOpenFeature={openFeatureDialog}\r\n />\r\n ) : (\r\n <SidebarMenuButton asChild>\r\n <a\r\n href={item.url}\r\n className={`text-xs flex items-center gap-2 w-full ${isCollapsed ? \"justify-center p-2\" : \"justify-start p-2\"\r\n }`}\r\n title={item.tooltip}\r\n >\r\n <item.icon className=\"h-4 w-4\" />\r\n <span className={isCollapsed ? \"hidden\" : \"inline\"}>\r\n {item.title}\r\n </span>\r\n </a>\r\n </SidebarMenuButton>\r\n )}\r\n </SidebarMenuItem>\r\n ))}\r\n </SidebarMenu>\r\n </SidebarGroup>\r\n </SidebarFooter>\r\n </>\r\n )\r\n}"],"mappings":";AAqRU,SAwCE,UAvCA,KADF;AAhRV,YAAY,QA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ACC,MAAM,KAAK;AAAA,YACX,WAAW,0CAA0C,cAAc,uBAAuB,mBACxF;AAAA,YACF,OAAO,KAAK;AAAA,YAEZ;AAAA,kCAAC,KAAK,MAAL,EAAU,WAAU,WAAU;AAAA,cAC/B,oBAAC,UAAK,WAAW,cAAc,WAAW,UACvC,eAAK,OACR;AAAA;AAAA;AAAA,QACF,GACF,KArBkB,KAuBtB,CACD,GACH;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/core/components/AppSidebarContent.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as LR from 'lucide-react'\r\nimport { useSession } from 'next-auth/react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from 'react'\r\n\r\n// Dependencies\r\nimport { SupportMenu } from \"../components/support/SupportMenu\"\r\nimport {\r\n SidebarContent,\r\n SidebarGroup,\r\n SidebarGroupContent,\r\n SidebarGroupLabel,\r\n SidebarMenu,\r\n SidebarMenuButton,\r\n SidebarMenuItem,\r\n SidebarHeader,\r\n SidebarFooter,\r\n useSidebar,\r\n} from '../components/ui/Sidebar'\r\nimport { useUserRole } from '../hooks/users/users'\r\nimport { usePluginDataPages } from '../plugins/host/usePluginDataPages'\r\nimport { AppConfigContext, MapContext, useMenusContext } from '../store'\r\nimport { ViewerNames } from '../types/'\r\nimport { resolveAppContent } from '../utils/appContent'\r\n\r\n// Shadcn Components\r\n\r\nimport LanguageSwitch from './LanguageSwitch'\r\nimport { Logo } from './Logo'\r\nimport { Button } from './ui/Button'\r\n\r\n// Custom Components\r\n\r\n// Icons\r\n\r\nimport { Separator } from './ui/Separator'\r\n\r\n\r\nimport type { Organization, Language, ViewerKey } from '../types/dbTypes'\r\nimport type { RoleNames } from '../types/global'\r\n\r\n\r\n\r\n\r\n\r\nexport const handleChangeViewer = (\r\n viewer: ViewerKey,\r\n setSelectedItem: React.Dispatch<React.SetStateAction<any>>,\r\n setSelectedSite: React.Dispatch<React.SetStateAction<any>>,\r\n setSelectedFile: React.Dispatch<React.SetStateAction<any>>,\r\n setView: React.Dispatch<React.SetStateAction<'table' | 'detail'>>,\r\n menusDispatch: any,\r\n) => {\r\n // Reset selected item, file, & view when changing viewer\r\n setSelectedItem(null)\r\n setSelectedSite(null)\r\n setSelectedFile(null)\r\n setView('table')\r\n\r\n menusDispatch({\r\n type: 'SET_VIEWER',\r\n payload: { currentViewer: viewer },\r\n })\r\n}\r\n\r\ninterface AppSidebarProps {\r\n organization: Organization\r\n countrySubdivisionsData?: Record<string, string>;\r\n minioBaseUrl?: string\r\n}\r\n\r\nexport function AppSidebarContent({ organization, countrySubdivisionsData, minioBaseUrl, }: AppSidebarProps) {\r\n // Translations\r\n const t = useTranslations('AppSidebar')\r\n\r\n const { dispatch: appConfigDispatch } = React.useContext(AppConfigContext)\r\n const { dispatch: mapDispatch } = React.useContext(MapContext)\r\n\r\n\r\n\r\n React.useEffect(() => {\r\n appConfigDispatch({\r\n type: 'SET_ORGANIZATION',\r\n payload: { organization },\r\n })\r\n }, [organization, appConfigDispatch])\r\n\r\n React.useEffect(() => {\r\n if (countrySubdivisionsData) {\r\n mapDispatch({\r\n type: 'SET_COUNTRY_SUBDIVISIONS',\r\n payload: { countrySubdivisionsData, organizationCountry: organization.country },\r\n })\r\n }\r\n }, [countrySubdivisionsData, mapDispatch, organization.country])\r\n\r\n const sidebarTitle = organization?.title ?? organization.name ?? 'CDT Platform'\r\n\r\n // Shared with the map popover's tool row, so a viewer hidden here is not reachable from there.\r\n const appContent = resolveAppContent(organization)\r\n\r\n const logoKey = organization?.logoKey\r\n const logoUrl = minioBaseUrl && logoKey\r\n ? `${minioBaseUrl}/org-logos/${logoKey}`\r\n : '/images/cdt-logo-stroke.svg'\r\n\r\n\r\n const { dispatch: menusDispatch, state: menusState } = useMenusContext()\r\n const { setSelectedItem, setSelectedSite, setSelectedFile, setView } = useMenusContext()\r\n\r\n const { data: session } = useSession()\r\n const { userRole } = useUserRole(session?.user?.id || '')\r\n const normalizedUserRoles = React.useMemo(\r\n () => new Set(userRole?.name ? [userRole.name.trim().toLowerCase()] : []),\r\n [userRole]\r\n )\r\n\r\n const {\r\n sidebarState, setOpenInfo, isMobile, openMobile, setOpenMobile,\r\n setBugReportOpen, setFeatureRequestOpen,\r\n } = useSidebar()\r\n\r\n const pluginPages = usePluginDataPages()\r\n\r\n const changeViewer = (viewer: ViewerKey) => {\r\n handleChangeViewer(viewer, setSelectedItem, setSelectedSite, setSelectedFile, setView, menusDispatch)\r\n setOpenInfo(false)\r\n }\r\n\r\n const handleMapClick = () => {\r\n changeViewer(ViewerNames.map)\r\n }\r\n\r\n interface MenuItem {\r\n title: string\r\n id: ViewerKey | string\r\n icon: React.ElementType\r\n onClick?: () => void\r\n accessibleTo?: RoleNames[],\r\n url?: string\r\n tooltip?: string\r\n }\r\n\r\n // Sidebar menu items\r\n const viewerItems: MenuItem[] = [\r\n {\r\n title: t('mapTitle'),\r\n id: ViewerNames.map,\r\n icon: LR.Map,\r\n onClick: handleMapClick,\r\n },\r\n {\r\n title: t('bimTitle'),\r\n id: ViewerNames.bim,\r\n icon: LR.Box,\r\n onClick: () => changeViewer(ViewerNames.bim),\r\n },\r\n {\r\n title: t('pointCloudTitle'),\r\n id: ViewerNames.pointcloud,\r\n icon: LR.Grip,\r\n onClick: () => changeViewer(ViewerNames.pointcloud),\r\n }\r\n ]\r\n\r\n const datasetItems: MenuItem[] = [\r\n {\r\n title: t('siteTitle'),\r\n id: ViewerNames.sites,\r\n onClick: () => changeViewer(ViewerNames.sites),\r\n icon: LR.BoxSelect,\r\n },\r\n {\r\n title: t('buildingsTitle'),\r\n id: ViewerNames.buildings,\r\n icon: LR.Building2,\r\n onClick: () => changeViewer(ViewerNames.buildings),\r\n },\r\n {\r\n title: t('filesTitle'),\r\n id: ViewerNames.files,\r\n icon: LR.GalleryVerticalEnd,\r\n onClick: () => changeViewer(ViewerNames.files),\r\n },\r\n // {\r\n // title: t('landTitle'),\r\n // id: ViewerNames.land,\r\n // icon: LR.Mountain,\r\n // onClick: () => changeViewer(ViewerNames.land),\r\n // },\r\n {\r\n title: t('infrastructureTitle'),\r\n id: ViewerNames.infrastructure,\r\n icon: LR.TrainTrack,\r\n onClick: () => changeViewer(ViewerNames.infrastructure),\r\n },\r\n // In Datasets, so a contributed page reads as part of the platform.\r\n ...pluginPages.map(page => ({\r\n title: page.title,\r\n id: page.id,\r\n icon: page.icon,\r\n onClick: () => changeViewer(page.id),\r\n })),\r\n ]\r\n\r\n const managementItems: MenuItem[] = [\r\n // {\r\n // title: t('users'),\r\n // id: ViewerNames.users,\r\n // onClick: () => changeViewer(ViewerNames.users),\r\n // icon: LR.Users,\r\n // accessibleTo: [RoleNames.admin],\r\n // },\r\n {\r\n title: t('addPlugins'),\r\n id: ViewerNames.extensions,\r\n icon: LR.Blocks,\r\n onClick: () => changeViewer(ViewerNames.extensions),\r\n }\r\n ]\r\n\r\n // Sidebar footer items\r\n const serviceItems: MenuItem[] = [\r\n {\r\n title: t('support'),\r\n id: 'support',\r\n url: 'mailto:info@collabdt.org?subject=Support Request - CDT Platform',\r\n icon: LR.LifeBuoy,\r\n tooltip: t('contact')\r\n },\r\n // {\r\n // title: t('feedback'),\r\n // url: 'mailto:info@collabdt.org?subject=Feedback - CDT Platform',\r\n // icon: LR.Send,\r\n // },\r\n ]\r\n const { currentViewer } = menusState.menus\r\n\r\n // On mobile, treat the sheet open as expanded so labels render when the drawer is visible\r\n const isCollapsed = isMobile ? !openMobile : sidebarState === 'collapsed'\r\n\r\n const buildBtnClass = (active: boolean) => [\r\n 'text-sm flex items-center gap-2 w-full cursor-pointer transition-colors rounded-md',\r\n isCollapsed ? 'justify-center p-2' : 'justify-start p-2',\r\n active ? 'bg-primary/5 hover:bg-primary/10 border border-primary/15' : 'hover:bg-muted/50',\r\n ].join(' ')\r\n\r\n const buildIconClass = (active: boolean) => [\r\n 'h-4 w-4 shrink-0',\r\n active ? 'text-primary stroke-2' : 'text-muted-foreground'\r\n ].join(' ')\r\n\r\n const canRenderItem = React.useCallback((item: MenuItem) => {\r\n if (item.accessibleTo == null) return true\r\n return item.accessibleTo.some(role => normalizedUserRoles.has(role.toLowerCase()))\r\n }, [normalizedUserRoles])\r\n\r\n const visibleDatasetItems = datasetItems\r\n .filter(item => !appContent || appContent.includes(item.id as ViewerNames))\r\n .filter(canRenderItem)\r\n\r\n // BugReportDialog/FeatureRequestDialog are rendered by AppSidebar, outside\r\n // the mobile Sheet's subtree — see the SidebarContext fields for why: this\r\n // component (AppSidebarContent) is itself the Sheet's children on mobile,\r\n // so a dialog rendered here would get unmounted along with the Sheet\r\n // shortly after closing it, right after it opens.\r\n // On mobile, also close the sidebar Sheet first so it doesn't end up behind\r\n // the dialog (e.g. visible in a \"Capture Screenshot\").\r\n const openBugDialog = () => {\r\n if (isMobile) setOpenMobile(false)\r\n setBugReportOpen(true)\r\n }\r\n const openFeatureDialog = () => {\r\n if (isMobile) setOpenMobile(false)\r\n setFeatureRequestOpen(true)\r\n }\r\n\r\n return (\r\n <>\r\n <SidebarContent className='overflow-hidden'>\r\n <SidebarHeader className={`w-full pt-7 flex items-center justify-center ${isCollapsed ? 'items-center' : 'px-2 items-start'}`}>\r\n <div className='flex flex-row items-center gap-3'>\r\n <Logo image={logoUrl} />\r\n {sidebarState === 'expanded'\r\n && <h1 className=\"text-sm font-bold max-w-36\">{sidebarTitle}</h1>}\r\n </div>\r\n </SidebarHeader>\r\n {isCollapsed && <Separator className=\"z-30 w-2/3 mx-auto\" />}\r\n\r\n <div className='overflow-y-auto overflow-x-hidden'>\r\n <SidebarGroup>\r\n <SidebarGroupLabel>{t('3dViewer')}</SidebarGroupLabel>\r\n <SidebarGroupContent>\r\n <SidebarMenu>\r\n {viewerItems.filter(item => !appContent || appContent.includes(item.id as ViewerNames))\r\n .filter(canRenderItem)\r\n .map(item => {\r\n const active = item.id === currentViewer;\r\n return (\r\n <SidebarMenuItem key={item.title}>\r\n <SidebarMenuButton asChild>\r\n <Button\r\n onClick={item.onClick}\r\n title={isCollapsed ? item.title : undefined}\r\n className={buildBtnClass(active)}\r\n variant=\"ghost\"\r\n >\r\n <item.icon className={buildIconClass(active)} />\r\n <span className={`${isCollapsed ? 'hidden' : 'inline'} ${active ? 'font-bold text-primary' : ''}`}>{item.title}</span>\r\n </Button>\r\n </SidebarMenuButton>\r\n </SidebarMenuItem>\r\n );\r\n })\r\n }\r\n </SidebarMenu>\r\n </SidebarGroupContent>\r\n </SidebarGroup>\r\n\r\n\r\n {visibleDatasetItems.length > 0 && (\r\n <>\r\n {isCollapsed && <Separator className=\"z-30 w-2/3 mx-auto\" />}\r\n\r\n <SidebarGroup>\r\n <SidebarGroupLabel>{t('data')}</SidebarGroupLabel>\r\n\r\n <SidebarGroupContent>\r\n <SidebarMenu>\r\n {visibleDatasetItems.map(item => {\r\n const active = item.id === currentViewer\r\n\r\n return (\r\n <SidebarMenuItem key={item.title}>\r\n <SidebarMenuButton asChild>\r\n <Button\r\n onClick={item.onClick}\r\n title={isCollapsed ? item.title : undefined}\r\n className={buildBtnClass(active)}\r\n variant=\"ghost\"\r\n >\r\n <item.icon className={buildIconClass(active)} />\r\n <span\r\n className={`${isCollapsed ? 'hidden' : 'inline'} ${active ? 'font-bold text-primary' : ''\r\n }`}\r\n >\r\n {item.title}\r\n </span>\r\n </Button>\r\n </SidebarMenuButton>\r\n </SidebarMenuItem>\r\n )\r\n })}\r\n </SidebarMenu>\r\n </SidebarGroupContent>\r\n </SidebarGroup>\r\n </>\r\n )}\r\n {isCollapsed && <Separator className=\"z-30 w-2/3 mx-auto\" />}\r\n <SidebarGroup>\r\n <SidebarGroupLabel>{t('plugins')}</SidebarGroupLabel>\r\n <SidebarGroupContent>\r\n <SidebarMenu>\r\n {managementItems.filter(canRenderItem).map(item => {\r\n const active = item.id === currentViewer\r\n return (\r\n <SidebarMenuItem key={item.title}>\r\n <SidebarMenuButton asChild>\r\n <Button\r\n onClick={item.onClick}\r\n title={isCollapsed ? item.title : undefined}\r\n className={buildBtnClass(active)}\r\n variant=\"ghost\"\r\n >\r\n <item.icon className={buildIconClass(active)} />\r\n <span className={`${isCollapsed ? 'hidden' : 'inline'} ${active ? 'font-bold text-primary' : ''}`}>{item.title}</span>\r\n </Button>\r\n </SidebarMenuButton>\r\n </SidebarMenuItem>\r\n )\r\n })}\r\n </SidebarMenu>\r\n </SidebarGroupContent>\r\n </SidebarGroup>\r\n </div>\r\n </SidebarContent>\r\n {/* Footer Content - only show when not in BIM mode or when collapsed */}\r\n <SidebarFooter className={`w-full flex flex-col gap-4 ${isCollapsed ? 'items-center justify-center px-0 pb-4' : 'items-start justify-start px-2 pb-4'}`}>\r\n {/* Preferences */}\r\n {organization.languages?.length > 1 && (\r\n <SidebarGroup>\r\n <SidebarGroupLabel>{t('preferences')}</SidebarGroupLabel>\r\n <SidebarMenu>\r\n <SidebarMenuItem>\r\n <LanguageSwitch showLabel={sidebarState === 'expanded'} languages={organization.languages as Language[]} />\r\n </SidebarMenuItem>\r\n </SidebarMenu>\r\n </SidebarGroup>\r\n )}\r\n {/* Services */}\r\n <SidebarGroup>\r\n <SidebarGroupLabel>{t('service')}</SidebarGroupLabel>\r\n <SidebarMenu>\r\n {serviceItems.map((item, index) => (\r\n <SidebarMenuItem key={index}>\r\n {item.id === \"support\" ? (\r\n <SupportMenu\r\n isCollapsed={isCollapsed}\r\n item={item}\r\n onOpenBug={openBugDialog}\r\n onOpenFeature={openFeatureDialog}\r\n />\r\n ) : (\r\n <SidebarMenuButton asChild>\r\n <a\r\n href={item.url}\r\n className={`text-xs flex items-center gap-2 w-full ${isCollapsed ? \"justify-center p-2\" : \"justify-start p-2\"\r\n }`}\r\n title={item.tooltip}\r\n >\r\n <item.icon className=\"h-4 w-4\" />\r\n <span className={isCollapsed ? \"hidden\" : \"inline\"}>\r\n {item.title}\r\n </span>\r\n </a>\r\n </SidebarMenuButton>\r\n )}\r\n </S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,iBAAiB,YAAY,WAAW,aAAa,WAAyB,GAC3G,GACF;AAAA,SACF;AAAA,MAGF,qBAAC,gBACC;AAAA,4BAAC,qBAAmB,YAAE,SAAS,GAAE;AAAA,QACjC,oBAAC,eACE,uBAAa,IAAI,CAAC,MAAM,UACvB,oBAAC,mBACE,eAAK,OAAO,YACX;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA,WAAW;AAAA,YACX,eAAe;AAAA;AAAA,QACjB,IAEA,oBAAC,qBAAkB,SAAO,MACxB;AAAA,UAAC;AAAA;AAAA,YACC,MAAM,KAAK;AAAA,YACX,WAAW,0CAA0C,cAAc,uBAAuB,mBACxF;AAAA,YACF,OAAO,KAAK;AAAA,YAEZ;AAAA,kCAAC,KAAK,MAAL,EAAU,WAAU,WAAU;AAAA,cAC/B,oBAAC,UAAK,WAAW,cAAc,WAAW,UACvC,eAAK,OACR;AAAA;AAAA;AAAA,QACF,GACF,KArBkB,KAuBtB,CACD,GACH;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import type { Organization } from '../types/dbTypes';
|
|
2
|
+
import type { Organization, ViewerKey } from '../types/dbTypes';
|
|
4
3
|
interface Props {
|
|
5
|
-
viewer:
|
|
4
|
+
viewer: ViewerKey;
|
|
6
5
|
minioBaseUrl?: string;
|
|
7
6
|
martinBaseUrl?: string;
|
|
8
7
|
organization?: Organization;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../../src/core/components/Toolbar.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../../src/core/components/Toolbar.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAkB/D,UAAU,KAAK;IACb,MAAM,EAAE,SAAS,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAWD,wBAAgB,OAAO,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,EAAE,KAAK,qBAmBpH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/components/Toolbar.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\n// Components\r\nimport dynamic from 'next/dynamic'\r\nimport * as React from 'react'\r\n\r\nimport { useMapToolbarTools } from '../components/viewers/map/src/tools/mapTools'\r\nimport { ViewerNames } from '../types'\r\n\r\nimport { ToolbarBody } from './ToolbarBody'\r\n\r\nimport type { Organization } from '../types/dbTypes'\r\n\r\n// The BIM and PointCloud toolbar tool registries transitively import\r\n// @thatopen and Potree-adjacent code. Statically importing them here (eagerly\r\n// mounted by Viewer.tsx) kept ~456 KB of @thatopen on the map route's\r\n// first-load JS. Dynamic-importing both per-viewer toolbars cuts that path.\r\n//\r\n// MapToolbar stays inline (no separate file, no dynamic) because the map\r\n// is the default landing surface and every user pays its cost anyway.\r\nconst BimToolbar = dynamic(\r\n () => import('./viewers/bim/BimToolbar').then(m => ({ default: m.BimToolbar })),\r\n { ssr: false },\r\n)\r\nconst PointCloudToolbar = dynamic(\r\n () => import('./viewers/pointcloud/PointCloudToolbar').then(m => ({ default: m.PointCloudToolbar })),\r\n { ssr: false },\r\n)\r\n\r\ninterface Props {\r\n viewer:
|
|
1
|
+
{"version":3,"sources":["../../../src/core/components/Toolbar.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\n// Components\r\nimport dynamic from 'next/dynamic'\r\nimport * as React from 'react'\r\n\r\nimport { useMapToolbarTools } from '../components/viewers/map/src/tools/mapTools'\r\nimport { ViewerNames } from '../types'\r\n\r\nimport { ToolbarBody } from './ToolbarBody'\r\n\r\nimport type { Organization, ViewerKey } from '../types/dbTypes'\r\n\r\n// The BIM and PointCloud toolbar tool registries transitively import\r\n// @thatopen and Potree-adjacent code. Statically importing them here (eagerly\r\n// mounted by Viewer.tsx) kept ~456 KB of @thatopen on the map route's\r\n// first-load JS. Dynamic-importing both per-viewer toolbars cuts that path.\r\n//\r\n// MapToolbar stays inline (no separate file, no dynamic) because the map\r\n// is the default landing surface and every user pays its cost anyway.\r\nconst BimToolbar = dynamic(\r\n () => import('./viewers/bim/BimToolbar').then(m => ({ default: m.BimToolbar })),\r\n { ssr: false },\r\n)\r\nconst PointCloudToolbar = dynamic(\r\n () => import('./viewers/pointcloud/PointCloudToolbar').then(m => ({ default: m.PointCloudToolbar })),\r\n { ssr: false },\r\n)\r\n\r\ninterface Props {\r\n viewer: ViewerKey\r\n minioBaseUrl?: string\r\n martinBaseUrl?: string\r\n organization?: Organization\r\n geocodeEarthApiKey?: string\r\n geocoderUrl?: string\r\n}\r\n\r\n// Own component so the tools hook is called unconditionally on the map branch,\r\n// instead of inside Toolbar's viewer check (which would break hook ordering when\r\n// the user switches viewers).\r\nfunction MapToolbar({ minioBaseUrl, martinBaseUrl, organization, geocodeEarthApiKey, geocoderUrl }: Omit<Props, 'viewer'>) {\r\n const tools = useMapToolbarTools({ minioBaseUrl, martinBaseUrl, organization, geocodeEarthApiKey, geocoderUrl })\r\n\r\n return <ToolbarBody viewer=\"map\" tools={tools} />\r\n}\r\n\r\nexport function Toolbar({ viewer, minioBaseUrl, martinBaseUrl, organization, geocodeEarthApiKey, geocoderUrl }: Props) {\r\n if (viewer === ViewerNames.map) {\r\n return (\r\n <MapToolbar\r\n minioBaseUrl={minioBaseUrl}\r\n martinBaseUrl={martinBaseUrl}\r\n organization={organization}\r\n geocodeEarthApiKey={geocodeEarthApiKey}\r\n geocoderUrl={geocoderUrl}\r\n />\r\n )\r\n }\r\n if (viewer === ViewerNames.bim) {\r\n return <BimToolbar />\r\n }\r\n if (viewer === ViewerNames.pointcloud) {\r\n return <PointCloudToolbar />\r\n }\r\n return null\r\n}\r\n"],"mappings":";AA+CS;AAzCT,OAAO,aAAa;AAGpB,SAAS,0BAA0B;AACnC,SAAS,mBAAmB;AAE5B,SAAS,mBAAmB;AAW5B,MAAM,aAAa;AAAA,EACjB,MAAM,OAAO,0BAA0B,EAAE,KAAK,QAAM,EAAE,SAAS,EAAE,WAAW,EAAE;AAAA,EAC9E,EAAE,KAAK,MAAM;AACf;AACA,MAAM,oBAAoB;AAAA,EACxB,MAAM,OAAO,wCAAwC,EAAE,KAAK,QAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE;AAAA,EACnG,EAAE,KAAK,MAAM;AACf;AAcA,SAAS,WAAW,EAAE,cAAc,eAAe,cAAc,oBAAoB,YAAY,GAA0B;AACzH,QAAM,QAAQ,mBAAmB,EAAE,cAAc,eAAe,cAAc,oBAAoB,YAAY,CAAC;AAE/G,SAAO,oBAAC,eAAY,QAAO,OAAM,OAAc;AACjD;AAEO,SAAS,QAAQ,EAAE,QAAQ,cAAc,eAAe,cAAc,oBAAoB,YAAY,GAAU;AACrH,MAAI,WAAW,YAAY,KAAK;AAC9B,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF;AAAA,EAEJ;AACA,MAAI,WAAW,YAAY,KAAK;AAC9B,WAAO,oBAAC,cAAW;AAAA,EACrB;AACA,MAAI,WAAW,YAAY,YAAY;AACrC,WAAO,oBAAC,qBAAkB;AAAA,EAC5B;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export declare const handleChangeViewer: (viewer:
|
|
2
|
+
import type { ViewerKey } from '../../types/dbTypes';
|
|
3
|
+
export declare const handleChangeViewer: (viewer: ViewerKey, setSelectedItem: React.Dispatch<React.SetStateAction<any>>, setSelectedSite: React.Dispatch<React.SetStateAction<any>>, setSelectedFile: React.Dispatch<React.SetStateAction<any>>, setView: React.Dispatch<React.SetStateAction<"table" | "detail">>, menusDispatch: any) => void;
|
|
4
4
|
interface AppSidebarProps {
|
|
5
5
|
children?: React.ReactNode;
|
|
6
6
|
signOut: (options?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppSidebar.d.ts","sourceRoot":"","sources":["../../../../src/core/components/ui/AppSidebar.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"AppSidebar.d.ts","sourceRoot":"","sources":["../../../../src/core/components/ui/AppSidebar.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AASpD,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,SAAS,EACjB,iBAAiB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,EAC1D,iBAAiB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,EAC1D,iBAAiB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,EAC1D,SAAS,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC,EACjE,eAAe,GAAG,SAYnB,CAAA;AAED,UAAU,eAAe;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAClF;AAED,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,eAAe,qBA6GhE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/components/ui/AppSidebar.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\n\r\n// Dependencies\r\n\r\n// Icons\r\nimport * as LR from 'lucide-react'\r\nimport Link from 'next/link'\r\nimport { useSession } from 'next-auth/react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from 'react'\r\n\r\n\r\nimport { useMenusContext } from '../../store'\r\nimport { ViewerNames } from '../../types'\r\nimport { BugReportDialog } from '../support/BugReportDialog'\r\nimport { FeatureRequestDialog } from '../support/FeatureRequestDialog'\r\n\r\nimport { Button } from './Button'\r\nimport { CdtIcon } from './Icons/CdtIcon'\r\n\r\nimport { Sidebar, useSidebar, NavUser } from './'\r\n\r\nexport const handleChangeViewer = (\r\n viewer:
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/components/ui/AppSidebar.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\n\r\n// Dependencies\r\n\r\n// Icons\r\nimport * as LR from 'lucide-react'\r\nimport Link from 'next/link'\r\nimport { useSession } from 'next-auth/react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from 'react'\r\n\r\n\r\nimport { useMenusContext } from '../../store'\r\nimport { ViewerNames } from '../../types'\r\n\r\nimport type { ViewerKey } from '../../types/dbTypes'\r\nimport { BugReportDialog } from '../support/BugReportDialog'\r\nimport { FeatureRequestDialog } from '../support/FeatureRequestDialog'\r\n\r\nimport { Button } from './Button'\r\nimport { CdtIcon } from './Icons/CdtIcon'\r\n\r\nimport { Sidebar, useSidebar, NavUser } from './'\r\n\r\nexport const handleChangeViewer = (\r\n viewer: ViewerKey,\r\n setSelectedItem: React.Dispatch<React.SetStateAction<any>>,\r\n setSelectedSite: React.Dispatch<React.SetStateAction<any>>,\r\n setSelectedFile: React.Dispatch<React.SetStateAction<any>>,\r\n setView: React.Dispatch<React.SetStateAction<'table' | 'detail'>>,\r\n menusDispatch: any,\r\n) => {\r\n // Reset selected item, file, & view when changing viewer\r\n setSelectedItem(null)\r\n setSelectedSite(null)\r\n setSelectedFile(null)\r\n setView('table')\r\n\r\n menusDispatch({\r\n type: 'SET_VIEWER',\r\n payload: { currentViewer: viewer },\r\n })\r\n}\r\n\r\ninterface AppSidebarProps {\r\n children?: React.ReactNode\r\n signOut: (options?: { redirectTo?: string; redirect?: boolean }) => Promise<void>\r\n}\r\n\r\nexport function AppSidebar({ children, signOut }: AppSidebarProps) {\r\n // Translations\r\n const t = useTranslations('AppSidebar')\r\n\r\n const { state: menusState } = useMenusContext()\r\n const { data: session } = useSession()\r\n\r\n const {\r\n sidebarState, isMobile, openMobile, toggleMenuSidebar,\r\n bugReportOpen, setBugReportOpen, featureRequestOpen, setFeatureRequestOpen,\r\n } = useSidebar()\r\n\r\n const { currentViewer } = menusState.menus\r\n\r\n // On mobile, treat the sheet open as expanded so labels render when the drawer is visible\r\n const isCollapsed = isMobile ? !openMobile : sidebarState === 'collapsed'\r\n\r\n // Determine the collapsible type based on the current viewer\r\n const collapsibleType = currentViewer === ViewerNames.auth ? 'offcanvas' : 'icon'\r\n\r\n return (\r\n <>\r\n {/* Always show toggle button on mobile when collapsed */}\r\n {isMobile && isCollapsed && (\r\n <div\r\n id=\"sidebar-toggle-button-mobile\"\r\n className=\"fixed left-0 bottom-[10px] z-[100] flex items-center justify-center pointer-events-auto\"\r\n >\r\n <button\r\n onClick={toggleMenuSidebar}\r\n className=\"text-muted-foreground hover:text-primary px-2 py-1.5 rounded-r-sm bg-sidebar\"\r\n style={{\r\n border: '1px solid rgba(128,128,128,0.2)',\r\n borderLeft: 'none',\r\n boxShadow: '4px 0 8px -4px rgba(0,0,0,0.12)',\r\n }}\r\n >\r\n <LR.ChevronRight className=\"w-6 h-6\" />\r\n </button>\r\n </div>\r\n )}\r\n <Sidebar collapsible={collapsibleType} className=\"border-none z-50 shadow-md relative\" >\r\n {/* Sidebar toggle button - right side inside Sidebar */}\r\n {(sidebarState === 'expanded') && (\r\n <div id='sidebar-toggle-button' className='absolute right-2 top-2 flex items-center justify-center pointer-events-auto z-50'>\r\n <button onClick={toggleMenuSidebar} className='text-muted-foreground hover:text-primary p-1'>\r\n <LR.X className='w-5' />\r\n </button>\r\n </div>\r\n )}\r\n {/* Show collapsed toggle only on desktop */}\r\n {!isMobile && sidebarState !== 'expanded' && (\r\n <div id='sidebar-toggle-button' className='absolute -right-1 max-h-1 top-1/2 -translate-y-1/2 flex items-center justify-center pointer-events-auto z-50'>\r\n <button\r\n onClick={toggleMenuSidebar}\r\n className=\"text-muted-foreground hover:text-primary p-0 rounded-md bg-sidebar\"\r\n style={{ borderRight: '1px solid rgba(128,128,128,0.2)', boxShadow: '4px 0 8px -4px rgba(0,0,0,0.12)' }}\r\n >\r\n <LR.ChevronRight className=\"w-4\" />\r\n </button>\r\n </div>\r\n )}\r\n {children}\r\n <div\r\n className={`w-full flex flex-col ${\r\n sidebarState === 'expanded'\r\n ? 'items-center justify-center'\r\n : 'justify-center pb-4'\r\n }`}\r\n >\r\n {/* Nav User */}\r\n <NavUser signOut={signOut} />\r\n\r\n {!isCollapsed ? (\r\n <Link\r\n href=\"https://collabdt.org/\"\r\n target=\"_blank\"\r\n rel=\"noopener noreferrer\"\r\n className=\"w-full\"\r\n >\r\n <Button\r\n title={t('home')}\r\n variant=\"ghost\"\r\n className=\"text-xs scale-[85%] py-0 my-0 w-full flex flex-row items-center justify-center gap-2\"\r\n >\r\n <CdtIcon monochromatic />\r\n <span>{t('home')}</span>\r\n </Button>\r\n </Link>\r\n ) : null}\r\n </div>\r\n </Sidebar>\r\n\r\n {/* Rendered outside <Sidebar> (and its mobile Sheet) so they survive the\r\n Sheet closing — see the SidebarContext comment for why. */}\r\n <BugReportDialog\r\n open={bugReportOpen}\r\n onOpenChange={setBugReportOpen}\r\n userEmail={session?.user?.email ?? undefined}\r\n viewer={currentViewer}\r\n />\r\n <FeatureRequestDialog\r\n open={featureRequestOpen}\r\n onOpenChange={setFeatureRequestOpen}\r\n userEmail={session?.user?.email ?? undefined}\r\n viewer={currentViewer}\r\n />\r\n </>\r\n )\r\n}"],"mappings":";AA0EI,mBAgBQ,KA2CI,YA3DZ;AAjEJ,YAAY,QAAQ;AACpB,OAAO,UAAU;AACjB,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAIhC,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAG5B,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AAErC,SAAS,cAAc;AACvB,SAAS,eAAe;AAExB,SAAS,SAAS,YAAY,eAAe;AAEtC,MAAM,qBAAqB,CAChC,QACA,iBACA,iBACA,iBACA,SACA,kBACG;AAEH,kBAAgB,IAAI;AACpB,kBAAgB,IAAI;AACpB,kBAAgB,IAAI;AACpB,UAAQ,OAAO;AAEf,gBAAc;AAAA,IACZ,MAAM;AAAA,IACN,SAAS,EAAE,eAAe,OAAO;AAAA,EACnC,CAAC;AACH;AAOO,SAAS,WAAW,EAAE,UAAU,QAAQ,GAAoB;AArDnE;AAuDE,QAAM,IAAI,gBAAgB,YAAY;AAEtC,QAAM,EAAE,OAAO,WAAW,IAAI,gBAAgB;AAC9C,QAAM,EAAE,MAAM,QAAQ,IAAI,WAAW;AAErC,QAAM;AAAA,I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AO;AAAA,gBACP,KAAI;AAAA,gBACJ,WAAU;AAAA,gBAEV;AAAA,kBAAC;AAAA;AAAA,oBACC,OAAO,EAAE,MAAM;AAAA,oBACf,SAAQ;AAAA,oBACR,WAAU;AAAA,oBAEV;AAAA,0CAAC,WAAQ,eAAa,MAAC;AAAA,sBACvB,oBAAC,UAAM,YAAE,MAAM,GAAE;AAAA;AAAA;AAAA,gBACnB;AAAA;AAAA,YACF,IACE;AAAA;AAAA;AAAA,MACN;AAAA,OACJ;AAAA,IAIA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,cAAc;AAAA,QACd,YAAW,8CAAS,SAAT,mBAAe,UAAf,YAAwB;AAAA,QACnC,QAAQ;AAAA;AAAA,IACV;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,cAAc;AAAA,QACd,YAAW,8CAAS,SAAT,mBAAe,UAAf,YAAwB;AAAA,QACnC,QAAQ;AAAA;AAAA,IACV;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommentsSection.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/ui/Comments/CommentsSection.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAiB9B,wBAAgB,eAAe,
|
|
1
|
+
{"version":3,"file":"CommentsSection.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/ui/Comments/CommentsSection.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAiB9B,wBAAgB,eAAe,sBA0L9B"}
|
|
@@ -17,10 +17,11 @@ function CommentsSection() {
|
|
|
17
17
|
const { dispatch: toolsDispatch } = React.useContext(ToolsContext);
|
|
18
18
|
const { state: menusState, dispatch: menusDispatch } = React.useContext(MenusContext);
|
|
19
19
|
const { currentViewer, commentsVisibleInViewer, focusedCommentId, pendingCommentAction } = menusState.menus;
|
|
20
|
+
const viewer = currentViewer;
|
|
20
21
|
const focusComment = React.useCallback((commentId) => {
|
|
21
|
-
menusDispatch({ type: "SHOW_COMMENTS_IN_VIEWER", payload: { viewer
|
|
22
|
+
menusDispatch({ type: "SHOW_COMMENTS_IN_VIEWER", payload: { viewer } });
|
|
22
23
|
menusDispatch({ type: "SET_FOCUSED_COMMENT_ID", payload: { commentId } });
|
|
23
|
-
}, [menusDispatch,
|
|
24
|
+
}, [menusDispatch, viewer]);
|
|
24
25
|
React.useEffect(() => {
|
|
25
26
|
if (pendingCommentAction) menusDispatch({ type: "CLEAR_PENDING_COMMENT_ACTION" });
|
|
26
27
|
}, [pendingCommentAction == null ? void 0 : pendingCommentAction.requestId, menusDispatch]);
|
|
@@ -34,14 +35,14 @@ function CommentsSection() {
|
|
|
34
35
|
const { updateComment } = useComment((_d = commentToEdit == null ? void 0 : commentToEdit.id) != null ? _d : null);
|
|
35
36
|
const { deleteComments } = useDeleteComments();
|
|
36
37
|
const handleAddComment = React.useCallback(() => {
|
|
37
|
-
if (!
|
|
38
|
+
if (!viewer) return;
|
|
38
39
|
toolsDispatch({
|
|
39
40
|
type: "SET-TOOL",
|
|
40
41
|
payload: {
|
|
41
|
-
currentToolId:
|
|
42
|
+
currentToolId: viewer === "bim" ? "bim-add-comment" : viewer === "map" ? "map-add-comment" : void 0
|
|
42
43
|
}
|
|
43
44
|
});
|
|
44
|
-
}, [toolsDispatch,
|
|
45
|
+
}, [toolsDispatch, viewer]);
|
|
45
46
|
const handleCommentAction = React.useCallback((action, id) => {
|
|
46
47
|
switch (action) {
|
|
47
48
|
case "delete": {
|
|
@@ -83,7 +84,7 @@ function CommentsSection() {
|
|
|
83
84
|
}, [createComment, user]);
|
|
84
85
|
const handleFileUpload = React.useCallback((commentId, files) => {
|
|
85
86
|
}, []);
|
|
86
|
-
const currentComments = comments.filter((comment) =>
|
|
87
|
+
const currentComments = comments.filter((comment) => viewer === comment.viewer && (!comment.buildingId || comment.buildingId === buildingId));
|
|
87
88
|
const repliesByParent = React.useMemo(() => {
|
|
88
89
|
var _a2;
|
|
89
90
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -110,15 +111,15 @@ function CommentsSection() {
|
|
|
110
111
|
}
|
|
111
112
|
);
|
|
112
113
|
}, [topLevelComments, searchQuery]);
|
|
113
|
-
const commentsVisible = commentsVisibleInViewer.includes(
|
|
114
|
+
const commentsVisible = commentsVisibleInViewer.includes(viewer);
|
|
114
115
|
const toggleCommentsVisibility = React.useCallback(() => {
|
|
115
116
|
menusDispatch({
|
|
116
117
|
type: commentsVisible ? "HIDE_COMMENTS_IN_VIEWER" : "SHOW_COMMENTS_IN_VIEWER",
|
|
117
118
|
payload: {
|
|
118
|
-
viewer
|
|
119
|
+
viewer
|
|
119
120
|
}
|
|
120
121
|
});
|
|
121
|
-
}, [
|
|
122
|
+
}, [viewer, commentsVisible, menusDispatch]);
|
|
122
123
|
return /* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col space-y-4 overflow-hidden", children: [
|
|
123
124
|
/* @__PURE__ */ jsx("div", { className: "px-4", children: /* @__PURE__ */ jsx(
|
|
124
125
|
SearchInput,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/core/components/ui/Comments/CommentsSection.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as LR from 'lucide-react'\r\nimport { useSession } from 'next-auth/react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from 'react'\r\nimport { toast } from 'sonner'\r\n\r\nimport { useComment, useComments, useCreateComment, useDeleteComments } from '../../../hooks/comments/comments';\r\nimport { BuildingsContext, MenusContext, ToolsContext, usePermissions } from '../../../store'\r\nimport { CollapsibleSection } from '../CollapsibleSection'\r\nimport { SearchInput } from '../SearchInput'\r\n\r\n\r\nimport { CollapsibleCommentItem } from './CollapsibleCommentItem'\r\n\r\nimport type { Comment } from '../../../types/dbTypes'\r\n\r\n\r\n\r\ntype CommentAction = 'view' | 'edit' | 'delete' | 'reply'\r\n\r\nexport function CommentsSection() {\r\n // Translation\r\n const t = useTranslations('CommentsSection')\r\n // Permissions\r\n const { ability } = usePermissions()\r\n\r\n const { dispatch: toolsDispatch } = React.useContext(ToolsContext)\r\n const { state: menusState, dispatch: menusDispatch } = React.useContext(MenusContext)\r\n const { currentViewer, commentsVisibleInViewer, focusedCommentId, pendingCommentAction } = menusState.menus\r\n\r\n const focusComment = React.useCallback((commentId: number) => {\r\n // Ensure comments are visible in the active viewer so the zoom target is actually rendered.\r\n menusDispatch({ type: 'SHOW_COMMENTS_IN_VIEWER', payload: { viewer: currentViewer } })\r\n menusDispatch({ type: 'SET_FOCUSED_COMMENT_ID', payload: { commentId } })\r\n }, [menusDispatch, currentViewer])\r\n\r\n // A pending action (open editor/reply from a marker) is one-shot: child items consume it\r\n // on their mount/update effect (children run before this parent effect), then we clear it so\r\n // it does not re-fire when the sidebar remounts.\r\n React.useEffect(() => {\r\n if (pendingCommentAction) menusDispatch({ type: 'CLEAR_PENDING_COMMENT_ACTION' })\r\n }, [pendingCommentAction?.requestId, menusDispatch])\r\n\r\n const {comments} = useComments()\r\n const {state: buildingsState} = React.useContext(BuildingsContext)\r\n const buildingId = buildingsState?.buildings?.building?.id || -1\r\n\r\n const user = useSession().data?.user\r\n const { createComment } = useCreateComment()\r\n\r\n const [commentToEdit, setCommentToEdit] = React.useState<{ id: number; text: string } | null>(null)\r\n const [searchQuery, setSearchQuery] = React.useState('')\r\n const { updateComment } = useComment(commentToEdit?.id ?? null)\r\n const { deleteComments } = useDeleteComments()\r\n\r\n const handleAddComment = React.useCallback(() => {\r\n if (!currentViewer) return\r\n toolsDispatch({\r\n type: 'SET-TOOL',\r\n payload: {\r\n currentToolId:\r\n currentViewer === 'bim'\r\n ? 'bim-add-comment'\r\n : currentViewer === 'map'\r\n ? 'map-add-comment'\r\n : undefined,\r\n },\r\n })\r\n }, [toolsDispatch, currentViewer])\r\n\r\n const handleCommentAction = React.useCallback((action: CommentAction, id: number) => {\r\n switch (action) {\r\n case 'delete': {\r\n toast.success(t('commentDeleted'))\r\n // Cascade: delete the comment together with its replies (DB does not cascade).\r\n const replyIds = comments.filter((c) => c.replyToId === id).map((c) => c.id)\r\n void deleteComments({ ids: [id, ...replyIds] })\r\n break\r\n }\r\n // 'view', 'edit' and 'reply' are handled inline by CollapsibleCommentItem\r\n // (edit -> onEdit, reply -> onReply)\r\n default:\r\n break\r\n }\r\n }, [t, comments, deleteComments])\r\n\r\n // Trigger edit when commentToEdit changes\r\n React.useEffect(() => {\r\n if (commentToEdit !== null) {\r\n void updateComment({ text: commentToEdit.text })\r\n setCommentToEdit(null)\r\n }\r\n }, [commentToEdit, updateComment])\r\n\r\n const handleEdit = React.useCallback((id: number, text: string) => {\r\n setCommentToEdit({ id, text })\r\n }, [])\r\n\r\n const handleReply = React.useCallback((parent: Comment, replyText: string) => {\r\n if (!replyText.trim() || !user) return\r\n void createComment({\r\n commentData: {\r\n text: replyText,\r\n authorId: Number(user.id),\r\n organizationId: user.organizationId,\r\n viewer: parent.viewer,\r\n buildingId: parent.buildingId,\r\n // Flat threading: a reply to a reply attaches to the top-level parent\r\n replyToId: parent.replyToId ?? parent.id,\r\n visible: true,\r\n },\r\n })\r\n }, [createComment, user])\r\n\r\n const handleFileUpload = React.useCallback((commentId: number, files: FileList) => {\r\n // ⚠️ Comment file upload not implemented (files are discarded)\r\n }, [])\r\n\r\n const currentComments = comments.filter((comment) => currentViewer === comment.viewer && (!comment.buildingId || comment.buildingId === buildingId))\r\n\r\n // Group replies under their parent (flat, single level)\r\n const repliesByParent = React.useMemo(() => {\r\n const map = new Map<number, Comment[]>()\r\n for (const comment of currentComments) {\r\n if (comment.replyToId != null) {\r\n const list = map.get(comment.replyToId) ?? []\r\n list.push(comment)\r\n map.set(comment.replyToId, list)\r\n }\r\n }\r\n return map\r\n }, [currentComments])\r\n\r\n // Top-level comments only (replies are nested under their parent)\r\n const topLevelComments = React.useMemo(\r\n () => currentComments.filter((comment) => comment.replyToId == null),\r\n [currentComments]\r\n )\r\n\r\n // Filter comments based on search query\r\n const filteredComments = React.useMemo(() => {\r\n if (!searchQuery.trim()) return topLevelComments\r\n\r\n const query = searchQuery.toLowerCase()\r\n return topLevelComments.filter((comment) =>\r\n comment.text?.toLowerCase().includes(query)\r\n )\r\n }, [topLevelComments, searchQuery])\r\n\r\n const commentsVisible = commentsVisibleInViewer.includes(currentViewer)\r\n\r\n const toggleCommentsVisibility = React.useCallback(() => {\r\n menusDispatch({\r\n type: commentsVisible ? 'HIDE_COMMENTS_IN_VIEWER' : 'SHOW_COMMENTS_IN_VIEWER',\r\n payload: {\r\n viewer: currentViewer,\r\n },\r\n })\r\n }, [currentViewer, commentsVisible, menusDispatch])\r\n\r\n return (\r\n <div className=\"flex-1 flex flex-col space-y-4 overflow-hidden\">\r\n <div className=\"px-4\">\r\n <SearchInput\r\n placeholder={t('searchComments')}\r\n value={searchQuery}\r\n onChange={e => setSearchQuery(e.target.value)}\r\n />\r\n </div>\r\n <CollapsibleSection\r\n title={t('commentsTitle')}\r\n icon={LR.MessageCircle}\r\n className=\"overflow-y-auto\"\r\n itemCount={filteredComments.length}\r\n onAddItem={handleAddComment}\r\n addItemTitle={t('addCommentTitle')}\r\n switchVariant={{\r\n checked: commentsVisible,\r\n onCheckedChange: toggleCommentsVisibility,\r\n }}\r\n >\r\n <div className=\"space-y-2 mx-2 pr-2 pb-2\">\r\n {filteredComments.map((comment) => (\r\n <CollapsibleCommentItem\r\n key={comment.id}\r\n comment={comment}\r\n onAction={handleCommentAction}\r\n onReply={handleReply}\r\n onEdit={handleEdit}\r\n onFileUpload={handleFileUpload}\r\n replies={repliesByParent.get(comment.id) ?? []}\r\n attachments={[]}\r\n isVisible={commentsVisible}\r\n focused={focusedCommentId === comment.id}\r\n onFocus={() => focusComment(comment.id)}\r\n pendingAction={pendingCommentAction ?? undefined}\r\n onMouseEnter={() => menusDispatch({ type: 'SET_CURRENT_COMMENT_ID', payload: { commentId: comment.id } })}\r\n onMouseLeave={() => menusDispatch({ type: 'SET_CURRENT_COMMENT_ID', payload: { commentId: null } })}\r\n />\r\n ))}\r\n </div>\r\n </CollapsibleSection>\r\n </div>\r\n )\r\n}\r\n"],"mappings":";AAsKI,SAEI,KAFJ;AAjKJ,YAAY,QAAQ;AACpB,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,YAAY,WAAW;AACvB,SAAS,aAAa;AAEtB,SAAS,YAAY,aAAa,kBAAkB,yBAAyB;AAC7E,SAAS,kBAAkB,cAAc,cAAc,sBAAsB;AAC7E,SAAS,0BAA0B;AACnC,SAAS,mBAAmB;AAG5B,SAAS,8BAA8B;AAQhC,SAAS,kBAAkB;AAzBlC;AA2BE,QAAM,IAAI,gBAAgB,iBAAiB;AAE3C,QAAM,EAAE,QAAQ,IAAI,eAAe;AAEnC,QAAM,EAAE,UAAU,cAAc,IAAI,MAAM,WAAW,YAAY;AACjE,QAAM,EAAE,OAAO,YAAY,UAAU,cAAc,IAAI,MAAM,WAAW,YAAY;AACpF,QAAM,EAAE,eAAe,yBAAyB,kBAAkB,qBAAqB,IAAI,WAAW;AAEtG,QAAM,eAAe,MAAM,YAAY,CAAC,cAAsB;AAE5D,kBAAc,EAAE,MAAM,2BAA2B,SAAS,EAAE,QAAQ,cAAc,EAAE,CAAC;AACrF,kBAAc,EAAE,MAAM,0BAA0B,SAAS,EAAE,UAAU,EAAE,CAAC;AAAA,EAC1E,GAAG,CAAC,eAAe,aAAa,CAAC;AAKjC,QAAM,UAAU,MAAM;AACpB,QAAI,qBAAsB,eAAc,EAAE,MAAM,+BAA+B,CAAC;AAAA,EAClF,GAAG,CAAC,6DAAsB,WAAW,aAAa,CAAC;AAEnD,QAAM,EAAC,SAAQ,IAAI,YAAY;AAC/B,QAAM,EAAC,OAAO,eAAc,IAAI,MAAM,WAAW,gBAAgB;AACjE,QAAM,eAAa,4DAAgB,cAAhB,mBAA2B,a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AA,cACtC,SAAS,MAAM,aAAa,QAAQ,EAAE;AAAA,cACtC,eAAe,sDAAwB;AAAA,cACvC,cAAc,MAAM,cAAc,EAAE,MAAM,0BAA0B,SAAS,EAAE,WAAW,QAAQ,GAAG,EAAE,CAAC;AAAA,cACxG,cAAc,MAAM,cAAc,EAAE,MAAM,0BAA0B,SAAS,EAAE,WAAW,KAAK,EAAE,CAAC;AAAA;AAAA,YAb7F,QAAQ;AAAA,UAcf;AAAA,SACD,GACH;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":["_a"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/core/components/ui/Comments/CommentsSection.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as LR from 'lucide-react'\r\nimport { useSession } from 'next-auth/react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from 'react'\r\nimport { toast } from 'sonner'\r\n\r\nimport { useComment, useComments, useCreateComment, useDeleteComments } from '../../../hooks/comments/comments';\r\nimport { BuildingsContext, MenusContext, ToolsContext, usePermissions } from '../../../store'\r\nimport { CollapsibleSection } from '../CollapsibleSection'\r\nimport { SearchInput } from '../SearchInput'\r\n\r\n\r\nimport { CollapsibleCommentItem } from './CollapsibleCommentItem'\r\n\r\nimport type { Comment, ViewerNames } from '../../../types/dbTypes'\r\n\r\n\r\n\r\ntype CommentAction = 'view' | 'edit' | 'delete' | 'reply'\r\n\r\nexport function CommentsSection() {\r\n // Translation\r\n const t = useTranslations('CommentsSection')\r\n // Permissions\r\n const { ability } = usePermissions()\r\n\r\n const { dispatch: toolsDispatch } = React.useContext(ToolsContext)\r\n const { state: menusState, dispatch: menusDispatch } = React.useContext(MenusContext)\r\n const { currentViewer, commentsVisibleInViewer, focusedCommentId, pendingCommentAction } = menusState.menus\r\n // Only mounted from a built-in viewer's sidebar, so the key is never a plugin page's.\r\n const viewer = currentViewer as ViewerNames\r\n\r\n const focusComment = React.useCallback((commentId: number) => {\r\n // Ensure comments are visible in the active viewer so the zoom target is actually rendered.\r\n menusDispatch({ type: 'SHOW_COMMENTS_IN_VIEWER', payload: { viewer } })\r\n menusDispatch({ type: 'SET_FOCUSED_COMMENT_ID', payload: { commentId } })\r\n }, [menusDispatch, viewer])\r\n\r\n // A pending action (open editor/reply from a marker) is one-shot: child items consume it\r\n // on their mount/update effect (children run before this parent effect), then we clear it so\r\n // it does not re-fire when the sidebar remounts.\r\n React.useEffect(() => {\r\n if (pendingCommentAction) menusDispatch({ type: 'CLEAR_PENDING_COMMENT_ACTION' })\r\n }, [pendingCommentAction?.requestId, menusDispatch])\r\n\r\n const {comments} = useComments()\r\n const {state: buildingsState} = React.useContext(BuildingsContext)\r\n const buildingId = buildingsState?.buildings?.building?.id || -1\r\n\r\n const user = useSession().data?.user\r\n const { createComment } = useCreateComment()\r\n\r\n const [commentToEdit, setCommentToEdit] = React.useState<{ id: number; text: string } | null>(null)\r\n const [searchQuery, setSearchQuery] = React.useState('')\r\n const { updateComment } = useComment(commentToEdit?.id ?? null)\r\n const { deleteComments } = useDeleteComments()\r\n\r\n const handleAddComment = React.useCallback(() => {\r\n if (!viewer) return\r\n toolsDispatch({\r\n type: 'SET-TOOL',\r\n payload: {\r\n currentToolId:\r\n viewer === 'bim'\r\n ? 'bim-add-comment'\r\n : viewer === 'map'\r\n ? 'map-add-comment'\r\n : undefined,\r\n },\r\n })\r\n }, [toolsDispatch, viewer])\r\n\r\n const handleCommentAction = React.useCallback((action: CommentAction, id: number) => {\r\n switch (action) {\r\n case 'delete': {\r\n toast.success(t('commentDeleted'))\r\n // Cascade: delete the comment together with its replies (DB does not cascade).\r\n const replyIds = comments.filter((c) => c.replyToId === id).map((c) => c.id)\r\n void deleteComments({ ids: [id, ...replyIds] })\r\n break\r\n }\r\n // 'view', 'edit' and 'reply' are handled inline by CollapsibleCommentItem\r\n // (edit -> onEdit, reply -> onReply)\r\n default:\r\n break\r\n }\r\n }, [t, comments, deleteComments])\r\n\r\n // Trigger edit when commentToEdit changes\r\n React.useEffect(() => {\r\n if (commentToEdit !== null) {\r\n void updateComment({ text: commentToEdit.text })\r\n setCommentToEdit(null)\r\n }\r\n }, [commentToEdit, updateComment])\r\n\r\n const handleEdit = React.useCallback((id: number, text: string) => {\r\n setCommentToEdit({ id, text })\r\n }, [])\r\n\r\n const handleReply = React.useCallback((parent: Comment, replyText: string) => {\r\n if (!replyText.trim() || !user) return\r\n void createComment({\r\n commentData: {\r\n text: replyText,\r\n authorId: Number(user.id),\r\n organizationId: user.organizationId,\r\n viewer: parent.viewer,\r\n buildingId: parent.buildingId,\r\n // Flat threading: a reply to a reply attaches to the top-level parent\r\n replyToId: parent.replyToId ?? parent.id,\r\n visible: true,\r\n },\r\n })\r\n }, [createComment, user])\r\n\r\n const handleFileUpload = React.useCallback((commentId: number, files: FileList) => {\r\n // ⚠️ Comment file upload not implemented (files are discarded)\r\n }, [])\r\n\r\n const currentComments = comments.filter((comment) => viewer === comment.viewer && (!comment.buildingId || comment.buildingId === buildingId))\r\n\r\n // Group replies under their parent (flat, single level)\r\n const repliesByParent = React.useMemo(() => {\r\n const map = new Map<number, Comment[]>()\r\n for (const comment of currentComments) {\r\n if (comment.replyToId != null) {\r\n const list = map.get(comment.replyToId) ?? []\r\n list.push(comment)\r\n map.set(comment.replyToId, list)\r\n }\r\n }\r\n return map\r\n }, [currentComments])\r\n\r\n // Top-level comments only (replies are nested under their parent)\r\n const topLevelComments = React.useMemo(\r\n () => currentComments.filter((comment) => comment.replyToId == null),\r\n [currentComments]\r\n )\r\n\r\n // Filter comments based on search query\r\n const filteredComments = React.useMemo(() => {\r\n if (!searchQuery.trim()) return topLevelComments\r\n\r\n const query = searchQuery.toLowerCase()\r\n return topLevelComments.filter((comment) =>\r\n comment.text?.toLowerCase().includes(query)\r\n )\r\n }, [topLevelComments, searchQuery])\r\n\r\n const commentsVisible = commentsVisibleInViewer.includes(viewer)\r\n\r\n const toggleCommentsVisibility = React.useCallback(() => {\r\n menusDispatch({\r\n type: commentsVisible ? 'HIDE_COMMENTS_IN_VIEWER' : 'SHOW_COMMENTS_IN_VIEWER',\r\n payload: {\r\n viewer,\r\n },\r\n })\r\n }, [viewer, commentsVisible, menusDispatch])\r\n\r\n return (\r\n <div className=\"flex-1 flex flex-col space-y-4 overflow-hidden\">\r\n <div className=\"px-4\">\r\n <SearchInput\r\n placeholder={t('searchComments')}\r\n value={searchQuery}\r\n onChange={e => setSearchQuery(e.target.value)}\r\n />\r\n </div>\r\n <CollapsibleSection\r\n title={t('commentsTitle')}\r\n icon={LR.MessageCircle}\r\n className=\"overflow-y-auto\"\r\n itemCount={filteredComments.length}\r\n onAddItem={handleAddComment}\r\n addItemTitle={t('addCommentTitle')}\r\n switchVariant={{\r\n checked: commentsVisible,\r\n onCheckedChange: toggleCommentsVisibility,\r\n }}\r\n >\r\n <div className=\"space-y-2 mx-2 pr-2 pb-2\">\r\n {filteredComments.map((comment) => (\r\n <CollapsibleCommentItem\r\n key={comment.id}\r\n comment={comment}\r\n onAction={handleCommentAction}\r\n onReply={handleReply}\r\n onEdit={handleEdit}\r\n onFileUpload={handleFileUpload}\r\n replies={repliesByParent.get(comment.id) ?? []}\r\n attachments={[]}\r\n isVisible={commentsVisible}\r\n focused={focusedCommentId === comment.id}\r\n onFocus={() => focusComment(comment.id)}\r\n pendingAction={pendingCommentAction ?? undefined}\r\n onMouseEnter={() => menusDispatch({ type: 'SET_CURRENT_COMMENT_ID', payload: { commentId: comment.id } })}\r\n onMouseLeave={() => menusDispatch({ type: 'SET_CURRENT_COMMENT_ID', payload: { commentId: null } })}\r\n />\r\n ))}\r\n </div>\r\n </CollapsibleSection>\r\n </div>\r\n )\r\n}\r\n"],"mappings":";AAwKI,SAEI,KAFJ;AAnKJ,YAAY,QAAQ;AACpB,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,YAAY,WAAW;AACvB,SAAS,aAAa;AAEtB,SAAS,YAAY,aAAa,k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;","names":["_a"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SensorsSection.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/ui/Sensors/SensorsSection.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAuC9B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,wBAAgB,cAAc,
|
|
1
|
+
{"version":3,"file":"SensorsSection.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/ui/Sensors/SensorsSection.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAuC9B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,wBAAgB,cAAc,sBA0W7B"}
|
|
@@ -36,6 +36,7 @@ function SensorsSection() {
|
|
|
36
36
|
const { dispatch: toolsDispatch } = React.useContext(ToolsContext);
|
|
37
37
|
const { state: menusState, dispatch: menusDispatch } = React.useContext(MenusContext);
|
|
38
38
|
const { currentViewer, visibleSensorTypes, visibleSensorTags, focusedSensorId, sensorLegendVisible, sensorLegendTypeId } = menusState.menus;
|
|
39
|
+
const viewer = currentViewer;
|
|
39
40
|
const { sensors: allSensors } = useSensors();
|
|
40
41
|
const { sensorTypes, isLoading } = useSensorTypes();
|
|
41
42
|
const { state: buildingsState } = React.useContext(BuildingsContext);
|
|
@@ -47,11 +48,11 @@ function SensorsSection() {
|
|
|
47
48
|
const [groupBy, setGroupBy] = React.useState("type");
|
|
48
49
|
const { deleteSensor } = useSensor(sensorToDelete);
|
|
49
50
|
const handleAddSensor = React.useCallback((currentSensorTypeId) => {
|
|
50
|
-
if (!
|
|
51
|
+
if (!viewer) return;
|
|
51
52
|
toolsDispatch({
|
|
52
53
|
type: "SET-TOOL",
|
|
53
54
|
payload: {
|
|
54
|
-
currentToolId:
|
|
55
|
+
currentToolId: viewer === "bim" ? "bim-add-sensor" : viewer === "map" ? "map-add-sensor" : void 0
|
|
55
56
|
}
|
|
56
57
|
});
|
|
57
58
|
if (currentSensorTypeId) {
|
|
@@ -60,7 +61,7 @@ function SensorsSection() {
|
|
|
60
61
|
payload: { currentSensorTypeId }
|
|
61
62
|
});
|
|
62
63
|
}
|
|
63
|
-
}, [toolsDispatch,
|
|
64
|
+
}, [toolsDispatch, viewer]);
|
|
64
65
|
const handleSensorAction = React.useCallback((action, id) => {
|
|
65
66
|
switch (action) {
|
|
66
67
|
case "view":
|
|
@@ -82,7 +83,7 @@ function SensorsSection() {
|
|
|
82
83
|
setSensorToDelete(null);
|
|
83
84
|
}
|
|
84
85
|
}, [sensorToDelete, deleteSensor]);
|
|
85
|
-
const currentSensors = allSensors.filter((sensor) =>
|
|
86
|
+
const currentSensors = allSensors.filter((sensor) => viewer === sensor.viewer && (!sensor.buildingId || sensor.buildingId === buildingId));
|
|
86
87
|
const { seriesById } = useSensorSeriesMulti(currentSensors, { enabled: currentSensors.length > 0 });
|
|
87
88
|
const readings = React.useMemo(
|
|
88
89
|
() => valueColoursBySensor(currentSensors, sensorTypes, seriesById),
|
|
@@ -101,12 +102,12 @@ function SensorsSection() {
|
|
|
101
102
|
const { displayTimeZone, displayTimeZoneUserSet } = appConfigState.appConfig;
|
|
102
103
|
React.useEffect(() => {
|
|
103
104
|
if (displayTimeZoneUserSet) return;
|
|
104
|
-
const candidates =
|
|
105
|
+
const candidates = viewer === "bim" ? [buildingLongitude, firstSensorLongitude] : [firstSensorLongitude, buildingLongitude];
|
|
105
106
|
const zone = resolveDefaultTimeZone(candidates);
|
|
106
107
|
if (zone !== displayTimeZone) {
|
|
107
108
|
appConfigDispatch({ type: "SET_DEFAULT_TIME_ZONE", payload: { displayTimeZone: zone } });
|
|
108
109
|
}
|
|
109
|
-
}, [
|
|
110
|
+
}, [viewer, buildingLongitude, firstSensorLongitude, displayTimeZone, displayTimeZoneUserSet, appConfigDispatch]);
|
|
110
111
|
const filteredSensors = React.useMemo(() => {
|
|
111
112
|
if (!searchQuery.trim()) return currentSensors;
|
|
112
113
|
const query = searchQuery.toLowerCase();
|
|
@@ -120,44 +121,44 @@ function SensorsSection() {
|
|
|
120
121
|
menusDispatch({
|
|
121
122
|
type: "TOGGLE_SENSOR_TYPE_VISIBILITY",
|
|
122
123
|
payload: {
|
|
123
|
-
viewer
|
|
124
|
+
viewer,
|
|
124
125
|
sensorTypeId
|
|
125
126
|
}
|
|
126
127
|
});
|
|
127
|
-
}, [
|
|
128
|
+
}, [viewer, menusDispatch]);
|
|
128
129
|
const handleGroupByChange = React.useCallback((newGroupBy) => {
|
|
129
130
|
setGroupBy(newGroupBy);
|
|
130
131
|
if (newGroupBy === "tag") {
|
|
131
|
-
menusDispatch({ type: "HIDE_ALL_SENSORS_IN_VIEWER", payload: { viewer
|
|
132
|
+
menusDispatch({ type: "HIDE_ALL_SENSORS_IN_VIEWER", payload: { viewer } });
|
|
132
133
|
} else {
|
|
133
|
-
menusDispatch({ type: "HIDE_ALL_SENSOR_TAGS_IN_VIEWER", payload: { viewer
|
|
134
|
+
menusDispatch({ type: "HIDE_ALL_SENSOR_TAGS_IN_VIEWER", payload: { viewer } });
|
|
134
135
|
}
|
|
135
|
-
}, [
|
|
136
|
+
}, [viewer, menusDispatch]);
|
|
136
137
|
const legendHasContent = legendScopeSensors(
|
|
137
138
|
allSensors,
|
|
138
139
|
{
|
|
139
|
-
viewer
|
|
140
|
-
visibleTypeIds: (_h = visibleSensorTypes == null ? void 0 : visibleSensorTypes[
|
|
141
|
-
visibleTags: (_i = visibleSensorTags == null ? void 0 : visibleSensorTags[
|
|
140
|
+
viewer,
|
|
141
|
+
visibleTypeIds: (_h = visibleSensorTypes == null ? void 0 : visibleSensorTypes[viewer]) != null ? _h : [],
|
|
142
|
+
visibleTags: (_i = visibleSensorTags == null ? void 0 : visibleSensorTags[viewer]) != null ? _i : []
|
|
142
143
|
},
|
|
143
144
|
activeSensorTypeId(allSensors, {
|
|
144
|
-
legendTypeId: sensorLegendTypeId == null ? void 0 : sensorLegendTypeId[
|
|
145
|
+
legendTypeId: sensorLegendTypeId == null ? void 0 : sensorLegendTypeId[viewer],
|
|
145
146
|
activeSensorId: focusedSensorId
|
|
146
147
|
})
|
|
147
148
|
).length > 0;
|
|
148
|
-
const legendVisible = legendHasContent && (sensorLegendVisible == null ? void 0 : sensorLegendVisible[
|
|
149
|
+
const legendVisible = legendHasContent && (sensorLegendVisible == null ? void 0 : sensorLegendVisible[viewer]) !== false;
|
|
149
150
|
const toggleLegend = React.useCallback(() => {
|
|
150
|
-
menusDispatch({ type: "TOGGLE_SENSOR_LEGEND", payload: { viewer
|
|
151
|
-
}, [
|
|
151
|
+
menusDispatch({ type: "TOGGLE_SENSOR_LEGEND", payload: { viewer } });
|
|
152
|
+
}, [viewer, menusDispatch]);
|
|
152
153
|
const toggleSensorTagVisibility = React.useCallback((tag) => {
|
|
153
154
|
menusDispatch({
|
|
154
155
|
type: "TOGGLE_SENSOR_TAG_VISIBILITY",
|
|
155
156
|
payload: {
|
|
156
|
-
viewer
|
|
157
|
+
viewer,
|
|
157
158
|
sensorTag: tag
|
|
158
159
|
}
|
|
159
160
|
});
|
|
160
|
-
}, [
|
|
161
|
+
}, [viewer, menusDispatch]);
|
|
161
162
|
const sensorsByType = React.useMemo(() => {
|
|
162
163
|
const grouped = {};
|
|
163
164
|
sensorTypes.forEach((type) => {
|
|
@@ -246,7 +247,7 @@ function SensorsSection() {
|
|
|
246
247
|
var _a2;
|
|
247
248
|
const type = sensorTypes.find((t2) => t2.name === typeName);
|
|
248
249
|
const typeId = (_a2 = type == null ? void 0 : type.id) != null ? _a2 : -1;
|
|
249
|
-
const viewerTypes = visibleSensorTypes == null ? void 0 : visibleSensorTypes[
|
|
250
|
+
const viewerTypes = visibleSensorTypes == null ? void 0 : visibleSensorTypes[viewer];
|
|
250
251
|
const isTypeVisible = (viewerTypes == null ? void 0 : viewerTypes.length) > 0 && viewerTypes.includes(typeId);
|
|
251
252
|
const sensorIcon = resolveLucideIcon(type == null ? void 0 : type.icon);
|
|
252
253
|
return /* @__PURE__ */ jsx(
|
|
@@ -287,7 +288,7 @@ function SensorsSection() {
|
|
|
287
288
|
);
|
|
288
289
|
}) : Object.entries(sensorsByTag).map(([tag, sensorsOfTag]) => {
|
|
289
290
|
var _a2, _b2;
|
|
290
|
-
const isTagVisible = (_b2 = (_a2 = visibleSensorTags == null ? void 0 : visibleSensorTags[
|
|
291
|
+
const isTagVisible = (_b2 = (_a2 = visibleSensorTags == null ? void 0 : visibleSensorTags[viewer]) == null ? void 0 : _a2.includes(tag)) != null ? _b2 : false;
|
|
291
292
|
return /* @__PURE__ */ jsx(
|
|
292
293
|
CollapsibleSection,
|
|
293
294
|
{
|
|
@@ -328,7 +329,7 @@ function SensorsSection() {
|
|
|
328
329
|
editSensorId != null && allSensors.some((s) => s.id === editSensorId) && /* @__PURE__ */ jsx(
|
|
329
330
|
SensorInput,
|
|
330
331
|
{
|
|
331
|
-
viewer
|
|
332
|
+
viewer,
|
|
332
333
|
layout: "dialog",
|
|
333
334
|
isOpen: editSensorId != null,
|
|
334
335
|
editSensor: allSensors.find((s) => s.id === editSensorId),
|