Commit 8d10afb5 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch '63177-follow-up-from-use-scoped-routes-for-labels-and-milestones' into 'master'

Resolve "Follow-up from "Use scoped routes for labels and milestones""

Closes #63177

See merge request gitlab-org/gitlab-ce!29983
parents d73b6d0f 9e93ea8e
...@@ -10,7 +10,7 @@ import { mergeUrlParams } from '../lib/utils/url_utility'; ...@@ -10,7 +10,7 @@ import { mergeUrlParams } from '../lib/utils/url_utility';
export default class AvailableDropdownMappings { export default class AvailableDropdownMappings {
constructor( constructor(
container, container,
baseEndpoint, runnerTagsEndpoint,
labelsEndpoint, labelsEndpoint,
milestonesEndpoint, milestonesEndpoint,
groupsOnly, groupsOnly,
...@@ -18,7 +18,7 @@ export default class AvailableDropdownMappings { ...@@ -18,7 +18,7 @@ export default class AvailableDropdownMappings {
includeDescendantGroups, includeDescendantGroups,
) { ) {
this.container = container; this.container = container;
this.baseEndpoint = baseEndpoint; this.runnerTagsEndpoint = runnerTagsEndpoint;
this.labelsEndpoint = labelsEndpoint; this.labelsEndpoint = labelsEndpoint;
this.milestonesEndpoint = milestonesEndpoint; this.milestonesEndpoint = milestonesEndpoint;
this.groupsOnly = groupsOnly; this.groupsOnly = groupsOnly;
...@@ -149,7 +149,7 @@ export default class AvailableDropdownMappings { ...@@ -149,7 +149,7 @@ export default class AvailableDropdownMappings {
} }
getRunnerTagsEndpoint() { getRunnerTagsEndpoint() {
return `${this.baseEndpoint}/admin/runners/tag_list.json`; return `${this.runnerTagsEndpoint}.json`;
} }
getMergeRequestTargetBranchesEndpoint() { getMergeRequestTargetBranchesEndpoint() {
......
...@@ -8,7 +8,7 @@ import FilteredSearchVisualTokens from './filtered_search_visual_tokens'; ...@@ -8,7 +8,7 @@ import FilteredSearchVisualTokens from './filtered_search_visual_tokens';
export default class FilteredSearchDropdownManager { export default class FilteredSearchDropdownManager {
constructor({ constructor({
baseEndpoint = '', runnerTagsEndpoint = '',
labelsEndpoint = '', labelsEndpoint = '',
milestonesEndpoint = '', milestonesEndpoint = '',
tokenizer, tokenizer,
...@@ -19,7 +19,7 @@ export default class FilteredSearchDropdownManager { ...@@ -19,7 +19,7 @@ export default class FilteredSearchDropdownManager {
filteredSearchTokenKeys, filteredSearchTokenKeys,
}) { }) {
this.container = FilteredSearchContainer.container; this.container = FilteredSearchContainer.container;
this.baseEndpoint = baseEndpoint.replace(/\/$/, ''); this.runnerTagsEndpoint = runnerTagsEndpoint.replace(/\/$/, '');
this.labelsEndpoint = labelsEndpoint.replace(/\/$/, ''); this.labelsEndpoint = labelsEndpoint.replace(/\/$/, '');
this.milestonesEndpoint = milestonesEndpoint.replace(/\/$/, ''); this.milestonesEndpoint = milestonesEndpoint.replace(/\/$/, '');
this.tokenizer = tokenizer; this.tokenizer = tokenizer;
...@@ -51,7 +51,7 @@ export default class FilteredSearchDropdownManager { ...@@ -51,7 +51,7 @@ export default class FilteredSearchDropdownManager {
const supportedTokens = this.filteredSearchTokenKeys.getKeys(); const supportedTokens = this.filteredSearchTokenKeys.getKeys();
const availableMappings = new AvailableDropdownMappings( const availableMappings = new AvailableDropdownMappings(
this.container, this.container,
this.baseEndpoint, this.runnerTagsEndpoint,
this.labelsEndpoint, this.labelsEndpoint,
this.milestonesEndpoint, this.milestonesEndpoint,
this.groupsOnly, this.groupsOnly,
......
...@@ -85,7 +85,8 @@ export default class FilteredSearchManager { ...@@ -85,7 +85,8 @@ export default class FilteredSearchManager {
if (this.filteredSearchInput) { if (this.filteredSearchInput) {
this.tokenizer = FilteredSearchTokenizer; this.tokenizer = FilteredSearchTokenizer;
this.dropdownManager = new FilteredSearchDropdownManager({ this.dropdownManager = new FilteredSearchDropdownManager({
baseEndpoint: this.filteredSearchInput.getAttribute('data-base-endpoint') || '', runnerTagsEndpoint:
this.filteredSearchInput.getAttribute('data-runner-tags-endpoint') || '',
labelsEndpoint: this.filteredSearchInput.getAttribute('data-labels-endpoint') || '', labelsEndpoint: this.filteredSearchInput.getAttribute('data-labels-endpoint') || '',
milestonesEndpoint: this.filteredSearchInput.getAttribute('data-milestones-endpoint') || '', milestonesEndpoint: this.filteredSearchInput.getAttribute('data-milestones-endpoint') || '',
tokenizer: this.tokenizer, tokenizer: this.tokenizer,
......
...@@ -169,18 +169,17 @@ module SearchHelper ...@@ -169,18 +169,17 @@ module SearchHelper
autocomplete: 'off' autocomplete: 'off'
} }
opts[:data]['runner-tags-endpoint'] = tag_list_admin_runners_path
if @project.present? if @project.present?
opts[:data]['project-id'] = @project.id opts[:data]['project-id'] = @project.id
opts[:data]['base-endpoint'] = project_path(@project)
opts[:data]['labels-endpoint'] = project_labels_path(@project) opts[:data]['labels-endpoint'] = project_labels_path(@project)
opts[:data]['milestones-endpoint'] = project_milestones_path(@project) opts[:data]['milestones-endpoint'] = project_milestones_path(@project)
elsif @group.present? elsif @group.present?
opts[:data]['group-id'] = @group.id opts[:data]['group-id'] = @group.id
opts[:data]['base-endpoint'] = group_canonical_path(@group)
opts[:data]['labels-endpoint'] = group_labels_path(@group) opts[:data]['labels-endpoint'] = group_labels_path(@group)
opts[:data]['milestones-endpoint'] = group_milestones_path(@group) opts[:data]['milestones-endpoint'] = group_milestones_path(@group)
else else
opts[:data]['base-endpoint'] = root_dashboard_path
opts[:data]['labels-endpoint'] = dashboard_labels_path opts[:data]['labels-endpoint'] = dashboard_labels_path
opts[:data]['milestones-endpoint'] = dashboard_milestones_path opts[:data]['milestones-endpoint'] = dashboard_milestones_path
end end
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
.scroll-container .scroll-container
%ul.tokens-container.list-unstyled %ul.tokens-container.list-unstyled
%li.input-token %li.input-token
%input.form-control.filtered-search{ { id: 'filtered-search-runners', placeholder: _('Search or filter results...') } } %input.form-control.filtered-search{ search_filter_input_options('runners') }
#js-dropdown-hint.filtered-search-input-dropdown-menu.dropdown-menu.hint-dropdown #js-dropdown-hint.filtered-search-input-dropdown-menu.dropdown-menu.hint-dropdown
%ul{ data: { dropdown: true } } %ul{ data: { dropdown: true } }
%li.filter-dropdown-item{ data: { action: 'submit' } } %li.filter-dropdown-item{ data: { action: 'submit' } }
......
...@@ -114,7 +114,7 @@ describe SearchHelper do ...@@ -114,7 +114,7 @@ describe SearchHelper do
end end
it 'includes project endpoints' do it 'includes project endpoints' do
expect(search_filter_input_options('')[:data]['base-endpoint']).to eq(project_path(@project)) expect(search_filter_input_options('')[:data]['runner-tags-endpoint']).to eq(tag_list_admin_runners_path)
expect(search_filter_input_options('')[:data]['labels-endpoint']).to eq(project_labels_path(@project)) expect(search_filter_input_options('')[:data]['labels-endpoint']).to eq(project_labels_path(@project))
expect(search_filter_input_options('')[:data]['milestones-endpoint']).to eq(project_milestones_path(@project)) expect(search_filter_input_options('')[:data]['milestones-endpoint']).to eq(project_milestones_path(@project))
end end
...@@ -134,7 +134,7 @@ describe SearchHelper do ...@@ -134,7 +134,7 @@ describe SearchHelper do
end end
it 'includes group endpoints' do it 'includes group endpoints' do
expect(search_filter_input_options('')[:data]['base-endpoint']).to eq("/groups#{group_path(@group)}") expect(search_filter_input_options('')[:data]['runner-tags-endpoint']).to eq(tag_list_admin_runners_path)
expect(search_filter_input_options('')[:data]['labels-endpoint']).to eq(group_labels_path(@group)) expect(search_filter_input_options('')[:data]['labels-endpoint']).to eq(group_labels_path(@group))
expect(search_filter_input_options('')[:data]['milestones-endpoint']).to eq(group_milestones_path(@group)) expect(search_filter_input_options('')[:data]['milestones-endpoint']).to eq(group_milestones_path(@group))
end end
...@@ -147,7 +147,7 @@ describe SearchHelper do ...@@ -147,7 +147,7 @@ describe SearchHelper do
end end
it 'includes dashboard endpoints' do it 'includes dashboard endpoints' do
expect(search_filter_input_options('')[:data]['base-endpoint']).to eq("/dashboard") expect(search_filter_input_options('')[:data]['runner-tags-endpoint']).to eq(tag_list_admin_runners_path)
expect(search_filter_input_options('')[:data]['labels-endpoint']).to eq(dashboard_labels_path) expect(search_filter_input_options('')[:data]['labels-endpoint']).to eq(dashboard_labels_path)
expect(search_filter_input_options('')[:data]['milestones-endpoint']).to eq(dashboard_milestones_path) expect(search_filter_input_options('')[:data]['milestones-endpoint']).to eq(dashboard_milestones_path)
end end
......
...@@ -155,7 +155,7 @@ describe('Filtered Search Visual Tokens', () => { ...@@ -155,7 +155,7 @@ describe('Filtered Search Visual Tokens', () => {
`); `);
const filteredSearchInput = document.querySelector('.filtered-search'); const filteredSearchInput = document.querySelector('.filtered-search');
filteredSearchInput.dataset.baseEndpoint = dummyEndpoint; filteredSearchInput.dataset.runnerTagsEndpoint = `${dummyEndpoint}/admin/runners/tag_list`;
filteredSearchInput.dataset.labelsEndpoint = `${dummyEndpoint}/-/labels`; filteredSearchInput.dataset.labelsEndpoint = `${dummyEndpoint}/-/labels`;
filteredSearchInput.dataset.milestonesEndpoint = `${dummyEndpoint}/-/milestones`; filteredSearchInput.dataset.milestonesEndpoint = `${dummyEndpoint}/-/milestones`;
......
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