mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
feat: support links with custom icons (#11629)
This commit is contained in:
7
coderd/apidoc/docs.go
generated
7
coderd/apidoc/docs.go
generated
@ -9530,7 +9530,12 @@ const docTemplate = `{
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"icon": {
|
"icon": {
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"bug",
|
||||||
|
"chat",
|
||||||
|
"docs"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
3
coderd/apidoc/swagger.json
generated
3
coderd/apidoc/swagger.json
generated
@ -8556,7 +8556,8 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"icon": {
|
"icon": {
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"enum": ["bug", "chat", "docs"]
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
@ -1890,7 +1890,7 @@ type SupportConfig struct {
|
|||||||
type LinkConfig struct {
|
type LinkConfig struct {
|
||||||
Name string `json:"name" yaml:"name"`
|
Name string `json:"name" yaml:"name"`
|
||||||
Target string `json:"target" yaml:"target"`
|
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.
|
// DeploymentOptionsWithoutSecrets returns a copy of the OptionSet with secret values omitted.
|
||||||
|
2
docs/api/enterprise.md
generated
2
docs/api/enterprise.md
generated
@ -28,7 +28,7 @@ curl -X GET http://coder-server:8080/api/v2/appearance \
|
|||||||
},
|
},
|
||||||
"support_links": [
|
"support_links": [
|
||||||
{
|
{
|
||||||
"icon": "string",
|
"icon": "bug",
|
||||||
"name": "string",
|
"name": "string",
|
||||||
"target": "string"
|
"target": "string"
|
||||||
}
|
}
|
||||||
|
2
docs/api/general.md
generated
2
docs/api/general.md
generated
@ -343,7 +343,7 @@ curl -X GET http://coder-server:8080/api/v2/deployment/config \
|
|||||||
"links": {
|
"links": {
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"icon": "string",
|
"icon": "bug",
|
||||||
"name": "string",
|
"name": "string",
|
||||||
"target": "string"
|
"target": "string"
|
||||||
}
|
}
|
||||||
|
20
docs/api/schemas.md
generated
20
docs/api/schemas.md
generated
@ -717,7 +717,7 @@ _None_
|
|||||||
{
|
{
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"icon": "string",
|
"icon": "bug",
|
||||||
"name": "string",
|
"name": "string",
|
||||||
"target": "string"
|
"target": "string"
|
||||||
}
|
}
|
||||||
@ -1024,7 +1024,7 @@ _None_
|
|||||||
},
|
},
|
||||||
"support_links": [
|
"support_links": [
|
||||||
{
|
{
|
||||||
"icon": "string",
|
"icon": "bug",
|
||||||
"name": "string",
|
"name": "string",
|
||||||
"target": "string"
|
"target": "string"
|
||||||
}
|
}
|
||||||
@ -2277,7 +2277,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
|||||||
"links": {
|
"links": {
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"icon": "string",
|
"icon": "bug",
|
||||||
"name": "string",
|
"name": "string",
|
||||||
"target": "string"
|
"target": "string"
|
||||||
}
|
}
|
||||||
@ -2655,7 +2655,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
|||||||
"links": {
|
"links": {
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"icon": "string",
|
"icon": "bug",
|
||||||
"name": "string",
|
"name": "string",
|
||||||
"target": "string"
|
"target": "string"
|
||||||
}
|
}
|
||||||
@ -3359,7 +3359,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"icon": "string",
|
"icon": "bug",
|
||||||
"name": "string",
|
"name": "string",
|
||||||
"target": "string"
|
"target": "string"
|
||||||
}
|
}
|
||||||
@ -3373,6 +3373,14 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
|||||||
| `name` | string | false | | |
|
| `name` | string | false | | |
|
||||||
| `target` | string | false | | |
|
| `target` | string | false | | |
|
||||||
|
|
||||||
|
#### Enumerated Values
|
||||||
|
|
||||||
|
| Property | Value |
|
||||||
|
| -------- | ------ |
|
||||||
|
| `icon` | `bug` |
|
||||||
|
| `icon` | `chat` |
|
||||||
|
| `icon` | `docs` |
|
||||||
|
|
||||||
## codersdk.LogLevel
|
## codersdk.LogLevel
|
||||||
|
|
||||||
```json
|
```json
|
||||||
@ -4455,7 +4463,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
|||||||
"links": {
|
"links": {
|
||||||
"value": [
|
"value": [
|
||||||
{
|
{
|
||||||
"icon": "string",
|
"icon": "bug",
|
||||||
"name": "string",
|
"name": "string",
|
||||||
"target": "string"
|
"target": "string"
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ const meta: Meta<typeof UserDropdown> = {
|
|||||||
{ icon: "docs", name: "Documentation", target: "" },
|
{ icon: "docs", name: "Documentation", target: "" },
|
||||||
{ icon: "bug", name: "Report a bug", target: "" },
|
{ icon: "bug", name: "Report a bug", target: "" },
|
||||||
{ icon: "chat", name: "Join the Coder Discord", target: "" },
|
{ icon: "chat", name: "Join the Coder Discord", target: "" },
|
||||||
|
{ icon: "/icon/aws.svg", name: "Amazon Web Services", target: "" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -17,6 +17,7 @@ import {
|
|||||||
type Theme,
|
type Theme,
|
||||||
} from "@emotion/react";
|
} from "@emotion/react";
|
||||||
import { usePopover } from "components/Popover/Popover";
|
import { usePopover } from "components/Popover/Popover";
|
||||||
|
import { ExternalImage } from "components/ExternalImage/ExternalImage";
|
||||||
|
|
||||||
export const Language = {
|
export const Language = {
|
||||||
accountLabel: "Account",
|
accountLabel: "Account",
|
||||||
@ -98,6 +99,24 @@ export const UserDropdownContent: FC<UserDropdownContentProps> = ({
|
|||||||
popover.setIsOpen(false);
|
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 (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Stack css={styles.info} spacing={0}>
|
<Stack css={styles.info} spacing={0}>
|
||||||
@ -131,9 +150,7 @@ export const UserDropdownContent: FC<UserDropdownContentProps> = ({
|
|||||||
css={styles.link}
|
css={styles.link}
|
||||||
>
|
>
|
||||||
<MenuItem css={styles.menuItem} onClick={onPopoverClose}>
|
<MenuItem css={styles.menuItem} onClick={onPopoverClose}>
|
||||||
{link.icon === "bug" && <BugIcon css={styles.menuItemIcon} />}
|
{renderMenuIcon(link.icon)}
|
||||||
{link.icon === "chat" && <ChatIcon css={styles.menuItemIcon} />}
|
|
||||||
{link.icon === "docs" && <DocsIcon css={styles.menuItemIcon} />}
|
|
||||||
<span css={styles.menuItemText}>{link.name}</span>
|
<span css={styles.menuItemText}>{link.name}</span>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</a>
|
</a>
|
||||||
|
Reference in New Issue
Block a user