2017-06-14 09:04:50 -04:00
|
|
|
<script>
|
2018-04-19 11:07:11 -04:00
|
|
|
import UserAvatarLink from './user_avatar/user_avatar_link.vue';
|
|
|
|
import tooltip from '../directives/tooltip';
|
|
|
|
import Icon from '../../vue_shared/components/icon.vue';
|
2017-06-14 09:04:50 -04:00
|
|
|
|
2018-04-19 11:07:11 -04:00
|
|
|
export default {
|
|
|
|
directives: {
|
|
|
|
tooltip,
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
UserAvatarLink,
|
|
|
|
Icon,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
/**
|
|
|
|
* Indicates the existance of a tag.
|
|
|
|
* Used to render the correct icon, if true will render `fa-tag` icon,
|
|
|
|
* if false will render a svg sprite fork icon
|
|
|
|
*/
|
|
|
|
tag: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
2018-01-04 19:18:35 -05:00
|
|
|
},
|
2018-04-19 11:07:11 -04:00
|
|
|
/**
|
|
|
|
* If provided is used to render the branch name and url.
|
|
|
|
* Should contain the following properties:
|
|
|
|
* name
|
|
|
|
* ref_url
|
|
|
|
*/
|
|
|
|
commitRef: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Used to link to the commit sha.
|
|
|
|
*/
|
|
|
|
commitUrl: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
2018-01-04 19:18:35 -05:00
|
|
|
},
|
2017-06-14 09:04:50 -04:00
|
|
|
|
2018-04-19 11:07:11 -04:00
|
|
|
/**
|
|
|
|
* Used to show the commit short sha that links to the commit url.
|
|
|
|
*/
|
|
|
|
shortSha: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* If provided shows the commit tile.
|
|
|
|
*/
|
|
|
|
title: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* If provided renders information about the author of the commit.
|
|
|
|
* When provided should include:
|
|
|
|
* `avatar_url` to render the avatar icon
|
|
|
|
* `web_url` to link to user profile
|
|
|
|
* `username` to render alt and title tags
|
|
|
|
*/
|
|
|
|
author: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
showBranch: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: true,
|
2017-06-14 09:04:50 -04:00
|
|
|
},
|
2018-04-19 11:07:11 -04:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
/**
|
|
|
|
* Used to verify if all the properties needed to render the commit
|
|
|
|
* ref section were provided.
|
|
|
|
*
|
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
|
|
|
hasCommitRef() {
|
|
|
|
return this.commitRef && this.commitRef.name && this.commitRef.ref_url;
|
2017-06-14 09:04:50 -04:00
|
|
|
},
|
2018-04-19 11:07:11 -04:00
|
|
|
/**
|
|
|
|
* Used to verify if all the properties needed to render the commit
|
|
|
|
* author section were provided.
|
|
|
|
*
|
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
|
|
|
hasAuthor() {
|
|
|
|
return this.author && this.author.avatar_url && this.author.path && this.author.username;
|
2017-08-31 06:38:23 -04:00
|
|
|
},
|
2018-04-19 11:07:11 -04:00
|
|
|
/**
|
|
|
|
* If information about the author is provided will return a string
|
|
|
|
* to be rendered as the alt attribute of the img tag.
|
|
|
|
*
|
|
|
|
* @returns {String}
|
|
|
|
*/
|
|
|
|
userImageAltDescription() {
|
|
|
|
return this.author && this.author.username ? `${this.author.username}'s avatar` : null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2017-06-14 09:04:50 -04:00
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<div class="branch-commit">
|
2017-10-18 12:30:31 -04:00
|
|
|
<template v-if="hasCommitRef && showBranch">
|
2018-02-03 17:36:01 -05:00
|
|
|
<div class="icon-container">
|
2017-10-18 12:30:31 -04:00
|
|
|
<i
|
|
|
|
v-if="tag"
|
|
|
|
class="fa fa-tag"
|
2018-01-04 19:18:35 -05:00
|
|
|
aria-hidden="true"
|
|
|
|
>
|
2017-10-18 12:30:31 -04:00
|
|
|
</i>
|
2017-12-01 14:30:49 -05:00
|
|
|
<icon
|
2017-10-18 12:30:31 -04:00
|
|
|
v-if="!tag"
|
2018-01-04 19:18:35 -05:00
|
|
|
name="fork"
|
|
|
|
/>
|
2017-10-18 12:30:31 -04:00
|
|
|
</div>
|
2017-06-14 09:04:50 -04:00
|
|
|
|
2017-10-18 12:30:31 -04:00
|
|
|
<a
|
|
|
|
v-tooltip
|
2018-06-11 05:49:47 -04:00
|
|
|
:href="commitRef.ref_url"
|
2018-01-04 19:18:35 -05:00
|
|
|
:title="commitRef.name"
|
2018-06-11 05:49:47 -04:00
|
|
|
class="ref-name"
|
|
|
|
data-container="body"
|
2018-01-04 19:18:35 -05:00
|
|
|
>
|
|
|
|
{{ commitRef.name }}
|
2017-10-18 12:30:31 -04:00
|
|
|
</a>
|
|
|
|
</template>
|
2018-04-19 11:07:11 -04:00
|
|
|
<icon
|
|
|
|
name="commit"
|
2018-01-04 19:18:35 -05:00
|
|
|
class="commit-icon js-commit-icon"
|
2018-04-19 11:07:11 -04:00
|
|
|
/>
|
2017-06-14 09:04:50 -04:00
|
|
|
|
|
|
|
<a
|
2018-01-04 19:18:35 -05:00
|
|
|
:href="commitUrl"
|
2018-06-11 05:49:47 -04:00
|
|
|
class="commit-sha"
|
2018-01-04 19:18:35 -05:00
|
|
|
>
|
|
|
|
{{ shortSha }}
|
2017-06-14 09:04:50 -04:00
|
|
|
</a>
|
|
|
|
|
|
|
|
<div class="commit-title flex-truncate-parent">
|
|
|
|
<span
|
|
|
|
v-if="title"
|
2018-01-04 19:18:35 -05:00
|
|
|
class="flex-truncate-child"
|
|
|
|
>
|
2017-06-14 09:04:50 -04:00
|
|
|
<user-avatar-link
|
|
|
|
v-if="hasAuthor"
|
|
|
|
:link-href="author.path"
|
|
|
|
:img-src="author.avatar_url"
|
|
|
|
:img-alt="userImageAltDescription"
|
|
|
|
:tooltip-text="author.username"
|
2018-06-11 05:49:47 -04:00
|
|
|
class="avatar-image-container"
|
2017-06-14 09:04:50 -04:00
|
|
|
/>
|
2017-08-31 06:38:23 -04:00
|
|
|
<a
|
2018-01-04 19:18:35 -05:00
|
|
|
:href="commitUrl"
|
2018-06-11 05:49:47 -04:00
|
|
|
class="commit-row-message"
|
2018-01-04 19:18:35 -05:00
|
|
|
>
|
|
|
|
{{ title }}
|
2017-06-14 09:04:50 -04:00
|
|
|
</a>
|
|
|
|
</span>
|
2018-04-16 11:52:15 -04:00
|
|
|
<span v-else>
|
2018-04-13 14:37:19 -04:00
|
|
|
Can't find HEAD commit for this branch
|
2017-06-14 09:04:50 -04:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|