blob: 77f03b0821778a3f2ec0766fb8447f36b9c821fc [file] [log] [blame]
Yoshie Muranakaf415a082020-12-07 13:04:11 -08001<template>
2 <b-modal
3 id="modal-confirmation"
4 ref="modal"
5 :title="$t('pageDumps.modal.initiateSystemDump')"
6 @hidden="resetForm"
7 >
8 <p>
9 <strong>
10 {{ $t('pageDumps.modal.initiateSystemDumpMessage1') }}
11 </strong>
12 </p>
13 <p>
14 {{ $t('pageDumps.modal.initiateSystemDumpMessage2') }}
15 </p>
16 <p>
17 <status-icon status="danger" />
18 {{ $t('pageDumps.modal.initiateSystemDumpMessage3') }}
19 </p>
Surya Vde23ea22024-07-11 15:19:46 +053020 <b-form-checkbox v-model="confirmed" @input="v$.confirmed.$touch()">
Yoshie Muranakaf415a082020-12-07 13:04:11 -080021 {{ $t('pageDumps.modal.initiateSystemDumpMessage4') }}
22 </b-form-checkbox>
23 <b-form-invalid-feedback
Surya Vde23ea22024-07-11 15:19:46 +053024 :state="getValidationState(v$.confirmed)"
Yoshie Muranakaf415a082020-12-07 13:04:11 -080025 role="alert"
26 >
27 {{ $t('global.form.required') }}
28 </b-form-invalid-feedback>
29 <template #modal-footer="{ cancel }">
30 <b-button variant="secondary" @click="cancel()">
31 {{ $t('global.action.cancel') }}
32 </b-button>
33 <b-button variant="danger" @click="handleSubmit">
34 {{ $t('pageDumps.form.initiateDump') }}
35 </b-button>
36 </template>
37 </b-modal>
38</template>
39
40<script>
41import StatusIcon from '@/components/Global/StatusIcon';
42import VuelidateMixin from '@/components/Mixins/VuelidateMixin.js';
Ed Tanous7d6b44c2024-03-23 14:56:34 -070043import { useVuelidate } from '@vuelidate/core';
Paul Fertser6e53b142025-01-21 16:19:36 +000044import { useI18n } from 'vue-i18n';
Yoshie Muranakaf415a082020-12-07 13:04:11 -080045
46export default {
47 components: { StatusIcon },
48 mixins: [VuelidateMixin],
tiwari-nishante1420032025-09-01 12:11:14 +053049 props: {
50 requireConfirmation: {
51 type: Boolean,
52 default: false,
53 },
54 },
Hariharan Rangasamyc5d60f52025-10-31 12:58:56 +053055 emits: ['ok'],
Ed Tanous7d6b44c2024-03-23 14:56:34 -070056 setup() {
57 return {
58 v$: useVuelidate(),
59 };
60 },
Yoshie Muranakaf415a082020-12-07 13:04:11 -080061 data() {
62 return {
Paul Fertser6e53b142025-01-21 16:19:36 +000063 $t: useI18n().t,
Yoshie Muranakaf415a082020-12-07 13:04:11 -080064 confirmed: false,
tiwari-nishante1420032025-09-01 12:11:14 +053065 isOpen: this.requireConfirmation,
Yoshie Muranakaf415a082020-12-07 13:04:11 -080066 };
67 },
tiwari-nishante1420032025-09-01 12:11:14 +053068 validations() {
69 return this.isOpen
70 ? {
71 confirmed: {
72 mustBeTrue: (value) => value === true,
73 },
74 }
75 : {};
Yoshie Muranakaf415a082020-12-07 13:04:11 -080076 },
77 methods: {
78 closeModal() {
79 this.$nextTick(() => {
80 this.$refs.modal.hide();
81 });
82 },
83 handleSubmit() {
Surya Vde23ea22024-07-11 15:19:46 +053084 this.v$.$touch();
85 if (this.v$.$invalid) return;
Yoshie Muranakaf415a082020-12-07 13:04:11 -080086 this.$emit('ok');
87 this.closeModal();
88 },
89 resetForm() {
90 this.confirmed = false;
tiwari-nishante1420032025-09-01 12:11:14 +053091 this.isOpen = false;
Surya Vde23ea22024-07-11 15:19:46 +053092 this.v$.$reset();
Yoshie Muranakaf415a082020-12-07 13:04:11 -080093 },
94 },
95};
96</script>