Skip to content

chore(UI): remove private icon from apps in dashboard #6801

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
Mar 27, 2023
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
29 changes: 24 additions & 5 deletions site/src/components/AppLink/AppLink.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ WithIcon.args = {
agent: MockWorkspaceAgent,
}

export const WithIconExternal = Template.bind({})
WithIconExternal.args = {
export const ExternalApp = Template.bind({})
ExternalApp.args = {
workspace: MockWorkspace,
app: {
...MockWorkspaceApp,
Expand All @@ -35,13 +35,32 @@ WithIconExternal.args = {
agent: MockWorkspaceAgent,
}

export const WithoutIcon = Template.bind({})
WithoutIcon.args = {
export const SharingLevelOwner = Template.bind({})
SharingLevelOwner.args = {
workspace: MockWorkspace,
app: {
...MockWorkspaceApp,
sharing_level: "owner",
health: "healthy",
},
agent: MockWorkspaceAgent,
}

export const SharingLevelAuthenticated = Template.bind({})
SharingLevelAuthenticated.args = {
workspace: MockWorkspace,
app: {
...MockWorkspaceApp,
sharing_level: "authenticated",
},
agent: MockWorkspaceAgent,
}

export const SharingLevelPublic = Template.bind({})
SharingLevelPublic.args = {
workspace: MockWorkspace,
app: {
...MockWorkspaceApp,
sharing_level: "public",
},
agent: MockWorkspaceAgent,
}
Expand Down
9 changes: 7 additions & 2 deletions site/src/components/AppLink/AppLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { makeStyles } from "@material-ui/core/styles"
import Tooltip from "@material-ui/core/Tooltip"
import ErrorOutlineIcon from "@material-ui/icons/ErrorOutline"
import { FC } from "react"
import { combineClasses } from "util/combineClasses"
import * as TypesGen from "../../api/typesGenerated"
import { generateRandomString } from "../../util/random"
import { BaseIcon } from "./BaseIcon"
Expand Down Expand Up @@ -79,15 +80,19 @@ export const AppLink: FC<AppLinkProps> = ({
"Your admin has not configured subdomain application access"
}

const isPrivateApp = app.sharing_level === "owner"

const button = (
<Button
size="small"
startIcon={icon}
endIcon={<ShareIcon app={app} />}
endIcon={isPrivateApp ? undefined : <ShareIcon app={app} />}
className={styles.button}
disabled={!canClick}
>
<span className={styles.appName}>{appDisplayName}</span>
<span className={combineClasses({ [styles.appName]: !isPrivateApp })}>
{appDisplayName}
</span>
</Button>
)

Expand Down
Empty file.
34 changes: 19 additions & 15 deletions site/src/components/AppLink/ShareIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import PublicOutlinedIcon from "@material-ui/icons/PublicOutlined"
import LockOutlinedIcon from "@material-ui/icons/LockOutlined"
import GroupOutlinedIcon from "@material-ui/icons/GroupOutlined"
import LaunchOutlinedIcon from "@material-ui/icons/LaunchOutlined"
import { FC } from "react"
import * as TypesGen from "../../api/typesGenerated"
import Tooltip from "@material-ui/core/Tooltip"
import { useTranslation } from "react-i18next"
Expand All @@ -11,23 +9,29 @@ export interface ShareIconProps {
app: TypesGen.WorkspaceApp
}

export const ShareIcon: FC<ShareIconProps> = ({ app }) => {
export const ShareIcon = ({ app }: ShareIconProps) => {
const { t } = useTranslation("agent")

let shareIcon = <LockOutlinedIcon />
let shareTooltip = t("shareTooltip.private")
if (app.external) {
return (
<Tooltip title={t("shareTooltip.external")}>
<LaunchOutlinedIcon />
</Tooltip>
)
}
if (app.sharing_level === "authenticated") {
shareIcon = <GroupOutlinedIcon />
shareTooltip = t("shareTooltip.authenticated")
return (
<Tooltip title={t("shareTooltip.authenticated")}>
<GroupOutlinedIcon />
</Tooltip>
)
}
if (app.sharing_level === "public") {
shareIcon = <PublicOutlinedIcon />
shareTooltip = t("shareTooltip.public")
}
if (app.external) {
shareIcon = <LaunchOutlinedIcon />
shareTooltip = t("shareTooltip.external")
return (
<Tooltip title={t("shareTooltip.public")}>
<PublicOutlinedIcon />
</Tooltip>
)
}

return <Tooltip title={shareTooltip}>{shareIcon}</Tooltip>
return null
}