From 1b5034686bd95e2d7929f92953f226ce356a0745 Mon Sep 17 00:00:00 2001 From: Jiri Tomasek Date: Wed, 12 Jun 2019 13:07:02 +0200 Subject: [PATCH 1/3] Add Status components to @console/shared * Introduces common Status components which are supposed to replace current StatusIconAndText component usage * Expands Icon + Text implementation with Link and Popover capabilities * Allows to define custom resource specific status handling while reusing existing status components (important for plugins) * Allows to easily define custom status components while reusing underlining components provided * Current StatusIconAndText usage is replaces by Status component * Uses PatternFly4 icons * Adds ability to render icon only * Adds ability to specify custom title for the status --- .../console-shared/src/components/index.ts | 1 + .../src/components/status/ErrorStatus.tsx | 23 ++++++ .../src/components/status/Icons.tsx | 27 ++++++ .../src/components/status/InfoStatus.tsx | 23 ++++++ .../src/components/status/LinkStatus.tsx | 28 +++++++ .../src/components/status/PopoverStatus.tsx | 21 +++++ .../src/components/status/ProgressStatus.tsx | 15 ++++ .../src/components/status/Status.tsx | 82 +++++++++++++++++++ .../src/components/status/StatusIcon.tsx | 6 ++ .../components/status/StatusIconAndText.tsx | 34 ++++++++ .../src/components/status/SuccessStatus.tsx | 15 ++++ .../src/components/status/index.ts | 10 +++ 12 files changed, 285 insertions(+) create mode 100644 frontend/packages/console-shared/src/components/status/ErrorStatus.tsx create mode 100644 frontend/packages/console-shared/src/components/status/Icons.tsx create mode 100644 frontend/packages/console-shared/src/components/status/InfoStatus.tsx create mode 100644 frontend/packages/console-shared/src/components/status/LinkStatus.tsx create mode 100644 frontend/packages/console-shared/src/components/status/PopoverStatus.tsx create mode 100644 frontend/packages/console-shared/src/components/status/ProgressStatus.tsx create mode 100644 frontend/packages/console-shared/src/components/status/Status.tsx create mode 100644 frontend/packages/console-shared/src/components/status/StatusIcon.tsx create mode 100644 frontend/packages/console-shared/src/components/status/StatusIconAndText.tsx create mode 100644 frontend/packages/console-shared/src/components/status/SuccessStatus.tsx create mode 100644 frontend/packages/console-shared/src/components/status/index.ts diff --git a/frontend/packages/console-shared/src/components/index.ts b/frontend/packages/console-shared/src/components/index.ts index 42951b9d9e3..acff32325df 100644 --- a/frontend/packages/console-shared/src/components/index.ts +++ b/frontend/packages/console-shared/src/components/index.ts @@ -1 +1,2 @@ export { default as TechPreviewBadge } from './TechPreviewBadge'; +export * from './status'; diff --git a/frontend/packages/console-shared/src/components/status/ErrorStatus.tsx b/frontend/packages/console-shared/src/components/status/ErrorStatus.tsx new file mode 100644 index 00000000000..080fae14a6b --- /dev/null +++ b/frontend/packages/console-shared/src/components/status/ErrorStatus.tsx @@ -0,0 +1,23 @@ +import * as React from 'react'; + +import PopoverStatus from './PopoverStatus'; +import StatusIconAndText from './StatusIconAndText'; +import { RedExclamationCircleIcon } from './Icons'; + +type ErrorStatusProps = { + title?: string; + iconOnly?: boolean; +}; + +const ErrorStatus: React.FC = ({ title, iconOnly, children }) => { + const icon = ; + return children ? ( + + {children} + + ) : ( + + ); +}; + +export default ErrorStatus; diff --git a/frontend/packages/console-shared/src/components/status/Icons.tsx b/frontend/packages/console-shared/src/components/status/Icons.tsx new file mode 100644 index 00000000000..86adaf7c8f6 --- /dev/null +++ b/frontend/packages/console-shared/src/components/status/Icons.tsx @@ -0,0 +1,27 @@ +import * as React from 'react'; +import { + CheckCircleIcon, + ExclamationCircleIcon, + ExclamationTriangleIcon, +} from '@patternfly/react-icons'; +import { + global_success_color_100 as successColor, + global_warning_color_100 as warningColor, + global_danger_color_100 as dangerColor, +} from '@patternfly/react-tokens'; + +export type ColoredIconProps = { + className?: string; +}; + +export const GreenCheckCircleIcon: React.FC = ({ className }) => { + return ; +}; + +export const RedExclamationCircleIcon: React.FC = ({ className }) => { + return ; +}; + +export const YellowExclamationTriangleIcon: React.FC = ({ className }) => { + return ; +}; diff --git a/frontend/packages/console-shared/src/components/status/InfoStatus.tsx b/frontend/packages/console-shared/src/components/status/InfoStatus.tsx new file mode 100644 index 00000000000..7e2feaa4a4d --- /dev/null +++ b/frontend/packages/console-shared/src/components/status/InfoStatus.tsx @@ -0,0 +1,23 @@ +import * as React from 'react'; +import { InfoCircleIcon } from '@patternfly/react-icons'; + +import PopoverStatus from './PopoverStatus'; +import StatusIconAndText from './StatusIconAndText'; + +type InfoStatusProps = { + title?: string; + iconOnly?: boolean; +}; + +const InfoStatus: React.FC = ({ title, iconOnly, children }) => { + const icon = ; + return children ? ( + + {children} + + ) : ( + + ); +}; + +export default InfoStatus; diff --git a/frontend/packages/console-shared/src/components/status/LinkStatus.tsx b/frontend/packages/console-shared/src/components/status/LinkStatus.tsx new file mode 100644 index 00000000000..45925fa76e9 --- /dev/null +++ b/frontend/packages/console-shared/src/components/status/LinkStatus.tsx @@ -0,0 +1,28 @@ +import * as React from 'react'; +import * as History from 'history'; +import { Link } from 'react-router-dom'; + +import StatusIconAndText from './StatusIconAndText'; + +type LinkStatusProps = React.ComponentProps & { + linkTitle?: string; + linkTo?: History.LocationDescriptor; +}; + +const LinkStatus: React.FC = ({ + icon, + title, + spin, + linkTitle, + linkTo, + iconOnly, +}) => + linkTo ? ( + + + + ) : ( + + ); + +export default LinkStatus; diff --git a/frontend/packages/console-shared/src/components/status/PopoverStatus.tsx b/frontend/packages/console-shared/src/components/status/PopoverStatus.tsx new file mode 100644 index 00000000000..b3c2612244e --- /dev/null +++ b/frontend/packages/console-shared/src/components/status/PopoverStatus.tsx @@ -0,0 +1,21 @@ +import * as React from 'react'; +import { Popover, PopoverPosition } from '@patternfly/react-core'; +import { Button } from 'patternfly-react'; + +import StatusIconAndText from './StatusIconAndText'; + +const PopoverStatus: React.FC> = ({ + icon, + title, + spin, + children, + iconOnly, +}) => ( + + + +); + +export default PopoverStatus; diff --git a/frontend/packages/console-shared/src/components/status/ProgressStatus.tsx b/frontend/packages/console-shared/src/components/status/ProgressStatus.tsx new file mode 100644 index 00000000000..ba482a6b617 --- /dev/null +++ b/frontend/packages/console-shared/src/components/status/ProgressStatus.tsx @@ -0,0 +1,15 @@ +import * as React from 'react'; +import { InProgressIcon } from '@patternfly/react-icons'; + +import StatusIconAndText from './StatusIconAndText'; + +type ProgressStatusProps = { + title?: string; + iconOnly?: boolean; +}; + +const ProgressStatus: React.FC = ({ title, iconOnly }) => ( + } title={title} iconOnly={iconOnly} /> +); + +export default ProgressStatus; diff --git a/frontend/packages/console-shared/src/components/status/Status.tsx b/frontend/packages/console-shared/src/components/status/Status.tsx new file mode 100644 index 00000000000..430d02ae904 --- /dev/null +++ b/frontend/packages/console-shared/src/components/status/Status.tsx @@ -0,0 +1,82 @@ +import * as React from 'react'; +import { + HourglassStartIcon, + HourglassHalfIcon, + SyncAltIcon, + BanIcon, + ExclamationTriangleIcon, + UnknownIcon, +} from '@patternfly/react-icons'; + +import StatusIconAndText from './StatusIconAndText'; +import ProgressStatus from './ProgressStatus'; +import ErrorStatus from './ErrorStatus'; +import SuccessStatus from './SuccessStatus'; +import InfoStatus from './InfoStatus'; +import { DASH } from '../../constants'; + +export type StatusProps = { + status?: string; + title?: string; + iconOnly?: boolean; +}; + +const Status: React.FC = ({ status, title, children, iconOnly }) => { + const statusProps = { title: title || status, iconOnly }; + switch (status) { + case 'New': + return } />; + + case 'Pending': + return } />; + + case 'ContainerCreating': + return ; + + case 'In Progress': + case 'Running': + case 'Updating': + case 'Upgrading': + return } />; + + case 'Cancelled': + case 'Expired': + case 'Not Ready': + case 'Terminating': + return } />; + + case 'Warning': + return } />; + + case 'ContainerCannotRun': + case 'CrashLoopBackOff': + case 'Critical': + case 'Error': + case 'Failed': + case 'InstallCheckFailed': + case 'Lost': + case 'Rejected': + return {children}; + + case 'Accepted': + case 'Active': + case 'Bound': + case 'Complete': + case 'Completed': + case 'Enabled': + case 'Ready': + case 'Up to date': + return ; + + case 'Info': + return {children}; + + case 'Unknown': + return } />; + + default: + return <>{DASH}; + } +}; + +export default Status; diff --git a/frontend/packages/console-shared/src/components/status/StatusIcon.tsx b/frontend/packages/console-shared/src/components/status/StatusIcon.tsx new file mode 100644 index 00000000000..116b1580a82 --- /dev/null +++ b/frontend/packages/console-shared/src/components/status/StatusIcon.tsx @@ -0,0 +1,6 @@ +import * as React from 'react'; +import Status from './Status'; + +const StatusIcon = ({ status }) => ; + +export default StatusIcon; diff --git a/frontend/packages/console-shared/src/components/status/StatusIconAndText.tsx b/frontend/packages/console-shared/src/components/status/StatusIconAndText.tsx new file mode 100644 index 00000000000..17224aafd55 --- /dev/null +++ b/frontend/packages/console-shared/src/components/status/StatusIconAndText.tsx @@ -0,0 +1,34 @@ +import * as React from 'react'; +import classNames from 'classnames'; + +import { CamelCaseWrap } from '@console/internal/components/utils'; +import { DASH } from '../../constants'; + +type StatusIconAndTextProps = { + icon?: React.ReactElement; + title?: string; + spin?: boolean; + iconOnly?: boolean; +}; + +const StatusIconAndText: React.FC = ({ icon, title, spin, iconOnly }) => { + if (!title) { + return <>{DASH}; + } + + return ( + + {icon && + React.cloneElement(icon, { + className: classNames( + spin && 'fa-spin', + icon.props.className, + !iconOnly && 'co-icon-and-text__icon', + ), + })} + {!iconOnly && } + + ); +}; + +export default StatusIconAndText; diff --git a/frontend/packages/console-shared/src/components/status/SuccessStatus.tsx b/frontend/packages/console-shared/src/components/status/SuccessStatus.tsx new file mode 100644 index 00000000000..d0afffb4743 --- /dev/null +++ b/frontend/packages/console-shared/src/components/status/SuccessStatus.tsx @@ -0,0 +1,15 @@ +import * as React from 'react'; + +import { GreenCheckCircleIcon } from './Icons'; +import StatusIconAndText from './StatusIconAndText'; + +type SuccessStatusProps = { + title?: string; + iconOnly?: boolean; +}; + +const SuccessStatus: React.FC = ({ title, iconOnly }) => ( + } title={title} iconOnly={iconOnly} /> +); + +export default SuccessStatus; diff --git a/frontend/packages/console-shared/src/components/status/index.ts b/frontend/packages/console-shared/src/components/status/index.ts new file mode 100644 index 00000000000..1ec174834f0 --- /dev/null +++ b/frontend/packages/console-shared/src/components/status/index.ts @@ -0,0 +1,10 @@ +export { default as Status } from './Status'; +export { default as StatusIcon } from './StatusIcon'; +export { default as StatusIconAndText } from './StatusIconAndText'; +export { default as PopoverStatus } from './PopoverStatus'; +export { default as LinkStatus } from './LinkStatus'; +export { default as SuccessStatus } from './SuccessStatus'; +export { default as ErrorStatus } from './ErrorStatus'; +export { default as InfoStatus } from './InfoStatus'; +export { default as ProgressStatus } from './ProgressStatus'; +export * from './Icons'; From f0b89df6dfbfefb49027bcfebc98377582324127 Mon Sep 17 00:00:00 2001 From: Jiri Tomasek Date: Mon, 24 Jun 2019 13:48:46 +0200 Subject: [PATCH 2/3] Replace StatusIconAndText with Status component --- .../clusterserviceversion.spec.tsx | 5 +-- .../__tests__/components/route-pages.spec.tsx | 16 ++++++---- .../data-resiliency/data-resiliency.tsx | 5 +-- .../pipelineruns/PipelineRunRow.tsx | 12 +++---- .../src/components/pipelines/PipelineRow.tsx | 12 +++---- .../src/components/host-detail.tsx | 4 +-- .../src/components/host-status.tsx | 29 ++++++++++------- .../src/components/machine-cell.tsx | 10 ++---- frontend/public/components/build.tsx | 7 ++-- frontend/public/components/container.tsx | 4 +-- .../dashboard/events-card/event-item.tsx | 2 +- .../dashboard/health-card/alert-item.tsx | 2 +- .../dashboard/health-card/health-item.tsx | 32 +++++++++---------- .../inventory-card/inventory-item.tsx | 6 ++-- .../public/components/deployment-config.tsx | 7 ++-- frontend/public/components/deployment.tsx | 7 ++-- frontend/public/components/job.jsx | 6 ++-- frontend/public/components/namespace.jsx | 9 +++--- frontend/public/components/node.tsx | 6 ++-- .../operator-hub/operator-hub-items.tsx | 2 +- .../clusterserviceversion.tsx | 6 ++-- .../descriptors/status/index.tsx | 8 ++--- .../operator-lifecycle-manager/operand.tsx | 7 ++-- .../components/overview/build-overview.tsx | 25 +++++++++------ .../components/overview/project-overview.tsx | 4 +-- .../components/persistent-volume-claim.jsx | 6 ++-- .../public/components/persistent-volume.jsx | 6 ++-- frontend/public/components/pod.tsx | 12 +++---- frontend/public/components/routes.tsx | 6 ++-- .../public/components/template-instance.tsx | 7 ++-- .../utils/service-catalog-status.tsx | 4 +-- 31 files changed, 145 insertions(+), 129 deletions(-) diff --git a/frontend/__tests__/components/operator-lifecycle-manager/clusterserviceversion.spec.tsx b/frontend/__tests__/components/operator-lifecycle-manager/clusterserviceversion.spec.tsx index 7fb903a0b7d..86136c745de 100644 --- a/frontend/__tests__/components/operator-lifecycle-manager/clusterserviceversion.spec.tsx +++ b/frontend/__tests__/components/operator-lifecycle-manager/clusterserviceversion.spec.tsx @@ -94,8 +94,9 @@ describe(ClusterServiceVersionTableRow.displayName, () => { it('renders column for app status', () => { const col = wrapper.find(TableRow).childAt(3); - - expect(col.childAt(0).text()).toContain(CSVConditionReason.CSVReasonInstallSuccessful); + const statusComponent = col.childAt(0).find('SuccessStatus'); + expect(statusComponent.exists()).toBeTruthy(); + expect(statusComponent.prop('title')).toEqual(CSVConditionReason.CSVReasonInstallSuccessful); }); it('renders "disabling" status if CSV has `deletionTimestamp`', () => { diff --git a/frontend/__tests__/components/route-pages.spec.tsx b/frontend/__tests__/components/route-pages.spec.tsx index 0dfae95ca9d..7b32105a525 100644 --- a/frontend/__tests__/components/route-pages.spec.tsx +++ b/frontend/__tests__/components/route-pages.spec.tsx @@ -196,8 +196,9 @@ describe(RouteStatus.displayName, () => { }; const wrapper = mount(); - expect(wrapper.find('.co-icon-and-text__icon').exists()).toBe(true); - expect(wrapper.text()).toEqual('Accepted'); + const statusComponent = wrapper.find('SuccessStatus'); + expect(statusComponent.exists()).toBeTruthy(); + expect(statusComponent.prop('title')).toEqual('Accepted'); }); it('renders Rejected status', () => { @@ -223,8 +224,9 @@ describe(RouteStatus.displayName, () => { }; const wrapper = mount(); - expect(wrapper.find('.co-icon-and-text__icon').exists()).toBe(true); - expect(wrapper.text()).toEqual('Rejected'); + const statusComponent = wrapper.find('ErrorStatus'); + expect(statusComponent.exists()).toBeTruthy(); + expect(statusComponent.prop('title')).toEqual('Rejected'); }); it('renders Pending status', () => { @@ -237,7 +239,9 @@ describe(RouteStatus.displayName, () => { }; const wrapper = mount(); - expect(wrapper.find('.co-icon-and-text__icon').exists()).toBe(true); - expect(wrapper.text()).toEqual('Pending'); + const statusComponent = wrapper.find('StatusIconAndText'); + const icon = wrapper.find('HourglassHalfIcon'); + expect(icon.exists()).toBeTruthy(); + expect(statusComponent.prop('title')).toEqual('Pending'); }); }); diff --git a/frontend/packages/ceph-storage-plugin/src/components/dashboard-page/storage-dashboard/data-resiliency/data-resiliency.tsx b/frontend/packages/ceph-storage-plugin/src/components/dashboard-page/storage-dashboard/data-resiliency/data-resiliency.tsx index d5a8fadc958..a29505a9ffb 100644 --- a/frontend/packages/ceph-storage-plugin/src/components/dashboard-page/storage-dashboard/data-resiliency/data-resiliency.tsx +++ b/frontend/packages/ceph-storage-plugin/src/components/dashboard-page/storage-dashboard/data-resiliency/data-resiliency.tsx @@ -4,6 +4,7 @@ import { Progress } from '@patternfly/react-core'; import './data-resiliency.scss'; +import { GreenCheckCircleIcon, RedExclamationCircleIcon } from '@console/shared'; import { DashboardCard } from '@console/internal/components/dashboard/dashboard-card/card'; import { DashboardCardBody } from '@console/internal/components/dashboard/dashboard-card/card-body'; import { DashboardCardHeader } from '@console/internal/components/dashboard/dashboard-card/card-header'; @@ -12,10 +13,6 @@ import { withDashboardResources, DashboardItemProps, } from '@console/internal/components/dashboards-page/with-dashboard-resources'; -import { - GreenCheckCircleIcon, - RedExclamationCircleIcon, -} from '@console/internal/components/utils/status-icon'; import { DATA_RESILIENCY_QUERIES } from '../../../../constants/queries'; diff --git a/frontend/packages/dev-console/src/components/pipelineruns/PipelineRunRow.tsx b/frontend/packages/dev-console/src/components/pipelineruns/PipelineRunRow.tsx index 0bb58073bae..6d604725d65 100644 --- a/frontend/packages/dev-console/src/components/pipelineruns/PipelineRunRow.tsx +++ b/frontend/packages/dev-console/src/components/pipelineruns/PipelineRunRow.tsx @@ -1,12 +1,8 @@ import * as React from 'react'; + +import { Status } from '@console/shared'; import { TableRow, TableData } from '@console/internal/components/factory'; -import { - Kebab, - ResourceLink, - Timestamp, - ResourceKebab, - StatusIconAndText, -} from '@console/internal/components/utils'; +import { Kebab, ResourceLink, Timestamp, ResourceKebab } from '@console/internal/components/utils'; import { referenceForModel } from '@console/internal/module/k8s'; import { pipelineRunFilterReducer } from '../../utils/pipeline-filter-reducer'; import { reRunPipelineRun, stopPipelineRun } from '../../utils/pipeline-actions'; @@ -40,7 +36,7 @@ const PipelineRunRow: React.FC = ({ obj, index, key, style - + diff --git a/frontend/packages/dev-console/src/components/pipelines/PipelineRow.tsx b/frontend/packages/dev-console/src/components/pipelines/PipelineRow.tsx index 9f677a3f8af..a6c124ccb9e 100644 --- a/frontend/packages/dev-console/src/components/pipelines/PipelineRow.tsx +++ b/frontend/packages/dev-console/src/components/pipelines/PipelineRow.tsx @@ -1,12 +1,8 @@ import * as React from 'react'; + +import { Status } from '@console/shared'; import { TableRow, TableData } from '@console/internal/components/factory'; -import { - Kebab, - ResourceLink, - Timestamp, - ResourceKebab, - StatusIconAndText, -} from '@console/internal/components/utils'; +import { Kebab, ResourceLink, Timestamp, ResourceKebab } from '@console/internal/components/utils'; import { referenceForModel } from '@console/internal/module/k8s'; import { pipelineFilterReducer } from '../../utils/pipeline-filter-reducer'; import { Pipeline } from '../../utils/pipeline-augment'; @@ -53,7 +49,7 @@ const PipelineRow: React.FC = ({ obj, index, key, style }) => )} - + {(obj.latestRun && ) || diff --git a/frontend/packages/metal3-plugin/src/components/host-detail.tsx b/frontend/packages/metal3-plugin/src/components/host-detail.tsx index d97eb5a5186..6fc5aa8f3a9 100644 --- a/frontend/packages/metal3-plugin/src/components/host-detail.tsx +++ b/frontend/packages/metal3-plugin/src/components/host-detail.tsx @@ -17,7 +17,6 @@ import { SectionHeading, Timestamp, humanizeDecimalBytes, - StatusIconAndText, ResourceLink, FirehoseResource, } from '@console/internal/components/utils'; @@ -28,6 +27,7 @@ import { getMachineNodeName, getNamespace, getMachineRole, + StatusIconAndText, } from '@console/shared'; import { ResourceEventStream } from '@console/internal/components/events'; @@ -148,7 +148,7 @@ const BaremetalHostDetails: React.FC = ({
Power Status
: } />
diff --git a/frontend/packages/metal3-plugin/src/components/host-status.tsx b/frontend/packages/metal3-plugin/src/components/host-status.tsx index 4381a33dc6b..cb2eb940e5f 100644 --- a/frontend/packages/metal3-plugin/src/components/host-status.tsx +++ b/frontend/packages/metal3-plugin/src/components/host-status.tsx @@ -1,13 +1,15 @@ import * as React from 'react'; import { Button } from 'patternfly-react'; -import { AddCircleOIcon, SyncAltIcon, UnknownIcon, MaintenanceIcon } from '@patternfly/react-icons'; +import { AddCircleOIcon, MaintenanceIcon } from '@patternfly/react-icons'; -import { K8sResourceKind } from '@console/internal/module/k8s'; import { + ProgressStatus, + SuccessStatus, + ErrorStatus, + Status, StatusIconAndText, - GreenCheckCircleIcon, - RedExclamationCircleIcon, -} from '@console/internal/components/utils/status-icon'; +} from '@console/shared'; +import { K8sResourceKind } from '@console/internal/module/k8s'; import { RequireCreatePermission } from '@console/internal/components/utils'; import { HostMultiStatus } from '../utils/host-status'; @@ -32,7 +34,7 @@ export const AddDiscoveredHostButton: React.FC<{ host: K8sResourceKind }> = ( return ( ); @@ -43,22 +45,25 @@ type BaremetalHostStatusProps = { status: HostMultiStatus; }; -const BaremetalHostStatus = ({ host, status: { status, title } }: BaremetalHostStatusProps) => { +const BaremetalHostStatus = ({ + host, + status: { status, title, errorMessage }, +}: BaremetalHostStatusProps) => { const statusTitle = title || status; switch (true) { case status === HOST_STATUS_DISCOVERED: return ; case status === HOST_STATUS_UNDER_MAINTENANCE: - return } />; + return } title={statusTitle} />; case HOST_PROGRESS_STATES.includes(status): - return } />; + return ; case HOST_SUCCESS_STATES.includes(status): - return } />; + return ; case HOST_ERROR_STATES.includes(status): - return } />; + return {errorMessage}; default: - return } />; + return ; } }; diff --git a/frontend/packages/metal3-plugin/src/components/machine-cell.tsx b/frontend/packages/metal3-plugin/src/components/machine-cell.tsx index f7de99f88e7..2cf26b9e9e1 100644 --- a/frontend/packages/metal3-plugin/src/components/machine-cell.tsx +++ b/frontend/packages/metal3-plugin/src/components/machine-cell.tsx @@ -2,13 +2,9 @@ import * as React from 'react'; import { Link } from 'react-router-dom'; import { AddCircleOIcon } from '@patternfly/react-icons'; -import { DASH } from '@console/shared'; +import { DASH, StatusIconAndText } from '@console/shared'; import { MachineModel } from '@console/internal/models'; -import { - ResourceLink, - RequireCreatePermission, - StatusIconAndText, -} from '@console/internal/components/utils'; +import { ResourceLink, RequireCreatePermission } from '@console/internal/components/utils'; import { referenceForModel, K8sResourceKind } from '@console/internal/module/k8s'; import { getHostMachineName } from '../selectors'; @@ -42,7 +38,7 @@ const MachineCell: React.FC = ({ host, status }) => { return ( - } /> + } title="Add machine" /> ); diff --git a/frontend/public/components/build.tsx b/frontend/public/components/build.tsx index 9c6e823146c..5ed338f83ac 100644 --- a/frontend/public/components/build.tsx +++ b/frontend/public/components/build.tsx @@ -3,6 +3,8 @@ import * as _ from 'lodash-es'; import { Link } from 'react-router-dom'; import * as classNames from 'classnames'; import { sortable } from '@patternfly/react-table'; + +import { Status } from '@console/shared'; import { K8sResourceKindReference, referenceFor, K8sResourceKind, k8sPatch, K8sKind } from '../module/k8s'; import { cloneBuild, formatBuildDuration, getBuildNumber } from '../module/k8s/builds'; import { DetailsPage, ListPage, Table, TableRow, TableData } from './factory'; @@ -23,7 +25,6 @@ import { resourcePath, ResourceSummary, SectionHeading, - StatusIconAndText, Timestamp, } from './utils'; import { BuildPipeline, BuildPipelineLogLink } from './build-pipeline'; @@ -172,7 +173,7 @@ export const BuildsDetails: React.SFC = ({ obj: build }) =>
Status
-
+
{logSnippet &&
Log Snippet
} {logSnippet &&
{logSnippet}
} {message &&
Reason
} @@ -286,7 +287,7 @@ const BuildsTableRow: React.FC = ({obj, index, key, style}) - + {fromNow(obj.metadata.creationTimestamp)} diff --git a/frontend/public/components/container.tsx b/frontend/public/components/container.tsx index b095f2cdf42..02b06d57180 100644 --- a/frontend/public/components/container.tsx +++ b/frontend/public/components/container.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import * as _ from 'lodash-es'; +import { Status } from '@console/shared'; import { ContainerLifecycle, ContainerLifecycleStage, @@ -28,7 +29,6 @@ import { ResourceLink, ScrollToTopOnMount, SectionHeading, - StatusIconAndText, Timestamp, } from './utils'; import { resourcePath } from './utils/resource-link'; @@ -190,7 +190,7 @@ const ContainerDetails: React.FC = (props) => {
State
-
+
ID
{status.containerID || '-'}
Restarts
diff --git a/frontend/public/components/dashboard/events-card/event-item.tsx b/frontend/public/components/dashboard/events-card/event-item.tsx index 1387840b7e5..7d92e50bb8e 100644 --- a/frontend/public/components/dashboard/events-card/event-item.tsx +++ b/frontend/public/components/dashboard/events-card/event-item.tsx @@ -1,13 +1,13 @@ import * as React from 'react'; import { Link } from 'react-router-dom'; +import { RedExclamationCircleIcon } from '@console/shared'; import { connectToFlags } from '../../../reducers/features'; import { FLAGS } from '../../../const'; import { Timestamp, ResourceLink, resourcePathFromModel } from '../../utils'; import { NodeModel } from '../../../models'; import { EventComponentProps } from '../../utils/event-stream'; import { categoryFilter } from '../../events'; -import { RedExclamationCircleIcon } from '@console/internal/components/utils/status-icon'; const EventItem_: React.FC = ({ event, flags }) => { const { count, firstTimestamp, lastTimestamp, involvedObject: obj, source, message } = event; diff --git a/frontend/public/components/dashboard/health-card/alert-item.tsx b/frontend/public/components/dashboard/health-card/alert-item.tsx index 5ef8c553fac..b22688a6d7b 100644 --- a/frontend/public/components/dashboard/health-card/alert-item.tsx +++ b/frontend/public/components/dashboard/health-card/alert-item.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; +import { RedExclamationCircleIcon, YellowExclamationTriangleIcon } from '@console/shared'; import { getAlertSeverity, getAlertMessage, getAlertDescription } from './'; import { Alert } from '../../monitoring'; -import { RedExclamationCircleIcon, YellowExclamationTriangleIcon } from '@console/internal/components/utils/status-icon'; const getSeverityIcon = (severity: string) => { switch (severity) { diff --git a/frontend/public/components/dashboard/health-card/health-item.tsx b/frontend/public/components/dashboard/health-card/health-item.tsx index addd7bd4a20..f3eaad7e042 100644 --- a/frontend/public/components/dashboard/health-card/health-item.tsx +++ b/frontend/public/components/dashboard/health-card/health-item.tsx @@ -1,13 +1,13 @@ import * as React from 'react'; import classNames from 'classnames'; -import { HealthState } from './states'; import { GreenCheckCircleIcon, - LoadingInline, RedExclamationCircleIcon, YellowExclamationTriangleIcon, -} from '../../utils'; +} from '@console/shared'; +import { HealthState } from './states'; +import { LoadingInline } from '../../utils'; const HealthItemIcon: React.FC = ({ state }) => { let icon; @@ -22,22 +22,20 @@ const HealthItemIcon: React.FC = ({ state }) => { default: icon = ; } - return ( -
- {icon} -
- ); + return
{icon}
; }; -export const HealthItem: React.FC = React.memo(({ className, state, message, details }) => ( -
- {state === HealthState.LOADING ? : } -
- {message && {message}} - {details &&
{details}
} +export const HealthItem: React.FC = React.memo( + ({ className, state, message, details }) => ( +
+ {state === HealthState.LOADING ? : } +
+ {message && {message}} + {details &&
{details}
} +
-
-)); + ), +); type HealthItemProps = { className?: string; @@ -48,4 +46,4 @@ type HealthItemProps = { type HealthItemIconProps = { state?: HealthState; -} +}; diff --git a/frontend/public/components/dashboard/inventory-card/inventory-item.tsx b/frontend/public/components/dashboard/inventory-card/inventory-item.tsx index 703063e0a6f..57ebe24efc5 100644 --- a/frontend/public/components/dashboard/inventory-card/inventory-item.tsx +++ b/frontend/public/components/dashboard/inventory-card/inventory-item.tsx @@ -2,12 +2,14 @@ import * as React from 'react'; import { Link } from 'react-router-dom'; import { InProgressIcon, QuestionCircleIcon } from '@patternfly/react-icons'; -import * as plugins from '../../../plugins'; import { GreenCheckCircleIcon, - LoadingInline, RedExclamationCircleIcon, YellowExclamationTriangleIcon, +} from '@console/shared'; +import * as plugins from '../../../plugins'; +import { + LoadingInline, } from '../../utils'; import { K8sResourceKind, K8sKind } from '../../../module/k8s'; import { InventoryStatusGroup } from './status-group'; diff --git a/frontend/public/components/deployment-config.tsx b/frontend/public/components/deployment-config.tsx index a63ccf8bcff..88e181ca413 100644 --- a/frontend/public/components/deployment-config.tsx +++ b/frontend/public/components/deployment-config.tsx @@ -1,5 +1,7 @@ import * as React from 'react'; import * as _ from 'lodash-es'; + +import { Status } from '@console/shared'; import { k8sCreate, K8sKind, K8sResourceKind, K8sResourceKindReference } from '../module/k8s'; import { errorModal } from './modals'; import { DeploymentConfigModel } from '../models'; @@ -25,7 +27,6 @@ import { SectionHeading, togglePaused, WorkloadPausedAlert, - StatusIconAndText, } from './utils'; import { @@ -139,8 +140,8 @@ export const DeploymentConfigsDetails: React.FC<{obj: K8sResourceKind}> = ({obj:
Status
{dc.status.availableReplicas === dc.status.updatedReplicas && dc.spec.replicas === dc.status.availableReplicas - ? - : } + ? + : }
diff --git a/frontend/public/components/deployment.tsx b/frontend/public/components/deployment.tsx index bd20250cf32..340445a6438 100644 --- a/frontend/public/components/deployment.tsx +++ b/frontend/public/components/deployment.tsx @@ -1,5 +1,7 @@ import * as React from 'react'; import * as _ from 'lodash-es'; + +import { Status } from '@console/shared'; import { DeploymentModel } from '../models'; import { K8sKind, K8sResourceKind, K8sResourceKindReference } from '../module/k8s'; import { configureUpdateStrategyModal, errorModal } from './modals'; @@ -22,7 +24,6 @@ import { pluralize, ResourceSummary, SectionHeading, - StatusIconAndText, togglePaused, WorkloadPausedAlert, } from './utils'; @@ -98,8 +99,8 @@ const DeploymentDetails: React.FC = ({obj: deployment})
Status
{deployment.status.availableReplicas === deployment.status.updatedReplicas && deployment.spec.replicas === deployment.status.availableReplicas - ? - : } + ? + : }
diff --git a/frontend/public/components/job.jsx b/frontend/public/components/job.jsx index 40c77a2e3bf..8d34b1c4887 100644 --- a/frontend/public/components/job.jsx +++ b/frontend/public/components/job.jsx @@ -2,10 +2,12 @@ import * as React from 'react'; import { Link } from 'react-router-dom'; import * as classNames from 'classnames'; import { sortable } from '@patternfly/react-table'; + +import { Status } from '@console/shared'; import { getJobTypeAndCompletions } from '../module/k8s'; import { DetailsPage, ListPage, Table, TableRow, TableData } from './factory'; import { configureJobParallelismModal } from './modals'; -import { Kebab, ContainerTable, SectionHeading, LabelList, ResourceKebab, ResourceLink, ResourceSummary, Timestamp, navFactory, StatusIconAndText } from './utils'; +import { Kebab, ContainerTable, SectionHeading, LabelList, ResourceKebab, ResourceLink, ResourceSummary, Timestamp, navFactory } from './utils'; import { ResourceEventStream } from './events'; const ModifyJobParallelism = (kind, obj) => ({ @@ -109,7 +111,7 @@ const Details = ({obj: job}) =>
Status
-
{job.status.conditions ? : }
+
{job.status.conditions ? : }
Start Time
Completion Time
diff --git a/frontend/public/components/namespace.jsx b/frontend/public/components/namespace.jsx index 766d04b4d86..635c1d59052 100644 --- a/frontend/public/components/namespace.jsx +++ b/frontend/public/components/namespace.jsx @@ -6,12 +6,13 @@ import { connect } from 'react-redux'; import { Tooltip } from './utils/tooltip'; import { Link } from 'react-router-dom'; import * as fuzzy from 'fuzzysearch'; +import { Status } from '@console/shared'; import { NamespaceModel, ProjectModel, SecretModel } from '../models'; import { k8sGet } from '../module/k8s'; import * as UIActions from '../actions/ui'; import { DetailsPage, ListPage, Table, TableRow, TableData } from './factory'; -import { Kebab, Dropdown, Firehose, LabelList, LoadingInline, navFactory, ResourceKebab, SectionHeading, ResourceLink, ResourceIcon, ResourceSummary, MsgBox, StatusIconAndText, ExternalLink, humanizeCpuCores, humanizeDecimalBytes, useAccessReview } from './utils'; +import { Kebab, Dropdown, Firehose, LabelList, LoadingInline, navFactory, ResourceKebab, SectionHeading, ResourceLink, ResourceIcon, ResourceSummary, MsgBox, ExternalLink, humanizeCpuCores, humanizeDecimalBytes, useAccessReview } from './utils'; import { createNamespaceModal, createProjectModal, deleteNamespaceModal, configureNamespacePullSecretModal } from './modals'; import { RoleBindingsPage } from './RBAC'; import { Bar, Area, requirePrometheus } from './graphs'; @@ -85,7 +86,7 @@ const NamespacesTableRow = ({obj: ns, index, key, style}) => { - + @@ -170,7 +171,7 @@ const ProjectTableRow = ({obj: project, index, key, style, customData = {}}) => )} - + {requester || No requester} @@ -302,7 +303,7 @@ export const NamespaceSummary = ({ns}) => {
Status
-
+
{canListSecrets &&
Default Pull Secret
diff --git a/frontend/public/components/node.tsx b/frontend/public/components/node.tsx index d1c8646dd3d..3168f687129 100644 --- a/frontend/public/components/node.tsx +++ b/frontend/public/components/node.tsx @@ -2,12 +2,14 @@ import * as _ from 'lodash-es'; import * as React from 'react'; import * as classNames from 'classnames'; import { sortable } from '@patternfly/react-table'; + +import { Status } from '@console/shared'; import { getNodeRoles, nodeStatus, makeNodeSchedulable, K8sResourceKind, referenceForModel } from '../module/k8s'; import { ResourceEventStream } from './events'; import { Table, TableRow, TableData, DetailsPage, ListPage } from './factory'; import { configureUnschedulableModal } from './modals'; import { PodsPage } from './pod'; -import { Kebab, navFactory, LabelList, ResourceKebab, SectionHeading, ResourceLink, Timestamp, units, cloudProviderNames, cloudProviderID, pluralize, StatusIconAndText, humanizeDecimalBytes, humanizeCpuCores, useAccessReview, humanizeDecimalBytesPerSec } from './utils'; +import { Kebab, navFactory, LabelList, ResourceKebab, SectionHeading, ResourceLink, Timestamp, units, cloudProviderNames, cloudProviderID, pluralize, humanizeDecimalBytes, humanizeCpuCores, useAccessReview, humanizeDecimalBytesPerSec } from './utils'; import { Area, requirePrometheus } from './graphs'; import { MachineModel, NodeModel } from '../models'; import { CamelCaseWrap } from './utils/camel-case-wrap'; @@ -95,7 +97,7 @@ const NodeTableHeader = () => { }; NodeTableHeader.displayName = 'NodeTableHeader'; -const NodeStatus = ({node}) => ; +const NodeStatus = ({node}) => ; const NodeTableRow: React.FC = ({obj: node, index, key, style}) => { const machine = getMachine(node); diff --git a/frontend/public/components/operator-hub/operator-hub-items.tsx b/frontend/public/components/operator-hub/operator-hub-items.tsx index af7669fa98c..370f7714e22 100644 --- a/frontend/public/components/operator-hub/operator-hub-items.tsx +++ b/frontend/public/components/operator-hub/operator-hub-items.tsx @@ -3,6 +3,7 @@ import * as _ from 'lodash-es'; import { Modal } from 'patternfly-react'; import { CatalogTile } from 'patternfly-react-extensions'; +import { GreenCheckCircleIcon } from '@console/shared'; import { history } from '../utils/router'; import { COMMUNITY_PROVIDERS_WARNING_LOCAL_STORAGE_KEY } from '../../const'; import { normalizeIconClass } from '../catalog/catalog-item-icon'; @@ -10,7 +11,6 @@ import { TileViewPage } from '../utils/tile-view-page'; import { OperatorHubItemDetails } from './operator-hub-item-details'; import { communityOperatorWarningModal } from './operator-hub-community-provider-modal'; import { OperatorHubItem, InstalledState, ProviderType, CapabilityLevel } from './index'; -import { GreenCheckCircleIcon } from '../utils/status-icon'; const badge = (text: string) => {text}; diff --git a/frontend/public/components/operator-lifecycle-manager/clusterserviceversion.tsx b/frontend/public/components/operator-lifecycle-manager/clusterserviceversion.tsx index 22055708896..5697e933fb7 100644 --- a/frontend/public/components/operator-lifecycle-manager/clusterserviceversion.tsx +++ b/frontend/public/components/operator-lifecycle-manager/clusterserviceversion.tsx @@ -7,6 +7,7 @@ import { sortable } from '@patternfly/react-table'; import { Helmet } from 'react-helmet'; import { Alert } from '@patternfly/react-core'; +import { SuccessStatus, ErrorStatus } from '@console/shared'; import { ProvidedAPIsPage, ProvidedAPIPage } from './operand'; import { DetailsPage, ListPage, Table, TableRow, TableData } from '../factory'; import { withFallback } from '../utils/error-boundary'; @@ -47,7 +48,6 @@ import { } from '../utils'; import { operatorGroupFor, operatorNamespaceFor } from './operator-group'; import { SubscriptionDetails } from './subscription'; -import { GreenCheckCircleIcon, RedExclamationCircleIcon } from '@console/internal/components/utils/status-icon'; const tableColumnClasses = [ classNames('col-lg-3', 'col-md-4', 'col-sm-4', 'col-xs-6'), @@ -92,9 +92,9 @@ export const ClusterServiceVersionTableRow = withFallback{showSuccessIcon && - }{statusString} + } - : Failed; + : ; return ( diff --git a/frontend/public/components/operator-lifecycle-manager/descriptors/status/index.tsx b/frontend/public/components/operator-lifecycle-manager/descriptors/status/index.tsx index 3e9de48a430..098f510fd34 100644 --- a/frontend/public/components/operator-lifecycle-manager/descriptors/status/index.tsx +++ b/frontend/public/components/operator-lifecycle-manager/descriptors/status/index.tsx @@ -1,14 +1,14 @@ import * as React from 'react'; import * as _ from 'lodash-es'; import { Map as ImmutableMap } from 'immutable'; +import { Status, SuccessStatus } from '@console/shared'; -import { ResourceLink, StatusIconAndText } from '../../../utils'; +import { ResourceLink } from '../../../utils'; import { StatusCapability, CapabilityProps, DescriptorProps } from '../types'; import { Phase } from './phase'; import { PodStatusChart } from './pods'; import { Tooltip } from '../../../utils/tooltip'; import { Conditions } from '../../../conditions'; -import { GreenCheckCircleIcon } from '@console/internal/components/utils/status-icon'; const Invalid: React.SFC = (props) =>