Commit 1bd4cd44 authored by Bryce Johnson's avatar Bryce Johnson

Backport getAllParams and other nav changes from service desk.

parent 5f6545f3
...@@ -332,7 +332,14 @@ class FilteredSearchManager { ...@@ -332,7 +332,14 @@ class FilteredSearchManager {
const removeElements = []; const removeElements = [];
[].forEach.call(this.tokensContainer.children, (t) => { [].forEach.call(this.tokensContainer.children, (t) => {
if (t.classList.contains('js-visual-token')) { let canClearToken = t.classList.contains('js-visual-token');
if (canClearToken) {
const tokenKey = t.querySelector('.name').textContent.trim();
canClearToken = this.canEdit && this.canEdit(tokenKey);
}
if (canClearToken) {
removeElements.push(t); removeElements.push(t);
} }
}); });
...@@ -411,8 +418,14 @@ class FilteredSearchManager { ...@@ -411,8 +418,14 @@ class FilteredSearchManager {
}); });
} }
// allows for modifying params array when a param can't be included in the URL (e.g. Service Desk)
getAllParams(urlParams) {
return this.modifyUrlParams ? this.modifyUrlParams(urlParams) : urlParams;
}
loadSearchParamsFromURL() { loadSearchParamsFromURL() {
const params = gl.utils.getUrlParamsArray(); const urlParams = gl.utils.getUrlParamsArray();
const params = this.getAllParams(urlParams);
const usernameParams = this.getUsernameParams(); const usernameParams = this.getUsernameParams();
let hasFilteredSearch = false; let hasFilteredSearch = false;
......
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
%span.badge.count.issue_counter.fly-out-badge %span.badge.count.issue_counter.fly-out-badge
= number_with_delimiter(@project.open_issues_count) = number_with_delimiter(@project.open_issues_count)
%li.divider.fly-out-top-item %li.divider.fly-out-top-item
= nav_link(controller: :issues) do = nav_link(controller: :issues, action: :index) do
= link_to project_issues_path(@project), title: 'Issues' do = link_to project_issues_path(@project), title: 'Issues' do
%span %span
List List
......
- empty_state_path = local_assigns.fetch(:empty_state_path, 'shared/empty_states/issues')
%ul.content-list.issues-list.issuable-list %ul.content-list.issues-list.issuable-list
= render partial: "projects/issues/issue", collection: @issues = render partial: "projects/issues/issue", collection: @issues
- if @issues.blank? - if @issues.blank?
= render 'shared/empty_states/issues' = render empty_state_path
- if @issues.present? - if @issues.present?
= paginate @issues, theme: "gitlab", total_pages: @total_pages = paginate @issues, theme: "gitlab", total_pages: @total_pages
= link_to params.merge(rss_url_options), class: 'btn btn-default append-right-10 has-tooltip', title: 'Subscribe' do - show_rss_button = local_assigns.fetch(:show_rss_button, true)
- show_export_button = local_assigns.fetch(:show_export_button, true)
- if show_rss_button
= link_to params.merge(rss_url_options), class: 'btn btn-default append-right-10 has-tooltip', title: 'Subscribe' do
= icon('rss') = icon('rss')
- if show_export_button
= render 'projects/issues/export_issues/button'
- if @can_bulk_update - if @can_bulk_update
= button_tag "Edit issues", class: "btn btn-default append-right-10 js-bulk-update-toggle" = button_tag "Edit issues", class: "btn btn-default append-right-10 js-bulk-update-toggle"
= link_to "New issue", new_project_issue_path(@project, = link_to "New issue", new_project_issue_path(@project,
issue: { assignee_id: issues_finder.assignee.try(:id), issue: { assignee_id: issues_finder.assignee.try(:id),
milestone_id: issues_finder.milestones.first.try(:id) }), milestone_id: issues_finder.milestones.first.try(:id) }),
......
...@@ -411,4 +411,26 @@ describe('Filtered Search Manager', () => { ...@@ -411,4 +411,26 @@ describe('Filtered Search Manager', () => {
expect(document.querySelector('.filtered-search-box').classList.contains('focus')).toEqual(false); expect(document.querySelector('.filtered-search-box').classList.contains('focus')).toEqual(false);
}); });
}); });
describe('getAllParams', () => {
beforeEach(() => {
this.paramsArr = ['key=value', 'otherkey=othervalue'];
initializeManager();
});
it('correctly modifies params when custom modifier is passed', () => {
const modifedParams = manager.getAllParams.call({
modifyUrlParams: paramsArr => paramsArr.reverse(),
}, [].concat(this.paramsArr));
expect(modifedParams[0]).toBe(this.paramsArr[1]);
});
it('does not modify params when no custom modifier is passed', () => {
const modifedParams = manager.getAllParams.call({}, this.paramsArr);
expect(modifedParams[1]).toBe(this.paramsArr[1]);
});
});
}); });
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