@orsetra/shared-ui 1.10.7 → 1.10.9

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 once so the anchor's `href` attribute itself is already correct — not just
328
- // the JS click handler — so middle-click / right-click "open in new tab" (which bypass
329
- // onClick entirely) don't navigate to a literal "${envAlias}"-style broken URL.
330
- const templateResolution = item.target === "_blank" ? resolveTemplateVars(item.href) : null
331
- const isDisabled = !!templateResolution && !templateResolution.isResolved
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={item.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}
@@ -85,7 +85,13 @@ export function UserPanel({ main_base_url }: UserPanelProps) {
85
85
  </span>
86
86
  <div className="flex items-center gap-3 mt-1.5">
87
87
  <button
88
- onClick={() => { close(); openBusinessUnitSwitcher() }}
88
+ onClick={() => {
89
+ close()
90
+ // Deferred: closing this dropdown and opening the dialog in
91
+ // the same tick races Radix's body pointer-events cleanup,
92
+ // leaving the whole app unclickable until a refresh.
93
+ setTimeout(() => openBusinessUnitSwitcher(), 0)
94
+ }}
89
95
  className="text-xs text-[#0f62fe] hover:underline"
90
96
  >
91
97
  Switch
@@ -2,7 +2,12 @@
2
2
 
3
3
  import { useState, useEffect } from "react"
4
4
  import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from "./dialog"
5
- import { Loader2, Globe } from "lucide-react"
5
+ import { Button } from "./button"
6
+ import { Loader2, Globe, Plus } from "lucide-react"
7
+
8
+ const CREATE_ENV_URL = process.env.NEXT_PUBLIC_MAIN_APP_URL
9
+ ? `${process.env.NEXT_PUBLIC_MAIN_APP_URL}/infra/environments`
10
+ : undefined
6
11
 
7
12
  interface Environment {
8
13
  name: string
@@ -69,8 +74,20 @@ export function EnvironmentPickerDialog({
69
74
  <span className="ml-2 text-sm text-ibm-gray-70">Loading environments...</span>
70
75
  </div>
71
76
  ) : environments.length === 0 ? (
72
- <div className="text-center py-8 text-sm text-ibm-gray-60">
73
- No environments found
77
+ <div className="flex flex-col items-center gap-4 py-8 text-center">
78
+ <p className="text-sm text-ibm-gray-60">
79
+ No environments found for this project yet. Create one to continue.
80
+ </p>
81
+ {CREATE_ENV_URL && (
82
+ <Button
83
+ variant="secondary"
84
+ className="rounded-none h-9"
85
+ leftIcon={<Plus className="h-3.5 w-3.5" />}
86
+ onClick={() => { window.location.href = CREATE_ENV_URL }}
87
+ >
88
+ Create an environment
89
+ </Button>
90
+ )}
74
91
  </div>
75
92
  ) : (
76
93
  <div className="border border-ibm-gray-20 max-h-60 overflow-y-auto">
@@ -38,6 +38,7 @@ export interface ProjectSelectorModalProps extends ProjectSelectorProps {
38
38
  onOpenChange?: (open: boolean) => void
39
39
  title?: string
40
40
  description?: string
41
+ currentProjectId?: string
41
42
  }
42
43
 
43
44
  export function ProjectSelectorModal({
@@ -45,6 +46,7 @@ export function ProjectSelectorModal({
45
46
  onOpenChange,
46
47
  title = "Select Business Unit",
47
48
  description = "Choose a business unit to continue. This will be used for all operations in this application.",
49
+ currentProjectId,
48
50
  getProjects,
49
51
  createProject,
50
52
  doInit,
@@ -68,9 +70,13 @@ export function ProjectSelectorModal({
68
70
  try {
69
71
  const projectsList = await getProjects()
70
72
  setProjects(projectsList)
71
-
72
- // If no project selected yet and we have projects, select the first one
73
- if (!selectedProject && projectsList.length > 0) {
73
+
74
+ // Always re-seed from the actual current project when the dialog opens,
75
+ // so switching business units twice in a row doesn't leave the picker
76
+ // stuck showing the previous pick.
77
+ if (currentProjectId && projectsList.some((p) => p.id === currentProjectId)) {
78
+ setSelectedProject(currentProjectId)
79
+ } else if (!selectedProject && projectsList.length > 0) {
74
80
  setSelectedProject(projectsList[0].id)
75
81
  }
76
82
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orsetra/shared-ui",
3
- "version": "1.10.7",
3
+ "version": "1.10.9",
4
4
  "description": "Shared UI components for Orsetra platform",
5
5
  "main": "./index.ts",
6
6
  "types": "./index.ts",