- Notifications
You must be signed in to change notification settings - Fork1.1k
feat: group provisioners by authentication method#14580
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 |
|---|---|---|
| @@ -0,0 +1,213 @@ | ||
| import{useTheme}from"@emotion/react"; | ||
| importBusinessfrom"@mui/icons-material/Business"; | ||
| importPersonfrom"@mui/icons-material/Person"; | ||
| importButtonfrom"@mui/material/Button"; | ||
| importTooltipfrom"@mui/material/Tooltip"; | ||
| importtype{BuildInfoResponse,ProvisionerDaemon}from"api/typesGenerated"; | ||
| import{DropdownArrow}from"components/DropdownArrow/DropdownArrow"; | ||
| import{Pill}from"components/Pill/Pill"; | ||
| import{typeFC,useState}from"react"; | ||
| import{createDayString}from"utils/createDayString"; | ||
| import{ProvisionerTag}from"./ProvisionerTag"; | ||
| typeProvisionerGroupType="builtin"|"psk"|"key"; | ||
aslilac marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| interfaceProvisionerGroupProps{ | ||
| readonlybuildInfo?:BuildInfoResponse; | ||
| readonlykeyName?:string; | ||
| readonlytype:ProvisionerGroupType; | ||
| readonlyprovisioners:ProvisionerDaemon[]; | ||
aslilac marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| } | ||
| exportconstProvisionerGroup:FC<ProvisionerGroupProps>=({ | ||
| buildInfo, | ||
| keyName, | ||
| type, | ||
| provisioners, | ||
| })=>{ | ||
| const[provisioner]=provisioners; | ||
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. Should there be a check to make sure that the If there are multiple provisioners, is there anything implied by the order they appear in? As in, is the first provisioner always the "main" one? 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. currently, it should never be passed an empty | ||
| consttheme=useTheme(); | ||
| const[showDetails,setShowDetails]=useState(false); | ||
| constdaemonScope=provisioner.tags.scope||"organization"; | ||
| consticonScope=daemonScope==="organization" ?<Business/> :<Person/>; | ||
aslilac marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| constprovisionerVersion=provisioner.version; | ||
| constallProvisionersAreSameVersion=provisioners.every( | ||
| (provisioner)=>provisioner.version===provisionerVersion, | ||
| ); | ||
| constupToDate= | ||
| allProvisionersAreSameVersion&&buildInfo?.version===provisioner.version; | ||
| constprovisionerCount= | ||
| provisioners.length===1 | ||
| ?"1 provisioner" | ||
| :`${provisioners.length} provisioners`; | ||
| constextraTags=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"&&( | ||
| <divcss={{lineHeight:"160%"}}> | ||
| <h4css={{fontWeight:500,margin:0}}> | ||
| Built-in provisioners | ||
| </h4> | ||
| <spancss={{color:theme.palette.text.secondary}}> | ||
| {provisionerCount} — Built-in | ||
| </span> | ||
| </div> | ||
| )} | ||
| {type==="psk"&&( | ||
| <divcss={{lineHeight:"160%"}}> | ||
| <h4css={{fontWeight:500,margin:0}}>PSK provisioners</h4> | ||
| <spancss={{color:theme.palette.text.secondary}}> | ||
| {provisionerCount} —{" "} | ||
| {allProvisionersAreSameVersion ?( | ||
| <code>{provisionerVersion}</code> | ||
| ) :( | ||
| <span>Multiple versions</span> | ||
| )} | ||
| </span> | ||
| </div> | ||
| )} | ||
| {type==="key"&&( | ||
| <divcss={{lineHeight:"160%"}}> | ||
| <h4css={{fontWeight:500,margin:0}}> | ||
| Key group –{keyName} | ||
| </h4> | ||
| <spancss={{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", | ||
| }} | ||
| > | ||
| <Tooltiptitle="Scope"> | ||
| <Pillsize="lg"icon={iconScope}> | ||
| <span | ||
| css={{ | ||
| ":first-letter":{textTransform:"uppercase"}, | ||
aslilac marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| }} | ||
| > | ||
| {daemonScope} | ||
| </span> | ||
| </Pill> | ||
| </Tooltip> | ||
| {type==="key"&& | ||
| extraTags.map(([key,value])=>( | ||
| <ProvisionerTagkey={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, | ||
| }} | ||
| > | ||
| <divcss={{lineHeight:"160%"}}> | ||
| <h4css={{fontWeight:500,margin:0}}>{provisioner.name}</h4> | ||
| <spancss={{color:theme.palette.text.secondary}}> | ||
| {type==="builtin" ?( | ||
| <span>Built-in</span> | ||
| ) :( | ||
| <> | ||
| {upToDate ?"Up to date" :provisioner.version} —{" "} | ||
| {provisioner.last_seen_at&&( | ||
| <spandata-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{" "} | ||
| <DropdownArrowclose={showDetails}/> | ||
| </Button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,49 @@ | ||
| importtype{Meta,StoryObj}from"@storybook/react"; | ||
| import{ | ||
| MockBuildInfo, | ||
| MockProvisioner, | ||
| MockProvisioner2, | ||
| MockProvisionerWithTags, | ||
| MockUserProvisioner, | ||
| }from"testHelpers/entities"; | ||
| import{OrganizationProvisionersPageView}from"./OrganizationProvisionersPageView"; | ||
| constmeta:Meta<typeofOrganizationProvisionersPageView>={ | ||
| title:"pages/OrganizationProvisionersPage", | ||
| component:OrganizationProvisionersPageView, | ||
| args:{ | ||
| buildInfo:MockBuildInfo, | ||
| }, | ||
| }; | ||
| exportdefaultmeta; | ||
| typeStory=StoryObj<typeofOrganizationProvisionersPageView>; | ||
| exportconstProvisioners:Story={ | ||
| args:{ | ||
| provisioners:{ | ||
| builtin:[MockProvisioner,MockProvisioner2], | ||
| psk:[MockProvisioner,MockUserProvisioner,MockProvisionerWithTags], | ||
| userAuth:[], | ||
| keys:newMap([ | ||
| [ | ||
| "ケイラ", | ||
| [ | ||
| { | ||
| ...MockProvisioner, | ||
| tags:{ | ||
| ...MockProvisioner.tags, | ||
| 都市:"ユタ", | ||
| きっぷ:"yes", | ||
| ちいさい:"no", | ||
| }, | ||
| warnings:[ | ||
| {code:"EUNKNOWN",message:"私は日本語が話せません"}, | ||
aslilac marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| ], | ||
| }, | ||
| ], | ||
| ], | ||
| ]), | ||
| }, | ||
| }, | ||
| }; | ||
Uh oh!
There was an error while loading.Please reload this page.