@balena/ui-shared-components 13.0.0-build-rename-and-require-widget-extracontext-02517a1eb79682c0cdcb0dd0fe8ccb17c7a2f285-1 → 13.0.0-build-remove-role-inheritance-ac3d10291e39eebb252625d4d728cead979ec6ad-1

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.
Files changed (37) hide show
  1. package/dist/components/RJST/Actions/Create.js +1 -1
  2. package/dist/components/RJST/Actions/Update.js +6 -2
  3. package/dist/components/RJST/components/Widget/Formats/BooleanAsIconWidget.d.ts +1 -1
  4. package/dist/components/RJST/components/Widget/Formats/BooleanAsIconWidget.js +1 -1
  5. package/dist/components/RJST/components/Widget/Formats/CodeWidget.d.ts +1 -1
  6. package/dist/components/RJST/components/Widget/Formats/CodeWidget.js +1 -1
  7. package/dist/components/RJST/components/Widget/Formats/DisabledTextWidget.d.ts +1 -1
  8. package/dist/components/RJST/components/Widget/Formats/DisabledTextWidget.js +1 -1
  9. package/dist/components/RJST/components/Widget/Formats/DurationWidget.d.ts +6 -1
  10. package/dist/components/RJST/components/Widget/Formats/DurationWidget.js +1 -1
  11. package/dist/components/RJST/components/Widget/Formats/ElapsedTimeWidget.d.ts +1 -1
  12. package/dist/components/RJST/components/Widget/Formats/ElapsedTimeWidget.js +4 -5
  13. package/dist/components/RJST/components/Widget/Formats/HashWidget.d.ts +1 -1
  14. package/dist/components/RJST/components/Widget/Formats/HashWidget.js +1 -1
  15. package/dist/components/RJST/components/Widget/Formats/PercentageWidget.d.ts +1 -1
  16. package/dist/components/RJST/components/Widget/Formats/PercentageWidget.js +1 -1
  17. package/dist/components/RJST/components/Widget/Formats/PlaceholderTextWidget.d.ts +1 -1
  18. package/dist/components/RJST/components/Widget/Formats/PlaceholderTextWidget.js +1 -1
  19. package/dist/components/RJST/components/Widget/Formats/TemperatureWidget.d.ts +1 -1
  20. package/dist/components/RJST/components/Widget/Formats/TemperatureWidget.js +1 -1
  21. package/dist/components/RJST/components/Widget/Formats/TxtWidget.d.ts +1 -1
  22. package/dist/components/RJST/components/Widget/Formats/TxtWidget.js +10 -2
  23. package/dist/components/RJST/components/Widget/Formats/WrapWidget.d.ts +1 -1
  24. package/dist/components/RJST/components/Widget/Formats/WrapWidget.js +1 -1
  25. package/dist/components/RJST/components/Widget/index.d.ts +1 -1
  26. package/dist/components/RJST/components/Widget/index.js +2 -2
  27. package/dist/components/RJST/components/Widget/utils.d.ts +5 -5
  28. package/dist/components/RJST/components/Widget/utils.js +2 -1
  29. package/dist/components/RJST/index.js +1 -1
  30. package/dist/components/RJST/models/example.d.ts +1 -1
  31. package/dist/components/RJST/models/example.js +1 -1
  32. package/dist/components/RJST/models/helpers.d.ts +1 -1
  33. package/dist/components/RJST/models/helpers.js +2 -2
  34. package/dist/components/RJST/schemaOps.d.ts +2 -2
  35. package/dist/components/RJST/utils.d.ts +1 -1
  36. package/dist/components/RJST/utils.js +8 -8
  37. package/package.json +2 -2
