@dovetail-v2/refine 0.1.12 → 0.1.14-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12181,40 +12181,413 @@ var __publicField = (obj, key, value) => {
12181
12181
  })
12182
12182
  });
12183
12183
  }
12184
- const NodeTaintsTable = ({ taints = [] }) => {
12185
- const { t: t2 } = useTranslation();
12186
- const component = React.useContext(ComponentContext);
12187
- const Table2 = component.Table || Table$1;
12188
- const taintsWithId = addId(taints, "key");
12189
- const columns = [
12190
- {
12191
- key: "key",
12192
- display: true,
12193
- dataIndex: "key",
12194
- title: t2("dovetail.key"),
12195
- width: 120,
12196
- sortable: true
12197
- },
12198
- {
12199
- key: "value",
12200
- display: true,
12201
- dataIndex: "value",
12202
- title: t2("dovetail.value"),
12203
- width: 120,
12204
- sortable: true
12205
- },
12206
- {
12184
+ function validateLabelKey(key2) {
12185
+ const labelPrefixRegex = /(^[a-zA-Z0-9]$)|(^[a-zA-Z0-9][a-zA-Z0-9\.]*[a-zA-Z0-9]$)/;
12186
+ const labelNameRegex = /(^[a-zA-Z0-9]$)|(^[a-zA-Z0-9][a-zA-Z0-9\.\-]*[a-zA-Z0-9]$)/;
12187
+ let prefix, name2;
12188
+ const splitResult = key2.split("/");
12189
+ if (splitResult.length === 1) {
12190
+ name2 = splitResult[0];
12191
+ } else {
12192
+ prefix = splitResult[0];
12193
+ name2 = splitResult[1];
12194
+ }
12195
+ if (prefix === "") {
12196
+ return { isValid: false, errorMessage: "EMPTY_PREFIX" };
12197
+ }
12198
+ if (prefix && !labelPrefixRegex.test(prefix)) {
12199
+ return { isValid: false, errorMessage: "INVALID_PREFIX" };
12200
+ }
12201
+ if (!labelNameRegex.test(name2)) {
12202
+ return { isValid: false, errorMessage: "INVALID_NAME" };
12203
+ }
12204
+ if (prefix && prefix.length > 253) {
12205
+ return { isValid: false, errorMessage: "MAX_253" };
12206
+ }
12207
+ if (name2 && name2.length > 63) {
12208
+ return { isValid: false, errorMessage: "MAX_63" };
12209
+ }
12210
+ return { isValid: true };
12211
+ }
12212
+ function validateLabelValue(value2) {
12213
+ const labelValueRegex = /(^[a-zA-Z0-9]$)|(^[a-zA-Z0-9][a-zA-Z0-9\.\-]*[a-zA-Z0-9]$)/;
12214
+ if (value2 === "") {
12215
+ return { isValid: true };
12216
+ }
12217
+ if (value2.length > 63) {
12218
+ return { isValid: false, errorMessage: "MAX_63" };
12219
+ }
12220
+ if (!labelValueRegex.test(value2)) {
12221
+ return { isValid: false, errorMessage: "INVALID_VALUE" };
12222
+ }
12223
+ return { isValid: true };
12224
+ }
12225
+ const LabelFormatPopover_105yfzn = "";
12226
+ const PodLabelFormatRulePopoverStyle = "p5jt6nm";
12227
+ const LabelFormatPopover = () => {
12228
+ const {
12229
+ t: t2
12230
+ } = useTranslation();
12231
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Popover, {
12232
+ overlayClassName: PodLabelFormatRulePopoverStyle,
12233
+ placement: "bottomRight",
12234
+ content: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.AntdTable, {
12235
+ bordered: true,
12236
+ dataSource: [{
12237
+ object: t2("dovetail.key"),
12238
+ contains: t2("dovetail.suffix"),
12239
+ optional: t2("dovetail.no"),
12240
+ rule: [t2("dovetail.suffix_format_rule_1"), t2("dovetail.suffix_format_rule_2"), t2("dovetail.suffix_format_rule_3")]
12241
+ }, {
12242
+ object: t2("dovetail.key"),
12243
+ contains: t2("dovetail.name"),
12244
+ optional: t2("dovetail.yes"),
12245
+ rule: [t2("dovetail.name_format_rule_1"), t2("dovetail.name_format_rule_2"), t2("dovetail.name_format_rule_3")]
12246
+ }, {
12247
+ object: t2("dovetail.value"),
12248
+ contains: t2("dovetail.name"),
12249
+ optional: t2("dovetail.no"),
12250
+ rule: [t2("dovetail.name_format_rule_1"), t2("dovetail.name_format_rule_2"), t2("dovetail.name_format_rule_3")]
12251
+ }],
12252
+ columns: [{
12253
+ key: "object",
12254
+ title: t2("dovetail.object"),
12255
+ dataIndex: "object",
12256
+ render: (cell, record, index2) => {
12257
+ return {
12258
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
12259
+ className: eagle.Typo.Label.l4_bold,
12260
+ children: cell
12261
+ }),
12262
+ props: {
12263
+ rowSpan: index2 === 0 ? 2 : index2 === 1 ? 0 : 1
12264
+ }
12265
+ };
12266
+ }
12267
+ }, {
12268
+ key: "contains",
12269
+ title: t2("dovetail.contains"),
12270
+ dataIndex: "contains"
12271
+ }, {
12272
+ key: "optional",
12273
+ title: t2("dovetail.optional"),
12274
+ dataIndex: "optional"
12275
+ }, {
12276
+ key: "rule",
12277
+ title: t2("dovetail.format_requirements"),
12278
+ dataIndex: "rule",
12279
+ render: (cell) => {
12280
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("ul", {
12281
+ className: "rule-list",
12282
+ children: cell.map((rule2, index2) => /* @__PURE__ */ jsxRuntimeExports.jsx("li", {
12283
+ children: rule2
12284
+ }, index2))
12285
+ });
12286
+ }
12287
+ }],
12288
+ pagination: false
12289
+ }),
12290
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Button, {
12291
+ size: "small",
12292
+ type: "link",
12293
+ children: t2("dovetail.look_format_requirement")
12294
+ })
12295
+ });
12296
+ };
12297
+ const KeyValueTableForm_1eydq7y = "";
12298
+ function _KeyValueTableFormForm(props, ref) {
12299
+ const {
12300
+ defaultValue,
12301
+ onSubmit,
12302
+ extraColumns,
12303
+ addButtonText
12304
+ } = props;
12305
+ const {
12306
+ t: t2
12307
+ } = useTranslation();
12308
+ const [value2, setValue] = React.useState([]);
12309
+ const tableFormRef = React.useRef(null);
12310
+ React.useImperativeHandle(ref, () => ({
12311
+ submit: () => {
12312
+ return new Promise((res, rej) => {
12313
+ var _a;
12314
+ (_a = tableFormRef.current) == null ? void 0 : _a.validateWholeFields();
12315
+ setTimeout(() => {
12316
+ var _a2;
12317
+ const isValid = (_a2 = tableFormRef.current) == null ? void 0 : _a2.isValid();
12318
+ if (isValid) {
12319
+ res(onSubmit(value2));
12320
+ } else {
12321
+ rej();
12322
+ }
12323
+ }, 0);
12324
+ });
12325
+ }
12326
+ }), [onSubmit, value2]);
12327
+ const renderTextAreaFunc = ({
12328
+ value: value22,
12329
+ onChange
12330
+ }) => {
12331
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.TextArea, {
12332
+ autoSize: true,
12333
+ className: "clsjtk2",
12334
+ size: "small",
12335
+ value: value22,
12336
+ onChange: (e2) => {
12337
+ onChange(e2.target.value);
12338
+ }
12339
+ });
12340
+ };
12341
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(eagle.Space, {
12342
+ size: 8,
12343
+ direction: "vertical",
12344
+ className: "cq3mbby",
12345
+ children: [/* @__PURE__ */ jsxRuntimeExports.jsx(eagle.TableForm, {
12346
+ ref: tableFormRef,
12347
+ onBodyChange: (value22) => {
12348
+ setValue(value22);
12349
+ },
12350
+ columns: [{
12351
+ key: "key",
12352
+ title: t2("dovetail.key"),
12353
+ type: "input",
12354
+ validator: ({
12355
+ value: value22
12356
+ }) => {
12357
+ if (!value22)
12358
+ return t2("dovetail.key_empty_text");
12359
+ const {
12360
+ isValid
12361
+ } = validateLabelKey(value22 || "");
12362
+ if (!isValid)
12363
+ return t2("dovetail.format_error");
12364
+ },
12365
+ render: renderTextAreaFunc
12366
+ }, {
12367
+ key: "value",
12368
+ title: t2("dovetail.value_optional"),
12369
+ type: "input",
12370
+ validator: ({
12371
+ value: value22
12372
+ }) => {
12373
+ const {
12374
+ isValid
12375
+ } = validateLabelValue(value22 || "");
12376
+ if (!isValid)
12377
+ return t2("dovetail.format_error");
12378
+ },
12379
+ render: renderTextAreaFunc
12380
+ }, ...extraColumns || []],
12381
+ disableBatchFilling: true,
12382
+ hideEmptyTable: true,
12383
+ rowAddConfig: {
12384
+ addible: true,
12385
+ text: () => addButtonText
12386
+ },
12387
+ defaultData: defaultValue,
12388
+ row: {
12389
+ deletable: true
12390
+ }
12391
+ }), /* @__PURE__ */ jsxRuntimeExports.jsx(LabelFormatPopover, {})]
12392
+ });
12393
+ }
12394
+ const KeyValueTableFormForm = React.forwardRef(_KeyValueTableFormForm);
12395
+ const EditNodeTaintForm_cgov7z = "";
12396
+ const UlStyle = "u19jcs7t";
12397
+ const EditNodeTaintForm = React.forwardRef(function EditNodeTaintForm2(props, ref) {
12398
+ const {
12399
+ nodeModel
12400
+ } = props;
12401
+ const {
12402
+ mutateAsync
12403
+ } = core.useUpdate();
12404
+ const {
12405
+ t: t2
12406
+ } = useTranslation();
12407
+ const defaultValue = React.useMemo(() => {
12408
+ var _a;
12409
+ return ((_a = nodeModel._rawYaml.spec) == null ? void 0 : _a.taints) || [];
12410
+ }, [nodeModel]);
12411
+ const onSubmit = React.useCallback((_value) => {
12412
+ const value2 = _value;
12413
+ const newYaml = nodeModel._globalStore.restoreItem(nodeModel);
12414
+ if (newYaml.spec) {
12415
+ newYaml.spec.taints = value2;
12416
+ }
12417
+ pruneBeforeEdit(newYaml);
12418
+ return mutateAsync({
12419
+ id: nodeModel.id,
12420
+ resource: nodeModel.name || "",
12421
+ values: newYaml,
12422
+ meta: {
12423
+ resourceBasePath: nodeModel.apiVersion,
12424
+ kind: nodeModel.kind
12425
+ },
12426
+ successNotification() {
12427
+ return {
12428
+ message: t2("dovetail.edit_node_taint_success_toast", {
12429
+ kind: nodeModel.kind,
12430
+ name: nodeModel.metadata.name,
12431
+ interpolation: {
12432
+ escapeValue: false
12433
+ }
12434
+ }),
12435
+ type: "success"
12436
+ };
12437
+ },
12438
+ errorNotification: false
12439
+ });
12440
+ }, [nodeModel, mutateAsync, t2]);
12441
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(KeyValueTableFormForm, {
12442
+ ref,
12443
+ defaultValue,
12444
+ onSubmit,
12445
+ addButtonText: t2("dovetail.add_taint"),
12446
+ extraColumns: [{
12207
12447
  key: "effect",
12208
- display: true,
12209
- dataIndex: "effect",
12210
12448
  title: t2("dovetail.effect"),
12211
- width: 120,
12212
- sortable: true,
12213
- render: (value2) => {
12214
- return t2(`dovetail.node_taint_${value2}`);
12449
+ render: ({
12450
+ value: value2,
12451
+ onChange
12452
+ }) => {
12453
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Select, {
12454
+ input: {},
12455
+ value: value2,
12456
+ onChange,
12457
+ size: "small",
12458
+ children: eagle.getOptions([{
12459
+ value: "NoSchedule",
12460
+ children: t2(`dovetail.node_taint_${"NoSchedule"}`),
12461
+ suffix: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Tooltip, {
12462
+ title: /* @__PURE__ */ jsxRuntimeExports.jsx(TaintEffectTooltip, {
12463
+ effect: "NoSchedule"
12464
+ /* NoSchedule */
12465
+ }),
12466
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Icon, {
12467
+ src: iconsReact.InfoICircleFill16GrayIcon,
12468
+ hoverSrc: iconsReact.InfoICircleFill16Gray70Icon
12469
+ })
12470
+ })
12471
+ }, {
12472
+ value: "PreferNoSchedule",
12473
+ children: t2(`dovetail.node_taint_${"PreferNoSchedule"}`),
12474
+ suffix: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Tooltip, {
12475
+ title: /* @__PURE__ */ jsxRuntimeExports.jsx(TaintEffectTooltip, {
12476
+ effect: "PreferNoSchedule"
12477
+ /* PreferNoSchedule */
12478
+ }),
12479
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Icon, {
12480
+ src: iconsReact.InfoICircleFill16GrayIcon,
12481
+ hoverSrc: iconsReact.InfoICircleFill16Gray70Icon
12482
+ })
12483
+ })
12484
+ }, {
12485
+ value: "NoExecute",
12486
+ children: t2(`dovetail.node_taint_${"NoExecute"}`),
12487
+ suffix: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Tooltip, {
12488
+ title: /* @__PURE__ */ jsxRuntimeExports.jsx(TaintEffectTooltip, {
12489
+ effect: "NoExecute"
12490
+ /* NoExecute */
12491
+ }),
12492
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Icon, {
12493
+ src: iconsReact.InfoICircleFill16GrayIcon,
12494
+ hoverSrc: iconsReact.InfoICircleFill16Gray70Icon
12495
+ })
12496
+ })
12497
+ }])
12498
+ });
12499
+ },
12500
+ validator: ({
12501
+ value: value2
12502
+ }) => {
12503
+ if (!value2)
12504
+ return t2("dovetail.taint_effect_empty_text");
12215
12505
  }
