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