@admin-layout/client 1.0.3-alpha.205 → 1.0.3-alpha.210

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.
@@ -1,14 +1,22 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
2
  import "reflect-metadata";
3
3
  /**
4
- *
5
4
  * An HOC that will render components using SLOT-FILL in case of
6
5
  * backendError else it will render the Component Passed
7
- *
8
6
  */
9
7
  interface ApplicationErrorHandlerCommonProps {
10
8
  plugins: Record<string, any>;
11
9
  children: ReactNode;
12
10
  }
13
- export declare const ApplicationErrorHandlerCommon: (FallbackComponent: any) => ({ plugins, children }: ApplicationErrorHandlerCommonProps) => ReactElement;
11
+ /**
12
+ * ApplicationErrorSlot is needed for mobile. Since for mobile
13
+ * we import Slot from @common-stack/react-mobile. The default
14
+ * Slot under RenderApplicationErrorSlot works for browser
15
+ * both ant and chakra
16
+ *
17
+ * @param FallbackComponent ReactNode
18
+ * @param [ApplicationErrorSlot] ReactNode
19
+ * @returns ReactNode
20
+ */
21
+ export declare const ApplicationErrorHandlerCommon: (FallbackComponent: any, ApplicationErrorSlot?: any) => ({ plugins, children }: ApplicationErrorHandlerCommonProps) => ReactElement;
14
22
  export {};
@@ -0,0 +1,10 @@
1
+ export declare type BACKEND_ERROR = '@platform/BACKEND_ERROR';
2
+ export declare const BACKEND_ERROR: BACKEND_ERROR;
3
+ export declare type DISMISS_APPLICATION_ERROR = '@platform/DISMISS_APPLICATION_ERROR';
4
+ export declare const DISMISS_APPLICATION_ERROR: DISMISS_APPLICATION_ERROR;
5
+ export declare type CLEAR_APPLICATION_ERRORS = '@platform/CLEAR_APPLICATION_ERRORS';
6
+ export declare const CLEAR_APPLICATION_ERRORS: CLEAR_APPLICATION_ERRORS;
7
+ export declare type RESTORE_APPLICATION_ERRORS = '@platform/RESTORE_APPLICATION_ERRORS';
8
+ export declare const RESTORE_APPLICATION_ERRORS: RESTORE_APPLICATION_ERRORS;
9
+ export declare type LOG_APPLICATION_ERROR = '@platform/LOG_APPLICATION_ERROR';
10
+ export declare const LOG_APPLICATION_ERROR: LOG_APPLICATION_ERROR;
@@ -1 +1,2 @@
1
1
  export * from './constants';
2
+ export * from './error';
package/lib/index.js CHANGED
@@ -146,16 +146,29 @@ const react_1 = __importDefault(__webpack_require__(/*! react */ "react"));
146
146
  const react_redux_1 = __webpack_require__(/*! react-redux */ "react-redux");
147
147
  __webpack_require__(/*! reflect-metadata */ "reflect-metadata");
148
148
  const components_1 = __webpack_require__(/*! @workbench-stack/components */ "@workbench-stack/components");
