Commit 228d6d45 authored by Fernando's avatar Fernando

Refactor license compliance query into constants

* Swap out hard coded strings for constsnta
parent 201d7f9a
...@@ -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,8 +21,8 @@ export const fetchLicenses = ({ state, dispatch }, params = {}) => { ...@@ -21,8 +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: 'classification', sort_by: SORT_BY.CLASSIFICATION,
sort_direction: 'desc', 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',
};
...@@ -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,8 +145,8 @@ describe('Licenses actions', () => { ...@@ -141,8 +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: 'classification', sort_by: SORT_BY.CLASSIFICATION,
sort_direction: 'desc', sort_direction: SORT_ORDER.DESC,
}; };
mock mock
...@@ -176,8 +180,8 @@ describe('Licenses actions', () => { ...@@ -176,8 +180,8 @@ describe('Licenses actions', () => {
const paramsSent = { const paramsSent = {
...paramsGiven, ...paramsGiven,
per_page: 10, per_page: 10,
sort_by: 'classification', sort_by: SORT_BY.CLASSIFICATION,
sort_direction: 'desc', 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