Skip to content

Commit

Permalink
Merge pull request #11368 from vhwweng/issue_11304
Browse files Browse the repository at this point in the history
feat:导出流水线功能优化 #11304
  • Loading branch information
bkci-bot authored Jan 6, 2025
2 parents 6270b4a + 85c4791 commit e8dbaf5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<bk-dialog
:value="isShow"
:width="480"
:width="560"
:auto-close="false"
:show-footer="false"
:title="$t('newlist.chooseExport')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
</template>

<script>
import { hashID } from '@/utils/util'
import { mapActions, mapState } from 'vuex'
import { CODE_MODE, UI_MODE } from '@/utils/pipelineConst'
Expand Down Expand Up @@ -119,42 +118,20 @@
},
async handleSuccess (result, type = UI_MODE) {
let res
if (type === UI_MODE) {
const newPipelineName = this.pipelineName || `${result.model.name}_${hashID().slice(0, 8)}`
const res = await this.updatePipeline(result, newPipelineName)
this.setEditFrom(true)
if (res) {
if (typeof this.handleImportSuccess === 'function') {
this.handleImportSuccess()
return
}
this.$nextTick(() => {
this.$router.push({
name: 'pipelineImportEdit',
params: {
tab: 'pipeline'
}
})
})
}
const newPipelineName = result.model.name
res = await this.updatePipeline(result, newPipelineName)
} else if (type === CODE_MODE) {
this.updatePipelineMode(CODE_MODE)
this.setEditFrom(true)
this.$store.dispatch('atom/setPipelineYaml', result)
try {
await this.transferPipeline({
projectId: this.$route.params.projectId,
actionType: 'FULL_YAML2MODEL',
oldYaml: result
})
} catch (error) {
this.$showTips({
message: error.message,
theme: 'error'
})
res = await this.updateCodeModePipeline(result)
}
if (res) {
if (typeof this.handleImportSuccess === 'function') {
this.handleImportSuccess()
return
}
this.setPipelineEditing(true)
this.$nextTick(() => {
this.$router.push({
Expand All @@ -172,6 +149,42 @@
theme: 'error'
})
},
async updateCodeModePipeline (result) {
this.$store.dispatch('atom/setPipelineYaml', result)
this.setEditFrom(true)
try {
const { modelAndSetting } = await this.transferPipeline({
projectId: this.$route.params.projectId,
actionType: 'FULL_YAML2MODEL',
oldYaml: result
})
const newPipelineName = modelAndSetting.model.name
const pipeline = {
...modelAndSetting.model,
name: newPipelineName
}
this.setPipelineSetting({
...modelAndSetting.setting,
pipelineId: this.pipelineId ?? modelAndSetting.setting.pipelineId,
pipelineName: newPipelineName
})
this.setPipeline(pipeline)
this.setPipelineWithoutTrigger({
...pipeline,
stages: modelAndSetting.model.stages.slice(1)
})
this.setPipelineEditing(true)
return true
} catch (error) {
this.$showTips({
message: error.message,
theme: 'error'
})
return false
}
},
async updatePipeline (result, newPipelineName) {
const { templateId, instanceFromTemplate, ...restModel } = result.model
const pipeline = {
Expand Down Expand Up @@ -212,6 +225,7 @@
stages: result.model.stages.slice(1)
})
this.setPipelineEditing(true)
this.setEditFrom(true)
return true
},
checkJsonValid (json) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ export default {
const blob = new Blob([result])
fn(blob)
})
} else if (type === UI_MODE) {
} else {
return fetch(url, { credentials: 'include' }).then((res) => {
if (res.status >= 200 && res.status < 300) {
return res.blob()
Expand Down

0 comments on commit e8dbaf5

Please sign in to comment.