Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | 4x | <script> import { GlSprintf, GlModal, GlAlert } from '@gitlab/ui'; import { s__, __ } from '~/locale'; import destroyOncallScheduleMutation from '../graphql/mutations/destroy_oncall_schedule.mutation.graphql'; import getOncallSchedulesQuery from '../graphql/queries/get_oncall_schedules.query.graphql'; import { updateStoreAfterScheduleDelete } from '../utils/cache_updates'; export const i18n = { deleteSchedule: s__('OnCallSchedules|Delete schedule'), deleteScheduleMessage: s__( 'OnCallSchedules|Are you sure you want to delete the "%{deleteSchedule}" schedule? This action cannot be undone.', ), escalationRulesWillBeDeletedMessage: s__( 'OnCallScheduless|Any escalation rules that are using this schedule will also be deleted.', ), }; export default { i18n, components: { GlSprintf, GlModal, GlAlert, }, inject: ['projectPath'], props: { schedule: { type: Object, required: true, }, modalId: { type: String, required: true, }, }, data() { return { loading: false, error: null, }; }, computed: { primaryProps() { return { text: this.$options.i18n.deleteSchedule, attributes: { category: 'primary', variant: 'danger', loading: this.loading }, }; }, cancelProps() { return { text: __('Cancel'), }; }, }, methods: { deleteSchedule() { const { projectPath, schedule: { iid }, } = this; this.loading = true; this.$apollo .mutate({ mutation: destroyOncallScheduleMutation, variables: { iid, projectPath, }, update(store, { data }) { updateStoreAfterScheduleDelete(store, getOncallSchedulesQuery, data, { projectPath }); }, }) .then(({ data: { oncallScheduleDestroy } = {} } = {}) => { const error = oncallScheduleDestroy.errors[0]; Iif (error) { throw error; } this.$refs.deleteScheduleModal.hide(); }) .catch((error) => { this.error = error; }) .finally(() => { this.loading = false; }); }, hideErrorAlert() { this.error = null; }, }, }; </script> <template> <gl-modal ref="deleteScheduleModal" :modal-id="modalId" size="sm" :data-testid="`delete-schedule-modal-${schedule.iid}`" :title="$options.i18n.deleteSchedule" :action-primary="primaryProps" :action-cancel="cancelProps" @primary.prevent="deleteSchedule" > <gl-alert v-if="error" variant="danger" class="gl-mt-n3 gl-mb-3" @dismiss="hideErrorAlert"> {{ error || $options.i18n.errorMsg }} </gl-alert> <gl-sprintf :message="$options.i18n.deleteScheduleMessage"> <template #deleteSchedule>{{ schedule.name }}</template> </gl-sprintf> <div class="gl-mt-5"> {{ $options.i18n.escalationRulesWillBeDeletedMessage }} </div> </gl-modal> </template> |