Skip to content

Commit 1454826

Browse files
committed
refactor(ui): enhance navigation with badges and popovers for unsupported features
1 parent cf29505 commit 1454826

1 file changed

Lines changed: 29 additions & 17 deletions

File tree

src/ui/src/components/genaiidp-layout/navigation.tsx

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import React, { useMemo } from 'react';
44
import { useLocation } from 'react-router-dom';
55
import type { SideNavigationProps } from '@cloudscape-design/components';
6-
import { SideNavigation } from '@cloudscape-design/components';
6+
import { Badge, Popover, SideNavigation } from '@cloudscape-design/components';
77
import useSettingsContext from '../../contexts/settings';
88
import useUserRole from '../../hooks/use-user-role';
99

@@ -152,7 +152,8 @@ export const reviewerNavItems = [{ type: 'link', text: 'Document List', href: `#
152152
export const documentsNavItems = adminNavItems;
153153

154154
const defaultOnFollowHandler = (ev: CustomEvent<SideNavigationProps.FollowDetail>): void => {
155-
if (ev.detail.href === '#deployment-info') {
155+
// Prevent navigation for non-navigable items (deployment info, region-restricted features)
156+
if (ev.detail.href === '#deployment-info' || ev.detail.href === '#custom-models-unavailable') {
156157
ev.preventDefault();
157158
return;
158159
}
@@ -207,33 +208,44 @@ const Navigation = ({
207208
const deployedRegion = import.meta.env.VITE_AWS_REGION as string | undefined;
208209
const isCustomModelsSupported = deployedRegion === 'us-east-1';
209210

210-
// Debug logging (remove after testing)
211-
if (pattern) {
212-
console.log('[Navigation] IDPPattern detected:', settings.IDPPattern, '| Capacity Planning supported:', isCapacityPlanningSupported);
213-
}
214-
console.log('[Navigation] Region:', deployedRegion, '| Custom Models supported:', isCustomModelsSupported);
215-
216211
// Build list of items to hide from the Configuration section
217212
const hiddenConfigItems = new Set<string>();
218213
if (!isCapacityPlanningSupported) {
219214
hiddenConfigItems.add('Capacity Planning');
220215
}
221-
if (!isCustomModelsSupported) {
222-
hiddenConfigItems.add('Custom Models');
223-
}
224-
225-
if (hiddenConfigItems.size === 0) {
226-
return baseItems;
227-
}
228216

229-
// Filter out hidden items from Configuration section and top-level
217+
// Transform navigation items: hide unsupported items, grey out region-restricted items
230218
return baseItems
231219
.map((item) => {
232220
if (item.type === 'section' && item.text === 'Configuration') {
233221
const section = item as SideNavigationProps.Section;
234222
return {
235223
...item,
236-
items: section.items.filter((subItem) => !hiddenConfigItems.has((subItem as { text?: string }).text ?? '')),
224+
items: section.items
225+
.filter((subItem) => !hiddenConfigItems.has((subItem as { text?: string }).text ?? ''))
226+
.map((subItem) => {
227+
const link = subItem as SideNavigationProps.Link;
228+
// Grey out Custom Models with region badge when not in us-east-1
229+
if (link.text === 'Custom Models' && !isCustomModelsSupported) {
230+
return {
231+
...link,
232+
href: '#custom-models-unavailable',
233+
info: React.createElement(
234+
Popover,
235+
{
236+
dismissButton: false,
237+
position: 'right',
238+
size: 'medium',
239+
triggerType: 'custom',
240+
content:
241+
'Custom Models requires Amazon Nova fine-tuning, which is currently available in us-east-1 only. Deploy your stack in us-east-1 to use this feature.',
242+
},
243+
React.createElement(Badge, { color: 'grey' }, 'us-east-1 only'),
244+
),
245+
};
246+
}
247+
return subItem;
248+
}),
237249
};
238250
}
239251
return item;

0 commit comments

Comments
 (0)