Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-14 21:08:38 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-14 21:08:38 +0300
commit14160fad80415337f8c08755af53ee994b4a7518 (patch)
treebfe1bf6bad8cda3e3bbf905c9d8ac742420dd8a3 /app/assets/javascripts/search
parent7a33080fff9a735cbe77968d67b13ffa92c0ffae (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/search')
-rw-r--r--app/assets/javascripts/search/sidebar/components/label_filter/data.js23
-rw-r--r--app/assets/javascripts/search/store/actions.js17
-rw-r--r--app/assets/javascripts/search/store/constants.js2
-rw-r--r--app/assets/javascripts/search/store/getters.js35
-rw-r--r--app/assets/javascripts/search/store/mutation_types.js2
-rw-r--r--app/assets/javascripts/search/store/mutations.js3
-rw-r--r--app/assets/javascripts/search/store/state.js1
7 files changed, 82 insertions, 1 deletions
diff --git a/app/assets/javascripts/search/sidebar/components/label_filter/data.js b/app/assets/javascripts/search/sidebar/components/label_filter/data.js
new file mode 100644
index 00000000000..654357da902
--- /dev/null
+++ b/app/assets/javascripts/search/sidebar/components/label_filter/data.js
@@ -0,0 +1,23 @@
+import { __ } from '~/locale';
+
+export const FIRST_DROPDOWN_INDEX = 0;
+
+export const SEARCH_BOX_INDEX = 0;
+
+export const SEARCH_INPUT_DESCRIPTION = 'label-search-input-description';
+
+export const SEARCH_RESULTS_DESCRIPTION = 'label-search-results-description';
+
+const header = __('Labels');
+
+const scopes = {
+ ISSUES: 'issues',
+};
+
+const filterParam = 'labels';
+
+export const labelFilterData = {
+ header,
+ scopes,
+ filterParam,
+};
diff --git a/app/assets/javascripts/search/store/actions.js b/app/assets/javascripts/search/store/actions.js
index 3fdc4165baf..077c46bbe22 100644
--- a/app/assets/javascripts/search/store/actions.js
+++ b/app/assets/javascripts/search/store/actions.js
@@ -5,6 +5,7 @@ import { visitUrl, setUrlParams } from '~/lib/utils/url_utility';
import { logError } from '~/lib/logger';
import { __ } from '~/locale';
import { languageFilterData } from '~/search/sidebar/components/language_filter/data';
+import { labelFilterData } from '~/search/sidebar/components/label_filter/data';
import { GROUPS_LOCAL_STORAGE_KEY, PROJECTS_LOCAL_STORAGE_KEY, SIDEBAR_PARAMS } from './constants';
import * as types from './mutation_types';
import {
@@ -108,10 +109,24 @@ export const applyQuery = ({ state }) => {
export const resetQuery = ({ state }) => {
visitUrl(
- setUrlParams({ ...state.query, page: null, state: null, confidential: null }, undefined, true),
+ setUrlParams(
+ { ...state.query, page: null, state: null, confidential: null, labels: null },
+ undefined,
+ true,
+ ),
);
};
+export const closeLabel = ({ state, commit }, { key }) => {
+ const labels = state?.query?.labels.filter((labelKey) => labelKey !== key);
+
+ setQuery({ state, commit }, { key: labelFilterData.filterParam, value: labels });
+};
+
+export const setLabelFilterSearch = ({ commit }, { value }) => {
+ commit(types.SET_LABEL_SEARCH_STRING, value);
+};
+
export const resetLanguageQueryWithRedirect = ({ state }) => {
visitUrl(setUrlParams({ ...state.query, language: null }, undefined, true));
};
diff --git a/app/assets/javascripts/search/store/constants.js b/app/assets/javascripts/search/store/constants.js
index c8ee0a3f9d9..91c16616f02 100644
--- a/app/assets/javascripts/search/store/constants.js
+++ b/app/assets/javascripts/search/store/constants.js
@@ -1,6 +1,7 @@
import { stateFilterData } from '~/search/sidebar/constants/state_filter_data';
import { confidentialFilterData } from '~/search/sidebar/constants/confidential_filter_data';
import { languageFilterData } from '~/search/sidebar/components/language_filter/data';
+import { labelFilterData } from '~/search/sidebar/components/label_filter/data';
export const MAX_FREQUENT_ITEMS = 5;
@@ -14,6 +15,7 @@ export const SIDEBAR_PARAMS = [
stateFilterData.filterParam,
confidentialFilterData.filterParam,
languageFilterData.filterParam,
+ labelFilterData.filterParam,
];
export const NUMBER_FORMATING_OPTIONS = { notation: 'compact', compactDisplay: 'short' };
diff --git a/app/assets/javascripts/search/store/getters.js b/app/assets/javascripts/search/store/getters.js
index 135c9a3d67c..d31d2b5ae11 100644
--- a/app/assets/javascripts/search/store/getters.js
+++ b/app/assets/javascripts/search/store/getters.js
@@ -1,5 +1,6 @@
import { findKey, has } from 'lodash';
import { languageFilterData } from '~/search/sidebar/components/language_filter/data';
+import { labelFilterData } from '~/search/sidebar/components/label_filter/data';
import { formatSearchResultCount, addCountOverLimit } from '~/search/store/utils';
import { GROUPS_LOCAL_STORAGE_KEY, PROJECTS_LOCAL_STORAGE_KEY, ICON_MAP } from './constants';
@@ -20,6 +21,40 @@ export const languageAggregationBuckets = (state) => {
);
};
+export const labelAggregationBuckets = (state) => {
+ return (
+ state?.aggregations?.data?.find(
+ (aggregation) => aggregation.name === labelFilterData.filterParam,
+ )?.buckets || []
+ );
+};
+
+export const filteredLabels = (state) => {
+ if (state.searchLabelString === '') {
+ return labelAggregationBuckets(state);
+ }
+ return labelAggregationBuckets(state).filter((label) => {
+ return label.title.toLowerCase().includes(state.searchLabelString.toLowerCase());
+ });
+};
+
+export const filteredAppliedSelectedLabels = (state) =>
+ filteredLabels(state)?.filter((label) => state?.urlQuery?.labels?.includes(label.key));
+
+export const appliedSelectedLabels = (state) =>
+ labelAggregationBuckets(state)?.filter((label) => state?.urlQuery?.labels?.includes(label.key));
+
+export const filteredUnappliedSelectedLabels = (state) =>
+ filteredLabels(state)?.filter((label) => state?.query?.labels?.includes(label.key));
+
+export const filteredUnselectedLabels = (state) => {
+ if (!state?.urlQuery?.labels) {
+ return filteredLabels(state);
+ }
+
+ return filteredLabels(state)?.filter((label) => !state?.urlQuery?.labels?.includes(label.key));
+};
+
export const currentScope = (state) => findKey(state.navigation, { active: true });
export const queryLanguageFilters = (state) => state.query[languageFilterData.filterParam] || [];
diff --git a/app/assets/javascripts/search/store/mutation_types.js b/app/assets/javascripts/search/store/mutation_types.js
index 4ffbadcd083..021dd01ca93 100644
--- a/app/assets/javascripts/search/store/mutation_types.js
+++ b/app/assets/javascripts/search/store/mutation_types.js
@@ -15,3 +15,5 @@ export const RECEIVE_NAVIGATION_COUNT = 'RECEIVE_NAVIGATION_COUNT';
export const REQUEST_AGGREGATIONS = 'REQUEST_AGGREGATIONS';
export const RECEIVE_AGGREGATIONS_SUCCESS = 'RECEIVE_AGGREGATIONS_SUCCESS';
export const RECEIVE_AGGREGATIONS_ERROR = 'RECEIVE_AGGREGATIONS_ERROR';
+
+export const SET_LABEL_SEARCH_STRING = 'SET_LABEL_SEARCH_STRING';
diff --git a/app/assets/javascripts/search/store/mutations.js b/app/assets/javascripts/search/store/mutations.js
index b2f9f5ab225..65bb21f1b8a 100644
--- a/app/assets/javascripts/search/store/mutations.js
+++ b/app/assets/javascripts/search/store/mutations.js
@@ -45,4 +45,7 @@ export default {
[types.RECEIVE_AGGREGATIONS_ERROR](state) {
state.aggregations = { fetching: false, error: true, data: [] };
},
+ [types.SET_LABEL_SEARCH_STRING](state, value) {
+ state.searchLabelString = value;
+ },
};
diff --git a/app/assets/javascripts/search/store/state.js b/app/assets/javascripts/search/store/state.js
index c897d4108a8..5407b08fa83 100644
--- a/app/assets/javascripts/search/store/state.js
+++ b/app/assets/javascripts/search/store/state.js
@@ -20,6 +20,7 @@ const createState = ({ query, navigation, useSidebarNavigation }) => ({
fetching: false,
data: [],
},
+ searchLabelString: '',
});
export default createState;