12506
+ }]
12507
+ });
12508
+ });
12509
+ const TaintEffectTooltip = ({
12510
+ effect: effect2
12511
+ }) => {
12512
+ const {
12513
+ t: t2
12514
+ } = useTranslation();
12515
+ const TaintEffectTooltipTextConfig = {
12516
+ [
12517
+ "NoSchedule"
12518
+ /* NoSchedule */
12519
+ ]: {
12520
+ title: "NoSchedule",
12521
+ tooltips: [t2("dovetail.taint_effect_NoSchedule_tooltip_1"), t2("dovetail.taint_effect_NoSchedule_tooltip_2")]
12522
+ },
12523
+ [
12524
+ "PreferNoSchedule"
12525
+ /* PreferNoSchedule */
12526
+ ]: {
12527
+ title: "PreferNoSchedule",
12528
+ tooltips: [t2("dovetail.taint_effect_PreferNoSchedule_tooltip_1"), t2("dovetail.taint_effect_PreferNoSchedule_tooltip_2"), t2("dovetail.taint_effect_PreferNoSchedule_tooltip_3")]
12529
+ },
12530
+ [
12531
+ "NoExecute"
12532
+ /* NoExecute */
12533
+ ]: {
12534
+ title: "NoExecute",
12535
+ tooltips: [t2("dovetail.taint_effect_NoExecute_tooltip_3")]
12536
+ }
12537
+ };
12538
+ const config = TaintEffectTooltipTextConfig[effect2];
12539
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
12540
+ children: [/* @__PURE__ */ jsxRuntimeExports.jsx("b", {
12541
+ children: config.title
12542
+ }), /* @__PURE__ */ jsxRuntimeExports.jsx("ul", {
12543
+ className: UlStyle,
12544
+ children: config.tooltips.map((tooltip, index2) => /* @__PURE__ */ jsxRuntimeExports.jsx("li", {
12545
+ children: tooltip
12546
+ }, index2))
12547
+ })]
12548
+ });
12549
+ };
12550
+ const NodeTaintsTable_wrxeox = "";
12551
+ const EffectStyle = "evoxbc1";
12552
+ const NodeTaintsTable = ({
12553
+ taints = []
12554
+ }) => {
12555
+ const {
12556
+ t: t2
12557
+ } = useTranslation();
12558
+ const component = React.useContext(ComponentContext);
12559
+ const Table2 = component.Table || Table$1;
12560
+ const taintsWithId = addId(taints, "key");
12561
+ const columns = [{
12562
+ key: "key",
12563
+ display: true,
12564
+ dataIndex: "key",
12565
+ title: t2("dovetail.key"),
12566
+ sortable: true
12567
+ }, {
12568
+ key: "value",
12569
+ display: true,
12570
+ dataIndex: "value",
12571
+ title: t2("dovetail.value"),
12572
+ sortable: true
12573
+ }, {
12574
+ key: "effect",
12575
+ display: true,
12576
+ dataIndex: "effect",
12577
+ title: t2("dovetail.effect"),
12578
+ sortable: true,
12579
+ render: (value2) => {
12580
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Tooltip, {
12581
+ title: /* @__PURE__ */ jsxRuntimeExports.jsx(TaintEffectTooltip, {
12582
+ effect: value2
12583
+ }),
12584
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
12585
+ className: EffectStyle,
12586
+ children: t2(`dovetail.node_taint_${value2}`)
12587
+ })
12588
+ });
12216
12589
  }
