Skip to content

Commit a756f3a

Browse files
committed
enrich support links from backend
1 parent c92370b commit a756f3a

File tree

2 files changed

+14
-32
lines changed

2 files changed

+14
-32
lines changed

coderd/appearance/appearance.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ package appearance
22

33
import (
44
"context"
5+
"fmt"
6+
"strings"
57

8+
"github.com/coder/coder/v2/buildinfo"
69
"github.com/coder/coder/v2/codersdk"
710
)
811

@@ -11,20 +14,21 @@ type Fetcher interface {
1114
}
1215

1316
func DefaultSupportLinks(docsURL string) []codersdk.LinkConfig {
17+
version := buildinfo.Version()
1418
if docsURL == "" {
15-
docsURL = "https://coder.com/docs/{CODER_VERSION}"
19+
docsURL = "https://coder.com/docs/@" + strings.Split(version, "-")[0]
1620
}
21+
buildInfo := fmt.Sprintf("Version: [`%s`](%s)", version, buildinfo.ExternalURL())
1722

18-
docsLink := codersdk.LinkConfig{
19-
Name: "Documentation",
20-
Target: docsURL,
21-
Icon: "docs",
22-
}
23-
24-
defaultSupportLinks := []codersdk.LinkConfig{
23+
return []codersdk.LinkConfig{
24+
{
25+
Name: "Documentation",
26+
Target: docsURL,
27+
Icon: "docs",
28+
},
2529
{
2630
Name: "Report a bug",
27-
Target: "https://github.com/coder/coder/issues/new?labels=needs+grooming&body={CODER_BUILD_INFO}",
31+
Target: "https://github.com/coder/coder/issues/new?labels=needs+grooming&body=" + buildInfo,
2832
Icon: "bug",
2933
},
3034
{
@@ -38,8 +42,6 @@ func DefaultSupportLinks(docsURL string) []codersdk.LinkConfig {
3842
Icon: "star",
3943
},
4044
}
41-
42-
return append([]codersdk.LinkConfig{docsLink}, defaultSupportLinks...)
4345
}
4446

4547
type AGPLFetcher struct {

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

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const UserDropdownContent: FC<UserDropdownContentProps> = ({
9393
<Divider />
9494
{supportLinks.map((link) => (
9595
<a
96-
href={includeBuildInfo(link.target, buildInfo)}
96+
href={link.target}
9797
key={link.name}
9898
target="_blank"
9999
rel="noreferrer"
@@ -177,26 +177,6 @@ export const GithubStar: FC<SvgIconProps> = (props) => (
177177
</svg>
178178
);
179179

180-
const includeBuildInfo = (
181-
href: string,
182-
buildInfo?: TypesGen.BuildInfoResponse,
183-
): string => {
184-
let version = encodeURIComponent((buildInfo?.version ?? "").split("-")[0]);
185-
if (version) {
186-
// Not encoding the @ because it makes the link look a bit weird.
187-
version = `@${version}`;
188-
}
189-
190-
return href
191-
.replace(
192-
"{CODER_BUILD_INFO}",
193-
`${encodeURIComponent(
194-
`Version: [\`${buildInfo?.version}\`](${buildInfo?.external_url})`,
195-
)}`,
196-
)
197-
.replace("{CODER_VERSION}", version);
198-
};
199-
200180
const styles = {
201181
info: (theme) => [
202182
theme.typography.body2 as CSSObject,

0 commit comments

Comments
 (0)