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

Update tab anchor link for Saved Scans

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