-
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 inventory REST API. 3. generic (empty) details page is provided via extentsion point 'console.page/resource/details' 4. actions in the table (kebab actions) as well as actions in the details page are provided via extension points: 'console.action/provider' and 'console.action/resource-provider' 5. inventory tab (part of the details) is provided via extension point 'console.tab/horizontalNav' Functional changes: 1. display all providers in one table 2. use only 'Ready' condition to describe the state of the provider Signed-off-by: Radoslaw Szwajkowski <[email protected]>
- Loading branch information
Showing
19 changed files
with
856 additions
and
4 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,50 @@ | ||
{ | ||
"{{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 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", | ||
"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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import * as React from 'react'; | ||
import { ErrorState, Loading } from 'src/components/StandardPage'; | ||
import { useTranslation } from 'src/internal/i18n'; | ||
import { ProviderResource } from 'src/internal/k8s'; | ||
|
||
import { | ||
DescriptionList, | ||
DescriptionListDescription, | ||
DescriptionListGroup, | ||
DescriptionListTerm, | ||
PageSection, | ||
} from '@patternfly/react-core'; | ||
|
||
import { useProvidersWithInventory } from './data'; | ||
|
||
interface ProviderDetailPageProps { | ||
obj: ProviderResource; | ||
} | ||
|
||
const ProviderInventoryTab = ({ obj }: ProviderDetailPageProps) => { | ||
const [[provider], loaded, error] = useProvidersWithInventory({ | ||
kind: obj?.kind ?? '', | ||
namespace: obj?.metadata?.namespace ?? '', | ||
name: obj?.metadata?.name ?? '', | ||
}); | ||
const { t } = useTranslation(); | ||
return ( | ||
<PageSection> | ||
{!loaded && <Loading />} | ||
{loaded && error && <ErrorState />} | ||
{loaded && !error && provider && ( | ||
<DescriptionList | ||
columnModifier={{ | ||
default: '1Col', | ||
md: '2Col', | ||
}} | ||
> | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>{t('Ready')}</DescriptionListTerm> | ||
<DescriptionListDescription>{provider.ready}</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>{t('Endpoint')}</DescriptionListTerm> | ||
<DescriptionListDescription>{provider.url}</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>{t('Type')}</DescriptionListTerm> | ||
<DescriptionListDescription>{provider.type}</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>{t('VMs')}</DescriptionListTerm> | ||
<DescriptionListDescription>{provider.vmCount}</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>{t('Networks')}</DescriptionListTerm> | ||
<DescriptionListDescription>{provider.networkCount}</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>{t('Clusters')}</DescriptionListTerm> | ||
<DescriptionListDescription>{provider.clusterCount}</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>{t('Hosts')}</DescriptionListTerm> | ||
<DescriptionListDescription>{provider.hostCount}</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>{t('Storage')}</DescriptionListTerm> | ||
<DescriptionListDescription>{provider.storageCount}</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
</DescriptionList> | ||
)} | ||
</PageSection> | ||
); | ||
}; | ||
|
||
export default ProviderInventoryTab; |
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,76 @@ | ||
import React from 'react'; | ||
import { RowProps } from 'src/components/TableView'; | ||
import { useTranslation } from 'src/internal/i18n'; | ||
import { NAME, NAMESPACE, READY, TYPE, URL } from 'src/utils/constants'; | ||
|
||
import { StatusIcon } from '@migtools/lib-ui'; | ||
import { ResourceLink } from '@openshift-console/dynamic-plugin-sdk'; | ||
import { Button, Popover } from '@patternfly/react-core'; | ||
import { Td, Tr } from '@patternfly/react-table'; | ||
|
||
import { MergedProvider } from './data'; | ||
import { ProviderActions } from './providerActions'; | ||
|
||
interface CellProps { | ||
value: string; | ||
entity: MergedProvider; | ||
} | ||
const StatusCell = ({ value, entity: { conditions } }: CellProps) => { | ||
const { t } = useTranslation(); | ||
const existingConditions = Object.values(conditions).filter(Boolean); | ||
const toState = (value) => (value === 'True' ? 'Ok' : value === 'False' ? 'Error' : 'Unknown'); | ||
const label = value === 'True' ? t('True') : value === 'False' ? t('False') : t('Unknown'); | ||
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 ProviderLink = ({ value, entity }: CellProps) => ( | ||
<ResourceLink kind={entity.kind} name={value} namespace={entity?.namespace} /> | ||
); | ||
|
||
const cellCreator = { | ||
[NAME]: ProviderLink, | ||
[READY]: StatusCell, | ||
[URL]: TextCell, | ||
[TYPE]: TextCell, | ||
[NAMESPACE]: ({ value }: CellProps) => <ResourceLink kind="Namespace" name={value} />, | ||
}; | ||
|
||
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, | ||
}) ?? <TextCell value={String(entity[id] ?? '')} />} | ||
</Td> | ||
))} | ||
<Td modifier="fitContent"> | ||
<ProviderActions entity={entity} /> | ||
</Td> | ||
</Tr> | ||
); | ||
}; | ||
|
||
export default ProviderRow; |
Oops, something went wrong.