Skip to content

Commit 466004d

Browse files
committed
add version through frontend
1 parent f9dfb4e commit 466004d

File tree

4 files changed

+38
-26
lines changed

4 files changed

+38
-26
lines changed

coderd/appearance/appearance.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,9 @@ type Fetcher interface {
1010
Fetch(ctx context.Context) (codersdk.AppearanceConfig, error)
1111
}
1212

13-
var defaultSupportLinks = []codersdk.LinkConfig{
14-
{
15-
Name: "Report a bug",
16-
Target: "https://github.com/coder/coder/issues/new?labels=needs+grooming&body={CODER_BUILD_INFO}",
17-
Icon: "bug",
18-
},
19-
{
20-
Name: "Join the Coder Discord",
21-
Target: "https://coder.com/chat?utm_source=coder&utm_medium=coder&utm_campaign=server-footer",
22-
Icon: "chat",
23-
},
24-
{
25-
Name: "Star the Repo",
26-
Target: "https://github.com/coder/coder",
27-
Icon: "star",
28-
},
29-
}
30-
3113
func DefaultSupportLinks(docsURL string) []codersdk.LinkConfig {
3214
if docsURL == "" {
33-
docsURL = "https://coder.com/docs/coder-oss"
15+
docsURL = "https://coder.com/docs/{CODER_VERSION}"
3416
}
3517

3618
docsLink := codersdk.LinkConfig{
@@ -39,6 +21,24 @@ func DefaultSupportLinks(docsURL string) []codersdk.LinkConfig {
3921
Icon: "docs",
4022
}
4123

24+
defaultSupportLinks := []codersdk.LinkConfig{
25+
{
26+
Name: "Report a bug",
27+
Target: "https://github.com/coder/coder/issues/new?labels=needs+grooming&body={CODER_BUILD_INFO}",
28+
Icon: "bug",
29+
},
30+
{
31+
Name: "Join the Coder Discord",
32+
Target: "https://coder.com/chat?utm_source=coder&utm_medium=coder&utm_campaign=server-footer",
33+
Icon: "chat",
34+
},
35+
{
36+
Name: "Star the Repo",
37+
Target: "https://github.com/coder/coder",
38+
Icon: "star",
39+
},
40+
}
41+
4242
return append([]codersdk.LinkConfig{docsLink}, defaultSupportLinks...)
4343
}
4444

enterprise/coderd/appearance.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ type appearanceFetcher struct {
4545
database database.Store
4646
supportLinks []codersdk.LinkConfig
4747
docsURL string
48+
coderVersion string
4849
}
4950

50-
func newAppearanceFetcher(store database.Store, links []codersdk.LinkConfig, docsURL string) agpl.Fetcher {
51+
func newAppearanceFetcher(store database.Store, links []codersdk.LinkConfig, docsURL, coderVersion string) agpl.Fetcher {
5152
return &appearanceFetcher{
5253
database: store,
5354
supportLinks: links,
5455
docsURL: docsURL,
56+
coderVersion: coderVersion,
5557
}
5658
}
5759

enterprise/coderd/coderd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"sync"
1313
"time"
1414

15+
"github.com/coder/coder/v2/buildinfo"
1516
"github.com/coder/coder/v2/coderd/appearance"
1617
"github.com/coder/coder/v2/coderd/database"
1718
agplportsharing "github.com/coder/coder/v2/coderd/portsharing"
@@ -791,6 +792,7 @@ func (api *API) updateEntitlements(ctx context.Context) error {
791792
api.Database,
792793
api.DeploymentValues.Support.Links.Value,
793794
api.DeploymentValues.DocsURL.String(),
795+
buildinfo.Version(),
794796
)
795797
api.AGPL.AppearanceFetcher.Store(&f)
796798
} else {

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,20 @@ const includeBuildInfo = (
181181
href: string,
182182
buildInfo?: TypesGen.BuildInfoResponse,
183183
): string => {
184-
return href.replace(
185-
"{CODER_BUILD_INFO}",
186-
`${encodeURIComponent(
187-
`Version: [\`${buildInfo?.version}\`](${buildInfo?.external_url})`,
188-
)}`,
189-
);
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);
190198
};
191199

192200
const styles = {

0 commit comments

Comments
 (0)