Commit 2f9231ac authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Fix creating a custom stage

Updates the route for creating a
custom stage
parent 1db40d61
...@@ -42,15 +42,16 @@ export const receiveStageDataError = ({ commit }) => { ...@@ -42,15 +42,16 @@ export const receiveStageDataError = ({ commit }) => {
createFlash(__('There was an error fetching data for the selected stage')); createFlash(__('There was an error fetching data for the selected stage'));
}; };
export const fetchStageData = ({ state, dispatch, getters }, slug) => { export const fetchStageData = ({ dispatch, getters }, slug) => {
const { cycleAnalyticsRequestParams = {} } = getters; const { cycleAnalyticsRequestParams = {}, currentValueStreamId, currentGroupPath } = getters;
const {
selectedGroup: { fullPath },
} = state;
dispatch('requestStageData'); dispatch('requestStageData');
return Api.cycleAnalyticsStageEvents(fullPath, slug, cycleAnalyticsRequestParams) return Api.cycleAnalyticsStageEvents(
currentGroupPath,
currentValueStreamId,
slug,
cycleAnalyticsRequestParams,
)
.then(({ data }) => dispatch('receiveStageDataSuccess', data)) .then(({ data }) => dispatch('receiveStageDataSuccess', data))
.catch(error => dispatch('receiveStageDataError', error)); .catch(error => dispatch('receiveStageDataError', error));
}; };
...@@ -72,13 +73,23 @@ const fetchStageMedian = (currentGroupPath, stageId, params) => ...@@ -72,13 +73,23 @@ const fetchStageMedian = (currentGroupPath, stageId, params) =>
})); }));
export const fetchStageMedianValues = ({ dispatch, getters }) => { export const fetchStageMedianValues = ({ dispatch, getters }) => {
const { currentGroupPath, cycleAnalyticsRequestParams, activeStages } = getters; const {
currentGroupPath,
cycleAnalyticsRequestParams,
activeStages,
currentValueStreamId,
} = getters;
const stageIds = activeStages.map(s => s.slug); const stageIds = activeStages.map(s => s.slug);
dispatch('requestStageMedianValues'); dispatch('requestStageMedianValues');
return Promise.all( return Promise.all(
stageIds.map(stageId => stageIds.map(stageId =>
fetchStageMedian(currentGroupPath, stageId, cycleAnalyticsRequestParams), fetchStageMedian(
currentGroupPath,
currentValueStreamId,
stageId,
cycleAnalyticsRequestParams,
),
), ),
) )
.then(data => dispatch('receiveStageMedianValuesSuccess', data)) .then(data => dispatch('receiveStageMedianValuesSuccess', data))
......
...@@ -23,13 +23,19 @@ export const receiveDurationDataError = ({ commit }) => { ...@@ -23,13 +23,19 @@ export const receiveDurationDataError = ({ commit }) => {
export const fetchDurationData = ({ dispatch, rootGetters }) => { export const fetchDurationData = ({ dispatch, rootGetters }) => {
dispatch('requestDurationData'); dispatch('requestDurationData');
const { cycleAnalyticsRequestParams, activeStages, currentGroupPath } = rootGetters; const {
cycleAnalyticsRequestParams,
activeStages,
currentGroupPath,
currentValueStreamId,
} = rootGetters;
return Promise.all( return Promise.all(
activeStages.map(stage => { activeStages.map(stage => {
const { slug } = stage; const { slug } = stage;
return Api.cycleAnalyticsDurationChart( return Api.cycleAnalyticsDurationChart(
currentGroupPath, currentGroupPath,
currentValueStreamId,
slug, slug,
cycleAnalyticsRequestParams, cycleAnalyticsRequestParams,
).then(({ data }) => ({ ).then(({ data }) => ({
...@@ -53,7 +59,12 @@ export const receiveDurationMedianDataError = ({ commit }) => { ...@@ -53,7 +59,12 @@ export const receiveDurationMedianDataError = ({ commit }) => {
export const fetchDurationMedianData = ({ dispatch, rootState, rootGetters }) => { export const fetchDurationMedianData = ({ dispatch, rootState, rootGetters }) => {
const { startDate, endDate } = rootState; const { startDate, endDate } = rootState;
const { cycleAnalyticsRequestParams, activeStages, currentGroupPath } = rootGetters; const {
cycleAnalyticsRequestParams,
activeStages,
currentGroupPath,
currentValueStreamId,
} = rootGetters;
const offsetValue = getDayDifference(new Date(startDate), new Date(endDate)); const offsetValue = getDayDifference(new Date(startDate), new Date(endDate));
const offsetCreatedAfter = getDateInPast(new Date(startDate), offsetValue); const offsetCreatedAfter = getDateInPast(new Date(startDate), offsetValue);
...@@ -63,7 +74,7 @@ export const fetchDurationMedianData = ({ dispatch, rootState, rootGetters }) => ...@@ -63,7 +74,7 @@ export const fetchDurationMedianData = ({ dispatch, rootState, rootGetters }) =>
activeStages.map(stage => { activeStages.map(stage => {
const { slug } = stage; const { slug } = stage;
return Api.cycleAnalyticsDurationChart(currentGroupPath, slug, { return Api.cycleAnalyticsDurationChart(currentGroupPath, currentValueStreamId, slug, {
...cycleAnalyticsRequestParams, ...cycleAnalyticsRequestParams,
created_after: dateFormat(offsetCreatedAfter, dateFormats.isoDate), created_after: dateFormat(offsetCreatedAfter, dateFormats.isoDate),
created_before: dateFormat(offsetCreatedBefore, dateFormats.isoDate), created_before: dateFormat(offsetCreatedBefore, dateFormats.isoDate),
......
...@@ -16,15 +16,17 @@ export default { ...@@ -16,15 +16,17 @@ export default {
cycleAnalyticsTimeSummaryDataPath: '/groups/:id/-/analytics/value_stream_analytics/time_summary', cycleAnalyticsTimeSummaryDataPath: '/groups/:id/-/analytics/value_stream_analytics/time_summary',
cycleAnalyticsGroupStagesAndEventsPath: '/groups/:id/-/analytics/value_stream_analytics/stages', cycleAnalyticsGroupStagesAndEventsPath: '/groups/:id/-/analytics/value_stream_analytics/stages',
cycleAnalyticsValueStreamGroupStagesAndEventsPath: cycleAnalyticsValueStreamGroupStagesAndEventsPath:
'/groups/:id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages', '/groups/:group_id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages',
cycleAnalyticsValueStreamsPath: '/groups/:id/-/analytics/value_stream_analytics/value_streams', cycleAnalyticsValueStreamsPath:
'/groups/:group_id/-/analytics/value_stream_analytics/value_streams',
cycleAnalyticsStageEventsPath: cycleAnalyticsStageEventsPath:
'/groups/:id/-/analytics/value_stream_analytics/stages/:stage_id/records', '/groups/:group_id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id/records',
cycleAnalyticsStageMedianPath: cycleAnalyticsStageMedianPath:
'/groups/:id/-/analytics/value_stream_analytics/stages/:stage_id/median', '/groups/:group_id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id/median',
cycleAnalyticsStagePath: '/groups/:id/-/analytics/value_stream_analytics/stages/:stage_id', cycleAnalyticsStagePath:
'/groups/:group_id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id',
cycleAnalyticsDurationChartPath: cycleAnalyticsDurationChartPath:
'/groups/:id/-/analytics/value_stream_analytics/stages/:stage_id/duration_chart', '/groups/:group_id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id/duration_chart',
cycleAnalyticsGroupLabelsPath: '/groups/:namespace_path/-/labels.json', cycleAnalyticsGroupLabelsPath: '/groups/:namespace_path/-/labels.json',
codeReviewAnalyticsPath: '/api/:version/analytics/code_review', codeReviewAnalyticsPath: '/api/:version/analytics/code_review',
groupActivityIssuesPath: '/api/:version/analytics/group_activity/issues_count', groupActivityIssuesPath: '/api/:version/analytics/group_activity/issues_count',
...@@ -146,23 +148,25 @@ export default { ...@@ -146,23 +148,25 @@ export default {
cycleAnalyticsValueStreamGroupStagesAndEvents(groupId, valueStreamId, params = {}) { cycleAnalyticsValueStreamGroupStagesAndEvents(groupId, valueStreamId, params = {}) {
const url = Api.buildUrl(this.cycleAnalyticsValueStreamGroupStagesAndEventsPath) const url = Api.buildUrl(this.cycleAnalyticsValueStreamGroupStagesAndEventsPath)
.replace(':id', groupId) .replace(':group_id', groupId)
.replace(':value_stream_id', valueStreamId); .replace(':value_stream_id', valueStreamId);
return axios.get(url, { params }); return axios.get(url, { params });
}, },
cycleAnalyticsStageEvents(groupId, stageId, params = {}) { cycleAnalyticsStageEvents(groupId, valueStreamId, stageId, params = {}) {
const url = Api.buildUrl(this.cycleAnalyticsStageEventsPath) const url = Api.buildUrl(this.cycleAnalyticsStageEventsPath)
.replace(':id', groupId) .replace(':value_stream_id', valueStreamId)
.replace(':group_id', groupId)
.replace(':stage_id', stageId); .replace(':stage_id', stageId);
return axios.get(url, { params }); return axios.get(url, { params });
}, },
cycleAnalyticsStageMedian(groupId, stageId, params = {}) { cycleAnalyticsStageMedian(groupId, valueStreamId, stageId, params = {}) {
const url = Api.buildUrl(this.cycleAnalyticsStageMedianPath) const url = Api.buildUrl(this.cycleAnalyticsStageMedianPath)
.replace(':id', groupId) .replace(':group_id', groupId)
.replace(':value_stream_id', valueStreamId)
.replace(':stage_id', stageId); .replace(':stage_id', stageId);
return axios.get(url, { params: { ...params } }); return axios.get(url, { params: { ...params } });
...@@ -170,43 +174,45 @@ export default { ...@@ -170,43 +174,45 @@ export default {
cycleAnalyticsCreateStage(groupId, valueStreamId, data) { cycleAnalyticsCreateStage(groupId, valueStreamId, data) {
const url = Api.buildUrl(this.cycleAnalyticsValueStreamGroupStagesAndEventsPath) const url = Api.buildUrl(this.cycleAnalyticsValueStreamGroupStagesAndEventsPath)
.replace(':id', groupId) .replace(':group_id', groupId)
.replace(':value_stream_id', valueStreamId); .replace(':value_stream_id', valueStreamId);
return axios.post(url, data); return axios.post(url, data);
}, },
cycleAnalyticsCreateValueStream(groupId, data) { cycleAnalyticsCreateValueStream(groupId, data) {
const url = Api.buildUrl(this.cycleAnalyticsValueStreamsPath).replace(':id', groupId); const url = Api.buildUrl(this.cycleAnalyticsValueStreamsPath).replace(':group_id', groupId);
return axios.post(url, data); return axios.post(url, data);
}, },
cycleAnalyticsValueStreams(groupId, data) { cycleAnalyticsValueStreams(groupId, data) {
const url = Api.buildUrl(this.cycleAnalyticsValueStreamsPath).replace(':id', groupId); const url = Api.buildUrl(this.cycleAnalyticsValueStreamsPath).replace(':group_id', groupId);
return axios.get(url, data); return axios.get(url, data);
}, },
cycleAnalyticsStageUrl(stageId, groupId) { cycleAnalyticsStageUrl(groupId, valueStreamId, stageId) {
return Api.buildUrl(this.cycleAnalyticsStagePath) return Api.buildUrl(this.cycleAnalyticsStagePath)
.replace(':id', groupId) .replace(':group_id', groupId)
.replace(':value_stream_id', valueStreamId)
.replace(':stage_id', stageId); .replace(':stage_id', stageId);
}, },
cycleAnalyticsUpdateStage(stageId, groupId, data) { cycleAnalyticsUpdateStage(groupId, valueStreamId, stageId, data) {
const url = this.cycleAnalyticsStageUrl(stageId, groupId); const url = this.cycleAnalyticsStageUrl(valueStreamId, stageId, groupId);
return axios.put(url, data); return axios.put(url, data);
}, },
cycleAnalyticsRemoveStage(stageId, groupId) { cycleAnalyticsRemoveStage(groupId, valueStreamId, stageId) {
const url = this.cycleAnalyticsStageUrl(stageId, groupId); const url = this.cycleAnalyticsStageUrl(groupId, valueStreamId, stageId);
return axios.delete(url); return axios.delete(url);
}, },
cycleAnalyticsDurationChart(groupId, stageSlug, params = {}) { cycleAnalyticsDurationChart(groupId, valueStreamId, stageSlug, params = {}) {
const url = Api.buildUrl(this.cycleAnalyticsDurationChartPath) const url = Api.buildUrl(this.cycleAnalyticsDurationChartPath)
.replace(':id', groupId) .replace(':group_id', groupId)
.replace(':value_stream_id', valueStreamId)
.replace(':stage_id', stageSlug); .replace(':stage_id', stageSlug);
return axios.get(url, { return axios.get(url, {
......
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