Commit de034bfd authored by Martin Wortschack's avatar Martin Wortschack

Merge branch '213908-sort-by-policy-violations' into 'master'

Add sort and order for policy violations

Closes #213908

See merge request gitlab-org/gitlab!30564
parents a5a4b817 228d6d45
...@@ -3,7 +3,7 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -3,7 +3,7 @@ import axios from '~/lib/utils/axios_utils';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { FETCH_ERROR_MESSAGE } from './constants'; import { FETCH_ERROR_MESSAGE, SORT_BY, SORT_ORDER } from './constants';
import * as types from './mutation_types'; import * as types from './mutation_types';
export const setLicensesEndpoint = ({ commit }, endpoint) => export const setLicensesEndpoint = ({ commit }, endpoint) =>
...@@ -21,6 +21,8 @@ export const fetchLicenses = ({ state, dispatch }, params = {}) => { ...@@ -21,6 +21,8 @@ export const fetchLicenses = ({ state, dispatch }, params = {}) => {
params: { params: {
per_page: 10, per_page: 10,
page: state.pageInfo.page || 1, page: state.pageInfo.page || 1,
sort_by: SORT_BY.CLASSIFICATION,
sort_direction: SORT_ORDER.DESC,
...params, ...params,
}, },
}) })
......
...@@ -11,3 +11,11 @@ export const REPORT_STATUS = { ...@@ -11,3 +11,11 @@ export const REPORT_STATUS = {
export const FETCH_ERROR_MESSAGE = s__( export const FETCH_ERROR_MESSAGE = s__(
'Licenses|Error fetching the license list. Please check your network connection and try again.', 'Licenses|Error fetching the license list. Please check your network connection and try again.',
); );
export const SORT_BY = {
CLASSIFICATION: 'classification',
};
export const SORT_ORDER = {
DESC: 'desc',
};
---
title: Sort license policy violations first
merge_request: 30564
author:
type: changed
...@@ -6,7 +6,11 @@ import * as actions from 'ee/license_compliance/store/modules/list/actions'; ...@@ -6,7 +6,11 @@ import * as actions from 'ee/license_compliance/store/modules/list/actions';
import * as types from 'ee/license_compliance/store/modules/list/mutation_types'; import * as types from 'ee/license_compliance/store/modules/list/mutation_types';
import getInitialState from 'ee/license_compliance/store/modules/list/state'; import getInitialState from 'ee/license_compliance/store/modules/list/state';
import { FETCH_ERROR_MESSAGE } from 'ee/license_compliance/store/modules/list/constants'; import {
FETCH_ERROR_MESSAGE,
SORT_BY,
SORT_ORDER,
} from 'ee/license_compliance/store/modules/list/constants';
import createFlash from '~/flash'; import createFlash from '~/flash';
import mockLicensesResponse from './data/mock_licenses.json'; import mockLicensesResponse from './data/mock_licenses.json';
...@@ -141,6 +145,8 @@ describe('Licenses actions', () => { ...@@ -141,6 +145,8 @@ describe('Licenses actions', () => {
const paramsDefault = { const paramsDefault = {
page: state.pageInfo.page, page: state.pageInfo.page,
per_page: 10, per_page: 10,
sort_by: SORT_BY.CLASSIFICATION,
sort_direction: SORT_ORDER.DESC,
}; };
mock mock
...@@ -174,6 +180,8 @@ describe('Licenses actions', () => { ...@@ -174,6 +180,8 @@ describe('Licenses actions', () => {
const paramsSent = { const paramsSent = {
...paramsGiven, ...paramsGiven,
per_page: 10, per_page: 10,
sort_by: SORT_BY.CLASSIFICATION,
sort_direction: SORT_ORDER.DESC,
}; };
beforeEach(() => { beforeEach(() => {
......
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