Skip to content

Commit

Permalink
feat: Update AppList component (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
floreks authored Mar 9, 2023
1 parent cd6aafe commit 743bd8a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 27 deletions.
64 changes: 37 additions & 27 deletions src/components/AppList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
Input,
ListBoxItem,
Select,
Tooltip,
WrapWithIf,
} from '../index'

import { useWindowSize } from './wizard/hooks'
Expand Down Expand Up @@ -244,6 +246,7 @@ type AppProps = {
primaryAction?: JSX.Element
actions?: Array<AppMenuAction>
promoted?: boolean
isAlive?: boolean
} & CardProps

interface AppMenuAction {
Expand All @@ -255,7 +258,7 @@ interface AppMenuAction {
}

function AppUnstyled({
logoUrl, icon, name, description, primaryAction, actions, ...props
logoUrl, icon, name, description, primaryAction, actions, isAlive, ...props
}: AppProps): JSX.Element {
return (
<Card {...props}>
Expand All @@ -282,33 +285,40 @@ function AppUnstyled({

{actions && (
<div className="actions">
<Select
aria-label="moreMenu"
selectedKey={null}
onSelectionChange={key => actions.find(action => action.label === key)?.onSelect()}
width="max-content"
maxHeight={197}
triggerButton={(
<Button
secondary
width={32}
minHeight={32}
><MoreIcon />
</Button>
)}
<WrapWithIf
condition={!isAlive}
wrapper={<Tooltip label="Application not ready" />}
>
{actions.map(action => (
<ListBoxItem
key={action.label}
label={action.label}
textValue={action.label}
leftContent={action.leftContent}
rightContent={action.rightContent}
destructive={action.destructive}
/>
))}
</Select>

<div>
<Select
aria-label="moreMenu"
selectedKey={null}
onSelectionChange={key => actions.find(action => action.label === key)?.onSelect()}
isDisabled={!isAlive}
width="max-content"
maxHeight={197}
triggerButton={(
<Button
secondary
width={32}
minHeight={32}
><MoreIcon />
</Button>
)}
>
{actions.map(action => (
<ListBoxItem
key={action.label}
label={action.label}
textValue={action.label}
leftContent={action.leftContent}
rightContent={action.rightContent}
destructive={action.destructive}
/>
))}
</Select>
</div>
</WrapWithIf>
</div>
)}
</Card>
Expand Down
1 change: 1 addition & 0 deletions src/components/ListBoxItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ const ListBoxFooterPlus = forwardRef<HTMLDivElement, ListBoxFooterProps>(({ left

export type {
ListBoxItemBaseProps,
ListBoxItemProps,
ListBoxFooterProps,
ListBoxFooterProps as ListBoxFooterPlusProps,
}
Expand Down
1 change: 1 addition & 0 deletions src/stories/AppList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const APPS: Array<AppProps & CardProps> = [
</Button>
),
actions: [{ label: 'Rebuild', onSelect: () => {} }],
isAlive: true,
}, {
name: 'GitLab',
description: 'v2.11',
Expand Down

0 comments on commit 743bd8a

Please sign in to comment.