Skip to content

Commit f3fb51d

Browse files
committed
show only the console app in self-hosted clusters
1 parent a44d53e commit f3fb51d

File tree

7 files changed

+127
-236
lines changed

7 files changed

+127
-236
lines changed

www/src/components/cluster/Cluster.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { ResponsiveLayoutPage } from '../utils/layout/ResponsiveLayoutPage'
2525
import { EditPluralOIDCClients } from '../overview/clusters/plural-cloud/EditPluralOIDCClients'
2626

2727
import { ClusterAdminsModal } from './ClusterAdminsModal'
28-
import { ClusterApps } from './ClusterApps'
28+
import { ClusterConsole } from './ClusterConsole'
2929
import { ClusterDependencyModal } from './ClusterDependencyModal'
3030
import ClusterMetadataPanel from './ClusterMetadataPanel'
3131
import { ClusterPromoteModal } from './ClusterPromoteModal'
@@ -181,7 +181,7 @@ export function Cluster() {
181181
skip={!cluster.owner?.serviceAccount}
182182
>
183183
<>
184-
<ClusterApps cluster={cluster} />
184+
<ClusterConsole cluster={cluster} />
185185
<div
186186
css={{
187187
...theme.partials.text.body1Bold,

www/src/components/cluster/ClusterApp.tsx

Lines changed: 0 additions & 130 deletions
This file was deleted.

www/src/components/cluster/ClusterApps.tsx

Lines changed: 0 additions & 86 deletions
This file was deleted.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import { ReactElement } from 'react'
2+
3+
import LoadingIndicator from '../utils/LoadingIndicator'
4+
import { EmptyListMessage } from '../overview/clusters/misc'
5+
import { Cluster, useRepositoryQuery } from '../../generated/graphql'
6+
7+
import { GqlError } from '../utils/Alert'
8+
import { useNavigate, useParams } from 'react-router-dom'
9+
import { useTheme } from 'styled-components'
10+
import {
11+
IconFrame,
12+
Flex,
13+
Card,
14+
Chip,
15+
GearTrainIcon,
16+
Button,
17+
ArrowTopRightIcon,
18+
} from '@pluralsh/design-system'
19+
import { Body1BoldP } from '../utils/Typography'
20+
import { ensureURLValidity } from '../../utils/url'
21+
import { ignoreEvent } from '../../utils/ignore-event'
22+
23+
const CONSOLE_APP_NAME = 'console'
24+
25+
type ClusterAppsProps = { cluster: Cluster }
26+
27+
export function ClusterConsole({
28+
cluster: { consoleUrl },
29+
}: ClusterAppsProps): ReactElement {
30+
const theme = useTheme()
31+
const navigate = useNavigate()
32+
const { clusterId } = useParams()
33+
const { data, loading, error } = useRepositoryQuery({
34+
variables: { name: CONSOLE_APP_NAME },
35+
})
36+
const console = data?.repository
37+
const url = ensureURLValidity(consoleUrl)
38+
39+
if (error)
40+
return (
41+
<GqlError
42+
header="Could not fetch console details"
43+
error={error}
44+
/>
45+
)
46+
47+
if (!data && loading) return <LoadingIndicator />
48+
49+
if (!console)
50+
return (
51+
<EmptyListMessage>
52+
Looks like you haven't installed your first app yet.
53+
</EmptyListMessage>
54+
)
55+
56+
return (
57+
<Card
58+
clickable={!!url}
59+
onClick={(e) => {
60+
ignoreEvent(e)
61+
if (url) window.open(url, '_blank', 'noopener noreferrer')
62+
}}
63+
alignItems="center"
64+
display="flex"
65+
gap="medium"
66+
padding="small"
67+
>
68+
<IconFrame
69+
icon={
70+
<img
71+
src={console.darkIcon || console.icon || ''}
72+
width={32}
73+
height={32}
74+
/>
75+
}
76+
size="large"
77+
type="floating"
78+
/>
79+
<Body1BoldP>{console.name}</Body1BoldP>
80+
<Chip
81+
severity={console.installation?.synced ? 'success' : 'warning'}
82+
size={'small'}
83+
>
84+
{console.installation?.synced ? 'Synced' : 'Pending Sync'}
85+
</Chip>
86+
{console.installation?.locked && <Chip>Locked</Chip>}
87+
<Flex grow={1} />
88+
<Button
89+
floating
90+
small
91+
startIcon={<GearTrainIcon />}
92+
onClick={(e) => {
93+
ignoreEvent(e)
94+
navigate(`/apps/${clusterId}/${console.name}`)
95+
}}
96+
>
97+
Settings
98+
</Button>
99+
{url && (
100+
<Button
101+
endIcon={<ArrowTopRightIcon size={14} />}
102+
small
103+
onClick={(e) => {
104+
ignoreEvent(e)
105+
window.open(url, '_blank', 'noopener noreferrer')
106+
}}
107+
>
108+
Launch
109+
</Button>
110+
)}
111+
</Card>
112+
)
113+
}

www/src/components/cluster/ClusterSidecar.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ export function ClusterSidecar({ cluster }: ClusterSidecarProps): ReactElement {
2020
width={200}
2121
display-desktopSmall-down="none"
2222
>
23-
{cluster.consoleUrl && (
24-
<Button
25-
as="a"
26-
href={ensureURLValidity(cluster.consoleUrl)}
27-
target="_blank"
28-
rel="noopener noreferrer"
29-
>
30-
Launch Console
31-
</Button>
32-
)}
3323
<Sidecar heading="Metadata">
3424
<SidecarItem heading="Cluster name">{cluster.name}</SidecarItem>
3525
<SidecarItem heading="Status">

0 commit comments

Comments
 (0)