2018-12-05 23:21:45 +05:30
|
|
|
<script>
|
2020-11-24 15:15:51 +05:30
|
|
|
/* eslint-disable vue/no-v-html */
|
2020-05-24 23:13:21 +05:30
|
|
|
import { mapActions } from 'vuex';
|
2021-01-03 14:25:43 +05:30
|
|
|
import { GlButtonGroup, GlButton, GlTooltipDirective, GlIcon } from '@gitlab/ui';
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
|
2021-03-08 18:12:59 +05:30
|
|
|
import ModalCopyButton from '~/vue_shared/components/modal_copy_button.vue';
|
2018-12-05 23:21:45 +05:30
|
|
|
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
import CommitPipelineStatus from '~/projects/tree/components/commit_pipeline_status_component.vue';
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
import initUserPopovers from '../../user_popovers';
|
2020-05-24 23:13:21 +05:30
|
|
|
import { setUrlParams } from '../../lib/utils/url_utility';
|
2018-12-05 23:21:45 +05:30
|
|
|
|
|
|
|
/**
|
|
|
|
* CommitItem
|
|
|
|
*
|
|
|
|
* -----------------------------------------------------------------
|
|
|
|
* WARNING: Please keep changes up-to-date with the following files:
|
|
|
|
* - `views/projects/commits/_commit.html.haml`
|
|
|
|
* -----------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* This Component was cloned from a HAML view. For the time being they
|
|
|
|
* coexist, but there is an issue to remove the duplication.
|
2019-12-04 20:38:33 +05:30
|
|
|
* https://gitlab.com/gitlab-org/gitlab-foss/issues/51613
|
2018-12-05 23:21:45 +05:30
|
|
|
*
|
2020-05-24 23:13:21 +05:30
|
|
|
* EXCEPTION WARNING
|
|
|
|
* 1. The commit navigation buttons (next neighbor, previous neighbor)
|
|
|
|
* are not duplicated because:
|
|
|
|
* - We don't have the same data available on the Rails side (yet,
|
|
|
|
* without backend work)
|
|
|
|
* - This Vue component should always be what's used when in the
|
|
|
|
* context of an MR diff, so the HAML should never have any idea
|
|
|
|
* about navigating among commits.
|
2018-12-05 23:21:45 +05:30
|
|
|
*/
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
UserAvatarLink,
|
2021-03-08 18:12:59 +05:30
|
|
|
ModalCopyButton,
|
2018-12-05 23:21:45 +05:30
|
|
|
TimeAgoTooltip,
|
|
|
|
CommitPipelineStatus,
|
2020-05-24 23:13:21 +05:30
|
|
|
GlButtonGroup,
|
|
|
|
GlButton,
|
|
|
|
GlIcon,
|
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
GlTooltip: GlTooltipDirective,
|
2018-12-05 23:21:45 +05:30
|
|
|
},
|
2020-05-24 23:13:21 +05:30
|
|
|
mixins: [glFeatureFlagsMixin()],
|
2018-12-05 23:21:45 +05:30
|
|
|
props: {
|
2020-10-24 23:57:45 +05:30
|
|
|
isSelectable: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
commit: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
2020-10-24 23:57:45 +05:30
|
|
|
checked: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
collapsible: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: true,
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
},
|
|
|
|
computed: {
|
2019-02-15 15:39:39 +05:30
|
|
|
author() {
|
|
|
|
return this.commit.author || {};
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
authorName() {
|
2019-02-15 15:39:39 +05:30
|
|
|
return this.author.name || this.commit.author_name;
|
|
|
|
},
|
|
|
|
authorClass() {
|
|
|
|
return this.author.name ? 'js-user-link' : '';
|
|
|
|
},
|
|
|
|
authorId() {
|
|
|
|
return this.author.id ? this.author.id : '';
|
2018-12-05 23:21:45 +05:30
|
|
|
},
|
|
|
|
authorUrl() {
|
2019-09-30 21:07:59 +05:30
|
|
|
// name: 'mailto:' is a false positive: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26#possible-false-positives
|
2020-04-22 19:07:51 +05:30
|
|
|
// eslint-disable-next-line @gitlab/require-i18n-strings
|
2019-02-15 15:39:39 +05:30
|
|
|
return this.author.web_url || `mailto:${this.commit.author_email}`;
|
2018-12-05 23:21:45 +05:30
|
|
|
},
|
|
|
|
authorAvatar() {
|
2019-02-15 15:39:39 +05:30
|
|
|
return this.author.avatar_url || this.commit.author_gravatar_url;
|
2018-12-05 23:21:45 +05:30
|
|
|
},
|
2020-10-24 23:57:45 +05:30
|
|
|
commitDescription() {
|
|
|
|
// Strip the newline at the beginning
|
|
|
|
return this.commit.description_html.replace(/^
/, '');
|
|
|
|
},
|
2020-05-24 23:13:21 +05:30
|
|
|
nextCommitUrl() {
|
|
|
|
return this.commit.next_commit_id
|
|
|
|
? setUrlParams({ commit_id: this.commit.next_commit_id })
|
|
|
|
: '';
|
|
|
|
},
|
|
|
|
previousCommitUrl() {
|
|
|
|
return this.commit.prev_commit_id
|
|
|
|
? setUrlParams({ commit_id: this.commit.prev_commit_id })
|
|
|
|
: '';
|
|
|
|
},
|
|
|
|
hasNeighborCommits() {
|
|
|
|
return this.commit.next_commit_id || this.commit.prev_commit_id;
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
},
|
2019-02-15 15:39:39 +05:30
|
|
|
created() {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
initUserPopovers(this.$el.querySelectorAll('.js-user-link'));
|
|
|
|
});
|
|
|
|
},
|
2020-05-24 23:13:21 +05:30
|
|
|
methods: {
|
|
|
|
...mapActions('diffs', ['moveToNeighboringCommit']),
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2021-01-03 14:25:43 +05:30
|
|
|
<li :class="{ 'js-toggle-container': collapsible }" class="commit">
|
|
|
|
<div
|
|
|
|
class="d-block d-sm-flex flex-row-reverse justify-content-between align-items-start flex-lg-row-reverse"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
class="commit-actions flex-row d-none d-sm-flex align-items-start flex-wrap justify-content-end"
|
|
|
|
>
|
2019-02-15 15:39:39 +05:30
|
|
|
<div v-if="commit.signature_html" v-html="commit.signature_html"></div>
|
2018-12-05 23:21:45 +05:30
|
|
|
<commit-pipeline-status
|
2019-02-15 15:39:39 +05:30
|
|
|
v-if="commit.pipeline_status_path"
|
|
|
|
:endpoint="commit.pipeline_status_path"
|
2021-01-03 14:25:43 +05:30
|
|
|
class="d-inline-flex mb-2"
|
2018-12-05 23:21:45 +05:30
|
|
|
/>
|
2021-01-03 14:25:43 +05:30
|
|
|
<gl-button-group class="gl-ml-4 gl-mb-4" data-testid="commit-sha-group">
|
2021-02-22 17:27:13 +05:30
|
|
|
<gl-button
|
|
|
|
label
|
|
|
|
class="gl-font-monospace"
|
|
|
|
data-testid="commit-sha-short-id"
|
|
|
|
v-text="commit.short_id"
|
|
|
|
/>
|
2021-03-08 18:12:59 +05:30
|
|
|
<modal-copy-button
|
2018-12-05 23:21:45 +05:30
|
|
|
:text="commit.id"
|
2019-12-21 20:55:43 +05:30
|
|
|
:title="__('Copy commit SHA')"
|
2021-01-03 14:25:43 +05:30
|
|
|
class="input-group-text"
|
2018-12-05 23:21:45 +05:30
|
|
|
/>
|
2021-01-03 14:25:43 +05:30
|
|
|
</gl-button-group>
|
2021-03-08 18:12:59 +05:30
|
|
|
<div v-if="hasNeighborCommits" class="commit-nav-buttons ml-3">
|
2020-05-24 23:13:21 +05:30
|
|
|
<gl-button-group>
|
|
|
|
<gl-button
|
|
|
|
:href="previousCommitUrl"
|
|
|
|
:disabled="!commit.prev_commit_id"
|
|
|
|
@click.prevent="moveToNeighboringCommit({ direction: 'previous' })"
|
|
|
|
>
|
|
|
|
<span
|
|
|
|
v-if="!commit.prev_commit_id"
|
|
|
|
v-gl-tooltip
|
|
|
|
class="h-100 w-100 position-absolute"
|
|
|
|
:title="__('You\'re at the first commit')"
|
|
|
|
></span>
|
|
|
|
<gl-icon name="chevron-left" />
|
|
|
|
{{ __('Prev') }}
|
|
|
|
</gl-button>
|
|
|
|
<gl-button
|
|
|
|
:href="nextCommitUrl"
|
|
|
|
:disabled="!commit.next_commit_id"
|
|
|
|
@click.prevent="moveToNeighboringCommit({ direction: 'next' })"
|
|
|
|
>
|
|
|
|
<span
|
|
|
|
v-if="!commit.next_commit_id"
|
|
|
|
v-gl-tooltip
|
|
|
|
class="h-100 w-100 position-absolute"
|
|
|
|
:title="__('You\'re at the last commit')"
|
|
|
|
></span>
|
|
|
|
{{ __('Next') }}
|
|
|
|
<gl-icon name="chevron-right" />
|
|
|
|
</gl-button>
|
|
|
|
</gl-button-group>
|
|
|
|
</div>
|
2018-12-05 23:21:45 +05:30
|
|
|
</div>
|
2021-01-03 14:25:43 +05:30
|
|
|
<div>
|
|
|
|
<div class="d-flex float-left align-items-center align-self-start">
|
|
|
|
<input
|
|
|
|
v-if="isSelectable"
|
|
|
|
class="mr-2"
|
|
|
|
type="checkbox"
|
|
|
|
:checked="checked"
|
|
|
|
@change="$emit('handleCheckboxChange', $event.target.checked)"
|
|
|
|
/>
|
|
|
|
<user-avatar-link
|
|
|
|
:link-href="authorUrl"
|
|
|
|
:img-src="authorAvatar"
|
|
|
|
:img-alt="authorName"
|
|
|
|
:img-size="40"
|
|
|
|
class="avatar-cell d-none d-sm-block"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div class="commit-detail flex-list">
|
|
|
|
<div class="commit-content qa-commit-content">
|
|
|
|
<a
|
|
|
|
:href="commit.commit_url"
|
|
|
|
class="commit-row-message item-title"
|
|
|
|
v-html="commit.title_html"
|
|
|
|
></a>
|
|
|
|
|
|
|
|
<span class="commit-row-message d-block d-sm-none">· {{ commit.short_id }}</span>
|
|
|
|
|
|
|
|
<gl-button
|
|
|
|
v-if="commit.description_html && collapsible"
|
|
|
|
class="js-toggle-button"
|
|
|
|
size="small"
|
|
|
|
icon="ellipsis_h"
|
|
|
|
:aria-label="__('Toggle commit description')"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<div class="committer">
|
|
|
|
<a
|
|
|
|
:href="authorUrl"
|
|
|
|
:class="authorClass"
|
|
|
|
:data-user-id="authorId"
|
|
|
|
v-text="authorName"
|
|
|
|
></a>
|
|
|
|
{{ s__('CommitWidget|authored') }}
|
|
|
|
<time-ago-tooltip :time="commit.authored_date" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<pre
|
|
|
|
v-if="commit.description_html"
|
|
|
|
:class="{ 'js-toggle-content': collapsible, 'd-block': !collapsible }"
|
|
|
|
class="commit-row-description gl-mb-3 text-dark"
|
|
|
|
v-html="commitDescription"
|
|
|
|
></pre>
|
2018-12-05 23:21:45 +05:30
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</template>
|