8000 feat: Enable custom support links by mtojek · Pull Request #6313 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: Enable custom support links #6313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix: site tests
  • Loading branch information
mtojek committed Feb 24, 2023
commit 81a1fcb5dd5fdb3ec7778b9bf6086c9faec3ccdb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ describe("UserDropdownContent", () => {
expect(screen.getByText(MockSupportLinks[0].name)).toBeDefined()
expect(screen.getByText(MockSupportLinks[1].name)).toBeDefined()
expect(screen.getByText(MockSupportLinks[2].name)).toBeDefined()
expect(screen.getByText(MockSupportLinks[2].name)
.closest("a")).toHaveAttribute("href", "https://github.com/coder/coder/issues/new?labels=needs+grooming&body=Version%3A%20%5B%60v99.999.9999%2Bc9cdf14%60%5D(file%3A%2F%2F%2Fmock-url)")
expect(screen.getByText(MockBuildInfo.version)).toBeDefined()
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const UserDropdownContent: FC<UserDropdownContentProps> = ({
{supportLinks &&
supportLinks.map((link) => (
<a
href={link.target}
href={includeBuildInfo(link.target, buildInfo)}
key={link.name}
target="_blank"
rel="noreferrer"
Expand Down Expand Up @@ -166,3 +166,8 @@ const useStyles = makeStyles((theme) => ({
color: theme.palette.text.primary,
},
}))

const includeBuildInfo = (href: string, buildInfo?: TypesGen.BuildInfoResponse): string => {
return href.replace("{CODER_BUILD_INFO}",
`${encodeURIComponent(`Version: [\`${buildInfo?.version}\`](${buildInfo?.external_url})`)}`)
}
2 changes: 1 addition & 1 deletion site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const MockSupportLinks: TypesGen.LinkConfig[] = [
},
{
name: "Third link",
target: "http://third-link",
target: "https://github.com/coder/coder/issues/new?labels=needs+grooming&body={CODER_BUILD_INFO}",
icon: ""
}
];
Expand Down
0