@7365admin1/layer-common 3.2.8-staging.214 → 3.2.8-staging.216

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.
@@ -1343,27 +1343,41 @@ const { userAppRole } = useLocalSetup();
1343
1343
  const { downloadPDF } = usePDFDownload();
1344
1344
  const route = useRoute();
1345
1345
 
1346
+ // Each app spells its own resources, and the three that render this dashboard
1347
+ // disagree: work orders are `work_orders` in `-security`, `workOrder` in
1348
+ // `-property-management` and `work_order` in this layer's `useCleaningPermission`;
1349
+ // visitors are `visitor-mgmt` in `-security` and `visitorManagement` in
1350
+ // `-property-management`. A widget asking for one spelling is invisible to a role
1351
+ // granted another, so every spelling in use is listed. One canonical vocabulary
1352
+ // would let all of these collapse back to a single string -- that is a
1353
+ // cross-repo change, not one this component can make.
1354
+ const WORK_ORDER_SEE_ALL = [
1355
+ "work_orders:see-all-work-orders",
1356
+ "workOrder:see-all-work-orders",
1357
+ "work_order:see-all-work-orders",
1358
+ ];
1359
+
1346
1360
  const propertyWidgetPermissions: Record<string, string[]> = {
1347
- workOrders: ["work_orders:see-all-work-orders"],
1361
+ workOrders: WORK_ORDER_SEE_ALL,
1348
1362
  incidents: ["incident-reports:see-incident-reports"],
1349
- visitors: ["visitor-mgmt:see-all-visitor"],
1363
+ visitors: ["visitor-mgmt:see-all-visitor", "visitorManagement:see-all-visitor"],
1350
1364
  facilityBookings: ["facility-booking-mgmt:see-all-facility-booking"],
1351
- activity: ["work_orders:see-all-work-orders"],
1365
+ activity: WORK_ORDER_SEE_ALL,
1352
1366
  upcomingEvents: ["event-mgmt:see-all-event"],
1353
1367
  todayReminders: ["event-mgmt:see-all-event"],
1354
1368
  todayAttentions: [
1355
1369
  "incident-reports:see-incident-reports",
1356
1370
  "facility-booking-mgmt:see-all-facility-booking",
1357
1371
  ],
1358
- workOrderStatus: ["work_orders:see-all-work-orders"],
1372
+ workOrderStatus: WORK_ORDER_SEE_ALL,
1359
1373
  feedbacks: ["feedbacks:see-all-feedback"],
1360
1374
  activePatrol: ["virtual-patrol:see-all-virtual-patrol-logs"],
1361
1375
  };
1362
1376
 
1363
1377
  const moduleWidgetPermissions: Record<string, string[]> = {
1364
- openWorkOrder: ["work_orders:see-all-work-orders"],
1365
- workOrders: ["work_orders:see-all-work-orders"],
1366
- activity: ["work_orders:see-all-work-orders"],
1378
+ openWorkOrder: WORK_ORDER_SEE_ALL,
1379
+ workOrders: WORK_ORDER_SEE_ALL,
1380
+ activity: WORK_ORDER_SEE_ALL,
1367
1381
  taskSchedule: [
1368
1382
  "cleaning-schedule-mgmt:see-all-schedules",
1369
1383
  "schedule-task-mgmt:see-all-schedule-tasks",
@@ -1406,7 +1420,12 @@ function canViewWidget(key: string) {
1406
1420
  ? propertyWidgetPermissions[key]
1407
1421
  : moduleWidgetPermissions[key];
1408
1422
 
1409
- if (!permissions) return true;
1423
+ // Fail closed. This used to return `true` while `userAppRole` was still
1424
+ // unresolved, so the dashboard drew every widget and then took some away --
1425
+ // and if the role fetch failed outright it drew every widget permanently.
1426
+ // Every other gate in this package returns `false` without a role; this one
1427
+ // now agrees with them.
1428
+ if (!permissions) return false;
1410
1429
  if (permissions.includes("*")) return true;
1411
1430
 
1412
1431
  if (
@@ -2,7 +2,12 @@ import { useCommonPermissions } from "./useCommonPermission";
2
2
 
3
3
  export function useBulletinBoardPermission() {
4
4
  const { hasPermission } = usePermission();
5
- const { bulletinBoardPermissions: permissions } = useCommonPermissions();
5
+ // Same nesting rule as every other permission composable: `hasPermission`
6
+ // reads `catalogue[resource][action]`, and `bulletinBoardPermissions` is a
7
+ // flat `{action: ...}` map. Unwrapped, `catalogue["bulletin-board"]` was
8
+ // undefined and all five gates were reachable only through `"*"`.
9
+ const { bulletinBoardPermissions } = useCommonPermissions();
10
+ const permissions: TPermissions = { "bulletin-board": bulletinBoardPermissions };
6
11
 
7
12
  const { userAppRole } = useLocalSetup();
8
13
 
@@ -2,7 +2,13 @@ import { useCommonPermissions } from "./useCommonPermission";
2
2
 
3
3
  export function useSettingsPermission() {
4
4
  const { hasPermission } = usePermission();
5
- const { siteSettingsPermissions: permissions } = useCommonPermissions();
5
+ // `hasPermission` looks the action up as `catalogue[resource][action]`, so the
6
+ // catalogue has to be nested by resource. `siteSettingsPermissions` is a flat
7
+ // `{action: ...}` map, so passing it straight through made
8
+ // `catalogue["site-settings"]` undefined and every check below fell through to
9
+ // `false` -- only the `"*"` short-circuit could ever open a panel.
10
+ const { siteSettingsPermissions } = useCommonPermissions();
11
+ const permissions: TPermissions = { "site-settings": siteSettingsPermissions };
6
12
  const { userAppRole } = useLocalSetup();
7
13
 
8
14
  const canManageSiteInformation = computed(() => {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "3.2.8-staging.214",
5
+ "version": "3.2.8-staging.216",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
@@ -35,7 +35,7 @@
35
35
  "build": "nuxt build .playground",
36
36
  "generate": "nuxt generate .playground",
37
37
  "preview": "nuxt preview .playground",
38
- "test": "esbuild composables/useVisitorSocket.ts --format=esm --outfile=test/.build/useVisitorSocket.mjs --log-level=error && node --test \"test/*.test.mjs\" && yarn test:units",
38
+ "test": "esbuild composables/useVisitorSocket.ts --format=esm --outfile=test/.build/useVisitorSocket.mjs --log-level=error && node --experimental-strip-types --test \"test/*.test.mjs\" && yarn test:units",
39
39
  "test:units": "node --experimental-strip-types --test \"utils/*.test.ts\"",
40
40
  "release": "yarn run build && changeset publish"
41
41
  },