From cafa5b6a865e97f4add0cd704fcee788b9afba67 Mon Sep 17 00:00:00 2001 From: Yuikill <105910874+Yuikill@users.noreply.github.com> Date: Mon, 30 Oct 2023 19:18:41 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=A9=BA=E9=97=B4=E6=A0=B7=E5=BC=8F=E5=92=8C=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E9=97=AE=E9=A2=98=20(#2718)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix:修复在新服务中点击跳转问题 * fix:修复导入变量样式 * feat:服务密钥关联配置添加前端校验 * feat:查询被引用配置文件 添加脚本类型展示 --- .../ui/src/components/code-editor/index.vue | 50 ++-- .../bcs-bscp/ui/src/components/diff/text.vue | 10 +- .../bcs-bscp/ui/src/components/footer.vue | 2 +- .../components/permission-input-picker.vue | 4 +- .../associate-config-items/index.vue | 2 +- .../associate-config-items/rule-edit.vue | 240 ++++++++++-------- .../ui/src/views/space/credentials/index.vue | 2 +- .../groups/components/group-edit-form.vue | 2 +- .../space/scripts/list/create-script.vue | 17 +- .../views/space/scripts/list/script-cited.vue | 5 +- .../views/space/scripts/list/script-list.vue | 2 +- .../space/scripts/version-manage/index.vue | 8 +- .../version-manage/script-version-diff.vue | 6 +- .../create-version/create-version-slider.vue | 2 +- .../publish-version/confirm-dialog.vue | 4 +- .../publish-version/select-group/index.vue | 2 +- .../publish-version/select-group/preview.vue | 6 +- .../publish-version/select-group/tree.vue | 47 ++-- .../version-diff/aside-menu/configs.vue | 16 +- .../config-list-with-templates.vue | 15 +- .../create-config/pkg-templates-table.vue | 32 ++- .../config-table-list/edit-config.vue | 2 +- .../tables/table-with-pagination.vue | 4 +- .../tables/table-with-templates.vue | 41 ++- .../variables/variables-table.vue | 10 +- .../config-table-list/view-config.vue | 2 +- .../version-list-aside/version-table-list.vue | 3 +- .../list/components/create-service.vue | 2 +- .../service/list/components/edit-service.vue | 4 +- .../list/components/service-list-content.vue | 2 +- .../ui/src/views/space/service/list/index.vue | 4 +- .../package-detail/apps-bound-by-template.vue | 4 +- .../add-from-existing-configs/index.vue | 6 +- .../package-table.vue | 12 +- .../add-configs/create-new-config/index.vue | 2 +- .../create-new-config/select-package.vue | 29 ++- .../add-configs/import-configs/index.vue | 2 +- .../operations/add-to-pkgs/add-to-dialog.vue | 23 +- .../delete-configs/delete-config-dialog.vue | 2 +- .../operations/edit-config/edit-config.vue | 2 +- .../batch-move-out-from-pkg-dialog.vue | 23 +- .../move-out-from-pkgs-dialog.vue | 12 +- .../tables/common-config-table.vue | 12 +- .../list/package-detail/use-package-apps.vue | 9 +- .../templates/list/package-menu/menu.vue | 8 +- .../list/package-menu/package-delete.vue | 21 +- .../space/templates/list/space/selector.vue | 4 +- .../version-bound-by-apps-detail.vue | 4 +- .../create-version-confirm-dialog.vue | 24 +- .../version-detail/version-editor.vue | 4 +- .../ui/src/views/space/variables/index.vue | 4 +- .../space/variables/separator-select.vue | 9 +- .../views/space/variables/variable-edit.vue | 2 +- .../views/space/variables/variable-import.vue | 2 +- bcs-services/bcs-bscp/ui/types/credential.ts | 1 + 55 files changed, 437 insertions(+), 332 deletions(-) diff --git a/bcs-services/bcs-bscp/ui/src/components/code-editor/index.vue b/bcs-services/bcs-bscp/ui/src/components/code-editor/index.vue index 259c63d2d8..915ee96637 100644 --- a/bcs-services/bcs-bscp/ui/src/components/code-editor/index.vue +++ b/bcs-services/bcs-bscp/ui/src/components/code-editor/index.vue @@ -51,7 +51,7 @@ const props = withDefaults( editable: true, lfEol: true, language: '', - } + }, ); const emit = defineEmits(['update:modelValue', 'change', 'enter']); @@ -72,21 +72,21 @@ watch( if (val !== localVal.value) { editor.setValue(val); } - } + }, ); watch( () => props.language, (val) => { monaco.editor.setModelLanguage(editor.getModel() as monaco.editor.ITextModel, val); - } + }, ); watch( () => props.editable, (val) => { editor.updateOptions({ readOnly: !val }); - } + }, ); watch( @@ -95,14 +95,14 @@ watch( if (Array.isArray(val) && val.length > 0) { editorHoverProvider = useEditorVariableReplace(editor, val); } - } + }, ); watch( () => props.errorLine, () => { setErrorLine(); - } + }, ); onMounted(() => { @@ -167,9 +167,9 @@ const handleVariableList = async () => { getVariableList(bkBizId.value, { start: 0, limit: 1000 }), getUnReleasedAppVariables(bkBizId.value, appId.value), ]); - variableNameList.value = variableList.details.map((item: any) => item.spec.name); - privateVariableNameList.value = privateVariableList.details.map((item: any) => item.name); - variableNameList.value?.filter((item) => !privateVariableNameList.value!.includes(item)); + variableNameList.value = variableList.details.map((item: any) => `.${item.spec.name}`); + privateVariableNameList.value = privateVariableList.details.map((item: any) => `.${item.name}`); + variableNameList.value?.filter(item => !privateVariableNameList.value!.includes(item)); }; // 注册自定义语言 @@ -208,22 +208,18 @@ const aotoCompletion = () => { const lineContent = model.getLineContent(position.lineNumber); const charBeforeCursor = lineContent.charAt(position.column - 2); // 根据当前的文本内容和光标位置,返回自动补全的候选项列表 - const variableSuggestions = variableNameList.value!.map((item: string) => { - return { - label: item, // 候选项的显示文本 - kind: monaco.languages.CompletionItemKind.Variable, // 候选项的类型 - insertText: item, // 插入光标后的文本 - range: new monaco.Range(position.lineNumber, position.column, position.lineNumber, position.column), - }; - }); - const privateVariableSuggestions = privateVariableNameList.value!.map((item: string) => { - return { - label: item, - kind: monaco.languages.CompletionItemKind.Variable, - insertText: item, - range: new monaco.Range(position.lineNumber, position.column, position.lineNumber, position.column), - }; - }); + const variableSuggestions = variableNameList.value!.map((item: string) => ({ + label: item, // 候选项的显示文本 + kind: monaco.languages.CompletionItemKind.Variable, // 候选项的类型 + insertText: item, // 插入光标后的文本 + range: new monaco.Range(position.lineNumber, position.column, position.lineNumber, position.column), + })); + const privateVariableSuggestions = privateVariableNameList.value!.map((item: string) => ({ + label: item, + kind: monaco.languages.CompletionItemKind.Variable, + insertText: item, + range: new monaco.Range(position.lineNumber, position.column, position.lineNumber, position.column), + })); const suggestions = [...variableSuggestions, ...privateVariableSuggestions]; if (charBeforeCursor === '{') { return { @@ -234,9 +230,7 @@ const aotoCompletion = () => { suggestions: [], }; }, - resolveCompletionItem: (item: any) => { - return item; - }, + resolveCompletionItem: (item: any) => item, }); }; diff --git a/bcs-services/bcs-bscp/ui/src/components/diff/text.vue b/bcs-services/bcs-bscp/ui/src/components/diff/text.vue index 0f1f7107a3..3f85cf09d1 100644 --- a/bcs-services/bcs-bscp/ui/src/components/diff/text.vue +++ b/bcs-services/bcs-bscp/ui/src/components/diff/text.vue @@ -59,7 +59,7 @@ const props = withDefaults( currentVariables: () => [], currentLanguage: '', baseVariables: () => [], - } + }, ); const textDiffRef = ref(); @@ -76,7 +76,7 @@ watch( () => { updateModel(); replaceDiffVariables(); - } + }, ); watch( @@ -84,7 +84,7 @@ watch( () => { updateModel(); replaceDiffVariables(); - } + }, ); watch( @@ -92,7 +92,7 @@ watch( () => { updateModel(); replaceDiffVariables(); - } + }, ); onMounted(() => { @@ -182,7 +182,7 @@ const replaceDiffVariables = () => { permissionDiffEditorHoverProvider = useDiffEditorVariableReplace( permissionEditor, props.currentVariables, - props.baseVariables + props.baseVariables, ); } }; diff --git a/bcs-services/bcs-bscp/ui/src/components/footer.vue b/bcs-services/bcs-bscp/ui/src/components/footer.vue index 3b1da15c22..884db5d887 100644 --- a/bcs-services/bcs-bscp/ui/src/components/footer.vue +++ b/bcs-services/bcs-bscp/ui/src/components/footer.vue @@ -12,7 +12,7 @@ import { defineComponent } from 'vue'; export default defineComponent({ - name: 'app-footer', + name: 'AppFooter', setup() { return { // @ts-ignore diff --git a/bcs-services/bcs-bscp/ui/src/components/permission-input-picker.vue b/bcs-services/bcs-bscp/ui/src/components/permission-input-picker.vue index 7886372498..5eb9751bc5 100644 --- a/bcs-services/bcs-bscp/ui/src/components/permission-input-picker.vue +++ b/bcs-services/bcs-bscp/ui/src/components/permission-input-picker.vue @@ -78,14 +78,14 @@ watch( privilegeInputVal.value = val; localVal.value = val; }, - { immediate: true } + { immediate: true }, ); // 将权限数字拆分成三个分组配置 const privilegeGroupsValue = computed(() => { const data: { [index: string]: number[] } = { 0: [], 1: [], 2: [] }; if (typeof localVal.value === 'string' && localVal.value.length > 0) { - const valArr = localVal.value.split('').map((i) => parseInt(i, 10)); + const valArr = localVal.value.split('').map(i => parseInt(i, 10)); valArr.forEach((item, index) => { data[index as keyof typeof data] = PRIVILEGE_VALUE_MAP[item as keyof typeof PRIVILEGE_VALUE_MAP]; }); diff --git a/bcs-services/bcs-bscp/ui/src/views/space/credentials/associate-config-items/index.vue b/bcs-services/bcs-bscp/ui/src/views/space/credentials/associate-config-items/index.vue index e99de5a0b1..fab47d976c 100644 --- a/bcs-services/bcs-bscp/ui/src/views/space/credentials/associate-config-items/index.vue +++ b/bcs-services/bcs-bscp/ui/src/views/space/credentials/associate-config-items/index.vue @@ -74,7 +74,7 @@ watch( alter_scope: [], }; } - } + }, ); const loadRules = async () => { diff --git a/bcs-services/bcs-bscp/ui/src/views/space/credentials/associate-config-items/rule-edit.vue b/bcs-services/bcs-bscp/ui/src/views/space/credentials/associate-config-items/rule-edit.vue index 349aca57e0..77eead1128 100644 --- a/bcs-services/bcs-bscp/ui/src/views/space/credentials/associate-config-items/rule-edit.vue +++ b/bcs-services/bcs-bscp/ui/src/views/space/credentials/associate-config-items/rule-edit.vue @@ -2,39 +2,45 @@

配置关联规则

-
- - - -
- - - +
+
+ + + +
+ + + +
+
输入的规则有误,请重新确认
-

可填写服务名称/文件路径,支持通配符,如:myservice/*

+

可填写服务名称/文件路径,支持glob 表达式,如:myservice/**

@@ -44,8 +50,8 @@ import { ref, watch } from 'vue'; import { ICredentialRule, IRuleEditing, IRuleUpdateParams } from '../../../../../types/credential'; const props = defineProps<{ - rules: ICredentialRule[] - }>(); + rules: ICredentialRule[]; +}>(); const emits = defineEmits(['change']); @@ -61,21 +67,25 @@ const transformRulesToEditing = (rules: ICredentialRule[]) => { const rulesEditing: IRuleEditing[] = []; rules.forEach((item) => { const { id, spec } = item; - rulesEditing.push({ id, type: '', content: spec.credential_scope, original: spec.credential_scope }); + rulesEditing.push({ id, type: '', content: spec.credential_scope, original: spec.credential_scope, isRight: true }); }); return rulesEditing; }; -watch(() => props.rules, (val) => { - if (val.length === 0) { - localRules.value = [{ id: 0, type: 'new', content: '', original: '' }]; - } else { - localRules.value = transformRulesToEditing(val); - } -}, { immediate: true }); +watch( + () => props.rules, + (val) => { + if (val.length === 0) { + localRules.value = [{ id: 0, type: 'new', content: '', original: '', isRight: true }]; + } else { + localRules.value = transformRulesToEditing(val); + } + }, + { immediate: true }, +); const handleAddRule = (index: number) => { - localRules.value.splice(index + 1, 0, { id: 0, type: 'new', content: '', original: '' }); + localRules.value.splice(index + 1, 0, { id: 0, type: 'new', content: '', original: '', isRight: true }); }; const handleDeleteRule = (index: number) => { @@ -95,8 +105,17 @@ const handleRevoke = (index: number) => { updateRuleParams(); }; +const testRule = (rule: string) => { + const parts = rule.split('/', 2); + if (!parts[0] || !parts[1]) { + return false; + } + return /^([!@+*?{}()|\]\\[\-^$])/.test(parts[1]); +}; + const handleRuleContentChange = (index: number) => { const rule = localRules.value[index]; + localRules.value[index].isRight = testRule(rule.content); if (rule.id) { rule.type = rule.content === rule.original ? '' : 'modify'; } @@ -129,80 +148,83 @@ const updateRuleParams = () => { }; diff --git a/bcs-services/bcs-bscp/ui/src/views/space/credentials/index.vue b/bcs-services/bcs-bscp/ui/src/views/space/credentials/index.vue index b73ff9289a..6fca728cf4 100644 --- a/bcs-services/bcs-bscp/ui/src/views/space/credentials/index.vue +++ b/bcs-services/bcs-bscp/ui/src/views/space/credentials/index.vue @@ -246,7 +246,7 @@ watch( createPending.value = false; getPermData(); refreshListWithLoading(); - } + }, ); onMounted(() => { diff --git a/bcs-services/bcs-bscp/ui/src/views/space/groups/components/group-edit-form.vue b/bcs-services/bcs-bscp/ui/src/views/space/groups/components/group-edit-form.vue index 6903147908..5f7bfd755c 100644 --- a/bcs-services/bcs-bscp/ui/src/views/space/groups/components/group-edit-form.vue +++ b/bcs-services/bcs-bscp/ui/src/views/space/groups/components/group-edit-form.vue @@ -136,7 +136,7 @@ watch( () => props.group, (val) => { formData.value = cloneDeep(val); - } + }, ); onMounted(() => { diff --git a/bcs-services/bcs-bscp/ui/src/views/space/scripts/list/create-script.vue b/bcs-services/bcs-bscp/ui/src/views/space/scripts/list/create-script.vue index 20f26eabb0..2f734656ef 100644 --- a/bcs-services/bcs-bscp/ui/src/views/space/scripts/list/create-script.vue +++ b/bcs-services/bcs-bscp/ui/src/views/space/scripts/list/create-script.vue @@ -2,7 +2,7 @@ + + +