@dovetail-v2/refine 0.0.44 → 0.0.45-bowen.1

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,4 +1,4 @@
1
- import { j as jsxRuntimeExports } from "./index-72d47bc9.js";
1
+ import { j as jsxRuntimeExports } from "./index-ad1e8a1c.js";
2
2
  import * as monaco from "monaco-editor";
3
3
  import { useRef, useEffect } from "react";
4
4
  import "i18next";
@@ -10,7 +10,7 @@ import React__default, { createElement, isValidElement, cloneElement, Children,
10
10
  import { ResourceContext, matchResourceFromRoute, useResource, useDelete, useNavigation, useBreadcrumb, useList, useParsed, useGo, useDeleteMany, CanAccess, useCan, useShow, useUpdate, useDataProvider, useRefineContext, useTranslate, useWarnAboutChange, useForm as useForm$2, flattenObjectKeys, pickNotDeprecated, useMenu, useTable, Refine } from "@refinedev/core";
11
11
  import { parse, stringify } from "qs";
12
12
  import { useLocation, useHistory, useParams, matchPath, Link, Route, NavLink, Router } from "react-router-dom";
13
- import { Typo, Tag, useUIKit, kitContext, Link as Link$1, OverflowTooltip, Tooltip, StatusCapsule, pushModal, Button, Icon as Icon$1, popModal, Loading, Divider, Fields, Form, Space, Modal, useMessage, ModalStack, KitStoreProvider } from "@cloudtower/eagle";
13
+ import { Typo, Tag, useUIKit, kitContext, Link as Link$1, OverflowTooltip, Tooltip, StatusCapsule, pushModal, Button, Icon as Icon$1, popModal, Loading, Divider, Fields, Space, Form, Modal, useMessage, ModalStack, KitStoreProvider } from "@cloudtower/eagle";
14
14
  import { PlusAddCreateNew16BoldOntintIcon, EditPen16PrimaryIcon, Download16GradientBlueIcon, TrashBinDelete16Icon, MoreEllipsis324BoldSecondaryIcon, MoreEllipsis324BoldBlueIcon, MoreEllipsis316BoldBlueIcon, ArrowChevronLeft16BoldTertiaryIcon, ArrowChevronLeftSmall16BoldBlueIcon, EditPen16GradientBlueIcon, ViewEye16GradientGrayIcon, EntityFilterIgnoreGradient16GrayIcon, RecoverContinue16GradientBlueIcon, SuspendedPause16GradientBlueIcon, Retry16GradientBlueIcon, HierarchyTriangleRight16GrayIcon, HierarchyTriangleRight16BlueIcon, ClipboardCopy16GradientGrayIcon, ClipboardCopy16GradientBlueIcon, Retry16GradientGrayIcon, EditPen16GradientGrayIcon, Showdiff16GradientGrayIcon, Showdiff16GradientBlueIcon, XmarkFailedSeriousWarningFill16RedIcon, ExclamationErrorCircleFill16RedIcon, Pause16GradientBlueIcon } from "@cloudtower/icons-react";
15
15
  import { get as get$3, first, debounce, last, isObject as isObject$4, merge, keyBy } from "lodash-es";
16
16
  import yaml from "js-yaml";
@@ -9953,7 +9953,7 @@ const ServiceOutClusterAccessComponent = ({
9953
9953
  children: content || "-"
9954
9954
  });
9955
9955
  };
9956
- const index_1wlqq0y = "";
9956
+ const index_10ylmu3 = "";
9957
9957
  const TagWrapper = "t13a6vox";
9958
9958
  const TagStyle = "t12ikbmp";
9959
9959
  const Tags = (props) => {
@@ -9992,23 +9992,24 @@ const StateTag = ({
9992
9992
  const {
9993
9993
  t: t2
9994
9994
  } = useTranslation();
9995
- const colorMap = {
9996
- updating: "blue",
9995
+ const statusMap = {
9996
+ updating: "loading",
9997
9997
  ready: "green",
9998
9998
  completed: "gray",
9999
9999
  failed: "red",
10000
10000
  suspended: "warning",
10001
- running: "blue",
10002
- succeeded: "green",
10003
- unknown: "warning",
10004
- terminating: "red",
10005
- pending: "gray",
10001
+ running: "green",
10002
+ succeeded: "blue",
10003
+ unknown: "gray",
10004
+ terminating: "loading",
10005
+ pending: "warning",
10006
10006
  waiting: "warning",
10007
10007
  terminated: "red"
10008
10008
  };
10009
10009
  return /* @__PURE__ */ jsxRuntimeExports.jsx(kit.statusCapsule, {
10010
10010
  className: cx_default(className, StateTagStyle, hideBackground && "no-background"),
10011
- color: colorMap[state2],
10011
+ color: statusMap[state2] !== "loading" ? statusMap[state2] : void 0,
10012
+ loading: statusMap[state2] === "loading",
10012
10013
  children: t2(`dovetail.${state2 || "updating"}`)
10013
10014
  });
10014
10015
  };
@@ -10683,7 +10684,7 @@ const IngressRulesTable = ({ ingress }) => {
10683
10684
  }
10684
10685
  );
10685
10686
  };
10686
- const KeyValue_1v1utgj = "";
10687
+ const KeyValue_q4vd5r = "";
10687
10688
  const ContentBlockStyle = "c8jy7dc";
10688
10689
  const KeyStyle = "k2sddxl";
10689
10690
  const ValueStyle$2 = "v16vicsr";
@@ -18314,7 +18315,7 @@ function parseJSON(value2) {
18314
18315
  }
18315
18316
  }
18316
18317
  const GlobalStoreContext = createContext({});
18317
- const index_1uuzt53 = "";
18318
+ const index_1xad2h9 = "";
18318
18319
  const SelectStyle = "sj0ggy";
18319
18320
  const DropdownStyle = "d1eo8uqs";
18320
18321
  const SearchInputStyle = "s64gojc";
