@next-core/brick-kit 2.167.0 → 2.168.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.
@@ -172,6 +172,10 @@
172
172
  K["NETWORK_ERROR"] = "NETWORK_ERROR";
173
173
  K["PAGE_NOT_FOUND"] = "PAGE_NOT_FOUND";
174
174
  K["APP_NOT_FOUND"] = "APP_NOT_FOUND";
175
+ K["LICENSE_EXPIRED"] = "LICENSE_EXPIRED";
176
+ K["NO_PERMISSION"] = "NO_PERMISSION";
177
+ K["OTHER_ERROR"] = "OTHER_ERROR";
178
+ K["GO_BACK_PREVIOUS_PAGE"] = "GO_BACK_PREVIOUS_PAGE";
175
179
  })(K || (K = {}));
176
180
 
177
181
  /**
@@ -821,6 +825,32 @@
821
825
  return StateOfUseBrick.INITIAL;
822
826
  }
823
827
 
828
+ function getTracks(value) {
829
+ var contextNames = false;
830
+ var stateNames = false;
831
+ var formStateNames = false;
832
+ if (typeof value === "string" ? brickUtils.isEvaluable(value) : isPreEvaluated(value)) {
833
+ var raw = typeof value === "string" ? value : getPreEvaluatedRaw(value);
834
+ if (brickUtils.isTrackAll(raw)) {
835
+ var result = brickUtils.trackAll(raw);
836
+ if (result) {
837
+ contextNames = result.context;
838
+ stateNames = result.state;
839
+ formStateNames = result.formState;
840
+ }
841
+ } else {
842
+ contextNames = brickUtils.trackContext(raw);
843
+ stateNames = brickUtils.trackState(raw);
844
+ formStateNames = brickUtils.trackFormState(raw);
845
+ }
846
+ }
847
+ return {
848
+ contextNames,
849
+ stateNames,
850
+ formStateNames
851
+ };
852
+ }
853
+
824
854
  /** @internal */
825
855
  function transformElementProperties(element, data, to, from, mapArray) {
826
856
  var result = preprocessTransformProperties(data, to, from, mapArray);
@@ -885,9 +915,11 @@
885
915
  raw = getPreEvaluatedRaw(v);
886
916
  addDataToPreEvaluated(v, data);
887
917
  }
