Commit d659fe96 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo Committed by Illya Klymov

Do not set default stages as custom

parent 1507163d
<script> <script>
import { GlButton, GlButtonGroup } from '@gitlab/ui'; import { GlButton, GlButtonGroup, GlTooltipDirective } from '@gitlab/ui';
import { __ } from '~/locale';
import { STAGE_SORT_DIRECTION } from './constants'; import { STAGE_SORT_DIRECTION } from './constants';
export default { export default {
...@@ -8,6 +9,9 @@ export default { ...@@ -8,6 +9,9 @@ export default {
GlButton, GlButton,
GlButtonGroup, GlButtonGroup,
}, },
directives: {
GlTooltip: GlTooltipDirective,
},
props: { props: {
index: { index: {
type: Number, type: Number,
...@@ -36,6 +40,9 @@ export default { ...@@ -36,6 +40,9 @@ export default {
hideActionEvent() { hideActionEvent() {
return this.canRemove ? 'remove' : 'hide'; return this.canRemove ? 'remove' : 'hide';
}, },
hideActionTooltip() {
return this.canRemove ? __('Remove') : __('Hide');
},
hideActionIcon() { hideActionIcon() {
return this.canRemove ? 'remove' : 'archive'; return this.canRemove ? 'remove' : 'archive';
}, },
...@@ -50,19 +57,25 @@ export default { ...@@ -50,19 +57,25 @@ export default {
<div> <div>
<gl-button-group class="gl-px-2"> <gl-button-group class="gl-px-2">
<gl-button <gl-button
v-gl-tooltip
:data-testid="`stage-action-move-down-${index}`" :data-testid="`stage-action-move-down-${index}`"
:disabled="isLastActiveStage" :disabled="isLastActiveStage"
icon="arrow-down" icon="arrow-down"
:title="__('Move down')"
@click="$emit('move', { index, direction: $options.STAGE_SORT_DIRECTION.DOWN })" @click="$emit('move', { index, direction: $options.STAGE_SORT_DIRECTION.DOWN })"
/> />
<gl-button <gl-button
v-gl-tooltip
:data-testid="`stage-action-move-up-${index}`" :data-testid="`stage-action-move-up-${index}`"
:disabled="isFirstActiveStage" :disabled="isFirstActiveStage"
icon="arrow-up" icon="arrow-up"
:title="__('Move up')"
@click="$emit('move', { index, direction: $options.STAGE_SORT_DIRECTION.UP })" @click="$emit('move', { index, direction: $options.STAGE_SORT_DIRECTION.UP })"
/> />
</gl-button-group> </gl-button-group>
<gl-button <gl-button
v-gl-tooltip
:title="hideActionTooltip"
:data-testid="hideActionTestId" :data-testid="hideActionTestId"
:icon="hideActionIcon" :icon="hideActionIcon"
@click="$emit(hideActionEvent, index)" @click="$emit(hideActionEvent, index)"
......
...@@ -151,9 +151,10 @@ export const formatStageDataForSubmission = (stages, isEditing = false) => { ...@@ -151,9 +151,10 @@ export const formatStageDataForSubmission = (stages, isEditing = false) => {
// The new stage is still `custom` but wont have an id until the form submits and its persisted to the DB // The new stage is still `custom` but wont have an id until the form submits and its persisted to the DB
editProps = id ? { id, custom: true } : { custom: true }; editProps = id ? { id, custom: true } : { custom: true };
} }
// While we work on https://gitlab.com/gitlab-org/gitlab/-/issues/321959 we should not allow editing default
return custom return custom
? convertObjectPropsToSnakeCase({ ...rest, ...editProps, name }) ? convertObjectPropsToSnakeCase({ ...rest, ...editProps, name })
: convertObjectPropsToSnakeCase({ ...editProps, name }); : convertObjectPropsToSnakeCase({ ...editProps, name, custom: false });
}); });
}; };
......
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
GlDropdownDivider, GlDropdownDivider,
GlModal, GlModal,
GlModalDirective, GlModalDirective,
GlSprintf,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { mapState, mapActions } from 'vuex'; import { mapState, mapActions } from 'vuex';
import { sprintf, __, s__ } from '~/locale'; import { sprintf, __, s__ } from '~/locale';
...@@ -16,7 +17,7 @@ import ValueStreamForm from './value_stream_form.vue'; ...@@ -16,7 +17,7 @@ import ValueStreamForm from './value_stream_form.vue';
const i18n = { const i18n = {
DELETE_NAME: s__('DeleteValueStream|Delete %{name}'), DELETE_NAME: s__('DeleteValueStream|Delete %{name}'),
DELETE_CONFIRMATION: s__( DELETE_CONFIRMATION: s__(
'DeleteValueStream|Are you sure you want to delete "%{name}" Value Stream?', 'DeleteValueStream|Are you sure you want to delete the "%{name}" Value Stream?',
), ),
DELETED: s__("DeleteValueStream|'%{name}' Value Stream deleted"), DELETED: s__("DeleteValueStream|'%{name}' Value Stream deleted"),
DELETE: __('Delete'), DELETE: __('Delete'),
...@@ -33,6 +34,7 @@ export default { ...@@ -33,6 +34,7 @@ export default {
GlDropdownItem, GlDropdownItem,
GlDropdownDivider, GlDropdownDivider,
GlModal, GlModal,
GlSprintf,
ValueStreamForm, ValueStreamForm,
}, },
directives: { directives: {
...@@ -77,9 +79,6 @@ export default { ...@@ -77,9 +79,6 @@ export default {
isCustomValueStream() { isCustomValueStream() {
return this.selectedValueStream?.isCustom || false; return this.selectedValueStream?.isCustom || false;
}, },
deleteSelectedText() {
return sprintf(this.$options.i18n.DELETE_NAME, { name: this.selectedValueStreamName });
},
deleteConfirmationText() { deleteConfirmationText() {
return sprintf(this.$options.i18n.DELETE_CONFIRMATION, { return sprintf(this.$options.i18n.DELETE_CONFIRMATION, {
name: this.selectedValueStreamName, name: this.selectedValueStreamName,
...@@ -160,8 +159,11 @@ export default { ...@@ -160,8 +159,11 @@ export default {
v-gl-modal-directive="'delete-value-stream-modal'" v-gl-modal-directive="'delete-value-stream-modal'"
variant="danger" variant="danger"
data-testid="delete-value-stream" data-testid="delete-value-stream"
>{{ deleteSelectedText }}</gl-dropdown-item
> >
<gl-sprintf :message="$options.i18n.DELETE_NAME">
<template #name>{{ selectedValueStreamName }}</template>
</gl-sprintf>
</gl-dropdown-item>
</gl-dropdown> </gl-dropdown>
<gl-button <gl-button
v-else v-else
...@@ -193,7 +195,11 @@ export default { ...@@ -193,7 +195,11 @@ export default {
<gl-alert v-if="deleteValueStreamError" variant="danger">{{ <gl-alert v-if="deleteValueStreamError" variant="danger">{{
deleteValueStreamError deleteValueStreamError
}}</gl-alert> }}</gl-alert>
<p>{{ deleteConfirmationText }}</p> <p>
<gl-sprintf :message="$options.i18n.DELETE_CONFIRMATION">
<template #name>{{ selectedValueStreamName }}</template>
</gl-sprintf>
</p>
</gl-modal> </gl-modal>
</div> </div>
</template> </template>
...@@ -189,6 +189,10 @@ describe('formatStageDataForSubmission', () => { ...@@ -189,6 +189,10 @@ describe('formatStageDataForSubmission', () => {
it('will convert all properties to snake case', () => { it('will convert all properties to snake case', () => {
expect(Object.keys(res)).toEqual(['custom', 'name']); expect(Object.keys(res)).toEqual(['custom', 'name']);
}); });
it('will set custom to `false`', () => {
expect(res.custom).toBe(false);
});
}); });
describe('with a custom stage', () => { describe('with a custom stage', () => {
...@@ -221,12 +225,12 @@ describe('formatStageDataForSubmission', () => { ...@@ -221,12 +225,12 @@ describe('formatStageDataForSubmission', () => {
describe('isEditing = true ', () => { describe('isEditing = true ', () => {
it('will include the `id` if it has a value', () => { it('will include the `id` if it has a value', () => {
[res] = formatStageDataForSubmission([{ ...fakeStage, id: 10 }], true); [res] = formatStageDataForSubmission([{ ...fakeStage, id: 10, custom: true }], true);
expect(Object.keys(res).includes('id')).toBe(true); expect(Object.keys(res).includes('id')).toBe(true);
}); });
it('will set custom to `true`', () => { it('will set custom to `true`', () => {
[res] = formatStageDataForSubmission([fakeStage], true); [res] = formatStageDataForSubmission([{ ...fakeStage, custom: true }], true);
expect(res.custom).toBe(true); expect(res.custom).toBe(true);
}); });
}); });
......
...@@ -105,7 +105,6 @@ describe('ValueStreamSelect', () => { ...@@ -105,7 +105,6 @@ describe('ValueStreamSelect', () => {
it('renders a delete option for custom value streams', () => { it('renders a delete option for custom value streams', () => {
expect(findDeleteValueStreamButton().exists()).toBe(true); expect(findDeleteValueStreamButton().exists()).toBe(true);
expect(findDeleteValueStreamButton().text()).toBe(`Delete ${selectedValueStream.name}`);
}); });
it('renders an edit option for custom value streams', () => { it('renders an edit option for custom value streams', () => {
......
...@@ -9785,7 +9785,7 @@ msgstr "" ...@@ -9785,7 +9785,7 @@ msgstr ""
msgid "DeleteValueStream|'%{name}' Value Stream deleted" msgid "DeleteValueStream|'%{name}' Value Stream deleted"
msgstr "" msgstr ""
msgid "DeleteValueStream|Are you sure you want to delete \"%{name}\" Value Stream?" msgid "DeleteValueStream|Are you sure you want to delete the \"%{name}\" Value Stream?"
msgstr "" msgstr ""
msgid "DeleteValueStream|Delete %{name}" msgid "DeleteValueStream|Delete %{name}"
...@@ -14922,6 +14922,9 @@ msgstr "" ...@@ -14922,6 +14922,9 @@ msgstr ""
msgid "Hi %{username}!" msgid "Hi %{username}!"
msgstr "" msgstr ""
msgid "Hide"
msgstr ""
msgid "Hide archived projects" msgid "Hide archived projects"
msgstr "" msgstr ""
...@@ -19571,6 +19574,9 @@ msgstr "" ...@@ -19571,6 +19574,9 @@ msgstr ""
msgid "Move" msgid "Move"
msgstr "" msgstr ""
msgid "Move down"
msgstr ""
msgid "Move issue" msgid "Move issue"
msgstr "" msgstr ""
...@@ -19589,6 +19595,9 @@ msgstr "" ...@@ -19589,6 +19595,9 @@ msgstr ""
msgid "Move this issue to another project." msgid "Move this issue to another project."
msgstr "" msgstr ""
msgid "Move up"
msgstr ""
msgid "MoveIssue|Cannot move issue due to insufficient permissions!" msgid "MoveIssue|Cannot move issue due to insufficient permissions!"
msgstr "" msgstr ""
......
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