Skip to content

Commit d1afff7

Browse files
carddev81PThorpe92
authored andcommitted
fix: move links on menu per #611 and modify logic for correctly dispaying menu links per #647
1 parent e71324f commit d1afff7

File tree

2 files changed

+38
-39
lines changed

2 files changed

+38
-39
lines changed

frontend/src/Components/Navbar.tsx

+27-32
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
CloudIcon,
1616
RssIcon,
1717
RectangleStackIcon,
18-
CogIcon
18+
CogIcon,
19+
LightBulbIcon
1920
} from '@heroicons/react/24/solid';
2021
import {
2122
getDashboardLink,
@@ -50,11 +51,6 @@ export default function Navbar({
5051
const { toaster } = useToast();
5152
const confirmSeedModal = useRef<HTMLDialogElement | null>(null);
5253
const [seedInProgress, setSeedInProgress] = useState<boolean>(false);
53-
const dashboardTitleAdmin = new Map([
54-
['/learning-insights', 'Learning'],
55-
['/knowledge-insights', 'Knowledge'],
56-
['/operational-insights', 'Operational']
57-
]);
5854
const dashboardTitleStudent = new Map([
5955
['/trending-content', 'Trending Content'],
6056
['/learning-path', 'Learning Path'],
@@ -109,42 +105,41 @@ export default function Navbar({
109105

110106
<div className="h-full">
111107
<ul className="menu h-full flex flex-col justify-between">
112-
<div>
108+
<div className="mt-16">
113109
{/* admin view */}
114110
{user && isAdministrator(user) ? (
115111
<>
116-
<li className="mt-16">
117-
<Link to={getDashboardLink(user)}>
118-
<ULIComponent icon={HomeIcon} />
119-
{dashboardTitleAdmin.get(
120-
getDashboardLink(user)
121-
) ?? 'Operational'}{' '}
122-
Insights
123-
</Link>
124-
</li>
125112
{hasFeature(
126113
user,
127114
FeatureAccess.OpenContentAccess
128-
) &&
129-
user.feature_access.length > 1 && (
130-
<li>
131-
<Link to="/knowledge-insights">
132-
<ULIComponent
133-
icon={BookOpenIcon}
134-
/>
135-
Knowledge Insights
136-
</Link>
137-
</li>
138-
)}
139-
{/* this acts as the dashboard in the case there are no features enabled */}
140-
{user.feature_access.length > 0 && (
115+
) && (
141116
<li>
142-
<Link to="/operational-insights">
143-
<ULIComponent icon={CogIcon} />
144-
Operational Insights
117+
<Link to="/knowledge-insights">
118+
<ULIComponent icon={BookOpenIcon} />
119+
Knowledge Insights
145120
</Link>
146121
</li>
147122
)}
123+
{hasFeature(
124+
user,
125+
FeatureAccess.ProviderAccess
126+
) && (
127+
<li>
128+
<Link to="/learning-insights">
129+
<ULIComponent
130+
icon={LightBulbIcon}
131+
/>
132+
Learning Insights
133+
</Link>
134+
</li>
135+
)}
136+
{/* this acts as the dashboard in the case there are no features enabled */}
137+
<li>
138+
<Link to="/operational-insights">
139+
<ULIComponent icon={CogIcon} />
140+
Operational Insights
141+
</Link>
142+
</li>
148143
{hasFeature(
149144
user,
150145
FeatureAccess.ProviderAccess

frontend/src/useAuth.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,6 @@ const accessValues = new Map<FeatureAccess, number>([
158158
[FeatureAccess.ProviderAccess, 2],
159159
[FeatureAccess.ProgramAccess, 3]
160160
]);
161-
const adminAccessLinks = [
162-
'/operational-insights', // temporary layer 0 until implemented
163-
'/knowledge-insights',
164-
'/learning-insights',
165-
'/learning-insights' // temporary until layer 3 is implemented
166-
];
167161

168162
export const studentAccessLinks = [
169163
'/home', // temporary layer 0 until implemented
@@ -181,6 +175,16 @@ export const getDashboardLink = (user?: User) => {
181175
.sort((a, b) => a - b)
182176
.pop() ?? 0;
183177
return isAdministrator(user)
184-
? adminAccessLinks[maxFeature]
178+
? getAdminLink(user)
185179
: studentAccessLinks[maxFeature];
186180
};
181+
182+
const getAdminLink = (user: User): string => {
183+
if (user.feature_access.includes(FeatureAccess.OpenContentAccess)) {
184+
return "/knowledge-insights";
185+
}
186+
if (user.feature_access.includes(FeatureAccess.ProviderAccess)) {
187+
return "/learning-insights";
188+
}
189+
return "/operational-insights";
190+
};

0 commit comments

Comments
 (0)