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:Code 方式创建的流水线,变量面板-输出变量未获取到问题优化 #10755 #10817

Merged
merged 5 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Expand Up @@ -115,7 +115,8 @@
},
computed: {
...mapState('atom', [
'editingElementPos'
'editingElementPos',
'atomsOutputMap'
]),
...mapGetters('atom', [
'getStage',
Expand Down Expand Up @@ -155,7 +156,12 @@
if (stage) {
(stage.containers || []).forEach((container, containerIndex) => {
(container.elements || []).forEach((element, elementIndex) => {
if (element?.data?.output && typeof (element?.data?.output) && Object.keys(element?.data?.output).length) {
// 从api获取的output信息
const apiOutput = this.atomsOutputMap[`${element.atomCode}@${element.version}`] || {}
// 从model解析的output信息
const modelOutput = element?.data?.output || {}
if (Object.keys(modelOutput).length || Object.keys(apiOutput).length) {
const realOutput = Object.keys(apiOutput).length > 0 ? apiOutput : modelOutput
list.push({
id: element.id,
location: {
Expand All @@ -169,9 +175,9 @@
stepId: element.stepId,
stepName: element.name,
envPrefix: `jobs.${container.jobId}.steps.${element.stepId}.outputs.`,
params: Object.keys(element.data.output).map(item => ({
params: Object.keys(realOutput).map(item => ({
name: item,
desc: ''
desc: realOutput[item]?.description
}))
})
}
Expand All @@ -196,9 +202,13 @@
}))
}
},
created () {
this.fetchAtomsOutput()
},
methods: {
...mapActions('atom', [
'updateAtom'
'updateAtom',
'fetchAtomsOutput'
]),
async handleUpdateStepId () {
const valid = await this.$validator.validate('step.*')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
<template>
<section class="bk-form-item">
<form-field
:hide-colon="true"
v-if="isCodelibParam(param.type)"
:label="$t('editPage.codelibParams')"
:is-error="errors.has(`scmType`)"
:error-msg="errors.first(`pipelineParam.scmType`)"
>
<selector
:disabled="disabled"
:list="codeTypeList"
:handle-change="(name, value) => handleCodeTypeChange(name, value)"
name="scmType"
placeholder=""
:value="param.scmType"
></selector>
</form-field>
<form-field
:hide-colon="true"
v-if="isGitParam(param.type)"
:label="$t('editPage.gitRepo')"
:is-error="errors.has(`repoHashId`)"
:error-msg="errors.first(`pipelineParam.repoHashId`)"
>
<request-selector
v-bind="getRepoOption('CODE_GIT,CODE_GITLAB,GITHUB,CODE_TGIT')"
:disabled="disabled"
name="repoHashId"
:value="param.repoHashId"
:handle-change="handleChange"
v-validate="'required'"
:data-vv-scope="'pipelineParam'"
replace-key="{keyword}"
:search-url="getSearchUrl()"
>
</request-selector>
</form-field>
<form-field
:hide-colon="true"
v-if="isSvnParam(param.type)"
:label="$t('editPage.svnParams')"
:is-error="errors.has(`repoHashId`)"
:error-msg="errors.first(`pipelineParam.repoHashId`)"
>
<request-selector
v-bind="getRepoOption('CODE_SVN')"
:disabled="disabled"
name="repoHashId"
:value="param.repoHashId"
:handle-change="handleChange"
v-validate="'required'"
:data-vv-scope="'pipelineParam'"
:replace-key="param.replaceKey"
:search-url="param.searchUrl"
>
</request-selector>
</form-field>
<select-type-param
v-if="isSelectorParam(param.type)"
:param="param"
Expand Down Expand Up @@ -130,27 +186,6 @@
</request-selector>
</form-field>

<form-field
:hide-colon="true"
v-if="isSvnParam(param.type)"
:label="$t('editPage.svnParams')"
:is-error="errors.has(`repoHashId`)"
:error-msg="errors.first(`pipelineParam.repoHashId`)"
>
<request-selector
v-bind="getRepoOption('CODE_SVN')"
:disabled="disabled"
name="repoHashId"
:value="param.repoHashId"
:handle-change="handleChange"
v-validate="'required'"
:data-vv-scope="'pipelineParam'"
:replace-key="param.replaceKey"
:search-url="param.searchUrl"
>
</request-selector>
</form-field>

<form-field
:hide-colon="true"
v-if="isSvnParam(param.type)"
Expand All @@ -167,44 +202,6 @@
></vuex-input>
</form-field>

<form-field
:hide-colon="true"
v-if="isGitParam(param.type)"
:label="$t('editPage.gitRepo')"
:is-error="errors.has(`repoHashId`)"
:error-msg="errors.first(`pipelineParam.repoHashId`)"
>
<request-selector
v-bind="getRepoOption('CODE_GIT,CODE_GITLAB,GITHUB,CODE_TGIT')"
:disabled="disabled"
name="repoHashId"
:value="param.repoHashId"
:handle-change="handleChange"
v-validate="'required'"
:data-vv-scope="'pipelineParam'"
replace-key="{keyword}"
:search-url="getSearchUrl()"
>
</request-selector>
</form-field>

<form-field
:hide-colon="true"
v-if="isCodelibParam(param.type)"
:label="$t('editPage.codelibParams')"
:is-error="errors.has(`scmType`)"
:error-msg="errors.first(`pipelineParam.scmType`)"
>
<selector
:disabled="disabled"
:list="codeTypeList"
:handle-change="(name, value) => handleCodeTypeChange(name, value)"
name="scmType"
placeholder=""
:value="param.scmType"
></selector>
</form-field>

<template v-if="isBuildResourceParam(param.type)">
<form-field
:hide-colon="true"
Expand Down Expand Up @@ -252,6 +249,42 @@
@handle-change="(value) => uploadPathFromFileName(value)"
></file-upload>
</form-field>

<template v-if="isArtifactoryParam(param.type)">
<form-field
:label="$t('editPage.filterRule')"
:is-error="errors.has(`pipelineParam.glob`)"
:error-msg="errors.first(`pipelineParam.glob`)"
>
<vuex-input
:disabled="disabled"
:handle-change="handleChange"
name="glob"
:data-vv-scope="'pipelineParam'"
:placeholder="$t('editPage.filterRuleTips')"
:value="param.glob"
></vuex-input>
</form-field>

<form-field
label-width="auto"
:label="$t('metaData')"
:is-error="errors.has(`pipelineParam.properties`)"
:error-msg="errors.first(`pipelineParam.properties`)"
>
<key-value-normal
:disabled="disabled"
name="properties"
:data-vv-scope="'pipelineParam'"
:is-metadata-var="true"
:add-btn-text="$t('editPage.addMetaData')"
:value="getProperties(param)"
:handle-change="
(name, value) => handleProperties(name, value)
"
></key-value-normal>
</form-field>
</template>
</section>
</template>

Expand All @@ -266,6 +299,7 @@
import Selector from '@/components/atomFormField/Selector'
import FileUpload from '@/components/FileUpload'
import FileParamInput from '@/components/FileParamInput'
import KeyValueNormal from '@/components/atomFormField/KeyValueNormal'
import validMixins from '@/components/validMixins'
import {
isTextareaParam,
Expand Down Expand Up @@ -310,7 +344,8 @@
VuexTextarea,
RequestSelector,
FileUpload,
FileParamInput
FileParamInput,
KeyValueNormal
},
mixins: [validMixins],
props: {
Expand Down Expand Up @@ -499,9 +534,27 @@
}
this.handleUpdateParam(key, value)
},

uploadPathFromFileName (value) {
this.uploadFileName = value
},
getProperties (param) {
try {
return Object.keys(param.properties).map((item) => {
return {
key: item,
value: param.properties[item]
}
})
} catch (e) {
return []
}
},
handleProperties (key, value, index) {
const properties = {}
value.forEach((val) => {
properties[val.key] = val.value
})
this.handleUpdateParam(key, properties)
}
}
}
Expand Down
19 changes: 19 additions & 0 deletions src/frontend/devops-pipeline/src/store/modules/atom/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
SET_ATOM_MODAL_FETCHING,
SET_ATOM_PAGE_OVER,
SET_ATOM_VERSION_LIST,
SET_ATOMS_OUTPUT_MAP,
SET_COMMEND_ATOM_COUNT,
SET_COMMEND_ATOM_PAGE_OVER,
SET_COMMON_PARAMS,
Expand Down Expand Up @@ -399,6 +400,24 @@ export default {
})
},

fetchAtomsOutput: async ({ commit, state, getters }) => {
const elements = getters.getAllElements(state.pipeline?.stages)
const arr = elements.map(ele => `${ele.atomCode}@${ele.version}`)
const data = Array.from(new Set(arr))
try {
request.post(`${STORE_API_URL_PREFIX}/user/pipeline/atom/output/info/list`, data).then(res => {
const map = {}
for (const item in res.data) {
map[item] = JSON.parse(res.data[item])
}
console.log(map, 88552)
commit(SET_ATOMS_OUTPUT_MAP, map)
})
} catch (error) {
commit(SET_ATOMS_OUTPUT_MAP, {})
}
},

fetchAtoms: async ({ commit, state, getters }, { projectCode, category, jobType, classifyId, os, searchKey, queryProjectAtomFlag, fitOsFlag = undefined }) => {
try {
const isCommendAtomPageOver = state.isCommendAtomPageOver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const RESET_ATOM_MODAL_MAP = 'RESET_ATOM_MODAL_MAP'
export const SET_ATOM_MODAL_FETCHING = 'SET_FETCHING_ATOM_MODAL'
export const SET_CONTAINER_FETCHING = 'SET_CONTAINER_FETCHING'
export const SET_CONTAINER = 'SET_CONTAINER'
export const SET_ATOMS_OUTPUT_MAP = 'SET_ATOMS_OUTPUT_MAP'

export const UPDATE_ATOM_TYPE = 'UPDATE_ATOM_TYPE'
export const INSERT_ATOM = 'INSERT_ATOM'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default {
isCommendAtomPageOver: false,
isAtomPageOver: false,
atomList: [],
atomsOutputMap: {},
requestAtomData: {
recommendFlag: true,
keyword: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
SET_ATOM_MODAL_FETCHING,
SET_ATOM_PAGE_OVER,
SET_ATOM_VERSION_LIST,
SET_ATOMS_OUTPUT_MAP,
SET_COMMEND_ATOM_COUNT,
SET_COMMEND_ATOM_PAGE_OVER,
SET_COMMON_PARAMS,
Expand Down Expand Up @@ -209,6 +210,12 @@ export default {
})
return state
},
[SET_ATOMS_OUTPUT_MAP]: (state, atomsOutputMap) => {
Object.assign(state, {
atomsOutputMap
})
return state
},
[SET_ATOM_MODAL_FETCHING]: (state, fetchingAtmoModal) => {
Object.assign(state, {
fetchingAtmoModal
Expand Down
Loading