12217
- ];
12590
+ }];
12218
12591
  const {
12219
12592
  data: finalData,
12220
12593
  currentPage,
@@ -12223,40 +12596,34 @@ var __publicField = (obj, key, value) => {
12223
12596
  } = useTableData({
12224
12597
  data: taintsWithId,
12225
12598
  columns,
12226
- defaultSorters: [
12227
- {
12228
- field: "lastUpdateTime",
12229
- order: "desc"
12230
- }
12231
- ]
12599
+ defaultSorters: [{
12600
+ field: "lastUpdateTime",
12601
+ order: "desc"
12602
+ }]
12232
12603
  });
12233
12604
  const currentSize = 10;
12234
12605
  if (taintsWithId.length === 0) {
12235
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
12236
- WidgetErrorContent,
12237
- {
12238
- errorText: t2("dovetail.no_resource", { kind: t2("dovetail.taint") }),
12239
- type: ErrorContentType.Card
12240
- }
12241
- );
12606
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(WidgetErrorContent, {
12607
+ errorText: t2("dovetail.no_resource", {
12608
+ kind: t2("dovetail.taint")
12609
+ }),
12610
+ type: ErrorContentType.Card
12611
+ });
12242
12612
  }
12243
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
12244
- Table2,
12245
- {
12246
- tableKey: "condition",
12247
- loading: false,
12248
- data: finalData,
12249
- total: taintsWithId.length,
12250
- columns: addDefaultRenderToColumns(columns),
12251
- rowKey: "key",
12252
- empty: t2("dovetail.empty"),
12253
- defaultSize: currentSize,
12254
- currentPage,
12255
- onPageChange,
12256
- onSorterChange,
12257
- showMenuColumn: false
12258
- }
12259
- );
12613
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Table2, {
12614
+ tableKey: "condition",
12615
+ loading: false,
12616
+ data: finalData,
12617
+ total: taintsWithId.length,
12618
+ columns: addDefaultRenderToColumns(columns),
12619
+ rowKey: "key",
12620
+ empty: t2("dovetail.empty"),
12621
+ defaultSize: currentSize,
12622
+ currentPage,
12623
+ onPageChange,
12624
+ onSorterChange,
12625
+ showMenuColumn: false
12626
+ });
12260
12627
  };
