Skip to content

Commit 3464ad2

Browse files
committed
feat: expose deployment_id in the user dropdown
1 parent 15157c1 commit 3464ad2

File tree

10 files changed

+66
-11
lines changed

10 files changed

+66
-11
lines changed

coderd/apidoc/docs.go

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

coderd/apidoc/swagger.json

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

coderd/coderd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ func New(options *Options) *API {
735735
// All CSP errors will be logged
736736
r.Post("/csp/reports", api.logReportCSPViolations)
737737

738-
r.Get("/buildinfo", buildInfo(api.AccessURL, api.DeploymentValues.CLIUpgradeMessage.String()))
738+
r.Get("/buildinfo", buildInfo(api.AccessURL, api.DeploymentValues.CLIUpgradeMessage.String(), api.DeploymentID))
739739
// /regions is overridden in the enterprise version
740740
r.Group(func(r chi.Router) {
741741
r.Use(apiKeyMiddleware)

coderd/deployment.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (api *API) deploymentStats(rw http.ResponseWriter, r *http.Request) {
6868
// @Tags General
6969
// @Success 200 {object} codersdk.BuildInfoResponse
7070
// @Router /buildinfo [get]
71-
func buildInfo(accessURL *url.URL, upgradeMessage string) http.HandlerFunc {
71+
func buildInfo(accessURL *url.URL, upgradeMessage, deploymentID string) http.HandlerFunc {
7272
return func(rw http.ResponseWriter, r *http.Request) {
7373
httpapi.Write(r.Context(), rw, http.StatusOK, codersdk.BuildInfoResponse{
7474
ExternalURL: buildinfo.ExternalURL(),
@@ -77,6 +77,7 @@ func buildInfo(accessURL *url.URL, upgradeMessage string) http.HandlerFunc {
7777
DashboardURL: accessURL.String(),
7878
WorkspaceProxy: false,
7979
UpgradeMessage: upgradeMessage,
80+
DeploymentID: deploymentID,
8081
})
8182
}
8283
}

codersdk/deployment.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,6 +2151,9 @@ type BuildInfoResponse struct {
21512151
// UpgradeMessage is the message displayed to users when an outdated client
21522152
// is detected.
21532153
UpgradeMessage string `json:"upgrade_message"`
2154+
2155+
// DeploymentID is the unique identifier for this deployment.
2156+
DeploymentID string `json:"deployment_id"`
21542157
}
21552158

21562159
type WorkspaceProxyBuildInfo struct {

docs/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/api/schemas.md

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

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/UserDropdown/UserDropdownContent.tsx

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ import LaunchIcon from "@mui/icons-material/LaunchOutlined";
1212
import DocsIcon from "@mui/icons-material/MenuBook";
1313
import Divider from "@mui/material/Divider";
1414
import MenuItem from "@mui/material/MenuItem";
15+
import Tooltip from "@mui/material/Tooltip";
1516
import type { FC } from "react";
1617
import { Link } from "react-router-dom";
1718
import type * as TypesGen from "api/typesGenerated";
19+
import { CopyButton } from "components/CopyButton/CopyButton";
1820
import { ExternalImage } from "components/ExternalImage/ExternalImage";
1921
import { usePopover } from "components/Popover/Popover";
2022
import { Stack } from "components/Stack/Stack";
@@ -161,15 +163,51 @@ export const UserDropdownContent: FC<UserDropdownContentProps> = ({
161163
<Divider css={{ marginBottom: "0 !important" }} />
162164

163165
<Stack css={styles.info} spacing={0}>
164-
<a
165-
title="Browse Source Code"
166-
css={[styles.footerText, styles.buildInfo]}
167-
href={buildInfo?.external_url}
168-
target="_blank"
169-
rel="noreferrer"
170-
>
171-
{buildInfo?.version} <LaunchIcon />
172-
</a>
166+
<Tooltip title="Coder Version">
167+
<a
168+
title="Browse Source Code"
169+
css={[styles.footerText, styles.buildInfo]}
170+
href={buildInfo?.external_url}
171+
target="_blank"
172+
rel="noreferrer"
173+
>
174+
{buildInfo?.version} <LaunchIcon />
175+
</a>
176+
</Tooltip>
177+
178+
{buildInfo?.deployment_id && (
179+
<div
180+
css={css`
181+
font-size: 12px;
182+
display: flex;
183+
align-items: center;
184+
`}
185+
>
186+
<Tooltip title="Deployment Identifier">
187+
<div
188+
css={css`
189+
white-space: nowrap;
190+
overflow: hidden;
191+
text-overflow: ellipsis;
192+
`}
193+
>
194+
{buildInfo?.deployment_id}
195+
</div>
196+
</Tooltip>
197+
<CopyButton
198+
text={buildInfo.deployment_id}
199+
buttonStyles={css`
200+
width: 16px;
201+
height: 16px;
202+
203+
svg {
204+
width: 16px;
205+
height: 16px;
206+
}
207+
`}
208+
/>{" "}
209+
</div>
210+
)}
173211

174212
<div css={styles.footerText}>{Language.copyrightText}</div>
175213
</Stack>

site/src/testHelpers/entities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ export const MockBuildInfo: TypesGen.BuildInfoResponse = {
201201
dashboard_url: "https:///mock-url",
202202
workspace_proxy: false,
203203
upgrade_message: "My custom upgrade message",
204+
deployment_id: "510d407f-e521-4180-b559-eab4a6d802b8",
204205
};
205206

206207
export const MockSupportLinks: TypesGen.LinkConfig[] = [

0 commit comments

Comments
 (0)