Commit b91f153b authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Truncate long custom stage names

Ensures we truncate long names in customizable
cycle analytics, and adds a tooltip.
parent 60eb3ff9
<script> <script>
import { GlButton } from '@gitlab/ui'; import { GlButton, GlTooltipDirective } from '@gitlab/ui';
import { approximateDuration } from '~/lib/utils/datetime_utility'; import { approximateDuration } from '~/lib/utils/datetime_utility';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import StageCardListItem from './stage_card_list_item.vue'; import StageCardListItem from './stage_card_list_item.vue';
...@@ -11,6 +11,9 @@ export default { ...@@ -11,6 +11,9 @@ export default {
Icon, Icon,
GlButton, GlButton,
}, },
directives: {
GlTooltip: GlTooltipDirective,
},
props: { props: {
isDefaultStage: { isDefaultStage: {
type: Boolean, type: Boolean,
...@@ -40,6 +43,7 @@ export default { ...@@ -40,6 +43,7 @@ export default {
data() { data() {
return { return {
isHover: false, isHover: false,
isTitleOverflowing: false,
}; };
}, },
computed: { computed: {
...@@ -53,6 +57,9 @@ export default { ...@@ -53,6 +57,9 @@ export default {
return this.canEdit; return this.canEdit;
}, },
}, },
mounted() {
this.checkIfTitleOverflows();
},
methods: { methods: {
handleDropdownAction(action) { handleDropdownAction(action) {
this.$emit(action); this.$emit(action);
...@@ -67,6 +74,12 @@ export default { ...@@ -67,6 +74,12 @@ export default {
handleHover(hoverState = false) { handleHover(hoverState = false) {
this.isHover = hoverState; this.isHover = hoverState;
}, },
checkIfTitleOverflows() {
const [titleEl] = this.$refs.title?.children;
if (titleEl) {
this.isTitleOverflowing = titleEl.offsetWidth > this.$refs.title.offsetWidth;
}
},
}, },
}; };
</script> </script>
...@@ -74,8 +87,13 @@ export default { ...@@ -74,8 +87,13 @@ export default {
<template> <template>
<li @click="handleSelectStage" @mouseover="handleHover(true)" @mouseleave="handleHover()"> <li @click="handleSelectStage" @mouseover="handleHover(true)" @mouseleave="handleHover()">
<stage-card-list-item :is-active="isActive" :can-edit="editable"> <stage-card-list-item :is-active="isActive" :can-edit="editable">
<div class="stage-nav-item-cell stage-name p-0" :class="{ 'font-weight-bold': isActive }"> <div
{{ title }} ref="title"
class="stage-nav-item-cell stage-name p-0 pr-2 text-truncate"
:class="{ 'font-weight-bold': isActive }"
>
<span v-if="isTitleOverflowing" v-gl-tooltip.hover :title="title">{{ title }}</span>
<span v-else>{{ title }}</span>
</div> </div>
<div class="stage-nav-item-cell stage-median mr-4"> <div class="stage-nav-item-cell stage-median mr-4">
<span v-if="hasValue">{{ median }}</span> <span v-if="hasValue">{{ median }}</span>
......
...@@ -741,6 +741,22 @@ describe 'Group Value Stream Analytics', :js do ...@@ -741,6 +741,22 @@ describe 'Group Value Stream Analytics', :js do
expect(nav).not_to have_text(custom_stage_name) expect(nav).not_to have_text(custom_stage_name)
end end
end end
context 'custom stage with a long name' do
let(:bad_custom_stage_name) { 'This is a very very very long stage name that will break the ui' }
let(:params) { { name: bad_custom_stage_name, start_event_identifier: start_event_identifier, end_event_identifier: end_event_identifier } }
before do
create_custom_stage
select_group
expect(page).to have_text bad_custom_stage_name
end
it 'will have a tooltip for the stage' do
expect(page.find(".stage-nav")).to have_css "span[title='#{bad_custom_stage_name}']"
end
end
end end
end end
......
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