identity-admin 1.17.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
- break;
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 visibiltyCheck = resource.properties.isAllowed ? yield resource.properties.isAllowed(currentUser) : true;
68
- if (visibiltyCheck) {
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 (modifiedResource.modelParents[adaptedResource.properties.parent.name]) {
73
- modifiedResource.modelParents[adaptedResource.properties.parent.name].push(modelName);
74
- }
75
- else {
76
- modifiedResource.modelParents[adaptedResource.properties.parent.name] = [];
77
- modifiedResource.modelParents[adaptedResource.properties.parent.name].push(modelName);
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
@@ -287,6 +289,22 @@ interface ExtraAction {
287
289
  * {@link https://mui.com/material-ui/material-icons/}
288
290
  */
289
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;
290
308
  /**
291
309
  * Action type if it is record action or resource action.
292
310
  */
@@ -315,7 +333,12 @@ interface ExtraAction {
315
333
  /**
316
334
  * Handler function that is executed after clicking the action.
317
335
  */
318
- handler: (req: Request, res: any, data: ActionData) => Promise<IActionHandlerResponse>;
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;
319
342
  }
320
343
  export interface IActionHandlerResponse {
321
344
  /**
@@ -332,6 +355,10 @@ export interface IActionHandlerResponse {
332
355
  * Id of the record that is used in actions that needs record id like show or edit
333
356
  */
334
357
  recordId?: string;
358
+ /**
359
+ * Path of the uploaded file in case of file download handling strategy
360
+ */
361
+ filePath?: string;
335
362
  }
336
363
  export interface IResourceFile {
337
364
  properties: {
@@ -366,6 +393,11 @@ export interface IResourceFile {
366
393
  * @default true
367
394
  */
368
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>;
369
401
  /**
370
402
  * The default order
371
403
  * @default asc
@@ -43,3 +43,8 @@ export declare enum FileTypes {
43
43
  POWER_POINT = "POWER_POINT",
44
44
  AUDIO = "AUDIO"
45
45
  }
46
+ export declare enum HandlerStrategy {
47
+ NORMAL = "NORMAL",
48
+ FILE_DOWNLOAD = "FILE_DOWNLOAD",
49
+ CUSTOM_COMPONENT = "CUSTOM_COMPONENT"
50
+ }
@@ -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 = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "identity-admin",
3
- "version": "1.17.0",
3
+ "version": "1.18.0",
4
4
  "description": "",
5
5
  "main": "lib/Dashboard.js",
6
6
  "types": "lib/Dashbord.d.ts",