|
3 | 3 | @click="showDialog = true" |
4 | 4 | v-bind="$attrs" |
5 | 5 | :disabled="notHasAuthorization" |
| 6 | + data-test="firewall-delete-dialog-btn" |
6 | 7 | > |
7 | 8 | <div class="d-flex align-center"> |
8 | 9 | <div class="mr-2"> |
|
50 | 51 | </v-dialog> |
51 | 52 | </template> |
52 | 53 |
|
53 | | -<script lang="ts"> |
54 | | -import { defineComponent, ref } from "vue"; |
| 54 | +<script setup lang="ts"> |
| 55 | +import { ref } from "vue"; |
55 | 56 | import { |
56 | 57 | INotificationsError, |
57 | 58 | INotificationsSuccess, |
58 | 59 | } from "../../interfaces/INotifications"; |
59 | 60 | import { useStore } from "../../store"; |
60 | 61 | import handleError from "@/utils/handleError"; |
61 | 62 |
|
62 | | -export default defineComponent({ |
63 | | - props: { |
64 | | - id: { |
65 | | - type: String, |
66 | | - required: true, |
67 | | - }, |
68 | | - notHasAuthorization: { |
69 | | - type: Boolean, |
70 | | - default: false, |
71 | | - }, |
| 63 | +const props = defineProps({ |
| 64 | + id: { |
| 65 | + type: String, |
| 66 | + required: true, |
72 | 67 | }, |
73 | | - emits: ["update"], |
74 | | - setup(props, ctx) { |
75 | | - const showDialog = ref(false); |
76 | | - const store = useStore(); |
77 | | -
|
78 | | - const remove = async () => { |
79 | | - try { |
80 | | - await store.dispatch("firewallRules/remove", props.id); |
81 | | -
|
82 | | - store.dispatch( |
83 | | - "snackbar/showSnackbarSuccessAction", |
84 | | - INotificationsSuccess.firewallRuleDeleting, |
85 | | - ); |
86 | | - ctx.emit("update"); |
87 | | - } catch (error: unknown) { |
88 | | - store.dispatch( |
89 | | - "snackbar/showSnackbarErrorAction", |
90 | | - INotificationsError.firewallRuleDeleting, |
91 | | - ); |
92 | | - handleError(error); |
93 | | - } finally { |
94 | | - showDialog.value = false; |
95 | | - } |
96 | | - }; |
97 | | -
|
98 | | - return { |
99 | | - showDialog, |
100 | | - remove, |
101 | | - }; |
| 68 | + notHasAuthorization: { |
| 69 | + type: Boolean, |
| 70 | + default: false, |
102 | 71 | }, |
103 | 72 | }); |
| 73 | +const emit = defineEmits(["update"]); |
| 74 | +const showDialog = ref(false); |
| 75 | +const store = useStore(); |
| 76 | +
|
| 77 | +const remove = async () => { |
| 78 | + try { |
| 79 | + await store.dispatch("firewallRules/remove", props.id); |
| 80 | +
|
| 81 | + store.dispatch( |
| 82 | + "snackbar/showSnackbarSuccessAction", |
| 83 | + INotificationsSuccess.firewallRuleDeleting, |
| 84 | + ); |
| 85 | + emit("update"); |
| 86 | + } catch (error: unknown) { |
| 87 | + store.dispatch( |
| 88 | + "snackbar/showSnackbarErrorAction", |
| 89 | + INotificationsError.firewallRuleDeleting, |
| 90 | + ); |
| 91 | + handleError(error); |
| 92 | + } finally { |
| 93 | + showDialog.value = false; |
| 94 | + } |
| 95 | +}; |
104 | 96 | </script> |
0 commit comments