Link to on-demand scan's security tab

This changes the on-demand scans' "View results" link's href
to point to the pipeline's security tab.
parent c85ac152
...@@ -3,6 +3,7 @@ import { GlButton } from '@gitlab/ui'; ...@@ -3,6 +3,7 @@ import { GlButton } from '@gitlab/ui';
import pipelineCancelMutation from '~/pipelines/graphql/mutations/cancel_pipeline.mutation.graphql'; import pipelineCancelMutation from '~/pipelines/graphql/mutations/cancel_pipeline.mutation.graphql';
import pipelineRetryMutation from '~/pipelines/graphql/mutations/retry_pipeline.mutation.graphql'; import pipelineRetryMutation from '~/pipelines/graphql/mutations/retry_pipeline.mutation.graphql';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
import { getSecurityTabPath } from 'ee/vue_shared/security_reports/utils';
import { import {
PIPELINES_GROUP_RUNNING, PIPELINES_GROUP_RUNNING,
PIPELINES_GROUP_PENDING, PIPELINES_GROUP_PENDING,
...@@ -52,6 +53,9 @@ export default { ...@@ -52,6 +53,9 @@ export default {
hasResults() { hasResults() {
return this.isRetryable || this.scan?.detailedStatus?.group === PIPELINES_GROUP_SUCCESS; return this.isRetryable || this.scan?.detailedStatus?.group === PIPELINES_GROUP_SUCCESS;
}, },
viewResultsPath() {
return this.hasResults ? getSecurityTabPath(this.scan.path) : '';
},
}, },
watch: { watch: {
'scan.detailedStatus.group': function detailedStatusGroupWatcher() { 'scan.detailedStatus.group': function detailedStatusGroupWatcher() {
...@@ -119,7 +123,7 @@ export default { ...@@ -119,7 +123,7 @@ export default {
v-if="hasResults" v-if="hasResults"
data-testid="view-scan-results-button" data-testid="view-scan-results-button"
size="small" size="small"
:href="scan.path" :href="viewResultsPath"
> >
{{ $options.i18n.viewResults }} {{ $options.i18n.viewResults }}
</gl-button> </gl-button>
......
...@@ -40,6 +40,7 @@ import { ...@@ -40,6 +40,7 @@ import {
MODULE_SECRET_DETECTION, MODULE_SECRET_DETECTION,
trackMrSecurityReportDetails, trackMrSecurityReportDetails,
} from './store/constants'; } from './store/constants';
import { getSecurityTabPath } from './utils';
export default { export default {
store: createStore(), store: createStore(),
...@@ -300,7 +301,7 @@ export default { ...@@ -300,7 +301,7 @@ export default {
]), ]),
...mapGetters(MODULE_API_FUZZING, ['groupedApiFuzzingText', 'apiFuzzingStatusIcon']), ...mapGetters(MODULE_API_FUZZING, ['groupedApiFuzzingText', 'apiFuzzingStatusIcon']),
securityTab() { securityTab() {
return `${this.pipelinePath}/security`; return getSecurityTabPath(this.pipelinePath);
}, },
hasContainerScanningReports() { hasContainerScanningReports() {
return this.enabledReports.containerScanning; return this.enabledReports.containerScanning;
......
export const getSecurityTabPath = (pipelinePath = '') => `${pipelinePath}/security`;
...@@ -167,6 +167,6 @@ describe('Actions', () => { ...@@ -167,6 +167,6 @@ describe('Actions', () => {
const viewScanResultsButton = findViewScanResultsButton(); const viewScanResultsButton = findViewScanResultsButton();
expect(viewScanResultsButton.exists()).toBe(true); expect(viewScanResultsButton.exists()).toBe(true);
expect(viewScanResultsButton.attributes('href')).toBe(scan.path); expect(viewScanResultsButton.attributes('href')).toBe(`${scan.path}/security`);
}); });
}); });
import * as utils from 'ee/vue_shared/security_reports/utils';
describe('utils', () => {
describe('getSecurityTabPath', () => {
it.each([
[undefined, '/security'],
['', '/security'],
['/foo/bar', '/foo/bar/security'],
])("when input is %p, returns '%s'", (input, expected) => {
expect(utils.getSecurityTabPath(input)).toBe(expected);
});
});
});
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