xref: /openbmc/webui-vue/src/components/Global/ConfirmModal.vue (revision d36ac8a8be8636ddd0e64ce005d507b21bcdeb00)
1<template>
2  <!-- Simplified ConfirmModal using native Window.confirm() -->
3  <!-- This component preserves the API for future proper modal implementation -->
4  <div style="display: none"></div>
5</template>
6
7<script>
8export default {
9  name: 'ConfirmModal',
10  data() {
11    return {
12      resolve: null,
13    };
14  },
15  created() {
16    const bus = require('@/eventBus').default;
17    bus.$on('confirm:open', this.handleConfirm);
18  },
19  beforeUnmount() {
20    require('@/eventBus').default.$off('confirm:open', this.handleConfirm);
21  },
22  methods: {
23    handleConfirm(options) {
24      // Extract message from options (could be string or object)
25      const message =
26        typeof options === 'string'
27          ? options
28          : options.message || 'Are you sure?';
29
30      // Use native browser confirm for now
31      // The following parameters are accepted but not used by the window.confirm() shim.
32      // They will be used when the proper Bootstrap 5 modal is implemented:
33      // - title: Modal title text
34      // - okTitle: OK/Confirm button text
35      // - cancelTitle: Cancel button text
36      // - okVariant: OK button Bootstrap variant (e.g., 'danger', 'primary')
37      // - cancelVariant: Cancel button Bootstrap variant (e.g., 'secondary')
38      // - autoFocusButton: Which button to focus ('ok' or 'cancel')
39      // - processing: Show processing state with progress bar
40      // - processingText: Processing state message
41      // - processingMax: Processing progress bar maximum value
42      //
43      // Code can safely pass these parameters now and they will work when the
44      // proper modal implementation is added.
45      const result = window.confirm(message);
46
47      // Resolve the promise with result
48      if (options.resolve) {
49        options.resolve(result);
50      }
51    },
52  },
53};
54</script>
55