-
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.
Merge pull request #932 from yaacov/logs-in-overview
🐾 Add pods tab to overview page
- Loading branch information
Showing
14 changed files
with
346 additions
and
31 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
104 changes: 104 additions & 0 deletions
104
packages/forklift-console-plugin/src/components/status/StatusIcon.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,104 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
BlueInfoCircleIcon, | ||
GreenCheckCircleIcon, | ||
RedExclamationCircleIcon, | ||
YellowExclamationTriangleIcon, | ||
} from '@openshift-console/dynamic-plugin-sdk'; | ||
import { Spinner } from '@patternfly/react-core'; | ||
import { BanIcon } from '@patternfly/react-icons/dist/esm/icons/ban-icon'; | ||
import { ClipboardListIcon } from '@patternfly/react-icons/dist/esm/icons/clipboard-list-icon'; | ||
import { HourglassHalfIcon } from '@patternfly/react-icons/dist/esm/icons/hourglass-half-icon'; | ||
import { HourglassStartIcon } from '@patternfly/react-icons/dist/esm/icons/hourglass-start-icon'; | ||
import { NotStartedIcon } from '@patternfly/react-icons/dist/esm/icons/not-started-icon'; | ||
import { SyncAltIcon } from '@patternfly/react-icons/dist/esm/icons/sync-alt-icon'; | ||
import { UnknownIcon } from '@patternfly/react-icons/dist/esm/icons/unknown-icon'; | ||
|
||
export const StatusIcon: React.FC<{ phase: string }> = ({ phase }) => { | ||
switch (phase) { | ||
case 'New': | ||
return <HourglassStartIcon />; | ||
|
||
case 'Pending': | ||
return <HourglassHalfIcon />; | ||
|
||
case 'Planning': | ||
return <ClipboardListIcon />; | ||
|
||
case 'ContainerCreating': | ||
case 'UpgradePending': | ||
case 'PendingUpgrade': | ||
case 'PendingRollback': | ||
return <Spinner size="sm" />; | ||
|
||
case 'In Progress': | ||
case 'Installing': | ||
case 'InstallReady': | ||
case 'Replacing': | ||
case 'Running': | ||
case 'Updating': | ||
case 'Upgrading': | ||
case 'PendingInstall': | ||
return <SyncAltIcon />; | ||
|
||
case 'Cancelled': | ||
case 'Deleting': | ||
case 'Expired': | ||
case 'Not Ready': | ||
case 'Cancelling': | ||
case 'Terminating': | ||
case 'Superseded': | ||
case 'Uninstalling': | ||
return <BanIcon />; | ||
|
||
case 'Warning': | ||
case 'RequiresApproval': | ||
return <YellowExclamationTriangleIcon />; | ||
|
||
case 'ContainerCannotRun': | ||
case 'CrashLoopBackOff': | ||
case 'Critical': | ||
case 'ErrImagePull': | ||
case 'Error': | ||
case 'Failed': | ||
case 'Failure': | ||
case 'ImagePullBackOff': | ||
case 'InstallCheckFailed': | ||
case 'Lost': | ||
case 'Rejected': | ||
case 'UpgradeFailed': | ||
return <RedExclamationCircleIcon />; | ||
|
||
case 'Accepted': | ||
case 'Active': | ||
case 'Bound': | ||
case 'Complete': | ||
case 'Completed': | ||
case 'Created': | ||
case 'Enabled': | ||
case 'Succeeded': | ||
case 'Ready': | ||
case 'Up to date': | ||
case 'Loaded': | ||
case 'Provisioned as node': | ||
case 'Preferred': | ||
case 'Connected': | ||
case 'Deployed': | ||
return <GreenCheckCircleIcon />; | ||
|
||
case 'Info': | ||
return <BlueInfoCircleIcon />; | ||
|
||
case 'Unknown': | ||
return <UnknownIcon />; | ||
|
||
case 'PipelineNotStarted': | ||
return <NotStartedIcon />; | ||
|
||
default: | ||
return <>-</>; | ||
} | ||
}; | ||
|
||
export default StatusIcon; |
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
75 changes: 75 additions & 0 deletions
75
...ages/forklift-console-plugin/src/modules/Overview/views/overview/components/PodsTable.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,75 @@ | ||
import React from 'react'; | ||
import StatusIcon from 'src/components/status/StatusIcon'; | ||
import { useForkliftTranslation } from 'src/utils/i18n'; | ||
|
||
import { IoK8sApiCoreV1Pod } from '@kubev2v/types'; | ||
import { ResourceLink, Timestamp } from '@openshift-console/dynamic-plugin-sdk'; | ||
import { Split, SplitItem } from '@patternfly/react-core'; | ||
import { TableComposable, Tbody, Td, Th, Thead, Tr } from '@patternfly/react-table'; | ||
|
||
export const PodsTable: React.FC<PodsTableProps> = ({ pods, showOwner }) => { | ||
const { t } = useForkliftTranslation(); | ||
|
||
if (!pods) { | ||
return <></>; | ||
} | ||
|
||
const getStatusLabel = (phase: string) => { | ||
return ( | ||
<Split> | ||
<SplitItem className="forklift-overview__controller-card__status-icon"> | ||
<StatusIcon phase={phase} /> | ||
</SplitItem> | ||
<SplitItem>{phase}</SplitItem> | ||
</Split> | ||
); | ||
}; | ||
|
||
return ( | ||
<TableComposable aria-label="Expandable table" variant="compact"> | ||
<Thead> | ||
<Tr> | ||
<Th width={20}>{t('Pod')}</Th> | ||
{showOwner && <Th width={20}>{t('Owner')}</Th>} | ||
<Th width={10}>{t('Status')}</Th> | ||
<Th width={10}>{t('Created at')}</Th> | ||
</Tr> | ||
</Thead> | ||
<Tbody> | ||
{pods.map((pod) => ( | ||
<Tr key={pod?.metadata?.uid}> | ||
<Td> | ||
<ResourceLink | ||
kind={pod?.kind} | ||
name={pod?.metadata?.name} | ||
namespace={pod?.metadata?.namespace} | ||
/> | ||
</Td> | ||
{showOwner && ( | ||
<Td> | ||
{pod?.metadata?.ownerReferences?.[0] ? ( | ||
<ResourceLink | ||
kind={pod?.metadata?.ownerReferences?.[0]?.kind} | ||
name={pod?.metadata?.ownerReferences?.[0]?.name} | ||
namespace={pod?.metadata?.namespace} | ||
/> | ||
) : ( | ||
'' | ||
)} | ||
</Td> | ||
)} | ||
<Td>{getStatusLabel(pod?.status?.phase)}</Td> | ||
<Td> | ||
<Timestamp timestamp={pod?.metadata?.creationTimestamp} /> | ||
</Td> | ||
</Tr> | ||
))} | ||
</Tbody> | ||
</TableComposable> | ||
); | ||
}; | ||
|
||
export type PodsTableProps = { | ||
pods: IoK8sApiCoreV1Pod[]; | ||
showOwner?: boolean; | ||
}; |
2 changes: 2 additions & 0 deletions
2
packages/forklift-console-plugin/src/modules/Overview/views/overview/components/index.ts
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,4 +1,6 @@ | ||
// @index(['./*', /style/g], f => `export * from '${f.path}';`) | ||
export * from './HeaderTitle'; | ||
export * from './OperatorStatus'; | ||
export * from './PodsTable'; | ||
export * from './ShowWelcomeCardButton'; | ||
// @endindex |
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
38 changes: 38 additions & 0 deletions
38
...-console-plugin/src/modules/Overview/views/overview/tabs/Details/cards/ControllerCard.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,38 @@ | ||
import React, { FC } from 'react'; | ||
import { Suspend } from 'src/modules/Plans/views/details/components'; | ||
import { useForkliftTranslation } from 'src/utils/i18n'; | ||
|
||
import { IoK8sApiCoreV1Pod, V1beta1ForkliftController } from '@kubev2v/types'; | ||
import { useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk'; | ||
import { Card, CardBody, CardTitle } from '@patternfly/react-core'; | ||
|
||
import { PodsTable } from '../../../components'; | ||
|
||
type ControllerCardProps = { | ||
obj?: V1beta1ForkliftController; | ||
}; | ||
|
||
export const ControllerCard: FC<ControllerCardProps> = ({ obj }) => { | ||
const { t } = useForkliftTranslation(); | ||
|
||
const [pods, loaded, loadError] = useK8sWatchResource<IoK8sApiCoreV1Pod[]>({ | ||
kind: 'Pod', | ||
namespaced: true, | ||
isList: true, | ||
namespace: obj?.metadata?.namespace, | ||
selector: { matchLabels: { app: 'forklift', 'control-plane': 'controller-manager' } }, | ||
}); | ||
|
||
return ( | ||
<Card> | ||
<CardTitle className="forklift-title">{t('Controller')}</CardTitle> | ||
<Suspend obj={pods} loaded={loaded} loadError={loadError}> | ||
<CardBody> | ||
<PodsTable pods={pods} /> | ||
</CardBody> | ||
</Suspend> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default ControllerCard; |
1 change: 1 addition & 0 deletions
1
...s/forklift-console-plugin/src/modules/Overview/views/overview/tabs/Details/cards/index.ts
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
Oops, something went wrong.