@orsetra/shared-ui 1.18.0 → 1.18.2
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.
|
@@ -4,9 +4,10 @@ import { ChevronDown } from "lucide-react"
|
|
|
4
4
|
import { useUserContext } from "../../context/user-context"
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* The business unit of the page, in the header,
|
|
8
|
-
*
|
|
9
|
-
* business unit stays the
|
|
7
|
+
* The business unit of the page, in the header, on the ground of the header itself (unlike the grey
|
|
8
|
+
* block of the environment switcher). It opens the dialog of the application
|
|
9
|
+
* (openBusinessUnitSwitcher of the user context): what follows a change of business unit stays the
|
|
10
|
+
* application's.
|
|
10
11
|
*/
|
|
11
12
|
export function BusinessUnitSwitcher() {
|
|
12
13
|
const { currentProject, organization, openBusinessUnitSwitcher } = useUserContext()
|
|
@@ -20,12 +21,12 @@ export function BusinessUnitSwitcher() {
|
|
|
20
21
|
disabled={loading}
|
|
21
22
|
title="Change business unit"
|
|
22
23
|
aria-haspopup="dialog"
|
|
23
|
-
className="h-8 w-
|
|
24
|
+
className="h-8 max-w-[12rem] flex-shrink-0 flex items-center gap-1.5 px-2 bg-transparent text-text-primary hover:bg-ui-background transition-colors disabled:cursor-default"
|
|
24
25
|
>
|
|
25
26
|
{loading ? (
|
|
26
27
|
<span className="h-2.5 w-20 bg-gray-300 animate-pulse" aria-label="Loading business unit" />
|
|
27
28
|
) : (
|
|
28
|
-
<span className="truncate text-
|
|
29
|
+
<span className="truncate text-sm font-medium">{label}</span>
|
|
29
30
|
)}
|
|
30
31
|
<ChevronDown className="h-3.5 w-3.5 flex-shrink-0 text-gray-500" />
|
|
31
32
|
</button>
|
|
@@ -11,9 +11,11 @@ export interface EnvironmentGateProps {
|
|
|
11
11
|
children: ReactNode
|
|
12
12
|
required?: boolean
|
|
13
13
|
createHref?: string
|
|
14
|
+
/** Address of the home application, for the links of the page without environment. */
|
|
15
|
+
mainBaseUrl?: string
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
export function EnvironmentGate({ children, required = true, createHref }: EnvironmentGateProps) {
|
|
18
|
+
export function EnvironmentGate({ children, required = true, createHref, mainBaseUrl }: EnvironmentGateProps) {
|
|
17
19
|
const { status, current, lost, dismissLost } = useEnvironmentContext()
|
|
18
20
|
const view = environmentGateView(status, required)
|
|
19
21
|
|
|
@@ -26,11 +28,7 @@ export function EnvironmentGate({ children, required = true, createHref }: Envir
|
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
if (view === "required") {
|
|
29
|
-
return
|
|
30
|
-
<div className="p-4">
|
|
31
|
-
<EnvironmentRequired createHref={createHref} />
|
|
32
|
-
</div>
|
|
33
|
-
)
|
|
31
|
+
return <EnvironmentRequired createHref={createHref} mainBaseUrl={mainBaseUrl} />
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
return (
|
|
@@ -131,6 +131,8 @@ function LayoutContent({
|
|
|
131
131
|
const environmentRequired = isEnvironmentRequired ? isEnvironmentRequired(pathname) : true
|
|
132
132
|
// The application of the page: the header of its secondary menu (none on the home page).
|
|
133
133
|
const appTitle = sectionLabels[currentMenu]
|
|
134
|
+
// Its icon, the one of its entry in the main menu.
|
|
135
|
+
const AppIcon = mainMenuItems.find((m) => m.id === currentMenu)?.icon
|
|
134
136
|
// The support of the platform; '#' is the default of the build argument when it is not given.
|
|
135
137
|
const configuredSupport = process.env.NEXT_PUBLIC_SUPPORT_URL
|
|
136
138
|
const supportHref = configuredSupport && configuredSupport !== '#' ? configuredSupport : `${main_base_url}/support`
|
|
@@ -154,8 +156,9 @@ function LayoutContent({
|
|
|
154
156
|
<Menu className="h-5 w-5" />
|
|
155
157
|
</Button>
|
|
156
158
|
{appTitle && (
|
|
157
|
-
<span className="hidden md:inline-
|
|
158
|
-
{
|
|
159
|
+
<span className="hidden md:inline-flex items-center gap-2 min-w-0 ml-2 pl-4 border-l border-ui-border text-sm font-normal text-text-primary">
|
|
160
|
+
{AppIcon && <AppIcon className="h-4 w-4 flex-shrink-0 text-text-secondary" aria-hidden />}
|
|
161
|
+
<span className="truncate">{appTitle}</span>
|
|
159
162
|
</span>
|
|
160
163
|
)}
|
|
161
164
|
<EnvironmentSwitcher createHref={createEnvironmentHref} />
|
|
@@ -202,7 +205,7 @@ function LayoutContent({
|
|
|
202
205
|
|
|
203
206
|
<main className="flex-1 bg-ibm-gray-10 min-h-0 overflow-auto">
|
|
204
207
|
<ProjectGate selection={projectSelection} required={isProjectRequired} mainBaseUrl={main_base_url}>
|
|
205
|
-
<EnvironmentGate required={environmentRequired} createHref={createEnvironmentHref}>
|
|
208
|
+
<EnvironmentGate required={environmentRequired} createHref={createEnvironmentHref} mainBaseUrl={main_base_url}>
|
|
206
209
|
{children}
|
|
207
210
|
</EnvironmentGate>
|
|
208
211
|
</ProjectGate>
|
|
@@ -1,59 +1,154 @@
|
|
|
1
1
|
import * as React from "react"
|
|
2
|
-
import {
|
|
2
|
+
import { ArrowRight, BookOpen, Globe, LifeBuoy, Plus, Server } from "lucide-react"
|
|
3
3
|
import { cn } from "../../lib/utils"
|
|
4
4
|
|
|
5
5
|
export interface EnvironmentRequiredProps {
|
|
6
6
|
createHref?: string
|
|
7
|
+
/** Address of the home application: the links to the environments and targets pages. */
|
|
8
|
+
mainBaseUrl?: string
|
|
7
9
|
className?: string
|
|
8
10
|
}
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
const DOCS_URL = process.env.NEXT_PUBLIC_DOCS_URL
|
|
13
|
+
const CONFIGURED_SUPPORT = process.env.NEXT_PUBLIC_SUPPORT_URL
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Environments of a business unit on the target they run on, the last one still to create: in the
|
|
17
|
+
* style of the empty states of the console (gray ground, black outlines, blue in use, dashed teal to
|
|
18
|
+
* create). Drawn here rather than shipped as a file, so that every application has it.
|
|
19
|
+
*/
|
|
20
|
+
function EnvironmentsIllustration() {
|
|
11
21
|
return (
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
22
|
+
<svg
|
|
23
|
+
viewBox="0 0 1024 1024"
|
|
24
|
+
className="w-full max-w-[280px] h-auto"
|
|
25
|
+
role="img"
|
|
26
|
+
aria-label="Environments running on a target, one still to create"
|
|
17
27
|
>
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
<rect width="1024" height="1024" fill="#f4f4f4"/>
|
|
29
|
+
<rect x="128" y="250" width="232" height="250" fill="#ffffff" stroke="#161616" strokeWidth="5"/>
|
|
30
|
+
<rect x="162" y="290" width="164" height="70" fill="#0f62fe"/>
|
|
31
|
+
<rect x="162" y="384" width="164" height="70" fill="#a6c8ff"/>
|
|
32
|
+
<line x1="244" y1="500" x2="244" y2="620" stroke="#8d8d8d" strokeWidth="4"/>
|
|
33
|
+
<rect x="396" y="250" width="232" height="250" fill="#ffffff" stroke="#161616" strokeWidth="5"/>
|
|
34
|
+
<rect x="430" y="290" width="164" height="70" fill="#0f62fe"/>
|
|
35
|
+
<rect x="430" y="384" width="164" height="70" fill="#0f62fe"/>
|
|
36
|
+
<line x1="512" y1="500" x2="512" y2="620" stroke="#8d8d8d" strokeWidth="4"/>
|
|
37
|
+
<rect x="664" y="250" width="232" height="250" fill="#d9fbfb" stroke="#007d79" strokeWidth="5" strokeDasharray="18 12"/>
|
|
38
|
+
<rect x="774" y="335" width="12" height="80" fill="#007d79"/>
|
|
39
|
+
<rect x="740" y="369" width="80" height="12" fill="#007d79"/>
|
|
40
|
+
<line x1="780" y1="500" x2="780" y2="620" stroke="#007d79" strokeWidth="4"/>
|
|
41
|
+
<rect x="128" y="620" width="768" height="128" fill="#161616"/>
|
|
42
|
+
<rect x="176" y="664" width="88" height="40" fill="#ffffff"/>
|
|
43
|
+
<rect x="296" y="664" width="88" height="40" fill="#ffffff"/>
|
|
44
|
+
<rect x="416" y="664" width="88" height="40" fill="#ffffff"/>
|
|
45
|
+
</svg>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The cards of the getting-start pages: icon, title with an arrow, a line of explanation. */
|
|
50
|
+
function EntryCard({ icon: Icon, title, description, href }: { icon: typeof Globe; title: string; description: string; href?: string }) {
|
|
51
|
+
const body = (
|
|
52
|
+
<>
|
|
53
|
+
<Icon className="h-6 w-6 text-ibm-blue-60 mb-3" />
|
|
54
|
+
<span className="flex items-center gap-1.5 text-sm font-semibold text-ibm-gray-100 mb-1 group-hover:text-ibm-blue-60">
|
|
55
|
+
{title}
|
|
56
|
+
{href && <ArrowRight className="h-3.5 w-3.5 text-ibm-blue-60" />}
|
|
57
|
+
</span>
|
|
58
|
+
<span className="block text-sm text-ibm-gray-60 leading-relaxed">{description}</span>
|
|
59
|
+
</>
|
|
60
|
+
)
|
|
61
|
+
const cls = "group bg-white px-6 py-5 flex flex-col text-left"
|
|
62
|
+
if (!href) return <div className={cls}>{body}</div>
|
|
63
|
+
const external = href.startsWith("http") && !!DOCS_URL && href.startsWith(DOCS_URL)
|
|
64
|
+
return (
|
|
65
|
+
<a href={href} className={cls} {...(external ? { target: "_blank", rel: "noopener noreferrer" } : {})}>
|
|
66
|
+
{body}
|
|
67
|
+
</a>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The page an application shows while its business unit has no environment: laid out as the
|
|
73
|
+
* getting-start pages, a banner with the picture and the way to create one, what an environment
|
|
74
|
+
* and a target are, then the documentation and the support.
|
|
75
|
+
*/
|
|
76
|
+
export function EnvironmentRequired({ createHref, mainBaseUrl, className }: EnvironmentRequiredProps) {
|
|
77
|
+
const base = (mainBaseUrl ?? "").replace(/\/+$/, "")
|
|
78
|
+
const docOrPage = (docPath: string, page: string) =>
|
|
79
|
+
DOCS_URL ? `${DOCS_URL}${docPath}` : base ? `${base}${page}` : undefined
|
|
80
|
+
const supportHref = CONFIGURED_SUPPORT && CONFIGURED_SUPPORT !== "#" ? CONFIGURED_SUPPORT : base ? `${base}/support` : undefined
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<div className={cn("min-h-full bg-ibm-gray-10", className)}>
|
|
84
|
+
<div className="p-4 sm:p-6">
|
|
85
|
+
<div className="bg-white mb-6">
|
|
86
|
+
<div className="flex flex-col md:flex-row-reverse items-center gap-8 md:gap-12 px-10 py-12">
|
|
87
|
+
<div className="flex-shrink-0 w-full max-w-[280px]">
|
|
88
|
+
<EnvironmentsIllustration />
|
|
89
|
+
</div>
|
|
90
|
+
<div className="flex-1 min-w-0 text-center md:text-left">
|
|
91
|
+
<h1 className="text-2xl font-semibold text-ibm-gray-100 mb-3">Create an environment to get started</h1>
|
|
92
|
+
<p className="text-sm md:text-base text-ibm-gray-60 leading-relaxed max-w-2xl mx-auto md:mx-0 mb-6">
|
|
93
|
+
This application works inside an environment. What you create here is deployed to the environment
|
|
94
|
+
selected at the top of the page, and this business unit has none yet.
|
|
95
|
+
</p>
|
|
96
|
+
{createHref ? (
|
|
97
|
+
<a
|
|
98
|
+
href={createHref}
|
|
99
|
+
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"
|
|
100
|
+
>
|
|
101
|
+
<Plus className="h-4 w-4" />
|
|
102
|
+
Create an environment
|
|
103
|
+
</a>
|
|
104
|
+
) : (
|
|
105
|
+
<p className="text-sm text-ibm-gray-60">Open Environments in the main menu to create one.</p>
|
|
106
|
+
)}
|
|
107
|
+
</div>
|
|
36
108
|
</div>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
<div className="mb-6">
|
|
112
|
+
<h2 className="text-xs font-semibold text-ibm-gray-50 uppercase tracking-widest mb-3">What you will find here</h2>
|
|
113
|
+
<div className="grid grid-cols-1 sm:grid-cols-2 gap-px bg-ibm-gray-20">
|
|
114
|
+
<EntryCard
|
|
115
|
+
icon={Globe}
|
|
116
|
+
title="Environments"
|
|
117
|
+
description="A stage of your business unit: development, staging, production. Each one has its own settings and its own permissions."
|
|
118
|
+
href={docOrPage("/infra/environments", "/infra/environments")}
|
|
119
|
+
/>
|
|
120
|
+
<EntryCard
|
|
121
|
+
icon={Server}
|
|
122
|
+
title="Targets"
|
|
123
|
+
description="Where an environment runs: a place on a cluster we operate or on a cluster of your own, in the region you choose."
|
|
124
|
+
href={docOrPage("/infra/targets", "/infra/targets")}
|
|
125
|
+
/>
|
|
43
126
|
</div>
|
|
44
127
|
</div>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
128
|
+
|
|
129
|
+
{(DOCS_URL || supportHref) && (
|
|
130
|
+
<div className="mt-2 border-t border-ui-border pt-5 flex flex-col sm:flex-row gap-6 sm:gap-10">
|
|
131
|
+
{DOCS_URL && (
|
|
132
|
+
<a
|
|
133
|
+
href={DOCS_URL}
|
|
134
|
+
target="_blank"
|
|
135
|
+
rel="noopener noreferrer"
|
|
136
|
+
className="flex items-center gap-2 text-sm text-ibm-gray-60 hover:text-ibm-blue-60 transition-colors"
|
|
137
|
+
>
|
|
138
|
+
<BookOpen className="h-4 w-4 flex-shrink-0" />
|
|
139
|
+
Documentation
|
|
140
|
+
</a>
|
|
141
|
+
)}
|
|
142
|
+
{supportHref && (
|
|
143
|
+
<a
|
|
144
|
+
href={supportHref}
|
|
145
|
+
className="flex items-center gap-2 text-sm text-ibm-gray-60 hover:text-ibm-blue-60 transition-colors"
|
|
146
|
+
>
|
|
147
|
+
<LifeBuoy className="h-4 w-4 flex-shrink-0" />
|
|
148
|
+
Contact support
|
|
149
|
+
</a>
|
|
150
|
+
)}
|
|
151
|
+
</div>
|
|
57
152
|
)}
|
|
58
153
|
</div>
|
|
59
154
|
</div>
|
package/components/ui/logo.tsx
CHANGED
|
@@ -9,20 +9,6 @@ interface LogoProps {
|
|
|
9
9
|
href?: string
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
const MonogramIcon = ({ className }: { className?: string }) => (
|
|
13
|
-
<svg
|
|
14
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
-
viewBox="0 0 64 64"
|
|
16
|
-
className={cn("inline-block flex-shrink-0", className)}
|
|
17
|
-
aria-hidden="true"
|
|
18
|
-
>
|
|
19
|
-
<rect width="64" height="64" fill="#0F62FE" />
|
|
20
|
-
<polygon fill="#FFFFFF" points="12.56,14.72 18.32,14.72 26.96,32 18.32,49.28 12.56,49.28 21.2,32" />
|
|
21
|
-
<polygon fill="#FFFFFF" points="51.44,14.72 45.68,14.72 37.04,32 45.68,49.28 51.44,49.28 42.8,32" />
|
|
22
|
-
<rect fill="#FFFFFF" x="28.4" y="28.4" width="7.2" height="7.2" />
|
|
23
|
-
</svg>
|
|
24
|
-
)
|
|
25
|
-
|
|
26
12
|
const Wordmark = ({ className }: { className?: string }) => (
|
|
27
13
|
<svg
|
|
28
14
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -40,13 +26,25 @@ const Wordmark = ({ className }: { className?: string }) => (
|
|
|
40
26
|
</svg>
|
|
41
27
|
)
|
|
42
28
|
|
|
29
|
+
/**
|
|
30
|
+
* The mark in colour on a transparent ground (graphic/icon/png/cx-icon-color-64.png), the one of
|
|
31
|
+
* the header: inlined, so that every application has it without a file of its own. 64 pixels shown
|
|
32
|
+
* at 24, sharp on dense screens.
|
|
33
|
+
*/
|
|
34
|
+
const COLOR_ICON = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeA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e7z1oQPXTduh1s0M3Gqd1l0yATQjhEEI+gJAPnXJg6tTn1FcvhAJ7pkmjYGkQCvCiXwpjzsl7D2jYeQjKGcyAd2Z6oZel5OlzsL0AS66+dwooRxBe78t7mDcKsALqe6WAKqC+VwqwIup7o4Aqor43CrBC6nuhgCqkvhcKsGLqF04BVUz9winACqpfKAVUQfULpQArqn5hFFBCp9HKPY09IB1PWUEJ1E/LPMVjNbHbuUR13R3EzKzQ3NzcHUT8ICZV12mauQrDsAzqd1EQBMFS0sPSiKgPeN/d3d396FIw4fiaR81F5CEiHjhpJrOizIz2aXHTN4zeTAwaEzMnPi4fzQkAPrkU4EX/wUS/Vgblvf1kZqg/PirYqhr32MY2trHBSOwv3W+B8hcSQw8AAAAASUVORK5CYII="
|
|
35
|
+
|
|
36
|
+
const ColorIcon = () => (
|
|
37
|
+
// eslint-disable-next-line @next/next/no-img-element
|
|
38
|
+
<img src={COLOR_ICON} alt="Camel X" width={24} height={24} className="inline-block flex-shrink-0 w-6 h-6" />
|
|
39
|
+
)
|
|
40
|
+
|
|
43
41
|
export function Logo({ className, iconOnly = false, href = "/" }: LogoProps) {
|
|
44
42
|
return (
|
|
45
43
|
<Link
|
|
46
44
|
href={href}
|
|
47
45
|
className={cn("text-text-primary truncate flex items-center no-underline", className)}
|
|
48
46
|
>
|
|
49
|
-
{iconOnly ? <
|
|
47
|
+
{iconOnly ? <ColorIcon /> : <Wordmark />}
|
|
50
48
|
</Link>
|
|
51
49
|
)
|
|
52
50
|
}
|