-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert Providers screen to Console page
Code changes: 1. use StandardPage list component 2. entity list is produced by merging results from k8s API and exsting Forklift inventory REST API. 3. actions in the table (kebab actions) are provided via extension point 'console.action/provider' 4. use existing actions for Add/Edit/Delete/Select Network Functional changes: 1. display all providers in one table 2. use only 'Ready' condition to describe the state of the provider 3. disable rich content in Network/Storage columns until the design for the details page is known Signed-off-by: Radoslaw Szwajkowski <[email protected]>
- Loading branch information
Showing
18 changed files
with
892 additions
and
34 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,53 @@ | ||
{ | ||
"{{type}} provider {{name}} will no longer be selectable as a migration source.": "{{type}} provider {{name}} will no longer be selectable as a migration source.", | ||
"{{type}} provider {{name}} will no longer be selectable as a migration target.": "{{type}} provider {{name}} will no longer be selectable as a migration target.", | ||
"Actions": "Actions", | ||
"Add Provider": "Add Provider", | ||
"Cancel": "Cancel", | ||
"Cannot remove provider": "Cannot remove provider", | ||
"Clear all filters": "Clear all filters", | ||
"Clusters": "Clusters", | ||
"Delete": "Delete", | ||
"Delete Provider": "Delete Provider", | ||
"Edit Provider": "Edit Provider", | ||
"Endpoint": "Endpoint", | ||
"False": "False", | ||
"Filter by endpoint": "Filter by endpoint", | ||
"Filter by name": "Filter by name", | ||
"Filter by namespace": "Filter by namespace", | ||
"Hosts": "Hosts", | ||
"KubeVirt": "KubeVirt", | ||
"Loading": "Loading", | ||
"Manage Columns": "Manage Columns", | ||
"Mappings for VM Import": "Mappings for VM Import", | ||
"Name": "Name", | ||
"Namespace": "Namespace", | ||
"Networks": "Networks", | ||
"No information": "No information", | ||
"No results found": "No results found", | ||
"No results match the filter criteria. Clear all filters and try again.": "No results match the filter criteria. Clear all filters and try again.", | ||
"oVirt": "oVirt", | ||
"Permanently delete provider?": "Permanently delete provider?", | ||
"Plans for VM Import": "Plans for VM Import", | ||
"Providers": "Providers", | ||
"Providers for VM Import": "Providers for VM Import", | ||
"Ready": "Ready", | ||
"Reorder": "Reorder", | ||
"Restore default colums": "Restore default colums", | ||
"Save": "Save", | ||
"Select a default migration network for the provider. This network will be used for migrating data to all namespaces to which it is attached.": "Select a default migration network for the provider. This network will be used for migrating data to all namespaces to which it is attached.", | ||
"Select Filter": "Select Filter", | ||
"Select migration network": "Select migration network", | ||
"Selected columns will be displayed in the table.": "Selected columns will be displayed in the table.", | ||
"Storage": "Storage", | ||
"Table column management": "Table column management", | ||
"The host provider cannot be edited": "The host provider cannot be edited", | ||
"This provider cannot be edited because it has running migrations": "This provider cannot be edited because it has running migrations", | ||
"True": "True", | ||
"Type": "Type", | ||
"Unable to retrieve data": "Unable to retrieve data", | ||
"Virtualization": "Virtualization" | ||
"Unknown": "Unknown", | ||
"Virtualization": "Virtualization", | ||
"VMs": "VMs", | ||
"VMware": "VMware" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import React, { JSXElementConstructor } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { RowProps } from 'src/components/TableView'; | ||
import { CONDITIONS, PROVIDERS, useTranslation } from 'src/internal/i18n'; | ||
import { | ||
ACTIONS, | ||
HOST_COUNT, | ||
NAME, | ||
NAMESPACE, | ||
NETWORK_COUNT, | ||
READY, | ||
STORAGE_COUNT, | ||
TYPE, | ||
URL, | ||
} from 'src/utils/constants'; | ||
|
||
import { PATH_PREFIX } from '@app/common/constants'; | ||
import { StatusIcon } from '@migtools/lib-ui'; | ||
import { ResourceLink } from '@openshift-console/dynamic-plugin-sdk'; | ||
import { Button, Popover } from '@patternfly/react-core'; | ||
import { DatabaseIcon, NetworkIcon, OutlinedHddIcon } from '@patternfly/react-icons'; | ||
import { Td, Tr } from '@patternfly/react-table'; | ||
|
||
import { MergedProvider } from './data'; | ||
import { ProviderActions } from './providerActions'; | ||
|
||
interface CellProps { | ||
value: string; | ||
entity: MergedProvider; | ||
t?: (k: string) => string; | ||
} | ||
const StatusCell = ({ value, entity: { conditions }, t }: CellProps) => { | ||
const existingConditions = Object.values(conditions).filter(Boolean); | ||
const toState = (value) => { | ||
switch (value) { | ||
case 'True': | ||
return 'Ok'; | ||
case 'False': | ||
return 'Error'; | ||
default: | ||
return 'Unknown'; | ||
} | ||
}; | ||
const label = CONDITIONS?.[value]?.(t); | ||
return ( | ||
<Popover | ||
hasAutoWidth | ||
bodyContent={ | ||
<div> | ||
{existingConditions.length > 0 | ||
? existingConditions.map(({ message, status }) => { | ||
return <StatusIcon key={message} status={toState(status)} label={message} />; | ||
}) | ||
: t('No information')} | ||
</div> | ||
} | ||
> | ||
<Button variant="link" isInline aria-label={label}> | ||
<StatusIcon status={toState(value)} label={label} /> | ||
</Button> | ||
</Popover> | ||
); | ||
}; | ||
|
||
const TextCell = ({ value }: { value: string }) => <>{value ?? ''}</>; | ||
|
||
const TextWithIcon = ({ value, Icon }: { value: string; Icon: JSXElementConstructor<unknown> }) => ( | ||
<> | ||
{value && ( | ||
<> | ||
<Icon /> <TextCell value={value} /> | ||
</> | ||
)} | ||
</> | ||
); | ||
|
||
const ProviderLink = ({ value, entity }: CellProps) => ( | ||
<ResourceLink kind={entity.kind} name={value} namespace={entity?.namespace} /> | ||
); | ||
|
||
const HostCell = ({ value, entity: { ready, name, type } }: CellProps) => ( | ||
<> | ||
{ready === 'True' && value && type === 'vsphere' ? ( | ||
<Link to={`${PATH_PREFIX}/providers/vsphere/${name}`}> | ||
<TextWithIcon Icon={OutlinedHddIcon} value={value} /> | ||
</Link> | ||
) : ( | ||
<TextWithIcon Icon={OutlinedHddIcon} value={value} /> | ||
)} | ||
</> | ||
); | ||
|
||
const cellCreator = { | ||
[NAME]: ProviderLink, | ||
[READY]: StatusCell, | ||
[URL]: TextCell, | ||
[TYPE]: ({ value, t }: CellProps) => <TextCell value={PROVIDERS?.[value]?.(t)} />, | ||
[NAMESPACE]: ({ value }: CellProps) => <ResourceLink kind="Namespace" name={value} />, | ||
[ACTIONS]: ProviderActions, | ||
[NETWORK_COUNT]: ({ value }: CellProps) => <TextWithIcon Icon={NetworkIcon} value={value} />, | ||
[STORAGE_COUNT]: ({ value }: CellProps) => <TextWithIcon Icon={DatabaseIcon} value={value} />, | ||
[HOST_COUNT]: HostCell, | ||
}; | ||
|
||
const ProviderRow = ({ columns, entity }: RowProps<MergedProvider>) => { | ||
const { t } = useTranslation(); | ||
return ( | ||
<Tr> | ||
{columns.map(({ id, toLabel }) => ( | ||
<Td key={id} dataLabel={toLabel(t)}> | ||
{cellCreator?.[id]?.({ | ||
value: entity[id], | ||
entity, | ||
t, | ||
}) ?? <TextCell value={String(entity[id] ?? '')} />} | ||
</Td> | ||
))} | ||
</Tr> | ||
); | ||
}; | ||
|
||
export default ProviderRow; |
Oops, something went wrong.