Commit b960a114 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Minor review comments

Moved some the isStageNameExistsError
function to a utils file
parent 4d69c73d
...@@ -103,6 +103,9 @@ export default { ...@@ -103,6 +103,9 @@ export default {
isLoadingTypeOfWork() { isLoadingTypeOfWork() {
return this.isLoadingTasksByTypeChartTopLabels || this.isLoadingTasksByTypeChart; return this.isLoadingTasksByTypeChartTopLabels || this.isLoadingTasksByTypeChart;
}, },
isUpdatingCustomStage() {
return this.isEditingCustomStage && this.isSavingCustomStage;
},
hasDateRangeSet() { hasDateRangeSet() {
return this.startDate && this.endDate; return this.startDate && this.endDate;
}, },
...@@ -296,7 +299,7 @@ export default { ...@@ -296,7 +299,7 @@ export default {
/> />
</template> </template>
<template v-if="customStageFormActive" #content> <template v-if="customStageFormActive" #content>
<div v-if="isEditingCustomStage && isSavingCustomStage"> <div v-if="isUpdatingCustomStage">
<gl-loading-icon class="mt-4" size="md" /> <gl-loading-icon class="mt-4" size="md" />
</div> </div>
<custom-stage-form <custom-stage-form
......
...@@ -3,15 +3,7 @@ import createFlash from '~/flash'; ...@@ -3,15 +3,7 @@ import createFlash from '~/flash';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import httpStatus from '~/lib/utils/http_status'; import httpStatus from '~/lib/utils/http_status';
import * as types from './mutation_types'; import * as types from './mutation_types';
import { removeFlash, handleErrorOrRethrow } from '../utils'; import { removeFlash, handleErrorOrRethrow, isStageNameExistsError } from '../utils';
const isStageNameExistsError = ({ status, errors }) => {
const ERROR_NAME_RESERVED = 'is reserved';
if (status === httpStatus.UNPROCESSABLE_ENTITY) {
if (errors?.name?.includes(ERROR_NAME_RESERVED)) return true;
}
return false;
};
export const setFeatureFlags = ({ commit }, featureFlags) => export const setFeatureFlags = ({ commit }, featureFlags) =>
commit(types.SET_FEATURE_FLAGS, featureFlags); commit(types.SET_FEATURE_FLAGS, featureFlags);
...@@ -104,7 +96,7 @@ export const receiveCycleAnalyticsDataSuccess = ({ commit, dispatch }) => { ...@@ -104,7 +96,7 @@ export const receiveCycleAnalyticsDataSuccess = ({ commit, dispatch }) => {
}; };
export const receiveCycleAnalyticsDataError = ({ commit }, { response }) => { export const receiveCycleAnalyticsDataError = ({ commit }, { response }) => {
const { status = null } = response; // non api errors thrown wont have a status field const { status = null } = response; // non api errors thrown won't have a status field
commit(types.RECEIVE_CYCLE_ANALYTICS_DATA_ERROR, status); commit(types.RECEIVE_CYCLE_ANALYTICS_DATA_ERROR, status);
if (!status || status !== httpStatus.FORBIDDEN) if (!status || status !== httpStatus.FORBIDDEN)
......
import Api from 'ee/api'; import Api from 'ee/api';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import httpStatus from '~/lib/utils/http_status';
import * as types from './mutation_types'; import * as types from './mutation_types';
import { removeFlash } from '../../../utils'; import { removeFlash, isStageNameExistsError } from '../../../utils';
const isStageNameExistsError = ({ status, errors }) => {
const ERROR_NAME_RESERVED = 'is reserved';
if (status === httpStatus.UNPROCESSABLE_ENTITY) {
if (errors?.name?.includes(ERROR_NAME_RESERVED)) return true;
}
return false;
};
export const setStageEvents = ({ commit }, data) => commit(types.SET_STAGE_EVENTS, data); export const setStageEvents = ({ commit }, data) => commit(types.SET_STAGE_EVENTS, data);
export const setStageFormErrors = ({ commit }, errors) => export const setStageFormErrors = ({ commit }, errors) =>
......
...@@ -18,6 +18,7 @@ import { STAGE_NAME } from './constants'; ...@@ -18,6 +18,7 @@ import { STAGE_NAME } from './constants';
import { toYmd } from '../shared/utils'; import { toYmd } from '../shared/utils';
const EVENT_TYPE_LABEL = 'label'; const EVENT_TYPE_LABEL = 'label';
const ERROR_NAME_RESERVED = 'is reserved';
export const removeFlash = (type = 'alert') => { export const removeFlash = (type = 'alert') => {
const flashEl = document.querySelector(`.flash-${type}`); const flashEl = document.querySelector(`.flash-${type}`);
...@@ -337,3 +338,6 @@ export const handleErrorOrRethrow = ({ action, error }) => { ...@@ -337,3 +338,6 @@ export const handleErrorOrRethrow = ({ action, error }) => {
} }
action(); action();
}; };
export const isStageNameExistsError = ({ status, errors }) =>
status === httpStatus.UNPROCESSABLE_ENTITY && errors?.name?.includes(ERROR_NAME_RESERVED);
...@@ -28,7 +28,7 @@ const stageEndpoint = ({ stageId }) => ...@@ -28,7 +28,7 @@ const stageEndpoint = ({ stageId }) =>
jest.mock('~/flash'); jest.mock('~/flash');
describe.only('Cycle analytics actions', () => { describe('Cycle analytics actions', () => {
let state; let state;
let mock; let mock;
......
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