From 5b4a7844625f747a7dc311e8cc4b2db9136671c2 Mon Sep 17 00:00:00 2001 From: gy2006 <32008001@qq.com> Date: Wed, 8 Dec 2021 14:01:48 +0100 Subject: [PATCH 1/5] show multiple commits --- src/components/Jobs/ListItem.vue | 73 +++--- src/util/jobs.js | 44 ++-- src/util/vars.js | 13 +- src/view/Job/DetailTabContext.vue | 382 +++++++++++++++--------------- 4 files changed, 261 insertions(+), 251 deletions(-) diff --git a/src/components/Jobs/ListItem.vue b/src/components/Jobs/ListItem.vue index 26edb8df..16a6461e 100644 --- a/src/components/Jobs/ListItem.vue +++ b/src/components/Jobs/ListItem.vue @@ -10,7 +10,7 @@ # {{ wrapper.buildNumber }} {{ wrapper.triggerText }} @@ -29,13 +29,22 @@ no-gutters v-if="wrapper.isPushTrigger || wrapper.isTagTrigger || wrapper.hasGitCommitInfo"> - {{ wrapper.branch }} +
+ mdi-source-branch + {{ wrapper.pushOrTag.branch }} +
+
+ flow-icon-git-commit + {{ wrapper.pushOrTag.commit_total }} + commits +
-
{{ wrapper.commitMsg }}
- {{ wrapper.commitId }} +
{{ wrapper.pushOrTag.head_commit.message }}
+ {{ wrapper.pushOrTag.head_commit.id }}
@@ -47,9 +56,9 @@
- {{ wrapper.prBaseRepo }} ← {{ wrapper.prHeadRepo}} + {{ wrapper.prBaseRepo }} ← {{ wrapper.prHeadRepo }}
-
{{ wrapper.prBaseBranch }} ← {{ wrapper.prHeadBranch}}
+
{{ wrapper.prBaseBranch }} ← {{ wrapper.prHeadBranch }}
@@ -79,38 +88,38 @@ diff --git a/src/util/jobs.js b/src/util/jobs.js index 29aa1992..590a0036 100644 --- a/src/util/jobs.js +++ b/src/util/jobs.js @@ -48,30 +48,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 } @@ -172,6 +152,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 +206,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..3254cb2b 100644 --- a/src/view/Job/DetailTabContext.vue +++ b/src/view/Job/DetailTabContext.vue @@ -1,211 +1,213 @@ From feca6df0327a47af303e54b8958aca80386420bf Mon Sep 17 00:00:00 2001 From: gy2006 <32008001@qq.com> Date: Wed, 8 Dec 2021 14:11:41 +0100 Subject: [PATCH 2/5] multiple commits for tag --- src/view/Job/DetailTabContext.vue | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/view/Job/DetailTabContext.vue b/src/view/Job/DetailTabContext.vue index 3254cb2b..ce848011 100644 --- a/src/view/Job/DetailTabContext.vue +++ b/src/view/Job/DetailTabContext.vue @@ -131,6 +131,7 @@ export default { }, getTagData() { + let tag = this.wrapper.pushOrTag return [ { key: 'Repo', @@ -142,16 +143,11 @@ export default { }, { key: 'Tag', - value: this.wrapper.branch + value: tag.branch }, { - key: 'Commit ID', - value: this.wrapper.commitId, - link: this.wrapper.commitUrl - }, - { - key: 'Commit Message', - value: this.wrapper.commitMsg + key: 'Commits', + value: tag.commit_list, } ] }, From 51dfe72e67b53099dd0ee474140266e9abbe9cfd Mon Sep 17 00:00:00 2001 From: gy2006 <32008001@qq.com> Date: Wed, 8 Dec 2021 21:32:31 +0100 Subject: [PATCH 3/5] add web url in system setting page --- src/components/Common/TextBox.vue | 9 ++++++++- src/view/Settings/System/Index.vue | 29 ++++++++++++++++++----------- 2 files changed, 26 insertions(+), 12 deletions(-) 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 @@ @@ -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") }) } } From ae2e49312789b20fcaac72ade66249eb5556afcc Mon Sep 17 00:00:00 2001 From: gy2006 <32008001@qq.com> Date: Fri, 10 Dec 2021 15:28:45 +0100 Subject: [PATCH 4/5] show built in variables --- src/assets/styles/common.scss | 8 ++++++++ src/util/jobs.js | 32 +++++++++++++++++++++---------- src/view/Job/DetailTabContext.vue | 23 +++++++++++++++++++--- 3 files changed, 50 insertions(+), 13 deletions(-) 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/util/jobs.js b/src/util/jobs.js index 590a0036..54366670 100644 --- a/src/util/jobs.js +++ b/src/util/jobs.js @@ -26,6 +26,23 @@ 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 (value === '') { + return + } + + if (key.startsWith('FLOWCI_')) { + this.builtInVarList.push({key: key, value: value}) + return + } + + this.customVarList.push({key: key, value: value}) + }) } get context() { @@ -86,16 +103,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() { diff --git a/src/view/Job/DetailTabContext.vue b/src/view/Job/DetailTabContext.vue index ce848011..4cdc87a6 100644 --- a/src/view/Job/DetailTabContext.vue +++ b/src/view/Job/DetailTabContext.vue @@ -6,6 +6,7 @@ :items="value.data" class="mb-2 bottom-border" v-show="value.show" + disable-pagination hide-default-footer hide-default-header> @@ -20,7 +21,9 @@ {{ item.key }} - + +
+
- @@ -31,7 +34,7 @@
{{ item.value }} - {{ item.value }} + {{ item.value }}
@@ -85,7 +88,15 @@ export default { variables: { name: 'Variables', show: true, - data: this.wrapper.customVarList + data: this.wrapper.vars.custom, + showBar: true + }, + + builtInVars: { + name: 'Built In Variables', + show: true, + data: this.wrapper.vars.builtIn, + showBar: true } } } @@ -206,4 +217,10 @@ export default { vertical-align: middle; background-color: #E0E0E0; } + +.vertical-bar { + display: flex; + height: 20px; + border-left: 1px solid #c6c6cb; +} From fccdd812010a7fe38658e5a5763b2be3cd063447 Mon Sep 17 00:00:00 2001 From: gy2006 <32008001@qq.com> Date: Fri, 10 Dec 2021 20:44:00 +0100 Subject: [PATCH 5/5] skip _TYPE_ for job context --- src/util/jobs.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util/jobs.js b/src/util/jobs.js index 54366670..540ec9f4 100644 --- a/src/util/jobs.js +++ b/src/util/jobs.js @@ -32,6 +32,10 @@ export class JobWrapper { Object.keys(this.context).forEach(key => { let value = this.context[key] + if (key === '_TYPE_') { + return + } + if (value === '') { return }