Skip to content

Commit

Permalink
Modified code based on the review
Browse files Browse the repository at this point in the history
  • Loading branch information
LEIYOUSU committed Oct 28, 2024
1 parent 5515dd8 commit 72f1451
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,12 @@ const modalTitle = props.group
const handleSave = async () => {
try {
isSubmitting.value = true;
const existingGroupsResponse =
await coreApiClient.storage.group.listGroup();
const existingGroups = existingGroupsResponse.data.items || [];
const nameExists = existingGroups.some(
const { data: groups } = await coreApiClient.storage.group.listGroup();
const hasDisplayNameDuplicate = groups.items.some(
(group) => group.spec.displayName === formState.value.spec.displayName
);
if (nameExists) {
alert("该分组名称已存在,请重新创建!");
if (hasDisplayNameDuplicate) {
Toast.error(t("core.common.toast.group_name_exists"));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ const formState = ref<Policy>({
const isUpdateMode = !!props.policy;
const { data: policies } = useQuery({
queryKey: ["core:attachment:policies"],
queryFn: async () => {
const { data } = await coreApiClient.storage.policy.listPolicy(); // 修改为 listPolicy
return data;
},
});
onMounted(async () => {
if (props.policy) {
formState.value = cloneDeep(props.policy);
Expand Down Expand Up @@ -143,12 +135,13 @@ const submitting = ref(false);
const handleSave = async () => {
try {
submitting.value = true;
const nameExists = policies.value?.items.some(
const { data: policies } = await coreApiClient.storage.policy.listPolicy();
const hasDisplayNameDuplicate = policies.items.some(
(policy) => policy.spec.displayName === formState.value.spec.displayName
);
if (nameExists) {
alert("该存储策略名称已存在,请重新创建!");
if (hasDisplayNameDuplicate) {
Toast.error(t("core.common.toast.policy_name_exists"));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,17 @@ const onGroupEditingModalClose = async () => {
@click="selectedGroupName = group.metadata.name"
/>

<AttachmentPolicyBadge @click="handleOpenCreateNewGroupModal">
<AttachmentGroupBadge
:features="{ actions: false }"
@click="handleOpenCreateNewGroupModal"
>
<template #text>
<span>{{ $t("core.common.buttons.new") }}</span>
</template>
<template #actions>
<IconAddCircle />
</template>
</AttachmentPolicyBadge>
</AttachmentGroupBadge>
</div>
<UppyUpload
endpoint="/apis/api.console.halo.run/v1alpha1/attachments/upload"
Expand Down
2 changes: 2 additions & 0 deletions ui/src/locales/zh-CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1671,6 +1671,8 @@ core:
unknown_error: 未知错误
disable_success: 禁用成功
enable_success: 啟用成功
group_name_exists: 该分组名称已存在,请重新创建
policy_name_exists: 该存储策略已存在,请重新创建
dialog:
titles:
tip: 提示
Expand Down

0 comments on commit 72f1451

Please sign in to comment.