Commit 8f7d62a6 authored by Scott Hampton's avatar Scott Hampton

Merge branch '321201-api-fuzzing-form-ux-fine-tuning' into 'master'

API fuzzing - Scroll to top of window on error

See merge request gitlab-org/gitlab!56890
parents cbbc105c 50218ba5
...@@ -55,7 +55,7 @@ export default { ...@@ -55,7 +55,7 @@ export default {
data() { data() {
return { return {
isLoading: false, isLoading: false,
showError: false, isErrorVisible: false,
targetUrl: { targetUrl: {
field: 'targetUrl', field: 'targetUrl',
label: s__('APIFuzzing|Target URL'), label: s__('APIFuzzing|Target URL'),
...@@ -184,7 +184,7 @@ export default { ...@@ -184,7 +184,7 @@ export default {
methods: { methods: {
async onSubmit() { async onSubmit() {
this.isLoading = true; this.isLoading = true;
this.showError = false; this.dismissError();
try { try {
const input = { const input = {
projectPath: this.fullPath, projectPath: this.fullPath,
...@@ -211,21 +211,25 @@ export default { ...@@ -211,21 +211,25 @@ export default {
variables: { input }, variables: { input },
}); });
if (errors.length) { if (errors.length) {
this.showError = true; this.showError();
} else { } else {
this.ciYamlEditPath = gitlabCiYamlEditPath; this.ciYamlEditPath = gitlabCiYamlEditPath;
this.configurationYaml = configurationYaml; this.configurationYaml = configurationYaml;
this.$refs[CONFIGURATION_SNIPPET_MODAL_ID].show(); this.$refs[CONFIGURATION_SNIPPET_MODAL_ID].show();
} }
} catch (e) { } catch (e) {
this.showError = true; this.showError();
Sentry.captureException(e); Sentry.captureException(e);
} finally { } finally {
this.isLoading = false; this.isLoading = false;
} }
}, },
showError() {
this.isErrorVisible = true;
window.scrollTo({ top: 0 });
},
dismissError() { dismissError() {
this.showError = false; this.isErrorVisible = false;
}, },
}, },
SCAN_MODES, SCAN_MODES,
...@@ -234,8 +238,8 @@ export default { ...@@ -234,8 +238,8 @@ export default {
<template> <template>
<form @submit.prevent="onSubmit"> <form @submit.prevent="onSubmit">
<gl-alert v-if="showError" variant="danger" class="gl-mb-5" @dismiss="dismissError"> <gl-alert v-if="isErrorVisible" variant="danger" class="gl-mb-5" @dismiss="dismissError">
{{ s__('APIFuzzing|The configuration could not be saved, please try again later.') }} {{ s__('APIFuzzing|Code snippet could not be generated. Try again later.') }}
</gl-alert> </gl-alert>
<form-input v-model="targetUrl.value" v-bind="targetUrl" class="gl-mb-7" /> <form-input v-model="targetUrl.value" v-bind="targetUrl" class="gl-mb-7" />
......
---
title: Scroll to top of window when API Fuzzing configuration fails
merge_request: 56890
author:
type: changed
...@@ -270,6 +270,7 @@ variables: ...@@ -270,6 +270,7 @@ variables:
await waitForPromises(); await waitForPromises();
expect(findAlert().exists()).toBe(true); expect(findAlert().exists()).toBe(true);
expect(window.scrollTo).toHaveBeenCalledWith({ top: 0 });
}); });
it('shows an error on error-as-data', async () => { it('shows an error on error-as-data', async () => {
...@@ -294,6 +295,7 @@ variables: ...@@ -294,6 +295,7 @@ variables:
await waitForPromises(); await waitForPromises();
expect(findAlert().exists()).toBe(true); expect(findAlert().exists()).toBe(true);
expect(window.scrollTo).toHaveBeenCalledWith({ top: 0 });
}); });
}); });
}); });
...@@ -1494,6 +1494,9 @@ msgstr "" ...@@ -1494,6 +1494,9 @@ msgstr ""
msgid "APIFuzzing|Choose a profile" msgid "APIFuzzing|Choose a profile"
msgstr "" msgstr ""
msgid "APIFuzzing|Code snippet could not be generated. Try again later."
msgstr ""
msgid "APIFuzzing|Code snippet for the API Fuzzing configuration" msgid "APIFuzzing|Code snippet for the API Fuzzing configuration"
msgstr "" msgstr ""
...@@ -1557,9 +1560,6 @@ msgstr "" ...@@ -1557,9 +1560,6 @@ msgstr ""
msgid "APIFuzzing|Target URL" msgid "APIFuzzing|Target URL"
msgstr "" msgstr ""
msgid "APIFuzzing|The configuration could not be saved, please try again later."
msgstr ""
msgid "APIFuzzing|There are two ways to perform scans." msgid "APIFuzzing|There are two ways to perform scans."
msgstr "" msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment