Commit 6d1c1a57 authored by Dheeraj Joshi's avatar Dheeraj Joshi Committed by Martin Wortschack

Update tab anchor link for Saved Scans

parent 62a3697e
<script> <script>
import { GlDropdown, GlDropdownItem, GlTab, GlTabs } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem, GlTab, GlTabs } from '@gitlab/ui';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { camelCase, kebabCase } from 'lodash';
import { getLocationHash } from '~/lib/utils/url_utility'; import { getLocationHash } from '~/lib/utils/url_utility';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
...@@ -45,17 +44,17 @@ export default { ...@@ -45,17 +44,17 @@ export default {
}, },
tabIndex: { tabIndex: {
get() { get() {
const activeTabIndex = Object.keys(this.profileSettings).indexOf( const activeTabIndex = Object.values(this.profileSettings).findIndex(
camelCase(getLocationHash()), ({ tabName }) => tabName === getLocationHash(),
); );
return Math.max(0, activeTabIndex); return Math.max(0, activeTabIndex);
}, },
set(newTabIndex) { set(newTabIndex) {
const profileTypeName = Object.keys(this.profileSettings)[newTabIndex]; const { tabName } = Object.values(this.profileSettings)[newTabIndex];
if (profileTypeName) { if (tabName) {
window.location.hash = kebabCase(profileTypeName); window.location.hash = tabName;
} }
}, },
}, },
......
...@@ -13,6 +13,7 @@ import { s__ } from '~/locale'; ...@@ -13,6 +13,7 @@ import { s__ } from '~/locale';
export const getProfileSettings = ({ createNewProfilePaths }) => ({ export const getProfileSettings = ({ createNewProfilePaths }) => ({
dastProfiles: { dastProfiles: {
profileType: 'dastProfiles', profileType: 'dastProfiles',
tabName: 'saved-scans',
createNewProfilePath: createNewProfilePaths.savedScan, createNewProfilePath: createNewProfilePaths.savedScan,
graphQL: { graphQL: {
query: dastProfilesQuery, query: dastProfilesQuery,
...@@ -56,6 +57,7 @@ export const getProfileSettings = ({ createNewProfilePaths }) => ({ ...@@ -56,6 +57,7 @@ export const getProfileSettings = ({ createNewProfilePaths }) => ({
}, },
siteProfiles: { siteProfiles: {
profileType: 'siteProfiles', profileType: 'siteProfiles',
tabName: 'site-profiles',
createNewProfilePath: createNewProfilePaths.siteProfile, createNewProfilePath: createNewProfilePaths.siteProfile,
graphQL: { graphQL: {
query: dastSiteProfilesQuery, query: dastSiteProfilesQuery,
...@@ -90,6 +92,7 @@ export const getProfileSettings = ({ createNewProfilePaths }) => ({ ...@@ -90,6 +92,7 @@ export const getProfileSettings = ({ createNewProfilePaths }) => ({
}, },
scannerProfiles: { scannerProfiles: {
profileType: 'scannerProfiles', profileType: 'scannerProfiles',
tabName: 'scanner-profiles',
createNewProfilePath: createNewProfilePaths.scannerProfile, createNewProfilePath: createNewProfilePaths.scannerProfile,
graphQL: { graphQL: {
query: dastScannerProfilesQuery, query: dastScannerProfilesQuery,
......
---
title: Update tab links for DAST Saved Scans
merge_request: 57205
author:
type: changed
...@@ -148,7 +148,7 @@ describe('EE - DastProfiles', () => { ...@@ -148,7 +148,7 @@ describe('EE - DastProfiles', () => {
describe.each` describe.each`
tabName | index | givenLocationHash tabName | index | givenLocationHash
${'Saved Scans'} | ${0} | ${'dast-profiles'} ${'Saved Scans'} | ${0} | ${'saved-scans'}
${'Site Profiles'} | ${1} | ${'site-profiles'} ${'Site Profiles'} | ${1} | ${'site-profiles'}
${'Scanner Profiles'} | ${2} | ${'scanner-profiles'} ${'Scanner Profiles'} | ${2} | ${'scanner-profiles'}
`('with location hash set to "$givenLocationHash"', ({ tabName, index, givenLocationHash }) => { `('with location hash set to "$givenLocationHash"', ({ tabName, index, givenLocationHash }) => {
......
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