diff options
Diffstat (limited to 'app/assets/javascripts/vue_common_component/commit.js.es6')
-rw-r--r-- | app/assets/javascripts/vue_common_component/commit.js.es6 | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/app/assets/javascripts/vue_common_component/commit.js.es6 b/app/assets/javascripts/vue_common_component/commit.js.es6 index 1bc68c1ba2f..62a22e39a3b 100644 --- a/app/assets/javascripts/vue_common_component/commit.js.es6 +++ b/app/assets/javascripts/vue_common_component/commit.js.es6 @@ -23,7 +23,7 @@ * name * ref_url */ - ref: { + commitRef: { type: Object, required: false, default: () => ({}), @@ -32,16 +32,16 @@ /** * Used to link to the commit sha. */ - commit_url: { + commitUrl: { type: String, required: false, default: '', }, /** - * Used to show the commit short_sha that links to the commit url. + * Used to show the commit short sha that links to the commit url. */ - short_sha: { + shortSha: { type: String, required: false, default: '', @@ -68,6 +68,11 @@ required: false, default: () => ({}), }, + + commitIconSvg: { + type: String, + required: false, + }, }, computed: { @@ -79,8 +84,8 @@ * * @returns {Boolean} */ - hasRef() { - return this.ref && this.ref.name && this.ref.ref_url; + hasCommitRef() { + return this.commitRef && this.commitRef.name && this.commitRef.ref_url; }, /** @@ -110,43 +115,25 @@ }, }, - /** - * In order to reuse the svg instead of copy and paste in this template - * we need to render it outside this component using =custom_icon partial. - * Make sure it has this structure: - * .commit-icon-svg.hidden - * svg - * - * TODO: Find a better way to include SVG - */ - mounted() { - const commitIconContainer = this.$el.querySelector('.commit-icon-container'); - const commitIcon = document.querySelector('.commit-icon-svg.hidden svg'); - - if (commitIconContainer && commitIcon) { - commitIconContainer.appendChild(commitIcon.cloneNode(true)); - } - }, - template: ` <div class="branch-commit"> - <div v-if="hasRef" class="icon-container"> + <div v-if="hasCommitRef" class="icon-container"> <i v-if="tag" class="fa fa-tag"></i> <i v-if="!tag" class="fa fa-code-fork"></i> </div> - <a v-if="hasRef" + <a v-if="hasCommitRef" class="monospace branch-name" - :href="ref.ref_url"> - {{ref.name}} + :href="commitRef.ref_url"> + {{commitRef.name}} </a> - <div class="icon-container commit-icon commit-icon-container"></div> + <div v-html="commitIconSvg" class="commit-icon js-commit-icon"></div> <a class="commit-id monospace" - :href="commit_url"> - {{short_sha}} + :href="commitUrl"> + {{shortSha}} </a> <p class="commit-title"> @@ -162,7 +149,7 @@ </a> <a class="commit-row-message" - :href="commit_url"> + :href="commitUrl"> {{title}} </a> </span> |