12261
12628
  function PVVolumeModeDisplay(props) {
12262
12629
  const { value: value2 } = props;
@@ -32788,7 +33155,7 @@ WARNING: This link could potentially be dangerous`)) {
32788
33155
  });
32789
33156
  }
32790
33157
  }, [encode, send, props.fit]);
32791
- const debouncedFit = React.useCallback(() => lodashEs.debounce(fit, 200), [fit]);
33158
+ const debouncedFit = React.useMemo(() => lodashEs.debounce(fit, 200), [fit]);
32792
33159
  const flush = React.useCallback(() => {
32793
33160
  const backlog = backlogRef.current.slice();
32794
33161
  backlogRef.current = [];
@@ -39023,267 +39390,56 @@ WARNING: This link could potentially be dangerous`)) {
39023
39390
  }
39024
39391
  function CronJobDropdown(props) {
39025
39392
  const { record, size } = props;
39026
- const { spec } = record;
39027
- const { resource } = core.useResource();
39028
- const { mutateAsync } = core.useUpdate();
39029
- const { t: t2 } = useTranslation();
39030
- const { data: canEditData } = core.useCan({
39031
- resource: resource == null ? void 0 : resource.name,
39032
- action: AccessControlAuth.Edit
39033
- });
39034
- const suspended2 = Boolean(spec == null ? void 0 : spec.suspend);
39035
- return /* @__PURE__ */ jsxRuntimeExports.jsx(K8sDropdown, { record, size, children: (canEditData == null ? void 0 : canEditData.can) !== false ? /* @__PURE__ */ jsxRuntimeExports.jsx(
39036
- eagle.Menu.Item,
39037
- {
39038
- onClick: async () => {
39039
- const v = suspended2 ? record.resume() : record.suspend();
39040
- const id = record.id;
39041
- pruneBeforeEdit(v);
39042
- await mutateAsync({
39043
- id,
39044
- resource: (resource == null ? void 0 : resource.name) || "",
39045
- values: v,
39046
- successNotification() {
39047
- return {
39048
- message: t2(suspended2 ? "dovetail.resume_success_toast" : "dovetail.pause_success_toast", {
39049
- kind: record.kind,
39050
- name: id,
39051
- interpolation: {
39052
- escapeValue: false
39053
- }
39054
- }),
39055
- type: "success"
39056
- };
39057
- },
39058
- errorNotification() {
39059
- return {
39060
- message: t2(suspended2 ? "dovetail.resume_failed_toast" : "dovetail.pause_failed_toast", {
39061
- kind: record.kind,
39062
- name: id,
39063
- interpolation: {
39064
- escapeValue: false
39065
- }
39066
- }),
39067
- type: "error"
39068
- };
39069
- }
39070
- });
39071
- },
39072
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Icon, { src: suspended2 ? iconsReact.RecoverContinue16GradientBlueIcon : iconsReact.Pause16GradientBlueIcon, children: t2(suspended2 ? "dovetail.resume" : "dovetail.suspend") })
39073
- }
39074
- ) : null });
39075
- }
39076
- function validateLabelKey(key2) {
39077
- const labelPrefixRegex = /(^[a-zA-Z0-9]$)|(^[a-zA-Z0-9][a-zA-Z0-9\.]*[a-zA-Z0-9]$)/;
39078
- const labelNameRegex = /(^[a-zA-Z0-9]$)|(^[a-zA-Z0-9][a-zA-Z0-9\.\-]*[a-zA-Z0-9]$)/;
39079
- let prefix, name2;
39080
- const splitResult = key2.split("/");
39081
- if (splitResult.length === 1) {
39082
- name2 = splitResult[0];
39083
- } else {
39084
- prefix = splitResult[0];
39085
- name2 = splitResult[1];
39086
- }
39087
- if (prefix === "") {
39088
- return { isValid: false, errorMessage: "EMPTY_PREFIX" };
39089
- }
39090
- if (prefix && !labelPrefixRegex.test(prefix)) {
39091
- return { isValid: false, errorMessage: "INVALID_PREFIX" };
39092
- }
39093
- if (!labelNameRegex.test(name2)) {
39094
- return { isValid: false, errorMessage: "INVALID_NAME" };
39095
- }
39096
- if (prefix && prefix.length > 253) {
39097
- return { isValid: false, errorMessage: "MAX_253" };
39098
- }
39099
- if (name2 && name2.length > 63) {
39100
- return { isValid: false, errorMessage: "MAX_63" };
39101
- }
39102
- return { isValid: true };
39103
- }
39104
- function validateLabelValue(value2) {
39105
- const labelValueRegex = /(^[a-zA-Z0-9]$)|(^[a-zA-Z0-9][a-zA-Z0-9\.\-]*[a-zA-Z0-9]$)/;
39106
- if (value2 === "") {
39107
- return { isValid: true };
39108
- }
39109
- if (value2.length > 63) {
39110
- return { isValid: false, errorMessage: "MAX_63" };
39111
- }
39112
- if (!labelValueRegex.test(value2)) {
39113
- return { isValid: false, errorMessage: "INVALID_VALUE" };
39114
- }
39115
- return { isValid: true };
39116
- }
39117
- const LabelFormatPopover_105yfzn = "";
39118
- const PodLabelFormatRulePopoverStyle = "p5jt6nm";
39119
- const LabelFormatPopover = () => {
39120
- const {
39121
- t: t2
39122
- } = useTranslation();
39123
- return /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Popover, {
39124
- overlayClassName: PodLabelFormatRulePopoverStyle,
39125
- placement: "bottomRight",
39126
- content: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.AntdTable, {
39127
- bordered: true,
39128
- dataSource: [{
39129
- object: t2("dovetail.key"),
39130
- contains: t2("dovetail.suffix"),
39131
- optional: t2("dovetail.no"),
39132
- rule: [t2("dovetail.suffix_format_rule_1"), t2("dovetail.suffix_format_rule_2"), t2("dovetail.suffix_format_rule_3")]
39133
- }, {
39134
- object: t2("dovetail.key"),
39135
- contains: t2("dovetail.name"),
39136
- optional: t2("dovetail.yes"),
39137
- rule: [t2("dovetail.name_format_rule_1"), t2("dovetail.name_format_rule_2"), t2("dovetail.name_format_rule_3")]
39138
- }, {
39139
- object: t2("dovetail.value"),
39140
- contains: t2("dovetail.name"),
39141
- optional: t2("dovetail.no"),
39142
- rule: [t2("dovetail.name_format_rule_1"), t2("dovetail.name_format_rule_2"), t2("dovetail.name_format_rule_3")]
39143
- }],
39144
- columns: [{
39145
- key: "object",
39146
- title: t2("dovetail.object"),
39147
- dataIndex: "object",
39148
- render: (cell, record, index2) => {
39149
- return {
39150
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
39151
- className: eagle.Typo.Label.l4_bold,
39152
- children: cell
39153
- }),
39154
- props: {
39155
- rowSpan: index2 === 0 ? 2 : index2 === 1 ? 0 : 1
39156
- }
39157
- };
39158
- }
39159
- }, {
39160
- key: "contains",
39161
- title: t2("dovetail.contains"),
39162
- dataIndex: "contains"
39163
- }, {
39164
- key: "optional",
39165
- title: t2("dovetail.optional"),
39166
- dataIndex: "optional"
39167
- }, {
39168
- key: "rule",
39169
- title: t2("dovetail.format_requirements"),
39170
- dataIndex: "rule",
39171
- render: (cell) => {
39172
- return /* @__PURE__ */ jsxRuntimeExports.jsx("ul", {
39173
- className: "rule-list",
39174
- children: cell.map((rule2, index2) => /* @__PURE__ */ jsxRuntimeExports.jsx("li", {
39175
- children: rule2
39176
- }, index2))
39177
- });
39178
- }
39179
- }],
39180
- pagination: false
39181
- }),
39182
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Button, {
39183
- size: "small",
39184
- type: "link",
39185
- children: t2("dovetail.look_format_requirement")
39186
- })
39187
- });
39188
- };
39189
- const KeyValueTableForm_1eydq7y = "";
39190
- function _KeyValueTableFormForm(props, ref) {
39191
- const {
39192
- defaultValue,
39193
- onSubmit,
39194
- extraColumns,
39195
- addButtonText
39196
- } = props;
39197
- const {
39198
- t: t2
39199
- } = useTranslation();
39200
- const [value2, setValue] = React.useState([]);
39201
- const tableFormRef = React.useRef(null);
39202
- React.useImperativeHandle(ref, () => ({
39203
- submit: () => {
39204
- return new Promise((res, rej) => {
39205
- var _a;
39206
- (_a = tableFormRef.current) == null ? void 0 : _a.validateWholeFields();
39207
- setTimeout(() => {
39208
- var _a2;
39209
- const isValid = (_a2 = tableFormRef.current) == null ? void 0 : _a2.isValid();
39210
- if (isValid) {
39211
- res(onSubmit(value2));
39212
- } else {
39213
- rej();
39393
+ const { spec } = record;
39394
+ const { resource } = core.useResource();
39395
+ const { mutateAsync } = core.useUpdate();
39396
+ const { t: t2 } = useTranslation();
39397
+ const { data: canEditData } = core.useCan({
39398
+ resource: resource == null ? void 0 : resource.name,
39399
+ action: AccessControlAuth.Edit
39400
+ });
39401
+ const suspended2 = Boolean(spec == null ? void 0 : spec.suspend);
39402
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(K8sDropdown, { record, size, children: (canEditData == null ? void 0 : canEditData.can) !== false ? /* @__PURE__ */ jsxRuntimeExports.jsx(
39403
+ eagle.Menu.Item,
39404
+ {
39405
+ onClick: async () => {
39406
+ const v = suspended2 ? record.resume() : record.suspend();
39407
+ const id = record.id;
39408
+ pruneBeforeEdit(v);
39409
+ await mutateAsync({
39410
+ id,
39411
+ resource: (resource == null ? void 0 : resource.name) || "",
39412
+ values: v,
39413
+ successNotification() {
39414
+ return {
39415
+ message: t2(suspended2 ? "dovetail.resume_success_toast" : "dovetail.pause_success_toast", {
39416
+ kind: record.kind,
39417
+ name: id,
39418
+ interpolation: {
39419
+ escapeValue: false
39420
+ }
39421
+ }),
39422
+ type: "success"
39423
+ };
39424
+ },
39425
+ errorNotification() {
39426
+ return {
39427
+ message: t2(suspended2 ? "dovetail.resume_failed_toast" : "dovetail.pause_failed_toast", {
39428
+ kind: record.kind,
39429
+ name: id,
39430
+ interpolation: {
39431
+ escapeValue: false
39432
+ }
39433
+ }),
39434
+ type: "error"
39435
+ };
39214
39436
  }
39215
- }, 0);
39216
- });
39217
- }
39218
- }), [onSubmit, value2]);
39219
- const renderTextAreaFunc = ({
39220
- value: value22,
39221
- onChange
39222
- }) => {
39223
- return /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.TextArea, {
39224
- autoSize: true,
39225
- className: "clsjtk2",
39226
- size: "small",
39227
- value: value22,
39228
- onChange: (e2) => {
39229
- onChange(e2.target.value);
39230
- }
39231
- });
39232
- };
39233
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(eagle.Space, {
39234
- size: 8,
39235
- direction: "vertical",
39236
- className: "cq3mbby",
39237
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx(eagle.TableForm, {
39238
- ref: tableFormRef,
39239
- onBodyChange: (value22) => {
39240
- setValue(value22);
39241
- },
39242
- columns: [{
39243
- key: "key",
39244
- title: t2("dovetail.key"),
39245
- type: "input",
39246
- validator: ({
39247
- value: value22
39248
- }) => {
39249
- if (!value22)
39250
- return t2("dovetail.key_empty_text");
39251
- const {
39252
- isValid
39253
- } = validateLabelKey(value22 || "");
39254
- if (!isValid)
39255
- return t2("dovetail.format_error");
39256
- },
39257
- render: renderTextAreaFunc
39258
- }, {
39259
- key: "value",
39260
- title: t2("dovetail.value_optional"),
39261
- type: "input",
39262
- validator: ({
39263
- value: value22
39264
- }) => {
39265
- const {
39266
- isValid
39267
- } = validateLabelValue(value22 || "");
39268
- if (!isValid)
39269
- return t2("dovetail.format_error");
39270
- },
39271
- render: renderTextAreaFunc
39272
- }, ...extraColumns || []],
39273
- disableBatchFilling: true,
39274
- hideEmptyTable: true,
39275
- rowAddConfig: {
39276
- addible: true,
39277
- text: () => addButtonText
39437
+ });
39278
39438
  },
39279
- defaultData: defaultValue,
39280
- row: {
39281
- deletable: true
39282
- }
39283
- }), /* @__PURE__ */ jsxRuntimeExports.jsx(LabelFormatPopover, {})]
39284
- });
39439
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Icon, { src: suspended2 ? iconsReact.RecoverContinue16GradientBlueIcon : iconsReact.Pause16GradientBlueIcon, children: t2(suspended2 ? "dovetail.resume" : "dovetail.suspend") })
39440
+ }
39441
+ ) : null });
39285
39442
  }