@@ -18350,6 +18351,7 @@ const NamespacesFilter = ({
18350
18351
  t: t2
18351
18352
  } = useTranslation();
18352
18353
  const [search, setSearch] = useState("");
18354
+ const [tagMaxWidth, setTagMaxWidth] = useState("");
18353
18355
  const {
18354
18356
  data: data2,
18355
18357
  isLoading
@@ -18364,91 +18366,144 @@ const NamespacesFilter = ({
18364
18366
  }
18365
18367
  });
18366
18368
  const [value2, setValue] = useLocalStorage(NS_STORE_KEY, [ALL_NS]);
18369
+ const [open, setOpen] = useState(false);
18367
18370
  const debouncedSetSearch = debounce(setSearch, 100);
18368
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(kit.select, {
18369
- loading: isLoading,
18370
- style: {
18371
- width: 278
18372
- },
18373
- className: cx_default(SelectStyle, className),
18374
- dropdownClassName: DropdownStyle,
18375
- searchValue: search,
18376
- virtual: false,
18377
- input: {
18378
- value: value2,
18379
- onChange(value22) {
18380
- if (last(value22) === ALL_NS || value22.length === 0) {
18381
- setValue([ALL_NS]);
18382
- } else {
18383
- setValue(value22.filter((namespace2) => namespace2 !== ALL_NS));
18371
+ const MAX_TAG_COUNT = 8;
18372
+ const COUNT_TAG_WIDTH = 22;
18373
+ const TAG_GAP = 4;
18374
+ const PADDING = 36;
18375
+ const hasCountTag = value2.length > MAX_TAG_COUNT;
18376
+ const WRAPPER_CLASS = "d2-namespace-select-wrapper";
18377
+ const SELECT_CLASS = "d2-namespace-select";
18378
+ const calcTagMaxWidth = useCallback(() => {
18379
+ const wrapper = document.querySelector(`.${WRAPPER_CLASS}`);
18380
+ const n2 = Math.min(value2.length, MAX_TAG_COUNT);
18381
+ const tagWidth = ((wrapper == null ? void 0 : wrapper.offsetWidth) || 0) / n2;
18382
+ const gapsWidth = (Math.min(value2.length, MAX_TAG_COUNT + 1) - 1) * TAG_GAP;
18383
+ const paddingAndCountTagWidth = PADDING + (hasCountTag ? COUNT_TAG_WIDTH : 0);
18384
+ const perTagMaxWidth = tagWidth - (paddingAndCountTagWidth + gapsWidth) / n2;
18385
+ setTagMaxWidth(`${perTagMaxWidth}px`);
18386
+ }, [value2, hasCountTag]);
18387
+ useEffect(() => {
18388
+ calcTagMaxWidth();
18389
+ }, [calcTagMaxWidth]);
18390
+ useEffect(() => {
18391
+ window.addEventListener("resize", calcTagMaxWidth);
18392
+ return () => {
18393
+ window.removeEventListener("resize", calcTagMaxWidth);
18394
+ };
18395
+ }, [calcTagMaxWidth]);
18396
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
18397
+ className: WRAPPER_CLASS,
18398
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs(kit.select, {
18399
+ loading: isLoading,
18400
+ className: cx_default(SelectStyle, SELECT_CLASS, className),
18401
+ style: {
18402
+ "--tag-max-width": tagMaxWidth
18403
+ },
18404
+ dropdownClassName: DropdownStyle,
18405
+ searchValue: search,
18406
+ virtual: false,
18407
+ input: {
18408
+ value: value2,
18409
+ onChange(value22) {
18410
+ if (last(value22) === ALL_NS || value22.length === 0) {
18411
+ setValue([ALL_NS]);
18412
+ } else {
18413
+ setValue(value22.filter((namespace2) => namespace2 !== ALL_NS));
18414
+ }
18384
18415
  }
18385
- }
18386
- },
18387
- dropdownRender: (menu) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
18388
- className: SelectContentStyle,
18389
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx(kit.searchInput, {
18390
- style: {
18391
- width: "100%"
18392
- },
18393
- className: SearchInputStyle,
18394
- onChange: debouncedSetSearch,
18395
- placeholder: t2("dovetail.please_input")
18396
- }), menu, isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(kit.loading, {}) : null]
18397
- }),
18398
- tagRender: ({
18399
- label: label2,
18400
- value: value22,
18401
- closable,
18402
- onClose
18403
- }) => {
18404
- const isCountToken = label2 !== value22 && typeof label2 === "string";
18405
- const isAll = value22 === ALL_NS;
18406
- return isAll ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
18407
- style: {
18408
- marginLeft: 8
18409
- },
18410
- children: label2
18411
- }) : /* @__PURE__ */ jsxRuntimeExports.jsx(kit.token, {
18412
- className: cx_default(isCountToken ? CountTokenStyle : TokenStyle, isCountToken ? "" : "closable-token"),
18416
+ },
18417
+ dropdownRender: (menu) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
18418
+ className: SelectContentStyle,
18419
+ children: [/* @__PURE__ */ jsxRuntimeExports.jsx(kit.searchInput, {
18420
+ style: {
18421
+ width: "100%"
18422
+ },
18423
+ className: SearchInputStyle,
18424
+ onChange: debouncedSetSearch,
18425
+ placeholder: t2("dovetail.please_input")
18426
+ }), menu, isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(kit.loading, {}) : null]
18427
+ }),
18428
+ tagRender: ({
18429
+ label: label2,
18430
+ value: namespaceValue,
18413
18431
  closable,
18414
- size: "medium",
18415
- onClose,
18432
+ onClose
18433
+ }) => {
18434
+ const isCountToken = label2 !== namespaceValue && typeof label2 === "string";
18435
+ const isAll = namespaceValue === ALL_NS;
18436
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
18437
+ onClick: () => {
18438
+ setOpen(!open);
18439
+ },
18440
+ children: isAll ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", {
18441
+ style: {
18442
+ marginLeft: 8
18443
+ },
18444
+ children: [label2, "..."]
18445
+ }) : /* @__PURE__ */ jsxRuntimeExports.jsx(kit.token, {
18446
+ className: cx_default(isCountToken ? CountTokenStyle : TokenStyle, isCountToken ? "" : "closable-token"),
18447
+ closable,
18448
+ size: "medium",
18449
+ onClose,
18450
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18451
+ content: isCountToken ? /* @__PURE__ */ jsxRuntimeExports.jsx(kit.tooltip, {
18452
+ title: isCountToken ? value2.slice(MAX_TAG_COUNT).map((namespace2, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
18453
+ children: [/* @__PURE__ */ jsxRuntimeExports.jsx("div", {
18454
+ children: namespace2
18455
+ }), index !== value2.length - 1 - MAX_TAG_COUNT ? /* @__PURE__ */ jsxRuntimeExports.jsx(kit.divider, {
18456
+ style: {
18457
+ margin: "6px 0",
18458
+ borderColor: "rgba(107, 128, 167, 0.60)"
18459
+ }
18460
+ }) : null]
18461
+ })) : null,
18462
+ trigger: ["hover"],
18463
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
18464
+ children: label2.replace(/[\s\.]/g, "")
18465
+ })
18466
+ }) : label2
18467
+ })
18468
+ })
18469
+ });
18470
+ },
18471
+ maxTagCount: MAX_TAG_COUNT,
18472
+ optionLabelProp: "label",
18473
+ showArrow: true,
18474
+ showSearch: false,
18475
+ open,
18476
+ onDropdownVisibleChange: (open2) => {
18477
+ setOpen(open2);
18478
+ },
18479
+ multiple: true,
18480
+ children: [/* @__PURE__ */ jsxRuntimeExports.jsx(kit.option, {
18481
+ value: "_all",
18482
+ label: t2("dovetail.all_namespaces"),
18483
+ className: AllNamespaceOptionStyle,
18416
18484
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18417
- content: isCountToken ? label2.replace(/[\s\.]/g, "") : label2
18485
+ content: t2("dovetail.all_namespaces"),
18486
+ className: LabelWrapperStyle
18418
18487
  })
18419
- });
18420
- },
18421
- maxTagCount: 1,
18422
- optionLabelProp: "label",
18423
- showArrow: true,
18424
- showSearch: false,
18425
- multiple: true,
18426
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx(kit.option, {
18427
- value: "_all",
18428
- label: t2("dovetail.all_namespaces"),
18429
- className: AllNamespaceOptionStyle,
18430
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18431
- content: t2("dovetail.all_namespaces"),
18432
- className: LabelWrapperStyle
18433
- })
18434
- }, "_all"), /* @__PURE__ */ jsxRuntimeExports.jsx(kit.selectOptGroup, {
18435
- label: "",
18436
- className: SelectOptionGroupStyle,
18437
- children: data2 == null ? void 0 : data2.data.map((namespace2) => {
18438
- const {
18439
- name: name2
18440
- } = namespace2.metadata;
18441
- return /* @__PURE__ */ jsxRuntimeExports.jsx(kit.option, {
18442
- value: name2,
18443
- label: name2,
18444
- className: OptionStyle,
18445
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18446
- content: name2,
18447
- className: LabelWrapperStyle
18448
- })
18449
- }, name2);
18450
- })
18451
- })]
18488
+ }, "_all"), /* @__PURE__ */ jsxRuntimeExports.jsx(kit.selectOptGroup, {
18489
+ label: "",
18490
+ className: SelectOptionGroupStyle,
18491
+ children: data2 == null ? void 0 : data2.data.map((namespace2) => {
18492
+ const {
18493
+ name: name2
18494
+ } = namespace2.metadata;
18495
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(kit.option, {
18496
+ value: name2,
18497
+ label: name2,
18498
+ className: OptionStyle,
18499
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18500
+ content: name2,
18501
+ className: LabelWrapperStyle
18502
+ })
18503
+ }, name2);
18504
+ })
18505
+ })]
18506
+ })
18452
18507
  });
