Skip to content

Commit d0f16d5

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent 68aa327 commit d0f16d5

File tree

65 files changed

+953
-470
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+953
-470
lines changed

.rubocop_todo/gitlab/strong_memoize_attr.yml

-1
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,6 @@ Gitlab/StrongMemoizeAttr:
647647
- 'lib/gitlab/git_access_project.rb'
648648
- 'lib/gitlab/gitaly_client/with_feature_flag_actors.rb'
649649
- 'lib/gitlab/github_import/client.rb'
650-
- 'lib/gitlab/github_import/importer/repository_importer.rb'
651650
- 'lib/gitlab/github_import/representation/diff_notes/suggestion_formatter.rb'
652651
- 'lib/gitlab/gl_repository/identifier.rb'
653652
- 'lib/gitlab/gpg/commit.rb'

.rubocop_todo/layout/argument_alignment.yml

-1
Original file line numberDiff line numberDiff line change
@@ -2048,7 +2048,6 @@ Layout/ArgumentAlignment:
20482048
- 'lib/gitlab/import_export/snippets_repo_restorer.rb'
20492049
- 'lib/gitlab/import_export/snippets_repo_saver.rb'
20502050
- 'lib/gitlab/issuable/clone/copy_resource_events_service.rb'
2051-
- 'lib/gitlab/legacy_github_import/importer.rb'
20522051
- 'lib/gitlab/mail_room.rb'
20532052
- 'lib/gitlab/markdown_cache/redis/store.rb'
20542053
- 'lib/gitlab/memory/reports_uploader.rb'

.rubocop_todo/layout/line_length.yml

-1
Original file line numberDiff line numberDiff line change
@@ -3062,7 +3062,6 @@ Layout/LineLength:
30623062
- 'lib/gitlab/kubernetes/helm/pod.rb'
30633063
- 'lib/gitlab/kubernetes/kubectl_cmd.rb'
30643064
- 'lib/gitlab/kubernetes/pod_cmd.rb'
3065-
- 'lib/gitlab/legacy_github_import/importer.rb'
30663065
- 'lib/gitlab/legacy_github_import/project_creator.rb'
30673066
- 'lib/gitlab/local_and_remote_storage_migration/base_migrater.rb'
30683067
- 'lib/gitlab/lograge/custom_options.rb'

.rubocop_todo/naming/heredoc_delimiter_naming.yml

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ Naming/HeredocDelimiterNaming:
5050
- 'rubocop/cop/default_scope.rb'
5151
- 'rubocop/cop/file_decompression.rb'
5252
- 'rubocop/cop/gitlab/httparty.rb'
53-
- 'rubocop/cop/gitlab/json.rb'
5453
- 'rubocop/cop/gitlab/module_with_instance_variables.rb'
5554
- 'rubocop/cop/gitlab/predicate_memoization.rb'
5655
- 'spec/controllers/projects/pipelines_controller_spec.rb'

.rubocop_todo/performance/map_compact.yml

-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ Performance/MapCompact:
116116
- 'lib/gitlab/jira_import/metadata_collector.rb'
117117
- 'lib/gitlab/json_cache.rb'
118118
- 'lib/gitlab/language_detection.rb'
119-
- 'lib/gitlab/legacy_github_import/importer.rb'
120119
- 'lib/gitlab/private_commit_email.rb'
121120
- 'lib/gitlab/sql/pattern.rb'
122121
- 'lib/gitlab/url_blocker.rb'

.rubocop_todo/performance/string_include.yml

-9
This file was deleted.

.rubocop_todo/rake/require.yml

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ Rake/Require:
1212
- 'lib/tasks/gitlab/packages/migrate.rake'
1313
- 'lib/tasks/gitlab/pages.rake'
1414
- 'lib/tasks/gitlab/refresh_project_statistics_build_artifacts_size.rake'
15-
- 'lib/tasks/gitlab/terraform/migrate.rake'
16-
- 'lib/tasks/gitlab/tw/codeowners.rake'
1715
- 'lib/tasks/gitlab/x509/update.rake'
1816
- 'lib/tasks/import.rake'
1917
- 'lib/tasks/tokens.rake'

