Commit a2ef287d authored by Scott Stern's avatar Scott Stern Committed by Olena Horal-Koretska

Add user to top of filtered search in epics

parent b587e0d5
<script>
import BoardFilteredSearch from '~/boards/components/board_filtered_search.vue';
import { TYPE_USER } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils';
import { __ } from '~/locale';
import AuthorToken from '~/vue_shared/components/filtered_search_bar/tokens/author_token.vue';
import LabelToken from '~/vue_shared/components/filtered_search_bar/tokens/label_token.vue';
......@@ -46,6 +48,7 @@ export default {
token: AuthorToken,
unique: true,
fetchAuthors: this.fetchAuthors,
preloadedAuthors: this.preloadedAuthors(),
},
];
},
......@@ -75,6 +78,18 @@ export default {
})
.then(({ data }) => data.group?.labels.nodes || []);
},
preloadedAuthors() {
return gon?.current_user_id
? [
{
id: convertToGraphQLId(TYPE_USER, gon.current_user_id),
name: gon.current_user_fullname,
username: gon.current_username,
avatarUrl: gon.current_user_avatar_url,
},
]
: [];
},
},
};
</script>
......
......@@ -16,6 +16,13 @@ describe('EpicFilteredSearch', () => {
});
};
window.gon = {
current_user_id: '4',
current_username: 'root',
current_user_avatar_url: 'url',
current_user_fullname: 'Admin',
};
afterEach(() => {
wrapper.destroy();
});
......@@ -56,6 +63,9 @@ describe('EpicFilteredSearch', () => {
token: AuthorToken,
unique: true,
fetchAuthors: wrapper.vm.fetchAuthors,
preloadedAuthors: [
{ id: 'gid://gitlab/User/4', name: 'Admin', username: 'root', avatarUrl: 'url' },
],
},
];
expect(wrapper.find(BoardFilteredSearch).props('tokens')).toEqual(tokens);
......
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