149
- const constants_1 = __webpack_require__(/*! ../constants/constants */ "./src/constants/constants.ts");
150
- const platform_client_1 = __webpack_require__(/*! @adminide-stack/platform-client */ "@adminide-stack/platform-client");
151
- const ApplicationErrorHandlerCommon = (FallbackComponent) => ({ plugins, children }) => {
149
+ const constants_1 = __webpack_require__(/*! ../constants */ "./src/constants/index.ts");
150
+ const selectors_1 = __webpack_require__(/*! ../redux/selectors */ "./src/redux/selectors/index.ts");
151
+ /**
152
+ * ApplicationErrorSlot is needed for mobile. Since for mobile
153
+ * we import Slot from @common-stack/react-mobile. The default
154
+ * Slot under RenderApplicationErrorSlot works for browser
155
+ * both ant and chakra
156
+ *
157
+ * @param FallbackComponent ReactNode
158
+ * @param [ApplicationErrorSlot] ReactNode
159
+ * @returns ReactNode
160
+ */
161
+ const ApplicationErrorHandlerCommon = (FallbackComponent, ApplicationErrorSlot = undefined) => ({ plugins, children }) => {
152
162
  const applicationErrors = react_redux_1.useSelector((state) => state === null || state === void 0 ? void 0 : state.applicationErrors);
153
- const errors = applicationErrors.filter((error) => !!plugins.find((plugin) => { var _a; return plugin.name === ((_a = (error === null || error === void 0 ? void 0 : error.payload).extensions) === null || _a === void 0 ? void 0 : _a.pluginName); }));
154
- const backendError = react_redux_1.useSelector(platform_client_1.backendErrorSelector);
163
+ const errors = applicationErrors.filter((error) => !!plugins.find((plugin) => plugin.name === (error === null || error === void 0 ? void 0 : error.pluginName)));
164
+ const backendError = react_redux_1.useSelector(selectors_1.backendErrorSelector);
165
+ const RenderApplicationErrorSlot = (props) => {
166
+ return !!ApplicationErrorSlot ? react_1.default.createElement(ApplicationErrorSlot, Object.assign({}, props)) : react_1.default.createElement(components_1.Slot, Object.assign({}, props));
167
+ };
155
168
  return (react_1.default.createElement(react_1.default.Fragment, null,
156
169
  !!backendError && react_1.default.createElement(FallbackComponent, { error: backendError }),
157
170
  !!(errors === null || errors === void 0 ? void 0 : errors.length)
158
- ? react_1.default.createElement(components_1.Slot, { name: constants_1.APPLICATION_ERROR_SLOT_FILL, fillProps: { active: true, applicationErrors: errors } })
171
+ ? react_1.default.createElement(RenderApplicationErrorSlot, { name: constants_1.APPLICATION_ERROR_SLOT_FILL, fillProps: { active: true, applicationErrors: errors } })
159
172
  : children));
160
173
  };
161
174
  exports.ApplicationErrorHandlerCommon = ApplicationErrorHandlerCommon;
@@ -325,6 +338,26 @@ exports.CHANGE_LANGUAGE = 'language/changeLanguage';
325
338
  exports.APPLICATION_ERROR_SLOT_FILL = "APPLICATION_ERROR_SLOT_FILL";
326
339
 
327
340
 
341
+ /***/ }),
342
+
343
+ /***/ "./src/constants/error.ts":
344
+ /*!********************************!*\
345
+ !*** ./src/constants/error.ts ***!
346
+ \********************************/
347
+ /*! no static exports found */
348
+ /***/ (function(module, exports, __webpack_require__) {
349
+
350
+ "use strict";
351
+
352
+ Object.defineProperty(exports, "__esModule", { value: true });
353
+ exports.LOG_APPLICATION_ERROR = exports.RESTORE_APPLICATION_ERRORS = exports.CLEAR_APPLICATION_ERRORS = exports.DISMISS_APPLICATION_ERROR = exports.BACKEND_ERROR = void 0;
354
+ exports.BACKEND_ERROR = '@platform/BACKEND_ERROR';
355
+ exports.DISMISS_APPLICATION_ERROR = '@platform/DISMISS_APPLICATION_ERROR';
356
+ exports.CLEAR_APPLICATION_ERRORS = '@platform/CLEAR_APPLICATION_ERRORS';
357
+ exports.RESTORE_APPLICATION_ERRORS = '@platform/RESTORE_APPLICATION_ERRORS';
358
+ exports.LOG_APPLICATION_ERROR = '@platform/LOG_APPLICATION_ERROR';
359
+
360
+
328
361
  /***/ }),
329
362
 
330
363
  /***/ "./src/constants/index.ts":
@@ -348,6 +381,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
348
381
  };
349
382
  Object.defineProperty(exports, "__esModule", { value: true });
350
383
  __exportStar(__webpack_require__(/*! ./constants */ "./src/constants/constants.ts"), exports);
384
+ __exportStar(__webpack_require__(/*! ./error */ "./src/constants/error.ts"), exports);
351
385
 
352
386
 
353
387
  /***/ }),
@@ -393,6 +427,20 @@ __exportStar(__webpack_require__(/*! ./components */ "./src/components/index.tsx
393
427
  Object.defineProperty(exports, "__esModule", { value: true });
394
428
 
395
429
 
430
+ /***/ }),
431
+
432
+ /***/ "./src/interfaces/error-state.ts":
433
+ /*!***************************************!*\
434
+ !*** ./src/interfaces/error-state.ts ***!
435
+ \***************************************/
436
+ /*! no static exports found */
437
+ /***/ (function(module, exports, __webpack_require__) {
438
+
439
+ "use strict";
440
+
441
+ Object.defineProperty(exports, "__esModule", { value: true });
442
+
443
+
396
444
  /***/ }),
397
445
 
398
446
  /***/ "./src/interfaces/generated/generated-models.ts":