18453
18508
  };
18454
18509
  const index_hp158y = "";
@@ -21724,20 +21779,44 @@ function useForm$1(props = {}) {
21724
21779
  _formControl.current.formState = getProxyFormState(formState, control);
21725
21780
  return _formControl.current;
21726
21781
  }
21727
- const RefineFormContent_1in3vad = "";
21782
+ const RefineFormContent_1tb00bi = "";
21728
21783
  const RefineFormContent = (props) => {
21729
- var _a, _b;
21784
+ var _a, _b, _c, _d;
21730
21785
  const {
21731
21786
  config,
21732
21787
  formResult,
21733
- action,
21788
+ resourceId,
21734
21789
  errorMsg
21735
21790
  } = props;
21736
21791
  const {
21737
21792
  control,
21738
21793
  getValues
21739
21794
  } = formResult;
21740
- const fields = (_b = (_a = config == null ? void 0 : config.formConfig) == null ? void 0 : _a.fields) == null ? void 0 : _b.map((c2) => {
21795
+ const action = resourceId ? "edit" : "create";
21796
+ const listQuery = useList({
21797
+ resource: config == null ? void 0 : config.name,
21798
+ meta: {
21799
+ resourceBasePath: config == null ? void 0 : config.basePath,
21800
+ kind: config == null ? void 0 : config.kind
21801
+ },
21802
+ pagination: {
21803
+ mode: "off"
21804
+ }
21805
+ });
21806
+ const showQuery = useShow({
21807
+ resource: config == null ? void 0 : config.name,
21808
+ meta: {
21809
+ resourceBasePath: config == null ? void 0 : config.basePath,
21810
+ kind: config == null ? void 0 : config.kind
21811
+ },
21812
+ id: resourceId
21813
+ });
21814
+ const formFieldsConfig = (_d = (_a = config == null ? void 0 : config.formConfig) == null ? void 0 : _a.fields) == null ? void 0 : _d.call(_a, {
21815
+ record: (_b = showQuery.queryResult.data) == null ? void 0 : _b.data,
21816
+ records: ((_c = listQuery.data) == null ? void 0 : _c.data) || [],
21817
+ action
21818
+ });
21819
+ const fields = formFieldsConfig == null ? void 0 : formFieldsConfig.map((c2) => {
21741
21820
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Controller, {
21742
21821
  control,
21743
21822
  name: c2.path.join("."),
@@ -21769,6 +21848,7 @@ const RefineFormContent = (props) => {
21769
21848
  var _a2;
21770
21849
  const formValue = getValues();
21771
21850
  let ele = /* @__PURE__ */ jsxRuntimeExports.jsx(Fields.String, {
21851
+ placeholder: c2.placeholder,
21772
21852
  input: {
21773
21853
  value: value2,
21774
21854
  onChange,
@@ -21796,6 +21876,17 @@ const RefineFormContent = (props) => {
21796
21876
  children: value2
21797
21877
  });
21798
21878
  }
21879
+ if (c2.helperText) {
21880
+ ele = /* @__PURE__ */ jsxRuntimeExports.jsxs(Space, {
21881
+ size: 4,
21882
+ direction: "vertical",
21883
+ className: "c154n7ie",
21884
+ children: [c2, /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
21885
+ className: cx_default(Typo.Footnote.f2_regular, "c1c9j4da"),
21886
+ children: c2.helperText
21887
+ })]
21888
+ });
21889
+ }
21799
21890
  if (c2 == null ? void 0 : c2.render) {
21800
21891
  ele = c2.render(value2, onChange, formValue, onBlur, action);
21801
21892
  }
@@ -21813,7 +21904,7 @@ const RefineFormContent = (props) => {
21813
21904
  });
21814
21905
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Space, {
21815
21906
  direction: "vertical",
21816
- className: "c154n7ie",
21907
+ className: "cjxv8cf",
21817
21908
  children: [fields, /* @__PURE__ */ jsxRuntimeExports.jsx(FormErrorAlert, {
21818
21909
  errorMsgs: errorMsg ? [errorMsg] : [],
21819
21910
  style: {
@@ -22453,7 +22544,6 @@ const useForm = ({
22453
22544
  };
22454
22545
  };
22455
22546
  const useRefineForm = (props) => {
22456
- var _a;
22457
22547
  const { config, id, refineProps } = props;
22458
22548
  const [responseErrorMsg, setResponseErrorMsg] = useState("");
22459
22549
  const i18n2 = useTranslation();
@@ -22486,15 +22576,15 @@ const useRefineForm = (props) => {
22486
22576
  defaultValues: config == null ? void 0 : config.initValue
22487
22577
  });
22488
22578
  useEffect(() => {
22489
- var _a2, _b;
22490
- const response = (_a2 = result.refineCore.mutationResult.error) == null ? void 0 : _a2.response;
22579
+ var _a, _b;
22580
+ const response = (_a = result.refineCore.mutationResult.error) == null ? void 0 : _a.response;
22491
22581
  if (response && !(response == null ? void 0 : response.bodyUsed)) {
22492
22582
  (_b = response.json) == null ? void 0 : _b.call(response).then((body) => {
22493
- var _a3, _b2;
22494
- setResponseErrorMsg(((_b2 = (_a3 = config.formConfig) == null ? void 0 : _a3.formatError) == null ? void 0 : _b2.call(_a3, body)) || body.message);
22583
+ var _a2, _b2;
22584
+ setResponseErrorMsg(((_b2 = (_a2 = config.formConfig) == null ? void 0 : _a2.formatError) == null ? void 0 : _b2.call(_a2, body)) || body.message);
22495
22585
  });
22496
22586
  }
22497
- }, [config.formConfig, (_a = result.refineCore.mutationResult.error) == null ? void 0 : _a.response]);
22587
+ }, [config.formConfig, result]);
22498
22588
  return { formResult: result, responseErrorMsg };
22499
22589
  };
22500
22590
  const index_12sfrn = "";
@@ -22505,7 +22595,7 @@ const Separator = () => {
22505
22595
  });
22506
22596
  };
22507
22597
  const MonacoYamlEditor = React__default.lazy(() => Promise.resolve().then(() => MonacoYamlEditor$2));
22508
- const MonacoYamlDiffEditor = React__default.lazy(() => import("./MonacoYamlDiffEditor-71c3ccc4.js"));
22598
+ const MonacoYamlDiffEditor = React__default.lazy(() => import("./MonacoYamlDiffEditor-481880fe.js"));
22509
22599
  const YamlEditorComponent = forwardRef(
22510
22600
  function YamlEditorComponent2(props, ref) {
22511
22601
  const {
@@ -23020,9 +23110,18 @@ const useYamlForm = ({
23020
23110
  setEditorErrors(errors);
23021
23111
  return;
23022
23112
  }
23023
- const objectValues = editor.current ? yaml.load(((_a2 = editor.current) == null ? void 0 : _a2.getEditorValue()) || "") : values;
23024
- const finalValues = (transformApplyValues == null ? void 0 : transformApplyValues(objectValues)) || objectValues;
23025
- return onFinish(finalValues);
23113
+ try {
23114
+ const objectValues = editor.current ? yaml.load(((_a2 = editor.current) == null ? void 0 : _a2.getEditorValue()) || "") : values;
23115
+ const finalValues = (transformApplyValues == null ? void 0 : transformApplyValues(objectValues)) || objectValues;
23116
+ return onFinish(finalValues);
23117
+ } catch (error) {
23118
+ if (error instanceof Error) {
23119
+ if (error.message === "expected a single document in the stream, but found more") {
23120
+ setEditorErrors([t2("dovetail.only_support_one_yaml")]);
23121
+ return;
23122
+ }
23123
+ }
23124
+ }
23026
23125
  },
23027
23126
  onKeyUp,
23028
23127
  onValuesChange,
@@ -23244,7 +23343,7 @@ function FormModal(props) {
23244
23343
  formResult: refineFormResult.formResult,
23245
23344
  config,
23246
23345
  errorMsg: refineFormResult.responseErrorMsg,
23247
- action: id ? "edit" : "create"
23346
+ resourceId: id
23248
23347
  });
23249
23348
  })();
23250
23349
  const saveButtonProps = isYamlForm ? yamlSaveButtonProps : refineFormResult.formResult.saveButtonProps;
@@ -23327,7 +23426,7 @@ const RefineFormPage = (props) => {
23327
23426
  children: [/* @__PURE__ */ jsxRuntimeExports.jsx(RefineFormContent, {
23328
23427
  config,
23329
23428
  formResult,
23330
- action
23429
+ resourceId: id
23331
23430
  }), ";", /* @__PURE__ */ jsxRuntimeExports.jsx(Button, {
23332
23431
  ...saveButtonProps,
23333
23432
  onClick,
@@ -23728,7 +23827,11 @@ const PlainTextNameColumnRenderer = (i18n2) => {
23728
23827
  title: i18n2.t("dovetail.name"),
23729
23828
  sortable: true,
23730
23829
  width: 200,
23731
- sorter: CommonSorter(dataIndex)
23830
+ sorter: CommonSorter(dataIndex),
23831
+ render: (v) => /* @__PURE__ */ jsxRuntimeExports.jsx(OverflowTooltip, {
23832
+ content: v,
23833
+ tooltip: v
23834
+ })
23732
23835
  };
23733
23836
  };
23734
23837
  const NameSpaceColumnRenderer = (i18n2) => {
@@ -24168,7 +24271,7 @@ const PortMappingColumnRenderer = (i18n2) => {
24168
24271
  href: `//${v.servicePort}`,
24169
24272
  target: "_blank",
24170
24273
  children: v.servicePort
24171
- }) : v.servicePort, " > ", v.targetPort, "/", v.protocol]
24274
+ }) : v.servicePort, " ", "> ", v.targetPort, "/", v.protocol]
24172
24275
  }),
24173
24276
  tooltip: `${v.servicePort} > ${v.targetPort}/${v.protocol}`
24174
24277
  }, v.servicePort));
