Skip to content

Commit ad662cc

Browse files
committed
fix: add confirmation modal for maintenance without monitors
- Add Confirm modal when creating maintenance without affected monitors - Replace unused 'atLeastOneMonitor' translation with 'noMonitorsSelectedWarning' - Allow maintenance creation without monitors (user must confirm) Addresses review feedback on PR louislam#6606
1 parent 22d9d46 commit ad662cc

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

src/lang/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@
646646
"recurringIntervalMessage": "Run once every day | Run once every {0} days",
647647
"affectedMonitorsDescription": "Select monitors that are affected by current maintenance",
648648
"affectedStatusPages": "Show this maintenance message on selected status pages",
649-
"atLeastOneMonitor": "Select at least one affected monitor",
649+
"noMonitorsSelectedWarning": "You are creating a maintenance without any affected monitors. Are you sure you want to continue?",
650650
"passwordNotMatchMsg": "The repeat password does not match.",
651651
"notificationDescription": "Notifications must be assigned to a monitor to function.",
652652
"keywordDescription": "Search keyword in plain HTML or JSON response. The search is case-sensitive.",

src/pages/EditMaintenance.vue

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@
253253
</div>
254254
</div>
255255
</form>
256+
257+
<Confirm ref="confirmNoMonitors" :yes-text="$t('Yes')" :no-text="$t('No')" @yes="doSubmit">
258+
{{ $t("noMonitorsSelectedWarning") }}
259+
</Confirm>
256260
</div>
257261
</transition>
258262
</template>
@@ -262,11 +266,13 @@ import VueMultiselect from "vue-multiselect";
262266
import Datepicker from "@vuepic/vue-datepicker";
263267
import { timezoneList } from "../util-frontend";
264268
import cronstrue from "cronstrue/i18n";
269+
import Confirm from "../components/Confirm.vue";
265270
266271
export default {
267272
components: {
268273
VueMultiselect,
269-
Datepicker
274+
Datepicker,
275+
Confirm
270276
},
271277
272278
data() {
@@ -539,11 +545,34 @@ export default {
539545
}
540546
},
541547
548+
/**
549+
* Check if maintenance has monitors or status pages assigned
550+
* @returns {boolean} True if maintenance has monitors or status pages
551+
*/
552+
hasMonitorsOrStatusPages() {
553+
const hasMonitors = this.affectedMonitors.length > 0;
554+
const hasStatusPages = this.showOnAllPages || this.selectedStatusPages.length > 0;
555+
return hasMonitors || hasStatusPages;
556+
},
557+
558+
/**
559+
* Handle form submission - show confirmation if no monitors selected
560+
* @returns {void}
561+
*/
562+
submit() {
563+
// If creating/cloning and no monitors selected, show confirmation
564+
if ((this.isAdd || this.isClone) && this.affectedMonitors.length === 0) {
565+
this.$refs.confirmNoMonitors.show();
566+
return;
567+
}
568+
this.doSubmit();
569+
},
570+
542571
/**
543572
* Create new maintenance
544573
* @returns {Promise<void>}
545574
*/
546-
async submit() {
575+
async doSubmit() {
547576
this.processing = true;
548577
549578
if (this.isAdd || this.isClone) {

0 commit comments

Comments
 (0)