Skip to content

feat: add app sharing icon and tooltip #4556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions site/src/components/AppLink/AppLink.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ WithIcon.args = {
workspaceName: MockWorkspace.name,
appName: "code-server",
appIcon: "/icon/code.svg",
appSharingLevel: "owner",
health: "healthy",
}

Expand All @@ -23,6 +24,7 @@ WithoutIcon.args = {
username: "developer",
workspaceName: MockWorkspace.name,
appName: "code-server",
appSharingLevel: "owner",
health: "healthy",
}

Expand All @@ -31,6 +33,7 @@ HealthDisabled.args = {
username: "developer",
workspaceName: MockWorkspace.name,
appName: "code-server",
appSharingLevel: "owner",
health: "disabled",
}

Expand Down
35 changes: 29 additions & 6 deletions site/src/components/AppLink/AppLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import Link from "@material-ui/core/Link"
import { makeStyles } from "@material-ui/core/styles"
import Tooltip from "@material-ui/core/Tooltip"
import ComputerIcon from "@material-ui/icons/Computer"
import PublicOutlinedIcon from "@material-ui/icons/PublicOutlined"
import LockOutlinedIcon from "@material-ui/icons/LockOutlined"
import GroupOutlinedIcon from "@material-ui/icons/GroupOutlined"
import ErrorOutlineIcon from "@material-ui/icons/ErrorOutline"
import { FC, PropsWithChildren } from "react"
import * as TypesGen from "../../api/typesGenerated"
Expand All @@ -23,6 +26,7 @@ export interface AppLinkProps {
appIcon?: TypesGen.WorkspaceApp["icon"]
appCommand?: TypesGen.WorkspaceApp["command"]
appSubdomain: TypesGen.WorkspaceApp["subdomain"]
appSharingLevel: TypesGen.WorkspaceApp["sharing_level"]
health: TypesGen.WorkspaceApp["health"]
}

Expand All @@ -35,6 +39,7 @@ export const AppLink: FC<PropsWithChildren<AppLinkProps>> = ({
appIcon,
appCommand,
appSubdomain,
appSharingLevel,
health,
}) => {
const styles = useStyles()
Expand All @@ -60,36 +65,50 @@ export const AppLink: FC<PropsWithChildren<AppLinkProps>> = ({
) : (
<ComputerIcon />
)
let tooltip = ""

let shareIcon = <LockOutlinedIcon />
let shareTooltip = "Private, only accessible by you"
if (appSharingLevel === "authenticated") {
shareIcon = <GroupOutlinedIcon />
shareTooltip = "Shared with all authenticated users"
}
if (appSharingLevel === "public") {
shareIcon = <PublicOutlinedIcon />
shareTooltip = "Shared publicly"
}

let primaryTooltip = ""
if (health === "initializing") {
canClick = false
icon = <CircularProgress size={16} />
tooltip = "Initializing..."
primaryTooltip = "Initializing..."
}
if (health === "unhealthy") {
canClick = false
icon = <ErrorOutlineIcon className={styles.unhealthyIcon} />
tooltip = "Unhealthy"
primaryTooltip = "Unhealthy"
}
if (!appsHost && appSubdomain) {
canClick = false
icon = <ErrorOutlineIcon className={styles.notConfiguredIcon} />
tooltip = "Your admin has not configured subdomain application access"
primaryTooltip =
"Your admin has not configured subdomain application access"
}

const button = (
<Button
size="small"
startIcon={icon}
endIcon={<Tooltip title={shareTooltip}>{shareIcon}</Tooltip>}
className={styles.button}
disabled={!canClick}
>
{appName}
<span className={styles.appName}>{appName}</span>
</Button>
)

return (
<Tooltip title={tooltip}>
<Tooltip title={primaryTooltip}>
<span>
<Link
href={href}
Expand Down Expand Up @@ -136,4 +155,8 @@ const useStyles = makeStyles((theme) => ({
notConfiguredIcon: {
color: theme.palette.grey[300],
},

appName: {
marginRight: theme.spacing(1),
},
}))
3 changes: 2 additions & 1 deletion site/src/components/PortForwardButton/PortForwardButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ const EnabledView: React.FC<PortForwardButtonProps> = (props) => {
<HelpTooltipText>
Access ports running on the agent with the{" "}
<strong>port, agent name, workspace name</strong> and{" "}
<strong>your username</strong> URL schema, as shown below.
<strong>your username</strong> URL schema, as shown below. Port URLs are
only accessible by you.
</HelpTooltipText>

<CodeExample code={urlExample} className={styles.code} />
Expand Down
1 change: 1 addition & 0 deletions site/src/components/Resources/Resources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export const Resources: FC<React.PropsWithChildren<ResourcesProps>> = ({
appName={app.name}
appCommand={app.command}
appSubdomain={app.subdomain}
appSharingLevel={app.sharing_level}
username={workspace.owner_name}
workspaceName={workspace.name}
agentName={agent.name}
Expand Down