package/dist/refine.js CHANGED
@@ -1,4 +1,4 @@
1
- import { b6, bK, A, az, aB, aj, bm, aJ, G, bA, bo, at, w, C, g, bO, am, aN, Y, bQ, a0, a7, bZ, ab, bp, bn, c0, ap, aT, t, ah, aY, b$, bL, b0, D, aG, b2, b_, aH, ax, b9, bN, bP, by, ak, a1, p, o, bR, I, aQ, aw, q, bq, bT, ao, aP, ac, ad, T, ae, aA, ai, aZ, b1, U, M, bz, b5, N, H, b, ay, O, b8, aV, aU, bS, bk, e, bs, V, P, aL, s, Z, bj, aI, bX, bW, aE, aR, n, an, aK, v, aS, aF, c4, bM, b3, ba, bb, al, R, $, a5, a4, b4, a2, bY, a3, a8, f, bF, bI, bE, bD, bG, bH, bB, bt, bw, bx, bv, bu, br, bc, aq, aO, af, k, bf, i, aC, c3, m, bg, aD, l, av, aM, h, c2, as, au, aX, aW, ar, S, a$, a_, c1, bC, bl, bh, bi, X, bV, _, W, bU, a6, aa, a9, c, bJ, ag, bd, x, J, d, Q, L, K, r, a, z, y, B, E, b7, F, be, u } from "./index-72d47bc9.js";
1
+ import { b6, bK, A, az, aB, aj, bm, aJ, G, bA, bo, at, w, C, g, bO, am, aN, Y, bQ, a0, a7, bZ, ab, bp, bn, c0, ap, aT, t, ah, aY, b$, bL, b0, D, aG, b2, b_, aH, ax, b9, bN, bP, by, ak, a1, p, o, bR, I, aQ, aw, q, bq, bT, ao, aP, ac, ad, T, ae, aA, ai, aZ, b1, U, M, bz, b5, N, H, b, ay, O, b8, aV, aU, bS, bk, e, bs, V, P, aL, s, Z, bj, aI, bX, bW, aE, aR, n, an, aK, v, aS, aF, c4, bM, b3, ba, bb, al, R, $, a5, a4, b4, a2, bY, a3, a8, f, bF, bI, bE, bD, bG, bH, bB, bt, bw, bx, bv, bu, br, bc, aq, aO, af, k, bf, i, aC, c3, m, bg, aD, l, av, aM, h, c2, as, au, aX, aW, ar, S, a$, a_, c1, bC, bl, bh, bi, X, bV, _, W, bU, a6, aa, a9, c, bJ, ag, bd, x, J, d, Q, L, K, r, a, z, y, B, E, b7, F, be, u } from "./index-ad1e8a1c.js";
2
2
  import "@cloudtower/eagle";
3
3
  import "@refinedev/core";
4
4
  import "@cloudtower/icons-react";
@@ -9959,7 +9959,7 @@ var __publicField = (obj, key, value) => {
9959
9959
  children: content || "-"
9960
9960
  });
9961
9961
  };
9962
- const index_1wlqq0y = "";
9962
+ const index_10ylmu3 = "";
9963
9963
  const TagWrapper = "t13a6vox";
9964
9964
  const TagStyle = "t12ikbmp";
