Skip to content

feat: support links with custom icons #11629

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
Jan 15, 2024
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
7 changes: 6 additions & 1 deletion coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -1890,7 +1890,7 @@ type SupportConfig struct {
type LinkConfig struct {
Name string `json:"name" yaml:"name"`
Target string `json:"target" yaml:"target"`
Icon string `json:"icon" yaml:"icon"`
Icon string `json:"icon" yaml:"icon" enums:"bug,chat,docs"`
}

// DeploymentOptionsWithoutSecrets returns a copy of the OptionSet with secret values omitted.
Expand Down
2 changes: 1 addition & 1 deletion docs/api/enterprise.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/api/general.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions docs/api/schemas.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const meta: Meta<typeof UserDropdown> = {
{ icon: "docs", name: "Documentation", target: "" },
{ icon: "bug", name: "Report a bug", target: "" },
{ icon: "chat", name: "Join the Coder Discord", target: "" },
{ icon: "/icon/aws.svg", name: "Amazon Web Services", target: "" },
],
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
type Theme,
} from "@emotion/react";
import { usePopover } from "components/Popover/Popover";
import { ExternalImage } from "components/ExternalImage/ExternalImage";

export const Language = {
accountLabel: "Account",
Expand Down Expand Up @@ -98,6 +99,24 @@ export const UserDropdownContent: FC<UserDropdownContentProps> = ({
popover.setIsOpen(false);
};

const renderMenuIcon = (icon: string): JSX.Element => {
switch (icon) {
case "bug":
return <BugIcon css={styles.menuItemIcon} />;
case "chat":
return <ChatIcon css={styles.menuItemIcon} />;
case "docs":
return <DocsIcon css={styles.menuItemIcon} />;
default:
return (
<ExternalImage
src={icon}
css={{ maxWidth: "20px", maxHeight: "20px" }}
/>
);
}
};

return (
<div>
<Stack css={styles.info} spacing={0}>
Expand Down Expand Up @@ -131,9 +150,7 @@ export const UserDropdownContent: FC<UserDropdownContentProps> = ({
css={styles.link}
>
<MenuItem css={styles.menuItem} onClick={onPopoverClose}>
{link.icon === "bug" && <BugIcon css={styles.menuItemIcon} />}
{link.icon === "chat" && <ChatIcon css={styles.menuItemIcon} />}
{link.icon === "docs" && <DocsIcon css={styles.menuItemIcon} />}
{renderMenuIcon(link.icon)}
<span css={styles.menuItemText}>{link.name}</span>
</MenuItem>
</a>
Expand Down