- Notifications
You must be signed in to change notification settings - Fork1.1k
fix: improve provisioner details layout and show count line#14749
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
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
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.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import { type Interpolation, type Theme, useTheme } from "@emotion/react"; | ||
| import BusinessIcon from "@mui/icons-material/Business"; | ||
| import PersonIcon from "@mui/icons-material/Person"; | ||
| import TagIcon from "@mui/icons-material/Sell"; | ||
| import Button from "@mui/material/Button"; | ||
| import Link from "@mui/material/Link"; | ||
| import Tooltip from "@mui/material/Tooltip"; | ||
| @@ -21,6 +22,7 @@ import { | ||
| } from "components/Popover/Popover"; | ||
| import { Stack } from "components/Stack/Stack"; | ||
| import { StatusIndicator } from "components/StatusIndicator/StatusIndicator"; | ||
| import isEqual from "lodash/isEqual"; | ||
| import { type FC, useState } from "react"; | ||
| import { createDayString } from "utils/createDayString"; | ||
| import { docs } from "utils/docs"; | ||
| @@ -30,14 +32,16 @@ type ProvisionerGroupType = "builtin" | "psk" | "key"; | ||
| interface ProvisionerGroupProps { | ||
| readonly buildInfo?: BuildInfoResponse; | ||
| readonly keyName: string; | ||
| readonly keyTags: Record<string, string>; | ||
| readonly type: ProvisionerGroupType; | ||
| readonly provisioners: readonly ProvisionerDaemon[]; | ||
| } | ||
Comment on lines 33 to 39 Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Is there a reason why we haven't been using the typeProvisionerGroupProps=Readonly<{buildInfo?:BuildInfoResponse;keyName:string;keyTags:Readonly<Record<string,string>>;type:ProvisionerGroupType;provisioners:readonlyProvisionerDaemon[];}> I know our entire API types file uses interfaces, but I'm a little fussed about that, since it's all auto-generated MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. yeah, I've just been trying something 🤷♀️ idek if we get any benefit out of it when we immediately destructure the props off of the object in the component | ||
| export const ProvisionerGroup: FC<ProvisionerGroupProps> = ({ | ||
| buildInfo, | ||
| keyName, | ||
| keyTags, | ||
| type, | ||
| provisioners, | ||
| }) => { | ||
| @@ -61,7 +65,7 @@ export const ProvisionerGroup: FC<ProvisionerGroupProps> = ({ | ||
| provisioners.length === 1 | ||
| ? "1 provisioner" | ||
| : `${provisioners.length} provisioners`; | ||
| const extraTags = Object.entries(keyTags).filter( | ||
| ([key]) => key !== "scope" && key !== "owner", | ||
| ); | ||
| @@ -90,6 +94,10 @@ export const ProvisionerGroup: FC<ProvisionerGroupProps> = ({ | ||
| ? "1 provisioner" | ||
| : `${provisionersWithWarnings} provisioners`; | ||
| const hasMultipleTagVariants = | ||
| type === "psk" && | ||
| provisioners.some((it) => !isEqual(it.tags, { scope: "organization" })); | ||
aslilac marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| return ( | ||
| <div | ||
| css={[ | ||
| @@ -153,14 +161,26 @@ export const ProvisionerGroup: FC<ProvisionerGroupProps> = ({ | ||
| justifyContent: "right", | ||
| }} | ||
| > | ||
| {!hasMultipleTagVariants ? ( | ||
| <Tooltip title="Scope"> | ||
| <Pill | ||
| size="lg" | ||
| icon={ | ||
| daemonScope === "organization" ? ( | ||
| <BusinessIcon /> | ||
| ) : ( | ||
| <PersonIcon /> | ||
| ) | ||
| } | ||
| > | ||
| <span css={{ textTransform: "capitalize" }}>{daemonScope}</span> | ||
| </Pill> | ||
| </Tooltip> | ||
| ) : ( | ||
| <Pill size="lg" icon={<TagIcon />}> | ||
| Multiple tags | ||
| </Pill> | ||
| )} | ||
| {type === "key" && | ||
| extraTags.map(([key, value]) => ( | ||
| <ProvisionerTag key={key} tagName={key} tagValue={value} /> | ||
| @@ -172,9 +192,9 @@ export const ProvisionerGroup: FC<ProvisionerGroupProps> = ({ | ||
| <div | ||
| css={{ | ||
| padding: "0 24px 24px", | ||
| display: "grid", | ||
| gap: 12, | ||
| gridTemplateColumns: "repeat(auto-fill, minmax(385px, 1fr))", | ||
| }} | ||
| > | ||
| {provisionersWithWarningInfo.map((provisioner) => ( | ||
| @@ -186,7 +206,6 @@ export const ProvisionerGroup: FC<ProvisionerGroupProps> = ({ | ||
| border: `1px solid ${theme.palette.divider}`, | ||
| fontSize: 14, | ||
| padding: "14px 18px", | ||
| }, | ||
| provisioner.warningCount > 0 && styles.warningBorder, | ||
| ]} | ||
| @@ -222,7 +241,7 @@ export const ProvisionerGroup: FC<ProvisionerGroupProps> = ({ | ||
| )} | ||
| </span> | ||
| </div> | ||
| {hasMultipleTagVariants && ( | ||
| <PskProvisionerTags tags={provisioner.tags} /> | ||
| )} | ||
| </Stack> | ||
| @@ -317,7 +336,8 @@ interface PskProvisionerTagsProps { | ||
| const PskProvisionerTags: FC<PskProvisionerTagsProps> = ({ tags }) => { | ||
| const daemonScope = tags.scope || "organization"; | ||
| const iconScope = | ||
| daemonScope === "organization" ? <BusinessIcon /> : <PersonIcon />; | ||
| const extraTags = Object.entries(tags).filter( | ||
| ([tag]) => tag !== "scope" && tag !== "owner", | ||
| @@ -343,6 +363,7 @@ const PskProvisionerTags: FC<PskProvisionerTagsProps> = ({ tags }) => { | ||
| css={{ | ||
| "& .MuiPaper-root": { | ||
| padding: 20, | ||
| minWidth: "unset", | ||
aslilac marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| maxWidth: 340, | ||
| width: "fit-content", | ||
| }, | ||
Uh oh!
There was an error while loading.Please reload this page.