9965
9965
  const Tags = (props) => {
@@ -9998,23 +9998,24 @@ var __publicField = (obj, key, value) => {
9998
9998
  const {
9999
9999
  t: t2
10000
10000
  } = useTranslation();
10001
- const colorMap = {
10002
- updating: "blue",
10001
+ const statusMap = {
10002
+ updating: "loading",
10003
10003
  ready: "green",
10004
10004
  completed: "gray",
10005
10005
  failed: "red",
10006
10006
  suspended: "warning",
10007
- running: "blue",
10008
- succeeded: "green",
10009
- unknown: "warning",
10010
- terminating: "red",
10011
- pending: "gray",
10007
+ running: "green",
10008
+ succeeded: "blue",
10009
+ unknown: "gray",
10010
+ terminating: "loading",
10011
+ pending: "warning",
10012
10012
  waiting: "warning",
10013
10013
  terminated: "red"
10014
10014
  };
10015
10015
  return /* @__PURE__ */ jsxRuntimeExports.jsx(kit.statusCapsule, {
10016
10016
  className: cx_default(className, StateTagStyle, hideBackground && "no-background"),
10017
- color: colorMap[state2],
10017
+ color: statusMap[state2] !== "loading" ? statusMap[state2] : void 0,
10018
+ loading: statusMap[state2] === "loading",
10018
10019
  children: t2(`dovetail.${state2 || "updating"}`)
10019
10020
  });
10020
10021
  };
@@ -10689,7 +10690,7 @@ var __publicField = (obj, key, value) => {
10689
10690
  }
10690
10691
  );
10691
10692
  };
10692
- const KeyValue_1v1utgj = "";
10693
+ const KeyValue_q4vd5r = "";
10693
10694
  const ContentBlockStyle = "c8jy7dc";
10694
10695
  const KeyStyle = "k2sddxl";
10695
10696
  const ValueStyle$2 = "v16vicsr";
@@ -18320,7 +18321,7 @@ var __publicField = (obj, key, value) => {
18320
18321
  }
18321
18322
  }
18322
18323
  const GlobalStoreContext = React.createContext({});
18323
- const index_1uuzt53 = "";
18324
+ const index_1xad2h9 = "";
18324
18325
  const SelectStyle = "sj0ggy";
18325
18326
  const DropdownStyle = "d1eo8uqs";
18326
18327
  const SearchInputStyle = "s64gojc";
@@ -18356,6 +18357,7 @@ var __publicField = (obj, key, value) => {
18356
18357
  t: t2
18357
18358
  } = useTranslation();
18358
18359
  const [search, setSearch] = React.useState("");
18360
+ const [tagMaxWidth, setTagMaxWidth] = React.useState("");
18359
18361
  const {
18360
18362
  data: data2,
18361
18363
  isLoading
@@ -18370,91 +18372,144 @@ var __publicField = (obj, key, value) => {
18370
18372
  }
18371
18373
  });
18372
18374
  const [value2, setValue] = useLocalStorage(NS_STORE_KEY, [ALL_NS]);
18375
+ const [open, setOpen] = React.useState(false);
18373
18376
  const debouncedSetSearch = lodashEs.debounce(setSearch, 100);
