-
Notifications
You must be signed in to change notification settings - Fork 943
feat: show more detailed provisioner version info #14593
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
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
665c9b3
work
aslilac 4558b44
do the stuff
aslilac fcd8614
🧹
aslilac 82c6362
feat: show more detailed provisioner version info
aslilac 8bb49a7
🧹
aslilac 401eab3
Merge branch 'main' into group-provisioners
aslilac 716b257
hook up to api
aslilac a1b7cbd
:)
aslilac 5d6d312
Merge branch 'group-provisioners' into provisioner-version-popups
aslilac 37e3933
v2.99.99
aslilac 05cdba4
Merge branch 'main' into provisioner-version-popups
aslilac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,273 @@ | ||
import { type Interpolation, type Theme, useTheme } from "@emotion/react"; | ||
import Business from "@mui/icons-material/Business"; | ||
import Person from "@mui/icons-material/Person"; | ||
import Button from "@mui/material/Button"; | ||
import Link from "@mui/material/Link"; | ||
import Tooltip from "@mui/material/Tooltip"; | ||
import type { BuildInfoResponse, ProvisionerDaemon } from "api/typesGenerated"; | ||
import { DropdownArrow } from "components/DropdownArrow/DropdownArrow"; | ||
import { Pill } from "components/Pill/Pill"; | ||
import { | ||
Popover, | ||
PopoverContent, | ||
PopoverTrigger, | ||
} from "components/Popover/Popover"; | ||
import { type FC, useState } from "react"; | ||
import { createDayString } from "utils/createDayString"; | ||
import { docs } from "utils/docs"; | ||
import { ProvisionerTag } from "./ProvisionerTag"; | ||
|
||
type ProvisionerGroupType = "builtin" | "psk" | "key"; | ||
|
||
interface ProvisionerGroupProps { | ||
readonly buildInfo?: BuildInfoResponse; | ||
readonly keyName?: string; | ||
readonly type: ProvisionerGroupType; | ||
readonly provisioners: ProvisionerDaemon[]; | ||
} | ||
|
||
export const ProvisionerGroup: FC<ProvisionerGroupProps> = ({ | ||
buildInfo, | ||
keyName, | ||
type, | ||
provisioners, | ||
}) => { | ||
const [provisioner] = provisioners; | ||
const theme = useTheme(); | ||
|
||
const [showDetails, setShowDetails] = useState(false); | ||
|
||
const daemonScope = provisioner.tags.scope || "organization"; | ||
const iconScope = daemonScope === "organization" ? <Business /> : <Person />; | ||
|
||
const provisionerVersion = provisioner.version; | ||
const allProvisionersAreSameVersion = provisioners.every( | ||
(provisioner) => provisioner.version === provisionerVersion, | ||
); | ||
const upToDate = | ||
allProvisionersAreSameVersion && buildInfo?.version === provisioner.version; | ||
const provisionerCount = | ||
provisioners.length === 1 | ||
? "1 provisioner" | ||
: `${provisioners.length} provisioners`; | ||
|
||
const extraTags = Object.entries(provisioner.tags).filter( | ||
([key]) => key !== "scope" && key !== "owner", | ||
); | ||
|
||
return ( | ||
<div | ||
css={{ | ||
borderRadius: 8, | ||
border: `1px solid ${theme.palette.divider}`, | ||
fontSize: 14, | ||
}} | ||
> | ||
<header | ||
css={{ | ||
padding: 24, | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContenxt: "space-between", | ||
gap: 24, | ||
}} | ||
> | ||
<div | ||
css={{ | ||
display: "flex", | ||
alignItems: "center", | ||
gap: 24, | ||
objectFit: "fill", | ||
}} | ||
> | ||
{type === "builtin" && ( | ||
<div css={{ lineHeight: "160%" }}> | ||
<h4 css={{ fontWeight: 500, margin: 0 }}> | ||
Built-in provisioners | ||
</h4> | ||
<span css={{ color: theme.palette.text.secondary }}> | ||
{provisionerCount} — Built-in | ||
</span> | ||
</div> | ||
)} | ||
{type === "psk" && ( | ||
<div css={{ lineHeight: "160%" }}> | ||
<h4 css={{ fontWeight: 500, margin: 0 }}>PSK provisioners</h4> | ||
<span css={{ color: theme.palette.text.secondary }}> | ||
{provisionerCount} —{" "} | ||
{allProvisionersAreSameVersion ? ( | ||
<code>{provisionerVersion}</code> | ||
) : ( | ||
<span>Multiple versions</span> | ||
)} | ||
</span> | ||
</div> | ||
)} | ||
{type === "key" && ( | ||
<div css={{ lineHeight: "160%" }}> | ||
<h4 css={{ fontWeight: 500, margin: 0 }}> | ||
Key group – {keyName} | ||
</h4> | ||
<span css={{ color: theme.palette.text.secondary }}> | ||
{provisionerCount} —{" "} | ||
{allProvisionersAreSameVersion ? ( | ||
<code>{provisionerVersion}</code> | ||
) : ( | ||
<span>Multiple versions</span> | ||
)} | ||
</span> | ||
</div> | ||
)} | ||
</div> | ||
<div | ||
css={{ | ||
marginLeft: "auto", | ||
display: "flex", | ||
flexWrap: "wrap", | ||
gap: 12, | ||
justifyContent: "right", | ||
}} | ||
> | ||
<Tooltip title="Scope"> | ||
<Pill size="lg" icon={iconScope}> | ||
<span | ||
css={{ | ||
":first-letter": { textTransform: "uppercase" }, | ||
}} | ||
> | ||
{daemonScope} | ||
</span> | ||
</Pill> | ||
</Tooltip> | ||
{type === "key" && | ||
extraTags.map(([key, value]) => ( | ||
<ProvisionerTag key={key} tagName={key} tagValue={value} /> | ||
))} | ||
</div> | ||
</header> | ||
|
||
{showDetails && ( | ||
<div | ||
css={{ | ||
padding: "0 24px 24px", | ||
display: "flex", | ||
gap: 12, | ||
flexWrap: "wrap", | ||
}} | ||
> | ||
{provisioners.map((provisioner) => ( | ||
<div | ||
key={provisioner.id} | ||
css={{ | ||
borderRadius: 8, | ||
border: `1px solid ${theme.palette.divider}`, | ||
fontSize: 14, | ||
padding: "12px 18px", | ||
width: 310, | ||
}} | ||
> | ||
<div css={{ lineHeight: 1.6 }}> | ||
<h4 css={{ fontWeight: 500, margin: 0 }}>{provisioner.name}</h4> | ||
<span | ||
css={{ color: theme.palette.text.secondary, fontSize: 13 }} | ||
> | ||
{type === "builtin" ? ( | ||
<span>Built-in</span> | ||
) : ( | ||
<> | ||
<Popover mode="hover"> | ||
<PopoverTrigger> | ||
<span> | ||
{buildInfo | ||
? provisioner.version === buildInfo.version | ||
? "Up to date" | ||
: "Out of date" | ||
: provisioner.version} | ||
</span> | ||
</PopoverTrigger> | ||
<PopoverContent | ||
transformOrigin={{ vertical: -8, horizontal: 0 }} | ||
css={{ | ||
"& .MuiPaper-root": { | ||
padding: "20px 20px 8px", | ||
maxWidth: 340, | ||
}, | ||
}} | ||
> | ||
<h4 css={styles.title}>Release version</h4> | ||
<p css={styles.text}>{provisioner.version}</p> | ||
<h4 css={styles.title}>Protocol version</h4> | ||
<p css={styles.text}>{provisioner.api_version}</p> | ||
{provisioner.api_version !== | ||
buildInfo?.provisioner_api_version && ( | ||
<p css={[styles.text, { fontSize: 13 }]}> | ||
This provisioner is out of date. You may | ||
experience issues when using a provisioner version | ||
that doesn’t match your Coder deployment. Please | ||
upgrade to a newer version.{" "} | ||
<Link href={docs("/")}>Learn more…</Link> | ||
</p> | ||
)} | ||
</PopoverContent> | ||
</Popover>{" "} | ||
—{" "} | ||
{provisioner.last_seen_at && ( | ||
<span data-chromatic="ignore"> | ||
Last seen {createDayString(provisioner.last_seen_at)} | ||
</span> | ||
)} | ||
</> | ||
)} | ||
</span> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
)} | ||
|
||
<div | ||
css={{ | ||
borderTop: `1px solid ${theme.palette.divider}`, | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "space-between", | ||
padding: "8px 8px 8px 24px", | ||
fontSize: 12, | ||
color: theme.palette.text.secondary, | ||
}} | ||
> | ||
<span>No warnings from {provisionerCount}</span> | ||
<Button | ||
variant="text" | ||
css={{ | ||
display: "flex", | ||
alignItems: "center", | ||
gap: 4, | ||
color: theme.roles.info.text, | ||
fontSize: "inherit", | ||
}} | ||
onClick={() => setShowDetails((it) => !it)} | ||
> | ||
{showDetails ? "Hide" : "Show"} provisioner details{" "} | ||
<DropdownArrow close={showDetails} /> | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
const styles = { | ||
title: (theme) => ({ | ||
marginTop: 0, | ||
marginBottom: 0, | ||
color: theme.palette.text.primary, | ||
fontSize: 14, | ||
lineHeight: "150%", | ||
aslilac marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fontWeight: 600, | ||
}), | ||
|
||
text: (theme) => ({ | ||
marginTop: 0, | ||
marginBottom: 12, | ||
}), | ||
} satisfies Record<string, Interpolation<Theme>>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.