Commit 22e722ec authored by Paul Slaughter's avatar Paul Slaughter

Merge branch '321732-use-glavatarlabeled-to-improve-invite-a-group-modal-dropdown' into 'master'

Add group avatars to invite modal dropdown

See merge request gitlab-org/gitlab!62263
parents 58450269 d65e6206
<script>
import { GlDropdown, GlDropdownItem, GlDropdownText, GlSearchBoxByType } from '@gitlab/ui';
import {
GlAvatarLabeled,
GlDropdown,
GlDropdownItem,
GlDropdownText,
GlSearchBoxByType,
} from '@gitlab/ui';
import { debounce } from 'lodash';
import Api from '~/api';
import { s__ } from '~/locale';
......@@ -8,6 +14,7 @@ import { SEARCH_DELAY } from '../constants';
export default {
name: 'GroupSelect',
components: {
GlAvatarLabeled,
GlDropdown,
GlDropdownItem,
GlDropdownText,
......@@ -49,6 +56,7 @@ export default {
id: group.id,
name: group.full_name,
path: group.path,
avatarUrl: group.avatar_url,
}));
this.isFetching = false;
})
......@@ -82,7 +90,7 @@ export default {
menu-class="gl-w-full!"
>
<gl-search-box-by-type
v-model.trim="searchTerm"
v-model="searchTerm"
:is-loading="isFetching"
:placeholder="$options.i18n.searchPlaceholder"
data-qa-selector="group_select_dropdown_search_field"
......@@ -93,7 +101,13 @@ export default {
:name="group.name"
@click="selectGroup(group)"
>
{{ group.name }}
<gl-avatar-labeled
:label="group.name"
:src="group.avatarUrl"
:entity-id="group.id"
:entity-name="group.name"
:size="32"
/>
</gl-dropdown-item>
<gl-dropdown-text v-if="isFetchResultEmpty && !isFetching" data-testid="empty-result-message">
<span class="gl-text-gray-500">{{ $options.i18n.emptySearchResult }}</span>
......
import { GlDropdown, GlDropdownItem, GlSearchBoxByType } from '@gitlab/ui';
import { GlAvatarLabeled, GlDropdown, GlSearchBoxByType } from '@gitlab/ui';
import { mount } from '@vue/test-utils';
import waitForPromises from 'helpers/wait_for_promises';
import Api from '~/api';
......@@ -8,8 +8,8 @@ const createComponent = () => {
return mount(GroupSelect, {});
};
const group1 = { id: 1, full_name: 'Group One' };
const group2 = { id: 2, full_name: 'Group Two' };
const group1 = { id: 1, full_name: 'Group One', avatar_url: 'test' };
const group2 = { id: 2, full_name: 'Group Two', avatar_url: 'test' };
const allGroups = [group1, group2];
describe('GroupSelect', () => {
......@@ -29,10 +29,10 @@ describe('GroupSelect', () => {
const findSearchBoxByType = () => wrapper.findComponent(GlSearchBoxByType);
const findDropdown = () => wrapper.findComponent(GlDropdown);
const findDropdownToggle = () => findDropdown().find('button[aria-haspopup="true"]');
const findDropdownItemByText = (text) =>
const findAvatarByLabel = (text) =>
wrapper
.findAllComponents(GlDropdownItem)
.wrappers.find((dropdownItemWrapper) => dropdownItemWrapper.text() === text);
.findAllComponents(GlAvatarLabeled)
.wrappers.find((dropdownItemWrapper) => dropdownItemWrapper.props('label') === text);
it('renders GlSearchBoxByType with default attributes', () => {
expect(findSearchBoxByType().exists()).toBe(true);
......@@ -74,9 +74,20 @@ describe('GroupSelect', () => {
});
});
describe('avatar label', () => {
it('includes the correct attributes with name and avatar_url', () => {
expect(findAvatarByLabel(group1.full_name).attributes()).toMatchObject({
src: group1.avatar_url,
'entity-id': `${group1.id}`,
'entity-name': group1.full_name,
size: '32',
});
});
});
describe('when group is selected from the dropdown', () => {
beforeEach(() => {
findDropdownItemByText(group1.full_name).vm.$emit('click');
findAvatarByLabel(group1.full_name).trigger('click');
});
it('emits `input` event used by `v-model`', () => {
......
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