888
- var contextNames = brickUtils.trackContext(raw);
889
- var stateNames = brickUtils.trackState(raw);
890
- var formStateNames = brickUtils.trackFormState(raw);
918
+ var {
919
+ contextNames,
920
+ stateNames,
921
+ formStateNames
922
+ } = getTracks(raw);
891
923
  if (contextNames || stateNames || formStateNames) {
892
924
  options.trackingContextList.push({
893
925
  contextNames,
@@ -1125,7 +1157,11 @@
1125
1157
  [K.LOGIN_TIMEOUT_MESSAGE]: "You haven't logged in or your login session has expired. Login right now?",
1126
1158
  [K.NETWORK_ERROR]: "Network error, please check your network.",
1127
1159
  [K.PAGE_NOT_FOUND]: "Page not found, please check the URL",
1128
- [K.APP_NOT_FOUND]: "App not found, maybe the URL is wrong or you don't have permission to access"
1160
+ [K.APP_NOT_FOUND]: "App not found, maybe the URL is wrong or you don't have permission to access",
1161
+ [K.LICENSE_EXPIRED]: "The license authorization has expired, please contact the platform administrator",
1162
+ [K.NO_PERMISSION]: "Unauthorized access, unable to retrieve the required resources for this page",
1163
+ [K.OTHER_ERROR]: "Oops! Something went wrong",
1164
+ [K.GO_BACK_PREVIOUS_PAGE]: "Go back to previous page"
1129
1165
  };
1130
1166
  var en = locale$7;
1131
1167
 
@@ -1137,7 +1173,11 @@
1137
1173
  [K.LOGIN_TIMEOUT_MESSAGE]: "您还未登录或登录信息已过期,现在重新登录?",
1138
1174
  [K.NETWORK_ERROR]: "网络错误,请检查您的网络连接。",
1139
1175
  [K.PAGE_NOT_FOUND]: "请求的页面未找到,请确认 URL 是否正确",
1140
- [K.APP_NOT_FOUND]: "请求的微应用无法找到, 可能是 URL 错误或者无权限访问"
1176
+ [K.APP_NOT_FOUND]: "请求的微应用无法找到, 可能是 URL 错误或者无权限访问",
1177
+ [K.LICENSE_EXPIRED]: "License 授权失效,请联系平台管理员",
1178
+ [K.NO_PERMISSION]: "没有权限,无法获取页面所需要的资源",
1179
+ [K.OTHER_ERROR]: "糟糕!页面出现了一些问题",
1180
+ [K.GO_BACK_PREVIOUS_PAGE]: "回到上一页"
1141
1181
  };
1142
1182
  var zh = locale$6;
1143
1183
 
@@ -2620,12 +2660,12 @@
2620
2660
  var _excluded$7 = ["properties", "slots"];
2621
2661
  function setupUseBrickInTemplate(props, proxyContext) {
2622
2662
  function walk(props) {
2623
- if (!brickUtils.isObject(props)) {
2624
- return props;
2625
- }
2626
2663
  if (Array.isArray(props)) {
2627
2664
  return props.map(walk);
2628
2665
  }
2666
+ if (!brickUtils.isObject(props) || !isPlainObject(props)) {
2667
+ return props;
2668
+ }
2629
2669
  return Object.fromEntries(Object.entries(props).map(_ref => {
2630
2670
  var [key, value] = _ref;
2631
2671
  return brickUtils.isObject(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.map(setup)] : [key, setup(value)] : [key, walk(value)];
@@ -2652,6 +2692,9 @@
2652
2692
  }
2653
2693
  return walk(props);
2654
2694
  }
2695
+ function isPlainObject(object) {
2696
+ return Object.prototype.toString.call(object) === "[object Object]";
2697
+ }
2655
2698
 
2656
2699
  var computeRealValue = (value, context, injectDeep, internalOptions) => {
2657
2700
  var preEvaluated = isPreEvaluated(value);
@@ -2751,11 +2794,12 @@
2751
2794
  result[propName] = realValue;
2752
2795
  }
2753
2796
  }
2754
- if (Array.isArray(trackingContextList) && (typeof propValue === "string" ? brickUtils.isEvaluable(propValue) : isPreEvaluated(propValue))) {
2755
- var raw = typeof propValue === "string" ? propValue : getPreEvaluatedRaw(propValue);
2756
- var contextNames = brickUtils.trackContext(raw);
2757
- var stateNames = brickUtils.trackState(raw);
2758
- var formStateNames = brickUtils.trackFormState(raw);
2797
+ if (Array.isArray(trackingContextList)) {
2798
+ var {
2799
+ contextNames,
2800
+ stateNames,
2801
+ formStateNames
2802
+ } = getTracks(propValue);
2759
2803
  if (contextNames || stateNames || formStateNames) {
2760
2804
  trackingContextList.push({
2761
2805
  contextNames,
@@ -3901,6 +3945,47 @@
3901
3945
  }, []);
3902
3946
  return /*#__PURE__*/React__default["default"].createElement("div", null, i18next__default["default"].t("".concat(NS_BRICK_KIT, ":").concat(K.LOGIN_TIMEOUT_MESSAGE)));
3903
3947
  }
3948
+ function getConfOfHttpStatus(error) {
3949
+ var _error$response;
3950
+ switch ((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) {
3951
+ case 403:
3952
+ return {
3953
+ showBackLink: true,
3954
+ title: i18next__default["default"].t("".concat(NS_BRICK_KIT, ":").concat(K.NO_PERMISSION)),
3955
+ illustration: {
3956
+ name: "no-permission",
3957
+ category: "easyops2"
3958
+ }
3959
+ };
3960
+ default:
3961
+ return null;
3962
+ }
3963
+ }
3964
+ function getConfOfHttpCode(error) {
3965
+ var _error$responseJson;
3966
+ switch ((_error$responseJson = error.responseJson) === null || _error$responseJson === void 0 ? void 0 : _error$responseJson.code) {
3967
+ case "200000":
3968
+ return {
3969
+ title: i18next__default["default"].t("".concat(NS_BRICK_KIT, ":").concat(K.LICENSE_EXPIRED)),
3970
+ illustration: {
3971
+ name: "license-expired",
3972
+ category: "easyops2"
3973
+ }
3974
+ };
3975
+ default:
3976
+ return {
3977
+ showBackLink: true,
3978
+ title: i18next__default["default"].t("".concat(NS_BRICK_KIT, ":").concat(K.OTHER_ERROR)),
3979
+ illustration: {
3980
+ name: "unknown-error",
3981
+ category: "easyops2"
3982
+ }
3983
+ };
3984
+ }
3985
+ }
3986
+ function getRefinedErrorConf(error) {
3987
+ return [getConfOfHttpStatus, getConfOfHttpCode].reduce((result, method) => result ? result : method(error), null);
3988
+ }
3904
3989
 
3905
3990
  class WebsocketMessageRequest {
3906
3991
  constructor(event, topic) {
@@ -8695,10 +8780,10 @@
8695
8780
  _this3.presetBricks = layout === "business" ? {
8696
8781
  loadingBar: "business-website.loading-bar",
8697
8782
  pageNotFound: "presentational-bricks.brick-result",
8698
- pageError: "business-website.page-error"
8783
+ pageError: "presentational-bricks.brick-result"
8699
8784
  } : _objectSpread__default["default"](_objectSpread__default["default"]({}, _this3.bootstrapData.navbar), {}, {
8700
8785
  pageNotFound: "presentational-bricks.brick-result",
8701
- pageError: "basic-bricks.page-error"
8786
+ pageError: "presentational-bricks.brick-result"
8702
8787
  });
8703
8788
  for (var item of supportedLayouts) {
8704
8789
  if (item === layout) {
@@ -11512,6 +11597,13 @@
11512
11597
  }
11513
11598
  _this3.kernel.setOriginFaviconHref(faviconElement.href);
11514
11599
  }
11600
+ var illustrationStyle = {
11601
+ display: "flex",
11602
+ alignItems: "center",
11603
+ justifyContent: "center",
11604
+ transform: "translateY(-100px)",
11605
+ height: "calc(100vh - var(--app-bar-height))"
11606
+ };
11515
11607
  setTheme(((_getLocalAppsTheme = getLocalAppsTheme()) === null || _getLocalAppsTheme === void 0 ? void 0 : _getLocalAppsTheme[currentApp === null || currentApp === void 0 ? void 0 : currentApp.id]) || (currentApp === null || currentApp === void 0 ? void 0 : currentApp.theme) || "light");
11516
11608
  getRuntime().getFeatureFlags()["support-ui-8.2-compact-layout"] ? document.body.classList.add("compact-layout") : document.body.classList.remove("compact-layout");
11517
11609
  setMode("default");
@@ -11569,14 +11661,41 @@
11569
11661
  var brickPageError = _this3.kernel.presetBricks.pageError;
11570
11662
  yield _this3.kernel.loadDynamicBricks([brickPageError]);
11571
11663
  mountRoutesResult.flags.failed = true;
11572
- mountRoutesResult.main = [{
11664
+ var {
11665
+ title,
11666
+ illustration,
11667
+ showBackLink
11668
+ } = getRefinedErrorConf(error);
11669
+ mountRoutesResult.main = [_objectSpread__default["default"](_objectSpread__default["default"]({
11573
11670
  type: brickPageError,
11574
11671
  properties: {
11575
- error: httpErrorToString(error),
11576
- code: error instanceof brickHttp.HttpResponseError ? error.response.status : null
11577
- },
11672
+ status: "illustrations",
11673
+ useNewIllustration: true,
11674
+ customTitle: title,
11675
+ subTitle: httpErrorToString(error),
11676
+ illustrationsConfig: illustration,
11677
+ style: illustrationStyle
11678
+ }
11679
+ }, showBackLink ? {
11680
+ children: [{
11681
+ type: "a",
11682
+ properties: {
11683
+ textContent: i18next__default["default"].t("".concat(NS_BRICK_KIT, ":").concat(K.GO_BACK_PREVIOUS_PAGE)),
11684
+ style: {
11685
+ display: "block",
11686
+ textAlign: "center"
11687
+ }
11688
+ },
11689
+ slotId: "content",
11690
+ events: {
11691
+ click: [{
11692
+ action: "history.goBack"
11693
+ }]
11694
+ }
11695
+ }]
11696
+ } : {}), {}, {
11578
11697
  events: {}
11579
- }];
11698
+ })];
11580
11699
  mountRoutesResult.portal = [];
11581
11700
  }
11582
11701
  }
@@ -11797,13 +11916,7 @@
11797
11916
  properties: _objectSpread__default["default"]({
11798
11917
  status: "illustrations",
11799
11918
  useNewIllustration: true,
11800
- style: {
11801
- display: "flex",
11802
- alignItems: "center",
11803
- justifyContent: "center",
11804
- transform: "translateY(-100px)",
11805
- height: "calc(100vh - var(--app-bar-height))"
11806
- }
11919
+ style: illustrationStyle
11807
11920
  }, storyboard ? notFoundPageConfig : notFoundAppConfig),
11808
11921
  events: {}
11809
11922
  }], mountPoints.main);