-
Notifications
You must be signed in to change notification settings - Fork 943
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
import { useTheme } from "@emotion/react"; | ||
import Business from "@mui/icons-material/Business"; | ||
import Person from "@mui/icons-material/Person"; | ||
import Tooltip from "@mui/material/Tooltip"; | ||
import type { HealthMessage, ProvisionerDaemon } from "api/typesGenerated"; | ||
import { Pill } from "components/Pill/Pill"; | ||
import type { FC } from "react"; | ||
import { createDayString } from "utils/createDayString"; | ||
import { ProvisionerTag } from "./ProvisionerTag"; | ||
import { useEmbeddedMetadata } from "hooks/useEmbeddedMetadata"; | ||
import { buildInfo } from "api/queries/buildInfo"; | ||
import { useQuery } from "react-query"; | ||
import ArrowDownward from "@mui/icons-material/ArrowDownward"; | ||
|
||
type ProvisionerGroupType = "builtin" | "psk" | "key"; | ||
|
||
interface ProvisionerGroupProps { | ||
readonly keyName?: string; | ||
readonly type: ProvisionerGroupType; | ||
readonly provisioners: ProvisionerDaemon[]; | ||
readonly warnings?: readonly HealthMessage[]; | ||
} | ||
|
||
export const ProvisionerGroup: FC<ProvisionerGroupProps> = ({ | ||
keyName, | ||
type, | ||
provisioners, | ||
warnings, | ||
}) => { | ||
const { metadata } = useEmbeddedMetadata(); | ||
const buildInfoQuery = useQuery(buildInfo(metadata["build-info"])); | ||
|
||
const [provisioner] = provisioners; | ||
const theme = useTheme(); | ||
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 && buildInfoQuery.data?.version; | ||
const protocolUpToDate = | ||
allProvisionersAreSameVersion && | ||
buildInfoQuery?.data?.provisioner_api_version === provisioner.api_version; | ||
const provisionerCount = | ||
provisioners.length === 1 | ||
? "1 provisioner" | ||
: `${provisioners.length} provisioners`; | ||
|
||
const extraTags = Object.entries(provisioner.tags).filter( | ||
([key]) => key !== "scope" && key !== "owner", | ||
); | ||
const isWarning = warnings && warnings.length > 0; | ||
return ( | ||
<div | ||
css={[ | ||
{ | ||
borderRadius: 8, | ||
border: `1px solid ${theme.palette.divider}`, | ||
fontSize: 14, | ||
}, | ||
isWarning && { borderColor: theme.roles.warning.outline }, | ||
]} | ||
> | ||
<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, | ||
}} | ||
> | ||
<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> | ||
|
||
<div | ||
css={{ | ||
borderTop: `1px solid ${theme.palette.divider}`, | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "space-between", | ||
padding: "8px 24px", | ||
fontSize: 12, | ||
color: theme.palette.text.secondary, | ||
}} | ||
> | ||
{warnings && warnings.length > 0 ? ( | ||
<div css={{ display: "flex", flexDirection: "column" }}> | ||
{warnings.map((warning) => ( | ||
<span key={warning.code}>{warning.message}</span> | ||
))} | ||
</div> | ||
) : ( | ||
<span>No warnings</span> | ||
)} | ||
<span | ||
css={{ | ||
display: "flex", | ||
alignItems: "center", | ||
gap: 4, | ||
color: theme.roles.info.text, | ||
}} | ||
> | ||
Show provisioner details{" "} | ||
<ArrowDownward fontSize="small" color="inherit" /> | ||
</span> | ||
</div> | ||
</div> | ||
); | ||
}; |
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
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.
feat: show tags for psk provisioners #14628
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
Uh oh!
There was an error while loading. Please reload this page.
feat: show tags for psk provisioners #14628
Changes from 1 commit
665c9b3
4558b44
fcd8614
82c6362
8bb49a7
dfa2621
55360f7
9129412
401eab3
716b257
a1b7cbd
5d6d312
37e3933
2c6fd6d
fd3b259
< 8000 div class="text-emphasized css-truncate css-truncate-target"> Merge branch 'provisioner-types' into psk-tags1f8c386
cc620a5
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.