18374
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(kit.select, {
18375
- loading: isLoading,
18376
- style: {
18377
- width: 278
18378
- },
18379
- className: cx_default(SelectStyle, className),
18380
- dropdownClassName: DropdownStyle,
18381
- searchValue: search,
18382
- virtual: false,
18383
- input: {
18384
- value: value2,
18385
- onChange(value22) {
18386
- if (lodashEs.last(value22) === ALL_NS || value22.length === 0) {
18387
- setValue([ALL_NS]);
18388
- } else {
18389
- setValue(value22.filter((namespace2) => namespace2 !== ALL_NS));
18377
+ const MAX_TAG_COUNT = 8;
18378
+ const COUNT_TAG_WIDTH = 22;
18379
+ const TAG_GAP = 4;
18380
+ const PADDING = 36;
18381
+ const hasCountTag = value2.length > MAX_TAG_COUNT;
18382
+ const WRAPPER_CLASS = "d2-namespace-select-wrapper";
18383
+ const SELECT_CLASS = "d2-namespace-select";
18384
+ const calcTagMaxWidth = React.useCallback(() => {
18385
+ const wrapper = document.querySelector(`.${WRAPPER_CLASS}`);
18386
+ const n2 = Math.min(value2.length, MAX_TAG_COUNT);
18387
+ const tagWidth = ((wrapper == null ? void 0 : wrapper.offsetWidth) || 0) / n2;
18388
+ const gapsWidth = (Math.min(value2.length, MAX_TAG_COUNT + 1) - 1) * TAG_GAP;
18389
+ const paddingAndCountTagWidth = PADDING + (hasCountTag ? COUNT_TAG_WIDTH : 0);
18390
+ const perTagMaxWidth = tagWidth - (paddingAndCountTagWidth + gapsWidth) / n2;
18391
+ setTagMaxWidth(`${perTagMaxWidth}px`);
18392
+ }, [value2, hasCountTag]);
18393
+ React.useEffect(() => {
18394
+ calcTagMaxWidth();
18395
+ }, [calcTagMaxWidth]);
18396
+ React.useEffect(() => {
18397
+ window.addEventListener("resize", calcTagMaxWidth);
18398
+ return () => {
18399
+ window.removeEventListener("resize", calcTagMaxWidth);
18400
+ };
18401
+ }, [calcTagMaxWidth]);
18402
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
18403
+ className: WRAPPER_CLASS,
18404
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs(kit.select, {
18405
+ loading: isLoading,
18406
+ className: cx_default(SelectStyle, SELECT_CLASS, className),
18407
+ style: {
18408
+ "--tag-max-width": tagMaxWidth
18409
+ },
18410
+ dropdownClassName: DropdownStyle,
18411
+ searchValue: search,
18412
+ virtual: false,
18413
+ input: {
18414
+ value: value2,
18415
+ onChange(value22) {
18416
+ if (lodashEs.last(value22) === ALL_NS || value22.length === 0) {
18417
+ setValue([ALL_NS]);
18418
+ } else {
18419
+ setValue(value22.filter((namespace2) => namespace2 !== ALL_NS));
18420
+ }
18390
18421
  }
18391
- }
18392
- },
18393
- dropdownRender: (menu) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
18394
- className: SelectContentStyle,
18395
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx(kit.searchInput, {
18396
- style: {
18397
- width: "100%"
18398
- },
18399
- className: SearchInputStyle,
18400
- onChange: debouncedSetSearch,
18401
- placeholder: t2("dovetail.please_input")
18402
- }), menu, isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(kit.loading, {}) : null]
18403
- }),
18404
- tagRender: ({
18405
- label: label2,
18406
- value: value22,
18407
- closable,
18408
- onClose
18409
- }) => {
18410
- const isCountToken = label2 !== value22 && typeof label2 === "string";
18411
- const isAll = value22 === ALL_NS;
18412
- return isAll ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
18413
- style: {
18414
- marginLeft: 8
18415
- },
18416
- children: label2
18417
- }) : /* @__PURE__ */ jsxRuntimeExports.jsx(kit.token, {
18418
- className: cx_default(isCountToken ? CountTokenStyle : TokenStyle, isCountToken ? "" : "closable-token"),
18422
+ },
18423
+ dropdownRender: (menu) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
18424
+ className: SelectContentStyle,
18425
+ children: [/* @__PURE__ */ jsxRuntimeExports.jsx(kit.searchInput, {
18426
+ style: {
18427
+ width: "100%"
18428
+ },
18429
+ className: SearchInputStyle,
18430
+ onChange: debouncedSetSearch,
18431
+ placeholder: t2("dovetail.please_input")
18432
+ }), menu, isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(kit.loading, {}) : null]
18433
+ }),
18434
+ tagRender: ({
18435
+ label: label2,
18436
+ value: namespaceValue,
18419
18437
  closable,
18420
- size: "medium",
18421
- onClose,
18438
+ onClose
18439
+ }) => {
18440
+ const isCountToken = label2 !== namespaceValue && typeof label2 === "string";
18441
+ const isAll = namespaceValue === ALL_NS;
18442
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
18443
+ onClick: () => {
18444
+ setOpen(!open);
18445
+ },
18446
+ children: isAll ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", {
18447
+ style: {
18448
+ marginLeft: 8
18449
+ },
18450
+ children: [label2, "..."]
18451
+ }) : /* @__PURE__ */ jsxRuntimeExports.jsx(kit.token, {
18452
+ className: cx_default(isCountToken ? CountTokenStyle : TokenStyle, isCountToken ? "" : "closable-token"),
18453
+ closable,
18454
+ size: "medium",
18455
+ onClose,
18456
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18457
+ content: isCountToken ? /* @__PURE__ */ jsxRuntimeExports.jsx(kit.tooltip, {
18458
+ title: isCountToken ? value2.slice(MAX_TAG_COUNT).map((namespace2, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
18459
+ children: [/* @__PURE__ */ jsxRuntimeExports.jsx("div", {
18460
+ children: namespace2
18461
+ }), index !== value2.length - 1 - MAX_TAG_COUNT ? /* @__PURE__ */ jsxRuntimeExports.jsx(kit.divider, {
18462
+ style: {
18463
+ margin: "6px 0",
18464
+ borderColor: "rgba(107, 128, 167, 0.60)"
18465
+ }
18466
+ }) : null]
18467
+ })) : null,
18468
+ trigger: ["hover"],
18469
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
18470
+ children: label2.replace(/[\s\.]/g, "")
18471
+ })
18472
+ }) : label2
18473
+ })
18474
+ })
18475
+ });
18476
+ },
18477
+ maxTagCount: MAX_TAG_COUNT,
18478
+ optionLabelProp: "label",
18479
+ showArrow: true,
18480
+ showSearch: false,
18481
+ open,
18482
+ onDropdownVisibleChange: (open2) => {
18483
+ setOpen(open2);
18484
+ },
18485
+ multiple: true,
18486
+ children: [/* @__PURE__ */ jsxRuntimeExports.jsx(kit.option, {
18487
+ value: "_all",
18488
+ label: t2("dovetail.all_namespaces"),
18489
+ className: AllNamespaceOptionStyle,
18422
18490
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18423
- content: isCountToken ? label2.replace(/[\s\.]/g, "") : label2
18491
+ content: t2("dovetail.all_namespaces"),
18492
+ className: LabelWrapperStyle
18424
18493
  })
18425
- });
18426
- },
18427
- maxTagCount: 1,
18428
- optionLabelProp: "label",
18429
- showArrow: true,
18430
- showSearch: false,
18431
- multiple: true,
18432
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx(kit.option, {
18433
- value: "_all",
18434
- label: t2("dovetail.all_namespaces"),
18435
- className: AllNamespaceOptionStyle,
18436
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18437
- content: t2("dovetail.all_namespaces"),
18438
- className: LabelWrapperStyle
18439
- })
18440
- }, "_all"), /* @__PURE__ */ jsxRuntimeExports.jsx(kit.selectOptGroup, {
18441
- label: "",
18442
- className: SelectOptionGroupStyle,
18443
- children: data2 == null ? void 0 : data2.data.map((namespace2) => {
18444
- const {
18445
- name: name2
18446
- } = namespace2.metadata;
18447
- return /* @__PURE__ */ jsxRuntimeExports.jsx(kit.option, {
18448
- value: name2,
18449
- label: name2,
18450
- className: OptionStyle,
18451
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18452
- content: name2,
18453
- className: LabelWrapperStyle
18454
- })
18455
- }, name2);
18456
- })
18457
- })]
18494
+ }, "_all"), /* @__PURE__ */ jsxRuntimeExports.jsx(kit.selectOptGroup, {
18495
+ label: "",
18496
+ className: SelectOptionGroupStyle,
18497
+ children: data2 == null ? void 0 : data2.data.map((namespace2) => {
18498
+ const {
18499
+ name: name2
18500
+ } = namespace2.metadata;
18501
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(kit.option, {
18502
+ value: name2,
18503
+ label: name2,
18504
+ className: OptionStyle,
18505
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18506
+ content: name2,
18507
+ className: LabelWrapperStyle
18508
+ })
18509
+ }, name2);
18510
+ })
18511
+ })]
18512
+ })
18458
18513
  });
18459
18514
  };
18460
18515
  const index_hp158y = "";
@@ -21730,20 +21785,44 @@ var __publicField = (obj, key, value) => {
21730
21785
  _formControl.current.formState = getProxyFormState(formState, control);
21731
21786
  return _formControl.current;
21732
21787
  }
