@prorobotech/openapi-k8s-toolkit 0.0.1-alpha.85 → 0.0.1-alpha.87

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.
@@ -44249,12 +44249,12 @@ const getCreatePathToNav = ({
44249
44249
  return pathToNav;
44250
44250
  }
44251
44251
  if (type === "crd") {
44252
- return `/${baseprefix}/${clusterName}/${namespace}/forms/crds/${apiGroup}/${apiVersion}/${typeName}`;
44252
+ return `/${baseprefix}/${clusterName}/${namespace}/forms/crds/${apiGroup}/${apiVersion}/${typeName}?backlink=${window.location.pathname}`;
44253
44253
  }
44254
44254
  if (type === "nonCrd") {
44255
- return `/${baseprefix}/${clusterName}/${namespace}/forms/apis/${apiGroup}/${apiVersion}/${typeName}`;
44255
+ return `/${baseprefix}/${clusterName}/${namespace}/forms/apis/${apiGroup}/${apiVersion}/${typeName}?backlink=${window.location.pathname}`;
44256
44256
  }
44257
- return `/${baseprefix}/${clusterName}/${namespace}/forms/builtin/${apiVersion}/${typeName}`;
44257
+ return `/${baseprefix}/${clusterName}/${namespace}/forms/builtin/${apiVersion}/${typeName}?backlink=${window.location.pathname}`;
44258
44258
  };
44259
44259
  const getListPath = ({
44260
44260
  clusterName,
@@ -44372,7 +44372,8 @@ const MarketplaceCard$1 = ({
44372
44372
  isEditMode,
44373
44373
  onDeleteClick,
44374
44374
  onEditClick,
44375
- addedMode
44375
+ addedMode,
44376
+ standalone
44376
44377
  }) => {
44377
44378
  const { useToken } = theme;
44378
44379
  const { token } = useToken();
@@ -44383,7 +44384,7 @@ const MarketplaceCard$1 = ({
44383
44384
  } catch {
44384
44385
  decodedIcon = "Can't decode";
44385
44386
  }
44386
- const navigateUrl = addedMode ? getPathToNav({
44387
+ const navigateUrl = addedMode || standalone ? getPathToNav({
44387
44388
  clusterName,
44388
44389
  namespace,
44389
44390
  type,
@@ -44529,7 +44530,8 @@ const MarketPlace = ({
44529
44530
  baseApiVersion,
44530
44531
  mpResourceName,
44531
44532
  mpResourceKind,
44532
- baseprefix
44533
+ baseprefix,
44534
+ standalone
44533
44535
  }) => {
44534
44536
  const [api, contextHolder] = notification.useNotification();
44535
44537
  const [isEditMode, setIsEditMode] = useState(false);
@@ -44682,7 +44684,8 @@ const MarketPlace = ({
44682
44684
  },
44683
44685
  onEditClick: () => {
44684
44686
  setIsAddEditOpen(marketplacePanels.items.find(({ spec }) => spec.name === name) || false);
44685
- }
44687
+ },
44688
+ standalone
44686
44689
  },
44687
44690
  name
44688
44691
  )
@@ -46137,21 +46140,19 @@ const StatusText = ({
46137
46140
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
46138
46141
  children
46139
46142
  }) => {
46140
- const { id, requestIndex, jsonPath, criteria, valueToCompare, successText, errorText, ...props } = data;
46141
- const { data: multiQueryData, isLoading, isError, errors } = useMultiQuery();
46142
- let jpQueryResult;
46143
- try {
46144
- ;
46145
- [jpQueryResult] = jp.query(multiQueryData[`req${requestIndex}`], `$${jsonPath}`);
46146
- } catch (err) {
46147
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
46148
- /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
46149
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: JSON.stringify(err) })
46150
- ] });
46151
- }
46152
- const result = criteria === "equals" ? valueToCompare === jpQueryResult : valueToCompare !== jpQueryResult;
46153
- if (isLoading) {
46154
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." });
46143
+ const { id, value, criteria, valueToCompare, successText, errorText, ...props } = data;
46144
+ const { data: multiQueryData, isLoading: isMultiqueryLoading, isError, errors } = useMultiQuery();
46145
+ const partsOfUrl = usePartsOfUrl();
46146
+ const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value2, index) => {
46147
+ acc[index.toString()] = value2;
46148
+ return acc;
46149
+ }, {});
46150
+ const successTextPrepared = parseAll({ text: successText, replaceValues, multiQueryData });
46151
+ const errorTextPrepared = parseAll({ text: errorText, replaceValues, multiQueryData });
46152
+ const valuePrepared = parseAll({ text: value, replaceValues, multiQueryData });
46153
+ const result = criteria === "equals" ? valueToCompare === valuePrepared : valueToCompare !== valuePrepared;
46154
+ if (isMultiqueryLoading) {
46155
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading multiquery" });
46155
46156
  }
46156
46157
  if (isError) {
46157
46158
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
@@ -46160,7 +46161,7 @@ const StatusText = ({
46160
46161
  ] });
46161
46162
  }
46162
46163
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Typography.Text, { type: result ? "success" : "danger", ...props, children: [
46163
- result ? successText : errorText,
46164
+ result ? successTextPrepared : errorTextPrepared,
46164
46165
  children
46165
46166
  ] });