.rubocop_todo/rspec/missing_feature_category.yml

-1
Original file line numberDiff line numberDiff line change
@@ -5057,7 +5057,6 @@ RSpec/MissingFeatureCategory:
50575057
- 'spec/lib/gitlab/legacy_github_import/branch_formatter_spec.rb'
50585058
- 'spec/lib/gitlab/legacy_github_import/client_spec.rb'
50595059
- 'spec/lib/gitlab/legacy_github_import/comment_formatter_spec.rb'
5060-
- 'spec/lib/gitlab/legacy_github_import/importer_spec.rb'
50615060
- 'spec/lib/gitlab/legacy_github_import/issuable_formatter_spec.rb'
50625061
- 'spec/lib/gitlab/legacy_github_import/issue_formatter_spec.rb'
50635062
- 'spec/lib/gitlab/legacy_github_import/label_formatter_spec.rb'

.rubocop_todo/style/if_unless_modifier.yml

-1
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,6 @@ Style/IfUnlessModifier:
891891
- 'lib/gitlab/jira_import.rb'
892892
- 'lib/gitlab/jira_import/base_importer.rb'
893893
- 'lib/gitlab/legacy_github_import/client.rb'
894-
- 'lib/gitlab/legacy_github_import/importer.rb'
895894
- 'lib/gitlab/legacy_github_import/issuable_formatter.rb'
896895
- 'lib/gitlab/legacy_github_import/project_creator.rb'
897896
- 'lib/gitlab/lograge/custom_options.rb'