21733
- const RefineFormContent_1in3vad = "";
21788
+ const RefineFormContent_1tb00bi = "";
21734
21789
  const RefineFormContent = (props) => {
21735
- var _a, _b;
21790
+ var _a, _b, _c, _d;
21736
21791
  const {
21737
21792
  config,
21738
21793
  formResult,
21739
- action,
21794
+ resourceId,
21740
21795
  errorMsg
21741
21796
  } = props;
21742
21797
  const {
21743
21798
  control,
21744
21799
  getValues
21745
21800
  } = formResult;
21746
- const fields = (_b = (_a = config == null ? void 0 : config.formConfig) == null ? void 0 : _a.fields) == null ? void 0 : _b.map((c2) => {
21801
+ const action = resourceId ? "edit" : "create";
21802
+ const listQuery = core.useList({
21803
+ resource: config == null ? void 0 : config.name,
21804
+ meta: {
21805
+ resourceBasePath: config == null ? void 0 : config.basePath,
21806
+ kind: config == null ? void 0 : config.kind
21807
+ },
21808
+ pagination: {
21809
+ mode: "off"
21810
+ }
21811
+ });
21812
+ const showQuery = core.useShow({
21813
+ resource: config == null ? void 0 : config.name,
21814
+ meta: {
21815
+ resourceBasePath: config == null ? void 0 : config.basePath,
21816
+ kind: config == null ? void 0 : config.kind
21817
+ },
21818
+ id: resourceId
21819
+ });
21820
+ const formFieldsConfig = (_d = (_a = config == null ? void 0 : config.formConfig) == null ? void 0 : _a.fields) == null ? void 0 : _d.call(_a, {
21821
+ record: (_b = showQuery.queryResult.data) == null ? void 0 : _b.data,
21822
+ records: ((_c = listQuery.data) == null ? void 0 : _c.data) || [],
21823
+ action
21824
+ });
21825
+ const fields = formFieldsConfig == null ? void 0 : formFieldsConfig.map((c2) => {
21747
21826
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Controller, {
21748
21827
  control,
21749
21828
  name: c2.path.join("."),
@@ -21775,6 +21854,7 @@ var __publicField = (obj, key, value) => {
21775
21854
  var _a2;
21776
21855
  const formValue = getValues();
21777
21856
  let ele = /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Fields.String, {
21857
+ placeholder: c2.placeholder,
21778
21858
  input: {
21779
21859
  value: value2,
21780
21860
  onChange,
@@ -21802,6 +21882,17 @@ var __publicField = (obj, key, value) => {
21802
21882
  children: value2
21803
21883
  });
21804
21884
  }
21885
+ if (c2.helperText) {
21886
+ ele = /* @__PURE__ */ jsxRuntimeExports.jsxs(eagle.Space, {
21887
+ size: 4,
21888
+ direction: "vertical",
21889
+ className: "c154n7ie",
21890
+ children: [c2, /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
21891
+ className: cx_default(eagle.Typo.Footnote.f2_regular, "c1c9j4da"),
21892
+ children: c2.helperText
21893
+ })]
21894
+ });
21895
+ }
21805
21896
  if (c2 == null ? void 0 : c2.render) {
21806
21897
  ele = c2.render(value2, onChange, formValue, onBlur, action);
21807
21898
  }
@@ -21819,7 +21910,7 @@ var __publicField = (obj, key, value) => {
21819
21910
  });
21820
21911
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(eagle.Space, {
21821
21912
  direction: "vertical",
21822
- className: "c154n7ie",
21913
+ className: "cjxv8cf",
21823
21914
  children: [fields, /* @__PURE__ */ jsxRuntimeExports.jsx(FormErrorAlert, {
21824
21915
  errorMsgs: errorMsg ? [errorMsg] : [],
21825
21916
  style: {
@@ -22459,7 +22550,6 @@ var __publicField = (obj, key, value) => {
22459
22550
  };
22460
22551
  };
22461
22552
  const useRefineForm = (props) => {
22462
- var _a;
22463
22553
  const { config, id, refineProps } = props;
22464
22554
  const [responseErrorMsg, setResponseErrorMsg] = React.useState("");
22465
22555
  const i18n2 = useTranslation();
@@ -22492,15 +22582,15 @@ var __publicField = (obj, key, value) => {
22492
22582
  defaultValues: config == null ? void 0 : config.initValue
22493
22583
  });
22494
22584
  React.useEffect(() => {
22495
- var _a2, _b;
22496
- const response = (_a2 = result.refineCore.mutationResult.error) == null ? void 0 : _a2.response;
22585
+ var _a, _b;
22586
+ const response = (_a = result.refineCore.mutationResult.error) == null ? void 0 : _a.response;
22497
22587
  if (response && !(response == null ? void 0 : response.bodyUsed)) {
22498
22588
  (_b = response.json) == null ? void 0 : _b.call(response).then((body) => {
22499
- var _a3, _b2;
22500
- setResponseErrorMsg(((_b2 = (_a3 = config.formConfig) == null ? void 0 : _a3.formatError) == null ? void 0 : _b2.call(_a3, body)) || body.message);
22589
+ var _a2, _b2;
22590
+ setResponseErrorMsg(((_b2 = (_a2 = config.formConfig) == null ? void 0 : _a2.formatError) == null ? void 0 : _b2.call(_a2, body)) || body.message);
22501
22591
  });
22502
22592
  }
22503
- }, [config.formConfig, (_a = result.refineCore.mutationResult.error) == null ? void 0 : _a.response]);
22593
+ }, [config.formConfig, result]);
22504
22594
  return { formResult: result, responseErrorMsg };
22505
22595
  };
22506
22596
  const index_12sfrn = "";
@@ -23026,9 +23116,18 @@ var __publicField = (obj, key, value) => {
23026
23116
  setEditorErrors(errors);
23027
23117
  return;
23028
23118
  }
23029
- const objectValues = editor.current ? yaml.load(((_a2 = editor.current) == null ? void 0 : _a2.getEditorValue()) || "") : values;
23030
- const finalValues = (transformApplyValues == null ? void 0 : transformApplyValues(objectValues)) || objectValues;
23031
- return onFinish(finalValues);
23119
+ try {
23120
+ const objectValues = editor.current ? yaml.load(((_a2 = editor.current) == null ? void 0 : _a2.getEditorValue()) || "") : values;
23121
+ const finalValues = (transformApplyValues == null ? void 0 : transformApplyValues(objectValues)) || objectValues;
23122
+ return onFinish(finalValues);
23123
+ } catch (error) {
23124
+ if (error instanceof Error) {
23125
+ if (error.message === "expected a single document in the stream, but found more") {
23126
+ setEditorErrors([t2("dovetail.only_support_one_yaml")]);
23127
+ return;
23128
+ }
23129
+ }
23130
+ }
23032
23131
  },
23033
23132
  onKeyUp,
23034
23133
  onValuesChange,
@@ -23250,7 +23349,7 @@ var __publicField = (obj, key, value) => {
23250
23349
  formResult: refineFormResult.formResult,
23251
23350
  config,
23252
23351
  errorMsg: refineFormResult.responseErrorMsg,
23253
- action: id ? "edit" : "create"
23352
+ resourceId: id
23254
23353
  });
23255
23354
  })();
23256
23355
  const saveButtonProps = isYamlForm ? yamlSaveButtonProps : refineFormResult.formResult.saveButtonProps;
@@ -23333,7 +23432,7 @@ var __publicField = (obj, key, value) => {
23333
23432
  children: [/* @__PURE__ */ jsxRuntimeExports.jsx(RefineFormContent, {
23334
23433
  config,
23335
23434
  formResult,
23336
- action
23435
+ resourceId: id
23337
23436
  }), ";", /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Button, {
23338
23437
  ...saveButtonProps,
23339
23438
  onClick,
@@ -23734,7 +23833,11 @@ var __publicField = (obj, key, value) => {
23734
23833
  title: i18n2.t("dovetail.name"),
23735
23834
  sortable: true,
23736
23835
  width: 200,
23737
- sorter: CommonSorter(dataIndex)
23836
+ sorter: CommonSorter(dataIndex),
23837
+ render: (v) => /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.OverflowTooltip, {
23838
+ content: v,
23839
+ tooltip: v
23840
+ })
23738
23841
  };
23739
23842
  };
23740
23843
  const NameSpaceColumnRenderer = (i18n2) => {
@@ -24174,7 +24277,7 @@ var __publicField = (obj, key, value) => {
24174
24277
  href: `//${v.servicePort}`,
24175
24278
  target: "_blank",
24176
24279
  children: v.servicePort
24177
- }) : v.servicePort, " > ", v.targetPort, "/", v.protocol]
24280
+ }) : v.servicePort, " ", "> ", v.targetPort, "/", v.protocol]
24178
24281
  }),
24179
24282
  tooltip: `${v.servicePort} > ${v.targetPort}/${v.protocol}`
24180
24283
  }, v.servicePort));
package/dist/style.css CHANGED
@@ -12,7 +12,7 @@
12
12
  .b1vtjd4k.ant-btn.ant-btn-link{display:block;}
13
13
  .luro4rx.ant-btn.ant-btn-link{line-height:18px;height:18px;}
14
14
  .t13a6vox{-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;max-width:100%;gap:8px 8px;}
