Commit 83bec651 authored by Tom Quirk's avatar Tom Quirk

Optimize click area in design version dropdown

- remove <strong> tag
- use pajamas-conforming dropdown checked icon
- update specs
parent 2353e28f
...@@ -33,12 +33,12 @@ export default { ...@@ -33,12 +33,12 @@ export default {
}, },
dropdownText() { dropdownText() {
if (this.isLatestVersion) { if (this.isLatestVersion) {
return __('Showing Latest Version'); return __('Showing latest version');
} }
// allVersions is sorted in reverse chronological order (latest first) // allVersions is sorted in reverse chronological order (latest first)
const currentVersionNumber = this.allVersions.length - this.currentVersionIdx; const currentVersionNumber = this.allVersions.length - this.currentVersionIdx;
return sprintf(__('Showing Version #%{versionNumber}'), { return sprintf(__('Showing version #%{versionNumber}'), {
versionNumber: currentVersionNumber, versionNumber: currentVersionNumber,
}); });
}, },
...@@ -50,25 +50,20 @@ export default { ...@@ -50,25 +50,20 @@ export default {
</script> </script>
<template> <template>
<gl-new-dropdown :text="dropdownText" size="small" class="design-version-dropdown"> <gl-new-dropdown :text="dropdownText" size="small">
<gl-new-dropdown-item v-for="(version, index) in allVersions" :key="version.id"> <gl-new-dropdown-item
<router-link v-for="(version, index) in allVersions"
class="d-flex js-version-link" :key="version.id"
:to="{ path: $route.path, query: { version: findVersionId(version.id) } }" :is-check-item="true"
> :is-checked="findVersionId(version.id) === currentVersionId"
<div class="flex-grow-1 ml-2"> @click="$router.push({ path: $route.path, query: { version: findVersionId(version.id) } })"
<div> >
<strong <template>
>{{ __('Version') }} {{ allVersions.length - index }} {{ __('Version') }} {{ allVersions.length - index }}
<span v-if="findVersionId(version.id) === latestVersionId">({{ __('latest') }})</span> <template v-if="findVersionId(version.id) === latestVersionId"
</strong> >({{ __('latest') }})</template
</div> >
</div> </template>
<i
v-if="findVersionId(version.id) === currentVersionId"
class="fa fa-check float-right gl-mr-2"
></i>
</router-link>
</gl-new-dropdown-item> </gl-new-dropdown-item>
</gl-new-dropdown> </gl-new-dropdown>
</template> </template>
---
title: Optimize click area in design version dropdown
merge_request: 38747
author:
type: fixed
...@@ -22230,6 +22230,12 @@ msgstr "" ...@@ -22230,6 +22230,12 @@ msgstr ""
msgid "Showing last %{size} of log -" msgid "Showing last %{size} of log -"
msgstr "" msgstr ""
msgid "Showing latest version"
msgstr ""
msgid "Showing version #%{versionNumber}"
msgstr ""
msgid "Side-by-side" msgid "Side-by-side"
msgstr "" msgstr ""
......
...@@ -3,12 +3,11 @@ ...@@ -3,12 +3,11 @@
exports[`Design management design version dropdown component renders design version dropdown button 1`] = ` exports[`Design management design version dropdown component renders design version dropdown button 1`] = `
<gl-new-dropdown-stub <gl-new-dropdown-stub
category="tertiary" category="tertiary"
class="design-version-dropdown"
headertext="" headertext=""
issueiid="" issueiid=""
projectpath="" projectpath=""
size="small" size="small"
text="Showing Latest Version" text="Showing latest version"
variant="default" variant="default"
> >
<gl-new-dropdown-item-stub <gl-new-dropdown-item-stub
...@@ -16,56 +15,26 @@ exports[`Design management design version dropdown component renders design vers ...@@ -16,56 +15,26 @@ exports[`Design management design version dropdown component renders design vers
iconcolor="" iconcolor=""
iconname="" iconname=""
iconrightname="" iconrightname=""
ischecked="true"
ischeckitem="true"
secondarytext="" secondarytext=""
> >
<router-link-stub
class="d-flex js-version-link" Version 2
to="[object Object]" (latest)
>
<div
class="flex-grow-1 ml-2"
>
<div>
<strong>
Version 2
<span>
(latest)
</span>
</strong>
</div>
</div>
<i
class="fa fa-check float-right gl-mr-2"
/>
</router-link-stub>
</gl-new-dropdown-item-stub> </gl-new-dropdown-item-stub>
<gl-new-dropdown-item-stub <gl-new-dropdown-item-stub
avatarurl="" avatarurl=""
iconcolor="" iconcolor=""
iconname="" iconname=""
iconrightname="" iconrightname=""
ischeckitem="true"
secondarytext="" secondarytext=""
> >
<router-link-stub
class="d-flex js-version-link" Version 1
to="[object Object]"
> <!---->
<div
class="flex-grow-1 ml-2"
>
<div>
<strong>
Version 1
<!---->
</strong>
</div>
</div>
<!---->
</router-link-stub>
</gl-new-dropdown-item-stub> </gl-new-dropdown-item-stub>
</gl-new-dropdown-stub> </gl-new-dropdown-stub>
`; `;
...@@ -73,12 +42,11 @@ exports[`Design management design version dropdown component renders design vers ...@@ -73,12 +42,11 @@ exports[`Design management design version dropdown component renders design vers
exports[`Design management design version dropdown component renders design version list 1`] = ` exports[`Design management design version dropdown component renders design version list 1`] = `
<gl-new-dropdown-stub <gl-new-dropdown-stub
category="tertiary" category="tertiary"
class="design-version-dropdown"
headertext="" headertext=""
issueiid="" issueiid=""
projectpath="" projectpath=""
size="small" size="small"
text="Showing Latest Version" text="Showing latest version"
variant="default" variant="default"
> >
<gl-new-dropdown-item-stub <gl-new-dropdown-item-stub
...@@ -86,56 +54,26 @@ exports[`Design management design version dropdown component renders design vers ...@@ -86,56 +54,26 @@ exports[`Design management design version dropdown component renders design vers
iconcolor="" iconcolor=""
iconname="" iconname=""
iconrightname="" iconrightname=""
ischecked="true"
ischeckitem="true"
secondarytext="" secondarytext=""
> >
<router-link-stub
class="d-flex js-version-link" Version 2
to="[object Object]" (latest)
>
<div
class="flex-grow-1 ml-2"
>
<div>
<strong>
Version 2
<span>
(latest)
</span>
</strong>
</div>
</div>
<i
class="fa fa-check float-right gl-mr-2"
/>
</router-link-stub>
</gl-new-dropdown-item-stub> </gl-new-dropdown-item-stub>
<gl-new-dropdown-item-stub <gl-new-dropdown-item-stub
avatarurl="" avatarurl=""
iconcolor="" iconcolor=""
iconname="" iconname=""
iconrightname="" iconrightname=""
ischeckitem="true"
secondarytext="" secondarytext=""
> >
<router-link-stub
class="d-flex js-version-link" Version 1
to="[object Object]"
> <!---->
<div
class="flex-grow-1 ml-2"
>
<div>
<strong>
Version 1
<!---->
</strong>
</div>
</div>
<!---->
</router-link-stub>
</gl-new-dropdown-item-stub> </gl-new-dropdown-item-stub>
</gl-new-dropdown-stub> </gl-new-dropdown-stub>
`; `;
...@@ -42,7 +42,7 @@ describe('Design management design version dropdown component', () => { ...@@ -42,7 +42,7 @@ describe('Design management design version dropdown component', () => {
wrapper.destroy(); wrapper.destroy();
}); });
const findVersionLink = index => wrapper.findAll('.js-version-link').at(index); const findVersionLink = index => wrapper.findAll(GlNewDropdownItem).at(index);
it('renders design version dropdown button', () => { it('renders design version dropdown button', () => {
createComponent(); createComponent();
...@@ -75,7 +75,7 @@ describe('Design management design version dropdown component', () => { ...@@ -75,7 +75,7 @@ describe('Design management design version dropdown component', () => {
createComponent(); createComponent();
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(GlNewDropdown).attributes('text')).toBe('Showing Latest Version'); expect(wrapper.find(GlNewDropdown).attributes('text')).toBe('Showing latest version');
}); });
}); });
...@@ -83,7 +83,7 @@ describe('Design management design version dropdown component', () => { ...@@ -83,7 +83,7 @@ describe('Design management design version dropdown component', () => {
createComponent({ maxVersions: 1 }); createComponent({ maxVersions: 1 });
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(GlNewDropdown).attributes('text')).toBe('Showing Latest Version'); expect(wrapper.find(GlNewDropdown).attributes('text')).toBe('Showing latest version');
}); });
}); });
...@@ -91,7 +91,7 @@ describe('Design management design version dropdown component', () => { ...@@ -91,7 +91,7 @@ describe('Design management design version dropdown component', () => {
createComponent({ $route: designRouteFactory(PREVIOUS_VERSION_ID) }); createComponent({ $route: designRouteFactory(PREVIOUS_VERSION_ID) });
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(GlNewDropdown).attributes('text')).toBe(`Showing Version #1`); expect(wrapper.find(GlNewDropdown).attributes('text')).toBe(`Showing version #1`);
}); });
}); });
...@@ -99,7 +99,7 @@ describe('Design management design version dropdown component', () => { ...@@ -99,7 +99,7 @@ describe('Design management design version dropdown component', () => {
createComponent({ $route: designRouteFactory(LATEST_VERSION_ID) }); createComponent({ $route: designRouteFactory(LATEST_VERSION_ID) });
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(GlNewDropdown).attributes('text')).toBe('Showing Latest Version'); expect(wrapper.find(GlNewDropdown).attributes('text')).toBe('Showing latest version');
}); });
}); });
......
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