Skip to content

Commit f2a4105

Browse files
authored
feat: add support buttons (coder#20339)
Fixes: coder#16804
1 parent aa689cb commit f2a4105

16 files changed

Lines changed: 237 additions & 73 deletions

File tree

coderd/apidoc/docs.go

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codersdk/deployment.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -984,9 +984,10 @@ func DefaultSupportLinks(docsURL string) []LinkConfig {
984984
Icon: "bug",
985985
},
986986
{
987-
Name: "Join the Coder Discord",
988-
Target: "https://coder.com/chat?utm_source=coder&utm_medium=coder&utm_campaign=server-footer",
989-
Icon: "chat",
987+
Name: "Join the Coder Discord",
988+
Target: "https://discord.gg/coder",
989+
Icon: "chat",
990+
Location: "navbar",
990991
},
991992
{
992993
Name: "Star the Repo",
@@ -3339,7 +3340,9 @@ type SupportConfig struct {
33393340
type LinkConfig struct {
33403341
Name string `json:"name" yaml:"name"`
33413342
Target string `json:"target" yaml:"target"`
3342-
Icon string `json:"icon" yaml:"icon" enums:"bug,chat,docs"`
3343+
Icon string `json:"icon" yaml:"icon" enums:"bug,chat,docs,star"`
3344+
3345+
Location string `json:"location,omitempty" yaml:"location,omitempty" enums:"navbar,dropdown"`
33433346
}
33443347

33453348
// Validate checks cross-field constraints for deployment values.

docs/reference/api/enterprise.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/api/general.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/api/schemas.md

Lines changed: 20 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

enterprise/coderd/appearance_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,17 @@ func TestCustomSupportLinks(t *testing.T) {
201201
Target: "http://second-link-2",
202202
Icon: "bug",
203203
},
204+
{
205+
Name: "First button",
206+
Target: "http://first-button-1",
207+
Icon: "bug",
208+
Location: "navbar",
209+
},
210+
{
211+
Name: "Third link",
212+
Target: "http://third-link-3",
213+
Icon: "star",
214+
},
204215
}
205216
cfg := coderdtest.DeploymentValues(t)
206217
cfg.Support.Links = serpent.Struct[[]codersdk.LinkConfig]{

site/src/api/typesGenerated.ts

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/modules/dashboard/Navbar/Navbar.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { buildInfo } from "api/queries/buildInfo";
2+
import type { LinkConfig } from "api/typesGenerated";
23
import { useProxy } from "contexts/ProxyContext";
34
import { useAuthenticated } from "hooks";
45
import { useEmbeddedMetadata } from "hooks/useEmbeddedMetadata";
@@ -25,12 +26,18 @@ export const Navbar: FC = () => {
2526
const canViewConnectionLog =
2627
featureVisibility.connection_log && permissions.viewAnyConnectionLog;
2728

29+
const uniqueLinks = new Map<string, LinkConfig>();
30+
for (const link of appearance.support_links ?? []) {
31+
if (!uniqueLinks.has(link.name)) {
32+
uniqueLinks.set(link.name, link);
33+
}
34+
}
2835
return (
2936
<NavbarView
3037
user={me}
3138
logo_url={appearance.logo_url}
3239
buildInfo={buildInfoQuery.data}
33-
supportLinks={appearance.support_links}
40+
supportLinks={Array.from(uniqueLinks.values())}
3441
onSignOut={signOut}
3542
canViewDeployment={canViewDeployment}
3643
canViewOrganizations={canViewOrganizations}

site/src/modules/dashboard/Navbar/NavbarView.stories.tsx

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const meta: Meta<typeof NavbarView> = {
3333
canViewDeployment: true,
3434
canViewHealth: true,
3535
canViewOrganizations: true,
36+
supportLinks: [],
3637
},
3738
decorators: [withDashboardProvider],
3839
};
@@ -129,3 +130,64 @@ export const IdleTasks: Story = {
129130
],
130131
},
131132
};
133+
134+
export const SupportLinks: Story = {
135+
args: {
136+
user: MockUserMember,
137+
canViewAuditLog: false,
138+
canViewDeployment: false,
139+
canViewHealth: false,
140+
canViewOrganizations: false,
141+
supportLinks: [
142+
{
143+
name: "This is a bug",
144+
icon: "bug",
145+
target: "#",
146+
},
147+
{
148+
name: "This is a star",
149+
icon: "star",
150+
target: "#",
151+
location: "navbar",
152+
},
153+
{
154+
name: "This is a chat",
155+
icon: "chat",
156+
target: "#",
157+
location: "navbar",
158+
},
159+
{
160+
name: "No icon here",
161+
icon: "",
162+
target: "#",
163+
location: "navbar",
164+
},
165+
{
166+
name: "No icon here too",
167+
icon: "",
168+
target: "#",
169+
},
170+
],
171+
},
172+
};
173+
174+
export const DefaultSupportLinks: Story = {
175+
args: {
176+
user: MockUserMember,
177+
canViewAuditLog: false,
178+
canViewDeployment: false,
179+
canViewHealth: false,
180+
canViewOrganizations: false,
181+
supportLinks: [
182+
{ icon: "docs", name: "Documentation", target: "" },
183+
{ icon: "bug", name: "Report a bug", target: "" },
184+
{
185+
icon: "chat",
186+
name: "Join the Coder Discord",
187+
target: "",
188+
location: "navbar",
189+
},
190+
{ icon: "star", name: "Star the Repo", target: "" },
191+
],
192+
},
193+
};

0 commit comments

Comments
 (0)