Commit df567ddb authored by Paul Slaughter's avatar Paul Slaughter

Update MR header and pipeline to use .label-truncate with .label-branch

Also:
- Renamed .label-truncated to .label-truncate
- Removed length checking in JS to let the CSS handle this
- Improve IE11 compatibility of MR headers
parent 243a2093
<script> <script>
import tooltip from '~/vue_shared/directives/tooltip';
import { n__ } from '~/locale'; import { n__ } from '~/locale';
import { mergeUrlParams, webIDEUrl } from '~/lib/utils/url_utility'; import { mergeUrlParams, webIDEUrl } from '~/lib/utils/url_utility';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import clipboardButton from '~/vue_shared/components/clipboard_button.vue'; import clipboardButton from '~/vue_shared/components/clipboard_button.vue';
import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate.vue';
export default { export default {
name: 'MRWidgetHeader', name: 'MRWidgetHeader',
directives: {
tooltip,
},
components: { components: {
Icon, Icon,
clipboardButton, clipboardButton,
TooltipOnTruncate,
}, },
props: { props: {
mr: { mr: {
...@@ -36,12 +34,6 @@ export default { ...@@ -36,12 +34,6 @@ export default {
gfm: `\`${this.mr.sourceBranch}\``, gfm: `\`${this.mr.sourceBranch}\``,
}); });
}, },
isSourceBranchLong() {
return this.isBranchTitleLong(this.mr.sourceBranch);
},
isTargetBranchLong() {
return this.isBranchTitleLong(this.mr.targetBranch);
},
webIdePath() { webIdePath() {
return mergeUrlParams({ return mergeUrlParams({
target_project: this.mr.sourceProjectFullPath !== this.mr.targetProjectFullPath ? target_project: this.mr.sourceProjectFullPath !== this.mr.targetProjectFullPath ?
...@@ -49,11 +41,6 @@ export default { ...@@ -49,11 +41,6 @@ export default {
}, webIDEUrl(`/${this.mr.sourceProjectFullPath}/merge_requests/${this.mr.iid}`)); }, webIDEUrl(`/${this.mr.sourceProjectFullPath}/merge_requests/${this.mr.iid}`));
}, },
}, },
methods: {
isBranchTitleLong(branchTitle) {
return branchTitle.length > 32;
},
},
}; };
</script> </script>
<template> <template>
...@@ -65,30 +52,21 @@ export default { ...@@ -65,30 +52,21 @@ export default {
<div class="normal"> <div class="normal">
<strong> <strong>
{{ s__("mrWidget|Request to merge") }} {{ s__("mrWidget|Request to merge") }}
<span <tooltip-on-truncate
:class="{ 'label-truncated': isSourceBranchLong }" :title="mr.sourceBranch"
:title="isSourceBranchLong ? mr.sourceBranch : ''" truncate-target="child"
:v-tooltip="isSourceBranchLong" class="label-branch label-truncate js-source-branch"
class="label-branch js-source-branch"
data-placement="bottom"
v-html="mr.sourceBranchLink" v-html="mr.sourceBranchLink"
> /><clipboard-button
</span>
<clipboard-button
:text="branchNameClipboardData" :text="branchNameClipboardData"
:title="__('Copy branch name to clipboard')" :title="__('Copy branch name to clipboard')"
css-class="btn-default btn-transparent btn-clipboard" css-class="btn-default btn-transparent btn-clipboard"
/> />
{{ s__("mrWidget|into") }} {{ s__("mrWidget|into") }}
<tooltip-on-truncate
<span :title="mr.targetBranch"
:v-tooltip="isTargetBranchLong" truncate-target="child"
:class="{ 'label-truncatedtooltip': isTargetBranchLong }" class="label-branch label-truncate"
:title="isTargetBranchLong ? mr.targetBranch : ''"
class="label-branch"
data-placement="bottom"
> >
<a <a
:href="mr.targetBranchTreePath" :href="mr.targetBranchTreePath"
...@@ -96,7 +74,7 @@ export default { ...@@ -96,7 +74,7 @@ export default {
> >
{{ mr.targetBranch }} {{ mr.targetBranch }}
</a> </a>
</span> </tooltip-on-truncate>
</strong> </strong>
<div <div
v-if="shouldShowCommitsBehindText" v-if="shouldShowCommitsBehindText"
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import PipelineStage from '~/pipelines/components/stage.vue'; import PipelineStage from '~/pipelines/components/stage.vue';
import CiIcon from '~/vue_shared/components/ci_icon.vue'; import CiIcon from '~/vue_shared/components/ci_icon.vue';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate.vue';
export default { export default {
name: 'MRWidgetPipeline', name: 'MRWidgetPipeline',
...@@ -10,6 +11,7 @@ export default { ...@@ -10,6 +11,7 @@ export default {
PipelineStage, PipelineStage,
CiIcon, CiIcon,
Icon, Icon,
TooltipOnTruncate,
}, },
props: { props: {
pipeline: { pipeline: {
...@@ -30,6 +32,10 @@ export default { ...@@ -30,6 +32,10 @@ export default {
type: String, type: String,
required: false, required: false,
}, },
sourceBranch: {
type: String,
required: false,
},
}, },
computed: { computed: {
hasPipeline() { hasPipeline() {
...@@ -107,11 +113,12 @@ export default { ...@@ -107,11 +113,12 @@ export default {
> >
{{ pipeline.commit.short_id }}</a> {{ pipeline.commit.short_id }}</a>
on on
<span <tooltip-on-truncate
class="label-branch" :title="sourceBranch"
truncate-target="child"
class="label-branch label-truncate"
v-html="sourceBranchLink" v-html="sourceBranchLink"
> />
</span>
</template> </template>
</div> </div>
<div <div
......
...@@ -254,6 +254,7 @@ export default { ...@@ -254,6 +254,7 @@ export default {
:pipeline="mr.pipeline" :pipeline="mr.pipeline"
:ci-status="mr.ciStatus" :ci-status="mr.ciStatus"
:has-ci="mr.hasCI" :has-ci="mr.hasCI"
:source-branch="mr.sourceBranch"
:source-branch-link="mr.sourceBranchLink" :source-branch-link="mr.sourceBranchLink"
/> />
<deployment <deployment
......
...@@ -195,6 +195,7 @@ ...@@ -195,6 +195,7 @@
.ci-widget-content { .ci-widget-content {
display: flex; display: flex;
align-items: center; align-items: center;
flex: 1;
} }
} }
...@@ -222,6 +223,7 @@ ...@@ -222,6 +223,7 @@
.normal { .normal {
flex: 1; flex: 1;
flex-basis: auto;
} }
.capitalize { .capitalize {
...@@ -236,21 +238,19 @@ ...@@ -236,21 +238,19 @@
overflow: hidden; overflow: hidden;
word-break: break-all; word-break: break-all;
&.label-truncated { &.label-truncate {
position: relative; // NOTE: This selector targets its children because some of the HTML comes from
display: inline-block; // 'source_branch_link'. Once this external HTML is no longer used, we could
width: 250px; // simplify this.
margin-bottom: -3px; > a,
white-space: nowrap; > span {
text-overflow: clip; display: inline-block;
line-height: 14px; max-width: 12.5em;
margin-bottom: -3px;
&::after { white-space: nowrap;
position: absolute; text-overflow: ellipsis;
content: '...'; line-height: 14px;
right: 0; overflow: hidden;
font-family: $regular-font;
background-color: $gray-light;
} }
} }
} }
...@@ -582,7 +582,7 @@ ...@@ -582,7 +582,7 @@
@include media-breakpoint-down(md) { @include media-breakpoint-down(md) {
flex-direction: column; flex-direction: column;
align-items: flex-start; align-items: stretch;
.branch-actions { .branch-actions {
margin-top: 16px; margin-top: 16px;
...@@ -593,6 +593,7 @@ ...@@ -593,6 +593,7 @@
.branch-actions { .branch-actions {
align-self: center; align-self: center;
margin-left: $gl-padding; margin-left: $gl-padding;
white-space: nowrap;
} }
} }
} }
...@@ -918,7 +919,7 @@ ...@@ -918,7 +919,7 @@
flex: 1; flex: 1;
flex-direction: row; flex-direction: row;
@include media-breakpoint-down(md) { @include media-breakpoint-down(sm) {
flex-direction: column; flex-direction: column;
.stage-cell .stage-container { .stage-cell .stage-container {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment