Commit ba27460a authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '228705-enable-open-closed-all-tabs-in-jira-issue-list-ui' into 'master'

Add Open/Closed/All tab navigation to Jira issues

See merge request gitlab-org/gitlab!36929
parents 54aba1a8 dbd239aa
...@@ -293,10 +293,10 @@ export default { ...@@ -293,10 +293,10 @@ export default {
this.filters = filters; this.filters = filters;
}, },
refetchIssuables() { refetchIssuables() {
const ignored = ['utf8', 'state']; const ignored = ['utf8'];
const params = omit(this.filters, ignored); const params = omit(this.filters, ignored);
historyPushState(setUrlParams(params, window.location.href, true)); historyPushState(setUrlParams(params, window.location.href, true, true));
this.fetchIssuables(); this.fetchIssuables();
}, },
handleFilter(filters) { handleFilter(filters) {
......
...@@ -344,9 +344,15 @@ export function objectToQuery(obj) { ...@@ -344,9 +344,15 @@ export function objectToQuery(obj) {
* @param {Object} params The query params to be set/updated * @param {Object} params The query params to be set/updated
* @param {String} url The url to be operated on * @param {String} url The url to be operated on
* @param {Boolean} clearParams Indicates whether existing query params should be removed or not * @param {Boolean} clearParams Indicates whether existing query params should be removed or not
* @param {Boolean} railsArraySyntax When enabled, changes the array syntax from `keys=` to `keys[]=` according to Rails conventions
* @returns {String} A copy of the original with the updated query params * @returns {String} A copy of the original with the updated query params
*/ */
export const setUrlParams = (params, url = window.location.href, clearParams = false) => { export const setUrlParams = (
params,
url = window.location.href,
clearParams = false,
railsArraySyntax = false,
) => {
const urlObj = new URL(url); const urlObj = new URL(url);
const queryString = urlObj.search; const queryString = urlObj.search;
const searchParams = clearParams ? new URLSearchParams('') : new URLSearchParams(queryString); const searchParams = clearParams ? new URLSearchParams('') : new URLSearchParams(queryString);
...@@ -355,11 +361,12 @@ export const setUrlParams = (params, url = window.location.href, clearParams = f ...@@ -355,11 +361,12 @@ export const setUrlParams = (params, url = window.location.href, clearParams = f
if (params[key] === null || params[key] === undefined) { if (params[key] === null || params[key] === undefined) {
searchParams.delete(key); searchParams.delete(key);
} else if (Array.isArray(params[key])) { } else if (Array.isArray(params[key])) {
const keyName = railsArraySyntax ? `${key}[]` : key;
params[key].forEach((val, idx) => { params[key].forEach((val, idx) => {
if (idx === 0) { if (idx === 0) {
searchParams.set(key, val); searchParams.set(keyName, val);
} else { } else {
searchParams.append(key, val); searchParams.append(keyName, val);
} }
}); });
} else { } else {
......
...@@ -18,6 +18,8 @@ module Projects ...@@ -18,6 +18,8 @@ module Projects
rescue_from ::Projects::Integrations::Jira::IssuesFinder::RequestError, with: :render_request_error rescue_from ::Projects::Integrations::Jira::IssuesFinder::RequestError, with: :render_request_error
def index def index
params[:state] = params[:state].presence || default_state
respond_to do |format| respond_to do |format|
format.html format.html
format.json do format.json do
...@@ -46,7 +48,6 @@ module Projects ...@@ -46,7 +48,6 @@ module Projects
end end
def finder_options def finder_options
params[:state] = default_state if params[:state].blank?
options = { sort: set_sort_order } options = { sort: set_sort_order }
# Used by view to highlight active option # Used by view to highlight active option
......
.nav-controls.issues-nav-controls.gl-my-5 .nav-controls.issues-nav-controls
= link_to @project.external_issue_tracker.new_issue_url, class: 'btn gl-button', target: '_blank', rel: 'noopener noreferrer' do = link_to @project.external_issue_tracker.new_issue_url, class: 'btn gl-button gl-align-self-start', target: '_blank', rel: 'noopener noreferrer' do
= _('Create new issue in Jira') = _('Create new issue in Jira')
= sprite_icon('external-link', css_class: 'gl-ml-1') = sprite_icon('external-link', css_class: 'gl-ml-1')
- page_title _('Jira Issues') - page_title _('Jira Issues')
.top-area.gl-border-b-0.gl-justify-content-end .top-area.gl-border-b-0.gl-mt-6
= render 'shared/issuable/nav', type: :issues, display_count: false
= render 'projects/integrations/jira/issues/nav_btns' = render 'projects/integrations/jira/issues/nav_btns'
.js-issuables-list{ data: { endpoint: expose_path(project_integrations_jira_issues_path(@project, format: :json)), .js-issuables-list{ data: { endpoint: expose_path(project_integrations_jira_issues_path(@project, format: :json)),
......
...@@ -595,6 +595,14 @@ describe('URL utility', () => { ...@@ -595,6 +595,14 @@ describe('URL utility', () => {
); );
}); });
it('handles arrays properly when railsArraySyntax=true', () => {
const url = 'https://gitlab.com/test';
expect(urlUtils.setUrlParams({ labels: ['foo', 'bar'] }, url, false, true)).toEqual(
'https://gitlab.com/test?labels%5B%5D=foo&labels%5B%5D=bar',
);
});
it('removes all existing URL params and sets a new param when cleanParams=true', () => { it('removes all existing URL params and sets a new param when cleanParams=true', () => {
const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project'; const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project';
......
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