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

feat:导出流水线功能优化 #11304 #11368

Merged
merged 4 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
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
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