|
3 | 3 | import React, { useMemo } from 'react'; |
4 | 4 | import { useLocation } from 'react-router-dom'; |
5 | 5 | import type { SideNavigationProps } from '@cloudscape-design/components'; |
6 | | -import { SideNavigation } from '@cloudscape-design/components'; |
| 6 | +import { Badge, Popover, SideNavigation } from '@cloudscape-design/components'; |
7 | 7 | import useSettingsContext from '../../contexts/settings'; |
8 | 8 | import useUserRole from '../../hooks/use-user-role'; |
9 | 9 |
|
@@ -152,7 +152,8 @@ export const reviewerNavItems = [{ type: 'link', text: 'Document List', href: `# |
152 | 152 | export const documentsNavItems = adminNavItems; |
153 | 153 |
|
154 | 154 | 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') { |
156 | 157 | ev.preventDefault(); |
157 | 158 | return; |
158 | 159 | } |
@@ -207,33 +208,44 @@ const Navigation = ({ |
207 | 208 | const deployedRegion = import.meta.env.VITE_AWS_REGION as string | undefined; |
208 | 209 | const isCustomModelsSupported = deployedRegion === 'us-east-1'; |
209 | 210 |
|
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 | | - |
216 | 211 | // Build list of items to hide from the Configuration section |
217 | 212 | const hiddenConfigItems = new Set<string>(); |
218 | 213 | if (!isCapacityPlanningSupported) { |
219 | 214 | hiddenConfigItems.add('Capacity Planning'); |
220 | 215 | } |
221 | | - if (!isCustomModelsSupported) { |
222 | | - hiddenConfigItems.add('Custom Models'); |
223 | | - } |
224 | | - |
225 | | - if (hiddenConfigItems.size === 0) { |
226 | | - return baseItems; |
227 | | - } |
228 | 216 |
|
229 | | - // Filter out hidden items from Configuration section and top-level |
| 217 | + // Transform navigation items: hide unsupported items, grey out region-restricted items |
230 | 218 | return baseItems |
231 | 219 | .map((item) => { |
232 | 220 | if (item.type === 'section' && item.text === 'Configuration') { |
233 | 221 | const section = item as SideNavigationProps.Section; |
234 | 222 | return { |
235 | 223 | ...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 | + }), |
237 | 249 | }; |
238 | 250 | } |
239 | 251 | return item; |
|
0 commit comments