@dovetail-v2/refine 0.3.0 → 0.3.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.
@@ -1180,6 +1180,7 @@ const confirm = "确认";
1180
1180
  const cant_delete_resource = "无法删除{{resource}}";
1181
1181
  const cant_delete_resource_with_name = "无法删除{{resource}} <0>{{name}}</0> 。";
1182
1182
  const close = "关闭";
1183
+ const import_from_file = "从文件读取";
1183
1184
  const dovetail = {
1184
1185
  copy,
1185
1186
  reset_arguments,
@@ -1421,7 +1422,8 @@ const dovetail = {
1421
1422
  confirm,
1422
1423
  cant_delete_resource,
1423
1424
  cant_delete_resource_with_name,
1424
- close
1425
+ close,
1426
+ import_from_file
1425
1427
  };
1426
1428
  const ZH = {
1427
1429
  dovetail
@@ -10193,29 +10195,38 @@ function getInitialValues(config) {
10193
10195
  spec: {}
10194
10196
  };
10195
10197
  }
10196
- function useOpenForm(options) {
10198
+ function useOpenForm() {
10197
10199
  const { resource } = core.useResource();
10198
10200
  const configs = React.useContext(ConfigsContext);
10199
10201
  const { edit: edit2 } = useEdit();
10200
10202
  const navigation = core.useNavigation();
10201
10203
  const pushModal = eagle.usePushModal();
10202
10204
  const go = core.useGo();
10203
- return function openForm(resourceName) {
10204
- var _a, _b;
10205
- const finalResourceName = resourceName || (resource == null ? void 0 : resource.name);
10205
+ return function openForm(options) {
10206
+ var _a;
10207
+ const finalResourceName = (options == null ? void 0 : options.resourceName) || (resource == null ? void 0 : resource.name);
10206
10208
  if (finalResourceName) {
10207
10209
  const config = configs[finalResourceName];
10208
10210
  const formType = (_a = config.formConfig) == null ? void 0 : _a.formContainerType;
10209
10211
  if (formType === void 0 || formType === FormContainerType.MODAL) {
10210
10212
  pushModal({
10211
- component: ((_b = config.formConfig) == null ? void 0 : _b.CustomFormModal) || FormModal,
10212
- props: {
10213
- resource: finalResourceName,
10214
- id: options == null ? void 0 : options.id,
10215
- formProps: {
10216
- initialValues: getInitialValues(config)
10217
- }
10218
- }
10213
+ component: () => {
10214
+ var _a2;
10215
+ const ModalComponent = ((_a2 = config.formConfig) == null ? void 0 : _a2.CustomFormModal) || FormModal;
10216
+ return /* @__PURE__ */ common.jsxRuntimeExports.jsx(
10217
+ ModalComponent,
10218
+ {
10219
+ resource: finalResourceName,
10220
+ id: options == null ? void 0 : options.id,
10221
+ yamlFormProps: {
10222
+ config,
10223
+ initialValuesForCreate: getInitialValues(config)
10224
+ },
10225
+ onSuccess: options == null ? void 0 : options.onSuccess
10226
+ }
10227
+ );
10228
+ },
10229
+ props: {}
10219
10230
  });
10220
10231
  } else if (options == null ? void 0 : options.id) {
10221
10232
  edit2(options.id);
@@ -10234,6 +10245,52 @@ function getResourceNameByKind(kind, configs) {
10234
10245
  var _a;
10235
10246
  return (_a = Object.values(configs).find((config) => config.kind === kind)) == null ? void 0 : _a.name;
10236
10247
  }
10248
+ function validateDnsSubdomain(subdomain) {
10249
+ const regex = /(^[a-zA-Z0-9]$)|(^[a-zA-Z0-9][a-zA-Z0-9\.\-\_]*[a-zA-Z0-9]$)/;
10250
+ if (!regex.test(subdomain)) {
10251
+ return { isValid: false };
10252
+ }
10253
+ if (subdomain && subdomain.length > 63) {
10254
+ return { isValid: false };
10255
+ }
10256
+ return { isValid: true };
10257
+ }
10258
+ function validateLabelKey(key2) {
10259
+ const labelRegex = /(^[a-zA-Z0-9]$)|(^[a-zA-Z0-9][a-zA-Z0-9\.\-\_]*[a-zA-Z0-9]$)/;
10260
+ let prefix2, name2;
10261
+ const splitResult = key2.split("/");
10262
+ if (splitResult.length === 1) {
10263
+ name2 = splitResult[0];
10264
+ } else {
10265
+ prefix2 = splitResult[0];
10266
+ name2 = splitResult[1];
10267
+ }
10268
+ if (prefix2 === "") {
10269
+ return { isValid: false };
10270
+ }
10271
+ if (prefix2 && !labelRegex.test(prefix2)) {
10272
+ return { isValid: false };
10273
+ }
10274
+ if (prefix2 && prefix2.length > 253) {
10275
+ return { isValid: false };
10276
+ }
10277
+ return validateDnsSubdomain(name2);
10278
+ }
10279
+ function validateLabelValue(value2, isOptional) {
10280
+ const labelValueRegex = /(^[a-zA-Z0-9]$)|(^[a-zA-Z0-9][a-zA-Z0-9\.\-\_]*[a-zA-Z0-9]$)/;
10281
+ if (isOptional && value2 === "") {
10282
+ return { isValid: true };
10283
+ } else if (value2 === "") {
10284
+ return { isValid: false };
10285
+ }
10286
+ if (value2.length > 63) {
10287
+ return { isValid: false };
10288
+ }
10289
+ if (!labelValueRegex.test(value2)) {
10290
+ return { isValid: false };
10291
+ }
10292
+ return { isValid: true };
10293
+ }
10237
10294
  function K8sDropdown(props) {
10238
10295
  var _a;
10239
10296
  const { record, size = "normal" } = props;
@@ -10245,7 +10302,7 @@ function K8sDropdown(props) {
10245
10302
  const { t: t2 } = common.useTranslation();
10246
10303
  const { openDeleteConfirmModal } = useDeleteModal({ resourceName: resourceName || "" });
10247
10304
  const download2 = useDownloadYAML();
10248
- const openForm = useOpenForm({ id: record.id });
10305
+ const openForm = useOpenForm();
10249
10306
  const isInShowPage = useResourceResult.action === "show";
10250
10307
  const { data: canEditData } = core.useCan({
10251
10308
  resource: resourceName,
@@ -10266,7 +10323,7 @@ function K8sDropdown(props) {
10266
10323
  eagle.Dropdown,
10267
10324
  {
10268
10325
  overlay: /* @__PURE__ */ common.jsxRuntimeExports.jsxs(eagle.Menu, { children: [
10269
- isInShowPage || (canEditData == null ? void 0 : canEditData.can) === false || config.hideEdit ? null : /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Menu.Item, { onClick: () => openForm(), children: /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Icon, { src: iconsReact.EditPen16PrimaryIcon, children: formType === FormType.FORM ? t2("dovetail.edit") : t2("dovetail.edit_yaml") }) }),
10326
+ isInShowPage || (canEditData == null ? void 0 : canEditData.can) === false || config.hideEdit ? null : /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Menu.Item, { onClick: () => openForm({ id: record.id }), children: /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Icon, { src: iconsReact.EditPen16PrimaryIcon, children: formType === FormType.FORM ? t2("dovetail.edit") : t2("dovetail.edit_yaml") }) }),
10270
10327
  /* @__PURE__ */ common.jsxRuntimeExports.jsx(
10271
10328
  eagle.Menu.Item,
10272
10329
  {
@@ -11044,9 +11101,7 @@ const ShowContent = (props) => {
11044
11101
  } = queryResult;
11045
11102
  const navigation = core.useNavigation();
11046
11103
  const go = core.useGo();
11047
- const openForm = useOpenForm({
11048
- id
11049
- });
11104
+ const openForm = useOpenForm();
11050
11105
  const Component = React.useContext(ComponentContext);
11051
11106
  const configs = React.useContext(ConfigsContext);
11052
11107
  const config = configs[(resource == null ? void 0 : resource.name) || ""];
@@ -11149,7 +11204,9 @@ const ShowContent = (props) => {
11149
11204
  style: {
11150
11205
  marginRight: 8
11151
11206
  },
11152
- onClick: () => openForm(),
11207
+ onClick: () => openForm({
11208
+ id
11209
+ }),
11153
11210
  children: ((_f = config.formConfig) == null ? void 0 : _f.formType) === FormType.FORM ? t2("dovetail.edit") : t2("dovetail.edit_yaml")
11154
11211
  })
11155
11212
  }) : null, /* @__PURE__ */ common.jsxRuntimeExports.jsx(Dropdown, {
@@ -11238,45 +11295,36 @@ function KeyValueSecret(props) {
11238
11295
  })
11239
11296
  });
11240
11297
  }
11241
- function validateLabelKey(key2) {
11242
- const labelRegex = /(^[a-zA-Z0-9]$)|(^[a-zA-Z0-9][a-zA-Z0-9\.\-\_]*[a-zA-Z0-9]$)/;
11243
- let prefix2, name2;
11244
- const splitResult = key2.split("/");
11245
- if (splitResult.length === 1) {
11246
- name2 = splitResult[0];
11247
- } else {
11248
- prefix2 = splitResult[0];
11249
- name2 = splitResult[1];
11250
- }
11251
- if (prefix2 === "") {
11252
- return { isValid: false, errorMessage: "EMPTY_PREFIX" };
11253
- }
11254
- if (prefix2 && !labelRegex.test(prefix2)) {
11255
- return { isValid: false, errorMessage: "INVALID_PREFIX" };
11256
- }
11257
- if (!labelRegex.test(name2)) {
11258
- return { isValid: false, errorMessage: "INVALID_NAME" };
11259
- }
11260
- if (prefix2 && prefix2.length > 253) {
11261
- return { isValid: false, errorMessage: "MAX_253" };
11262
- }
11263
- if (name2 && name2.length > 63) {
11264
- return { isValid: false, errorMessage: "MAX_63" };
11298
+ function isUtf8(buffer) {
11299
+ try {
11300
+ const decoder = new TextDecoder("utf-8", { fatal: true });
11301
+ decoder.decode(buffer);
11302
+ return true;
11303
+ } catch (e2) {
11304
+ return false;
11265
11305
  }
11266
- return { isValid: true };
11267
11306
  }
11268
- function validateLabelValue(value2) {
11269
- const labelValueRegex = /(^[a-zA-Z0-9]$)|(^[a-zA-Z0-9][a-zA-Z0-9\.\-\_]*[a-zA-Z0-9]$)/;
11270
- if (value2 === "") {
11271
- return { isValid: true };
11272
- }
11273
- if (value2.length > 63) {
11274
- return { isValid: false, errorMessage: "MAX_63" };
11275
- }
11276
- if (!labelValueRegex.test(value2)) {
11277
- return { isValid: false, errorMessage: "INVALID_VALUE" };
11278
- }
11279
- return { isValid: true };
11307
+ function readFileAsBase64(file) {
11308
+ return new Promise((resolve, reject) => {
11309
+ const reader = new FileReader();
11310
+ reader.onload = async () => {
11311
+ const arrayBuffer = reader.result;
11312
+ if (arrayBuffer instanceof ArrayBuffer) {
11313
+ if (isUtf8(arrayBuffer)) {
11314
+ resolve(await file.text());
11315
+ } else {
11316
+ const base64String = btoa(
11317
+ String.fromCharCode(...new Uint8Array(arrayBuffer))
11318
+ );
11319
+ resolve(base64String);
11320
+ }
11321
+ return;
11322
+ }
11323
+ reject(new Error("Failed to read file"));
11324
+ };
11325
+ reader.onerror = reject;
11326
+ reader.readAsArrayBuffer(file);
11327
+ });
11280
11328
  }
11281
11329
  const LabelFormatPopover_piveun = "";
11282
11330
  const PodLabelFormatRulePopoverStyle = "p5jt6nm";
@@ -11364,59 +11412,86 @@ const LabelFormatPopover = ({
11364
11412
  })
11365
11413
  });
11366
11414
  };
11367
- const KeyValueTableForm_1eydq7y = "";
11368
- function _KeyValueTableFormForm(props, ref) {
11415
+ const index_t3zi07 = "";
11416
+ function _KeyValueTableForm(props, ref) {
11369
11417
  const {
11418
+ value: value2,
11370
11419
  defaultValue,
11371
- onSubmit,
11420
+ onChange,
11372
11421
  extraColumns,
11373
11422
  addButtonText,
11374
- noValueValidation
11423
+ noValueValidation,
11424
+ isHideLabelFormatPopover,
11425
+ isValueOptional = true,
11426
+ canImportFromFile,
11427
+ minSize,
11428
+ validateKey,
11429
+ validateValue,
11430
+ onSubmit
11375
11431
  } = props;
11376
11432
  const {
11377
11433
  t: t2
11378
11434
  } = common.useTranslation();
11379
- const [value2, setValue] = React.useState([]);
11380
11435
  const tableFormRef = React.useRef(null);
11436
+ const [_value, _setValue] = React.useState(value2 || defaultValue);
11437
+ const [forceUpdateCount, setForceUpdateCount] = React.useState(0);
11438
+ const validate = React.useCallback(() => {
11439
+ return new Promise((resolve) => {
11440
+ var _a;
11441
+ (_a = tableFormRef.current) == null ? void 0 : _a.validateWholeFields();
11442
+ setForceUpdateCount(forceUpdateCount + 1);
11443
+ setTimeout(() => {
11444
+ var _a2;
11445
+ const isValid = (_a2 = tableFormRef.current) == null ? void 0 : _a2.isValid();
11446
+ resolve(isValid || false);
11447
+ }, 0);
11448
+ });
11449
+ }, [forceUpdateCount]);
11381
11450
  React.useImperativeHandle(ref, () => ({
11382
- submit: () => {
11383
- return new Promise((res, rej) => {
11384
- var _a;
11385
- (_a = tableFormRef.current) == null ? void 0 : _a.validateWholeFields();
11386
- setTimeout(() => {
11387
- var _a2;
11388
- const isValid = (_a2 = tableFormRef.current) == null ? void 0 : _a2.isValid();
11389
- if (isValid) {
11390
- res(onSubmit(value2));
11391
- } else {
11392
- rej();
11393
- }
11394
- }, 0);
11395
- });
11451
+ validate,
11452
+ submit: async () => {
11453
+ const isValid = await validate();
11454
+ if (isValid) {
11455
+ return onSubmit == null ? void 0 : onSubmit(_value);
11456
+ }
11457
+ return Promise.reject();
11458
+ },
11459
+ setValue: (value22) => {
11460
+ var _a;
11461
+ _setValue(value22);
11462
+ (_a = tableFormRef.current) == null ? void 0 : _a.setData(value22);
11463
+ }
11464
+ }), [validate, onSubmit, _value]);
11465
+ React.useEffect(() => {
11466
+ var _a;
11467
+ if (value2 && !lodashEs.isEqual(value2, _value)) {
11468
+ _setValue(value2);
11469
+ (_a = tableFormRef.current) == null ? void 0 : _a.setData(value2);
11396
11470
  }
11397
- }), [onSubmit, value2]);
11471
+ }, [value2]);
11398
11472
  const renderTextAreaFunc = ({
11399
11473
  value: value22,
11400
- onChange
11474
+ onChange: onChange2
11401
11475
  }) => {
11402
11476
  return /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.TextArea, {
11403
11477
  autoSize: true,
11404
- className: "clsjtk2",
11478
+ className: "c17gq8cd",
11405
11479
  size: "small",
11406
11480
  value: value22,
11407
11481
  onChange: (e2) => {
11408
- onChange(e2.target.value);
11482
+ onChange2(e2.target.value);
11409
11483
  }
11410
11484
  });
11411
11485
  };
11412
11486
  return /* @__PURE__ */ common.jsxRuntimeExports.jsxs(eagle.Space, {
11413
11487
  size: 8,
11414
11488
  direction: "vertical",
11415
- className: "cq3mbby",
11489
+ className: "c1n7fiws",
11416
11490
  children: [/* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.TableForm, {
11417
11491
  ref: tableFormRef,
11418
- onBodyChange: (value22) => {
11419
- setValue(value22);
11492
+ onBodyChange: (newValue) => {
11493
+ _setValue(newValue);
11494
+ onChange == null ? void 0 : onChange(newValue);
11420
11495
  },
11421
11496
  columns: [{
11422
11497
  key: "key",
@@ -11427,46 +11502,72 @@ function _KeyValueTableFormForm(props, ref) {
11427
11502
  }) => {
11428
11503
  if (!value22)
11429
11504
  return t2("dovetail.key_empty_text");
11505
+ const validate2 = validateKey || validateLabelKey;
11430
11506
  const {
11431
- isValid
11432
- } = validateLabelKey(value22 || "");
11507
+ isValid,
11508
+ errorMessage
11509
+ } = validate2(value22 || "");
11433
11510
  if (!isValid)
11434
- return t2("dovetail.format_error");
11511
+ return errorMessage || t2("dovetail.format_error");
11435
11512
  },
11436
11513
  render: renderTextAreaFunc
11437
11514
  }, {
11438
11515
  key: "value",
11439
- title: t2("dovetail.value_optional"),
11516
+ title: isValueOptional ? t2("dovetail.value_optional") : t2("dovetail.value"),
11440
11517
  type: "input",
11441
11518
  validator: ({
11442
11519
  value: value22
11443
11520
  }) => {
11444
11521
  if (noValueValidation)
11445
11522
  return;
11523
+ const validate2 = validateValue || validateLabelValue;
11446
11524
  const {
11447
- isValid
11448
- } = validateLabelValue(value22 || "");
11525
+ isValid,
11526
+ errorMessage
11527
+ } = validate2(value22 || "", isValueOptional);
11449
11528
  if (!isValid)
11450
- return t2("dovetail.format_error");
11529
+ return errorMessage || t2("dovetail.format_error");
11451
11530
  },
11452
11531
  render: renderTextAreaFunc
11453
11532
  }, ...extraColumns || []],
11454
- disableBatchFilling: true,
11455
- hideEmptyTable: true,
11456
11533
  rowAddConfig: {
11457
11534
  addible: true,
11458
11535
  text: () => addButtonText
11459
11536
  },
11460
11537
  defaultData: defaultValue,
11461
11538
  row: {
11462
- deletable: true
11463
- }
11464
- }), /* @__PURE__ */ common.jsxRuntimeExports.jsx(LabelFormatPopover, {
11539
+ deletable: _value.length > (minSize || 0)
11540
+ },
11541
+ disableBatchFilling: true,
11542
+ hideEmptyTable: true
11543
+ }), isHideLabelFormatPopover ? null : /* @__PURE__ */ common.jsxRuntimeExports.jsx(LabelFormatPopover, {
11465
11544
  noValueValidation
11466
- })]
11545
+ }), canImportFromFile ? /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Upload, {
11546
+ multiple: false,
11547
+ showUploadList: false,
11548
+ onChange: async (e2) => {
11549
+ var _a;
11550
+ const fileValue = {
11551
+ key: e2.file.name,
11552
+ value: await readFileAsBase64(e2.file.originFileObj)
11553
+ };
11554
+ let newValue = [..._value, fileValue];
11555
+ if (_value.some((v) => v.key === fileValue.key)) {
11556
+ newValue = _value.map((v) => v.key === fileValue.key ? fileValue : v);
11557
+ }
11558
+ _setValue(newValue);
11559
+ (_a = tableFormRef.current) == null ? void 0 : _a.setData(newValue);
11560
+ onChange == null ? void 0 : onChange(newValue);
11561
+ },
11562
+ children: /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Button, {
11563
+ type: "link",
11564
+ size: "small",
11565
+ children: t2("dovetail.import_from_file")
11566
+ })
11567
+ }) : null]
11467
11568
  });
11468
11569
  }
11469
- const KeyValueTableFormForm = React.forwardRef(_KeyValueTableFormForm);
11570
+ const KeyValueTableForm = React.forwardRef(_KeyValueTableForm);
11470
11571
  const EditNodeTaintForm_cgov7z = "";
11471
11572
  const UlStyle = "u19jcs7t";
11472
11573
  const EditNodeTaintForm = React.forwardRef(function EditNodeTaintForm2(props, ref) {
@@ -11479,6 +11580,7 @@ const EditNodeTaintForm = React.forwardRef(function EditNodeTaintForm2(props, re
11479
11580
  const {
11480
11581
  t: t2
11481
11582
  } = common.useTranslation();
11583
+ const tableFormRef = React.useRef(null);
11482
11584
  const defaultValue = React.useMemo(() => {
11483
11585
  var _a;
11484
11586
  return ((_a = nodeModel._rawYaml.spec) == null ? void 0 : _a.taints) || [];
@@ -11514,8 +11616,14 @@ const EditNodeTaintForm = React.forwardRef(function EditNodeTaintForm2(props, re
11514
11616
  errorNotification: false
11515
11617
  });
11516
11618
  }, [nodeModel, mutateAsync, t2]);
11517
- return /* @__PURE__ */ common.jsxRuntimeExports.jsx(KeyValueTableFormForm, {
11518
- ref,
11619
+ React.useImperativeHandle(ref, () => ({
11620
+ submit: () => {
11621
+ var _a;
11622
+ return (_a = tableFormRef.current) == null ? void 0 : _a.submit();
11623
+ }
11624
+ }), []);
11625
+ return /* @__PURE__ */ common.jsxRuntimeExports.jsx(KeyValueTableForm, {
11626
+ ref: tableFormRef,
11519
11627
  defaultValue,
11520
11628
  onSubmit,
11521
11629
  addButtonText: t2("dovetail.add_taint"),
@@ -12707,7 +12815,7 @@ const PodLogTab = (i18n2) => ({
12707
12815
  ]
12708
12816
  });
12709
12817
  const NetworkPolicyRulesViewer_r6jity = "";
12710
- const MonacoYamlEditor$1 = React.lazy(() => Promise.resolve().then(() => require("./MonacoYamlEditor-1ed09191.cjs")));
12818
+ const MonacoYamlEditor$1 = React.lazy(() => Promise.resolve().then(() => require("./MonacoYamlEditor-9b8b7cef.cjs")));
12711
12819
  const EditorStyle$1 = "e1cjl2b8";
12712
12820
  const NetworkPolicyRulesViewer = ({
12713
12821
  ingressOrEgress,
@@ -15278,6 +15386,11 @@ function usePathMap(options) {
15278
15386
  transformApplyValues
15279
15387
  };
15280
15388
  }
15389
+ var FormItemLayout = /* @__PURE__ */ ((FormItemLayout2) => {
15390
+ FormItemLayout2["VERTICAL"] = "VERTICAL";
15391
+ FormItemLayout2["HORIZONTAL"] = "HORIZONTAL";
15392
+ return FormItemLayout2;
15393
+ })(FormItemLayout || {});
15281
15394
  function useFieldsConfig(config, formConfig, resourceId) {
15282
15395
  var _a, _b, _c;
15283
15396
  const action = resourceId ? "edit" : "create";
@@ -15299,7 +15412,8 @@ function useFieldsConfig(config, formConfig, resourceId) {
15299
15412
  action
15300
15413
  });
15301
15414
  }
15302
- const RefineFormContent_ahna8x = "";
15415
+ const RefineFormContent_lnhybh = "";
15416
+ const VerticalFormItemStyle = "v154n7ie";
15303
15417
  function renderCommonFormFiled(props) {
15304
15418
  const {
15305
15419
  field,
@@ -15326,7 +15440,7 @@ function renderCommonFormFiled(props) {
15326
15440
  switch (fieldConfig.type) {
15327
15441
  case "number":
15328
15442
  ele = /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Fields.Integer, {
15329
- className: "c154n7ie",
15443
+ className: "c1c9j4da",
15330
15444
  placeholder: fieldConfig.placeholder,
15331
15445
  input: {
15332
15446
  value: value2,
@@ -15369,7 +15483,7 @@ const RefineFormContent = (props) => {
15369
15483
  control,
15370
15484
  name: fieldConfig.path.join("."),
15371
15485
  rules: {
15372
- validate(value2) {
15486
+ async validate(value2) {
15373
15487
  const formValue = getValues();
15374
15488
  if (!fieldConfig.validators || fieldConfig.validators.length === 0)
15375
15489
  return true;
@@ -15377,7 +15491,7 @@ const RefineFormContent = (props) => {
15377
15491
  const {
15378
15492
  isValid,
15379
15493
  errorMsg
15380
- } = func(value2, formValue, FormType.FORM);
15494
+ } = await func(value2, formValue, FormType.FORM);
15381
15495
  if (!isValid)
15382
15496
  return errorMsg;
15383
15497
  }
@@ -15405,13 +15519,14 @@ const RefineFormContent = (props) => {
15405
15519
  return /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Form.Item, {
15406
15520
  label: fieldConfig.label,
15407
15521
  colon: false,
15408
- labelCol: {
15522
+ labelCol: fieldConfig.layout === FormItemLayout.VERTICAL ? {} : {
15409
15523
  flex: `0 0 ${(formConfig == null ? void 0 : formConfig.labelWidth) || "216px"}`
15410
15524
  },
15411
- help: (_a2 = fieldState.error) == null ? void 0 : _a2.message,
15525
+ help: fieldConfig.isHideErrorStatus ? "" : (_a2 = fieldState.error) == null ? void 0 : _a2.message,
15412
15526
  extra: fieldConfig.helperText,
15413
- validateStatus: fieldState.invalid ? "error" : void 0,
15527
+ validateStatus: fieldState.invalid && !fieldConfig.isHideErrorStatus ? "error" : void 0,
15414
15528
  "data-test-id": fieldConfig.key,
15529
+ className: fieldConfig.layout === FormItemLayout.VERTICAL ? VerticalFormItemStyle : "",
15415
15530
  children: ele
15416
15531
  }, fieldConfig.key);
15417
15532
  }
@@ -15420,7 +15535,7 @@ const RefineFormContent = (props) => {
15420
15535
  return /* @__PURE__ */ common.jsxRuntimeExports.jsxs(eagle.Space, {
15421
15536
  direction: "vertical",
15422
15537
  size: 16,
15423
- className: "c1c9j4da",
15538
+ className: "cjxv8cf",
15424
15539
  children: [fields, /* @__PURE__ */ common.jsxRuntimeExports.jsx(FormErrorAlert, {
15425
15540
  errorMsgs: errorMsgs || [],
15426
15541
  style: {
@@ -16139,7 +16254,7 @@ const PlainCodeStyle = "pqch97v";
16139
16254
  const ErrorMsgStyle = "eh2qjnl";
16140
16255
  const ErrorWrapperStyle = "e19q2bnp";
16141
16256
  const YamlEditorStyle = "y16u5v3w";
16142
- const MonacoYamlEditor = React.lazy(() => Promise.resolve().then(() => require("./MonacoYamlEditor-1ed09191.cjs")));
16257
+ const MonacoYamlEditor = React.lazy(() => Promise.resolve().then(() => require("./MonacoYamlEditor-9b8b7cef.cjs")));
16143
16258
  const MonacoYamlDiffEditor = React.lazy(() => Promise.resolve().then(() => require("./MonacoYamlDiffEditor-7a07db88.cjs")));
16144
16259
  const YamlEditorComponent = React.forwardRef(
16145
16260
  function YamlEditorComponent2(props, ref) {
@@ -16664,21 +16779,21 @@ const useYamlForm = ({
16664
16779
  }
16665
16780
  return changeValues;
16666
16781
  };
16667
- const validateRules = (yamlValue) => {
16782
+ const validateRules = async (yamlValue) => {
16668
16783
  const errorMap = {};
16669
16784
  if (rules && isYamlValid && isSchemaValid) {
16670
16785
  const formValue = yaml$2.load(yamlValue || "");
16671
- rules.forEach((rule2) => {
16786
+ for (const rule2 of rules) {
16672
16787
  const { path: path2, validators } = rule2;
16673
16788
  const value2 = lodashEs.get(formValue, path2);
16674
16789
  for (const validator of validators || []) {
16675
- const { isValid, errorMsg } = validator(value2, formValue, FormType.YAML);
16790
+ const { isValid, errorMsg } = await validator(value2, formValue, FormType.YAML);
16676
16791
  if (!isValid) {
16677
16792
  errorMap[path2.join(".")] = `${errorMsg}(${path2.join(".")})`;
16678
16793
  break;
16679
16794
  }
16680
16795
  }
16681
- });
16796
+ }
16682
16797
  }
16683
16798
  setRulesErrors(lodashEs.uniq(Object.values(errorMap)));
16684
16799
  return errorMap;
@@ -16816,7 +16931,7 @@ function YamlForm(props) {
16816
16931
  try {
16817
16932
  const result = await ((_a = formProps.onFinish) == null ? void 0 : _a.call(formProps, store));
16818
16933
  if (result) {
16819
- (_b = props.onFinish) == null ? void 0 : _b.call(props);
16934
+ (_b = props.onFinish) == null ? void 0 : _b.call(props, result);
16820
16935
  }
16821
16936
  } catch {
16822
16937
  } finally {
@@ -16887,20 +17002,21 @@ function RefineFormContainer({
16887
17002
  config,
16888
17003
  id,
16889
17004
  refineProps: {
16890
- onMutationSuccess: () => {
16891
- onSuccess == null ? void 0 : onSuccess();
17005
+ onMutationSuccess: (data2) => {
17006
+ onSuccess == null ? void 0 : onSuccess(data2);
16892
17007
  },
16893
17008
  onMutationError() {
16894
17009
  onError == null ? void 0 : onError();
16895
17010
  },
16896
17011
  redirect: false,
17012
+ mutationMeta: {
17013
+ updateType: "put"
17014
+ },
16897
17015
  ...formConfig == null ? void 0 : formConfig.refineCoreProps
16898
17016
  },
16899
17017
  formConfig
16900
17018
  });
16901
- const {
16902
- transformApplyValues
16903
- } = usePathMap({
17019
+ const { transformApplyValues } = usePathMap({
16904
17020
  pathMap: formConfig == null ? void 0 : formConfig.pathMap,
16905
17021
  transformInitValues: formConfig == null ? void 0 : formConfig.transformInitValues,
16906
17022
  transformApplyValues: (formConfig == null ? void 0 : formConfig.transformApplyValues) || ((v) => v)
@@ -16915,14 +17031,16 @@ function RefineFormContainer({
16915
17031
  initialValuesForCreate: transformApplyValues(
16916
17032
  refineFormResult.formResult.getValues()
16917
17033
  ),
16918
- initialValuesForEdit: transformApplyValues(refineFormResult.formResult.getValues()),
17034
+ initialValuesForEdit: transformApplyValues(
17035
+ refineFormResult.formResult.getValues()
17036
+ ),
16919
17037
  id,
16920
17038
  action,
16921
17039
  isShowLayout: false,
16922
17040
  useFormProps: {
16923
17041
  redirect: false
16924
17042
  },
16925
- rules: fieldsConfig == null ? void 0 : fieldsConfig.map((config2) => ({
17043
+ rules: fieldsConfig == null ? void 0 : fieldsConfig.filter((config2) => !config2.isSkipValidationInYaml).map((config2) => ({
16926
17044
  path: config2.path,
16927
17045
  validators: config2.validators
16928
17046
  })),
@@ -16990,51 +17108,45 @@ function YamlFormContainer({
16990
17108
  onSaveButtonPropsChange
16991
17109
  }) {
16992
17110
  const action = id ? "edit" : "create";
16993
- const {
16994
- transformInitValues,
16995
- transformApplyValues
16996
- } = usePathMap({
17111
+ const { transformInitValues, transformApplyValues } = usePathMap({
16997
17112
  pathMap: formConfig == null ? void 0 : formConfig.pathMap,
16998
17113
  transformInitValues: formConfig == null ? void 0 : formConfig.transformInitValues,
16999
17114
  transformApplyValues: (formConfig == null ? void 0 : formConfig.transformApplyValues) || ((v) => v)
17000
17115
  });
17001
- const yamlFormProps = React.useMemo(
17002
- () => {
17003
- return {
17004
- ...customYamlFormProps,
17005
- config,
17006
- transformInitValues,
17007
- transformApplyValues,
17008
- initialValuesForCreate: (customYamlFormProps == null ? void 0 : customYamlFormProps.initialValuesForCreate) || config.initValue,
17009
- initialValuesForEdit: void 0,
17010
- id,
17011
- action,
17012
- isShowLayout: false,
17013
- useFormProps: {
17014
- redirect: false
17015
- },
17016
- rules: void 0,
17017
- onSaveButtonPropsChange,
17018
- onErrorsChange(errors) {
17019
- if (errors.length) {
17020
- onError == null ? void 0 : onError();
17021
- }
17022
- },
17023
- onFinish: onSuccess
17024
- };
17025
- },
17026
- [
17027
- id,
17028
- action,
17029
- customYamlFormProps,
17116
+ const yamlFormProps = React.useMemo(() => {
17117
+ return {
17118
+ ...customYamlFormProps,
17030
17119
  config,
17031
17120
  transformInitValues,
17032
17121
  transformApplyValues,
17033
- onSuccess,
17034
- onError,
17035
- onSaveButtonPropsChange
17036
- ]
17037
- );
17122
+ initialValuesForCreate: (customYamlFormProps == null ? void 0 : customYamlFormProps.initialValuesForCreate) || config.initValue,
17123
+ initialValuesForEdit: void 0,
17124
+ id,
17125
+ action,
17126
+ isShowLayout: false,
17127
+ useFormProps: {
17128
+ redirect: false
17129
+ },
17130
+ rules: void 0,
17131
+ onSaveButtonPropsChange,
17132
+ onErrorsChange(errors) {
17133
+ if (errors.length) {
17134
+ onError == null ? void 0 : onError();
17135
+ }
17136
+ },
17137
+ onFinish: onSuccess
17138
+ };
17139
+ }, [
17140
+ id,
17141
+ action,
17142
+ customYamlFormProps,
17143
+ config,
17144
+ transformInitValues,
17145
+ transformApplyValues,
17146
+ onSuccess,
17147
+ onError,
17148
+ onSaveButtonPropsChange
17149
+ ]);
17038
17150
  return /* @__PURE__ */ common.jsxRuntimeExports.jsx(YamlForm, { ...yamlFormProps });
17039
17151
  }
17040
17152
  const FormModal_64brhp = "";
@@ -17074,7 +17186,8 @@ function FormModal(props) {
17074
17186
  const {
17075
17187
  resource: resourceFromProps,
17076
17188
  id,
17077
- yamlFormProps: customYamlFormProps
17189
+ yamlFormProps: customYamlFormProps,
17190
+ onSuccess
17078
17191
  } = props;
17079
17192
  const {
17080
17193
  i18n: i18n2
@@ -17153,9 +17266,10 @@ function FormModal(props) {
17153
17266
  onError: () => {
17154
17267
  setIsError(true);
17155
17268
  },
17156
- onSuccess: () => {
17269
+ onSuccess: (data2) => {
17157
17270
  setIsError(false);
17158
17271
  popModal();
17272
+ onSuccess == null ? void 0 : onSuccess(data2);
17159
17273
  }
17160
17274
  };
17161
17275
  if (config.formConfig && (((_a2 = config.formConfig) == null ? void 0 : _a2.formType) === FormType.FORM || "fields" in config.formConfig)) {
@@ -17169,7 +17283,7 @@ function FormModal(props) {
17169
17283
  ...commonFormProps,
17170
17284
  formConfig: config.formConfig
17171
17285
  });
17172
- }, [id, customYamlFormProps, config, isYamlMode, popModal, setSaveButtonProps]);
17286
+ }, [id, customYamlFormProps, config, isYamlMode, popModal, setSaveButtonProps, onSuccess]);
17173
17287
  return /* @__PURE__ */ common.jsxRuntimeExports.jsxs(eagle.Modal, {
17174
17288
  className: common.cx_default(FullscreenModalStyle),
17175
17289
  style: {
@@ -17342,6 +17456,7 @@ const EditLabelForm = React.forwardRef(
17342
17456
  const { resourceModel } = props;
17343
17457
  const { mutateAsync } = core.useUpdate();
17344
17458
  const { t: t2 } = common.useTranslation();
17459
+ const tableFormRef = React.useRef(null);
17345
17460
  const defaultValue = React.useMemo(() => {
17346
17461
  var _a2;
17347
17462
  return Object.keys(((_a2 = resourceModel.metadata) == null ? void 0 : _a2.labels) || {}).map((key2) => {
@@ -17383,10 +17498,20 @@ const EditLabelForm = React.forwardRef(
17383
17498
  },
17384
17499
  [resourceModel, mutateAsync, t2]
17385
17500
  );
17501
+ React.useImperativeHandle(
17502
+ ref,
17503
+ () => ({
17504
+ submit: () => {
17505
+ var _a2;
17506
+ return (_a2 = tableFormRef.current) == null ? void 0 : _a2.submit();
17507
+ }
17508
+ }),
17509
+ []
17510
+ );
17386
17511
  return /* @__PURE__ */ common.jsxRuntimeExports.jsx(
17387
- KeyValueTableFormForm,
17512
+ KeyValueTableForm,
17388
17513
  {
17389
- ref,
17514
+ ref: tableFormRef,
17390
17515
  defaultValue,
17391
17516
  onSubmit,
17392
17517
  addButtonText: t2("dovetail.add_label")
@@ -17429,6 +17554,7 @@ const EditAnnotationForm = React.forwardRef(function EditAnnotationForm2(props,
17429
17554
  const { resourceModel } = props;
17430
17555
  const { mutateAsync } = core.useUpdate();
17431
17556
  const { t: t2 } = common.useTranslation();
17557
+ const tableFormRef = React.useRef(null);
17432
17558
  const defaultValue = React.useMemo(() => {
17433
17559
  var _a2;
17434
17560
  return Object.keys(((_a2 = resourceModel.metadata) == null ? void 0 : _a2.annotations) || {}).map((key2) => {
@@ -17470,10 +17596,20 @@ const EditAnnotationForm = React.forwardRef(function EditAnnotationForm2(props,
17470
17596
  },
17471
17597
  [resourceModel, mutateAsync, t2]
17472
17598
  );
17599
+ React.useImperativeHandle(
17600
+ ref,
17601
+ () => ({
17602
+ submit: () => {
17603
+ var _a2;
17604
+ return (_a2 = tableFormRef.current) == null ? void 0 : _a2.submit();
17605
+ }
17606
+ }),
17607
+ []
17608
+ );
17473
17609
  return /* @__PURE__ */ common.jsxRuntimeExports.jsx(
17474
- KeyValueTableFormForm,
17610
+ KeyValueTableForm,
17475
17611
  {
17476
- ref,
17612
+ ref: tableFormRef,
17477
17613
  defaultValue,
17478
17614
  onSubmit,
17479
17615
  addButtonText: t2("dovetail.add_annotation"),
@@ -18816,6 +18952,7 @@ exports.EventsTab = EventsTab;
18816
18952
  exports.EventsTableTabField = EventsTableTabField;
18817
18953
  exports.FormContainerType = FormContainerType;
18818
18954
  exports.FormErrorAlert = FormErrorAlert;
18955
+ exports.FormItemLayout = FormItemLayout;
18819
18956
  exports.FormModal = FormModal;
18820
18957
  exports.FormMode = FormMode;
18821
18958
  exports.FormType = FormType;
@@ -18842,6 +18979,7 @@ exports.KeyValue = KeyValue;
18842
18979
  exports.KeyValueAnnotation = KeyValueAnnotation;
18843
18980
  exports.KeyValueListWidget = KeyValueListWidget;
18844
18981
  exports.KeyValueSecret = KeyValueSecret;
18982
+ exports.KeyValueTableForm = KeyValueTableForm;
18845
18983
  exports.LabelsField = LabelsField;
18846
18984
  exports.Layout = Layout;
18847
18985
  exports.ListPage = ListPage;
@@ -19029,3 +19167,6 @@ exports.useNamespacesFilter = useNamespacesFilter;
19029
19167
  exports.useOpenForm = useOpenForm;
19030
19168
  exports.useRefineForm = useRefineForm;
19031
19169
  exports.useSchema = useSchema;
19170
+ exports.validateDnsSubdomain = validateDnsSubdomain;
19171
+ exports.validateLabelKey = validateLabelKey;
19172
+ exports.validateLabelValue = validateLabelValue;