Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
121 additions
and
45 deletions.
There are no files selected for viewing
14 changes: 0 additions & 14 deletions
14
frontend/packages/kubevirt-plugin/src/components/boot-order.tsx
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
frontend/packages/kubevirt-plugin/src/components/boot-order/boot-order-summary.scss
This file contains 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,7 @@ | ||
.kubevirt-boot-order-suammary__expandable.pf-c-expandable .pf-c-expandable__content { | ||
margin-top: 0; | ||
} | ||
|
||
.kubevirt-boot-order-suammary__empty-text { | ||
margin-bottom: 0; | ||
} |
62 changes: 62 additions & 0 deletions
62
frontend/packages/kubevirt-plugin/src/components/boot-order/boot-order-summary.tsx
This file contains 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,62 @@ | ||
import * as React from 'react'; | ||
import * as _ from 'lodash'; | ||
import { List, ListItem, Expandable, Text, TextVariants } from '@patternfly/react-core'; | ||
import { BootableDeviceType } from '../../types'; | ||
import { deviceLabel, deviceKey, bootOrderEmptyTitle, bootOrderEmptyMessage } from './constants'; | ||
|
||
import './boot-order-summary.scss'; | ||
|
||
export const BootOrderSummary = ({ devices }: BootOrderSummaryProps) => { | ||
const [isExpanded, setIsExpanded] = React.useState<boolean>(false); | ||
|
||
const sources = _.sortBy(devices.filter((device) => device.value.bootOrder), 'value.bootOrder'); | ||
const options = devices.filter((device) => !device.value.bootOrder); | ||
|
||
const onToggle = () => { | ||
setIsExpanded(!isExpanded); | ||
}; | ||
|
||
// Note(Yaacov): className='text-secondary' is a hack to fix TextVariants being overriden. | ||
const EmptyState: React.FC = () => ( | ||
<> | ||
<Text component={TextVariants.p} className="kubevirt-boot-order-suammary__empty-text"> | ||
{bootOrderEmptyTitle} | ||
</Text> | ||
<Text component={TextVariants.small} className="text-secondary"> | ||
{bootOrderEmptyMessage} | ||
</Text> | ||
{options.length > 0 && ( | ||
<Expandable | ||
toggleText={isExpanded ? 'Hide default boot disks' : 'Show default boot disks'} | ||
onToggle={onToggle} | ||
isExpanded={isExpanded} | ||
className="kubevirt-boot-order-suammary__expandable" | ||
> | ||
<List> | ||
{options.map((option) => ( | ||
<ListItem key={deviceKey(option)}>{deviceLabel(option)}</ListItem> | ||
))} | ||
</List> | ||
</Expandable> | ||
)} | ||
</> | ||
); | ||
|
||
return ( | ||
<> | ||
{sources.length === 0 ? ( | ||
<EmptyState /> | ||
) : ( | ||
<List> | ||
{sources.map((source) => ( | ||
<ListItem key={deviceKey(source)}>{deviceLabel(source)}</ListItem> | ||
))} | ||
</List> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export type BootOrderSummaryProps = { | ||
devices: BootableDeviceType[]; | ||
}; |
6 changes: 6 additions & 0 deletions
6
frontend/packages/kubevirt-plugin/src/components/boot-order/constants.tsx
This file contains 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,6 @@ | ||
export const bootOrderEmptyTitle = 'No resource selected'; | ||
export const bootOrderEmptyMessage = | ||
'VM will attempt to boot from disks by order of apearance in YAML file'; | ||
|
||
export const deviceKey = (device) => `${device.type}-${device.value.name}`; | ||
export const deviceLabel = (device) => `${device.value.name} (${device.typeLabel})`; |
1 change: 1 addition & 0 deletions
1
frontend/packages/kubevirt-plugin/src/components/boot-order/index.tsx
This file contains 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 @@ | ||
export * from './boot-order-summary'; |
This file contains 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 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 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 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