Commit c2af91e9 authored by Martin Wortschack's avatar Martin Wortschack Committed by Ezekiel Kigbo

[VSA] Reorder stage animation

parent 6538169b
<script> <script>
import { GlButton, GlForm, GlFormInput, GlFormGroup, GlFormRadioGroup, GlModal } from '@gitlab/ui'; import { GlButton, GlForm, GlFormInput, GlFormGroup, GlFormRadioGroup, GlModal } from '@gitlab/ui';
import { cloneDeep } from 'lodash'; import { cloneDeep, uniqueId } from 'lodash';
import Vue from 'vue'; import Vue from 'vue';
import { mapState, mapActions } from 'vuex'; import { mapState, mapActions } from 'vuex';
import { filterStagesByHiddenStatus } from '~/cycle_analytics/utils'; import { filterStagesByHiddenStatus } from '~/cycle_analytics/utils';
...@@ -26,11 +26,15 @@ import { ...@@ -26,11 +26,15 @@ import {
const initializeStageErrors = (defaultStageConfig, selectedPreset = PRESET_OPTIONS_DEFAULT) => const initializeStageErrors = (defaultStageConfig, selectedPreset = PRESET_OPTIONS_DEFAULT) =>
selectedPreset === PRESET_OPTIONS_DEFAULT ? defaultStageConfig.map(() => ({})) : [{}]; selectedPreset === PRESET_OPTIONS_DEFAULT ? defaultStageConfig.map(() => ({})) : [{}];
const initializeStages = (defaultStageConfig, selectedPreset = PRESET_OPTIONS_DEFAULT) => const initializeStages = (defaultStageConfig, selectedPreset = PRESET_OPTIONS_DEFAULT) => {
const stages =
selectedPreset === PRESET_OPTIONS_DEFAULT selectedPreset === PRESET_OPTIONS_DEFAULT
? defaultStageConfig ? defaultStageConfig
: [{ ...defaultCustomStageFields }]; : [{ ...defaultCustomStageFields }];
return stages.map((stage) => ({ ...stage, transitionKey: uniqueId('stage-') }));
};
export default { export default {
name: 'ValueStreamForm', name: 'ValueStreamForm',
components: { components: {
...@@ -85,6 +89,7 @@ export default { ...@@ -85,6 +89,7 @@ export default {
stageErrors: stageErrors:
cloneDeep(stageErrors) || initializeStageErrors(defaultStageConfig, initialPreset), cloneDeep(stageErrors) || initializeStageErrors(defaultStageConfig, initialPreset),
}; };
return { return {
hiddenStages: filterStagesByHiddenStatus(initialStages), hiddenStages: filterStagesByHiddenStatus(initialStages),
selectedPreset: initialPreset, selectedPreset: initialPreset,
...@@ -179,11 +184,6 @@ export default { ...@@ -179,11 +184,6 @@ export default {
} }
}); });
}, },
stageKey(index) {
return this.selectedPreset === PRESET_OPTIONS_DEFAULT
? `default-template-stage-${index}`
: `custom-template-stage-${index}`;
},
stageGroupLabel(index) { stageGroupLabel(index) {
return sprintf(this.$options.i18n.STAGE_INDEX, { index: index + 1 }); return sprintf(this.$options.i18n.STAGE_INDEX, { index: index + 1 });
}, },
...@@ -249,7 +249,10 @@ export default { ...@@ -249,7 +249,10 @@ export default {
addNewStage() { addNewStage() {
// validate previous stages only and add a new stage // validate previous stages only and add a new stage
this.validate(); this.validate();
Vue.set(this, 'stages', [...this.stages, { ...defaultCustomStageFields }]); Vue.set(this, 'stages', [
...this.stages,
{ ...defaultCustomStageFields, transitionKey: uniqueId('stage-') },
]);
Vue.set(this, 'stageErrors', [...this.stageErrors, {}]); Vue.set(this, 'stageErrors', [...this.stageErrors, {}]);
}, },
onAddStage() { onAddStage() {
...@@ -351,10 +354,11 @@ export default { ...@@ -351,10 +354,11 @@ export default {
@input="onSelectPreset" @input="onSelectPreset"
/> />
<div data-testid="extended-form-fields"> <div data-testid="extended-form-fields">
<transition-group name="stage-list" tag="div">
<div <div
v-for="(stage, activeStageIndex) in stages" v-for="(stage, activeStageIndex) in stages"
ref="formStages" ref="formStages"
:key="stageKey(activeStageIndex)" :key="stage.id || stage.transitionKey"
> >
<hr class="gl-my-3" /> <hr class="gl-my-3" />
<span <span
...@@ -384,6 +388,7 @@ export default { ...@@ -384,6 +388,7 @@ export default {
@input="validateStageFields(activeStageIndex)" @input="validateStageFields(activeStageIndex)"
/> />
</div> </div>
</transition-group>
<div v-if="hiddenStages.length"> <div v-if="hiddenStages.length">
<hr /> <hr />
<gl-form-group <gl-form-group
......
...@@ -54,3 +54,7 @@ ...@@ -54,3 +54,7 @@
flex: 0 0 20%; flex: 0 0 20%;
} }
} }
.stage-list-move {
transition: transform 0.15s;
}
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