@balena/ui-shared-components 12.3.6-build-update-analytics-client-c0bffc93007e8ab1140112689b40b9100c43ee13-1 → 13.0.0-build-remove-role-inheritance-cb07df8e4c7bad3712464f6cef505f1a18fed75f-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.
- package/dist/components/RJST/Actions/Create.js +1 -1
- package/dist/components/RJST/Actions/Update.js +6 -2
- package/dist/components/RJST/models/example.d.ts +1 -1
- package/dist/components/RJST/models/example.js +1 -1
- package/dist/components/RJST/models/helpers.d.ts +1 -1
- package/dist/components/RJST/models/helpers.js +2 -2
- package/dist/components/RJST/schemaOps.d.ts +2 -2
- package/dist/components/RJST/utils.d.ts +1 -1
- package/dist/components/RJST/utils.js +8 -8
- package/package.json +3 -3
|
@@ -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
|
|
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
|
|
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) => {
|
|
@@ -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;
|
|
@@ -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
|
|
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
|
|
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
|
|
64
|
-
|
|
65
|
-
|
|
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 (!
|
|
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
|
|
93
|
-
(Array.isArray(
|
|
94
|
-
|
|
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": "
|
|
3
|
+
"version": "13.0.0-build-remove-role-inheritance-cb07df8e4c7bad3712464f6cef505f1a18fed75f-1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"files": [
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"ajv": "^8.17.1",
|
|
33
33
|
"ajv-formats": "^3.0.1",
|
|
34
34
|
"ajv-keywords": "^5.1.0",
|
|
35
|
-
"analytics-client": "^3.
|
|
35
|
+
"analytics-client": "^3.0.0",
|
|
36
36
|
"color": "^5.0.0",
|
|
37
37
|
"color-hash": "^2.0.2",
|
|
38
38
|
"date-fns": "^4.1.0",
|
|
@@ -138,6 +138,6 @@
|
|
|
138
138
|
},
|
|
139
139
|
"homepage": "https://github.com/balena-io/ui-shared-components#readme",
|
|
140
140
|
"versionist": {
|
|
141
|
-
"publishedAt": "2025-04-
|
|
141
|
+
"publishedAt": "2025-04-30T15:02:38.870Z"
|
|
142
142
|
}
|
|
143
143
|
}
|