@trackunit/react-core-hooks 1.17.66 → 1.17.67-alpha-df707023a8f.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -1110,6 +1110,29 @@ const useToast = () => {
1110
1110
  return toastContext;
1111
1111
  };
1112
1112
 
1113
+ /**
1114
+ * Hook that checks whether the current user is allowed to perform a per-account,
1115
+ * FGA-backed `Account.actions` action for the active account.
1116
+ *
1117
+ * The action results are resolved once at manager startup (alongside the user's
1118
+ * permissions) and read synchronously from `useCurrentUser`, so this hook does
1119
+ * not issue a query and does not flip a loading state — mirroring
1120
+ * `useUserPermission`. Use it to gate UI on a per-account action.
1121
+ *
1122
+ * @param action - The `Account.actions` field to check.
1123
+ * @returns {boolean} `true` if the action is allowed, `false` otherwise (including before it has resolved).
1124
+ * @example
1125
+ * ```tsx
1126
+ * import { useAccountAction } from "@trackunit/react-core-hooks";
1127
+ *
1128
+ * const canManageUsers = useAccountAction("manageUsers");
1129
+ * ```
1130
+ */
1131
+ const useAccountAction = (action) => {
1132
+ const { accountActions } = useCurrentUser();
1133
+ return react.useMemo(() => accountActions?.[action] ?? false, [accountActions, action]);
1134
+ };
1135
+
1113
1136
  /**
1114
1137
  * This is a hook providing the Current User language.
1115
1138
  *
@@ -1526,6 +1549,7 @@ const useWidgetConfig = () => {
1526
1549
  };
1527
1550
 
1528
1551
  exports.fetchAssetBlobUrl = fetchAssetBlobUrl;
1552
+ exports.useAccountAction = useAccountAction;
1529
1553
  exports.useAnalytics = useAnalytics;
1530
1554
  exports.useAssetRuntime = useAssetRuntime;
1531
1555
  exports.useAssetSorting = useAssetSorting;
package/index.esm.js CHANGED
@@ -1108,6 +1108,29 @@ const useToast = () => {
1108
1108
  return toastContext;
1109
1109
  };
1110
1110
 
1111
+ /**
1112
+ * Hook that checks whether the current user is allowed to perform a per-account,
1113
+ * FGA-backed `Account.actions` action for the active account.
1114
+ *
1115
+ * The action results are resolved once at manager startup (alongside the user's
1116
+ * permissions) and read synchronously from `useCurrentUser`, so this hook does
1117
+ * not issue a query and does not flip a loading state — mirroring
1118
+ * `useUserPermission`. Use it to gate UI on a per-account action.
1119
+ *
1120
+ * @param action - The `Account.actions` field to check.
1121
+ * @returns {boolean} `true` if the action is allowed, `false` otherwise (including before it has resolved).
1122
+ * @example
1123
+ * ```tsx
1124
+ * import { useAccountAction } from "@trackunit/react-core-hooks";
1125
+ *
1126
+ * const canManageUsers = useAccountAction("manageUsers");
1127
+ * ```
1128
+ */
1129
+ const useAccountAction = (action) => {
1130
+ const { accountActions } = useCurrentUser();
1131
+ return useMemo(() => accountActions?.[action] ?? false, [accountActions, action]);
1132
+ };
1133
+
1111
1134
  /**
1112
1135
  * This is a hook providing the Current User language.
1113
1136
  *
@@ -1523,4 +1546,4 @@ const useWidgetConfig = () => {
1523
1546
  return result;
1524
1547
  };
1525
1548
 
1526
- export { fetchAssetBlobUrl, useAnalytics, useAssetRuntime, useAssetSorting, useConfirmationDialog, useCurrentUser, useCurrentUserFavoriteAdvancedSensors, useCurrentUserFavoriteInsights, useCurrentUserLanguage, useCurrentUserSystemOfMeasurement, useCurrentUserTimeFormat, useCurrentUserTimeZonePreference, useCustomerRuntime, useEnvironment, useErrorHandler, useErrorHandlerOrNull, useEventRuntime, useExportDataContext, useFeatureBranchQueryString, useFeatureFlags, useFilterBarContext, useGeolocation, useHasAccessTo, useHostFeatureFlag, useImageUploader, useIrisAppId, useIrisAppImage, useIrisAppName, useModalDialogContext, useNavigateInHost, useOemBrandingContext, useSettingsUtils, useSiteRuntime, useTimeRange, useToast, useToken, useUserPermission, useUserSubscription, useValidateAccess, useValidateAccessAsync, useWidgetConfig, useWidgetConfigAsync };
1549
+ export { fetchAssetBlobUrl, useAccountAction, useAnalytics, useAssetRuntime, useAssetSorting, useConfirmationDialog, useCurrentUser, useCurrentUserFavoriteAdvancedSensors, useCurrentUserFavoriteInsights, useCurrentUserLanguage, useCurrentUserSystemOfMeasurement, useCurrentUserTimeFormat, useCurrentUserTimeZonePreference, useCustomerRuntime, useEnvironment, useErrorHandler, useErrorHandlerOrNull, useEventRuntime, useExportDataContext, useFeatureBranchQueryString, useFeatureFlags, useFilterBarContext, useGeolocation, useHasAccessTo, useHostFeatureFlag, useImageUploader, useIrisAppId, useIrisAppImage, useIrisAppName, useModalDialogContext, useNavigateInHost, useOemBrandingContext, useSettingsUtils, useSiteRuntime, useTimeRange, useToast, useToken, useUserPermission, useUserSubscription, useValidateAccess, useValidateAccessAsync, useWidgetConfig, useWidgetConfigAsync };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../../../libs/react/core-hooks/migrations/entry.ts"],"names":[],"mappings":"","sourcesContent":["export {};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-hooks",
3
- "version": "1.17.66",
3
+ "version": "1.17.67-alpha-df707023a8f.0",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -8,9 +8,9 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "es-toolkit": "^1.39.10",
11
- "@trackunit/iris-app-runtime-core": "1.17.61",
12
- "@trackunit/iris-app-runtime-core-api": "1.16.60",
13
- "@trackunit/react-core-contexts-api": "1.17.60",
11
+ "@trackunit/iris-app-runtime-core": "1.17.62-alpha-df707023a8f.0",
12
+ "@trackunit/iris-app-runtime-core-api": "1.16.61-alpha-df707023a8f.0",
13
+ "@trackunit/react-core-contexts-api": "1.17.61-alpha-df707023a8f.0",
14
14
  "zod": "^3.25.76"
15
15
  },
16
16
  "peerDependencies": {
package/src/index.d.ts CHANGED
@@ -28,6 +28,7 @@ export * from "./timeRange/useTimeRange";
28
28
  export * from "./toast/useToast";
29
29
  export * from "./token/useToken";
30
30
  export * from "./useFeatureBranchQueryString";
31
+ export * from "./user/useAccountAction";
31
32
  export * from "./user/useCurrentUser";
32
33
  export * from "./user/useCurrentUserPreference";
33
34
  export * from "./user/useUserPermission";
@@ -0,0 +1,20 @@
1
+ export type AccountAction = "manageUsers";
2
+ /**
3
+ * Hook that checks whether the current user is allowed to perform a per-account,
4
+ * FGA-backed `Account.actions` action for the active account.
5
+ *
6
+ * The action results are resolved once at manager startup (alongside the user's
7
+ * permissions) and read synchronously from `useCurrentUser`, so this hook does
8
+ * not issue a query and does not flip a loading state — mirroring
9
+ * `useUserPermission`. Use it to gate UI on a per-account action.
10
+ *
11
+ * @param action - The `Account.actions` field to check.
12
+ * @returns {boolean} `true` if the action is allowed, `false` otherwise (including before it has resolved).
13
+ * @example
14
+ * ```tsx
15
+ * import { useAccountAction } from "@trackunit/react-core-hooks";
16
+ *
17
+ * const canManageUsers = useAccountAction("manageUsers");
18
+ * ```
19
+ */
20
+ export declare const useAccountAction: (action: AccountAction) => boolean;