debian-mirror-gitlab/app/assets/javascripts/diffs/components/commit_item.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

180 lines
5.5 KiB
Vue
Raw Normal View History

2018-12-05 23:21:45 +05:30
<script>
2021-12-11 22:18:48 +05:30
import { GlButtonGroup, GlButton, GlTooltipDirective, GlSafeHtmlDirective } from '@gitlab/ui';
2020-05-24 23:13:21 +05:30
2021-03-11 19:13:27 +05:30
import CommitPipelineStatus from '~/projects/tree/components/commit_pipeline_status_component.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';
2021-03-11 19:13:27 +05:30
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
2020-05-24 23:13:21 +05:30
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
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,
},
directives: {
GlTooltip: GlTooltipDirective,
2021-12-11 22:18:48 +05:30
SafeHtml: GlSafeHtmlDirective,
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-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(/^&#x000A;/, '');
},
2018-12-05 23:21:45 +05:30
},
2021-12-11 22:18:48 +05:30
safeHtmlConfig: {
ADD_TAGS: ['gl-emoji'],
},
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"
>
2021-11-11 11:23:49 +05:30
<div
v-if="commit.signature_html"
2022-06-21 17:19:12 +05:30
v-html="commit.signature_html /* eslint-disable-line vue/no-v-html */"
2021-11-11 11:23:49 +05:30
></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">
2022-08-27 11:52:29 +05:30
<gl-button label class="gl-font-monospace" data-testid="commit-sha-short-id">{{
commit.short_id
}}</gl-button>
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>
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"
2022-07-23 23:45:48 +05:30
class="gl-mr-3"
2021-01-03 14:25:43 +05:30
type="checkbox"
:checked="checked"
@change="$emit('handleCheckboxChange', $event.target.checked)"
/>
<user-avatar-link
:link-href="authorUrl"
:img-src="authorAvatar"
:img-alt="authorName"
2022-06-21 17:19:12 +05:30
:img-size="32"
2022-11-25 23:54:43 +05:30
class="avatar-cell d-none d-sm-block gl-my-2 gl-mr-4"
2021-01-03 14:25:43 +05:30
/>
</div>
2022-08-13 15:12:31 +05:30
<div
class="commit-detail flex-list gl-display-flex gl-justify-content-space-between gl-align-items-flex-start gl-flex-grow-1 gl-min-w-0"
>
2021-06-08 01:23:25 +05:30
<div class="commit-content" data-qa-selector="commit_content">
2021-01-03 14:25:43 +05:30
<a
2021-12-11 22:18:48 +05:30
v-safe-html:[$options.safeHtmlConfig]="commit.title_html"
2021-01-03 14:25:43 +05:30
:href="commit.commit_url"
class="commit-row-message item-title"
></a>
<span class="commit-row-message d-block d-sm-none">&middot; {{ commit.short_id }}</span>
<gl-button
v-if="commit.description_html && collapsible"
2022-04-04 11:22:00 +05:30
v-gl-tooltip
2021-01-03 14:25:43 +05:30
class="js-toggle-button"
size="small"
icon="ellipsis_h"
2022-04-04 11:22:00 +05:30
:title="__('Toggle commit description')"
2021-01-03 14:25:43 +05:30
: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"
2021-12-11 22:18:48 +05:30
v-safe-html:[$options.safeHtmlConfig]="commitDescription"
2021-01-03 14:25:43 +05:30
:class="{ 'js-toggle-content': collapsible, 'd-block': !collapsible }"
2022-11-25 23:54:43 +05:30
class="commit-row-description gl-mb-3 gl-text-body gl-white-space-pre-line"
2021-01-03 14:25:43 +05:30
></pre>
2018-12-05 23:21:45 +05:30
</div>
</li>
</template>