Commit 651b52ef authored by Coung Ngo's avatar Coung Ngo

Use ProjectAvatar in `frequent_items_list_item.vue`

https://gitlab.com/gitlab-org/gitlab/-/issues/335362

Changelog: fixed
parent 61820f46
...@@ -5,14 +5,14 @@ import highlight from '~/lib/utils/highlight'; ...@@ -5,14 +5,14 @@ import highlight from '~/lib/utils/highlight';
import { truncateNamespace } from '~/lib/utils/text_utility'; import { truncateNamespace } from '~/lib/utils/text_utility';
import { mapVuexModuleState } from '~/lib/utils/vuex_module_mappers'; import { mapVuexModuleState } from '~/lib/utils/vuex_module_mappers';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import Identicon from '~/vue_shared/components/identicon.vue'; import ProjectAvatar from '~/vue_shared/components/project_avatar.vue';
const trackingMixin = Tracking.mixin(); const trackingMixin = Tracking.mixin();
export default { export default {
components: { components: {
Identicon,
GlButton, GlButton,
ProjectAvatar,
}, },
mixins: [trackingMixin], mixins: [trackingMixin],
inject: ['vuexModule'], inject: ['vuexModule'],
...@@ -64,19 +64,12 @@ export default { ...@@ -64,19 +64,12 @@ export default {
class="gl-text-left gl-justify-content-start!" class="gl-text-left gl-justify-content-start!"
@click="track('click_link', { label: `${dropdownType}_dropdown_frequent_items_list_item` })" @click="track('click_link', { label: `${dropdownType}_dropdown_frequent_items_list_item` })"
> >
<div <project-avatar
ref="frequentItemsItemAvatarContainer" class="gl-float-left gl-mr-3"
class="frequent-items-item-avatar-container avatar-container rect-avatar s32" :project-avatar-url="avatarUrl"
> :project-name="itemName"
<img v-if="avatarUrl" ref="frequentItemsItemAvatar" :src="avatarUrl" class="avatar s32" /> aria-hidden="true"
<identicon />
v-else
:entity-id="itemId"
:entity-name="itemName"
size-class="s32"
class="rect-avatar"
/>
</div>
<div ref="frequentItemsItemMetadataContainer" class="frequent-items-item-metadata-container"> <div ref="frequentItemsItemMetadataContainer" class="frequent-items-item-metadata-container">
<div <div
ref="frequentItemsItemTitle" ref="frequentItemsItemTitle"
......
...@@ -933,13 +933,9 @@ header.header-content .dropdown-menu.frequent-items-dropdown-menu { ...@@ -933,13 +933,9 @@ header.header-content .dropdown-menu.frequent-items-dropdown-menu {
} }
.frequent-items-list-item-container { .frequent-items-list-item-container {
.frequent-items-item-avatar-container,
.frequent-items-item-metadata-container {
flex-shrink: 0;
}
.frequent-items-item-metadata-container { .frequent-items-item-metadata-container {
display: flex; display: flex;
flex-shrink: 0;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
} }
...@@ -951,12 +947,6 @@ header.header-content .dropdown-menu.frequent-items-dropdown-menu { ...@@ -951,12 +947,6 @@ header.header-content .dropdown-menu.frequent-items-dropdown-menu {
white-space: nowrap; white-space: nowrap;
} }
&:hover {
.frequent-items-item-avatar-container .avatar {
border-color: $gray-50;
}
}
.frequent-items-item-title { .frequent-items-item-title {
font-size: $gl-font-size; font-size: $gl-font-size;
font-weight: 400; font-weight: 400;
......
...@@ -5,6 +5,7 @@ import { trimText } from 'helpers/text_helper'; ...@@ -5,6 +5,7 @@ import { trimText } from 'helpers/text_helper';
import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
import frequentItemsListItemComponent from '~/frequent_items/components/frequent_items_list_item.vue'; import frequentItemsListItemComponent from '~/frequent_items/components/frequent_items_list_item.vue';
import { createStore } from '~/frequent_items/store'; import { createStore } from '~/frequent_items/store';
import ProjectAvatar from '~/vue_shared/components/project_avatar.vue';
import { mockProject } from '../mock_data'; import { mockProject } from '../mock_data';
const localVue = createLocalVue(); const localVue = createLocalVue();
...@@ -16,12 +17,12 @@ describe('FrequentItemsListItemComponent', () => { ...@@ -16,12 +17,12 @@ describe('FrequentItemsListItemComponent', () => {
let store; let store;
const findTitle = () => wrapper.find({ ref: 'frequentItemsItemTitle' }); const findTitle = () => wrapper.find({ ref: 'frequentItemsItemTitle' });
const findAvatar = () => wrapper.find({ ref: 'frequentItemsItemAvatar' }); const findAvatar = () => wrapper.findComponent(ProjectAvatar);
const findAllTitles = () => wrapper.findAll({ ref: 'frequentItemsItemTitle' }); const findAllTitles = () => wrapper.findAll({ ref: 'frequentItemsItemTitle' });
const findNamespace = () => wrapper.find({ ref: 'frequentItemsItemNamespace' }); const findNamespace = () => wrapper.find({ ref: 'frequentItemsItemNamespace' });
const findAllButtons = () => wrapper.findAllComponents(GlButton); const findAllButtons = () => wrapper.findAllComponents(GlButton);
const findAllNamespace = () => wrapper.findAll({ ref: 'frequentItemsItemNamespace' }); const findAllNamespace = () => wrapper.findAll({ ref: 'frequentItemsItemNamespace' });
const findAvatarContainer = () => wrapper.findAll({ ref: 'frequentItemsItemAvatarContainer' }); const findAllAvatars = () => wrapper.findAllComponents(ProjectAvatar);
const findAllMetadataContainers = () => const findAllMetadataContainers = () =>
wrapper.findAll({ ref: 'frequentItemsItemMetadataContainer' }); wrapper.findAll({ ref: 'frequentItemsItemMetadataContainer' });
...@@ -92,16 +93,8 @@ describe('FrequentItemsListItemComponent', () => { ...@@ -92,16 +93,8 @@ describe('FrequentItemsListItemComponent', () => {
createComponent(); createComponent();
}); });
it('should render avatar if avatarUrl is present', () => { it('renders avatar', () => {
wrapper.setProps({ avatarUrl: 'path/to/avatar.png' }); expect(findAvatar().exists()).toBe(true);
return wrapper.vm.$nextTick(() => {
expect(findAvatar().exists()).toBe(true);
});
});
it('should not render avatar if avatarUrl is not present', () => {
expect(findAvatar().exists()).toBe(false);
}); });
it('renders root element with the right classes', () => { it('renders root element with the right classes', () => {
...@@ -111,7 +104,7 @@ describe('FrequentItemsListItemComponent', () => { ...@@ -111,7 +104,7 @@ describe('FrequentItemsListItemComponent', () => {
it.each` it.each`
name | selector | expected name | selector | expected
${'button'} | ${findAllButtons} | ${1} ${'button'} | ${findAllButtons} | ${1}
${'avatar container'} | ${findAvatarContainer} | ${1} ${'avatar container'} | ${findAllAvatars} | ${1}
${'metadata container'} | ${findAllMetadataContainers} | ${1} ${'metadata container'} | ${findAllMetadataContainers} | ${1}
${'title'} | ${findAllTitles} | ${1} ${'title'} | ${findAllTitles} | ${1}
${'namespace'} | ${findAllNamespace} | ${1} ${'namespace'} | ${findAllNamespace} | ${1}
......
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