Merge branch 'backport-issues-controller-changes' into 'master'
Move issues index variable setting to a method See merge request !14048
This commit is contained in:
commit
56509d22d6
6 changed files with 58 additions and 18 deletions
|
@ -332,7 +332,14 @@ class FilteredSearchManager {
|
|||
const removeElements = [];
|
||||
|
||||
[].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);
|
||||
}
|
||||
});
|
||||
|
@ -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() {
|
||||
const params = gl.utils.getUrlParamsArray();
|
||||
const urlParams = gl.utils.getUrlParamsArray();
|
||||
const params = this.getAllParams(urlParams);
|
||||
const usernameParams = this.getUsernameParams();
|
||||
let hasFilteredSearch = false;
|
||||
|
||||
|
|
|
@ -10,6 +10,22 @@ module IssuableCollections
|
|||
|
||||
private
|
||||
|
||||
def set_issues_index
|
||||
@collection_type = "Issue"
|
||||
@issues = issues_collection
|
||||
@issues = @issues.page(params[:page])
|
||||
@issuable_meta_data = issuable_meta_data(@issues, @collection_type)
|
||||
@total_pages = issues_page_count(@issues)
|
||||
|
||||
return if redirect_out_of_range(@issues, @total_pages)
|
||||
|
||||
if params[:label_name].present?
|
||||
@labels = LabelsFinder.new(current_user, project_id: @project.id, title: params[:label_name]).execute
|
||||
end
|
||||
|
||||
@users = []
|
||||
end
|
||||
|
||||
def issues_collection
|
||||
issues_finder.execute.preload(:project, :author, :assignees, :labels, :milestone, project: :namespace)
|
||||
end
|
||||
|
|
|
@ -10,6 +10,7 @@ class Projects::IssuesController < Projects::ApplicationController
|
|||
|
||||
before_action :check_issues_available!
|
||||
before_action :issue, except: [:index, :new, :create, :bulk_update]
|
||||
before_action :set_issues_index, only: [:index]
|
||||
|
||||
# Allow write(create) issue
|
||||
before_action :authorize_create_issue!, only: [:new, :create]
|
||||
|
@ -23,20 +24,6 @@ class Projects::IssuesController < Projects::ApplicationController
|
|||
respond_to :html
|
||||
|
||||
def index
|
||||
@collection_type = "Issue"
|
||||
@issues = issues_collection
|
||||
@issues = @issues.page(params[:page])
|
||||
@issuable_meta_data = issuable_meta_data(@issues, @collection_type)
|
||||
@total_pages = issues_page_count(@issues)
|
||||
|
||||
return if redirect_out_of_range(@issues, @total_pages)
|
||||
|
||||
if params[:label_name].present?
|
||||
@labels = LabelsFinder.new(current_user, project_id: @project.id, title: params[:label_name]).execute
|
||||
end
|
||||
|
||||
@users = []
|
||||
|
||||
if params[:assignee_id].present?
|
||||
assignee = User.find_by_id(params[:assignee_id])
|
||||
@users.push(assignee) if assignee
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
%span.badge.count.issue_counter.fly-out-badge
|
||||
= number_with_delimiter(@project.open_issues_count)
|
||||
%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
|
||||
%span
|
||||
List
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
- empty_state_path = local_assigns.fetch(:empty_state_path, 'shared/empty_states/issues')
|
||||
|
||||
%ul.content-list.issues-list.issuable-list
|
||||
= render partial: "projects/issues/issue", collection: @issues
|
||||
- if @issues.blank?
|
||||
= render 'shared/empty_states/issues'
|
||||
= render empty_state_path
|
||||
|
||||
- if @issues.present?
|
||||
= paginate @issues, theme: "gitlab", total_pages: @total_pages
|
||||
|
|
|
@ -411,4 +411,26 @@ describe('Filtered Search Manager', () => {
|
|||
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]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue