Commit ff1baa6f authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'ek-display-full-design-name-in-tooltip' into 'master'

Add tooltip to design filenames

See merge request gitlab-org/gitlab!51421
parents cdbe89e6 4da77a7c
<script> <script>
import { GlLoadingIcon, GlIcon, GlIntersectionObserver } from '@gitlab/ui'; import { GlLoadingIcon, GlIcon, GlIntersectionObserver, GlTooltipDirective } from '@gitlab/ui';
import Timeago from '~/vue_shared/components/time_ago_tooltip.vue'; import Timeago from '~/vue_shared/components/time_ago_tooltip.vue';
import { n__, __ } from '~/locale'; import { n__, __ } from '~/locale';
import { DESIGN_ROUTE_NAME } from '../../router/constants'; import { DESIGN_ROUTE_NAME } from '../../router/constants';
...@@ -11,6 +11,9 @@ export default { ...@@ -11,6 +11,9 @@ export default {
GlIcon, GlIcon,
Timeago, Timeago,
}, },
directives: {
GlTooltip: GlTooltipDirective,
},
props: { props: {
id: { id: {
type: [Number, String], type: [Number, String],
...@@ -130,7 +133,7 @@ export default { ...@@ -130,7 +133,7 @@ export default {
<div <div
class="card-body gl-p-0 gl-display-flex gl-align-items-center gl-justify-content-center gl-overflow-hidden gl-relative" class="card-body gl-p-0 gl-display-flex gl-align-items-center gl-justify-content-center gl-overflow-hidden gl-relative"
> >
<div v-if="icon.name" data-testid="designEvent" class="design-event gl-absolute"> <div v-if="icon.name" data-testid="design-event" class="design-event gl-absolute">
<span :title="icon.tooltip" :aria-label="icon.tooltip"> <span :title="icon.tooltip" :aria-label="icon.tooltip">
<gl-icon <gl-icon
:name="icon.name" :name="icon.name"
...@@ -153,9 +156,10 @@ export default { ...@@ -153,9 +156,10 @@ export default {
v-show="showImage" v-show="showImage"
:src="imageLink" :src="imageLink"
:alt="filename" :alt="filename"
class="gl-display-block gl-mx-auto gl-max-w-full mh-100 design-img" class="gl-display-block gl-mx-auto gl-max-w-full gl-max-h-full design-img"
data-qa-selector="design_image" data-qa-selector="design_image"
:data-qa-filename="filename" :data-qa-filename="filename"
:data-testid="`design-img-${id}`"
@load="onImageLoad" @load="onImageLoad"
@error="onImageError" @error="onImageError"
/> />
...@@ -163,9 +167,14 @@ export default { ...@@ -163,9 +167,14 @@ export default {
</div> </div>
<div class="card-footer gl-display-flex gl-w-full"> <div class="card-footer gl-display-flex gl-w-full">
<div class="gl-display-flex gl-flex-direction-column str-truncated-100"> <div class="gl-display-flex gl-flex-direction-column str-truncated-100">
<span class="gl-font-weight-bold str-truncated-100" data-qa-selector="design_file_name">{{ <span
filename v-gl-tooltip
}}</span> class="gl-font-weight-bold str-truncated-100"
data-qa-selector="design_file_name"
:data-testid="`design-img-filename-${id}`"
:title="filename"
>{{ filename }}</span
>
<span v-if="updatedAt" class="str-truncated-100"> <span v-if="updatedAt" class="str-truncated-100">
{{ __('Updated') }} <timeago :time="updatedAt" tooltip-placement="bottom" /> {{ __('Updated') }} <timeago :time="updatedAt" tooltip-placement="bottom" />
</span> </span>
......
---
title: Display full design name in tooltip
merge_request: 51421
author:
type: changed
...@@ -26,9 +26,10 @@ exports[`Design management list item component with notes renders item with mult ...@@ -26,9 +26,10 @@ exports[`Design management list item component with notes renders item with mult
<img <img
alt="test" alt="test"
class="gl-display-block gl-mx-auto gl-max-w-full mh-100 design-img" class="gl-display-block gl-mx-auto gl-max-w-full gl-max-h-full design-img"
data-qa-filename="test" data-qa-filename="test"
data-qa-selector="design_image" data-qa-selector="design_image"
data-testid="design-img-1"
src="" src=""
/> />
</gl-intersection-observer-stub> </gl-intersection-observer-stub>
...@@ -43,6 +44,8 @@ exports[`Design management list item component with notes renders item with mult ...@@ -43,6 +44,8 @@ exports[`Design management list item component with notes renders item with mult
<span <span
class="gl-font-weight-bold str-truncated-100" class="gl-font-weight-bold str-truncated-100"
data-qa-selector="design_file_name" data-qa-selector="design_file_name"
data-testid="design-img-filename-1"
title="test"
> >
test test
</span> </span>
...@@ -100,9 +103,10 @@ exports[`Design management list item component with notes renders item with sing ...@@ -100,9 +103,10 @@ exports[`Design management list item component with notes renders item with sing
<img <img
alt="test" alt="test"
class="gl-display-block gl-mx-auto gl-max-w-full mh-100 design-img" class="gl-display-block gl-mx-auto gl-max-w-full gl-max-h-full design-img"
data-qa-filename="test" data-qa-filename="test"
data-qa-selector="design_image" data-qa-selector="design_image"
data-testid="design-img-1"
src="" src=""
/> />
</gl-intersection-observer-stub> </gl-intersection-observer-stub>
...@@ -117,6 +121,8 @@ exports[`Design management list item component with notes renders item with sing ...@@ -117,6 +121,8 @@ exports[`Design management list item component with notes renders item with sing
<span <span
class="gl-font-weight-bold str-truncated-100" class="gl-font-weight-bold str-truncated-100"
data-qa-selector="design_file_name" data-qa-selector="design_file_name"
data-testid="design-img-filename-1"
title="test"
> >
test test
</span> </span>
......
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import { GlIcon, GlLoadingIcon, GlIntersectionObserver } from '@gitlab/ui'; import { GlIcon, GlLoadingIcon, GlIntersectionObserver } from '@gitlab/ui';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import VueRouter from 'vue-router'; import VueRouter from 'vue-router';
import Item from '~/design_management/components/list/item.vue'; import Item from '~/design_management/components/list/item.vue';
...@@ -17,8 +18,11 @@ const DESIGN_VERSION_EVENT = { ...@@ -17,8 +18,11 @@ const DESIGN_VERSION_EVENT = {
describe('Design management list item component', () => { describe('Design management list item component', () => {
let wrapper; let wrapper;
const imgId = 1;
const imgFilename = 'test';
const findDesignEvent = () => wrapper.find('[data-testid="designEvent"]'); const findDesignEvent = () => wrapper.findByTestId('design-event');
const findImgFilename = (id = imgId) => wrapper.findByTestId(`design-img-filename-${id}`);
const findEventIcon = () => findDesignEvent().find(GlIcon); const findEventIcon = () => findDesignEvent().find(GlIcon);
const findLoadingIcon = () => wrapper.find(GlLoadingIcon); const findLoadingIcon = () => wrapper.find(GlLoadingIcon);
...@@ -28,25 +32,27 @@ describe('Design management list item component', () => { ...@@ -28,25 +32,27 @@ describe('Design management list item component', () => {
isUploading = false, isUploading = false,
imageLoading = false, imageLoading = false,
} = {}) { } = {}) {
wrapper = shallowMount(Item, { wrapper = extendedWrapper(
localVue, shallowMount(Item, {
router, localVue,
propsData: { router,
id: 1, propsData: {
filename: 'test', id: imgId,
image: 'http://via.placeholder.com/300', filename: imgFilename,
isUploading, image: 'http://via.placeholder.com/300',
event, isUploading,
notesCount, event,
updatedAt: '01-01-2019', notesCount,
}, updatedAt: '01-01-2019',
data() { },
return { data() {
imageLoading, return {
}; imageLoading,
}, };
stubs: ['router-link'], },
}); stubs: ['router-link'],
}),
);
} }
afterEach(() => { afterEach(() => {
...@@ -75,6 +81,10 @@ describe('Design management list item component', () => { ...@@ -75,6 +81,10 @@ describe('Design management list item component', () => {
return wrapper.vm.$nextTick(); return wrapper.vm.$nextTick();
}); });
it('renders a tooltip', () => {
expect(findImgFilename().attributes('title')).toEqual(imgFilename);
});
describe('before image is loaded', () => { describe('before image is loaded', () => {
it('renders loading spinner', () => { it('renders loading spinner', () => {
expect(wrapper.find(GlLoadingIcon)).toExist(); expect(wrapper.find(GlLoadingIcon)).toExist();
......
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