| 1 |
import { Fragment, useState } from 'react'; |
| 2 |
import { |
| 3 |
Card, |
| 4 |
CardHeader, |
| 5 |
CardTitle, |
| 6 |
CardBody, |
| 7 |
CardFooter, |
| 8 |
DescriptionList, |
| 9 |
DescriptionListGroup, |
| 10 |
DescriptionListTerm, |
| 11 |
DescriptionListDescription, |
| 12 |
Divider, |
| 13 |
Flex, |
| 14 |
FlexItem, |
| 15 |
Gallery, |
| 16 |
Icon, |
| 17 |
MenuToggle, |
| 18 |
Select, |
| 19 |
SelectList, |
| 20 |
SelectOption, |
| 21 |
Spinner, |
| 22 |
Timestamp, |
| 23 |
Title |
| 24 |
} from '@patternfly/react-core'; |
| 25 |
import RhUiErrorFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-error-fill-icon'; |
| 26 |
import RhUiCheckCircleFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-check-circle-fill-icon'; |
| 27 |
import flex from '@patternfly/react-styles/css/utilities/Flex/flex'; |
| 28 |
import cssGridTemplateColumnsMin from '@patternfly/react-tokens/dist/esm/l_gallery_GridTemplateColumns_min'; |
| 29 |
|
| 30 |
export const CardEventsView: React.FunctionComponent = () => { |
| 31 |
const [isOpen, setIsOpen] = useState(false); |
| 32 |
|
| 33 |
const selectItems = ( |
| 34 |
<SelectList> |
| 35 |
<SelectOption value="Success" key="option1"> |
| 36 |
Success |
| 37 |
</SelectOption> |
| 38 |
<SelectOption value="Error" key="option2"> |
| 39 |
Error |
| 40 |
</SelectOption> |
| 41 |
<SelectOption value="Warning" key="option3"> |
| 42 |
Warning |
| 43 |
</SelectOption> |
| 44 |
</SelectList> |
| 45 |
); |
| 46 |
|
| 47 |
const toggle = (toggleRef) => ( |
| 48 |
<MenuToggle ref={toggleRef} onClick={() => setIsOpen(!isOpen)} isExpanded={isOpen} variant="plainText"> |
| 49 |
Status |
| 50 |
</MenuToggle> |
| 51 |
); |
| 52 |
|
| 53 |
const headerActions = ( |
| 54 |
<Select onSelect={() => setIsOpen(!isOpen)} onOpenChange={setIsOpen} isOpen={isOpen} toggle={toggle}> |
| 55 |
{selectItems} |
| 56 |
</Select> |
| 57 |
); |
| 58 |
return ( |
| 59 |
<Fragment> |
| 60 |
<b>Note:</b> Custom CSS is used in this demo to align the card title and select toggle text to{' '} |
| 61 |
<code>baseline</code> alignment. |
| 62 |
<br /> |
| 63 |
<br /> |
| 64 |
<Gallery hasGutter style={{ [cssGridTemplateColumnsMin.name]: '360px' } as React.CSSProperties}> |
| 65 |
<Card id="card-events-view-example"> |
| 66 |
<CardHeader className={flex.alignItemsFlexStart} actions={{ actions: headerActions, hasNoOffset: true }}> |
| 67 |
<CardTitle> |
| 68 |
<Title headingLevel="h4" size="xl" style={{ paddingTop: '3px' }}> |
| 69 |
Events |
| 70 |
</Title> |
| 71 |
</CardTitle> |
| 72 |
</CardHeader> |
| 73 |
<CardBody> |
| 74 |
<DescriptionList aria-label="Events view"> |
| 75 |
<DescriptionListGroup> |
| 76 |
<DescriptionListTerm> |
| 77 |
<Flex flexWrap={{ default: 'nowrap' }}> |
| 78 |
<FlexItem> |
| 79 |
<Icon status="danger"> |
| 80 |
<RhUiErrorFillIcon /> |
| 81 |
</Icon> |
| 82 |
</FlexItem> |
| 83 |
<FlexItem> |
| 84 |
<span>Readiness probe failed</span> |
| 85 |
</FlexItem> |
| 86 |
</Flex> |
| 87 |
</DescriptionListTerm> |
| 88 |
<DescriptionListDescription> |
| 89 |
Readiness probe failed: Get https://10.131.0.7:5000/healthz: dial tcp 10.131.0.7:5000: connect: |
| 90 |
connection refused |
| 91 |
</DescriptionListDescription> |
| 92 |
<DescriptionListDescription> |
| 93 |
<Timestamp date={new Date('2023-06-17T11:02')} dateFormat="medium" timeFormat="short" /> |
| 94 |
</DescriptionListDescription> |
| 95 |
</DescriptionListGroup> |
| 96 |
<DescriptionListGroup> |
| 97 |
<DescriptionListTerm> |
| 98 |
<Flex flexWrap={{ default: 'nowrap' }}> |
| 99 |
<FlexItem> |
| 100 |
<Icon status="success"> |
| 101 |
<RhUiCheckCircleFillIcon /> |
| 102 |
</Icon> |
| 103 |
</FlexItem> |
| 104 |
<FlexItem> |
| 105 |
<span>Successful assignment</span> |
| 106 |
</FlexItem> |
| 107 |
</Flex> |
| 108 |
</DescriptionListTerm> |
| 109 |
<DescriptionListDescription> |
| 110 |
Successfully assigned default/example to ip-10-0-130-149.ec2.internal |
| 111 |
</DescriptionListDescription> |
| 112 |
<DescriptionListDescription> |
| 113 |
<Timestamp date={new Date('2023-06-17T11:13')} dateFormat="medium" timeFormat="short" /> |
| 114 |
</DescriptionListDescription> |
| 115 |
</DescriptionListGroup> |
| 116 |
<DescriptionListGroup> |
| 117 |
<DescriptionListTerm> |
| 118 |
<Flex flexWrap={{ default: 'nowrap' }}> |
| 119 |
<FlexItem> |
| 120 |
<Spinner size="md" aria-label="loading spinner" /> |
| 121 |
</FlexItem> |
| 122 |
<FlexItem> |
| 123 |
<span>Pulling image</span> |
| 124 |
</FlexItem> |
| 125 |
</Flex> |
| 126 |
</DescriptionListTerm> |
| 127 |
<DescriptionListDescription>Pulling image "openshift/hello-openshift"</DescriptionListDescription> |
| 128 |
<DescriptionListDescription> |
| 129 |
<Timestamp date={new Date('2023-06-17T10:59')} dateFormat="medium" timeFormat="short" /> |
| 130 |
</DescriptionListDescription> |
| 131 |
</DescriptionListGroup> |
| 132 |
<DescriptionListGroup> |
| 133 |
<DescriptionListTerm> |
| 134 |
<Flex flexWrap={{ default: 'nowrap' }}> |
| 135 |
<FlexItem> |
| 136 |
<Icon status="success"> |
| 137 |
<RhUiCheckCircleFillIcon /> |
| 138 |
</Icon> |
| 139 |
</FlexItem> |
| 140 |
<FlexItem> |
| 141 |
<span>Created container</span> |
| 142 |
</FlexItem> |
| 143 |
</Flex> |
| 144 |
</DescriptionListTerm> |
| 145 |
<DescriptionListDescription>Created container hello-openshift</DescriptionListDescription> |
| 146 |
<DescriptionListDescription> |
| 147 |
<Timestamp date={new Date('2023-06-17T10:45')} dateFormat="medium" timeFormat="short" /> |
| 148 |
</DescriptionListDescription> |
| 149 |
</DescriptionListGroup> |
| 150 |
</DescriptionList> |
| 151 |
</CardBody> |
| 152 |
<Divider /> |
| 153 |
<CardFooter> |
| 154 |
<a href="#">View all events</a> |
| 155 |
</CardFooter> |
| 156 |
</Card> |
| 157 |
</Gallery> |
| 158 |
</Fragment> |
| 159 |
); |
| 160 |
}; |