Commit d6692f4d authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '301003-cancel-button' into 'master'

Add cancel button

See merge request gitlab-org/gitlab!80608
parents 51fd9ff0 a15ae913
<script> <script>
import { GlForm, GlButton, GlAlert } from '@gitlab/ui'; import { GlForm, GlButton, GlAlert } from '@gitlab/ui';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { s__ } from '~/locale'; import { s__, __ } from '~/locale';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import { TYPE_PROJECT } from '~/graphql_shared/constants'; import { TYPE_PROJECT } from '~/graphql_shared/constants';
import { redirectTo } from '~/lib/utils/url_utility'; import { redirectTo } from '~/lib/utils/url_utility';
...@@ -22,7 +22,7 @@ export default { ...@@ -22,7 +22,7 @@ export default {
SectionName, SectionName,
SectionSolution, SectionSolution,
}, },
inject: ['projectId'], inject: ['projectId', 'vulnerabilityReportPath'],
data() { data() {
return { return {
form: { form: {
...@@ -181,6 +181,7 @@ export default { ...@@ -181,6 +181,7 @@ export default {
}, },
i18n: { i18n: {
title: s__('VulnerabilityManagement|Add vulnerability finding'), title: s__('VulnerabilityManagement|Add vulnerability finding'),
cancel: __('Cancel'),
submitVulnerability: s__('VulnerabilityManagement|Submit vulnerability'), submitVulnerability: s__('VulnerabilityManagement|Submit vulnerability'),
submitError: s__('VulnerabilityManagement|Something went wrong while creating vulnerability'), submitError: s__('VulnerabilityManagement|Something went wrong while creating vulnerability'),
description: s__( description: s__(
...@@ -223,10 +224,17 @@ export default { ...@@ -223,10 +224,17 @@ export default {
<gl-button <gl-button
type="submit" type="submit"
variant="confirm" variant="confirm"
class="js-no-auto-disable" class="js-no-auto-disable gl-mr-3"
:disabled="submitting" :disabled="submitting"
>{{ $options.i18n.submitVulnerability }}</gl-button >{{ $options.i18n.submitVulnerability }}</gl-button
> >
<gl-button
type="button"
class="js-no-auto-disable"
:disabled="submitting"
:href="vulnerabilityReportPath"
>{{ $options.i18n.cancel }}</gl-button
>
</div> </div>
</gl-form> </gl-form>
</div> </div>
......
...@@ -13,6 +13,7 @@ export default (el) => { ...@@ -13,6 +13,7 @@ export default (el) => {
provide: { provide: {
markdownDocsPath: el.dataset.markdownDocsPath, markdownDocsPath: el.dataset.markdownDocsPath,
markdownPreviewPath: el.dataset.markdownPreviewPath, markdownPreviewPath: el.dataset.markdownPreviewPath,
vulnerabilityReportPath: el.dataset.vulnerabilityReportPath,
projectId: el.dataset.projectId, projectId: el.dataset.projectId,
}, },
render: (h) => h(App), render: (h) => h(App),
......
...@@ -6,4 +6,5 @@ ...@@ -6,4 +6,5 @@
#js-vulnerability-new{ data: { markdown_docs_path: help_page_path('user/markdown'), #js-vulnerability-new{ data: { markdown_docs_path: help_page_path('user/markdown'),
markdown_preview_path: preview_markdown_path(@project), markdown_preview_path: preview_markdown_path(@project),
vulnerability_report_path: project_security_vulnerability_report_index_path(@project),
project_id: @project.id } } project_id: @project.id } }
...@@ -23,6 +23,8 @@ jest.mock('~/lib/utils/url_utility', () => ({ ...@@ -23,6 +23,8 @@ jest.mock('~/lib/utils/url_utility', () => ({
describe('New vulnerability component', () => { describe('New vulnerability component', () => {
const projectId = '22'; const projectId = '22';
const vulnerabilityReportPath = '/root/security-reports/-/vulnerability_report';
let wrapper; let wrapper;
const inputs = { const inputs = {
...@@ -54,13 +56,15 @@ describe('New vulnerability component', () => { ...@@ -54,13 +56,15 @@ describe('New vulnerability component', () => {
const findSectionDetails = () => wrapper.findComponent(SectionDetails); const findSectionDetails = () => wrapper.findComponent(SectionDetails);
const findSectionSolution = () => wrapper.findComponent(SectionSolution); const findSectionSolution = () => wrapper.findComponent(SectionSolution);
const findSectionIdentifiers = () => wrapper.findComponent(SectionIdentifiers); const findSectionIdentifiers = () => wrapper.findComponent(SectionIdentifiers);
const findSubmitButton = () => wrapper.findComponent(GlButton); const findSubmitButton = () => wrapper.findAllComponents(GlButton).at(0);
const findCancelButton = () => wrapper.findAllComponents(GlButton).at(1);
const createWrapper = ({ apolloProvider } = {}) => { const createWrapper = ({ apolloProvider } = {}) => {
return shallowMountExtended(NewVulnerability, { return shallowMountExtended(NewVulnerability, {
apolloProvider, apolloProvider,
provide: { provide: {
projectId, projectId,
vulnerabilityReportPath,
}, },
}); });
}; };
...@@ -103,6 +107,13 @@ describe('New vulnerability component', () => { ...@@ -103,6 +107,13 @@ describe('New vulnerability component', () => {
it('contains a submit button', () => { it('contains a submit button', () => {
expect(findSubmitButton().exists()).toBe(true); expect(findSubmitButton().exists()).toBe(true);
}); });
it('contains a cancel button', () => {
expect(findCancelButton().attributes()).toMatchObject({
href: vulnerabilityReportPath,
type: 'button',
});
});
}); });
describe('form submission', () => { describe('form submission', () => {
......
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