@orsetra/shared-ui 1.10.8 → 1.10.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -324,12 +324,11 @@ function Sidebar({ currentMenu, sidebarMenus = {}, main_base_url = "", sectionLa
|
|
|
324
324
|
? item.id === activeItemId
|
|
325
325
|
: (pathname === itemPath || pathname.startsWith(`${itemPath}/`))
|
|
326
326
|
|
|
327
|
-
// Resolved
|
|
328
|
-
//
|
|
329
|
-
|
|
330
|
-
const
|
|
331
|
-
const
|
|
332
|
-
const resolvedHref = templateResolution ? templateResolution.href : item.href
|
|
327
|
+
// Resolved unconditionally so middle-click/right-click (which bypass onClick) never
|
|
328
|
+
// navigate to a literal "${envAlias}"-style unresolved URL.
|
|
329
|
+
const templateResolution = resolveTemplateVars(item.href)
|
|
330
|
+
const isDisabled = !templateResolution.isResolved
|
|
331
|
+
const resolvedHref = templateResolution.href
|
|
333
332
|
|
|
334
333
|
const handleClick = (e: React.MouseEvent) => {
|
|
335
334
|
if (isDisabled) {
|
|
@@ -383,8 +382,10 @@ function Sidebar({ currentMenu, sidebarMenus = {}, main_base_url = "", sectionLa
|
|
|
383
382
|
) : (
|
|
384
383
|
<Link
|
|
385
384
|
key={item.id}
|
|
386
|
-
href={
|
|
385
|
+
href={isDisabled ? "#" : resolvedHref}
|
|
387
386
|
onClick={handleClick}
|
|
387
|
+
aria-disabled={isDisabled}
|
|
388
|
+
title={isDisabled ? "Select a project/environment first" : undefined}
|
|
388
389
|
className={linkCls}
|
|
389
390
|
>
|
|
390
391
|
{linkContent}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { Lock } from "lucide-react"
|
|
3
|
+
import { cn } from "../../lib/utils"
|
|
4
|
+
|
|
5
|
+
export interface AccessDeniedStateProps {
|
|
6
|
+
resourceName: string
|
|
7
|
+
message?: string
|
|
8
|
+
className?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function AccessDeniedState({ resourceName, message, className }: AccessDeniedStateProps) {
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
className={cn(
|
|
15
|
+
"flex flex-col md:flex-row items-center justify-center gap-8 md:gap-12 p-6 md:p-12 min-h-[450px] bg-white text-center md:text-left",
|
|
16
|
+
className
|
|
17
|
+
)}
|
|
18
|
+
>
|
|
19
|
+
<div className="flex-shrink-0 h-40 w-40 bg-red-50 flex items-center justify-center">
|
|
20
|
+
<Lock className="h-20 w-20 text-red-200" />
|
|
21
|
+
</div>
|
|
22
|
+
<div className="max-w-md">
|
|
23
|
+
<h2 className="text-xl md:text-2xl font-semibold text-ibm-gray-100 mb-3 text-center md:text-left">
|
|
24
|
+
Access denied
|
|
25
|
+
</h2>
|
|
26
|
+
<p className="text-ibm-gray-60 text-sm md:text-base leading-relaxed text-center md:text-left">
|
|
27
|
+
{message ?? `You don't have permission to view ${resourceName} in this business unit.`}
|
|
28
|
+
</p>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
}
|
package/components/ui/index.ts
CHANGED
|
@@ -24,6 +24,7 @@ export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from './
|
|
|
24
24
|
export { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel } from './alert-dialog'
|
|
25
25
|
export { Alert, AlertTitle, AlertDescription } from './alert'
|
|
26
26
|
export { AlertBanner, useAlertBanner, type AlertBannerProps, type AlertState } from './alert-banner'
|
|
27
|
+
export { AccessDeniedState, type AccessDeniedStateProps } from './access-denied-state'
|
|
27
28
|
export { ConfirmationDialog, type ConfirmationDialogProps } from './confirmation-dialog'
|
|
28
29
|
export { AspectRatio } from './aspect-ratio'
|
|
29
30
|
export { Badge } from './badge'
|