Skip to content

Commit

Permalink
Merge pull request #10738 from lockiechen/issue_8125_hotfix
Browse files Browse the repository at this point in the history
feat: 模板常量,应该在保存时就判断是否合法,而不是等到实例化的时候才提示 #8125
  • Loading branch information
bkci-bot authored Aug 7, 2024
2 parents c7b36d8 + fdd4e2b commit e31f1f8
Show file tree
Hide file tree
Showing 24 changed files with 499 additions and 224 deletions.
14 changes: 10 additions & 4 deletions src/frontend/devops-codelib/src/views/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
<div class="codelib-content">
<template v-if="hasCodelibs || aliasName.length || isLoading">
<div id="codelib-list-content">
<layout :flod.sync="isListFlod" @on-flod="handleLayoutFlod">
<layout
:flod.sync="isListFlod"
@on-flod="handleLayoutFlod"
>
<template>
<section class="header-content">
<link-code-lib
Expand All @@ -19,7 +22,8 @@
:create-codelib="createCodelib"
>
</link-code-lib>
<bk-input :placeholder="$t('codelib.aliasNamePlaceholder')"
<bk-input
:placeholder="$t('codelib.aliasNamePlaceholder')"
:class="{
'codelib-search': true,
'is-fold-search': isListFlod
Expand Down Expand Up @@ -69,7 +73,9 @@
<bk-button
v-for="item in codelibTypes"
:key="item.scmType"
:disabled="item.status !== 'OK'"
:ext-cls="{
'is-disabled': item.status !== 'OK'
}"
@click="createCodelib(item.scmType)"
>
{{ $t('codelib.linkCodelibLabel', [item.name]) }}
Expand Down Expand Up @@ -317,7 +323,7 @@
const codelibType = this.codelibTypes.find(type => type.scmType === typeLabel)
if (codelibType?.status === 'DEPLOYING') {
this.showUndeployDialog({
title: this.$t('codelib.codelibUndeployTitle', [typeLabel]),
title: this.$t('codelib.codelibUndeployTitle', [codelibType.name]),
desc: this.$t(`codelib.${typeLabel.toLowerCase()}UndeployDesc`),
link: `${DOCS_URL_PREFIX}${codelibType.docUrl}`
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,14 @@
},
data () {
return {
triggerList: [],
statusList: [],
repoList: [],
branchList: []
triggerList: []
}
},
computed: {
...mapGetters({
historyPageStatus: 'pipelines/getHistoryPageStatus'
}),
conditionsMap () {
return {
trigger: this.triggerList,
status: this.statusList,
materialAlias: this.repoList,
materialBranch: this.branchList
}
},
datePickerConf () {
return {
format: 'yyyy-MM-dd HH:mm:ss',
Expand All @@ -66,19 +56,43 @@
name: this.$t('status'),
id: 'status',
multiable: true,
children: this.statusList
children: this.statusList.map(item => ({
id: item.id,
name: item.value
}))
},
{
name: this.$t('materialRepo'),
id: 'materialAlias',
multiable: true,
children: this.repoList
// multiable: true,
remoteMethod:
async (search) => {
const repoList = await this.getConditionList('repo', {
type: 'MATERIAL',
search
})
return repoList.map(item => ({
name: item,
id: item
}))
},
inputInclude: true
},
{
name: this.$t('triggerRepo'),
id: 'triggerRepo',
multiable: true,
children: this.repoList
id: 'triggerAlias',
// multiable: true,
remoteMethod: async (search) => {
const repoList = await this.getConditionList('repo', {
type: 'TRIGGER',
search
})
return repoList.map(item => ({
name: item,
id: item
}))
},
inputInclude: true
},
{
name: 'Commit ID',
Expand All @@ -92,19 +106,44 @@
name: this.$t('history.triggerType'),
id: 'trigger',
multiable: true,
children: this.triggerList
children: this.triggerList.map(item => ({
id: item.id,
name: item.value
}))
},
{
name: this.$t('materialBranch'),
id: 'materialBranch',
multiable: true,
children: this.branchList
// multiable: true,
remoteMethod: async (search) => {
const repoList = await this.getConditionList('branchName', {
type: 'MATERIAL',
alias: this.getSearchKeyById('materialAlias'),
search
})
return repoList.map(item => ({
name: item,
id: item
}))
},
inputInclude: true
},
{
name: this.$t('triggerBranch'),
id: 'triggerBranch',
multiable: true,
children: this.branchList
// multiable: true,
remoteMethod: async (search) => {
const repoList = await this.getConditionList('branchName', {
type: 'TRIGGER',
alias: this.getSearchKeyById('triggerAlias'),
search
})
return repoList.map(item => ({
name: item,
id: item
}))
},
inputInclude: true
},
{
name: this.$t('history.remark'),
Expand All @@ -118,49 +157,29 @@
},
created () {
this.init()
this.handlePathQuery()
},
methods: {
...mapActions('pipelines', [
'setHistoryPageStatus'
]),
async init () {
try {
const [statusList, repoList, branchList, triggerList] = await Promise.all([
const [statusList, triggerList] = await Promise.all([
'status',
'repo',
`branchName?materialAlias=${this.$route.query.materialAlias ?? ''}`,
'trigger'
].map(this.getConditionList))
this.statusList = statusList.map(item => ({
name: item.value,
id: item.id
}))
this.repoList = repoList.map(item => ({
name: item,
id: item
}))
this.branchList = branchList.map(item => ({
name: item,
id: item
}))
this.triggerList = triggerList.map(item => ({
name: item.value,
id: item.id
}))
this.historyPageStatus.searchKey.forEach(item => {
if (this.conditionsMap[item.id]) {
item.values = item.values.map(item => ({
id: item,
name: this.conditionsMap[item.id].find(val => val.id === item)?.name ?? 'unknown'
}))
}
})
const conditionsMap = {
status: statusList,
trigger: triggerList
}
this.statusList = statusList
this.triggerList = triggerList
this.handlePathQuery(conditionsMap)
} catch (error) {
console.error(error)
}
},
async handlePathQuery () {
handlePathQuery (conditionsMap) {
// TODO 筛选参数目前不支持带#字符串回填
const { $route, historyPageStatus } = this
const pathQuery = $route.query
Expand All @@ -174,12 +193,17 @@
const newSearchKey = queryArr.map(key => {
const newItem = this.filterData.find(item => item.id === key)
if (!newItem) return null
const valueMap = conditionsMap[key]?.reduce((acc, item) => {
acc[item.id] = item.value
return acc
}, {})
newItem.values = newItem.multiable
? pathQuery[key].split(',').map(v => ({
id: v,
name: v
name: valueMap?.[v] ?? v
}))
: [{ id: pathQuery[key], name: pathQuery[key] }]
: [{ id: pathQuery[key], name: valueMap?.[pathQuery[key]] ?? pathQuery[key] }]
return newItem
}).filter(item => !!item)
Expand Down Expand Up @@ -231,10 +255,11 @@
this.startQuery()
},
async getConditionList (condition) {
async getConditionList (condition, query = {}) {
try {
const { $route: { params }, $ajax } = this
const url = `${PROCESS_API_URL_PREFIX}/user/builds/${params.projectId}/${params.pipelineId}/historyCondition/${condition}`
const querySearch = new URLSearchParams(query)
const url = `${PROCESS_API_URL_PREFIX}/user/builds/${params.projectId}/${params.pipelineId}/historyCondition/${condition}?${querySearch}`
const res = await $ajax.get(url)
return res.data
Expand All @@ -250,6 +275,14 @@
searchKey
})
this.startQuery()
},
getSearchKeyById (id) {
try {
const values = this.historyPageStatus.searchKey.find(item => item.id === id)?.values
return Array.isArray(values) ? values.map(i => i.id).join(',') : ''
} catch (error) {
return ''
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
:data-vv-scope="`param-${param.id}`"
:disabled="disabled"
:handle-change="(name, value) => handleUpdateParamId(name, value, index)"
v-validate.initial="`required|unique:${validateParams.map(p => p.id).join(',')}`"
v-validate.initial="`required|paramsIdRule|unique:${validateParams.map(p => p.id).join(',')}`"
name="id"
:placeholder="$t('nameInputTips')"
:value="param.id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,31 @@
@cancel="handleCancel"
>
<div class="disable-pipeline-dialog">
<i :class="['bk-icon disable-pipeline-warning-icon', {
'icon-exclamation': !lock,
'icon-check-1': lock
}]"></i>
<i
:class="['bk-icon disable-pipeline-warning-icon', {
'icon-exclamation': !lock,
'icon-check-1': lock
}]"
></i>
<h3>{{ $t(lock ? 'enablePipelineConfirmTips' : 'disablePipelineConfirmTips') }}</h3>
<p v-if="!lock">
{{ $t(pacEnabled ? 'disablePacPipelineConfirmDesc' : 'disablePipelineConfirmDesc') }}
</p>
<p v-else>
{{ $t(pacEnabled ? 'enablePacPipelineConfirmDesc' : 'enablePipelineConfirmDesc') }}
</p>
<pre class="disable-pac-code" v-if="pacEnabled">{{ disablePipelineYaml }}<copy-icon :value="disablePipelineYaml" /></pre>
<pre
class="disable-pac-code"
v-if="pacEnabled"
>{{ disablePipelineYaml }}<copy-icon :value="disablePipelineYaml" /></pre>
</div>
<footer slot="footer">
<bk-button v-if="!pacEnabled" :loading="disabling" theme="primary" @click="disablePipeline">
<bk-button
v-if="!pacEnabled"
:loading="disabling"
theme="primary"
@click="disablePipeline"
>
{{ $t(lock ? 'enable' : 'disable') }}
</bk-button>
<bk-button @click="handleCancel">
Expand Down Expand Up @@ -98,14 +108,15 @@
height: 42px;
background: #FFE8C3;
color: #FF9C01;
&.icon-check-1 {
background: #e5f6ea;
color: #3fc06d;
}
align-items: center;
justify-content: center;
border-radius: 50%;
font-size: 26px;
&.icon-check-1 {
background: #e5f6ea;
color: #3fc06d;
}
}
.disable-pac-code {
position: relative;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@
},
draftHintTitle () {
return this.hasDraftPipeline ? this.$t('hasDraftTips', [this.draftBaseVersionName]) : this.$t('createDraftTips', [this.versionName])
},
isTemplatePipeline () {
return this.pipelineInfo?.instanceFromTemplate ?? false
}
},
methods: {
Expand All @@ -133,7 +136,24 @@
]),
handleClick () {
if (this.isRollback) {
this.showDraftConfirmDialog()
if (this.isTemplatePipeline) {
this.$bkInfo({
subTitle: this.$t('templateRollbackBackTips'),
confirmFn: () => {
this.$router.push({
name: 'createInstance',
params: {
projectId: this.projectId,
templateId: this.pipelineInfo?.templateId,
curVersionId: this.pipelineInfo?.templateVersion
},
hash: `#${this.pipelineId}`
})
}
})
} else {
this.showDraftConfirmDialog()
}
} else {
this.goEdit(this.draftVersion ?? this.version)
}
Expand Down
Loading

0 comments on commit e31f1f8

Please sign in to comment.