debian-mirror-gitlab/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.vue

178 lines
5.7 KiB
Vue
Raw Normal View History

2018-03-17 18:26:18 +05:30
<script>
2020-11-24 15:15:51 +05:30
import {
GlButton,
GlDropdown,
GlDropdownSectionHeader,
GlDropdownItem,
2021-09-30 23:02:18 +05:30
GlLink,
2020-11-24 15:15:51 +05:30
GlTooltipDirective,
2021-02-22 17:27:13 +05:30
GlModalDirective,
2021-09-30 23:02:18 +05:30
GlSafeHtmlDirective as SafeHtml,
GlSprintf,
2020-11-24 15:15:51 +05:30
} from '@gitlab/ui';
2021-11-18 22:05:49 +05:30
import { constructWebIDEPath } from '~/lib/utils/url_utility';
2021-09-30 23:02:18 +05:30
import { s__ } from '~/locale';
2018-05-09 12:01:36 +05:30
import clipboardButton from '~/vue_shared/components/clipboard_button.vue';
2022-01-26 12:08:38 +05:30
import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate/tooltip_on_truncate.vue';
2021-10-27 15:23:28 +05:30
import WebIdeLink from '~/vue_shared/components/web_ide_link.vue';
2021-02-22 17:27:13 +05:30
import MrWidgetHowToMergeModal from './mr_widget_how_to_merge_modal.vue';
2021-03-11 19:13:27 +05:30
import MrWidgetIcon from './mr_widget_icon.vue';
2018-03-17 18:26:18 +05:30
2018-05-09 12:01:36 +05:30
export default {
name: 'MRWidgetHeader',
components: {
clipboardButton,
2018-11-20 20:47:30 +05:30
TooltipOnTruncate,
2019-02-15 15:39:39 +05:30
MrWidgetIcon,
2021-02-22 17:27:13 +05:30
MrWidgetHowToMergeModal,
2020-11-24 15:15:51 +05:30
GlButton,
GlDropdown,
GlDropdownSectionHeader,
GlDropdownItem,
2021-09-30 23:02:18 +05:30
GlLink,
GlSprintf,
2021-10-27 15:23:28 +05:30
WebIdeLink,
2018-11-20 20:47:30 +05:30
},
directives: {
2020-11-24 15:15:51 +05:30
GlTooltip: GlTooltipDirective,
2021-02-22 17:27:13 +05:30
GlModalDirective,
2021-09-30 23:02:18 +05:30
SafeHtml,
2018-05-09 12:01:36 +05:30
},
props: {
mr: {
type: Object,
required: true,
2018-03-17 18:26:18 +05:30
},
2018-05-09 12:01:36 +05:30
},
computed: {
shouldShowCommitsBehindText() {
return this.mr.divergedCommitsCount > 0;
2018-03-17 18:26:18 +05:30
},
2018-05-09 12:01:36 +05:30
branchNameClipboardData() {
// This supports code in app/assets/javascripts/copy_to_clipboard.js that
// works around ClipboardJS limitations to allow the context-specific
// copy/pasting of plain text or GFM.
return JSON.stringify({
text: this.mr.sourceBranch,
gfm: `\`${this.mr.sourceBranch}\``,
});
2018-03-17 18:26:18 +05:30
},
2018-05-09 12:01:36 +05:30
webIdePath() {
2021-11-18 22:05:49 +05:30
return constructWebIDEPath(this.mr);
2018-05-09 12:01:36 +05:30
},
2021-02-22 17:27:13 +05:30
isFork() {
return this.mr.sourceProjectFullPath !== this.mr.targetProjectFullPath;
},
2018-05-09 12:01:36 +05:30
},
2021-10-27 15:23:28 +05:30
i18n: {
webIdeText: s__('mrWidget|Open in Web IDE'),
gitpodText: s__('mrWidget|Open in Gitpod'),
},
2018-05-09 12:01:36 +05:30
};
2018-03-17 18:26:18 +05:30
</script>
<template>
2021-11-18 22:05:49 +05:30
<div class="gl-display-flex mr-source-target">
2019-02-15 15:39:39 +05:30
<mr-widget-icon name="git-merge" />
2018-11-08 19:23:39 +05:30
<div class="git-merge-container d-flex">
<div class="normal">
<strong>
2019-02-15 15:39:39 +05:30
{{ s__('mrWidget|Request to merge') }}
2018-11-20 20:47:30 +05:30
<tooltip-on-truncate
2021-09-30 23:02:18 +05:30
v-safe-html="mr.sourceBranchLink"
2018-11-20 20:47:30 +05:30
:title="mr.sourceBranch"
truncate-target="child"
class="label-branch label-truncate js-source-branch"
/><clipboard-button
2021-01-03 14:25:43 +05:30
data-testid="mr-widget-copy-clipboard"
2018-11-08 19:23:39 +05:30
:text="branchNameClipboardData"
2019-12-21 20:55:43 +05:30
:title="__('Copy branch name')"
2021-01-03 14:25:43 +05:30
category="tertiary"
2018-11-08 19:23:39 +05:30
/>
2019-02-15 15:39:39 +05:30
{{ s__('mrWidget|into') }}
2018-11-20 20:47:30 +05:30
<tooltip-on-truncate
:title="mr.targetBranch"
truncate-target="child"
class="label-branch label-truncate"
2018-03-17 18:26:18 +05:30
>
2019-02-15 15:39:39 +05:30
<a :href="mr.targetBranchTreePath" class="js-target-branch"> {{ mr.targetBranch }} </a>
2018-11-20 20:47:30 +05:30
</tooltip-on-truncate>
2018-11-08 19:23:39 +05:30
</strong>
2021-09-30 23:02:18 +05:30
<div v-if="shouldShowCommitsBehindText" class="diverged-commits-count">
<gl-sprintf :message="s__('mrWidget|The source branch is %{link} the target branch')">
<template #link>
<gl-link :href="mr.targetBranchPath">{{
n__('%d commit behind', '%d commits behind', mr.divergedCommitsCount)
}}</gl-link>
</template>
</gl-sprintf>
</div>
2018-11-08 19:23:39 +05:30
</div>
2018-03-17 18:26:18 +05:30
2019-07-07 11:18:12 +05:30
<div class="branch-actions d-flex">
<template v-if="mr.isOpen">
2021-10-27 15:23:28 +05:30
<web-ide-link
2019-07-07 11:18:12 +05:30
v-if="!mr.sourceBranchRemoved"
2021-10-27 15:23:28 +05:30
:show-edit-button="false"
:show-web-ide-button="true"
:web-ide-url="webIdePath"
:web-ide-text="$options.i18n.webIdeText"
:show-gitpod-button="mr.showGitpodButton"
:gitpod-url="mr.gitpodUrl"
:gitpod-enabled="mr.gitpodEnabled"
2022-03-02 08:16:31 +05:30
:user-preferences-gitpod-path="mr.userPreferencesGitpodPath"
:user-profile-enable-gitpod-path="mr.userProfileEnableGitpodPath"
2021-10-27 15:23:28 +05:30
:gitpod-text="$options.i18n.gitpodText"
class="gl-display-none gl-md-display-inline-block gl-mr-3"
data-placement="bottom"
tabindex="0"
data-qa-selector="open_in_web_ide_button"
/>
2020-11-24 15:15:51 +05:30
<gl-button
2021-02-22 17:27:13 +05:30
v-gl-modal-directive="'modal-merge-info'"
2019-07-07 11:18:12 +05:30
:disabled="mr.sourceBranchRemoved"
2020-11-24 15:15:51 +05:30
class="js-check-out-branch gl-mr-3"
2019-07-07 11:18:12 +05:30
>
{{ s__('mrWidget|Check out branch') }}
2020-11-24 15:15:51 +05:30
</gl-button>
2021-02-22 17:27:13 +05:30
<mr-widget-how-to-merge-modal
:is-fork="isFork"
:can-merge="mr.canMerge"
:source-branch="mr.sourceBranch"
:source-project="mr.sourceProject"
:source-project-path="mr.sourceProjectFullPath"
:target-branch="mr.targetBranch"
:source-project-default-url="mr.sourceProjectDefaultUrl"
:reviewing-docs-path="mr.reviewingDocsPath"
/>
2019-07-07 11:18:12 +05:30
</template>
2020-11-24 15:15:51 +05:30
<gl-dropdown
v-gl-tooltip
:title="__('Download as')"
:aria-label="__('Download as')"
icon="download"
right
data-qa-selector="download_dropdown"
>
2021-12-11 22:18:48 +05:30
<gl-dropdown-section-header>{{ __('Download as') }}</gl-dropdown-section-header>
2020-11-24 15:15:51 +05:30
<gl-dropdown-item
:href="mr.emailPatchesPath"
class="js-download-email-patches"
download
2021-04-17 20:07:23 +05:30
data-qa-selector="download_email_patches_menu_item"
2018-11-08 19:23:39 +05:30
>
2020-11-24 15:15:51 +05:30
{{ s__('mrWidget|Email patches') }}
</gl-dropdown-item>
<gl-dropdown-item
:href="mr.plainDiffPath"
class="js-download-plain-diff"
download
2021-04-17 20:07:23 +05:30
data-qa-selector="download_plain_diff_menu_item"
2020-11-24 15:15:51 +05:30
>
{{ s__('mrWidget|Plain diff') }}
</gl-dropdown-item>
</gl-dropdown>
2018-11-08 19:23:39 +05:30
</div>
2018-03-17 18:26:18 +05:30
</div>
</div>
</template>