mirror of https://github.com/halo-dev/halo
Refactor attachment policy form (#7790)
#### What type of PR is this? /area ui /milestone 2.22.x #### What this PR does / why we need it: Refactored AttachmentPolicyEditingModal.vue to group policy config fields under a 'config' group and improved the update logic to use JSON patch for displayName #### Does this PR introduce a user-facing change? ```release-note None ```pull/7792/head
parent
41005f2c0e
commit
838b97b812
|
@ -112,9 +112,8 @@ const isSubmitting = ref(false);
|
|||
|
||||
const handleSave = async (data: {
|
||||
displayName: string;
|
||||
[key: string]: unknown;
|
||||
config: Record<string, unknown>;
|
||||
}) => {
|
||||
console.log(data);
|
||||
try {
|
||||
isSubmitting.value = true;
|
||||
if (isUpdateMode.value) {
|
||||
|
@ -125,18 +124,18 @@ const handleSave = async (data: {
|
|||
await consoleApiClient.storage.policy.updatePolicyConfigByGroup({
|
||||
name: policy.value.metadata.name,
|
||||
group: CONFIG_MAP_GROUP,
|
||||
body: data,
|
||||
body: data.config,
|
||||
});
|
||||
|
||||
await coreApiClient.storage.policy.updatePolicy({
|
||||
await coreApiClient.storage.policy.patchPolicy({
|
||||
name: policy.value.metadata.name,
|
||||
policy: {
|
||||
...policy.value,
|
||||
spec: {
|
||||
...policy.value.spec,
|
||||
displayName: data.displayName,
|
||||
},
|
||||
jsonPatchInner: [
|
||||
{
|
||||
op: "add",
|
||||
path: "/spec/displayName",
|
||||
value: data.displayName,
|
||||
},
|
||||
],
|
||||
});
|
||||
} else {
|
||||
const { data: policies } =
|
||||
|
@ -157,7 +156,7 @@ const handleSave = async (data: {
|
|||
await coreApiClient.configMap.createConfigMap({
|
||||
configMap: {
|
||||
data: {
|
||||
[CONFIG_MAP_GROUP]: JSON.stringify(data),
|
||||
[CONFIG_MAP_GROUP]: JSON.stringify(data.config || {}),
|
||||
},
|
||||
apiVersion: "v1alpha1",
|
||||
kind: "ConfigMap",
|
||||
|
@ -207,16 +206,14 @@ const modalTitle = props.policy
|
|||
ref="modal"
|
||||
mount-to-body
|
||||
:title="modalTitle"
|
||||
:width="600"
|
||||
:width="650"
|
||||
@close="emit('close')"
|
||||
>
|
||||
<div>
|
||||
<VLoading v-if="isLoading" />
|
||||
<template v-else>
|
||||
<FormKit
|
||||
v-if="formSchema && configMapGroupData"
|
||||
id="attachment-policy-form"
|
||||
:value="toRaw(configMapGroupData) || {}"
|
||||
name="attachment-policy-form"
|
||||
:preserve="true"
|
||||
type="form"
|
||||
|
@ -235,11 +232,21 @@ const modalTitle = props.policy
|
|||
name="displayName"
|
||||
validation="required|length:0,50"
|
||||
></FormKit>
|
||||
<FormKit
|
||||
v-if="formSchema && configMapGroupData"
|
||||
:value="toRaw(configMapGroupData) || {}"
|
||||
type="group"
|
||||
name="config"
|
||||
:label="
|
||||
$t('core.attachment.policy_editing_modal.fields.config.label')
|
||||
"
|
||||
>
|
||||
<FormKitSchema
|
||||
:schema="toRaw(formSchema)"
|
||||
:data="toRaw(configMapGroupData) || {}"
|
||||
/>
|
||||
</FormKit>
|
||||
</FormKit>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -234,6 +234,9 @@ core:
|
|||
toast:
|
||||
group_name_exists: Group name already exists
|
||||
policy_editing_modal:
|
||||
fields:
|
||||
config:
|
||||
label: Policy configuration
|
||||
toast:
|
||||
policy_name_exists: Storage policy name already exists
|
||||
upload_modal:
|
||||
|
|
|
@ -750,6 +750,8 @@ core:
|
|||
fields:
|
||||
display_name:
|
||||
label: Display name
|
||||
config:
|
||||
label: Policy configuration
|
||||
toast:
|
||||
policy_name_exists: Storage policy name already exists
|
||||
upload_modal:
|
||||
|
|
|
@ -704,6 +704,8 @@ core:
|
|||
fields:
|
||||
display_name:
|
||||
label: 名称
|
||||
config:
|
||||
label: 策略配置
|
||||
toast:
|
||||
policy_name_exists: 存储策略名称已存在
|
||||
upload_modal:
|
||||
|
|
|
@ -689,6 +689,8 @@ core:
|
|||
fields:
|
||||
display_name:
|
||||
label: 名稱
|
||||
config:
|
||||
label: 策略配置
|
||||
toast:
|
||||
policy_name_exists: 儲存策略名稱已存在
|
||||
upload_modal:
|
||||
|
|
Loading…
Reference in New Issue