Commit 89497d78 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '217530-remove-unused-code' into 'master'

Remove unused refetch vulnerabilities code

See merge request gitlab-org/gitlab!42959
parents 2df79b4a 1b4d8322
...@@ -112,9 +112,6 @@ export default { ...@@ -112,9 +112,6 @@ export default {
}); });
} }
}, },
refetchVulnerabilities() {
this.$apollo.queries.vulnerabilities.refetch();
},
handleSortChange({ sortBy, sortDesc }) { handleSortChange({ sortBy, sortDesc }) {
this.sortDirection = sortDesc ? 'desc' : 'asc'; this.sortDirection = sortDesc ? 'desc' : 'asc';
this.sortBy = sortBy; this.sortBy = sortBy;
...@@ -144,7 +141,6 @@ export default { ...@@ -144,7 +141,6 @@ export default {
:filters="filters" :filters="filters"
:vulnerabilities="vulnerabilities" :vulnerabilities="vulnerabilities"
:security-scanners="securityScanners" :security-scanners="securityScanners"
@refetch-vulnerabilities="refetchVulnerabilities"
@sort-changed="handleSortChange" @sort-changed="handleSortChange"
/> />
<gl-intersection-observer <gl-intersection-observer
......
...@@ -3,7 +3,7 @@ import { GlButton, GlFormSelect } from '@gitlab/ui'; ...@@ -3,7 +3,7 @@ import { GlButton, GlFormSelect } from '@gitlab/ui';
import { s__, n__ } from '~/locale'; import { s__, n__ } from '~/locale';
import toast from '~/vue_shared/plugins/global_toast'; import toast from '~/vue_shared/plugins/global_toast';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import { deprecatedCreateFlash as createFlash } from '~/flash';
import dismissVulnerability from '../graphql/dismissVulnerability.graphql'; import vulnerabilityDismiss from '../graphql/vulnerability_dismiss.mutation.graphql';
const REASON_NONE = s__('SecurityReports|[No reason]'); const REASON_NONE = s__('SecurityReports|[No reason]');
const REASON_WONT_FIX = s__("SecurityReports|Won't fix / Accept risk"); const REASON_WONT_FIX = s__("SecurityReports|Won't fix / Accept risk");
...@@ -42,13 +42,6 @@ export default { ...@@ -42,13 +42,6 @@ export default {
}, },
}, },
methods: { methods: {
dismissalSuccessMessage() {
return n__(
'%d vulnerability dismissed',
'%d vulnerabilities dismissed',
this.selectedVulnerabilities.length,
);
},
handleDismiss() { handleDismiss() {
if (!this.canDismissVulnerability) return; if (!this.canDismissVulnerability) return;
...@@ -57,14 +50,21 @@ export default { ...@@ -57,14 +50,21 @@ export default {
dismissSelectedVulnerabilities() { dismissSelectedVulnerabilities() {
const promises = this.selectedVulnerabilities.map(vulnerability => const promises = this.selectedVulnerabilities.map(vulnerability =>
this.$apollo.mutate({ this.$apollo.mutate({
mutation: dismissVulnerability, mutation: vulnerabilityDismiss,
variables: { id: vulnerability.id, comment: this.dismissalReason }, variables: { id: vulnerability.id, comment: this.dismissalReason },
}), }),
); );
Promise.all(promises) Promise.all(promises)
.then(() => { .then(() => {
toast(this.dismissalSuccessMessage()); toast(
n__(
'%d vulnerability dismissed',
'%d vulnerabilities dismissed',
this.selectedVulnerabilities.length,
),
);
this.$emit('deselect-all-vulnerabilities'); this.$emit('deselect-all-vulnerabilities');
}) })
.catch(() => { .catch(() => {
...@@ -72,9 +72,6 @@ export default { ...@@ -72,9 +72,6 @@ export default {
s__('SecurityReports|There was an error dismissing the vulnerabilities.'), s__('SecurityReports|There was an error dismissing the vulnerabilities.'),
'alert', 'alert',
); );
})
.finally(() => {
this.$emit('refetch-vulnerabilities');
}); });
}, },
}, },
......
...@@ -296,7 +296,6 @@ export default { ...@@ -296,7 +296,6 @@ export default {
v-if="shouldShowSelectionSummary" v-if="shouldShowSelectionSummary"
:selected-vulnerabilities="Object.values(selectedVulnerabilities)" :selected-vulnerabilities="Object.values(selectedVulnerabilities)"
@deselect-all-vulnerabilities="deselectAllVulnerabilities" @deselect-all-vulnerabilities="deselectAllVulnerabilities"
@refetch-vulnerabilities="$emit('refetch-vulnerabilities')"
/> />
<gl-table <gl-table
:busy="isLoading" :busy="isLoading"
......
mutation($id: ID!, $comment: String!) { mutation($id: ID!, $comment: String!) {
dismissVulnerability(input: { id: $id, comment: $comment }) { vulnerabilityDismiss(input: { id: $id, comment: $comment }) {
errors errors
vulnerability { vulnerability {
id id
......
...@@ -124,22 +124,6 @@ describe('Selection Summary component', () => { ...@@ -124,22 +124,6 @@ describe('Selection Summary component', () => {
); );
}); });
}); });
it('should emit an event to refetch the vulnerabilities when the request is successful', () => {
dismissButton().trigger('submit');
return waitForPromises().then(() => {
expect(wrapper.emitted('deselect-all-vulnerabilities')).toEqual([[]]);
expect(wrapper.emitted('refetch-vulnerabilities')).toEqual([[]]);
});
});
it('should still emit an event to refetch the vulnerabilities when the request fails', () => {
mutateMock.mockRejectedValue();
dismissButton().trigger('submit');
return waitForPromises().then(() => {
expect(wrapper.emitted('refetch-vulnerabilities')).toEqual([[]]);
});
});
}); });
describe('when vulnerabilities are not selected', () => { describe('when vulnerabilities are not selected', () => {
......
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