Commit 62f1c400 authored by Christie Lenneville's avatar Christie Lenneville Committed by Nicolò Maria Mezzopera

Update delete environment modal to gl component

parent 6a0db429
<script> <script>
import { GlTooltipDirective } from '@gitlab/ui'; import { GlTooltipDirective, GlModal } from '@gitlab/ui';
import GlModal from '~/vue_shared/components/gl_modal.vue';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
export default { export default {
id: 'delete-environment-modal', id: 'delete-environment-modal',
name: 'DeleteEnvironmentModal', name: 'DeleteEnvironmentModal',
components: { components: {
GlModal, GlModal,
}, },
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
}, },
props: { props: {
environment: { environment: {
type: Object, type: Object,
required: true, required: true,
}, },
}, },
computed: { computed: {
primaryProps() {
return {
text: s__('Environments|Delete environment'),
attributes: [{ variant: 'danger' }],
};
},
cancelProps() {
return {
text: s__('Cancel'),
};
},
confirmDeleteMessage() { confirmDeleteMessage() {
return sprintf( return sprintf(
s__( s__(
...@@ -35,8 +41,12 @@ export default { ...@@ -35,8 +41,12 @@ export default {
false, false,
); );
}, },
modalTitle() {
return sprintf(s__(`Environments|Delete '%{environmentName}'?`), {
environmentName: this.environment.name,
});
},
}, },
methods: { methods: {
onSubmit() { onSubmit() {
eventHub.$emit('deleteEnvironment', this.environment); eventHub.$emit('deleteEnvironment', this.environment);
...@@ -47,20 +57,12 @@ export default { ...@@ -47,20 +57,12 @@ export default {
<template> <template>
<gl-modal <gl-modal
:id="$options.id" :modal-id="$options.id"
:footer-primary-button-text="s__('Environments|Delete environment')" :action-primary="primaryProps"
footer-primary-button-variant="danger" :action-cancel="cancelProps"
@submit="onSubmit" :title="modalTitle"
@primary="onSubmit"
> >
<template #header>
<h4 class="modal-title d-flex mw-100">
{{ __('Delete') }}
<span v-gl-tooltip :title="environment.name" class="text-truncate mx-1 flex-fill">
{{ environment.name }}?
</span>
</h4>
</template>
<p>{{ confirmDeleteMessage }}</p> <p>{{ confirmDeleteMessage }}</p>
</gl-modal> </gl-modal>
</template> </template>
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Used in the environments table. * Used in the environments table.
*/ */
import { GlTooltipDirective, GlButton } from '@gitlab/ui'; import { GlTooltipDirective, GlButton, GlModalDirective } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
...@@ -14,6 +14,7 @@ export default { ...@@ -14,6 +14,7 @@ export default {
}, },
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
GlModalDirective,
}, },
props: { props: {
environment: { environment: {
...@@ -54,6 +55,7 @@ export default { ...@@ -54,6 +55,7 @@ export default {
<template> <template>
<gl-button <gl-button
v-gl-tooltip="{ id: $options.deleteEnvironmentTooltipId }" v-gl-tooltip="{ id: $options.deleteEnvironmentTooltipId }"
v-gl-modal-directive="'delete-environment-modal'"
:loading="isLoading" :loading="isLoading"
:title="title" :title="title"
:aria-label="title" :aria-label="title"
...@@ -61,8 +63,6 @@ export default { ...@@ -61,8 +63,6 @@ export default {
variant="danger" variant="danger"
category="primary" category="primary"
icon="remove" icon="remove"
data-toggle="modal"
data-target="#delete-environment-modal"
@click="onClick" @click="onClick"
/> />
</template> </template>
...@@ -10411,6 +10411,9 @@ msgstr "" ...@@ -10411,6 +10411,9 @@ msgstr ""
msgid "Environments|Delete" msgid "Environments|Delete"
msgstr "" msgstr ""
msgid "Environments|Delete '%{environmentName}'?"
msgstr ""
msgid "Environments|Delete environment" msgid "Environments|Delete environment"
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