Commit 29d7ab32 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo Committed by Tim Zallmann

Ensure edit form gets correct fields

Makes sure we pass the correct stage fields
to the edit custom stage form

Updated custom stage form specs

Updated label selector specs
parent c61d4e39
...@@ -43,9 +43,7 @@ export default { ...@@ -43,9 +43,7 @@ export default {
initialFields: { initialFields: {
type: Object, type: Object,
required: false, required: false,
default: () => ({ default: () => {},
...initFields,
}),
}, },
isSavingCustomStage: { isSavingCustomStage: {
type: Boolean, type: Boolean,
...@@ -61,6 +59,7 @@ export default { ...@@ -61,6 +59,7 @@ export default {
data() { data() {
return { return {
fields: { fields: {
...initFields,
...this.initialFields, ...this.initialFields,
}, },
}; };
...@@ -114,7 +113,7 @@ export default { ...@@ -114,7 +113,7 @@ export default {
); );
}, },
isDirty() { isDirty() {
return !isEqual(this.initialFields, this.fields); return !isEqual(this.initialFields, this.fields) && !isEqual(initFields, this.fields);
}, },
hasValidStartAndEndEventPair() { hasValidStartAndEndEventPair() {
const { const {
...@@ -147,7 +146,10 @@ export default { ...@@ -147,7 +146,10 @@ export default {
}, },
methods: { methods: {
handleCancel() { handleCancel() {
this.fields = { ...this.initialFields }; this.fields = {
...initFields,
...this.initialFields,
};
this.$emit('cancel'); this.$emit('cancel');
}, },
handleSave() { handleSave() {
......
...@@ -41,7 +41,7 @@ export default { ...@@ -41,7 +41,7 @@ export default {
class="d-inline-block dropdown-label-box" class="d-inline-block dropdown-label-box"
> >
</span> </span>
{{ selectedLabel.name }} {{ selectedLabel.title }}
</span> </span>
<span v-else>{{ __('Select a label') }}</span> <span v-else>{{ __('Select a label') }}</span>
</template> </template>
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
> >
<span :style="{ backgroundColor: label.color }" class="d-inline-block dropdown-label-box"> <span :style="{ backgroundColor: label.color }" class="d-inline-block dropdown-label-box">
</span> </span>
{{ label.name }} {{ label.title }}
</gl-dropdown-item> </gl-dropdown-item>
</gl-dropdown> </gl-dropdown>
</template> </template>
...@@ -120,7 +120,25 @@ export default { ...@@ -120,7 +120,25 @@ export default {
]; ];
}, },
customStageInitialData() { customStageInitialData() {
return this.isEditingCustomStage ? this.currentStage : {}; if (this.isEditingCustomStage) {
const {
id = null,
name = null,
startEventIdentifier = null,
startEventLabel: { id: startEventLabelId = null } = {},
endEventIdentifier = null,
endEventLabel: { id: endEventLabelId = null } = {},
} = this.currentStage;
return {
id,
name,
startEventIdentifier,
startEventLabelId,
endEventIdentifier,
endEventLabelId,
};
}
return {};
}, },
}, },
methods: { methods: {
......
...@@ -30,7 +30,7 @@ exports[`TasksByTypeChart with data available filters labels with label dropdown ...@@ -30,7 +30,7 @@ exports[`TasksByTypeChart with data available filters labels with label dropdown
<a href=\\"#\\" class=\\"dropdown-menu-link is-active\\"> <a href=\\"#\\" class=\\"dropdown-menu-link is-active\\">
<span style=\\"background-color: #BADA55;\\" class=\\"d-inline-block dropdown-label-box\\"> <span style=\\"background-color: #BADA55;\\" class=\\"d-inline-block dropdown-label-box\\">
</span> </span>
Foo Label
</a> </a>
</li> </li>
...@@ -38,7 +38,7 @@ exports[`TasksByTypeChart with data available filters labels with label dropdown ...@@ -38,7 +38,7 @@ exports[`TasksByTypeChart with data available filters labels with label dropdown
<a href=\\"#\\" class=\\"dropdown-menu-link is-active\\"> <a href=\\"#\\" class=\\"dropdown-menu-link is-active\\">
<span style=\\"background-color: #0033CC;\\" class=\\"d-inline-block dropdown-label-box\\"> <span style=\\"background-color: #0033CC;\\" class=\\"d-inline-block dropdown-label-box\\">
</span> </span>
Foo::Bar
</a> </a>
</li> </li>
</ul> </ul>
......
...@@ -16,7 +16,7 @@ describe('Value Stream Analytics LabelsSelector', () => { ...@@ -16,7 +16,7 @@ describe('Value Stream Analytics LabelsSelector', () => {
} }
let wrapper = null; let wrapper = null;
const labelNames = groupLabels.map(({ name }) => name); const labelNames = groupLabels.map(({ title }) => title);
describe('with no item selected', () => { describe('with no item selected', () => {
beforeEach(() => { beforeEach(() => {
...@@ -27,8 +27,8 @@ describe('Value Stream Analytics LabelsSelector', () => { ...@@ -27,8 +27,8 @@ describe('Value Stream Analytics LabelsSelector', () => {
wrapper.destroy(); wrapper.destroy();
}); });
it.each(labelNames)('generate a label item for the label %s', name => { it.each(labelNames)('generate a label item for the label %s', title => {
expect(wrapper.text()).toContain(name); expect(wrapper.text()).toContain(title);
}); });
it('will render with the default option selected', () => { it('will render with the default option selected', () => {
...@@ -81,7 +81,7 @@ describe('Value Stream Analytics LabelsSelector', () => { ...@@ -81,7 +81,7 @@ describe('Value Stream Analytics LabelsSelector', () => {
const activeItem = wrapper.find('[active="true"]'); const activeItem = wrapper.find('[active="true"]');
expect(activeItem.exists()).toBe(true); expect(activeItem.exists()).toBe(true);
expect(activeItem.text()).toEqual(selectedLabel.name); expect(activeItem.text()).toEqual(selectedLabel.title);
}); });
}); });
}); });
...@@ -17,7 +17,7 @@ const endpoints = { ...@@ -17,7 +17,7 @@ const endpoints = {
summaryData: 'analytics/value_stream_analytics/summary.json', summaryData: 'analytics/value_stream_analytics/summary.json',
}; };
export const groupLabels = mockLabels.map(({ title, ...rest }) => ({ ...rest, name: title })); export const groupLabels = mockLabels;
export const group = { export const group = {
id: 1, id: 1,
......
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