@@ -655,6 +703,7 @@ __exportStar(__webpack_require__(/*! ./generated */ "./src/interfaces/generated/
655
703
  __exportStar(__webpack_require__(/*! ./default-settings */ "./src/interfaces/default-settings.ts"), exports);
656
704
  __exportStar(__webpack_require__(/*! ./pure-settings */ "./src/interfaces/pure-settings.ts"), exports);
657
705
  __exportStar(__webpack_require__(/*! ./typings */ "./src/interfaces/typings.ts"), exports);
706
+ __exportStar(__webpack_require__(/*! ./error-state */ "./src/interfaces/error-state.ts"), exports);
658
707
 
659
708
 
660
709
  /***/ }),
@@ -685,6 +734,71 @@ Object.defineProperty(exports, "__esModule", { value: true });
685
734
  Object.defineProperty(exports, "__esModule", { value: true });
686
735
 
687
736
 
737
+ /***/ }),
738
+
739
+ /***/ "./src/redux/actions/error-actions.ts":
740
+ /*!********************************************!*\
741
+ !*** ./src/redux/actions/error-actions.ts ***!
742
+ \********************************************/
743
+ /*! no static exports found */
744
+ /***/ (function(module, exports, __webpack_require__) {
745
+
746
+ "use strict";
747
+
748
+ Object.defineProperty(exports, "__esModule", { value: true });
749
+ exports.restoreApplicationError = exports.dismissApplicationError = exports.setApplicationError = void 0;
750
+ const constants_1 = __webpack_require__(/*! ../../constants */ "./src/constants/index.ts");
751
+ const setApplicationError = (payload) => {
752
+ return ({
753
+ type: constants_1.LOG_APPLICATION_ERROR,
754
+ payload,
755
+ });
756
+ };
757
+ exports.setApplicationError = setApplicationError;
758
+ function dismissApplicationError(dismissByType) {
759
+ return {
760
+ type: constants_1.DISMISS_APPLICATION_ERROR,
761
+ payload: {
762
+ dismissByType
763
+ }
764
+ };
765
+ }
766
+ exports.dismissApplicationError = dismissApplicationError;
767
+ const restoreApplicationError = (payload) => {
768
+ return ({
769
+ type: constants_1.RESTORE_APPLICATION_ERRORS,
770
+ payload,
771
+ });
772
+ };
773
+ exports.restoreApplicationError = restoreApplicationError;
774
+
775
+
776
+ /***/ }),
777
+
778
+ /***/ "./src/redux/actions/index.ts":
779
+ /*!************************************!*\
780
+ !*** ./src/redux/actions/index.ts ***!
781
+ \************************************/
782
+ /*! no static exports found */
783
+ /***/ (function(module, exports, __webpack_require__) {
784
+
785
+ "use strict";
786
+
787
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
788
+ if (k2 === undefined) k2 = k;
789
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
790
+ }) : (function(o, m, k, k2) {
791
+ if (k2 === undefined) k2 = k;
792
+ o[k2] = m[k];
793
+ }));
794
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
795
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
796
+ };
797
+ Object.defineProperty(exports, "__esModule", { value: true });
798
+ // export * from './settings-action';
799
+ __exportStar(__webpack_require__(/*! ./error-actions */ "./src/redux/actions/error-actions.ts"), exports);
800
+
801
+
688
802
  /***/ }),
689
803
 
690
804
  /***/ "./src/redux/index.ts":
@@ -707,8 +821,99 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
707
821
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
708
822
  };
709
823
  Object.defineProperty(exports, "__esModule", { value: true });
710
- // export * from './actions';
824
+ __exportStar(__webpack_require__(/*! ./actions */ "./src/redux/actions/index.ts"), exports);
711
825
  __exportStar(__webpack_require__(/*! ./settings */ "./src/redux/settings.ts"), exports);
