Debian Codegraph @

node/@patternfly/react-core/src/demos/examples/Card/CardLogView.tsx

raw
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 Gallery,
14 MenuToggle,
15 MenuToggleElement,
16 Select,
17 SelectList,
18 SelectOption,
19 Timestamp,
20 Title
21 } from '@patternfly/react-core';
22 import flex from '@patternfly/react-styles/css/utilities/Flex/flex';
23 import cssGridTemplateColumnsMin from '@patternfly/react-tokens/dist/esm/l_gallery_GridTemplateColumns_min';
24
25 export const CardLogView: React.FunctionComponent = () => {
26 const [isOpen, setIsOpen] = useState(false);
27
28 const selectItems = (
29 <SelectList>
30 <SelectOption key="option1" value="Last hour">
31 Last hour
32 </SelectOption>
33 <SelectOption key="option2" value="Last 6 hours">
34 Last 6 hours
35 </SelectOption>
36 <SelectOption key="option3" value="Last 24 hours">
37 Last 24 hours
38 </SelectOption>
39 <SelectOption key="option4" value="Last 7 days">
40 Last 7 days
41 </SelectOption>
42 </SelectList>
43 );
44
45 const toggle = (toggleRef: React.Ref<MenuToggleElement>) => (
46 <MenuToggle ref={toggleRef} onClick={() => setIsOpen(!isOpen)} isExpanded={isOpen} variant="plainText">
47 Filter
48 </MenuToggle>
49 );
50
51 const headerActions = (
52 <Select onSelect={() => setIsOpen(!isOpen)} onOpenChange={setIsOpen} isOpen={isOpen} toggle={toggle}>
53 {selectItems}
54 </Select>
55 );
56
57 return (
58 <Fragment>
59 <b>Note:</b> Custom CSS is used in this demo to align the card title and select toggle text to{' '}
60 <code>baseline</code> alignment.
61 <br />
62 <br />
63 <Gallery hasGutter style={{ [cssGridTemplateColumnsMin.name]: '360px' } as React.CSSProperties}>
64 <Card id="card-log-view-example">
65 <CardHeader className={flex.alignItemsFlexStart} actions={{ actions: headerActions, hasNoOffset: true }}>
66 <CardTitle>
67 <Title headingLevel="h4" size="xl" style={{ paddingTop: '3px' }}>
68 Activity
69 </Title>
70 </CardTitle>
71 </CardHeader>
72 <CardBody>
73 <DescriptionList aria-label="Activity logs">
74 <DescriptionListGroup>
75 <DescriptionListTerm>Readiness probe failed</DescriptionListTerm>
76 <DescriptionListDescription>
77 Readiness probe failed: Get https://10.131.0.7:5000/healthz: dial tcp 10.131.0.7:5000: connect:
78 connection refused
79 </DescriptionListDescription>
80 <DescriptionListDescription>
81 <Timestamp date={new Date('2023-06-17T11:02')} dateFormat="medium" timeFormat="short" />
82 </DescriptionListDescription>
83 </DescriptionListGroup>
84 <DescriptionListGroup>
85 <DescriptionListTerm>Successful assignment</DescriptionListTerm>
86 <DescriptionListDescription>
87 Successfully assigned default/example to ip-10-0-130-149.ec2.internal
88 </DescriptionListDescription>
89 <DescriptionListDescription>
90 <Timestamp date={new Date('2023-06-17T11:13')} dateFormat="medium" timeFormat="short" />
91 </DescriptionListDescription>
92 </DescriptionListGroup>
93 <DescriptionListGroup>
94 <DescriptionListTerm>Pulling image</DescriptionListTerm>
95 <DescriptionListDescription>Pulling image "openshift/hello-openshift"</DescriptionListDescription>
96 <DescriptionListDescription>
97 <Timestamp date={new Date('2023-06-17T10:59')} dateFormat="medium" timeFormat="short" />
98 </DescriptionListDescription>
99 </DescriptionListGroup>
100 <DescriptionListGroup>
101 <DescriptionListTerm>Created container</DescriptionListTerm>
102 <DescriptionListDescription>Created container hello-openshift</DescriptionListDescription>
103 <DescriptionListDescription>
104 <Timestamp date={new Date('2023-06-17T10:45')} dateFormat="medium" timeFormat="short" />
105 </DescriptionListDescription>
106 </DescriptionListGroup>
107 </DescriptionList>
108 </CardBody>
109 <Divider />
110 <CardFooter>
111 <a href="#">View all activity</a>
112 </CardFooter>
113 </Card>
114 </Gallery>
115 </Fragment>
116 );
117 };