Commit ed624def authored by Phil Hughes's avatar Phil Hughes

Merge branch '341380-dast-view-scans-view-results-path' into 'master'

Link to on-demand scan's security tab

See merge request gitlab-org/gitlab!76730
parents 00437641 152f76c0
......@@ -3,6 +3,7 @@ import { GlButton } from '@gitlab/ui';
import pipelineCancelMutation from '~/pipelines/graphql/mutations/cancel_pipeline.mutation.graphql';
import pipelineRetryMutation from '~/pipelines/graphql/mutations/retry_pipeline.mutation.graphql';
import { __, s__ } from '~/locale';
import { getSecurityTabPath } from 'ee/vue_shared/security_reports/utils';
import {
PIPELINES_GROUP_RUNNING,
PIPELINES_GROUP_PENDING,
......@@ -52,6 +53,9 @@ export default {
hasResults() {
return this.isRetryable || this.scan?.detailedStatus?.group === PIPELINES_GROUP_SUCCESS;
},
viewResultsPath() {
return this.hasResults ? getSecurityTabPath(this.scan.path) : '';
},
},
watch: {
'scan.detailedStatus.group': function detailedStatusGroupWatcher() {
......@@ -119,7 +123,7 @@ export default {
v-if="hasResults"
data-testid="view-scan-results-button"
size="small"
:href="scan.path"
:href="viewResultsPath"
>
{{ $options.i18n.viewResults }}
</gl-button>
......
......@@ -40,6 +40,7 @@ import {
MODULE_SECRET_DETECTION,
trackMrSecurityReportDetails,
} from './store/constants';
import { getSecurityTabPath } from './utils';
export default {
store: createStore(),
......@@ -300,7 +301,7 @@ export default {
]),
...mapGetters(MODULE_API_FUZZING, ['groupedApiFuzzingText', 'apiFuzzingStatusIcon']),
securityTab() {
return `${this.pipelinePath}/security`;
return getSecurityTabPath(this.pipelinePath);
},
hasContainerScanningReports() {
return this.enabledReports.containerScanning;
......
export const getSecurityTabPath = (pipelinePath = '') => `${pipelinePath}/security`;
......@@ -167,6 +167,6 @@ describe('Actions', () => {
const viewScanResultsButton = findViewScanResultsButton();
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