Skip to content
Snippets Groups Projects
Unverified Commit 805c5209 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre
Browse files

Merge branch '422520-zoekt-search-is-causing-aggregations-not-to-load-on-frontend' into 'master'

parents 989fd8e5 fa3f2857
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -10,12 +10,13 @@ import { initBlobRefSwitcher } from './under_topbar';
export const initSearchApp = () => {
syntaxHighlight(document.querySelectorAll('.js-search-results'));
const query = queryToObject(window.location.search, { gatherArrays: true });
const { navigationJsonParsed: navigation } = sidebarInitState() || {};
const { navigationJsonParsed: navigation, searchType } = sidebarInitState() || {};
 
const store = createStore({
query,
navigation,
useSidebarNavigation: gon.use_new_navigation,
searchType,
});
 
initTopbar(store);
Loading
Loading
Loading
Loading
@@ -5,7 +5,13 @@ import ScopeLegacyNavigation from '~/search/sidebar/components/scope_legacy_navi
import ScopeSidebarNavigation from '~/search/sidebar/components/scope_sidebar_navigation.vue';
import SidebarPortal from '~/super_sidebar/components/sidebar_portal.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { SCOPE_ISSUES, SCOPE_MERGE_REQUESTS, SCOPE_BLOB, SCOPE_PROJECTS } from '../constants';
import {
SCOPE_ISSUES,
SCOPE_MERGE_REQUESTS,
SCOPE_BLOB,
SCOPE_PROJECTS,
SEARCH_TYPE_ADVANCED,
} from '../constants';
import IssuesFilters from './issues_filters.vue';
import MergeRequestsFilters from './merge_requests_filters.vue';
import BlobsFilters from './blobs_filters.vue';
Loading
Loading
@@ -25,7 +31,7 @@ export default {
mixins: [glFeatureFlagsMixin()],
computed: {
// useSidebarNavigation refers to whether the new left sidebar navigation is enabled
...mapState(['useSidebarNavigation']),
...mapState(['useSidebarNavigation', 'searchType']),
...mapGetters(['currentScope']),
showIssuesFilters() {
return this.currentScope === SCOPE_ISSUES;
Loading
Loading
@@ -34,7 +40,7 @@ export default {
return this.currentScope === SCOPE_MERGE_REQUESTS;
},
showBlobFilters() {
return this.currentScope === SCOPE_BLOB;
return this.currentScope === SCOPE_BLOB && this.searchType === SEARCH_TYPE_ADVANCED;
},
showProjectsFilters() {
// for now the feature flag is here. Since we have only one filter in projects scope
Loading
Loading
Loading
Loading
@@ -19,3 +19,7 @@ export const ONLY_SHOW_MD = ['gl-display-none', 'gl-md-display-block'];
export const TRACKING_ACTION_CLICK = 'search:filters:click';
export const TRACKING_LABEL_APPLY = 'Apply Filters';
export const TRACKING_LABEL_RESET = 'Reset Filters';
export const SEARCH_TYPE_BASIC = 'basic';
export const SEARCH_TYPE_ADVANCED = 'advanced';
export const SEARCH_TYPE_ZOEKT = 'zoekt';
Loading
Loading
@@ -8,9 +8,11 @@ export const sidebarInitState = () => {
const el = document.getElementById('js-search-sidebar');
if (!el) return {};
 
const { navigationJson } = el.dataset;
const { navigationJson, searchType } = el.dataset;
const navigationJsonParsed = JSON.parse(navigationJson);
return { navigationJsonParsed };
return { navigationJsonParsed, searchType };
};
 
export const initSidebar = (store) => {
Loading
Loading
import { cloneDeep } from 'lodash';
import { GROUPS_LOCAL_STORAGE_KEY, PROJECTS_LOCAL_STORAGE_KEY } from './constants';
 
const createState = ({ query, navigation, useSidebarNavigation }) => ({
const createState = ({ query, navigation, useSidebarNavigation, searchType }) => ({
urlQuery: cloneDeep(query),
query,
groups: [],
Loading
Loading
@@ -21,6 +21,7 @@ const createState = ({ query, navigation, useSidebarNavigation }) => ({
data: [],
},
searchLabelString: '',
searchType,
});
 
export default createState;
Loading
Loading
@@ -23,6 +23,6 @@
 
#js-search-topbar{ data: { "group-initial-json": group_attributes.to_json, "project-initial-json": project_attributes.to_json, "elasticsearch-enabled": @search_service_presenter.advanced_search_enabled?.to_s, "default-branch-name": @project&.default_branch } }
.results.gl-md-display-flex.gl-mt-0
#js-search-sidebar{ class: search_bar_classes, data: { navigation_json: search_navigation_json } }
#js-search-sidebar{ class: search_bar_classes, data: { navigation_json: search_navigation_json, search_type: search_service.search_type } }
- if @search_term
= render 'search/results'
Loading
Loading
@@ -2,6 +2,7 @@ import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
// eslint-disable-next-line no-restricted-imports
import Vuex from 'vuex';
import { SEARCH_TYPE_ZOEKT, SEARCH_TYPE_ADVANCED } from '~/search/sidebar/constants';
import { MOCK_QUERY } from 'jest/search/mock_data';
import GlobalSearchSidebar from '~/search/sidebar/components/app.vue';
import IssuesFilters from '~/search/sidebar/components/issues_filters.vue';
Loading
Loading
@@ -60,7 +61,7 @@ describe('GlobalSearchSidebar', () => {
`('with sidebar $scope scope:', ({ scope, filter }) => {
beforeEach(() => {
getterSpies.currentScope = jest.fn(() => scope);
createComponent({ urlQuery: { scope } });
createComponent({ urlQuery: { scope }, searchType: SEARCH_TYPE_ADVANCED });
});
 
it(`shows filter ${filter.name.replace('find', '')}`, () => {
Loading
Loading
@@ -68,13 +69,23 @@ describe('GlobalSearchSidebar', () => {
});
});
 
describe('with sidebar $scope scope:', () => {
describe('filters for blobs will not load if zoekt is enabled', () => {
beforeEach(() => {
createComponent({ urlQuery: { scope: 'blobs' }, searchType: SEARCH_TYPE_ZOEKT });
});
it("doesn't render blobs filters", () => {
expect(findBlobsFilters().exists()).toBe(false);
});
});
describe('with sidebar scope: projects', () => {
beforeEach(() => {
getterSpies.currentScope = jest.fn(() => 'projects');
createComponent({ urlQuery: { scope: 'projects' } });
});
 
it(`shows filter ProjectsFilters}`, () => {
it(`shows filter ProjectsFilters`, () => {
expect(findProjectsFilters().exists()).toBe(true);
});
});
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment