@orsetra/shared-ui 1.10.33 → 1.11.0

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.
@@ -0,0 +1,49 @@
1
+ "use client"
2
+
3
+ import type { ReactNode } from "react"
4
+ import { useEnvironmentContext } from "../../context/environment-context"
5
+ import { environmentGateView, environmentLabel } from "../../lib/environment-context"
6
+ import { AlertBanner } from "../ui/alert-banner"
7
+ import { EnvironmentRequired } from "../ui/environment-required"
8
+
9
+ export interface EnvironmentGateProps {
10
+ children: ReactNode
11
+ required?: boolean
12
+ createHref?: string
13
+ }
14
+
15
+ export function EnvironmentGate({ children, required = true, createHref }: EnvironmentGateProps) {
16
+ const { status, current, lost, dismissLost } = useEnvironmentContext()
17
+ const view = environmentGateView(status, required)
18
+
19
+ if (view === "waiting") {
20
+ return (
21
+ <div className="p-4 space-y-3" aria-busy="true">
22
+ <div className="h-9 w-64 bg-ibm-gray-20 animate-pulse" />
23
+ <div className="h-24 bg-white border border-ui-border animate-pulse" />
24
+ <div className="h-24 bg-white border border-ui-border animate-pulse" />
25
+ </div>
26
+ )
27
+ }
28
+
29
+ if (view === "required") {
30
+ return (
31
+ <div className="p-4">
32
+ <EnvironmentRequired createHref={createHref} />
33
+ </div>
34
+ )
35
+ }
36
+
37
+ return (
38
+ <>
39
+ {lost && current && (
40
+ <AlertBanner
41
+ variant="warning"
42
+ message={`The environment ${lost} no longer exists. You are now working in ${environmentLabel(current)}.`}
43
+ onClose={dismissLost}
44
+ />
45
+ )}
46
+ {children}
47
+ </>
48
+ )
49
+ }
@@ -0,0 +1,52 @@
1
+ "use client"
2
+
3
+ import { useCallback, useState } from "react"
4
+ import { ChevronDown } from "lucide-react"
5
+ import { useEnvironmentContext } from "../../context/environment-context"
6
+ import { environmentButtonLabel, showsEnvironmentSwitcher } from "../../lib/environment-context"
7
+ import { EnvironmentPickerDialog } from "../ui/environment-picker-dialog"
8
+
9
+ export interface EnvironmentSwitcherProps {
10
+ createHref?: string
11
+ }
12
+
13
+ export function EnvironmentSwitcher({ createHref }: EnvironmentSwitcherProps) {
14
+ const { status, projectId, current, select, reload } = useEnvironmentContext()
15
+ const [open, setOpen] = useState(false)
16
+
17
+ const fetchEnvironments = useCallback(async () => ({ envs: await reload() }), [reload])
18
+
19
+ if (!showsEnvironmentSwitcher(status)) return null
20
+
21
+ const label = environmentButtonLabel(status, current)
22
+
23
+ return (
24
+ <>
25
+ <button
26
+ type="button"
27
+ onClick={() => setOpen(true)}
28
+ disabled={status === "loading"}
29
+ title="Change environment"
30
+ aria-haspopup="dialog"
31
+ className="h-8 max-w-[46vw] md:max-w-xs flex items-center gap-1.5 px-2.5 bg-gray-200/70 text-gray-600 hover:bg-gray-200 hover:text-gray-900 transition-colors disabled:cursor-default"
32
+ >
33
+ {label ? (
34
+ <span className="truncate text-xs font-medium uppercase tracking-wider">{label}</span>
35
+ ) : (
36
+ <span className="h-2.5 w-20 bg-gray-300 animate-pulse" aria-label="Loading environments" />
37
+ )}
38
+ <ChevronDown className="h-3.5 w-3.5 flex-shrink-0 text-gray-500" />
39
+ </button>
40
+
41
+ <EnvironmentPickerDialog
42
+ open={open}
43
+ onOpenChange={setOpen}
44
+ projectName={projectId}
45
+ fetchEnvironments={fetchEnvironments}
46
+ onSelect={select}
47
+ currentEnv={current?.name}
48
+ createHref={createHref}
49
+ />
50
+ </>
51
+ )
52
+ }
@@ -1,36 +1,38 @@
1
- // Layout components exports
2
- export { MainSidebar, type SidebarMode } from './sidebar/main-sidebar'
3
- export { resolveIcon, type MainMenuItem, type SubMenuItem, type SidebarMenus, type SidebarMenuMeta, type MenuApiResponse, type ApiMenuData, type ApiMainMenuItem, type ApiSubMenuItem, type ApiSubMenu, type OrgInfo, type Project } from './sidebar/data'
4
- export { QuickAccessTracker } from './sidebar/quick-access-tracker'
5
- export {
6
- Sidebar,
7
- SidebarContent,
8
- SidebarFooter,
9
- SidebarGroup,
10
- SidebarGroupAction,
11
- SidebarGroupContent,
12
- SidebarGroupLabel,
13
- SidebarHeader,
14
- SidebarInput,
15
- SidebarInset,
16
- SidebarMenu,
17
- SidebarMenuAction,
18
- SidebarMenuBadge,
19
- SidebarMenuButton,
20
- SidebarMenuItem,
21
- SidebarMenuSkeleton,
22
- SidebarMenuSub,
23
- SidebarMenuSubButton,
24
- SidebarMenuSubItem,
25
- SidebarProvider,
26
- SidebarRail,
27
- SidebarSeparator,
28
- SidebarTrigger,
29
- useSidebar,
30
- useSidebarNavigation,
31
- useInjectSidebarNavigation,
32
- } from './sidebar/sidebar'
33
- // Skeleton is exported from ../ui to avoid duplicate exports
34
- export { RootLayoutWrapper, ibmPlexSans, ibmPlexMono } from './root-layout-wrapper'
35
- export { LayoutContainer } from './layout-container'
36
- export { PageWithSidePanel } from './page-with-side-panel'
1
+ // Layout components exports
2
+ export { MainSidebar, type SidebarMode } from './sidebar/main-sidebar'
3
+ export { resolveIcon, type MainMenuItem, type SubMenuItem, type SidebarMenus, type SidebarMenuMeta, type MenuApiResponse, type ApiMenuData, type ApiMainMenuItem, type ApiSubMenuItem, type ApiSubMenu, type OrgInfo, type Project } from './sidebar/data'
4
+ export { QuickAccessTracker } from './sidebar/quick-access-tracker'
5
+ export {
6
+ Sidebar,
7
+ SidebarContent,
8
+ SidebarFooter,
9
+ SidebarGroup,
10
+ SidebarGroupAction,
11
+ SidebarGroupContent,
12
+ SidebarGroupLabel,
13
+ SidebarHeader,
14
+ SidebarInput,
15
+ SidebarInset,
16
+ SidebarMenu,
17
+ SidebarMenuAction,
18
+ SidebarMenuBadge,
19
+ SidebarMenuButton,
20
+ SidebarMenuItem,
21
+ SidebarMenuSkeleton,
22
+ SidebarMenuSub,
23
+ SidebarMenuSubButton,
24
+ SidebarMenuSubItem,
25
+ SidebarProvider,
26
+ SidebarRail,
27
+ SidebarSeparator,
28
+ SidebarTrigger,
29
+ useSidebar,
30
+ useSidebarNavigation,
31
+ useInjectSidebarNavigation,
32
+ } from './sidebar/sidebar'
33
+ // Skeleton is exported from ../ui to avoid duplicate exports
34
+ export { RootLayoutWrapper, ibmPlexSans, ibmPlexMono } from './root-layout-wrapper'
35
+ export { LayoutContainer, type LayoutContainerProps } from './layout-container'
36
+ export { EnvironmentSwitcher, type EnvironmentSwitcherProps } from './environment-switcher'
37
+ export { EnvironmentGate, type EnvironmentGateProps } from './environment-gate'
38
+ export { PageWithSidePanel } from './page-with-side-panel'
@@ -11,6 +11,8 @@ import { getMenuFromPath } from "../../lib/menu-utils"
11
11
  import { useIsMobile } from "../../hooks/use-mobile"
12
12
  import { Menu } from "lucide-react"
13
13
  import { UserPanel } from "./user-panel"
14
+ import { EnvironmentSwitcher } from "./environment-switcher"
15
+ import { EnvironmentGate } from "./environment-gate"
14
16
  import { useMenuContext } from "../../context/menu-context"
15
17
 
16
18
  // ─── Layout ──────────────────────────────────────────────────────────────────
@@ -23,6 +25,7 @@ export interface LayoutContainerProps {
23
25
  getSidebarMode?: (pathname: string, params: Record<string, string>, searchParams: URLSearchParams) => SidebarMode
24
26
  getCurrentMenu?: (pathname: string, searchParams: URLSearchParams) => string
25
27
  getCurrentMenuItem?: (pathname: string, searchParams: URLSearchParams) => string
28
+ isEnvironmentRequired?: (pathname: string) => boolean
26
29
  }
27
30
 
28
31
  function LayoutContent({
@@ -33,6 +36,7 @@ function LayoutContent({
33
36
  getSidebarMode,
34
37
  getCurrentMenu,
35
38
  getCurrentMenuItem,
39
+ isEnvironmentRequired,
36
40
  }: LayoutContainerProps) {
37
41
  const { fetchMenus } = useMenuContext()
38
42
  const pathname = usePathname()
@@ -113,6 +117,8 @@ function LayoutContent({
113
117
  const handleMainSidebarToggle = () => setIsMainSidebarOpen((v) => !v)
114
118
  const handleMenuSelect = (menu: string) => setCurrentMenu(menu)
115
119
  const handleSecondarySidebarOpen = () => setOpen(true)
120
+ const createEnvironmentHref = main_base_url ? `${main_base_url}/infra/environments` : undefined
121
+ const environmentRequired = isEnvironmentRequired ? isEnvironmentRequired(pathname) : true
116
122
 
117
123
  return (
118
124
  <div className="flex flex-col h-screen w-full bg-white overflow-hidden">
@@ -133,7 +139,10 @@ function LayoutContent({
133
139
  <Menu className="h-5 w-5" />
134
140
  </Button>
135
141
  </div>
136
- <div className="flex-1 flex items-center justify-end px-4 md:px-6">
142
+ <div className="flex-1 min-w-0 flex items-center justify-between gap-3 px-4 md:px-6">
143
+ <div className="min-w-0 flex items-center">
144
+ <EnvironmentSwitcher createHref={createEnvironmentHref} />
145
+ </div>
137
146
  <UserPanel main_base_url={main_base_url} />
138
147
  </div>
139
148
  </div>
@@ -166,7 +175,9 @@ function LayoutContent({
166
175
  />
167
176
 
168
177
  <main className="flex-1 bg-ibm-gray-10 min-h-0 overflow-auto">
169
- {children}
178
+ <EnvironmentGate required={environmentRequired} createHref={createEnvironmentHref}>
179
+ {children}
180
+ </EnvironmentGate>
170
181
  </main>
171
182
  </div>
172
183
  </div>
@@ -2,8 +2,7 @@
2
2
 
3
3
  import { useState, useEffect } from "react"
4
4
  import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from "./dialog"
5
- import { Button } from "./button"
6
- import { Loader2, Globe, Plus } from "lucide-react"
5
+ import { Loader2, Globe, Plus, Check, RotateCw } from "lucide-react"
7
6
 
8
7
  const CREATE_ENV_URL = process.env.NEXT_PUBLIC_MAIN_APP_URL
9
8
  ? `${process.env.NEXT_PUBLIC_MAIN_APP_URL}/infra/environments`
@@ -24,6 +23,8 @@ export interface EnvironmentPickerDialogProps {
24
23
  includeEnvs?: string[]
25
24
  title?: string
26
25
  description?: string
26
+ currentEnv?: string
27
+ createHref?: string
27
28
  }
28
29
 
29
30
  export function EnvironmentPickerDialog({
@@ -36,9 +37,12 @@ export function EnvironmentPickerDialog({
36
37
  includeEnvs,
37
38
  title = "Select an environment",
38
39
  description,
40
+ currentEnv,
41
+ createHref = CREATE_ENV_URL,
39
42
  }: EnvironmentPickerDialogProps) {
40
43
  const [environments, setEnvironments] = useState<Environment[]>([])
41
44
  const [loading, setLoading] = useState(true)
45
+ const [failed, setFailed] = useState(false)
42
46
 
43
47
  useEffect(() => {
44
48
  if (open) loadEnvironments()
@@ -46,6 +50,7 @@ export function EnvironmentPickerDialog({
46
50
 
47
51
  const loadEnvironments = async () => {
48
52
  setLoading(true)
53
+ setFailed(false)
49
54
  try {
50
55
  const response = await fetchEnvironments(projectName)
51
56
  let all = response.envs || []
@@ -53,7 +58,8 @@ export function EnvironmentPickerDialog({
53
58
  else if (excludeEnvs.length) all = all.filter((e) => !excludeEnvs.includes(e.name))
54
59
  setEnvironments(all)
55
60
  } catch {
56
- // silent
61
+ setEnvironments([])
62
+ setFailed(true)
57
63
  } finally {
58
64
  setLoading(false)
59
65
  }
@@ -73,14 +79,28 @@ export function EnvironmentPickerDialog({
73
79
  <Loader2 className="h-5 w-5 animate-spin text-ibm-blue-60" />
74
80
  <span className="ml-2 text-sm text-ibm-gray-70">Loading environments...</span>
75
81
  </div>
82
+ ) : failed ? (
83
+ <div className="flex flex-col items-center gap-4 py-8 text-center">
84
+ <p className="text-sm text-ibm-gray-60">
85
+ The list of environments could not be read.
86
+ </p>
87
+ <button
88
+ type="button"
89
+ onClick={loadEnvironments}
90
+ className="inline-flex items-center gap-1.5 h-9 px-4 text-sm border border-ibm-gray-30 bg-white hover:bg-ibm-gray-10 transition-colors"
91
+ >
92
+ <RotateCw className="h-3.5 w-3.5" />
93
+ Try again
94
+ </button>
95
+ </div>
76
96
  ) : environments.length === 0 ? (
77
97
  <div className="flex flex-col items-center gap-4 py-8 text-center">
78
98
  <p className="text-sm text-ibm-gray-60">
79
99
  No environments found for this project yet. Create one to continue.
80
100
  </p>
81
- {CREATE_ENV_URL ? (
101
+ {createHref ? (
82
102
  <a
83
- href={CREATE_ENV_URL}
103
+ href={createHref}
84
104
  className="inline-flex items-center gap-1.5 h-9 px-4 text-sm border border-ibm-gray-30 bg-white hover:bg-ibm-gray-10 transition-colors"
85
105
  >
86
106
  <Plus className="h-3.5 w-3.5" />
@@ -94,22 +114,27 @@ export function EnvironmentPickerDialog({
94
114
  </div>
95
115
  ) : (
96
116
  <div className="border border-ibm-gray-20 max-h-60 overflow-y-auto">
97
- {environments.map((env, index) => (
98
- <button
99
- key={env.name}
100
- type="button"
101
- className={`w-full text-left px-4 py-3 hover:bg-ibm-gray-10 transition-colors flex items-center gap-3 ${index !== environments.length - 1 ? "border-b border-ibm-gray-20" : ""}`}
102
- onClick={() => {
103
- onSelect(env.name, env.alias || env.name)
104
- onOpenChange(false)
105
- }}
106
- >
107
- <Globe className="h-4 w-4 text-ibm-gray-70 flex-shrink-0" />
108
- <span className="text-sm font-medium text-ibm-gray-100">
109
- {env.alias || env.name}
110
- </span>
111
- </button>
112
- ))}
117
+ {environments.map((env, index) => {
118
+ const selected = !!currentEnv && env.name === currentEnv
119
+ return (
120
+ <button
121
+ key={env.name}
122
+ type="button"
123
+ aria-current={selected ? "true" : undefined}
124
+ className={`w-full text-left px-4 py-3 transition-colors flex items-center gap-3 ${selected ? "bg-ibm-blue-10" : "hover:bg-ibm-gray-10"} ${index !== environments.length - 1 ? "border-b border-ibm-gray-20" : ""}`}
125
+ onClick={() => {
126
+ onSelect(env.name, env.alias || env.name)
127
+ onOpenChange(false)
128
+ }}
129
+ >
130
+ <Globe className="h-4 w-4 text-ibm-gray-70 flex-shrink-0" />
131
+ <span className="flex-1 min-w-0 truncate text-sm font-medium text-ibm-gray-100">
132
+ {env.alias || env.name}
133
+ </span>
134
+ {selected && <Check className="h-4 w-4 text-ibm-blue-60 flex-shrink-0" />}
135
+ </button>
136
+ )
137
+ })}
113
138
  </div>
114
139
  )}
115
140
  </div>
@@ -0,0 +1,61 @@
1
+ import * as React from "react"
2
+ import { Layers, Plus } from "lucide-react"
3
+ import { cn } from "../../lib/utils"
4
+
5
+ export interface EnvironmentRequiredProps {
6
+ createHref?: string
7
+ className?: string
8
+ }
9
+
10
+ export function EnvironmentRequired({ createHref, className }: EnvironmentRequiredProps) {
11
+ return (
12
+ <div
13
+ className={cn(
14
+ "flex flex-col md:flex-row items-center md:items-start justify-center gap-8 md:gap-12 p-6 md:p-12 min-h-[450px] bg-white",
15
+ className
16
+ )}
17
+ >
18
+ <div className="flex-shrink-0 h-40 w-40 bg-blue-50 flex items-center justify-center">
19
+ <Layers className="h-20 w-20 text-blue-200" />
20
+ </div>
21
+ <div className="max-w-xl">
22
+ <h2 className="text-xl md:text-2xl font-semibold text-ibm-gray-100 mb-3">
23
+ Create an environment to get started
24
+ </h2>
25
+ <p className="text-ibm-gray-60 text-sm md:text-base leading-relaxed mb-6">
26
+ This application works inside an environment. What you create here is deployed to the environment
27
+ selected at the top of the page, and this business unit has none yet.
28
+ </p>
29
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-5 mb-8">
30
+ <div className="border-l-2 border-ibm-blue-60 pl-3">
31
+ <p className="text-sm font-semibold text-ibm-gray-100 mb-1">Environment</p>
32
+ <p className="text-sm text-ibm-gray-60 leading-relaxed">
33
+ A stage of your business unit: development, staging, production. Each one has its own settings
34
+ and its own permissions.
35
+ </p>
36
+ </div>
37
+ <div className="border-l-2 border-ibm-blue-60 pl-3">
38
+ <p className="text-sm font-semibold text-ibm-gray-100 mb-1">Target</p>
39
+ <p className="text-sm text-ibm-gray-60 leading-relaxed">
40
+ Where an environment runs: a place on a cluster we operate or on a cluster of your own, in the
41
+ region you choose.
42
+ </p>
43
+ </div>
44
+ </div>
45
+ {createHref ? (
46
+ <a
47
+ href={createHref}
48
+ className="inline-flex items-center gap-2 h-11 px-8 text-sm font-medium bg-ibm-blue-60 text-white hover:bg-ibm-blue-70 transition-colors"
49
+ >
50
+ <Plus className="h-4 w-4" />
51
+ Create an environment
52
+ </a>
53
+ ) : (
54
+ <p className="text-sm text-ibm-gray-60">
55
+ Open Environments in the main menu to create one.
56
+ </p>
57
+ )}
58
+ </div>
59
+ </div>
60
+ )
61
+ }
@@ -1,85 +1,86 @@
1
- // UI Components exports
2
- export { Button } from './button'
3
- export { NotFoundPage, type NotFoundPageProps } from './not-found-page'
4
- export { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from './card'
5
- export { Avatar, AvatarImage, AvatarFallback } from './avatar'
6
- export { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator } from './dropdown-menu'
7
- export { Separator } from './separator'
8
- export { Logo } from './logo'
9
- export { UserMenu, type UserMenuItem, type UserMenuConfig } from './user-menu'
10
- export { Input } from './input'
11
- export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } from './tooltip'
12
- export { PageHeader } from './page-header'
13
- export { DetailPageHeader, type DetailPageHeaderProps, type DetailPageHeaderTab, type HeaderBreadcrumb } from './detail-page-header'
14
- export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, type ChartConfig } from './chart'
15
- export { SearchInput } from './search-input'
16
- export { AssetsHeader } from './assets-header'
17
- export { AssetLogo, getAssetIcon, getAssetColor } from './asset-logo'
18
- export { EditableTitle } from './editable-title'
19
- export { ImageCropDialog } from './image-crop-dialog'
20
- // Note: The following components are not exported as they depend on app-specific services or models:
21
- // - CertificateEditor, EnvironmentSettings, EnvironmentVariablesConfig
22
- // - FileImport, ProcessStatus, ResourceSettings, SecretExplorer, SecretPropertiesEditor, SelectedAsset
23
- export { ResourceSettings } from './resource-settings'
24
- export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from './accordion'
25
- export { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel } from './alert-dialog'
26
- export { Alert, AlertTitle, AlertDescription } from './alert'
27
- export { AlertBanner, useAlertBanner, type AlertBannerProps, type AlertState } from './alert-banner'
28
- export { AccessDeniedState, type AccessDeniedStateProps } from './access-denied-state'
29
- export { ConfirmationDialog, type ConfirmationDialogProps } from './confirmation-dialog'
30
- export { AspectRatio } from './aspect-ratio'
31
- export { Badge } from './badge'
32
- export { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis } from './breadcrumb'
33
- export { Calendar } from './calendar'
34
- export { Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext } from './carousel'
35
- export { Checkbox } from './checkbox'
36
- export { Collapsible, CollapsibleTrigger, CollapsibleContent } from './collapsible'
37
- export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandShortcut, CommandSeparator } from './command'
38
- export { ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuItem, ContextMenuCheckboxItem, ContextMenuRadioItem, ContextMenuLabel, ContextMenuSeparator, ContextMenuShortcut, ContextMenuGroup, ContextMenuPortal, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuRadioGroup } from './context-menu'
39
- export { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription } from './dialog'
40
- export { ProjectSelectorModal, type Project as ProjectSelectorItem, type ProjectSelectorModalProps } from './project-selector-modal'
41
- export { Drawer, DrawerTrigger, DrawerContent, DrawerHeader, DrawerFooter, DrawerTitle, DrawerDescription } from './drawer'
42
- export { Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField } from './form'
43
- export { HoverCard, HoverCardTrigger, HoverCardContent } from './hover-card'
44
- export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator } from './input-otp'
45
- export { Label } from './label'
46
- export { Menubar, MenubarMenu, MenubarTrigger, MenubarContent, MenubarItem, MenubarSeparator, MenubarLabel, MenubarCheckboxItem, MenubarRadioGroup, MenubarRadioItem, MenubarPortal, MenubarSubContent, MenubarSubTrigger, MenubarGroup, MenubarSub, MenubarShortcut } from './menubar'
47
- export { NavigationMenu, NavigationMenuList, NavigationMenuItem, NavigationMenuContent, NavigationMenuTrigger, NavigationMenuLink, NavigationMenuIndicator, NavigationMenuViewport, navigationMenuTriggerStyle } from './navigation-menu'
48
- export { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from './pagination'
49
- export { Popover, PopoverTrigger, PopoverContent } from './popover'
50
- export { Progress } from './progress'
51
- export { RadioGroup, RadioGroupItem } from './radio-group'
52
- export { RelativeTimeRangePicker, type RelativeTimeRangeOption, type RelativeTimeRangePickerProps } from './relative-time-range-picker'
53
- export { TimeRangePicker, resolveTimeRange, type TimeRangeValue, type TimeRangePickerProps } from './time-range-picker'
54
- export { ResizablePanelGroup, ResizablePanel, ResizableHandle } from './resizable'
55
- export { ScrollArea, ScrollBar } from './scroll-area'
56
- export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator } from './select'
57
- export { Sheet, SheetTrigger, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription } from './sheet'
58
- export { SidePanel, SidePanelTrigger, SidePanelClose, SidePanelContent, SidePanelHeader, SidePanelTitle, SidePanelDescription, SidePanelBody, SidePanelFooter } from './side-panel'
59
- export { PushPanel, type PushPanelProps } from './push-panel'
60
- export { Skeleton } from './skeleton'
61
- export { Spinner, type SpinnerProps } from './spinner'
62
- export { Slider } from './slider'
63
- export { Toaster } from './toaster'
64
- export { Switch } from './switch'
65
- export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption } from './table'
66
- export { Tabs, TabsList, TabsTrigger, TabsContent } from './tabs'
67
- export { Textarea } from './textarea'
68
- export { Toast, ToastAction, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport } from './toast'
69
- export { ToggleGroup, ToggleGroupItem } from './toggle-group'
70
- export { Toggle } from './toggle'
71
- export { StringsInput } from './strings-input'
72
- export { KVInput } from './kv-input'
73
- export { ResourcesInput } from './resources-input'
74
- export { NumbersInput } from './numbers-input'
75
- export { KVDynamicInput } from './kv-dynamic-input'
76
- export { SelectInput } from './select-input'
77
- export { SecretContextProvider, useSecretContext, type SecretEntry } from './secret-context'
78
- export { SecretInput } from './secret-input'
79
- export { ConfigSelectionProvider, useConfigSelection, useConfigChoices, type FieldConfigChoices } from './config-selection-context'
80
- export { SecretsInput } from './secrets-input'
81
- export { StructsInput } from './structs-input'
82
- export { CodeEditor } from './code-editor'
83
- export { K8sObjectsCode } from './k8s-objects-code'
84
- export { FileChip } from './file-chip'
85
- export { EnvironmentPickerDialog, type EnvironmentPickerDialogProps } from './environment-picker-dialog'
1
+ // UI Components exports
2
+ export { Button } from './button'
3
+ export { NotFoundPage, type NotFoundPageProps } from './not-found-page'
4
+ export { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from './card'
5
+ export { Avatar, AvatarImage, AvatarFallback } from './avatar'
6
+ export { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator } from './dropdown-menu'
7
+ export { Separator } from './separator'
8
+ export { Logo } from './logo'
9
+ export { UserMenu, type UserMenuItem, type UserMenuConfig } from './user-menu'
10
+ export { Input } from './input'
11
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } from './tooltip'
12
+ export { PageHeader } from './page-header'
13
+ export { DetailPageHeader, type DetailPageHeaderProps, type DetailPageHeaderTab, type HeaderBreadcrumb } from './detail-page-header'
14
+ export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, type ChartConfig } from './chart'
15
+ export { SearchInput } from './search-input'
16
+ export { AssetsHeader } from './assets-header'
17
+ export { AssetLogo, getAssetIcon, getAssetColor } from './asset-logo'
18
+ export { EditableTitle } from './editable-title'
19
+ export { ImageCropDialog } from './image-crop-dialog'
20
+ // Note: The following components are not exported as they depend on app-specific services or models:
21
+ // - CertificateEditor, EnvironmentSettings, EnvironmentVariablesConfig
22
+ // - FileImport, ProcessStatus, ResourceSettings, SecretExplorer, SecretPropertiesEditor, SelectedAsset
23
+ export { ResourceSettings } from './resource-settings'
24
+ export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from './accordion'
25
+ export { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel } from './alert-dialog'
26
+ export { Alert, AlertTitle, AlertDescription } from './alert'
27
+ export { AlertBanner, useAlertBanner, type AlertBannerProps, type AlertState } from './alert-banner'
28
+ export { AccessDeniedState, type AccessDeniedStateProps } from './access-denied-state'
29
+ export { ConfirmationDialog, type ConfirmationDialogProps } from './confirmation-dialog'
30
+ export { AspectRatio } from './aspect-ratio'
31
+ export { Badge } from './badge'
32
+ export { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis } from './breadcrumb'
33
+ export { Calendar } from './calendar'
34
+ export { Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext } from './carousel'
35
+ export { Checkbox } from './checkbox'
36
+ export { Collapsible, CollapsibleTrigger, CollapsibleContent } from './collapsible'
37
+ export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandShortcut, CommandSeparator } from './command'
38
+ export { ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuItem, ContextMenuCheckboxItem, ContextMenuRadioItem, ContextMenuLabel, ContextMenuSeparator, ContextMenuShortcut, ContextMenuGroup, ContextMenuPortal, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuRadioGroup } from './context-menu'
39
+ export { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription } from './dialog'
40
+ export { ProjectSelectorModal, type Project as ProjectSelectorItem, type ProjectSelectorModalProps } from './project-selector-modal'
41
+ export { Drawer, DrawerTrigger, DrawerContent, DrawerHeader, DrawerFooter, DrawerTitle, DrawerDescription } from './drawer'
42
+ export { Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField } from './form'
43
+ export { HoverCard, HoverCardTrigger, HoverCardContent } from './hover-card'
44
+ export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator } from './input-otp'
45
+ export { Label } from './label'
46
+ export { Menubar, MenubarMenu, MenubarTrigger, MenubarContent, MenubarItem, MenubarSeparator, MenubarLabel, MenubarCheckboxItem, MenubarRadioGroup, MenubarRadioItem, MenubarPortal, MenubarSubContent, MenubarSubTrigger, MenubarGroup, MenubarSub, MenubarShortcut } from './menubar'
47
+ export { NavigationMenu, NavigationMenuList, NavigationMenuItem, NavigationMenuContent, NavigationMenuTrigger, NavigationMenuLink, NavigationMenuIndicator, NavigationMenuViewport, navigationMenuTriggerStyle } from './navigation-menu'
48
+ export { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from './pagination'
49
+ export { Popover, PopoverTrigger, PopoverContent } from './popover'
50
+ export { Progress } from './progress'
51
+ export { RadioGroup, RadioGroupItem } from './radio-group'
52
+ export { RelativeTimeRangePicker, type RelativeTimeRangeOption, type RelativeTimeRangePickerProps } from './relative-time-range-picker'
53
+ export { TimeRangePicker, resolveTimeRange, type TimeRangeValue, type TimeRangePickerProps } from './time-range-picker'
54
+ export { ResizablePanelGroup, ResizablePanel, ResizableHandle } from './resizable'
55
+ export { ScrollArea, ScrollBar } from './scroll-area'
56
+ export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator } from './select'
57
+ export { Sheet, SheetTrigger, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription } from './sheet'
58
+ export { SidePanel, SidePanelTrigger, SidePanelClose, SidePanelContent, SidePanelHeader, SidePanelTitle, SidePanelDescription, SidePanelBody, SidePanelFooter } from './side-panel'
59
+ export { PushPanel, type PushPanelProps } from './push-panel'
60
+ export { Skeleton } from './skeleton'
61
+ export { Spinner, type SpinnerProps } from './spinner'
62
+ export { Slider } from './slider'
63
+ export { Toaster } from './toaster'
64
+ export { Switch } from './switch'
65
+ export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption } from './table'
66
+ export { Tabs, TabsList, TabsTrigger, TabsContent } from './tabs'
67
+ export { Textarea } from './textarea'
68
+ export { Toast, ToastAction, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport } from './toast'
69
+ export { ToggleGroup, ToggleGroupItem } from './toggle-group'
70
+ export { Toggle } from './toggle'
71
+ export { StringsInput } from './strings-input'
72
+ export { KVInput } from './kv-input'
73
+ export { ResourcesInput } from './resources-input'
74
+ export { NumbersInput } from './numbers-input'
75
+ export { KVDynamicInput } from './kv-dynamic-input'
76
+ export { SelectInput } from './select-input'
77
+ export { SecretContextProvider, useSecretContext, type SecretEntry } from './secret-context'
78
+ export { SecretInput } from './secret-input'
79
+ export { ConfigSelectionProvider, useConfigSelection, useConfigChoices, type FieldConfigChoices } from './config-selection-context'
80
+ export { SecretsInput } from './secrets-input'
81
+ export { StructsInput } from './structs-input'
82
+ export { CodeEditor } from './code-editor'
83
+ export { K8sObjectsCode } from './k8s-objects-code'
84
+ export { FileChip } from './file-chip'
85
+ export { EnvironmentPickerDialog, type EnvironmentPickerDialogProps } from './environment-picker-dialog'
86
+ export { EnvironmentRequired, type EnvironmentRequiredProps } from './environment-required'
@@ -0,0 +1,154 @@
1
+ "use client"
2
+
3
+ import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react"
4
+ import {
5
+ chooseEnvironment, environmentLabel, environmentStatusOf, findEnvironment, latestOnly, selectableEnvironments,
6
+ type EnvironmentLoadPhase, type EnvironmentOption, type EnvironmentStatus,
7
+ } from "../lib/environment-context"
8
+
9
+ export interface EnvironmentContextValue {
10
+ status: EnvironmentStatus
11
+ projectId: string
12
+ environments: EnvironmentOption[]
13
+ current: EnvironmentOption | null
14
+ lost: string | null
15
+ select: (name: string) => void
16
+ reload: () => Promise<EnvironmentOption[]>
17
+ dismissLost: () => void
18
+ }
19
+
20
+ const DISABLED: EnvironmentContextValue = {
21
+ status: "disabled",
22
+ projectId: "",
23
+ environments: [],
24
+ current: null,
25
+ lost: null,
26
+ select: () => {},
27
+ reload: async () => [],
28
+ dismissLost: () => {},
29
+ }
30
+
31
+ const EnvironmentContext = createContext<EnvironmentContextValue>(DISABLED)
32
+
33
+ export function useEnvironmentContext(): EnvironmentContextValue {
34
+ return useContext(EnvironmentContext)
35
+ }
36
+
37
+ export interface EnvironmentContextProviderProps {
38
+ children: React.ReactNode
39
+ enabled?: boolean
40
+ projectId: string | null | undefined
41
+ currentEnv: string
42
+ currentEnvAlias?: string
43
+ onSelect: (name: string, alias: string) => void
44
+ fetchEnvironments: (projectId: string) => Promise<{ envs?: EnvironmentOption[] | null } | null | undefined>
45
+ requestedEnv?: string | null
46
+ }
47
+
48
+ interface Loaded {
49
+ projectId: string
50
+ phase: EnvironmentLoadPhase
51
+ environments: EnvironmentOption[]
52
+ }
53
+
54
+ interface ReadOptions {
55
+ announce: boolean
56
+ reportLost: boolean
57
+ }
58
+
59
+ const NOTHING_LOADED: Loaded = { projectId: "", phase: "loading", environments: [] }
60
+
61
+ export function EnvironmentContextProvider({
62
+ children,
63
+ enabled = true,
64
+ projectId,
65
+ currentEnv,
66
+ currentEnvAlias,
67
+ onSelect,
68
+ fetchEnvironments,
69
+ requestedEnv,
70
+ }: EnvironmentContextProviderProps) {
71
+ const project = enabled ? (projectId ?? "") : ""
72
+ const [loaded, setLoaded] = useState<Loaded>(NOTHING_LOADED)
73
+ const [lost, setLost] = useState<string | null>(null)
74
+
75
+ const latest = useRef(latestOnly()).current
76
+ const live = useRef({ currentEnv, currentEnvAlias, onSelect, fetchEnvironments, requestedEnv })
77
+ live.current = { currentEnv, currentEnvAlias, onSelect, fetchEnvironments, requestedEnv }
78
+ const requestHonoured = useRef(false)
79
+ const previousProject = useRef("")
80
+
81
+ const read = useCallback(async (target: string, { announce, reportLost }: ReadOptions): Promise<EnvironmentOption[]> => {
82
+ const ticket = latest.begin()
83
+ if (announce) {
84
+ setLoaded({ projectId: target, phase: "loading", environments: [] })
85
+ setLost(null)
86
+ }
87
+
88
+ let environments: EnvironmentOption[]
89
+ try {
90
+ const answer = await live.current.fetchEnvironments(target)
91
+ environments = selectableEnvironments(answer?.envs, target)
92
+ } catch (error) {
93
+ if (announce && latest.isCurrent(ticket)) setLoaded({ projectId: target, phase: "failed", environments: [] })
94
+ throw error
95
+ }
96
+ if (!latest.isCurrent(ticket)) return environments
97
+
98
+ const requested = requestHonoured.current ? null : live.current.requestedEnv
99
+ requestHonoured.current = true
100
+ const remembered = live.current.currentEnv
101
+ const knownAlias = live.current.currentEnvAlias
102
+ const choice = chooseEnvironment(environments, { requested, remembered })
103
+
104
+ setLoaded({ projectId: target, phase: "loaded", environments })
105
+ const renamed = !!choice.name && knownAlias !== undefined && choice.alias !== knownAlias
106
+ if (choice.name !== remembered || renamed) live.current.onSelect(choice.name, choice.alias)
107
+ setLost(reportLost && choice.lost ? (knownAlias || choice.lost) : null)
108
+ return environments
109
+ }, [latest])
110
+
111
+ useEffect(() => {
112
+ const switched = !!previousProject.current && previousProject.current !== project
113
+ previousProject.current = project
114
+ if (!project) {
115
+ latest.begin()
116
+ setLoaded(NOTHING_LOADED)
117
+ setLost(null)
118
+ return
119
+ }
120
+ read(project, { announce: true, reportLost: !switched }).catch(() => {})
121
+ }, [project, read, latest])
122
+
123
+ const known = loaded.projectId === project
124
+ const environments = known ? loaded.environments : NOTHING_LOADED.environments
125
+ const phase: EnvironmentLoadPhase = known ? loaded.phase : "loading"
126
+ const status = environmentStatusOf({ enabled, projectId: project, phase, count: environments.length })
127
+
128
+ const select = useCallback((name: string) => {
129
+ const chosen = findEnvironment(environments, name)
130
+ if (!chosen) return
131
+ setLost(null)
132
+ live.current.onSelect(chosen.name, environmentLabel(chosen))
133
+ }, [environments])
134
+
135
+ const reload = useCallback(async (): Promise<EnvironmentOption[]> => {
136
+ if (!project) return []
137
+ return read(project, { announce: false, reportLost: true })
138
+ }, [project, read])
139
+
140
+ const dismissLost = useCallback(() => setLost(null), [])
141
+
142
+ const current = useMemo<EnvironmentOption | null>(() => {
143
+ if (status === "ready") return findEnvironment(environments, currentEnv)
144
+ if (status === "unavailable" && currentEnv) return { name: currentEnv, alias: currentEnvAlias || currentEnv }
145
+ return null
146
+ }, [status, environments, currentEnv, currentEnvAlias])
147
+
148
+ const value = useMemo<EnvironmentContextValue>(
149
+ () => ({ status, projectId: project, environments, current, lost, select, reload, dismissLost }),
150
+ [status, project, environments, current, lost, select, reload, dismissLost],
151
+ )
152
+
153
+ return <EnvironmentContext.Provider value={value}>{children}</EnvironmentContext.Provider>
154
+ }
package/context/index.tsx CHANGED
@@ -40,3 +40,4 @@ export const WorkflowEditContext = React.createContext<workflowEditContext>({})
40
40
 
41
41
  export { useUserContext, UserContextProvider, type UserProfile } from './user-context'
42
42
  export { useMenuContext, MenuContextProvider } from './menu-context';
43
+ export { useEnvironmentContext, EnvironmentContextProvider, type EnvironmentContextValue, type EnvironmentContextProviderProps } from './environment-context'
package/index.ts CHANGED
@@ -1,35 +1,36 @@
1
- // Utilities
2
- export * from './lib/utils'
3
- export * from './lib/menu-utils'
4
- export * from './lib/error-utils'
5
- export { BaseService } from './lib/base-service'
6
- export * from './lib/config-selection'
7
- export { createPlatformConfigSource, templateFilter, configOfHit, environmentWithTargets, type ConfigSource } from './lib/config-source'
8
- export { default as HttpClient, useHttpClient, ApiError } from './lib/http-client'
9
-
10
- // UI Components
11
- export * from './components/ui'
12
-
13
- // Extended Components for Dynamic Forms
14
- export * from './components/extends'
15
-
16
- // Layout Components
17
- export * from './components/layout'
18
-
19
- // Hooks
20
- export * from './hooks'
21
-
22
- // Context
23
- export * from './context/index'
24
-
25
- // Internationalization
26
- export { default as i18n } from './i18n'
27
-
28
- // Utilities (additional exports)
29
- export { locale } from './utils/locale'
30
- export * from './utils/common'
31
- export * from './utils/storage'
32
- export * from './utils/permission'
33
- export * from './utils/resetLogin'
34
- export * from './utils/cache'
35
- export * from './utils/errors'
1
+ // Utilities
2
+ export * from './lib/utils'
3
+ export * from './lib/menu-utils'
4
+ export * from './lib/error-utils'
5
+ export { BaseService } from './lib/base-service'
6
+ export * from './lib/config-selection'
7
+ export * from './lib/environment-context'
8
+ export { createPlatformConfigSource, templateFilter, configOfHit, environmentWithTargets, type ConfigSource } from './lib/config-source'
9
+ export { default as HttpClient, useHttpClient, ApiError } from './lib/http-client'
10
+
11
+ // UI Components
12
+ export * from './components/ui'
13
+
14
+ // Extended Components for Dynamic Forms
15
+ export * from './components/extends'
16
+
17
+ // Layout Components
18
+ export * from './components/layout'
19
+
20
+ // Hooks
21
+ export * from './hooks'
22
+
23
+ // Context
24
+ export * from './context/index'
25
+
26
+ // Internationalization
27
+ export { default as i18n } from './i18n'
28
+
29
+ // Utilities (additional exports)
30
+ export { locale } from './utils/locale'
31
+ export * from './utils/common'
32
+ export * from './utils/storage'
33
+ export * from './utils/permission'
34
+ export * from './utils/resetLogin'
35
+ export * from './utils/cache'
36
+ export * from './utils/errors'
@@ -0,0 +1,116 @@
1
+ export interface EnvironmentOption {
2
+ name: string
3
+ alias?: string
4
+ }
5
+
6
+ export type EnvironmentStatus = "disabled" | "no-project" | "loading" | "empty" | "ready" | "unavailable"
7
+
8
+ export type EnvironmentLoadPhase = "loading" | "loaded" | "failed"
9
+
10
+ export type EnvironmentChoiceReason = "requested" | "remembered" | "first" | "none"
11
+
12
+ export interface EnvironmentChoice {
13
+ name: string
14
+ alias: string
15
+ reason: EnvironmentChoiceReason
16
+ lost: string | null
17
+ }
18
+
19
+ const PROJECT_ENVIRONMENT_PREFIX = "sync-"
20
+ const NO_CHOICE: EnvironmentChoice = { name: "", alias: "", reason: "none", lost: null }
21
+
22
+ export function projectEnvironmentName(projectId: string): string {
23
+ return `${PROJECT_ENVIRONMENT_PREFIX}${projectId}`
24
+ }
25
+
26
+ export function isProjectEnvironment(name: string | null | undefined, projectId: string | null | undefined): boolean {
27
+ return !!name && !!projectId && name === projectEnvironmentName(projectId)
28
+ }
29
+
30
+ export function environmentLabel(environment: EnvironmentOption | null | undefined): string {
31
+ return environment?.alias?.trim() || environment?.name || ""
32
+ }
33
+
34
+ export function selectableEnvironments<T extends EnvironmentOption>(
35
+ environments: ReadonlyArray<T> | null | undefined,
36
+ projectId: string | null | undefined,
37
+ ): T[] {
38
+ const seen = new Set<string>()
39
+ const kept: T[] = []
40
+ for (const environment of environments ?? []) {
41
+ const name = typeof environment?.name === "string" ? environment.name : ""
42
+ if (!name || seen.has(name) || isProjectEnvironment(name, projectId)) continue
43
+ seen.add(name)
44
+ kept.push(environment)
45
+ }
46
+ return kept
47
+ }
48
+
49
+ export function findEnvironment<T extends EnvironmentOption>(
50
+ environments: ReadonlyArray<T>,
51
+ name: string | null | undefined,
52
+ ): T | null {
53
+ return name ? environments.find(environment => environment.name === name) ?? null : null
54
+ }
55
+
56
+ export function chooseEnvironment(
57
+ environments: ReadonlyArray<EnvironmentOption>,
58
+ wishes: { requested?: string | null; remembered?: string | null },
59
+ ): EnvironmentChoice {
60
+ if (environments.length === 0) return NO_CHOICE
61
+
62
+ const requested = findEnvironment(environments, wishes.requested)
63
+ if (requested) return { name: requested.name, alias: environmentLabel(requested), reason: "requested", lost: null }
64
+
65
+ const remembered = findEnvironment(environments, wishes.remembered)
66
+ if (remembered) return { name: remembered.name, alias: environmentLabel(remembered), reason: "remembered", lost: null }
67
+
68
+ const first = environments[0]
69
+ return { name: first.name, alias: environmentLabel(first), reason: "first", lost: wishes.remembered || null }
70
+ }
71
+
72
+ export function environmentStatusOf(input: {
73
+ enabled: boolean
74
+ projectId: string | null | undefined
75
+ phase: EnvironmentLoadPhase
76
+ count: number
77
+ }): EnvironmentStatus {
78
+ if (!input.enabled) return "disabled"
79
+ if (!input.projectId) return "no-project"
80
+ if (input.phase === "loading") return "loading"
81
+ if (input.phase === "failed") return "unavailable"
82
+ return input.count === 0 ? "empty" : "ready"
83
+ }
84
+
85
+ export function showsEnvironmentSwitcher(status: EnvironmentStatus): boolean {
86
+ return status !== "disabled" && status !== "no-project"
87
+ }
88
+
89
+ export type EnvironmentGateView = "content" | "waiting" | "required"
90
+
91
+ export function environmentGateView(status: EnvironmentStatus, required: boolean): EnvironmentGateView {
92
+ if (!required) return "content"
93
+ if (status === "loading") return "waiting"
94
+ if (status === "empty") return "required"
95
+ return "content"
96
+ }
97
+
98
+ export function environmentButtonLabel(status: EnvironmentStatus, current: EnvironmentOption | null): string {
99
+ if (status === "empty") return "No environment"
100
+ const label = environmentLabel(current)
101
+ if (label) return label
102
+ return status === "unavailable" ? "Environments unavailable" : ""
103
+ }
104
+
105
+ export interface LatestOnly {
106
+ begin(): number
107
+ isCurrent(ticket: number): boolean
108
+ }
109
+
110
+ export function latestOnly(): LatestOnly {
111
+ let last = 0
112
+ return {
113
+ begin: () => { last += 1; return last },
114
+ isCurrent: ticket => ticket === last,
115
+ }
116
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orsetra/shared-ui",
3
- "version": "1.10.33",
3
+ "version": "1.11.0",
4
4
  "description": "Shared UI components for Orsetra platform",
5
5
  "main": "./index.ts",
6
6
  "types": "./index.ts",