Commit 6c9cb080 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'rj/design-version-selector' into 'master'

Provide more information in design version selector

See merge request gitlab-org/gitlab!67844
parents 3019433a 0328208f
<script> <script>
import { GlDropdown, GlDropdownItem, GlSprintf } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem, GlSprintf } from '@gitlab/ui';
import defaultAvatarUrl from 'images/no_avatar.png';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
import allVersionsMixin from '../../mixins/all_versions'; import allVersionsMixin from '../../mixins/all_versions';
import { findVersionId } from '../../utils/design_management_utils'; import { findVersionId } from '../../utils/design_management_utils';
...@@ -9,6 +11,7 @@ export default { ...@@ -9,6 +11,7 @@ export default {
GlDropdown, GlDropdown,
GlDropdownItem, GlDropdownItem,
GlSprintf, GlSprintf,
TimeAgo,
}, },
mixins: [allVersionsMixin], mixins: [allVersionsMixin],
computed: { computed: {
...@@ -58,6 +61,9 @@ export default { ...@@ -58,6 +61,9 @@ export default {
} }
return __('Version %{versionNumber}'); return __('Version %{versionNumber}');
}, },
getAvatarUrl(version) {
return version?.author?.avatarUrl || defaultAvatarUrl;
},
}, },
}; };
</script> </script>
...@@ -68,14 +74,28 @@ export default { ...@@ -68,14 +74,28 @@ export default {
v-for="(version, index) in allVersions" v-for="(version, index) in allVersions"
:key="version.id" :key="version.id"
:is-check-item="true" :is-check-item="true"
:is-check-centered="true"
:is-checked="findVersionId(version.id) === currentVersionId" :is-checked="findVersionId(version.id) === currentVersionId"
:avatar-url="getAvatarUrl(version)"
@click="routeToVersion(version.id)" @click="routeToVersion(version.id)"
> >
<strong>
<gl-sprintf :message="versionText(version.id)"> <gl-sprintf :message="versionText(version.id)">
<template #versionNumber> <template #versionNumber>
{{ allVersions.length - index }} {{ allVersions.length - index }}
</template> </template>
</gl-sprintf> </gl-sprintf>
</strong>
<div v-if="version.author" class="gl-text-gray-600 gl-mt-1">
<div>{{ version.author.name }}</div>
<time-ago
v-if="version.createdAt"
class="text-1"
:time="version.createdAt"
tooltip-placement="bottom"
/>
</div>
</gl-dropdown-item> </gl-dropdown-item>
</gl-dropdown> </gl-dropdown>
</template> </template>
...@@ -32,6 +32,13 @@ query getDesignList($fullPath: ID!, $iid: String!, $atVersion: ID) { ...@@ -32,6 +32,13 @@ query getDesignList($fullPath: ID!, $iid: String!, $atVersion: ID) {
__typename __typename
id id
sha sha
createdAt
author {
__typename
id
name
avatarUrl
}
} }
} }
} }
......
...@@ -17,13 +17,31 @@ exports[`Design management design version dropdown component renders design vers ...@@ -17,13 +17,31 @@ exports[`Design management design version dropdown component renders design vers
iconname="" iconname=""
iconrightarialabel="" iconrightarialabel=""
iconrightname="" iconrightname=""
ischeckcentered="true"
ischecked="true" ischecked="true"
ischeckitem="true" ischeckitem="true"
secondarytext="" secondarytext=""
> >
<strong>
Version Version
2 2
(latest) (latest)
</strong>
<div
class="gl-text-gray-600 gl-mt-1"
>
<div>
Adminstrator
</div>
<time-ago-stub
class="text-1"
cssclass=""
time="2021-08-09T06:05:00Z"
tooltipplacement="bottom"
/>
</div>
</gl-dropdown-item-stub> </gl-dropdown-item-stub>
<gl-dropdown-item-stub <gl-dropdown-item-stub
avatarurl="" avatarurl=""
...@@ -31,12 +49,30 @@ exports[`Design management design version dropdown component renders design vers ...@@ -31,12 +49,30 @@ exports[`Design management design version dropdown component renders design vers
iconname="" iconname=""
iconrightarialabel="" iconrightarialabel=""
iconrightname="" iconrightname=""
ischeckcentered="true"
ischeckitem="true" ischeckitem="true"
secondarytext="" secondarytext=""
> >
<strong>
Version Version
1 1
</strong>
<div
class="gl-text-gray-600 gl-mt-1"
>
<div>
Adminstrator
</div>
<time-ago-stub
class="text-1"
cssclass=""
time="2021-08-09T06:05:00Z"
tooltipplacement="bottom"
/>
</div>
</gl-dropdown-item-stub> </gl-dropdown-item-stub>
</gl-dropdown-stub> </gl-dropdown-stub>
`; `;
...@@ -58,13 +94,31 @@ exports[`Design management design version dropdown component renders design vers ...@@ -58,13 +94,31 @@ exports[`Design management design version dropdown component renders design vers
iconname="" iconname=""
iconrightarialabel="" iconrightarialabel=""
iconrightname="" iconrightname=""
ischeckcentered="true"
ischecked="true" ischecked="true"
ischeckitem="true" ischeckitem="true"
secondarytext="" secondarytext=""
> >
<strong>
Version Version
2 2
(latest) (latest)
</strong>
<div
class="gl-text-gray-600 gl-mt-1"
>
<div>
Adminstrator
</div>
<time-ago-stub
class="text-1"
cssclass=""
time="2021-08-09T06:05:00Z"
tooltipplacement="bottom"
/>
</div>
</gl-dropdown-item-stub> </gl-dropdown-item-stub>
<gl-dropdown-item-stub <gl-dropdown-item-stub
avatarurl="" avatarurl=""
...@@ -72,12 +126,30 @@ exports[`Design management design version dropdown component renders design vers ...@@ -72,12 +126,30 @@ exports[`Design management design version dropdown component renders design vers
iconname="" iconname=""
iconrightarialabel="" iconrightarialabel=""
iconrightname="" iconrightname=""
ischeckcentered="true"
ischeckitem="true" ischeckitem="true"
secondarytext="" secondarytext=""
> >
<strong>
Version Version
1 1
</strong>
<div
class="gl-text-gray-600 gl-mt-1"
>
<div>
Adminstrator
</div>
<time-ago-stub
class="text-1"
cssclass=""
time="2021-08-09T06:05:00Z"
tooltipplacement="bottom"
/>
</div>
</gl-dropdown-item-stub> </gl-dropdown-item-stub>
</gl-dropdown-stub> </gl-dropdown-stub>
`; `;
import { GlDropdown, GlDropdownItem, GlSprintf } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import DesignVersionDropdown from '~/design_management/components/upload/design_version_dropdown.vue'; import DesignVersionDropdown from '~/design_management/components/upload/design_version_dropdown.vue';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
import mockAllVersions from './mock_data/all_versions'; import mockAllVersions from './mock_data/all_versions';
const LATEST_VERSION_ID = 3; const LATEST_VERSION_ID = 1;
const PREVIOUS_VERSION_ID = 2; const PREVIOUS_VERSION_ID = 2;
const designRouteFactory = (versionId) => ({ const designRouteFactory = (versionId) => ({
...@@ -110,5 +111,13 @@ describe('Design management design version dropdown component', () => { ...@@ -110,5 +111,13 @@ describe('Design management design version dropdown component', () => {
expect(wrapper.findAll(GlDropdownItem)).toHaveLength(wrapper.vm.allVersions.length); expect(wrapper.findAll(GlDropdownItem)).toHaveLength(wrapper.vm.allVersions.length);
}); });
}); });
it('should render TimeAgo', async () => {
createComponent();
await wrapper.vm.$nextTick();
expect(wrapper.findAllComponents(TimeAgo)).toHaveLength(wrapper.vm.allVersions.length);
});
}); });
}); });
export default [ export default [
{ {
id: 'gid://gitlab/DesignManagement::Version/3', id: 'gid://gitlab/DesignManagement::Version/1',
sha: '0945756378e0b1588b9dd40d5a6b99e8b7198f55', sha: 'b389071a06c153509e11da1f582005b316667001',
createdAt: '2021-08-09T06:05:00Z',
author: {
id: 'gid://gitlab/User/1',
name: 'Adminstrator',
},
}, },
{ {
id: 'gid://gitlab/DesignManagement::Version/2', id: 'gid://gitlab/DesignManagement::Version/2',
sha: '5b063fef0cd7213b312db65b30e24f057df21b20', sha: 'b389071a06c153509e11da1f582005b316667021',
createdAt: '2021-08-09T06:05:00Z',
author: {
id: 'gid://gitlab/User/1',
name: 'Adminstrator',
},
}, },
]; ];
...@@ -2,5 +2,19 @@ export default [ ...@@ -2,5 +2,19 @@ export default [
{ {
id: 'gid://gitlab/DesignManagement::Version/1', id: 'gid://gitlab/DesignManagement::Version/1',
sha: 'b389071a06c153509e11da1f582005b316667001', sha: 'b389071a06c153509e11da1f582005b316667001',
createdAt: '2021-08-09T06:05:00Z',
author: {
id: 'gid://gitlab/User/1',
name: 'Adminstrator',
},
},
{
id: 'gid://gitlab/DesignManagement::Version/1',
sha: 'b389071a06c153509e11da1f582005b316667021',
createdAt: '2021-08-09T06:05:00Z',
author: {
id: 'gid://gitlab/User/1',
name: 'Adminstrator',
},
}, },
]; ];
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