|
37 | 37 | />
|
38 | 38 | </div>
|
39 | 39 |
|
40 |
| - <div class="text-right"> |
| 40 | + <div class="d-flex justify-space-between mt-4"> |
| 41 | + <v-btn |
| 42 | + color="blue-grey" |
| 43 | + @click="sendTestNotification()" |
| 44 | + width="170" |
| 45 | + :disabled="testNotificationProgress" |
| 46 | + data-testid="settings-testAlerts" |
| 47 | + >Test Alerts</v-btn> |
41 | 48 | <v-btn color="primary" @click="saveProject()">{{ $t('save') }}</v-btn>
|
42 | 49 | </div>
|
| 50 | + |
| 51 | + <v-progress-linear |
| 52 | + v-if="testNotificationProgress" |
| 53 | + color="blue-grey darken-1" |
| 54 | + indeterminate |
| 55 | + rounded |
| 56 | + width="170" |
| 57 | + height="36" |
| 58 | + style="margin-top: -36px; width: 170px;" |
| 59 | + ></v-progress-linear> |
43 | 60 | </div>
|
44 | 61 |
|
45 | 62 | <h2 class="mt-8 mb-1">{{ $t('danger_zone_settings') }}</h2>
|
@@ -167,10 +184,40 @@ export default {
|
167 | 184 | deleteProjectDialog: null,
|
168 | 185 | backupProgress: false,
|
169 | 186 | clearCacheProgress: false,
|
| 187 | + testNotificationProgress: false, |
170 | 188 | };
|
171 | 189 | },
|
172 | 190 |
|
173 | 191 | methods: {
|
| 192 | + async sendTestNotification() { |
| 193 | + this.testNotificationProgress = true; |
| 194 | + try { |
| 195 | + await axios({ |
| 196 | + method: 'post', |
| 197 | + url: `/api/project/${this.projectId}/notifications/test`, |
| 198 | + responseType: 'json', |
| 199 | + }); |
| 200 | + EventBus.$emit('i-snackbar', { |
| 201 | + color: 'success', |
| 202 | + text: 'Test notification sent.', |
| 203 | + }); |
| 204 | + } catch (err) { |
| 205 | + let msg; |
| 206 | + if (err.response.status === 409) { |
| 207 | + msg = 'Please allow alerts for the project and save it.'; |
| 208 | + } else { |
| 209 | + msg = getErrorMessage(err); |
| 210 | + } |
| 211 | +
|
| 212 | + EventBus.$emit('i-snackbar', { |
| 213 | + color: 'error', |
| 214 | + text: msg, |
| 215 | + }); |
| 216 | + } finally { |
| 217 | + this.testNotificationProgress = false; |
| 218 | + } |
| 219 | + }, |
| 220 | +
|
174 | 221 | showDrawer() {
|
175 | 222 | EventBus.$emit('i-show-drawer');
|
176 | 223 | },
|
|
0 commit comments