826
+ __exportStar(__webpack_require__(/*! ./reducers */ "./src/redux/reducers/index.ts"), exports);
827
+
828
+
829
+ /***/ }),
830
+
831
+ /***/ "./src/redux/reducers/error.ts":
832
+ /*!*************************************!*\
833
+ !*** ./src/redux/reducers/error.ts ***!
834
+ \*************************************/
835
+ /*! no static exports found */
836
+ /***/ (function(module, exports, __webpack_require__) {
837
+
838
+ "use strict";
839
+
840
+ Object.defineProperty(exports, "__esModule", { value: true });
841
+ exports.applicationErrors = exports.initialErrorsState = void 0;
842
+ const constants_1 = __webpack_require__(/*! ../../constants */ "./src/constants/index.ts");
843
+ exports.initialErrorsState = [];
844
+ function applicationErrors(errorState = exports.initialErrorsState, action) {
845
+ switch (action === null || action === void 0 ? void 0 : action.type) {
846
+ case constants_1.LOG_APPLICATION_ERROR: {
847
+ const { type: errorType, payload, pluginName, displayable = true } = (action === null || action === void 0 ? void 0 : action.payload) || {};
848
+ const nextState = [...errorState];
849
+ nextState.push({
850
+ type: errorType,
851
+ displayable,
852
+ payload,
853
+ pluginName,
854
+ date: new Date(Date.now()).toUTCString(),
855
+ });
856
+ return nextState;
857
+ }
858
+ case constants_1.DISMISS_APPLICATION_ERROR: {
859
+ const { dismissByType } = action === null || action === void 0 ? void 0 : action.payload;
860
+ let nextState = [...errorState];
861
+ nextState = nextState.filter(({ type }) => dismissByType !== type);
862
+ return nextState;
863
+ }
864
+ case constants_1.CLEAR_APPLICATION_ERRORS: {
865
+ return [];
866
+ }
867
+ case constants_1.RESTORE_APPLICATION_ERRORS:
868
+ return action.payload;
869
+ default:
870
+ return errorState;
871
+ }
872
+ }
873
+ exports.applicationErrors = applicationErrors;
874
+
875
+
876
+ /***/ }),
877
+
878
+ /***/ "./src/redux/reducers/index.ts":
879
+ /*!*************************************!*\
880
+ !*** ./src/redux/reducers/index.ts ***!
881
+ \*************************************/
882
+ /*! no static exports found */
883
+ /***/ (function(module, exports, __webpack_require__) {
884
+
885
+ "use strict";
886
+
887
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
888
+ if (k2 === undefined) k2 = k;
889
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
890
+ }) : (function(o, m, k, k2) {
891
+ if (k2 === undefined) k2 = k;
892
+ o[k2] = m[k];
893
+ }));
894
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
895
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
896
+ };
897
+ Object.defineProperty(exports, "__esModule", { value: true });
898
+ __exportStar(__webpack_require__(/*! ./error */ "./src/redux/reducers/error.ts"), exports);
899
+
900
+
901
+ /***/ }),
902
+
903
+ /***/ "./src/redux/selectors/index.ts":
904
+ /*!**************************************!*\
905
+ !*** ./src/redux/selectors/index.ts ***!
906
+ \**************************************/
907
+ /*! no static exports found */
908
+ /***/ (function(module, exports, __webpack_require__) {
909
+
910
+ "use strict";
911
+
912
+ Object.defineProperty(exports, "__esModule", { value: true });
913
+ exports.backendErrorSelector = void 0;
914
+ const reselect_1 = __webpack_require__(/*! reselect */ "reselect");
915
+ const constants_1 = __webpack_require__(/*! ../../constants */ "./src/constants/index.ts");
916
+ exports.backendErrorSelector = reselect_1.createSelector((state) => state.applicationErrors, (applicationErrors) => applicationErrors.find((error) => error.type === constants_1.BACKEND_ERROR));
712
917
 
713
918
 
714
919
  /***/ }),
@@ -814,17 +1019,6 @@ const getMenuSeparation = (menus) => {
814
1019
  exports.getMenuSeparation = getMenuSeparation;
815
1020
 
816
1021
 
817
- /***/ }),
818
-
819
- /***/ "@adminide-stack/platform-client":
820
- /*!**************************************************!*\
821
- !*** external "@adminide-stack/platform-client" ***!
822
- \**************************************************/
823
- /*! no static exports found */
824
- /***/ (function(module, exports) {
825
-
826
- module.exports = require("@adminide-stack/platform-client");
827
-
828
1022
  /***/ }),
829
1023
 
830
1024
  /***/ "@apollo/client":
@@ -902,6 +1096,17 @@ module.exports = require("react-redux");
902
1096
 
903
1097
  module.exports = require("reflect-metadata");
904
1098
 
1099
+ /***/ }),
1100
+
1101
+ /***/ "reselect":
1102
+ /*!***************************!*\
1103
+ !*** external "reselect" ***!
1104
+ \***************************/
1105
+ /*! no static exports found */
1106
+ /***/ (function(module, exports) {
1107
+
1108
+ module.exports = require("reselect");
1109
+
905
1110
  /***/ })
906
1111
 
907
1112
  /******/ });