identity-admin 1.16.0 → 1.18.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.
|
@@ -100,7 +100,8 @@ let DashboardController = DashboardController_1 = class DashboardController {
|
|
|
100
100
|
for (var i = 0; i < extraActions.length; i++) {
|
|
101
101
|
const extraAction = extraActions[i];
|
|
102
102
|
if (!extraAction.isVisible) {
|
|
103
|
-
|
|
103
|
+
extraActionsArray.push(extraAction.key);
|
|
104
|
+
continue;
|
|
104
105
|
}
|
|
105
106
|
const isVisible = yield extraAction.isVisible(data);
|
|
106
107
|
if (isVisible) {
|
|
@@ -64,17 +64,20 @@ let ResourceController = class ResourceController {
|
|
|
64
64
|
}
|
|
65
65
|
for (var i = 0; i < this.resourceFiles.length; i++) {
|
|
66
66
|
const resource = this.resourceFiles[i];
|
|
67
|
-
const
|
|
68
|
-
|
|
67
|
+
const isAllowed = resource.properties.isAllowed ? yield resource.properties.isAllowed(currentUser) : true;
|
|
68
|
+
const isVisibile = resource.properties.isVisible ? yield resource.properties.isVisible(currentUser) : true;
|
|
69
|
+
if (isAllowed) {
|
|
69
70
|
const adaptedResource = ResourceGenerator_1.default.generate(resource, currentUser);
|
|
70
71
|
const modelName = StringUtils_1.default.lowerCaseFirstLetter(adaptedResource.properties.modelName);
|
|
71
72
|
modifiedResource[modelName] = adaptedResource;
|
|
72
|
-
if (
|
|
73
|
-
modifiedResource.modelParents[adaptedResource.properties.parent.name]
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
if (isVisibile) {
|
|
74
|
+
if (modifiedResource.modelParents[adaptedResource.properties.parent.name]) {
|
|
75
|
+
modifiedResource.modelParents[adaptedResource.properties.parent.name].push(modelName);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
modifiedResource.modelParents[adaptedResource.properties.parent.name] = [];
|
|
79
|
+
modifiedResource.modelParents[adaptedResource.properties.parent.name].push(modelName);
|
|
80
|
+
}
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
}
|
|
@@ -27,6 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const i18n_1 = __importStar(require("i18n"));
|
|
30
|
+
const helpers_1 = require("../types/helpers");
|
|
30
31
|
const ResourceHelper_1 = __importDefault(require("./ResourceHelper"));
|
|
31
32
|
var pluralize = require('pluralize');
|
|
32
33
|
class ActionsGenerator {
|
|
@@ -50,6 +51,7 @@ class ActionsGenerator {
|
|
|
50
51
|
extraActions.forEach((action) => {
|
|
51
52
|
action.keys = action.isVisible ? Object.keys(action.isVisible) : [];
|
|
52
53
|
action.name = (0, i18n_1.__)({ phrase: action.name, locale: i18n_1.default.getLocale() });
|
|
54
|
+
action.handlerStrategy = action.handlerStrategy ? action.handlerStrategy : helpers_1.HandlerStrategy.NORMAL;
|
|
53
55
|
action.actionType ? extraActionsObject[action.actionType][action.key] = action : '';
|
|
54
56
|
});
|
|
55
57
|
return extraActionsObject;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { Request } from "express";
|
|
2
1
|
import { Document, Model } from "mongoose";
|
|
3
2
|
import { IRequest } from "../middlewares/isAuth";
|
|
4
3
|
import { IRepository } from "../repositories/Repository";
|
|
5
|
-
import { ActionNames, ActionTypes, FieldTypes, FileTypes, Virtuals } from "./helpers";
|
|
4
|
+
import { ActionNames, ActionTypes, FieldTypes, FileTypes, HandlerStrategy, Virtuals } from "./helpers";
|
|
6
5
|
declare type orderTypes = 'asc' | 'desc';
|
|
7
6
|
declare type VirtualFieldTypes = 'password' | 'ref' | 'Array';
|
|
8
7
|
declare type Severity = 'success' | 'info' | 'warning' | 'error';
|
|
8
|
+
declare type ButtonColors = 'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning';
|
|
9
|
+
declare type ButtonVariants = 'text' | 'outlined' | 'contained';
|
|
10
|
+
declare type ButtonSizes = 'small' | 'medium' | 'large';
|
|
9
11
|
interface Parent {
|
|
10
12
|
/**
|
|
11
13
|
* Name of the parent
|
|
@@ -217,6 +219,11 @@ export interface IFieldValue {
|
|
|
217
219
|
* @default undefined
|
|
218
220
|
*/
|
|
219
221
|
apiRoute?: string;
|
|
222
|
+
/**
|
|
223
|
+
* Path of the value inside the model schema
|
|
224
|
+
* @default undefined
|
|
225
|
+
*/
|
|
226
|
+
valuePath?: string;
|
|
220
227
|
}
|
|
221
228
|
export interface IVirtualValue {
|
|
222
229
|
/**
|
|
@@ -282,6 +289,22 @@ interface ExtraAction {
|
|
|
282
289
|
* {@link https://mui.com/material-ui/material-icons/}
|
|
283
290
|
*/
|
|
284
291
|
icon: string;
|
|
292
|
+
/**
|
|
293
|
+
* Color of the action button
|
|
294
|
+
* In case of bulk actions it is one of the button colors. @default inherit
|
|
295
|
+
* In case of record actions it is any color like red, green, ... @default black
|
|
296
|
+
*/
|
|
297
|
+
color?: string | ButtonColors;
|
|
298
|
+
/**
|
|
299
|
+
* Size of the action button. Only used in case of bulk actions
|
|
300
|
+
* @default small
|
|
301
|
+
*/
|
|
302
|
+
size?: ButtonSizes;
|
|
303
|
+
/**
|
|
304
|
+
* Variant of the action button. Only used in case of bulk actions
|
|
305
|
+
* @default contained
|
|
306
|
+
*/
|
|
307
|
+
variant?: ButtonVariants;
|
|
285
308
|
/**
|
|
286
309
|
* Action type if it is record action or resource action.
|
|
287
310
|
*/
|
|
@@ -310,7 +333,12 @@ interface ExtraAction {
|
|
|
310
333
|
/**
|
|
311
334
|
* Handler function that is executed after clicking the action.
|
|
312
335
|
*/
|
|
313
|
-
handler: (req:
|
|
336
|
+
handler: (req: IRequest, res: any, data: ActionData) => Promise<IActionHandlerResponse>;
|
|
337
|
+
/**
|
|
338
|
+
* Icon of this action.
|
|
339
|
+
* {@link https://mui.com/material-ui/material-icons/}
|
|
340
|
+
*/
|
|
341
|
+
handlerStrategy?: HandlerStrategy;
|
|
314
342
|
}
|
|
315
343
|
export interface IActionHandlerResponse {
|
|
316
344
|
/**
|
|
@@ -327,6 +355,10 @@ export interface IActionHandlerResponse {
|
|
|
327
355
|
* Id of the record that is used in actions that needs record id like show or edit
|
|
328
356
|
*/
|
|
329
357
|
recordId?: string;
|
|
358
|
+
/**
|
|
359
|
+
* Path of the uploaded file in case of file download handling strategy
|
|
360
|
+
*/
|
|
361
|
+
filePath?: string;
|
|
330
362
|
}
|
|
331
363
|
export interface IResourceFile {
|
|
332
364
|
properties: {
|
|
@@ -361,6 +393,11 @@ export interface IResourceFile {
|
|
|
361
393
|
* @default true
|
|
362
394
|
*/
|
|
363
395
|
isAllowed?: (currentUser: Document) => Promise<boolean>;
|
|
396
|
+
/**
|
|
397
|
+
* The property that controls the visibility of this resource in the nav bar
|
|
398
|
+
* @default true
|
|
399
|
+
*/
|
|
400
|
+
isVisible?: (currentUser: Document) => Promise<boolean>;
|
|
364
401
|
/**
|
|
365
402
|
* The default order
|
|
366
403
|
* @default asc
|
package/lib/types/helpers.d.ts
CHANGED
package/lib/types/helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileTypes = exports.FieldTypes = exports.ActionTypes = exports.ActionNames = exports.Virtuals = void 0;
|
|
3
|
+
exports.HandlerStrategy = exports.FileTypes = exports.FieldTypes = exports.ActionTypes = exports.ActionNames = exports.Virtuals = void 0;
|
|
4
4
|
var Virtuals;
|
|
5
5
|
(function (Virtuals) {
|
|
6
6
|
Virtuals["SHOW"] = "SHOW";
|
|
@@ -51,3 +51,9 @@ var FileTypes;
|
|
|
51
51
|
FileTypes["POWER_POINT"] = "POWER_POINT";
|
|
52
52
|
FileTypes["AUDIO"] = "AUDIO";
|
|
53
53
|
})(FileTypes = exports.FileTypes || (exports.FileTypes = {}));
|
|
54
|
+
var HandlerStrategy;
|
|
55
|
+
(function (HandlerStrategy) {
|
|
56
|
+
HandlerStrategy["NORMAL"] = "NORMAL";
|
|
57
|
+
HandlerStrategy["FILE_DOWNLOAD"] = "FILE_DOWNLOAD";
|
|
58
|
+
HandlerStrategy["CUSTOM_COMPONENT"] = "CUSTOM_COMPONENT";
|
|
59
|
+
})(HandlerStrategy = exports.HandlerStrategy || (exports.HandlerStrategy = {}));
|