@@ -33,7 +33,7 @@ export const Create = ({ model, rjstContext, hasOngoingAction, onActionTriggered
33
33
  return (_jsx(Box, { display: "flex", children: _jsx(Tooltip, { title: typeof disabledReason === 'string' ? disabledReason : undefined, children: _jsx(Button, { "data-action": `create-${model.resource}`, variant: "contained", onClick: () => {
34
34
  onActionTriggered({
35
35
  action,
36
- schema: rjstJsonSchemaPick(model.schema, model.permissions.create),
36
+ schema: rjstJsonSchemaPick(model.schema, model.permissions.flatMap((p) => p.create)),
37
37
  });
38
38
  }, startIcon: _jsx(FontAwesomeIcon, { icon: faMagic }), disabled: !!disabledReason, children: _jsx(ActionContent, { action: action, getDisabledReason: action.isDisabled, affectedEntries: undefined, checkedState: undefined, onDisabledReady: (result) => {
39
39
  setDisabledReasonsByAction((disabledReasonsState) => (Object.assign(Object.assign({}, disabledReasonsState), { [action.title]: result })));
@@ -45,7 +45,9 @@ export const Update = ({ model, rjstContext, selected, hasOngoingAction, onActio
45
45
  action,
46
46
  schema: action.type === 'delete'
47
47
  ? {}
48
- : rjstJsonSchemaPick(model.schema, model.permissions[action.type]),
48
+ : rjstJsonSchemaPick(model.schema, model.permissions.flatMap(
49
+ // TODO: Why is this cast necessary?
50
+ (p) => p[action.type])),
49
51
  affectedEntries: selected,
50
52
  });
51
53
  },
@@ -86,7 +88,9 @@ export const Update = ({ model, rjstContext, selected, hasOngoingAction, onActio
86
88
  action,
87
89
  schema: action.type === 'delete'
88
90
  ? {}
89
- : rjstJsonSchemaPick(model.schema, model.permissions[action.type]),
91
+ : rjstJsonSchemaPick(model.schema, model.permissions.flatMap(
92
+ // TODO: Why is this cast necessary?
93
+ (p) => p[action.type])),
90
94
  affectedEntries: selected,
91
95
  });
92
96
  }, disabled: !!disabledUpdateReason, color: action.isDangerous ? 'error' : 'secondary', children: _jsx(ActionContent, { action: action, getDisabledReason: action.isDisabled, affectedEntries: selected, checkedState: checkedState, onDisabledReady: (result) => {
@@ -1 +1 @@
1
- export declare const BooleanAsIconWidget: import("../utils").Widget<object>;
1
+ export declare const BooleanAsIconWidget: import("../utils").Widget<object, object>;
@@ -4,7 +4,7 @@ import { faTimesCircle } from '@fortawesome/free-solid-svg-icons/faTimesCircle';
4
4
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5
5
  import { JsonTypes, widgetFactory } from '../utils';
6
6
  import { Box, Typography } from '@mui/material';
7
- export const BooleanAsIconWidget = widgetFactory('BooleanAsIcon', [
7
+ export const BooleanAsIconWidget = widgetFactory('BooleanAsIcon', {}, [
8
8
  JsonTypes.boolean,
9
9
  JsonTypes.number,
10
10
  JsonTypes.null,
@@ -1 +1 @@
1
- export declare const CodeWidget: import("../utils").Widget<object>;
1
+ export declare const CodeWidget: import("../utils").Widget<object, object>;
@@ -3,6 +3,6 @@ import { Tooltip } from '@mui/material';
3
3
  import { Copy } from '../../../../Copy';
4
4
  import { JsonTypes, widgetFactory } from '../utils';
5
5
  import { Code } from '../../../../Code';
6
- export const CodeWidget = widgetFactory('Code', [JsonTypes.string])(({ value, }) => {
6
+ export const CodeWidget = widgetFactory('Code', {}, [JsonTypes.string])(({ value, }) => {
7
7
  return (_jsx(Copy, { copy: value, children: _jsx(Tooltip, { title: value, children: _jsx(Code, { noWrap: true, children: value }) }) }));
8
8
  });
@@ -1 +1 @@
1
- export declare const DisabledTextWidget: import("../utils").Widget<object>;
1
+ export declare const DisabledTextWidget: import("../utils").Widget<object, object>;
@@ -3,7 +3,7 @@ import { Tooltip, Typography } from '@mui/material';
3
3
  import { useTranslation } from '../../../../../hooks/useTranslations';
4
4
  import { JsonTypes, widgetFactory } from '../utils';
5
5
  import { token } from '../../../../../utils/token';
6
- export const DisabledTextWidget = widgetFactory('DisabledText', [
6
+ export const DisabledTextWidget = widgetFactory('DisabledText', {}, [
7
7
  JsonTypes.string,
8
8
  JsonTypes.number,
9
9
  JsonTypes.null,
@@ -1 +1,6 @@
1
- export declare const DurationWidget: import("../utils").Widget<object>;
1
+ export declare const DurationWidget: import("../utils").Widget<object, {
2
+ value: {
3
+ start?: number | Date | null;
4
+ end?: number | Date | null;
5
+ };
6
+ }>;
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  import { intervalToDuration } from 'date-fns';
4
4
  import { JsonTypes, widgetFactory } from '../utils';
5
5
  import { Typography } from '@mui/material';
6
- export const DurationWidget = widgetFactory('Duration', [JsonTypes.object])(({ value, }) => {
6
+ export const DurationWidget = widgetFactory('Duration', {}, [JsonTypes.object])(({ value, }) => {
7
7
  const duration = React.useMemo(() => {
8
8
  var _a, _b, _c;
9
9
  if (!value.start || !value.end) {
@@ -1 +1 @@
1
- export declare const ElapsedTimeWidget: import("../utils").Widget<object>;
1
+ export declare const ElapsedTimeWidget: import("../utils").Widget<object, object>;
@@ -1,11 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { JsonTypes, widgetFactory, formatTimestamp, timeSince } from '../utils';
2
+ import { UiOption, JsonTypes, widgetFactory, formatTimestamp, timeSince, } from '../utils';
3
3
  import { Material, Tooltip } from '../../../../..';
4
4
  const { Typography } = Material;
5
- export const ElapsedTimeWidget = widgetFactory('ElapsedTime', [
6
- JsonTypes.string,
7
- JsonTypes.number,
8
- ])(({ value }) => {
5
+ export const ElapsedTimeWidget = widgetFactory('ElapsedTime', {
6
+ dtFormat: UiOption.string,
7
+ }, [JsonTypes.string, JsonTypes.number])(({ value }) => {
9
8
  if (!value) {
10
9
  return null;
11
10
  }
@@ -1 +1 @@
1
- export declare const HashWidget: import("../utils").Widget<object>;
1
+ export declare const HashWidget: import("../utils").Widget<object, object>;
@@ -2,6 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Code } from '@mui/icons-material';
3
3
  import { Copy } from '../../../../Copy';
4
4
  import { JsonTypes, truncateHash, widgetFactory } from '../utils';
5
- export const HashWidget = widgetFactory('Hash', [JsonTypes.string])(({ value, }) => {
5
+ export const HashWidget = widgetFactory('Hash', {}, [JsonTypes.string])(({ value, }) => {
6
6
  return (_jsx(Copy, { copy: value, children: _jsx(Code, { children: truncateHash(value) }) }));
7
7
  });
@@ -1 +1 @@
1
- export declare const PercentageWidget: import("../utils").Widget<object>;
1
+ export declare const PercentageWidget: import("../utils").Widget<object, object>;
@@ -1,6 +1,6 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { JsonTypes, widgetFactory } from '../utils';
3
- export const PercentageWidget = widgetFactory('Percentage', [
3
+ export const PercentageWidget = widgetFactory('Percentage', {}, [
4
4
  JsonTypes.string,
5
5
  JsonTypes.number,
6
6
  ])(({ value }) => {
@@ -1 +1 @@
1
- export declare const PlaceholderTextWidget: import("../utils").Widget<object>;
1
+ export declare const PlaceholderTextWidget: import("../utils").Widget<object, object>;
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Typography } from '@mui/material';
3
3
  import { JsonTypes, widgetFactory } from '../utils';
4
4
  import { token } from '../../../../../utils/token';
5
- export const PlaceholderTextWidget = widgetFactory('PlaceholderText', [
5
+ export const PlaceholderTextWidget = widgetFactory('PlaceholderText', {}, [
6
6
  JsonTypes.string,
7
7
  JsonTypes.number,
8
8
  JsonTypes.null,
@@ -1 +1 @@
1
- export declare const TemperatureWidget: import("../utils").Widget<object>;
1
+ export declare const TemperatureWidget: import("../utils").Widget<object, object>;
@@ -1,6 +1,6 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { JsonTypes, widgetFactory } from '../utils';
3
- export const TemperatureWidget = widgetFactory('Temperature', [
3
+ export const TemperatureWidget = widgetFactory('Temperature', {}, [
4
4
  JsonTypes.number,
5
5
  ])(({ value }) => {
6
6
  return _jsx(_Fragment, { children: value ? `~${value}°C` : '-' });
@@ -1,2 +1,2 @@
1
- declare const TxtWidget: import("../utils").Widget<object>;
1
+ declare const TxtWidget: import("../utils").Widget<object, object>;
2
2
  export default TxtWidget;
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import get from 'lodash/get';
3
3
  import invokeMap from 'lodash/invokeMap';
4
4
  import isArray from 'lodash/isArray';
5
- import { JsonTypes, widgetFactory, formatTimestamp } from '../utils';
5
+ import { UiOption, JsonTypes, widgetFactory, formatTimestamp } from '../utils';
6
6
  import { Truncate } from '../../../../Truncate';
7
7
  import { Typography } from '@mui/material';
8
8
  const getArrayValue = (value, uiSchema) => {
@@ -19,7 +19,15 @@ const getArrayValue = (value, uiSchema) => {
19
19
  return arrayString;
20
20
  };
21
21
  const DATE_TIME_FORMATS = ['date-time', 'date', 'time'];
22
- const TxtWidget = widgetFactory('Txt', [
22
+ const TxtWidget = widgetFactory('Txt', {
23
+ dtFormat: UiOption.string,
24
+ align: Object.assign(Object.assign({}, UiOption.string), { enum: ['inherit', 'left', 'center', 'right', 'justify'] }),
25
+ gutterBottom: UiOption.bolean,
26
+ noWrap: UiOption.boolean,
27
+ paragraph: UiOption.boolean,
28
+ sx: UiOption.object,
29
+ variant: UiOption.string,
30
+ }, [
23
31
  JsonTypes.string,
24
32
  JsonTypes.null,
25
33
  JsonTypes.integer,
@@ -1 +1 @@
1
- export declare const WrapWidget: import("../utils").Widget<object>;
1
+ export declare const WrapWidget: import("../utils").Widget<object, object>;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Typography } from '@mui/material';
3
3
  import { JsonTypes, widgetFactory } from '../utils';
4
- export const WrapWidget = widgetFactory('Wrap', [JsonTypes.string])(({ value, }) => {
4
+ export const WrapWidget = widgetFactory('Wrap', {}, [JsonTypes.string])(({ value, }) => {
5
5
  return (_jsx(Typography, { sx: { maxWidth: '475px', whitespace: 'normal' }, children: value }));
6
6
  });
@@ -1,2 +1,2 @@
1
1
  import type { WidgetProps } from './utils';
2
- export declare const Widget: ({ value, resource, schema, extraFormats, uiSchema, }: WidgetProps) => import("react/jsx-runtime").JSX.Element | null;
2
+ export declare const Widget: ({ value, extraContext, schema, extraFormats, uiSchema, }: WidgetProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -31,7 +31,7 @@ const getWidget = (value, format, uiSchemaWidget, extraFormats) => {
31
31
  });
32
32
  return (_b = (_a = extraFormat === null || extraFormat === void 0 ? void 0 : extraFormat.widget) !== null && _a !== void 0 ? _a : typeWidgets[valueType]) !== null && _b !== void 0 ? _b : typeWidgets.default;
33
33
  };
34
- export const Widget = ({ value, resource, schema = {}, extraFormats, uiSchema, }) => {
34
+ export const Widget = ({ value, extraContext, schema = {}, extraFormats, uiSchema, }) => {
35
35
  const format = getSchemaFormat(schema);
36
36
  if (!format) {
37
37
  return _jsx(_Fragment, { children: value });
@@ -43,5 +43,5 @@ export const Widget = ({ value, resource, schema = {}, extraFormats, uiSchema, }
43
43
  return null;
44
44
  }
45
45
  const WidgetComponent = getWidget(processedValue, format, undefined, extraFormats);
46
- return (_jsx(WidgetComponent, { resource: resource, value: processedValue !== null && processedValue !== void 0 ? processedValue : null, schema: schema }));
46
+ return (_jsx(WidgetComponent, { extraContext: extraContext, value: processedValue !== null && processedValue !== void 0 ? processedValue : null, schema: schema }));
47
47
  };
@@ -19,13 +19,13 @@ export interface WidgetProps<T extends object = object> {
19
19
  schema: JSONSchema | undefined;
20
20
  extraFormats?: Format[];
21
21
  uiSchema?: UiSchema;
22
- resource: T;
22
+ extraContext?: T;
23
23
  }
24
- export interface Widget<T extends object = object> {
24
+ export interface Widget<T extends object = object, ExtraProps = object> {
25
25
  uiOptions?: UiOptions;
26
26
  supportedTypes?: string[];
27
27
  displayName: string;
28
- (props: WidgetProps<T>): JSX.Element | null;
28
+ (props: WidgetProps<T> & ExtraProps): JSX.Element | null;
29
29
  }
30
30
  export declare const JsonTypes: {
31
31
  readonly array: "array";
@@ -49,9 +49,9 @@ export type UiOptions = {
49
49
  [key: string]: JSONSchema;
50
50
  };
51
51
  export declare const UiOption: UiOptions;
52
- export declare const widgetFactory: <ST extends Array<keyof JsonTypesTypeMap>>(displayName: string, supportedTypes: ST) => <T extends object, V extends WidgetProps["value"] | null = JsonTypesTypeMap[ST[number]]>(widgetFn: (props: Overwrite<WidgetProps<T>, {
52
+ export declare const widgetFactory: <ST extends Array<keyof JsonTypesTypeMap>>(displayName: string, uiOptions: Widget["uiOptions"], supportedTypes: ST) => <T extends object, ExtraProps extends object = object, V extends WidgetProps["value"] | null = JsonTypesTypeMap[ST[number]]>(widgetFn: (props: Overwrite<WidgetProps<T>, {
53
53
  value: V;
54
- }>) => JSX.Element | null) => Widget<T>;
54
+ }> & ExtraProps) => JSX.Element | null) => Widget<T, ExtraProps>;
55
55
  export declare const formatTimestamp: (timestamp: string | number, uiSchema?: UiSchema) => string;
56
56
  export declare const truncateHash: (str: string, maxLength?: number) => string;
57
57
  export declare const timeSince: (timestamp: string | number, suffix?: boolean) => string;
@@ -33,11 +33,12 @@ export const UiOption = {
33
33
  // TODO: Replace the HOF with a plain function once TS supports optional generic types
34
34
  // See: https://github.com/microsoft/TypeScript/issues/14400
35
35
  // TODO: convert the fn args to an object once we bump TS
36
- export const widgetFactory = (displayName, supportedTypes) => {
36
+ export const widgetFactory = (displayName, uiOptions, supportedTypes) => {
37
37
  return (widgetFn) => {
38
38
  const widget = widgetFn;
39
39
  Object.assign(widget, {
40
40
  displayName,
41
+ uiOptions,
41
42
  supportedTypes,
42
43
  });
43
44
  return widget;
@@ -378,7 +378,7 @@ const getColumnsFromSchema = ({ t, schema, idField, isServerSide, customSort, pr
378
378
  ? fieldCustomSort
379
379
  : getSortingFunction(key, val), render: (fieldVal, entry) => {
380
380
  const calculatedField = rjstAdaptRefScheme(fieldVal, val);
381
- return (_jsx(Widget, { extraFormats: [...(formats !== null && formats !== void 0 ? formats : []), ...defaultFormats], schema: widgetSchema, value: calculatedField, resource: entry }));
381
+ return (_jsx(Widget, { extraFormats: [...(formats !== null && formats !== void 0 ? formats : []), ...defaultFormats], schema: widgetSchema, value: calculatedField, extraContext: entry }));
382
382
  } });
383
383
  });
384
384
  };
@@ -8,7 +8,7 @@ export interface AugmentedSshKey extends RJSTBaseResource<AugmentedSshKey> {
8
8
  }
9
9
  export declare const model: RJSTRawModel<AugmentedSshKey>;
10
10
  export declare const transformers: {
11
- __permissions: () => import("../schemaOps").Permissions<AugmentedSshKey>;
11
+ __permissions: () => import("../schemaOps").Permissions<AugmentedSshKey>[];
12
12
  };
13
13
  export declare const dataExample: {
14
14
  id: number;
@@ -45,7 +45,7 @@ export const model = {
45
45
  },
46
46
  };
47
47
  export const transformers = {
48
- __permissions: () => model.permissions.administrator,
48
+ __permissions: () => [model.permissions.administrator],
49
49
  };
50
50
  export const dataExample = [
51
51
  {
@@ -10,6 +10,6 @@ export declare const rjstDefaultPermissions: {
10
10
  };
11
11
  export declare const rjstRunTransformers: <T extends Dictionary<any>, TResult extends T, TContext = null>(data: T | undefined, transformers: Transformers<T, Omit<TResult, keyof T>, TContext>, context?: TContext) => TResult | undefined;
12
12
  export declare const rjstGetModelForCollection: <T>(model: RJSTRawModel<T>, context?: {
13
- accessRole?: string | null;
13
+ accessRole?: string[] | null;
14
14
  }) => RJSTModel<T>;
15
15
  export {};
@@ -38,6 +38,6 @@ export const rjstGetModelForCollection = (model, context) => {
38
38
  ...model.priorities.tertiary,
39
39
  ])
40
40
  : model.schema;
41
- return Object.assign(Object.assign({}, model), { permissions: (accessRole != null && model.permissions[accessRole]) ||
42
- model.permissions['default'], schema });
41
+ return Object.assign(Object.assign({}, model), { permissions: (!!(accessRole === null || accessRole === void 0 ? void 0 : accessRole.length) &&
42
+ accessRole.map((a) => { var _a; return (_a = model.permissions[a]) !== null && _a !== void 0 ? _a : model.permissions['default']; })) || [model.permissions['default']], schema });
43
43
  };
@@ -4,7 +4,7 @@ import type { CheckedState } from './components/Table/utils';
4
4
  import type { PineFilterObject } from './oData/jsonToOData';
5
5
  export interface RJSTBaseResource<T> {
6
6
  id: number;
7
- __permissions: Permissions<T>;
7
+ __permissions: Array<Permissions<T>>;
8
8
  }
9
9
  type XHeaderLink = {
10
10
  tooltip: string;
@@ -30,7 +30,7 @@ export interface RJSTRawModel<T> {
30
30
  export interface RJSTModel<T> {
31
31
  resource: string;
32
32
  schema: JSONSchema;
33
- permissions: Permissions<T>;
33
+ permissions: Array<Permissions<T>>;
34
34
  priorities?: Priorities<T>;
35
35
  }
36
36
  export type RJSTEntityPropertyDefinition<T> = {
@@ -9,6 +9,6 @@ export declare const setToLocalStorage: (key: string, value: unknown) => void;
9
9
  export declare const findInObject: (obj: Record<string, any>, key: string) => any;
10
10
  export declare const ObjectFromEntries: (entries: Array<[string, any]>) => Record<string, any>;
11
11
  export declare const getTagsDisabledReason: <T extends RJSTBaseResource<T>>(selected: T[] | undefined, tagField: keyof T, checkedState: CheckedState | undefined, tagsSdk: RJSTTagsSdk<T>, t: TFunction) => Promise<string | null>;
12
- export declare const getCreateDisabledReason: <T extends RJSTBaseResource<T>>(permissions: Permissions<T>, hasOngoingAction: boolean, t: TFunction) => string | undefined;
12
+ export declare const getCreateDisabledReason: <T extends RJSTBaseResource<T>>(permissions: Array<Permissions<T>>, hasOngoingAction: boolean, t: TFunction) => string | undefined;
13
13
  export declare const rjstGetDisabledReason: <T extends RJSTBaseResource<T>>(selected: T[] | undefined, checkedState: CheckedState | undefined, hasOngoingAction: boolean, actionType: "update" | "delete" | null, t: TFunction) => string | undefined;
14
14
  export declare const getSortingFunction: <T>(schemaKey: keyof T, schemaValue: JSONSchema) => (a: T, b: T) => number;
@@ -60,9 +60,9 @@ export const getTagsDisabledReason = async (selected, tagField, checkedState, ta
60
60
  const lacksPermissionsOnSelected = tagsSdk && 'canAccess' in tagsSdk
61
61
  ? !(await tagsSdk.canAccess({ checkedState, selected }))
62
62
  : selected === null || selected === void 0 ? void 0 : selected.some((entry) => {
63
- return (!entry.__permissions.delete &&
64
- !entry.__permissions.create.includes(tagField) &&
65
- !entry.__permissions.update.includes(tagField));
63
+ return !entry.__permissions.some((p) => p.delete ||
64
+ p.create.includes(tagField) ||
65
+ p.update.includes(tagField));
66
66
  });
67
67
  if (lacksPermissionsOnSelected) {
68
68
  return t('info.edit_tag_no_permissions', { resource: 'item' });
@@ -70,11 +70,11 @@ export const getTagsDisabledReason = async (selected, tagField, checkedState, ta
70
70
  return null;
71
71
  };
72
72
  export const getCreateDisabledReason = (permissions, hasOngoingAction, t) => {
73
- var _a;
74
73
  if (hasOngoingAction) {
75
74
  return t('info.ongoing_action_wait');
76
75
  }
77
- if (!((_a = permissions.create) === null || _a === void 0 ? void 0 : _a.length)) {
76
+ if (!permissions.length ||
77
+ !permissions.filter((p) => { var _a; return (_a = p.create) === null || _a === void 0 ? void 0 : _a.length; }).length) {
78
78
  return t('info.create_item_no_permissions', { resource: 'item' });
79
79
  }
80
80
  };
@@ -89,9 +89,9 @@ export const rjstGetDisabledReason = (selected, checkedState, hasOngoingAction,
89
89
  return;
90
90
  }
91
91
  const lacksPermissionsOnSelected = selected.some((entry) => {
92
- return (!entry.__permissions[actionType] ||
93
- (Array.isArray(entry.__permissions[actionType]) &&
94
- entry.__permissions[actionType].length <= 0));
92
+ return entry.__permissions.every((p) => !p[actionType] ||
93
+ (Array.isArray(p[actionType]) &&
94
+ p[actionType].length <= 0));
95
95
  });
96
96
  if (lacksPermissionsOnSelected) {
97
97
  return t('info.update_item_no_permissions', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@balena/ui-shared-components",
3
- "version": "13.0.0-build-rename-and-require-widget-extracontext-02517a1eb79682c0cdcb0dd0fe8ccb17c7a2f285-1",
3
+ "version": "13.0.0-build-remove-role-inheritance-ac3d10291e39eebb252625d4d728cead979ec6ad-1",
4
4
  "main": "./dist/index.js",
5
5
  "sideEffects": false,
6
6
  "files": [
@@ -138,6 +138,6 @@
138
138
  },
139
139
  "homepage": "https://github.com/balena-io/ui-shared-components#readme",
140
140
  "versionist": {
141
- "publishedAt": "2025-05-08T18:53:24.991Z"
141
+ "publishedAt": "2025-05-13T11:25:22.649Z"
142
142
  }
143
143
  }