diff --git a/src/components/Profile/History/index.tsx b/src/components/Profile/History/index.tsx index 56d29c30c..2cb8bd869 100644 --- a/src/components/Profile/History/index.tsx +++ b/src/components/Profile/History/index.tsx @@ -51,6 +51,12 @@ function getTabs( return defaultTabs } +const tabsIndexList = { + published: 0, + downloads: 1, + computeJobs: 2 +} + export default function HistoryPage({ accountIdentifier }: { @@ -106,17 +112,16 @@ export default function HistoryPage({ const getDefaultIndex = useCallback((): number => { const url = new URL(location.href) const defaultTabString = url.searchParams.get('defaultTab') - const defaultTabIndex = /^\d+$/.test(defaultTabString) - ? parseInt(defaultTabString) - : 0 - - // we need to make sure the default index is not bigger than the highest - // tab index available otherwise the Tabs component will display no content - if (accountId === accountIdentifier) { - return defaultTabIndex > 2 ? 2 : defaultTabIndex - } + const defaultTabIndex = tabsIndexList?.[defaultTabString] + + if (!defaultTabIndex) return 0 + if ( + defaultTabIndex === tabsIndexList.computeJobs && + accountId !== accountIdentifier + ) + return 0 - return defaultTabIndex > 1 ? 1 : defaultTabIndex + return defaultTabIndex }, [accountId, accountIdentifier]) useEffect(() => {