@prorobotech/openapi-k8s-toolkit 0.0.1-alpha.54 → 0.0.1-alpha.56

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.
@@ -8393,7 +8393,8 @@ const ContentContainer = st.div`
8393
8393
  border-radius: 6px;
8394
8394
  background-color: ${({ $bgColor }) => $bgColor};
8395
8395
  width: 100%;
8396
- height: 100%;
8396
+ height: ${({ $maxHeight }) => $maxHeight || "100%"};
8397
+ overflow-y: auto;
8397
8398
  padding: 24px;
8398
8399
  flex-grow: ${({ $flexGrow }) => $flexGrow};
8399
8400
  display: ${({ $displayFlex }) => $displayFlex ? "flex" : "block"};
@@ -8403,7 +8404,7 @@ const Styled$e = {
8403
8404
  ContentContainer
8404
8405
  };
8405
8406
 
8406
- const ContentCard$1 = ({ children, flexGrow, displayFlex, flexFlow }) => {
8407
+ const ContentCard$1 = ({ children, flexGrow, displayFlex, flexFlow, maxHeight }) => {
8407
8408
  const { token } = theme.useToken();
8408
8409
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
8409
8410
  Styled$e.ContentContainer,
@@ -8413,6 +8414,7 @@ const ContentCard$1 = ({ children, flexGrow, displayFlex, flexFlow }) => {
8413
8414
  $borderColor: token.colorBorder,
8414
8415
  $displayFlex: displayFlex,
8415
8416
  $flexFlow: flexFlow,
8417
+ $maxHeight: maxHeight,
8416
8418
  children
8417
8419
  }
8418
8420
  );
@@ -26341,7 +26343,7 @@ const getEnrichedColumnsWithControls = ({
26341
26343
  );
26342
26344
  },
26343
26345
  icon: editIcon || /* @__PURE__ */ jsxRuntimeExports.jsx(EditOutlined, { size: 14 }),
26344
- disabled: !value.permissions.canUpdate
26346
+ disabled: value.permissions && value.permissions.canUpdate ? !value.permissions?.canUpdate : false
26345
26347
  }
26346
26348
  ),
26347
26349
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -26357,7 +26359,7 @@ const getEnrichedColumnsWithControls = ({
26357
26359
  );
26358
26360
  },
26359
26361
  icon: deleteIcon || /* @__PURE__ */ jsxRuntimeExports.jsx(DeleteOutlined, { size: 14 }),
26360
- disabled: !value.permissions.canDelete
26362
+ disabled: value.permissions && value.permissions.canDelete ? !value.permissions?.canDelete : false
26361
26363
  }
26362
26364
  )
26363
26365
  ] });
@@ -26366,13 +26368,14 @@ const getEnrichedColumnsWithControls = ({
26366
26368
  ];
26367
26369
  };
26368
26370
 
26369
- const EnrichedTable = ({
26371
+ const EnrichedTable$1 = ({
26370
26372
  theme,
26371
26373
  baseprefix,
26372
26374
  dataSource,
26373
26375
  columns,
26374
26376
  pathToNavigate,
26375
26377
  recordKeysForNavigation,
26378
+ recordKeysForNavigationSecond,
26376
26379
  additionalPrinterColumnsUndefinedValues,
26377
26380
  additionalPrinterColumnsTrimLengths,
26378
26381
  additionalPrinterColumnsColWidths,
@@ -26446,8 +26449,10 @@ const EnrichedTable = ({
26446
26449
  onClick: () => {
26447
26450
  if (pathToNavigate && recordKeysForNavigation) {
26448
26451
  const recordValueRaw = lodashExports.get(record, recordKeysForNavigation);
26452
+ const recordValueRawSecond = recordKeysForNavigationSecond ? lodashExports.get(record, recordKeysForNavigationSecond) : "no-second-record-keys";
26449
26453
  const recordValue = typeof recordValueRaw === "string" ? recordValueRaw : JSON.stringify(recordValueRaw);
26450
- const newPath = pathToNavigate.replaceAll("~recordValue~", recordValue);
26454
+ const recordValueSecond = typeof recordValueRawSecond === "string" ? recordValueRawSecond : JSON.stringify(recordValueRawSecond);
26455
+ const newPath = pathToNavigate.replaceAll("~recordValue~", recordValue).replaceAll("~recordValueSecond~", recordValueSecond);
26451
26456
  navigate(newPath);
26452
26457
  }
26453
26458
  }
@@ -33383,7 +33388,8 @@ const EnrichedTableProvider = ({
33383
33388
  tableMappingsReplaceValues,
33384
33389
  forceDefaultAdditionalPrinterColumns,
33385
33390
  selectData,
33386
- tableProps
33391
+ tableProps,
33392
+ withoutControls
33387
33393
  }) => {
33388
33394
  const [preparedProps, setPreparedProps] = useState();
33389
33395
  const [isLoading, setIsLoading] = useState(false);
@@ -33420,7 +33426,7 @@ const EnrichedTableProvider = ({
33420
33426
  additionalPrinterColumns: preparedProps.additionalPrinterColumns
33421
33427
  });
33422
33428
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
33423
- EnrichedTable,
33429
+ EnrichedTable$1,
33424
33430
  {
33425
33431
  theme,
33426
33432
  baseprefix,
@@ -33428,11 +33434,13 @@ const EnrichedTableProvider = ({
33428
33434
  columns,
33429
33435
  pathToNavigate: preparedProps.pathToNavigate,
33430
33436
  recordKeysForNavigation: preparedProps.recordKeysForNavigation,
33437
+ recordKeysForNavigationSecond: preparedProps.recordKeysForNavigationSecond,
33431
33438
  additionalPrinterColumnsUndefinedValues: preparedProps.additionalPrinterColumnsUndefinedValues,
33432
33439
  additionalPrinterColumnsTrimLengths: preparedProps.additionalPrinterColumnsTrimLengths,
33433
33440
  additionalPrinterColumnsColWidths: preparedProps.additionalPrinterColumnsColWidths,
33434
33441
  selectData,
33435
- tableProps
33442
+ tableProps,
33443
+ withoutControls
33436
33444
  }
33437
33445
  );
33438
33446
  };
@@ -45242,6 +45250,133 @@ const SidebarProvider = ({
45242
45250
  return /* @__PURE__ */ jsxRuntimeExports.jsx(ManageableSidebarWithDataProvider, { replaceValues, ...props });
45243
45251
  };
45244
45252
 
45253
+ const ThemeContext = createContext("dark");
45254
+ const ThemeProvider = ({ theme, children }) => /* @__PURE__ */ jsxRuntimeExports.jsx(ThemeContext.Provider, { value: theme, children });
45255
+ const useTheme = () => {
45256
+ return useContext(ThemeContext);
45257
+ };
45258
+
45259
+ const parseMutliqueryText = ({ text, multiQueryData }) => {
45260
+ if (!text) return "";
45261
+ return text.replace(/\{reqs\[(\d+)\]\[((?:\s*['"][^'"]+['"]\s*,?)+)\]\}/g, (match, reqIndexStr, rawPath) => {
45262
+ try {
45263
+ const reqIndex = parseInt(reqIndexStr, 10);
45264
+ const path = Array.from(rawPath.matchAll(/['"]([^'"]+)['"]/g)).map(
45265
+ (m) => m[1]
45266
+ );
45267
+ const value = _$1.get(multiQueryData[`req${reqIndex}`], path);
45268
+ return value != null ? String(value) : "";
45269
+ } catch {
45270
+ return match;
45271
+ }
45272
+ });
45273
+ };
45274
+ const serializeLabels = (input) => {
45275
+ if (typeof input !== "object" || input === null || Array.isArray(input) || Object.getPrototypeOf(input) !== Object.prototype) {
45276
+ return "Expected a plain object";
45277
+ }
45278
+ const entries = Object.entries(input);
45279
+ if (!entries.map(([, v]) => v).every((v) => typeof v === "string" || typeof v === "number")) {
45280
+ return "All values must be string or number";
45281
+ }
45282
+ return encodeURIComponent(entries.map(([k, v]) => `${k}=${v}`).join(","));
45283
+ };
45284
+
45285
+ const EnrichedTable = ({
45286
+ data,
45287
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
45288
+ children
45289
+ }) => {
45290
+ const { data: multiQueryData } = useMultiQuery();
45291
+ const { id, fetchUrl, pathToItems, clusterNamePartOfUrl, labelsSelector, fieldSelector, ...props } = data;
45292
+ const theme = useTheme();
45293
+ const partsOfUrl = usePartsOfUrl();
45294
+ const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value, index) => {
45295
+ acc[index.toString()] = value;
45296
+ return acc;
45297
+ }, {});
45298
+ const clusterName = prepareTemplate({
45299
+ template: clusterNamePartOfUrl,
45300
+ replaceValues
45301
+ });
45302
+ const fetchUrlPrepared = prepareTemplate({
45303
+ template: fetchUrl,
45304
+ replaceValues
45305
+ });
45306
+ let labelsSuffix;
45307
+ if (labelsSelector) {
45308
+ const parsedObject = Object.fromEntries(
45309
+ Object.entries(labelsSelector).map(
45310
+ ([key, value]) => [key, prepareTemplate({ template: parseMutliqueryText({ text: value, multiQueryData }), replaceValues })]
45311
+ )
45312
+ );
45313
+ const serializedLabels = serializeLabels(parsedObject);
45314
+ labelsSuffix = serializeLabels.length > 0 ? `?labelSelector=${serializedLabels}` : void 0;
45315
+ }
45316
+ let fieldSelectorSuffix;
45317
+ if (fieldSelector) {
45318
+ const preparedFieldSelectorValueText = parseMutliqueryText({ text: fieldSelector?.parsedText, multiQueryData });
45319
+ const preparedFieldSelectorValueTextWithPartsOfUrl = prepareTemplate({
45320
+ template: preparedFieldSelectorValueText,
45321
+ replaceValues
45322
+ });
45323
+ const preparedSelector = encodeURIComponent(
45324
+ `${fieldSelector.fieldName}=${preparedFieldSelectorValueTextWithPartsOfUrl}`
45325
+ );
45326
+ const prefix = labelsSelector ? "&fieldSelector=" : "?fieldSelector=";
45327
+ fieldSelectorSuffix = `${prefix}${preparedSelector}`;
45328
+ }
45329
+ const {
45330
+ data: fetchedData,
45331
+ isLoading: isFetchedDataLoading,
45332
+ error: fetchedDataError
45333
+ } = useDirectUnknownResource({
45334
+ uri: `${fetchUrlPrepared}${labelsSuffix || ""}${fieldSelectorSuffix || ""}`,
45335
+ queryKey: [fetchUrlPrepared]
45336
+ });
45337
+ if (!fetchedData) {
45338
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "No data has been fetched" });
45339
+ }
45340
+ if (isFetchedDataLoading) {
45341
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." });
45342
+ }
45343
+ if (fetchedDataError) {
45344
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
45345
+ "Error: ",
45346
+ JSON.stringify(fetchedDataError)
45347
+ ] });
45348
+ }
45349
+ const items = _$1.get(fetchedData, pathToItems);
45350
+ if (!items) {
45351
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
45352
+ "No data on this path ",
45353
+ JSON.stringify(pathToItems)
45354
+ ] });
45355
+ }
45356
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
45357
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
45358
+ EnrichedTableProvider,
45359
+ {
45360
+ tableMappingsReplaceValues: replaceValues,
45361
+ cluster: clusterName,
45362
+ theme,
45363
+ dataItems: items,
45364
+ tableProps: {
45365
+ borderless: true,
45366
+ paginationPosition: ["bottomRight"],
45367
+ isTotalLeft: true,
45368
+ editIcon: /* @__PURE__ */ jsxRuntimeExports.jsx(EditIcon, {}),
45369
+ deleteIcon: /* @__PURE__ */ jsxRuntimeExports.jsx(DeleteIcon, {}),
45370
+ disablePagination: true
45371
+ },
45372
+ ...props,
45373
+ withoutControls: true
45374
+ }
45375
+ ),
45376
+ children
45377
+ ] });
45378
+ };
45379
+
45245
45380
  const DynamicComponents = {
45246
45381
  DefaultDiv,
45247
45382
  antdText: AntdText,
@@ -45259,7 +45394,8 @@ const DynamicComponents = {
45259
45394
  ContentCard,
45260
45395
  Spacer,
45261
45396
  StatusText,
45262
- SidebarProvider
45397
+ SidebarProvider,
45398
+ EnrichedTable
45263
45399
  };
45264
45400
 
45265
45401
  const prepareUrlsToFetchForDynamicRenderer = ({
@@ -45280,12 +45416,12 @@ const prepareUrlsToFetchForDynamicRenderer = ({
45280
45416
 
45281
45417
  const DynamicRendererWithProviders = (props) => {
45282
45418
  const location = useLocation();
45283
- const { urlsToFetch } = props;
45419
+ const { urlsToFetch, theme } = props;
45284
45420
  const preparedUrlsToFetch = prepareUrlsToFetchForDynamicRenderer({
45285
45421
  urls: urlsToFetch,
45286
45422
  locationPathname: location.pathname
45287
45423
  });
45288
- return /* @__PURE__ */ jsxRuntimeExports.jsx(PartsOfUrlProvider, { value: { partsOfUrl: location.pathname.split("/") }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(MultiQueryProvider, { urls: preparedUrlsToFetch, children: /* @__PURE__ */ jsxRuntimeExports.jsx(DynamicRenderer, { ...props }) }) });
45424
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(ThemeProvider, { theme, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PartsOfUrlProvider, { value: { partsOfUrl: location.pathname.split("/") }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(MultiQueryProvider, { urls: preparedUrlsToFetch, children: /* @__PURE__ */ jsxRuntimeExports.jsx(DynamicRenderer, { ...props }) }) }) });
45289
45425
  };
45290
45426
 
45291
45427
  const isLeafNode = (value) => {
@@ -45761,5 +45897,5 @@ const useCrdData = ({
45761
45897
  });
45762
45898
  };
45763
45899
 
45764
- export { BackToDefaultIcon, BlackholeForm, BlackholeFormDataProvider, ContentCard$1 as ContentCard, DeleteIcon, DeleteModal, DeleteModalMany, DownIcon, DynamicComponents, DynamicRenderer, DynamicRendererWithProviders, EditIcon, EnrichedTable, EnrichedTableProvider, LockedIcon, ManageableBreadcrumbs, ManageableBreadcrumbsWithDataProvider, ManageableSidebar, ManageableSidebarWithDataProvider, MarketPlace, MarketplaceCard$1 as MarketplaceCard, MinusIcon, PlusIcon, ProjectInfoCard$1 as ProjectInfoCard, Spacer$1 as Spacer, SuccessIcon, TreeWithSearch, UnlockedIcon, UpIcon, checkIfApiInstanceNamespaceScoped, checkIfBuiltInInstanceNamespaceScoped, checkPermission, createContextFactory, createNewEntry, deleteEntry, feedbackIcons, filterIfApiInstanceNamespaceScoped, filterIfBuiltInInstanceNamespaceScoped, filterSelectOptions, floorToDecimal, getAllPathsFromObj, getApiResourceSingle, getApiResourceTypes, getApiResourceTypesByApiGroup, getApiResources, getBuiltinResourceSingle, getBuiltinResourceTypes, getBuiltinResources, getBuiltinTreeData, getClusterList, getCrdData, getCrdResourceSingle, getCrdResources, getDirectUnknownResource, getEnrichedColumns, getEnrichedColumnsWithControls, getGroupsByCategory, getObjectFormItemsDraft, getPrefixSubarrays, getStringByName, getSwagger, groupsToTreeData, isFlatObject, normalizeValuesForQuotasToNumber, parseQuotaValue, parseQuotaValueCpu, parseQuotaValueMemoryAndStorage, prepareDataForManageableBreadcrumbs, prepareDataForManageableSidebar, prepareTemplate, prepareUrlsToFetchForDynamicRenderer, updateEntry, useApiResourceSingle, useApiResourceTypesByGroup, useApiResources, useApisResourceTypes, useBuiltinResourceSingle, useBuiltinResourceTypes, useBuiltinResources, useClusterList, useCrdData, useCrdResourceSingle, useCrdResources, useDirectUnknownResource, usePermissions };
45900
+ export { BackToDefaultIcon, BlackholeForm, BlackholeFormDataProvider, ContentCard$1 as ContentCard, DeleteIcon, DeleteModal, DeleteModalMany, DownIcon, DynamicComponents, DynamicRenderer, DynamicRendererWithProviders, EditIcon, EnrichedTable$1 as EnrichedTable, EnrichedTableProvider, LockedIcon, ManageableBreadcrumbs, ManageableBreadcrumbsWithDataProvider, ManageableSidebar, ManageableSidebarWithDataProvider, MarketPlace, MarketplaceCard$1 as MarketplaceCard, MinusIcon, PlusIcon, ProjectInfoCard$1 as ProjectInfoCard, Spacer$1 as Spacer, SuccessIcon, TreeWithSearch, UnlockedIcon, UpIcon, checkIfApiInstanceNamespaceScoped, checkIfBuiltInInstanceNamespaceScoped, checkPermission, createContextFactory, createNewEntry, deleteEntry, feedbackIcons, filterIfApiInstanceNamespaceScoped, filterIfBuiltInInstanceNamespaceScoped, filterSelectOptions, floorToDecimal, getAllPathsFromObj, getApiResourceSingle, getApiResourceTypes, getApiResourceTypesByApiGroup, getApiResources, getBuiltinResourceSingle, getBuiltinResourceTypes, getBuiltinResources, getBuiltinTreeData, getClusterList, getCrdData, getCrdResourceSingle, getCrdResources, getDirectUnknownResource, getEnrichedColumns, getEnrichedColumnsWithControls, getGroupsByCategory, getObjectFormItemsDraft, getPrefixSubarrays, getStringByName, getSwagger, groupsToTreeData, isFlatObject, normalizeValuesForQuotasToNumber, parseQuotaValue, parseQuotaValueCpu, parseQuotaValueMemoryAndStorage, prepareDataForManageableBreadcrumbs, prepareDataForManageableSidebar, prepareTemplate, prepareUrlsToFetchForDynamicRenderer, updateEntry, useApiResourceSingle, useApiResourceTypesByGroup, useApiResources, useApisResourceTypes, useBuiltinResourceSingle, useBuiltinResourceTypes, useBuiltinResources, useClusterList, useCrdData, useCrdResourceSingle, useCrdResources, useDirectUnknownResource, usePermissions };
45765
45901
  //# sourceMappingURL=openapi-k8s-toolkit.es.js.map