39286
- const KeyValueTableFormForm = React.forwardRef(_KeyValueTableFormForm);
39287
39443
  const EditLabelForm = React.forwardRef(
39288
39444
  function EditLabelForm2(props, ref) {
39289
39445
  var _a;
@@ -39348,26 +39504,23 @@ WARNING: This link could potentially be dangerous`)) {
39348
39504
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
39349
39505
  eagle.Menu.Item,
39350
39506
  {
39507
+ ...props,
39351
39508
  className: "ant-dropdown-menu-item",
39352
- onClick: () => {
39509
+ onClick: (e2) => {
39510
+ var _a;
39353
39511
  const modalProps = {
39354
39512
  formRef,
39355
39513
  title: t2("dovetail.edit_label"),
39356
39514
  fullscreen: true,
39357
39515
  renderContent() {
39358
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
39359
- EditLabelForm,
39360
- {
39361
- ref: formRef,
39362
- resourceModel
39363
- }
39364
- );
39516
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(EditLabelForm, { ref: formRef, resourceModel });
39365
39517
  }
39366
39518
  };
39367
39519
  pushModal({
39368
39520
  component: EditFieldModal,
39369
39521
  props: modalProps
39370
39522
  });
39523
+ (_a = props.onClick) == null ? void 0 : _a.call(props, e2);
39371
39524
  },
39372
39525
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Icon, { src: iconsReact.EditPen16BlueIcon, children: t2("dovetail.edit_label") })
39373
39526
  }
@@ -39435,172 +39588,28 @@ WARNING: This link could potentially be dangerous`)) {
39435
39588
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
39436
39589
  eagle.Menu.Item,
39437
39590
  {
39591
+ ...props,
39438
39592
  className: "ant-dropdown-menu-item",
39439
- onClick: () => {
39593
+ onClick: (e2) => {
39594
+ var _a;
39440
39595
  const modalProps = {
39441
39596
  formRef,
39442
39597
  title: t2("dovetail.edit_annotation"),
39443
39598
  fullscreen: true,
39444
39599
  renderContent() {
39445
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
39446
- EditAnnotationForm,
39447
- {
39448
- ref: formRef,
39449
- resourceModel
39450
- }
39451
- );
39600
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(EditAnnotationForm, { ref: formRef, resourceModel });
39452
39601
  }
39453
39602
  };
39454
39603
  pushModal({
39455
39604
  component: EditFieldModal,
39456
39605
  props: modalProps
39457
39606
  });
39607
+ (_a = props.onClick) == null ? void 0 : _a.call(props, e2);
39458
39608
  },
39459
39609
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Icon, { src: iconsReact.EditPen16BlueIcon, children: t2("dovetail.edit_annotation") })
39460
39610
  }
