diff --git a/src/assets/styles/common.scss b/src/assets/styles/common.scss index dbf80f33..395271fb 100644 --- a/src/assets/styles/common.scss +++ b/src/assets/styles/common.scss @@ -55,6 +55,14 @@ height: auto !important; } +.if-overflow { + float: left; + width: 400px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + @-moz-keyframes loader { from { transform: rotate(0); diff --git a/src/components/Common/TextBox.vue b/src/components/Common/TextBox.vue index 723ef1d2..f40b392a 100644 --- a/src/components/Common/TextBox.vue +++ b/src/components/Common/TextBox.vue @@ -1,6 +1,9 @@ diff --git a/src/util/jobs.js b/src/util/jobs.js index 29aa1992..540ec9f4 100644 --- a/src/util/jobs.js +++ b/src/util/jobs.js @@ -26,6 +26,27 @@ export const TRIGGER_SCHEDULER = 'SCHEDULER' export class JobWrapper { constructor(job) { this.job = job + + this.builtInVarList = [] + this.customVarList = [] + + Object.keys(this.context).forEach(key => { + let value = this.context[key] + if (key === '_TYPE_') { + return + } + + if (value === '') { + return + } + + if (key.startsWith('FLOWCI_')) { + this.builtInVarList.push({key: key, value: value}) + return + } + + this.customVarList.push({key: key, value: value}) + }) } get context() { @@ -48,30 +69,10 @@ export class JobWrapper { return this.context[vars.git.credential] || '-' } - get commitId() { - return this.context[vars.git.commit.id] - } - - get commitMsg() { - return this.context[vars.git.commit.message] - } - - get commitUrl() { - return this.context[vars.git.commit.url] - } - - get commitNum() { - return this.context[vars.git.commit.number] - } - get fromNow() { return timeFormatFromNow(this.job.createdAt) } - get branch() { - return this.context[vars.git.branch] - } - get buildNumber() { return this.job.buildNumber } @@ -106,16 +107,11 @@ export class JobWrapper { return status } - get customVarList() { - const contextAsPairList = [] - - Object.keys(this.context).forEach(key => { - if (!key.startsWith('FLOWCI_')) { - contextAsPairList.push({key: key, value: this.context[key]}) - } - }) - - return contextAsPairList + get vars() { + return { + builtIn: this.builtInVarList, + custom: this.customVarList + } } get duration() { @@ -172,6 +168,27 @@ export class JobWrapper { return this.job.yamlRepoBranch } + get pushOrTag() { + let commitListB64 = this.context[vars.git.push.commit_list] + let commitList = [] + if (commitListB64) { + try { + commitList = JSON.parse(atob(commitListB64)) + } catch (e) { + // ignore + } + } + + return { + branch: this.context[vars.git.push.branch], + message: this.context[vars.git.push.message], + author: this.context[vars.git.push.author], + commit_total: this.context[vars.git.push.commit_total], + commit_list: commitList, + head_commit: commitList.length === 0 ? {id: '', message: ''} : commitList[0] + } + } + get prTitle() { return this.context[vars.git.pr.title] } @@ -205,8 +222,7 @@ export class JobWrapper { } get hasGitCommitInfo() { - return this.context[vars.git.commit.id] - && this.context[vars.git.commit.message] + return this.context[vars.git.push.message] } get isPushTrigger() { diff --git a/src/util/vars.js b/src/util/vars.js index 261915c4..034af12b 100644 --- a/src/util/vars.js +++ b/src/util/vars.js @@ -26,23 +26,22 @@ export default { git: { url: 'FLOWCI_GIT_URL', - branch: 'FLOWCI_GIT_BRANCH', credential: 'FLOWCI_GIT_CREDENTIAL', source: 'FLOWCI_GIT_SOURCE', event: 'FLOWCI_GIT_EVENT', - author: 'FLOWCI_GIT_AUTHOR', compare_url: 'FLOWCI_GIT_COMPARE_URL', - commit: { - id: 'FLOWCI_GIT_COMMIT_ID', + push: { + author: 'FLOWCI_GIT_AUTHOR', message: 'FLOWCI_GIT_COMMIT_MESSAGE', - time: 'FLOWCI_GIT_COMMIT_TIME', - url: 'FLOWCI_GIT_COMMIT_URL', - number: 'FLOWCI_GIT_COMMIT_NUM' + branch: 'FLOWCI_GIT_BRANCH', + commit_total: 'FLOWCI_GIT_COMMIT_TOTAL', + commit_list: 'FLOWCI_GIT_COMMIT_LIST' }, pr: { + author: 'FLOWCI_GIT_AUTHOR', title: 'FLOWCI_GIT_PR_TITLE', message: 'FLOWCI_GIT_PR_MESSAGE', url: 'FLOWCI_GIT_PR_URL', diff --git a/src/view/Job/DetailTabContext.vue b/src/view/Job/DetailTabContext.vue index b88c5f0b..4cdc87a6 100644 --- a/src/view/Job/DetailTabContext.vue +++ b/src/view/Job/DetailTabContext.vue @@ -1,211 +1,226 @@ diff --git a/src/view/Settings/System/Index.vue b/src/view/Settings/System/Index.vue index 5cdb8f4c..09a02fcf 100644 --- a/src/view/Settings/System/Index.vue +++ b/src/view/Settings/System/Index.vue @@ -1,23 +1,30 @@ @@ -25,8 +32,8 @@ import SaveBtn from '@/components/Settings/SaveBtn' import TextBox from '@/components/Common/TextBox' import actions from '@/store/actions' -import { mapState } from 'vuex' -import { httpUrl, required } from '@/util/rules' +import {mapState} from 'vuex' +import {httpUrl, required} from '@/util/rules' export default { name: "SystemSettingsHome", @@ -60,7 +67,7 @@ export default { } this.$store.dispatch(actions.settings.save, this.settings).then(() => { - this.showSnackBar("Saved") + this.showSnackBar("Saved") }) } }