Commit 5f36eb69 authored by Scott Stern's avatar Scott Stern Committed by Ezekiel Kigbo

Sort filtered search tokens

parent 3372ff2e
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { GlFilteredSearchToken } from '@gitlab/ui'; import { GlFilteredSearchToken } from '@gitlab/ui';
import fuzzaldrinPlus from 'fuzzaldrin-plus'; import fuzzaldrinPlus from 'fuzzaldrin-plus';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import { orderBy } from 'lodash';
import BoardFilteredSearch from 'ee_else_ce/boards/components/board_filtered_search.vue'; import BoardFilteredSearch from 'ee_else_ce/boards/components/board_filtered_search.vue';
import { BoardType } from '~/boards/constants'; import { BoardType } from '~/boards/constants';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
...@@ -79,7 +80,7 @@ export default { ...@@ -79,7 +80,7 @@ export default {
this.boardType, this.boardType,
); );
return [ const tokens = [
{ {
icon: 'user', icon: 'user',
title: assignee, title: assignee,
...@@ -189,6 +190,8 @@ export default { ...@@ -189,6 +190,8 @@ export default {
}, },
}, },
]; ];
return orderBy(tokens, ['title']);
}, },
tokens() { tokens() {
return this.tokensCE; return this.tokensCE;
......
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
} from '@gitlab/ui'; } from '@gitlab/ui';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import fuzzaldrinPlus from 'fuzzaldrin-plus'; import fuzzaldrinPlus from 'fuzzaldrin-plus';
import { orderBy } from 'lodash';
import getIssuesQuery from 'ee_else_ce/issues_list/queries/get_issues.query.graphql'; import getIssuesQuery from 'ee_else_ce/issues_list/queries/get_issues.query.graphql';
import getIssuesCountsQuery from 'ee_else_ce/issues_list/queries/get_issues_counts.query.graphql'; import getIssuesCountsQuery from 'ee_else_ce/issues_list/queries/get_issues_counts.query.graphql';
import IssueCardTimeInfo from 'ee_else_ce/issues_list/components/issue_card_time_info.vue'; import IssueCardTimeInfo from 'ee_else_ce/issues_list/components/issue_card_time_info.vue';
...@@ -405,7 +406,7 @@ export default { ...@@ -405,7 +406,7 @@ export default {
tokens.sort((a, b) => a.title.localeCompare(b.title)); tokens.sort((a, b) => a.title.localeCompare(b.title));
return tokens; return orderBy(tokens, ['title']);
}, },
showPaginationControls() { showPaginationControls() {
return this.issues.length > 0 && (this.pageInfo.hasNextPage || this.pageInfo.hasPreviousPage); return this.issues.length > 0 && (this.pageInfo.hasNextPage || this.pageInfo.hasPreviousPage);
......
<script> <script>
import { orderBy } from 'lodash';
import BoardFilteredSearch from 'ee/boards/components/board_filtered_search.vue'; import BoardFilteredSearch from 'ee/boards/components/board_filtered_search.vue';
import issueBoardFilter from '~/boards/issue_board_filters'; import issueBoardFilter from '~/boards/issue_board_filters';
import { TYPE_USER } from '~/graphql_shared/constants'; import { TYPE_USER } from '~/graphql_shared/constants';
...@@ -34,7 +35,7 @@ export default { ...@@ -34,7 +35,7 @@ export default {
); );
const { label, author } = this.$options.i18n; const { label, author } = this.$options.i18n;
return [ const tokens = [
{ {
icon: 'labels', icon: 'labels',
title: label, title: label,
...@@ -58,6 +59,8 @@ export default { ...@@ -58,6 +59,8 @@ export default {
preloadedAuthors: this.preloadedAuthors(), preloadedAuthors: this.preloadedAuthors(),
}, },
]; ];
return orderBy(tokens, ['title']);
}, },
}, },
methods: { methods: {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// extends a valid Vue single file component. // extends a valid Vue single file component.
/* eslint-disable @gitlab/no-runtime-template-compiler */ /* eslint-disable @gitlab/no-runtime-template-compiler */
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import { orderBy } from 'lodash';
import IssueBoardFilteredSearchFoss from '~/boards/components/issue_board_filtered_search.vue'; import IssueBoardFilteredSearchFoss from '~/boards/components/issue_board_filtered_search.vue';
import { BoardType } from '~/boards/constants'; import { BoardType } from '~/boards/constants';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -33,7 +34,7 @@ export default { ...@@ -33,7 +34,7 @@ export default {
tokens() { tokens() {
const { epic, iteration, weight } = this.$options.i18n; const { epic, iteration, weight } = this.$options.i18n;
return [ const tokens = [
...this.tokensCE, ...this.tokensCE,
{ {
type: 'epic', type: 'epic',
...@@ -67,6 +68,8 @@ export default { ...@@ -67,6 +68,8 @@ export default {
unique: true, unique: true,
}, },
]; ];
return orderBy(tokens, ['title']);
}, },
}, },
methods: { methods: {
......
import { GlFilteredSearchToken } from '@gitlab/ui'; import { GlFilteredSearchToken } from '@gitlab/ui';
import { orderBy } from 'lodash';
import Api from '~/api'; import Api from '~/api';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -183,7 +183,7 @@ export default { ...@@ -183,7 +183,7 @@ export default {
}); });
} }
return tokens; return orderBy(tokens, ['title']);
}, },
getFilteredSearchValue() { getFilteredSearchValue() {
const { const {
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { orderBy } from 'lodash';
import EpicFilteredSearch from 'ee/boards/components/epic_filtered_search.vue'; import EpicFilteredSearch from 'ee/boards/components/epic_filtered_search.vue';
import BoardFilteredSearch from 'ee/boards/components/board_filtered_search.vue'; import BoardFilteredSearch from 'ee/boards/components/board_filtered_search.vue';
import issueBoardFilters from '~/boards/issue_board_filters'; import issueBoardFilters from '~/boards/issue_board_filters';
...@@ -72,7 +73,9 @@ describe('EpicFilteredSearch', () => { ...@@ -72,7 +73,9 @@ describe('EpicFilteredSearch', () => {
], ],
}, },
]; ];
expect(wrapper.find(BoardFilteredSearch).props('tokens').toString()).toBe(tokens.toString()); expect(wrapper.find(BoardFilteredSearch).props('tokens').toString()).toBe(
orderBy(tokens, ['title']).toString(),
);
}); });
}); });
}); });
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { orderBy } from 'lodash';
import BoardFilteredSearch from 'ee/boards/components/board_filtered_search.vue'; import BoardFilteredSearch from 'ee/boards/components/board_filtered_search.vue';
import IssueBoardFilteredSpec from 'ee/boards/components/issue_board_filtered_search.vue'; import IssueBoardFilteredSpec from 'ee/boards/components/issue_board_filtered_search.vue';
import issueBoardFilters from '~/boards/issue_board_filters'; import issueBoardFilters from '~/boards/issue_board_filters';
...@@ -55,7 +56,7 @@ describe('IssueBoardFilter', () => { ...@@ -55,7 +56,7 @@ describe('IssueBoardFilter', () => {
wrapper.vm.fetchIterations, wrapper.vm.fetchIterations,
); );
expect(wrapper.find(BoardFilteredSearch).props('tokens')).toEqual(tokens); expect(wrapper.find(BoardFilteredSearch).props('tokens')).toEqual(orderBy(tokens, ['title']));
}); });
}); });
}); });
...@@ -197,10 +197,10 @@ describe('RoadmapFilters', () => { ...@@ -197,10 +197,10 @@ describe('RoadmapFilters', () => {
it('includes `Author`, `Milestone`, `Confidential`, `Epic` and `Label` tokens when user is not logged in', () => { it('includes `Author`, `Milestone`, `Confidential`, `Epic` and `Label` tokens when user is not logged in', () => {
expect(filteredSearchBar.props('tokens')).toEqual([ expect(filteredSearchBar.props('tokens')).toEqual([
mockAuthorTokenConfig, mockAuthorTokenConfig,
mockLabelTokenConfig,
mockMilestoneTokenConfig,
mockConfidentialTokenConfig, mockConfidentialTokenConfig,
mockEpicTokenConfig, mockEpicTokenConfig,
mockLabelTokenConfig,
mockMilestoneTokenConfig,
]); ]);
}); });
...@@ -310,10 +310,10 @@ describe('RoadmapFilters', () => { ...@@ -310,10 +310,10 @@ describe('RoadmapFilters', () => {
}, },
], ],
}, },
mockLabelTokenConfig,
mockMilestoneTokenConfig,
mockConfidentialTokenConfig, mockConfidentialTokenConfig,
mockEpicTokenConfig, mockEpicTokenConfig,
mockLabelTokenConfig,
mockMilestoneTokenConfig,
mockReactionEmojiTokenConfig, mockReactionEmojiTokenConfig,
]); ]);
}); });
......
import { orderBy } from 'lodash';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import BoardFilteredSearch from 'ee_else_ce/boards/components/board_filtered_search.vue'; import BoardFilteredSearch from 'ee_else_ce/boards/components/board_filtered_search.vue';
import IssueBoardFilteredSpec from '~/boards/components/issue_board_filtered_search.vue'; import IssueBoardFilteredSpec from '~/boards/components/issue_board_filtered_search.vue';
...@@ -62,7 +63,7 @@ describe('IssueBoardFilter', () => { ...@@ -62,7 +63,7 @@ describe('IssueBoardFilter', () => {
isSignedIn, isSignedIn,
); );
expect(findBoardsFilteredSearch().props('tokens')).toEqual(tokens); expect(findBoardsFilteredSearch().props('tokens')).toEqual(orderBy(tokens, ['title']));
}, },
); );
}); });
......
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