Skip to content

Commit 1515d75

Browse files
feat: add app sharing icon and tooltip (#4556)
Co-authored-by: Joe Previte <jjprevite@gmail.com>
1 parent 7ec88bf commit 1515d75

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

site/src/components/AppLink/AppLink.stories.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ WithIcon.args = {
1515
workspaceName: MockWorkspace.name,
1616
appName: "code-server",
1717
appIcon: "/icon/code.svg",
18+
appSharingLevel: "owner",
1819
health: "healthy",
1920
}
2021

@@ -23,6 +24,7 @@ WithoutIcon.args = {
2324
username: "developer",
2425
workspaceName: MockWorkspace.name,
2526
appName: "code-server",
27+
appSharingLevel: "owner",
2628
health: "healthy",
2729
}
2830

@@ -31,6 +33,7 @@ HealthDisabled.args = {
3133
username: "developer",
3234
workspaceName: MockWorkspace.name,
3335
appName: "code-server",
36+
appSharingLevel: "owner",
3437
health: "disabled",
3538
}
3639

site/src/components/AppLink/AppLink.tsx

+29-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import Link from "@material-ui/core/Link"
44
import { makeStyles } from "@material-ui/core/styles"
55
import Tooltip from "@material-ui/core/Tooltip"
66
import ComputerIcon from "@material-ui/icons/Computer"
7+
import PublicOutlinedIcon from "@material-ui/icons/PublicOutlined"
8+
import LockOutlinedIcon from "@material-ui/icons/LockOutlined"
9+
import GroupOutlinedIcon from "@material-ui/icons/GroupOutlined"
710
import ErrorOutlineIcon from "@material-ui/icons/ErrorOutline"
811
import { FC, PropsWithChildren } from "react"
912
import * as TypesGen from "../../api/typesGenerated"
@@ -23,6 +26,7 @@ export interface AppLinkProps {
2326
appIcon?: TypesGen.WorkspaceApp["icon"]
2427
appCommand?: TypesGen.WorkspaceApp["command"]
2528
appSubdomain: TypesGen.WorkspaceApp["subdomain"]
29+
appSharingLevel: TypesGen.WorkspaceApp["sharing_level"]
2630
health: TypesGen.WorkspaceApp["health"]
2731
}
2832

@@ -35,6 +39,7 @@ export const AppLink: FC<PropsWithChildren<AppLinkProps>> = ({
3539
appIcon,
3640
appCommand,
3741
appSubdomain,
42+
appSharingLevel,
3843
health,
3944
}) => {
4045
const styles = useStyles()
@@ -60,36 +65,50 @@ export const AppLink: FC<PropsWithChildren<AppLinkProps>> = ({
6065
) : (
6166
<ComputerIcon />
6267
)
63-
let tooltip = ""
68+
69+
let shareIcon = <LockOutlinedIcon />
70+
let shareTooltip = "Private, only accessible by you"
71+
if (appSharingLevel === "authenticated") {
72+
shareIcon = <GroupOutlinedIcon />
73+
shareTooltip = "Shared with all authenticated users"
74+
}
75+
if (appSharingLevel === "public") {
76+
shareIcon = <PublicOutlinedIcon />
77+
shareTooltip = "Shared publicly"
78+
}
79+
80+
let primaryTooltip = ""
6481
if (health === "initializing") {
6582
canClick = false
6683
icon = <CircularProgress size={16} />
67-
tooltip = "Initializing..."
84+
primaryTooltip = "Initializing..."
6885
}
6986
if (health === "unhealthy") {
7087
canClick = false
7188
icon = <ErrorOutlineIcon className={styles.unhealthyIcon} />
72-
tooltip = "Unhealthy"
89+
primaryTooltip = "Unhealthy"
7390
}
7491
if (!appsHost && appSubdomain) {
7592
canClick = false
7693
icon = <ErrorOutlineIcon className={styles.notConfiguredIcon} />
77-
tooltip = "Your admin has not configured subdomain application access"
94+
primaryTooltip =
95+
"Your admin has not configured subdomain application access"
7896
}
7997

8098
const button = (
8199
<Button
82100
size="small"
83101
startIcon={icon}
102+
endIcon={<Tooltip title={shareTooltip}>{shareIcon}</Tooltip>}
84103
className={styles.button}
85104
disabled={!canClick}
86105
>
87-
{appName}
106+
<span className={styles.appName}>{appName}</span>
88107
</Button>
89108
)
90109

91110
return (
92-
<Tooltip title={tooltip}>
111+
<Tooltip title={primaryTooltip}>
93112
<span>
94113
<Link
95114
href={href}
@@ -136,4 +155,8 @@ const useStyles = makeStyles((theme) => ({
136155
notConfiguredIcon: {
137156
color: theme.palette.grey[300],
138157
},
158+
159+
appName: {
160+
marginRight: theme.spacing(1),
161+
},
139162
}))

site/src/components/PortForwardButton/PortForwardButton.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ const EnabledView: React.FC<PortForwardButtonProps> = (props) => {
6464
<HelpTooltipText>
6565
Access ports running on the agent with the{" "}
6666
<strong>port, agent name, workspace name</strong> and{" "}
67-
<strong>your username</strong> URL schema, as shown below.
67+
<strong>your username</strong> URL schema, as shown below. Port URLs are
68+
only accessible by you.
6869
</HelpTooltipText>
6970

7071
<CodeExample code={urlExample} className={styles.code} />

site/src/components/Resources/Resources.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ export const Resources: FC<React.PropsWithChildren<ResourcesProps>> = ({
203203
appName={app.name}
204204
appCommand={app.command}
205205
appSubdomain={app.subdomain}
206+
appSharingLevel={app.sharing_level}
206207
username={workspace.owner_name}
207208
workspaceName={workspace.name}
208209
agentName={agent.name}

0 commit comments

Comments
 (0)