Commit bac9bb18 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'ee-3727-epic-labels-backport' into 'master'

CE Platform port for EE epics filtered search changes

See merge request gitlab-org/gitlab-ce!17445
parents 2c4f5d30 add8a308
...@@ -4,7 +4,9 @@ import FilteredSearchManager from '../filtered_search/filtered_search_manager'; ...@@ -4,7 +4,9 @@ import FilteredSearchManager from '../filtered_search/filtered_search_manager';
export default class FilteredSearchBoards extends FilteredSearchManager { export default class FilteredSearchBoards extends FilteredSearchManager {
constructor(store, updateUrl = false, cantEdit = []) { constructor(store, updateUrl = false, cantEdit = []) {
super('boards'); super({
page: 'boards',
});
this.store = store; this.store = store;
this.updateUrl = updateUrl; this.updateUrl = updateUrl;
......
...@@ -10,13 +10,22 @@ import DropdownUser from './dropdown_user'; ...@@ -10,13 +10,22 @@ import DropdownUser from './dropdown_user';
import FilteredSearchVisualTokens from './filtered_search_visual_tokens'; import FilteredSearchVisualTokens from './filtered_search_visual_tokens';
export default class FilteredSearchDropdownManager { export default class FilteredSearchDropdownManager {
constructor(baseEndpoint = '', tokenizer, page, isGroup, filteredSearchTokenKeys) { constructor({
baseEndpoint = '',
tokenizer,
page,
isGroup,
isGroupAncestor,
filteredSearchTokenKeys,
}) {
this.container = FilteredSearchContainer.container; this.container = FilteredSearchContainer.container;
this.baseEndpoint = baseEndpoint.replace(/\/$/, ''); this.baseEndpoint = baseEndpoint.replace(/\/$/, '');
this.tokenizer = tokenizer; this.tokenizer = tokenizer;
this.filteredSearchTokenKeys = filteredSearchTokenKeys || FilteredSearchTokenKeys; this.filteredSearchTokenKeys = filteredSearchTokenKeys || FilteredSearchTokenKeys;
this.filteredSearchInput = this.container.querySelector('.filtered-search'); this.filteredSearchInput = this.container.querySelector('.filtered-search');
this.page = page; this.page = page;
this.groupsOnly = isGroup;
this.groupAncestor = isGroupAncestor;
this.setupMapping(); this.setupMapping();
...@@ -59,7 +68,7 @@ export default class FilteredSearchDropdownManager { ...@@ -59,7 +68,7 @@ export default class FilteredSearchDropdownManager {
reference: null, reference: null,
gl: DropdownNonUser, gl: DropdownNonUser,
extraArguments: { extraArguments: {
endpoint: `${this.baseEndpoint}/milestones.json`, endpoint: this.getMilestoneEndpoint(),
symbol: '%', symbol: '%',
}, },
element: this.container.querySelector('#js-dropdown-milestone'), element: this.container.querySelector('#js-dropdown-milestone'),
...@@ -68,7 +77,7 @@ export default class FilteredSearchDropdownManager { ...@@ -68,7 +77,7 @@ export default class FilteredSearchDropdownManager {
reference: null, reference: null,
gl: DropdownNonUser, gl: DropdownNonUser,
extraArguments: { extraArguments: {
endpoint: `${this.baseEndpoint}/labels.json`, endpoint: this.getLabelsEndpoint(),
symbol: '~', symbol: '~',
preprocessing: DropdownUtils.duplicateLabelPreprocessing, preprocessing: DropdownUtils.duplicateLabelPreprocessing,
}, },
...@@ -90,6 +99,18 @@ export default class FilteredSearchDropdownManager { ...@@ -90,6 +99,18 @@ export default class FilteredSearchDropdownManager {
this.mapping = allowedMappings; this.mapping = allowedMappings;
} }
getMilestoneEndpoint() {
const endpoint = `${this.baseEndpoint}/milestones.json`;
return endpoint;
}
getLabelsEndpoint() {
const endpoint = `${this.baseEndpoint}/labels.json`;
return endpoint;
}
static addWordToInput(tokenName, tokenValue = '', clicked = false) { static addWordToInput(tokenName, tokenValue = '', clicked = false) {
const input = FilteredSearchContainer.container.querySelector('.filtered-search'); const input = FilteredSearchContainer.container.querySelector('.filtered-search');
......
...@@ -20,10 +20,13 @@ import DropdownUtils from './dropdown_utils'; ...@@ -20,10 +20,13 @@ import DropdownUtils from './dropdown_utils';
export default class FilteredSearchManager { export default class FilteredSearchManager {
constructor({ constructor({
page, page,
isGroup = false,
isGroupAncestor = false,
filteredSearchTokenKeys = FilteredSearchTokenKeys, filteredSearchTokenKeys = FilteredSearchTokenKeys,
stateFiltersSelector = '.issues-state-filters', stateFiltersSelector = '.issues-state-filters',
}) { }) {
this.isGroup = false; this.isGroup = isGroup;
this.isGroupAncestor = isGroupAncestor;
this.states = ['opened', 'closed', 'merged', 'all']; this.states = ['opened', 'closed', 'merged', 'all'];
this.page = page; this.page = page;
...@@ -75,13 +78,14 @@ export default class FilteredSearchManager { ...@@ -75,13 +78,14 @@ export default class FilteredSearchManager {
if (this.filteredSearchInput) { if (this.filteredSearchInput) {
this.tokenizer = FilteredSearchTokenizer; this.tokenizer = FilteredSearchTokenizer;
this.dropdownManager = new FilteredSearchDropdownManager( this.dropdownManager = new FilteredSearchDropdownManager({
this.filteredSearchInput.getAttribute('data-base-endpoint') || '', baseEndpoint: this.filteredSearchInput.getAttribute('data-base-endpoint') || '',
this.tokenizer, tokenizer: this.tokenizer,
this.page, page: this.page,
this.isGroup, isGroup: this.isGroup,
this.filteredSearchTokenKeys, isGroupAncestor: this.isGroupAncestor,
); filteredSearchTokenKeys: this.filteredSearchTokenKeys,
});
this.recentSearchesRoot = new RecentSearchesRoot( this.recentSearchesRoot = new RecentSearchesRoot(
this.recentSearchesStore, this.recentSearchesStore,
......
import FilteredSearchManager from '~/filtered_search/filtered_search_manager'; import FilteredSearchManager from '~/filtered_search/filtered_search_manager';
export default ({ page }) => { export default ({
page,
filteredSearchTokenKeys,
isGroup,
isGroupAncestor,
stateFiltersSelector,
}) => {
const filteredSearchEnabled = FilteredSearchManager && document.querySelector('.filtered-search'); const filteredSearchEnabled = FilteredSearchManager && document.querySelector('.filtered-search');
if (filteredSearchEnabled) { if (filteredSearchEnabled) {
const filteredSearchManager = new FilteredSearchManager({ page }); const filteredSearchManager = new FilteredSearchManager({
page,
isGroup,
isGroupAncestor,
filteredSearchTokenKeys,
stateFiltersSelector,
});
filteredSearchManager.setup(); filteredSearchManager.setup();
} }
}; };
...@@ -14,6 +14,11 @@ ...@@ -14,6 +14,11 @@
collapsedCalendarIcon, collapsedCalendarIcon,
}, },
props: { props: {
blockClass: {
type: String,
required: false,
default: '',
},
collapsed: { collapsed: {
type: Boolean, type: Boolean,
required: false, required: false,
...@@ -91,7 +96,10 @@ ...@@ -91,7 +96,10 @@
</script> </script>
<template> <template>
<div class="block"> <div
class="block"
:class="blockClass"
>
<div class="issuable-sidebar-header"> <div class="issuable-sidebar-header">
<toggle-sidebar <toggle-sidebar
:collapsed="collapsed" :collapsed="collapsed"
......
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