blob: 97c74c41414e57f2b238b664a64e2d64db729bc4 [file] [log] [blame]
Derick Montagueda9f0a62021-02-14 19:21:44 -06001<template>
2 <b-modal
3 id="modal-reset"
4 ref="modal"
jason westoverd36ac8a2025-11-03 20:58:59 -06005 :title="modalTitle"
Derick Montagueda9f0a62021-02-14 19:21:44 -06006 title-tag="h2"
7 @hidden="resetConfirm"
8 >
9 <p class="mb-2">
jason westoverd36ac8a2025-11-03 20:58:59 -060010 <strong>{{ modalHeader }}</strong>
Derick Montagueda9f0a62021-02-14 19:21:44 -060011 </p>
jason westoverd36ac8a2025-11-03 20:58:59 -060012 <ul v-if="resetType == 'resetBios'" class="ps-3 mb-4">
Surya Venkatesanf1ccca32024-09-23 11:00:39 +053013 <li class="mt-1 mb-1">
jason westoverd36ac8a2025-11-03 20:58:59 -060014 {{ t('pageFactoryReset.modal.resetBiosSettingsList.item1') }}
Surya Venkatesanf1ccca32024-09-23 11:00:39 +053015 </li>
16 <li class="mt-1 mb-1">
jason westoverd36ac8a2025-11-03 20:58:59 -060017 {{ t('pageFactoryReset.modal.resetBiosSettingsList.item2') }}
Surya Venkatesanf1ccca32024-09-23 11:00:39 +053018 </li>
19 </ul>
jason westoverd36ac8a2025-11-03 20:58:59 -060020 <ul v-else-if="resetType == 'resetToDefaults'" class="ps-3 mb-4">
Surya Venkatesanf1ccca32024-09-23 11:00:39 +053021 <li class="mt-1 mb-1">
jason westoverd36ac8a2025-11-03 20:58:59 -060022 {{ t('pageFactoryReset.modal.resetToDefaultsSettingsList.item1') }}
Surya Venkatesanf1ccca32024-09-23 11:00:39 +053023 </li>
24 <li class="mt-1 mb-1">
jason westoverd36ac8a2025-11-03 20:58:59 -060025 {{ t('pageFactoryReset.modal.resetToDefaultsSettingsList.item2') }}
Surya Venkatesanf1ccca32024-09-23 11:00:39 +053026 </li>
27 <li class="mt-1 mb-1">
jason westoverd36ac8a2025-11-03 20:58:59 -060028 {{ t('pageFactoryReset.modal.resetToDefaultsSettingsList.item3') }}
Surya Venkatesanf1ccca32024-09-23 11:00:39 +053029 </li>
30 <li class="mt-1 mb-1">
jason westoverd36ac8a2025-11-03 20:58:59 -060031 {{ t('pageFactoryReset.modal.resetToDefaultsSettingsList.item4') }}
Derick Montagueda9f0a62021-02-14 19:21:44 -060032 </li>
33 </ul>
34
35 <!-- Warning message -->
Derick Montague71114fe2021-05-06 18:17:34 -050036 <template v-if="!isServerOff">
Derick Montagueda9f0a62021-02-14 19:21:44 -060037 <p class="d-flex mb-2">
38 <status-icon status="danger" />
jason westoverd36ac8a2025-11-03 20:58:59 -060039 <span id="reset-to-default-warning" class="ms-1">
40 {{ t(`pageFactoryReset.modal.resetWarningMessage`) }}
Derick Montagueda9f0a62021-02-14 19:21:44 -060041 </span>
42 </p>
43 <b-form-checkbox
44 v-model="confirm"
45 aria-describedby="reset-to-default-warning"
Surya Vde23ea22024-07-11 15:19:46 +053046 @input="v$.confirm.$touch()"
Derick Montagueda9f0a62021-02-14 19:21:44 -060047 >
jason westoverd36ac8a2025-11-03 20:58:59 -060048 {{ t(`pageFactoryReset.modal.resetWarningCheckLabel`) }}
Derick Montagueda9f0a62021-02-14 19:21:44 -060049 </b-form-checkbox>
50 <b-form-invalid-feedback
51 role="alert"
Surya Vde23ea22024-07-11 15:19:46 +053052 :state="getValidationState(v$.confirm)"
Derick Montagueda9f0a62021-02-14 19:21:44 -060053 >
jason westoverd36ac8a2025-11-03 20:58:59 -060054 {{ t('global.form.fieldRequired') }}
Derick Montagueda9f0a62021-02-14 19:21:44 -060055 </b-form-invalid-feedback>
56 </template>
57
jason westoverd36ac8a2025-11-03 20:58:59 -060058 <template #footer="{ cancel }">
Derick Montagueda9f0a62021-02-14 19:21:44 -060059 <b-button
60 variant="secondary"
61 data-test-id="factoryReset-button-cancel"
62 @click="cancel()"
63 >
jason westoverd36ac8a2025-11-03 20:58:59 -060064 {{ t('global.action.cancel') }}
Derick Montagueda9f0a62021-02-14 19:21:44 -060065 </b-button>
66 <b-button
67 type="sumbit"
68 variant="primary"
69 data-test-id="factoryReset-button-confirm"
70 @click="handleConfirm"
71 >
jason westoverd36ac8a2025-11-03 20:58:59 -060072 {{ modalSubmitText }}
Derick Montagueda9f0a62021-02-14 19:21:44 -060073 </b-button>
74 </template>
75 </b-modal>
76</template>
77<script>
78import StatusIcon from '@/components/Global/StatusIcon';
79import VuelidateMixin from '@/components/Mixins/VuelidateMixin';
Surya Venkatesanf1ccca32024-09-23 11:00:39 +053080import { useVuelidate } from '@vuelidate/core';
Surya Vde23ea22024-07-11 15:19:46 +053081import { useI18n } from 'vue-i18n';
Derick Montagueda9f0a62021-02-14 19:21:44 -060082
83export default {
84 components: { StatusIcon },
85 mixins: [VuelidateMixin],
86 props: {
87 resetType: {
88 type: String,
89 default: null,
90 },
91 },
Hariharan Rangasamyc5d60f52025-10-31 12:58:56 +053092 emits: ['okConfirm'],
Surya Venkatesanf1ccca32024-09-23 11:00:39 +053093 setup() {
94 return {
95 v$: useVuelidate(),
96 };
97 },
Derick Montagueda9f0a62021-02-14 19:21:44 -060098 data() {
99 return {
jason westoverd36ac8a2025-11-03 20:58:59 -0600100 t: useI18n().t,
Derick Montagueda9f0a62021-02-14 19:21:44 -0600101 confirm: false,
102 };
103 },
104 computed: {
Derick Montague71114fe2021-05-06 18:17:34 -0500105 serverStatus() {
106 return this.$store.getters['global/serverStatus'];
Derick Montagueda9f0a62021-02-14 19:21:44 -0600107 },
Derick Montague71114fe2021-05-06 18:17:34 -0500108 isServerOff() {
109 return this.serverStatus === 'off' ? true : false;
Derick Montagueda9f0a62021-02-14 19:21:44 -0600110 },
jason westoverd36ac8a2025-11-03 20:58:59 -0600111 modalTitle() {
112 return this.t(`pageFactoryReset.modal.${this.resetType}Title`);
113 },
114 modalHeader() {
115 return this.t(`pageFactoryReset.modal.${this.resetType}Header`);
116 },
117 modalSubmitText() {
118 return this.t(`pageFactoryReset.modal.${this.resetType}SubmitText`);
119 },
Derick Montagueda9f0a62021-02-14 19:21:44 -0600120 },
121 validations: {
122 confirm: {
123 mustBeTrue: function (value) {
Derick Montague71114fe2021-05-06 18:17:34 -0500124 return this.isServerOff || value === true;
Derick Montagueda9f0a62021-02-14 19:21:44 -0600125 },
126 },
127 },
jason westoverd36ac8a2025-11-03 20:58:59 -0600128 watch: {
129 isServerOff: {
130 handler(newValue) {
131 // Touch validation when server is on to show required message immediately
132 if (!newValue) {
133 this.$nextTick(() => {
134 this.v$.confirm.$touch();
135 });
136 }
137 },
138 immediate: true,
139 },
140 },
Derick Montagueda9f0a62021-02-14 19:21:44 -0600141 methods: {
142 handleConfirm() {
Surya Vde23ea22024-07-11 15:19:46 +0530143 this.v$.$touch();
144 if (this.v$.$invalid) return;
Derick Montagueda9f0a62021-02-14 19:21:44 -0600145 this.$emit('okConfirm');
146 this.$nextTick(() => this.$refs.modal.hide());
147 this.resetConfirm();
148 },
149 resetConfirm() {
150 this.confirm = false;
Surya Vde23ea22024-07-11 15:19:46 +0530151 this.v$.$reset();
Derick Montagueda9f0a62021-02-14 19:21:44 -0600152 },
153 },
154};
155</script>