app/assets/javascripts/search/sidebar/components/checkbox_filter.vue

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script>
22
import { GlFormCheckboxGroup, GlFormCheckbox } from '@gitlab/ui';
3-
import { mapState, mapActions } from 'vuex';
3+
import { mapState, mapActions, mapGetters } from 'vuex';
44
import { intersection } from 'lodash';
55
import { NAV_LINK_COUNT_DEFAULT_CLASSES, LABEL_DEFAULT_CLASSES } from '../constants';
66
import { formatSearchResultCount } from '../../store/utils';
@@ -12,31 +12,29 @@ export default {
1212
GlFormCheckbox,
1313
},
1414
props: {
15-
filterData: {
15+
filtersData: {
1616
type: Object,
1717
required: true,
1818
},
1919
},
2020
computed: {
2121
...mapState(['query']),
22+
...mapGetters(['queryLangugageFilters']),
2223
scope() {
2324
return this.query.scope;
2425
},
25-
queryFilters() {
26-
return this.query[this.filterData?.filterParam] || [];
27-
},
2826
dataFilters() {
29-
return Object.values(this.filterData?.filters || []);
27+
return Object.values(this.filtersData?.filters || []);
3028
},
3129
flatDataFilterValues() {
3230
return this.dataFilters.map(({ value }) => value);
3331
},
3432
selectedFilter: {
3533
get() {
36-
return intersection(this.flatDataFilterValues, this.queryFilters);
34+
return intersection(this.flatDataFilterValues, this.queryLangugageFilters);
3735
},
3836
set(value) {
39-
this.setQuery({ key: this.filterData?.filterParam, value });
37+
this.setQuery({ key: this.filtersData?.filterParam, value });
4038
},
4139
},
4240
labelCountClasses() {
@@ -56,7 +54,7 @@ export default {
5654
5755
<template>
5856
<div class="gl-mx-5">
59-
<h5 class="gl-mt-0">{{ filterData.header }}</h5>
57+
<h5 class="gl-mt-0">{{ filtersData.header }}</h5>
6058
<gl-form-checkbox-group v-model="selectedFilter">
6159
<gl-form-checkbox
6260
v-for="f in dataFilters"

app/assets/javascripts/search/sidebar/components/language_filter.vue

+36-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@ export default {
2727
apply: __('Apply'),
2828
showingMax: sprintf(s__('GlobalSearch|Showing top %{maxItems}'), { maxItems: MAX_ITEM_LENGTH }),
2929
loadError: s__('GlobalSearch|Aggregations load error.'),
30+
reset: s__('GlobalSearch|Reset filters'),
3031
},
3132
computed: {
3233
...mapState(['aggregations', 'sidebarDirty']),
33-
...mapGetters(['langugageAggregationBuckets']),
34+
...mapGetters([
35+
'langugageAggregationBuckets',
36+
'currentUrlQueryHasLanguageFilters',
37+
'queryLangugageFilters',
38+
]),
3439
hasBuckets() {
3540
return this.langugageAggregationBuckets.length > 0;
3641
},
@@ -55,18 +60,33 @@ export default {
5560
dividerClasses() {
5661
return [...HR_DEFAULT_CLASSES, ...ONLY_SHOW_MD];
5762
},
63+
hasQueryFilters() {
64+
return this.queryLangugageFilters.length > 0;
65+
},
5866
},
5967
async created() {
6068
await this.fetchLanguageAggregation();
6169
},
6270
methods: {
63-
...mapActions(['applyQuery', 'fetchLanguageAggregation']),
71+
...mapActions([
72+
'applyQuery',
73+
'resetLanguageQuery',
74+
'resetLanguageQueryWithRedirect',
75+
'fetchLanguageAggregation',
76+
]),
6477
onShowMore() {
6578
this.showAll = true;
6679
},
6780
trimBuckets(length) {
6881
return this.langugageAggregationBuckets.slice(0, length);
6982
},
83+
cleanResetFilters() {
84+
if (this.currentUrlQueryHasLanguageFilters) {
85+
return this.resetLanguageQueryWithRedirect();
86+
}
87+
this.showAll = false;
88+
return this.resetLanguageQuery();
89+
},
7090
},
7191
HR_DEFAULT_CLASSES,
7292
};
@@ -84,7 +104,7 @@ export default {
84104
class="gl-overflow-x-hidden gl-overflow-y-auto"
85105
:class="{ 'language-filter-max-height': showAll }"
86106
>
87-
<checkbox-filter class="gl-px-5" :filter-data="filtersData" />
107+
<checkbox-filter :filters-data="filtersData" />
88108
<span v-if="showAll && hasOverMax" data-testid="has-over-max-text">{{
89109
$options.i18n.showingMax
90110
}}</span>
@@ -106,7 +126,9 @@ export default {
106126
</div>
107127
<div v-if="!aggregations.error">
108128
<hr :class="$options.HR_DEFAULT_CLASSES" />
109-
<div class="gl-display-flex gl-align-items-center gl-mt-4 gl-mx-5 gl-px-5">
129+
<div
130+
class="gl-display-flex gl-align-items-center gl-justify-content-space-between gl-mt-4 gl-mx-5"
131+
>
110132
<gl-button
111133
category="primary"
112134
variant="confirm"
@@ -116,6 +138,16 @@ export default {
116138
>
117139
{{ $options.i18n.apply }}
118140
</gl-button>
141+
<gl-button
142+
category="tertiary"
143+
variant="link"
144+
size="small"
145+
:disabled="!hasQueryFilters && !sidebarDirty"
146+
data-testid="reset-button"
147+
@click="cleanResetFilters"
148+
>
149+
{{ $options.i18n.reset }}
150+
</gl-button>
119151
</div>
120152
</div>
121153
</gl-form>
+12-15
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
import { languageFilterData } from '~/search/sidebar/constants/language_filter_data';
22

3-
export const convertFiltersData = (rawBuckets) => {
4-
return rawBuckets.reduce(
5-
(acc, bucket) => {
6-
return {
7-
...acc,
8-
filters: {
9-
...acc.filters,
10-
[bucket.key.toUpperCase()]: {
11-
label: bucket.key,
12-
value: bucket.key,
13-
count: bucket.count,
14-
},
3+
export const convertFiltersData = (rawBuckets) =>
4+
rawBuckets.reduce(
5+
(acc, bucket) => ({
6+
...acc,
7+
filters: {
8+
...acc.filters,
9+
[bucket.key.toUpperCase()]: {
10+
label: bucket.key,
11+
value: bucket.key,
12+
count: bucket.count,
1513
},
16-
};
17-
},
14+
},
15+
}),
1816
{ ...languageFilterData, filters: {} },
1917
);
20-
};

app/assets/javascripts/search/store/actions.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import axios from '~/lib/utils/axios_utils';
44
import { visitUrl, setUrlParams } from '~/lib/utils/url_utility';
55
import { logError } from '~/lib/logger';
66
import { __ } from '~/locale';
7+
import { languageFilterData } from '~/search/sidebar/constants/language_filter_data';
78
import { GROUPS_LOCAL_STORAGE_KEY, PROJECTS_LOCAL_STORAGE_KEY, SIDEBAR_PARAMS } from './constants';
89
import * as types from './mutation_types';
910
import {
@@ -105,7 +106,17 @@ export const applyQuery = ({ state }) => {
105106
};
106107

107108
export const resetQuery = ({ state }) => {
108-
visitUrl(setUrlParams({ ...state.query, page: null, state: null, confidential: null }));
109+
visitUrl(
110+
setUrlParams({ ...state.query, page: null, state: null, confidential: null }, undefined, true),
111+
);
112+
};
113+
114+
export const resetLanguageQueryWithRedirect = ({ state }) => {
115+
visitUrl(setUrlParams({ ...state.query, language: null }, undefined, true));
116+
};
117+
118+
export const resetLanguageQuery = ({ commit }) => {
119+
commit(types.SET_QUERY, { key: languageFilterData?.filterParam, value: [] });
109120
};
110121

111122
export const fetchSidebarCount = ({ commit, state }) => {

app/assets/javascripts/search/store/getters.js

+10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { has } from 'lodash';
12
import { languageFilterData } from '~/search/sidebar/constants/language_filter_data';
3+
24
import { GROUPS_LOCAL_STORAGE_KEY, PROJECTS_LOCAL_STORAGE_KEY } from './constants';
35

46
export const frequentGroups = (state) => {
@@ -16,3 +18,11 @@ export const langugageAggregationBuckets = (state) => {
1618
)?.buckets || []
1719
);
1820
};
21+
22+
export const queryLangugageFilters = (state) => {
23+
return state.query[languageFilterData.filterParam] || [];
24+
};
25+
26+
export const currentUrlQueryHasLanguageFilters = (state) =>
27+
has(state.urlQuery, languageFilterData.filterParam) &&
28+
state.urlQuery[languageFilterData.filterParam]?.length > 0;

app/assets/javascripts/search/store/mutations.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default {
2424
state.projects = [];
2525
},
2626
[types.SET_QUERY](state, { key, value }) {
27-
state.query[key] = value;
27+
state.query = { ...state.query, [key]: value };
2828
},
2929
[types.SET_SIDEBAR_DIRTY](state, value) {
3030
state.sidebarDirty = value;

app/assets/javascripts/search/store/utils.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isEqual } from 'lodash';
12
import AccessorUtilities from '~/lib/utils/accessor';
23
import { formatNumber } from '~/locale';
34
import { joinPaths } from '~/lib/utils/url_utility';
@@ -94,6 +95,10 @@ export const isSidebarDirty = (currentQuery, urlQuery) => {
9495
const userAddedParam = !urlQuery[param] && currentQuery[param];
9596
const userChangedExistingParam = urlQuery[param] && urlQuery[param] !== currentQuery[param];
9697

98+
if (Array.isArray(currentQuery[param]) || Array.isArray(urlQuery[param])) {
99+
return !isEqual(currentQuery[param], urlQuery[param]);
100+
}
101+
97102
return userAddedParam || userChangedExistingParam;
98103
});
99104
};

0 commit comments

Comments
 (0)