39461
39611
  );
39462
39612
  }
39463
- const EditNodeTaintForm_cgov7z = "";
39464
- const UlStyle = "u19jcs7t";
39465
- const EditNodeTaintForm = React.forwardRef(function EditNodeTaintForm2(props, ref) {
39466
- const {
39467
- nodeModel
39468
- } = props;
39469
- const {
39470
- mutateAsync
39471
- } = core.useUpdate();
39472
- const {
39473
- t: t2
39474
- } = useTranslation();
39475
- const defaultValue = React.useMemo(() => {
39476
- var _a;
39477
- return ((_a = nodeModel._rawYaml.spec) == null ? void 0 : _a.taints) || [];
39478
- }, [nodeModel]);
39479
- const onSubmit = React.useCallback((_value) => {
39480
- const value2 = _value;
39481
- const newYaml = nodeModel._globalStore.restoreItem(nodeModel);
39482
- if (newYaml.spec) {
39483
- newYaml.spec.taints = value2;
39484
- }
39485
- pruneBeforeEdit(newYaml);
39486
- return mutateAsync({
39487
- id: nodeModel.id,
39488
- resource: nodeModel.name || "",
39489
- values: newYaml,
39490
- meta: {
39491
- resourceBasePath: nodeModel.apiVersion,
39492
- kind: nodeModel.kind
39493
- },
39494
- successNotification() {
39495
- return {
39496
- message: t2("dovetail.edit_node_taint_success_toast", {
39497
- kind: nodeModel.kind,
39498
- name: nodeModel.metadata.name,
39499
- interpolation: {
39500
- escapeValue: false
39501
- }
39502
- }),
39503
- type: "success"
39504
- };
39505
- },
39506
- errorNotification: false
39507
- });
39508
- }, [nodeModel, mutateAsync, t2]);
39509
- const noScheduleTooltip = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
39510
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx("b", {
39511
- children: "NoSchedule"
39512
- }), /* @__PURE__ */ jsxRuntimeExports.jsxs("ul", {
39513
- className: UlStyle,
39514
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx("li", {
39515
- children: t2("dovetail.taint_effect_NoSchedule_tooltip_1")
39516
- }), /* @__PURE__ */ jsxRuntimeExports.jsx("li", {
39517
- children: t2("dovetail.taint_effect_NoSchedule_tooltip_2")
39518
- })]
39519
- })]
39520
- });
39521
- const preferNoScheduleTooltip = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
39522
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx("b", {
39523
- children: "PreferNoSchedule"
39524
- }), /* @__PURE__ */ jsxRuntimeExports.jsxs("ul", {
39525
- className: UlStyle,
39526
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx("li", {
39527
- children: t2("dovetail.taint_effect_PreferNoSchedule_tooltip_1")
39528
- }), /* @__PURE__ */ jsxRuntimeExports.jsx("li", {
39529
- children: t2("dovetail.taint_effect_PreferNoSchedule_tooltip_2")
39530
- }), /* @__PURE__ */ jsxRuntimeExports.jsx("li", {
39531
- children: t2("dovetail.taint_effect_PreferNoSchedule_tooltip_3")
39532
- })]
39533
- })]
39534
- });
39535
- const noExecuteTooltip = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
39536
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx("b", {
39537
- children: "NoExecute"
39538
- }), /* @__PURE__ */ jsxRuntimeExports.jsx("ul", {
39539
- className: UlStyle,
39540
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("li", {
39541
- children: t2("dovetail.taint_effect_NoExecute_tooltip_3")
39542
- })
39543
- })]
39544
- });
39545
- return /* @__PURE__ */ jsxRuntimeExports.jsx(KeyValueTableFormForm, {
39546
- ref,
39547
- defaultValue,
39548
- onSubmit,
39549
- addButtonText: t2("dovetail.add_taint"),
39550
- extraColumns: [{
39551
- key: "effect",
39552
- title: t2("dovetail.effect"),
39553
- render: ({
39554
- value: value2,
39555
- onChange
39556
- }) => {
39557
- return /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Select, {
39558
- input: {},
39559
- value: value2,
39560
- onChange,
39561
- size: "small",
39562
- children: eagle.getOptions([{
39563
- value: "NoSchedule",
39564
- children: t2(`dovetail.node_taint_${"NoSchedule"}`),
39565
- suffix: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Tooltip, {
39566
- title: noScheduleTooltip,
39567
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Icon, {
39568
- src: iconsReact.InfoICircleFill16GrayIcon,
39569
- hoverSrc: iconsReact.InfoICircleFill16Gray70Icon
39570
- })
39571
- })
39572
- }, {
39573
- value: "PreferNoSchedule",
39574
- children: t2(`dovetail.node_taint_${"PreferNoSchedule"}`),
39575
- suffix: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Tooltip, {
39576
- title: preferNoScheduleTooltip,
39577
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Icon, {
39578
- src: iconsReact.InfoICircleFill16GrayIcon,
39579
- hoverSrc: iconsReact.InfoICircleFill16Gray70Icon
39580
- })
39581
- })
39582
- }, {
39583
- value: "NoExecute",
39584
- children: t2(`dovetail.node_taint_${"NoExecute"}`),
39585
- suffix: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Tooltip, {
39586
- title: noExecuteTooltip,
39587
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Icon, {
39588
- src: iconsReact.InfoICircleFill16GrayIcon,
39589
- hoverSrc: iconsReact.InfoICircleFill16Gray70Icon
39590
- })
39591
- })
39592
- }])
39593
- });
39594
- },
39595
- validator: ({
39596
- value: value2
39597
- }) => {
39598
- if (!value2)
39599
- return t2("dovetail.taint_effect_empty_text");
39600
- }
39601
- }]
39602
- });
39603
- });
39604
39613
  function EditNodeTaintDropdownMenuItem(props) {
39605
39614
  const { formRef, resourceModel } = props;
39606
39615
  const { t: t2 } = useTranslation();
@@ -39608,26 +39617,23 @@ WARNING: This link could potentially be dangerous`)) {
39608
39617
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
39609
39618
  eagle.Menu.Item,
39610
39619
  {
39620
+ ...props,
39611
39621
  className: "ant-dropdown-menu-item",
39612
- onClick: () => {
39622
+ onClick: (e2) => {
39623
+ var _a;
39613
39624
  const modalProps = {
39614
39625
  formRef,
39615
39626
  title: t2("dovetail.edit_node_taint"),
39616
39627
  fullscreen: true,
39617
39628
  renderContent() {
39618
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
39619
- EditNodeTaintForm,
39620
- {
39621
- ref: formRef,
39622
- nodeModel: resourceModel
39623
- }
39624
- );
39629
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(EditNodeTaintForm, { ref: formRef, nodeModel: resourceModel });
39625
39630
  }
39626
39631
  };
39627
39632
  pushModal({
39628
39633
  component: EditFieldModal,
39629
39634
  props: modalProps
39630
39635
  });
39636
+ (_a = props.onClick) == null ? void 0 : _a.call(props, e2);
39631
39637
  },
39632
39638
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Icon, { src: iconsReact.EditPen16BlueIcon, children: t2("dovetail.edit_node_taint") })
39633
39639
  }