15
- .t12ikbmp.ant-tag{overflow:hidden;text-overflow:ellipsis;color:#1D326C;}.t12ikbmp.ant-tag.outside-tag{background-color:rgba(211,218,235,0.60);}.t12ikbmp.ant-tag .inside-tag{background-color:rgba(192,203,224,0.60);}
15
+ .t12ikbmp.ant-tag{overflow:hidden;text-overflow:ellipsis;color:#1D326C;}.t12ikbmp.ant-tag.outside-tag{border:1px solid #A3B4CC;background-color:#E4E9F2;}.t12ikbmp.ant-tag .inside-tag{background-color:#CCD4E3;}
16
16
  .s8qkbck.ant-tag{padding:3px 16px;height:24px;}.s8qkbck.no-background{background-color:transparent !important;padding:0;}
17
17
  .t19ustft{display:inline-block;line-height:18px;height:18px;border-bottom:1px dashed rgba(107,128,167,0.6);}
18
18
  .t1v3ienx{padding:12px 24px;}
@@ -22,7 +22,7 @@
22
22
  .w16agr8o.ant-space{width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}
23
23
  .i1u1f5zp{white-space:pre-line;}
24
24
  .c8jy7dc{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding:8px 10px;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:flex-start;-webkit-box-align:flex-start;-ms-flex-align:flex-start;align-items:flex-start;gap:8px;-webkit-align-self:stretch;-ms-flex-item-align:stretch;align-self:stretch;border-radius:4px;background:rgba(237,241,250,0.6);}.c8jy7dc:not(:last-of-type){margin-bottom:8px;}
25
- .k2sddxl{color:rgba(44,56,82,0.6);width:calc(30% - 4px);margin-right:8px;word-break:break-all;}
25
+ .k2sddxl{color:rgba(44,56,82,0.75);width:calc(30% - 4px);margin-right:8px;word-break:break-all;}
26
26
  .v16vicsr{word-break:break-all;white-space:pre-wrap;width:calc(70% - 4px);}
27
27
  .w14056kz{width:100%;}
28
28
  .hisq2gt{width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}.hisq2gt.expanded{margin-bottom:8px;}
@@ -1506,12 +1506,12 @@
1506
1506
  .e1cjl2b8{border-radius:8px;border:1px solid rgba(211,218,235,0.60);}.e1cjl2b8 .monaco-editor,.e1cjl2b8 .monaco-scrollable-element,.e1cjl2b8 .overflow-guard > .margin{border-radius:8px;}
1507
1507
  .w1akirqw{height:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}
1508
1508
  .t30srnq{line-height:32px !important;}
1509
- .sj0ggy.ant-select .ant-select-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap;overflow:hidden;gap:4px;}.sj0ggy.ant-select .ant-select-selector > span{max-width:calc(100% - 76px);-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;}.sj0ggy.ant-select .ant-select-selection-search{display:none;}.sj0ggy.ant-select .zoom-leave{opacity:0;position:absolute;}
1509
+ .sj0ggy.ant-select{-webkit-align-self:flex-start;-ms-flex-item-align:start;align-self:flex-start;min-width:276px;max-width:100%;}.sj0ggy.ant-select .ant-select-selector{display:block;overflow:hidden;padding-right:32px;white-space:nowrap;}.sj0ggy.ant-select .ant-select-selector > span:nth-child(-n + 8):not(.ant-select-selection-search){display:inline-block;max-width:var(--tag-max-width);margin-right:4px;}.sj0ggy.ant-select .ant-select-selection-search{display:none;}.sj0ggy.ant-select .zoom-leave{opacity:0;position:absolute;}
1510
1510
  .d1eo8uqs{border-radius:6px;}
1511
1511
  .s64gojc.s64gojc.ant-input-affix-wrapper{border:unset;border-bottom:1px solid rgba(211,218,235,.6);border-radius:unset;box-shadow:unset;outline:unset;padding:5px 18px;}.s64gojc.s64gojc.ant-input-affix-wrapper:hover,.s64gojc.s64gojc.ant-input-affix-wrapper:focus{box-shadow:unset;outline:unset;}
1512
1512
  .s16fqgtu .ant-select-item-group{border-bottom:1px solid rgba(211,218,235,0.6);min-height:0;padding:0;overflow:hidden;margin:6px 0;}
1513
1513
  .tgaujbg{max-width:100%;margin-right:0 !important;}
1514
- .c1vbd54v{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;margin-right:0;}
1514
+ .c1vbd54v{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;margin-right:0 !important;}
1515
1515
 
1516
1516
  .lqrghwd{margin-right:8px;}
1517
1517
  .api7z1z{border-radius:4px;margin:6px;margin-bottom:0;padding:4px 8px 4px 12px;}
@@ -1520,7 +1520,9 @@
1520
1520
  .l1ng0psc{padding:12px 24px;-webkit-flex:1;-ms-flex:1;flex:1;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;min-height:0;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}
1521
1521
  .tj6zpn4{-webkit-flex:1;-ms-flex:1;flex:1;min-height:0;}.tj6zpn4.table-wrapper{height:auto;-webkit-flex-shrink:1;-ms-flex-negative:1;flex-shrink:1;min-height:0;}
1522
1522
  .n1rqcyjn.ant-select{margin-bottom:12px;}
1523
- .c154n7ie{-webkit-flex-basis:58%;-ms-flex-preferred-size:58%;flex-basis:58%;width:100%;}
1523
+ .c154n7ie{width:100%;}
1524
+ .c1c9j4da{color:rgba(44,56,82,0.6);}
1525
+ .cjxv8cf{-webkit-flex-basis:58%;-ms-flex-preferred-size:58%;flex-basis:58%;width:100%;}
1524
1526
  .s1bsn3us{width:1px;height:16px;border-radius:1px;background:rgba(172,186,211,0.6);}
1525
1527
 
1526
1528
  .e1guqlj2{-webkit-flex:1;-ms-flex:1;flex:1;height:100%;margin-bottom:16px;}
@@ -6,7 +6,7 @@ type Props<Model extends ResourceModel> = {
6
6
  config?: ResourceConfig<Model>;
7
7
  formResult: UseFormReturnType;
8
8
  errorMsg?: string;
9
- action: 'create' | 'edit';
9
+ resourceId?: string;
10
10
  };
11
11
  export declare const RefineFormContent: <Model extends ResourceModel<import("k8s-api-provider").Unstructured>>(props: Props<Model>) => JSX.Element;
12
12
  export {};
@@ -7,6 +7,8 @@ export type RefineFormField = {
7
7
  path: string[];
8
8
  key: string;
9
9
  label: string;
10
+ placeholder?: string;
11
+ helperText?: string;
10
12
  type?: 'number';
11
13
  validators?: RefineFormValidator[];
12
14
  disabledWhenEdit?: boolean;
@@ -41,7 +41,11 @@ export type ResourceConfig<Model extends ResourceModel = ResourceModel> = {
41
41
  }>;
42
42
  isCustom?: boolean;
43
43
  formConfig?: {
44
- fields?: RefineFormField[];
44
+ fields?: (props: {
45
+ record?: Model;
46
+ records: Model[];
47
+ action: 'create' | 'edit';
48
+ }) => RefineFormField[];
45
49
  renderForm?: (props: YamlFormProps) => React.ReactNode;
46
50
  formType?: FormType;
47
51
  transformInitValues?: (values: Unstructured) => Unstructured;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dovetail-v2/refine",
3
- "version": "0.0.44",
3
+ "version": "0.0.45-bowen.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",