- Notifications
You must be signed in to change notification settings - Fork927
feat: add provisioners view to organization settings#14501
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
11 commits Select commitHold shift + click to select a range
3cc5274
feat: view provisioners from organization settings
aslilac0280092
Merge branch 'main' into org-provisioners-page
aslilac4d172e5
Merge branch 'main' into org-provisioners-page
aslilacd258246
🧹
aslilac6eca545
new pills!
aslilac89b4629
>:(
aslilace8f33fd
>>::((
aslilac1cc89f2
Update site/src/pages/ManagementSettingsPage/OrganizationProvisioners…
aslilacdc24263
:)
aslilacd643e00
fix test
aslilacec6db57
hm
aslilacFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletionssite/src/api/queries/organizations.ts
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
26 changes: 24 additions & 2 deletionssite/src/components/Pill/Pill.tsx
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
117 changes: 117 additions & 0 deletionssite/src/modules/provisioners/Provisioner.tsx
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,117 @@ | ||
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"; | ||
interface ProvisionerProps { | ||
readonly provisioner: ProvisionerDaemon; | ||
readonly warnings?: readonly HealthMessage[]; | ||
} | ||
export const Provisioner: FC<ProvisionerProps> = ({ | ||
provisioner, | ||
warnings, | ||
}) => { | ||
const theme = useTheme(); | ||
const daemonScope = provisioner.tags.scope || "organization"; | ||
const iconScope = daemonScope === "organization" ? <Business /> : <Person />; | ||
const extraTags = Object.entries(provisioner.tags).filter( | ||
([key]) => key !== "scope" && key !== "owner", | ||
); | ||
const isWarning = warnings && warnings.length > 0; | ||
return ( | ||
<div | ||
key={provisioner.name} | ||
css={[ | ||
{ | ||
borderRadius: 8, | ||
border: `1px solid ${theme.palette.divider}`, | ||
fontSize: 14, | ||
}, | ||
isWarning && { borderColor: theme.palette.warning.light }, | ||
]} | ||
> | ||
<header | ||
css={{ | ||
padding: 24, | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContenxt: "space-between", | ||
gap: 24, | ||
}} | ||
> | ||
<div | ||
css={{ | ||
display: "flex", | ||
alignItems: "center", | ||
gap: 24, | ||
objectFit: "fill", | ||
}} | ||
> | ||
<div css={{ lineHeight: "160%" }}> | ||
<h4 css={{ fontWeight: 500, margin: 0 }}>{provisioner.name}</h4> | ||
<span css={{ color: theme.palette.text.secondary }}> | ||
<code>{provisioner.version}</code> | ||
</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> | ||
{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> | ||
)} | ||
{provisioner.last_seen_at && ( | ||
<span css={{ color: theme.roles.info.text }} data-chromatic="ignore"> | ||
Last seen {createDayString(provisioner.last_seen_at)} | ||
</span> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; |
105 changes: 105 additions & 0 deletionssite/src/modules/provisioners/ProvisionerTag.tsx
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,105 @@ | ||
import type { Interpolation, Theme } from "@emotion/react"; | ||
import CheckCircleOutlined from "@mui/icons-material/CheckCircleOutlined"; | ||
import CloseIcon from "@mui/icons-material/Close"; | ||
import DoNotDisturbOnOutlined from "@mui/icons-material/DoNotDisturbOnOutlined"; | ||
import Sell from "@mui/icons-material/Sell"; | ||
import IconButton from "@mui/material/IconButton"; | ||
import { Pill } from "components/Pill/Pill"; | ||
import type { ComponentProps, FC } from "react"; | ||
const parseBool = (s: string): { valid: boolean; value: boolean } => { | ||
switch (s.toLowerCase()) { | ||
case "true": | ||
case "yes": | ||
case "1": | ||
return { valid: true, value: true }; | ||
case "false": | ||
case "no": | ||
case "0": | ||
case "": | ||
return { valid: true, value: false }; | ||
default: | ||
return { valid: false, value: false }; | ||
} | ||
}; | ||
interface ProvisionerTagProps { | ||
tagName: string; | ||
tagValue: string; | ||
/** Only used in the TemplateVersionEditor */ | ||
onDelete?: (tagName: string) => void; | ||
} | ||
export const ProvisionerTag: FC<ProvisionerTagProps> = ({ | ||
tagName, | ||
tagValue, | ||
onDelete, | ||
}) => { | ||
const { valid, value: boolValue } = parseBool(tagValue); | ||
const kv = ( | ||
<> | ||
<span css={{ fontWeight: 600 }}>{tagName}</span> <span>{tagValue}</span> | ||
</> | ||
); | ||
const content = onDelete ? ( | ||
<> | ||
{kv} | ||
<IconButton | ||
aria-label={`delete-${tagName}`} | ||
size="small" | ||
color="secondary" | ||
onClick={() => { | ||
onDelete(tagName); | ||
}} | ||
> | ||
<CloseIcon fontSize="inherit" css={{ width: 14, height: 14 }} /> | ||
</IconButton> | ||
</> | ||
) : ( | ||
kv | ||
); | ||
if (valid) { | ||
return <BooleanPill value={boolValue}>{content}</BooleanPill>; | ||
} | ||
return ( | ||
<Pill size="lg" icon={<Sell />}> | ||
{content} | ||
</Pill> | ||
); | ||
}; | ||
type BooleanPillProps = Omit<ComponentProps<typeof Pill>, "icon" | "value"> & { | ||
value: boolean; | ||
}; | ||
export const BooleanPill: FC<BooleanPillProps> = ({ | ||
value, | ||
children, | ||
...divProps | ||
}) => { | ||
return ( | ||
<Pill | ||
type={value ? "active" : "danger"} | ||
size="lg" | ||
icon={ | ||
value ? ( | ||
<CheckCircleOutlined css={styles.truePill} /> | ||
) : ( | ||
<DoNotDisturbOnOutlined css={styles.falsePill} /> | ||
) | ||
} | ||
{...divProps} | ||
> | ||
{children} | ||
</Pill> | ||
); | ||
}; | ||
const styles = { | ||
truePill: (theme) => ({ | ||
color: theme.roles.active.outline, | ||
}), | ||
falsePill: (theme) => ({ | ||
color: theme.roles.danger.outline, | ||
}), | ||
} satisfies Record<string, Interpolation<Theme>>; |
2 changes: 1 addition & 1 deletionsite/src/pages/HealthPage/Content.tsx
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.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.