2021-04-29 21:17:54 +05:30
|
|
|
<script>
|
|
|
|
import { GlModal, GlSprintf, GlButton } from '@gitlab/ui';
|
|
|
|
import { uniqueId } from 'lodash';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
GlModal,
|
|
|
|
GlSprintf,
|
|
|
|
GlButton,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
selector: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
labelName: '',
|
|
|
|
subjectName: '',
|
|
|
|
destroyPath: '',
|
|
|
|
modalId: uniqueId('modal-delete-label-'),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
document.querySelectorAll(this.selector).forEach((button) => {
|
|
|
|
button.addEventListener('click', (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
const { labelName, subjectName, destroyPath } = button.dataset;
|
|
|
|
this.labelName = labelName;
|
|
|
|
this.subjectName = subjectName;
|
|
|
|
this.destroyPath = destroyPath;
|
|
|
|
this.openModal();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
openModal() {
|
|
|
|
this.$refs.modal.show();
|
|
|
|
},
|
|
|
|
closeModal() {
|
|
|
|
this.$refs.modal.hide();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<gl-modal ref="modal" :modal-id="modalId">
|
|
|
|
<template #modal-title>
|
|
|
|
<gl-sprintf :message="__('Delete label: %{labelName}')">
|
|
|
|
<template #labelName>
|
|
|
|
{{ labelName }}
|
|
|
|
</template>
|
|
|
|
</gl-sprintf>
|
|
|
|
</template>
|
|
|
|
<gl-sprintf
|
2022-03-02 08:16:31 +05:30
|
|
|
v-if="subjectName"
|
2021-04-29 21:17:54 +05:30
|
|
|
:message="
|
|
|
|
__(
|
|
|
|
`%{strongStart}${labelName}%{strongEnd} will be permanently deleted from ${subjectName}. This cannot be undone.`,
|
|
|
|
)
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<template #strong="{ content }">
|
|
|
|
<strong>{{ content }}</strong>
|
|
|
|
</template>
|
|
|
|
</gl-sprintf>
|
2022-03-02 08:16:31 +05:30
|
|
|
<gl-sprintf
|
|
|
|
v-else
|
|
|
|
:message="
|
|
|
|
__(
|
|
|
|
`%{strongStart}${labelName}%{strongEnd} will be permanently deleted. This cannot be undone.`,
|
|
|
|
)
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<template #strong="{ content }">
|
|
|
|
<strong>{{ content }}</strong>
|
|
|
|
</template>
|
|
|
|
</gl-sprintf>
|
2021-04-29 21:17:54 +05:30
|
|
|
<template #modal-footer>
|
|
|
|
<gl-button category="secondary" @click="closeModal">{{ __('Cancel') }}</gl-button>
|
2023-06-20 00:43:36 +05:30
|
|
|
<gl-button category="primary" variant="danger" :href="destroyPath" data-method="delete">{{
|
|
|
|
__('Delete label')
|
|
|
|
}}</gl-button>
|
2021-04-29 21:17:54 +05:30
|
|
|
</template>
|
|
|
|
</gl-modal>
|
|
|
|
</template>
|