Skip to content

Commit

Permalink
Alias account tab hash anchors
Browse files Browse the repository at this point in the history
  • Loading branch information
jacbn committed Oct 21, 2024
1 parent 65b4ee2 commit c0e2c67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/app/components/pages/MyAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ import {
validatePassword,
isTeacherOrAbove,
isFirstLoginInPersistence,
ACCOUNT_TABS
ACCOUNT_TABS,
ACCOUNT_TABS_ALIASES
} from "../../services";
import queryString from "query-string";
import {Link, withRouter} from "react-router-dom";
Expand Down Expand Up @@ -225,9 +226,8 @@ const AccountPageComponent = ({user, getChosenUserAuthSettings, error, userAuthS
// @ts-ignore
const tab: ACCOUNT_TAB =
(authToken && ACCOUNT_TAB.teacherconnections) ||
// This feel particularly bad
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(hashAnchor && ACCOUNT_TAB[hashAnchor as any]) ||
(hashAnchor && hashAnchor in ACCOUNT_TAB && ACCOUNT_TAB[hashAnchor as keyof typeof ACCOUNT_TAB]) ||
(hashAnchor && hashAnchor in ACCOUNT_TABS_ALIASES && ACCOUNT_TABS_ALIASES[hashAnchor as string]) ||
ACCOUNT_TAB.account;
setActiveTab(tab);
}, [hashAnchor, authToken]);
Expand Down
7 changes: 7 additions & 0 deletions src/app/services/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,13 @@ export const ACCOUNT_TABS : AccountTabs[] = [
{tab: ACCOUNT_TAB.betafeatures, title: "Beta", hiddenIfEditingOtherUser: true},
];

// we can't change the names of tabs as we have historic links to them, so use aliases to use updated names instead
export const ACCOUNT_TABS_ALIASES: {[alias: string]: ACCOUNT_TAB} = {
"security": ACCOUNT_TAB.passwordreset,
"connections": ACCOUNT_TAB.teacherconnections,
"notifications": ACCOUNT_TAB.emailpreferences,
};

export enum MANAGE_QUIZ_TAB {set = 1, manage = 2}
export enum MARKBOOK_TYPE_TAB {assignments = 1, tests = 2}

Expand Down

0 comments on commit c0e2c67

Please sign in to comment.