46166
46167
  };
@@ -46586,6 +46587,90 @@ const VisibilityContainer = ({
46586
46587
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.VisibilityContainer, { $hidden: valuePrepared === "~undefined-value~", children });
46587
46588
  };
46588
46589
 
46590
+ const unknownToString = (value) => {
46591
+ if (!value) {
46592
+ return "No value";
46593
+ }
46594
+ if (typeof value === "object") {
46595
+ return JSON.stringify(value);
46596
+ }
46597
+ return value.toString();
46598
+ };
46599
+ const flattenOnce = (arr) => arr.reduce((acc, row) => [...acc, ...row], []);
46600
+ const isRecordArray = (val) => {
46601
+ return Array.isArray(val) && val.every(
46602
+ (item) => item !== null && typeof item === "object" && // exclude nested Arrays if you want “plain” objects only:
46603
+ !Array.isArray(item)
46604
+ );
46605
+ };
46606
+ const parseArrayOfAny = (value) => {
46607
+ if (!Array.isArray(value)) {
46608
+ return { error: "Value on jsonPath is not an array" };
46609
+ }
46610
+ let flattenArrayOfUnknown = [];
46611
+ try {
46612
+ flattenArrayOfUnknown = flattenOnce(value);
46613
+ } catch (e) {
46614
+ console.log(e);
46615
+ return { error: "Error while flattening" };
46616
+ }
46617
+ if (isRecordArray(flattenArrayOfUnknown)) {
46618
+ return { data: flattenArrayOfUnknown };
46619
+ }
46620
+ return { error: "Value on jsonPath is not a record array" };
46621
+ };
46622
+
46623
+ const ArrayOfObjectsToKeyValues = ({ data, children }) => {
46624
+ const {
46625
+ id,
46626
+ reqIndex,
46627
+ jsonPathToArray,
46628
+ keyFieldName,
46629
+ valueFieldName,
46630
+ separator,
46631
+ containerStyle,
46632
+ rowStyle,
46633
+ keyFieldStyle,
46634
+ valueFieldStyle
46635
+ } = data;
46636
+ const { data: multiQueryData, isLoading: isMultiQueryLoading, isError: isMultiQueryErrors, errors } = useMultiQuery();
46637
+ if (isMultiQueryLoading) {
46638
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." });
46639
+ }
46640
+ if (isMultiQueryErrors) {
46641
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
46642
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
46643
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
46644
+ ] });
46645
+ }
46646
+ const jsonRoot = multiQueryData[`req${reqIndex}`];
46647
+ if (jsonRoot === void 0) {
46648
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "No root for json path" });
46649
+ }
46650
+ const anythingForNow = jp.query(jsonRoot, `$${jsonPathToArray}`);
46651
+ const { data: arrayOfObjects, error: errorArrayOfObjects } = parseArrayOfAny(anythingForNow);
46652
+ if (!arrayOfObjects) {
46653
+ if (errorArrayOfObjects) {
46654
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: errorArrayOfObjects });
46655
+ }
46656
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Not a valid data structure" });
46657
+ }
46658
+ const separatorPrepared = separator || ":";
46659
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: containerStyle, children: [
46660
+ arrayOfObjects.map((item) => {
46661
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: rowStyle, children: [
46662
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { style: keyFieldStyle, children: [
46663
+ unknownToString(item[keyFieldName]),
46664
+ separatorPrepared,
46665
+ " "
46666
+ ] }),
46667
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: valueFieldStyle, children: unknownToString(item[valueFieldName]) })
46668
+ ] }, JSON.stringify(item));
46669
+ }),
46670
+ children
46671
+ ] });
46672
+ };
46673
+
46589
46674
  const DynamicComponents = {
46590
46675
  DefaultDiv,
46591
46676
  antdText: AntdText,
@@ -46610,7 +46695,8 @@ const DynamicComponents = {
46610
46695
  NodeTerminal,
46611
46696
  PodLogs,
46612
46697
  YamlEditorSingleton,
46613
- VisibilityContainer
46698
+ VisibilityContainer,
46699
+ ArrayOfObjectsToKeyValues
46614
46700
  };
46615
46701
 
46616
46702
  const prepareUrlsToFetchForDynamicRenderer = ({