Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(import-doc): 修复资源 Yaml 文档匹配逻辑错误问题 #1120

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/dashboard-front/src/views/resource/setting/import-doc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,21 @@
>
<template #default="{ data }">
<!-- 若是没匹配到资源,给出提示 -->
<template v-if="!data?.resource">
<span class="warning-c">{{ t('未匹配到资源') }}</span>
<!-- 若导入的是 zip -->
<template v-if="docType === 'archive'">
<span v-if="!data?.resource" class="warning-c">{{ t('未匹配到资源') }}</span>
<template v-else>
<span class="danger-c" v-if="!!data?.resource_doc">{{ t('覆盖') }}</span>
<span class="success-c" v-else>{{ t('新建') }}</span>
</template>
</template>
<!-- 若导入方式是自行编辑的 yaml -->
<template v-else>
<span class="danger-c" v-if="!!data?.resource_doc">{{ t('覆盖') }}</span>
<span class="success-c" v-else>{{ t('新建') }}</span>
<span v-if="!data?.id" class="warning-c">{{ t('未匹配到资源') }}</span>
<template v-else>
<span class="danger-c" v-if="hasExistedDoc(data)">{{ t('覆盖') }}</span>
<span class="success-c" v-else>{{ t('新建') }}</span>
</template>
</template>
</template>
</bk-table-column>
Expand Down Expand Up @@ -429,6 +438,14 @@ const handleHiddenExample = () => {
isShowExample.value = false;
};

const hasExistedDoc = (data?: { doc?: { id: number, language: string }[] }) => {
if (!data?.doc?.length) {
return false;
}

return data.doc.find(item => item.language === language.value)?.id;
};

</script>
<style scoped lang="scss">
.import-docs-container{
Expand Down
Loading