diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-14 03:17:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-14 03:17:46 +0300 |
commit | 270353e1ff556a43333f82f171c3a485958126f0 (patch) | |
tree | c7bb4ac335b1e101b9bf92905ec2e8e170c6696c /app/assets/javascripts/search | |
parent | b2e3da6a38f143a8c782dae4baceae3ed764733d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/search')
-rw-r--r-- | app/assets/javascripts/search/index.js | 1 | ||||
-rw-r--r-- | app/assets/javascripts/search/store/constants.js | 12 | ||||
-rw-r--r-- | app/assets/javascripts/search/store/getters.js | 13 | ||||
-rw-r--r-- | app/assets/javascripts/search/store/index.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/search/store/state.js | 3 | ||||
-rw-r--r-- | app/assets/javascripts/search/store/utils.js | 4 |
6 files changed, 33 insertions, 4 deletions
diff --git a/app/assets/javascripts/search/index.js b/app/assets/javascripts/search/index.js index d71785d7fac..1e4b1e36514 100644 --- a/app/assets/javascripts/search/index.js +++ b/app/assets/javascripts/search/index.js @@ -15,6 +15,7 @@ export const initSearchApp = () => { const store = createStore({ query, navigation, + useNewNavigation: gon.use_new_navigation, }); initTopbar(store); diff --git a/app/assets/javascripts/search/store/constants.js b/app/assets/javascripts/search/store/constants.js index 3f586c5fed8..c8ee0a3f9d9 100644 --- a/app/assets/javascripts/search/store/constants.js +++ b/app/assets/javascripts/search/store/constants.js @@ -17,3 +17,15 @@ export const SIDEBAR_PARAMS = [ ]; export const NUMBER_FORMATING_OPTIONS = { notation: 'compact', compactDisplay: 'short' }; + +export const ICON_MAP = { + blobs: 'code', + issues: 'issues', + merge_requests: 'merge-request', + commits: 'commit', + notes: 'comments', + milestones: 'tag', + users: 'users', + projects: 'project', + wiki_blobs: 'overview', +}; diff --git a/app/assets/javascripts/search/store/getters.js b/app/assets/javascripts/search/store/getters.js index 0e387607af7..135c9a3d67c 100644 --- a/app/assets/javascripts/search/store/getters.js +++ b/app/assets/javascripts/search/store/getters.js @@ -1,7 +1,8 @@ import { findKey, has } from 'lodash'; import { languageFilterData } from '~/search/sidebar/components/language_filter/data'; +import { formatSearchResultCount, addCountOverLimit } from '~/search/store/utils'; -import { GROUPS_LOCAL_STORAGE_KEY, PROJECTS_LOCAL_STORAGE_KEY } from './constants'; +import { GROUPS_LOCAL_STORAGE_KEY, PROJECTS_LOCAL_STORAGE_KEY, ICON_MAP } from './constants'; export const frequentGroups = (state) => { return state.frequentItems[GROUPS_LOCAL_STORAGE_KEY]; @@ -26,3 +27,13 @@ export const queryLanguageFilters = (state) => state.query[languageFilterData.fi export const currentUrlQueryHasLanguageFilters = (state) => has(state.urlQuery, languageFilterData.filterParam) && state.urlQuery[languageFilterData.filterParam]?.length > 0; + +export const navigationItems = (state) => + Object.values(state.navigation).map((item) => ({ + title: item.label, + icon: ICON_MAP[item.scope] || '', + link: item.link, + is_active: Boolean(item?.active), + pill_count: `${formatSearchResultCount(item?.count)}${addCountOverLimit(item?.count)}` || '', + items: [], + })); diff --git a/app/assets/javascripts/search/store/index.js b/app/assets/javascripts/search/store/index.js index e20a43808cf..634f8f7a7fa 100644 --- a/app/assets/javascripts/search/store/index.js +++ b/app/assets/javascripts/search/store/index.js @@ -7,11 +7,11 @@ import createState from './state'; Vue.use(Vuex); -export const getStoreConfig = ({ query, navigation }) => ({ +export const getStoreConfig = ({ query, navigation, useNewNavigation }) => ({ actions, getters, mutations, - state: createState({ query, navigation }), + state: createState({ query, navigation, useNewNavigation }), }); const createStore = (config) => new Vuex.Store(getStoreConfig(config)); diff --git a/app/assets/javascripts/search/store/state.js b/app/assets/javascripts/search/store/state.js index d85a135bb4e..a62b6728819 100644 --- a/app/assets/javascripts/search/store/state.js +++ b/app/assets/javascripts/search/store/state.js @@ -1,7 +1,7 @@ import { cloneDeep } from 'lodash'; import { GROUPS_LOCAL_STORAGE_KEY, PROJECTS_LOCAL_STORAGE_KEY } from './constants'; -const createState = ({ query, navigation }) => ({ +const createState = ({ query, navigation, useNewNavigation }) => ({ urlQuery: cloneDeep(query), query, groups: [], @@ -14,6 +14,7 @@ const createState = ({ query, navigation }) => ({ }, sidebarDirty: false, navigation, + useNewNavigation, aggregations: { error: false, fetching: false, diff --git a/app/assets/javascripts/search/store/utils.js b/app/assets/javascripts/search/store/utils.js index 9d1743e64ad..2f02ef3475c 100644 --- a/app/assets/javascripts/search/store/utils.js +++ b/app/assets/javascripts/search/store/utils.js @@ -144,3 +144,7 @@ export const prepareSearchAggregations = (state, aggregationData) => return item; }); + +export const addCountOverLimit = (count = '') => { + return count.includes('+') ? '+' : ''; +}; |