| 1 |
import { useState } from 'react'; |
| 2 |
import { |
| 3 |
PageSection, |
| 4 |
PageBreadcrumb, |
| 5 |
Breadcrumb, |
| 6 |
BreadcrumbItem, |
| 7 |
Tabs, |
| 8 |
Tab, |
| 9 |
TabContent, |
| 10 |
TabContentBody, |
| 11 |
TabTitleText, |
| 12 |
Title, |
| 13 |
DescriptionList, |
| 14 |
DescriptionListGroup, |
| 15 |
DescriptionListTerm, |
| 16 |
DescriptionListDescription, |
| 17 |
Label, |
| 18 |
LabelColor, |
| 19 |
LabelGroup, |
| 20 |
Flex, |
| 21 |
FlexItem |
| 22 |
} from '@patternfly/react-core'; |
| 23 |
import RhUiCheckCircleFillIcon from '@patternfly/react-icons/dist/js/icons/rh-ui-check-circle-fill-icon'; |
| 24 |
import RhUiInformationFillIcon from '@patternfly/react-icons/dist/js/icons/rh-ui-information-fill-icon'; |
| 25 |
import spacing from '@patternfly/react-styles/css/utilities/Spacing/spacing'; |
| 26 |
import { DashboardWrapper } from '@patternfly/react-core/dist/js/demos/DashboardWrapper'; |
| 27 |
|
| 28 |
export const TabsOpenWithSecondaryTabs: React.FunctionComponent = () => { |
| 29 |
const [activeTabKey, setActiveTabKey] = useState<number>(0); |
| 30 |
const [activeTabKeySecondary, setActiveTabKeySecondary] = useState<number>(10); |
| 31 |
|
| 32 |
// Toggle currently active tab |
| 33 |
const handleTabClick = (_event: React.MouseEvent<HTMLElement>, tabIndex: number) => { |
| 34 |
setActiveTabKey(tabIndex); |
| 35 |
}; |
| 36 |
|
| 37 |
// Toggle currently active secondary tab |
| 38 |
const handleTabClickSecondary = (_event: React.MouseEvent<HTMLElement>, tabIndex: number) => { |
| 39 |
setActiveTabKeySecondary(tabIndex); |
| 40 |
}; |
| 41 |
|
| 42 |
const tabsBreadcrumb = ( |
| 43 |
<PageBreadcrumb isWidthLimited> |
| 44 |
<Breadcrumb> |
| 45 |
<BreadcrumbItem to="#">Overview</BreadcrumbItem> |
| 46 |
<BreadcrumbItem to="#">Pods</BreadcrumbItem> |
| 47 |
<BreadcrumbItem to="#" isActive> |
| 48 |
Pod details{' '} |
| 49 |
</BreadcrumbItem> |
| 50 |
</Breadcrumb> |
| 51 |
</PageBreadcrumb> |
| 52 |
); |
| 53 |
|
| 54 |
const tabContent = ( |
| 55 |
<Flex direction={{ default: 'column' }}> |
| 56 |
<FlexItem spacer={{ default: 'spacerLg' }}> |
| 57 |
<Title headingLevel="h2" size="lg" className={spacing.mtSm} id="open-tabs-example-tabs-list-details-title"> |
| 58 |
Pod details |
| 59 |
</Title> |
| 60 |
</FlexItem> |
| 61 |
<FlexItem> |
| 62 |
<DescriptionList columnModifier={{ lg: '2Col' }} aria-labelledby="open-tabs-example-tabs-list-details-title"> |
| 63 |
<DescriptionListGroup> |
| 64 |
<DescriptionListTerm>Name</DescriptionListTerm> |
| 65 |
<DescriptionListDescription>3scale-control-fccb6ddb9-phyqv9</DescriptionListDescription> |
| 66 |
</DescriptionListGroup> |
| 67 |
<DescriptionListGroup> |
| 68 |
<DescriptionListTerm>Status</DescriptionListTerm> |
| 69 |
<DescriptionListDescription> |
| 70 |
<Flex spacer={{ default: 'spacerLg' }}> |
| 71 |
<FlexItem> |
| 72 |
<RhUiCheckCircleFillIcon /> |
| 73 |
</FlexItem> |
| 74 |
<FlexItem>Running</FlexItem> |
| 75 |
</Flex> |
| 76 |
</DescriptionListDescription> |
| 77 |
</DescriptionListGroup> |
| 78 |
<DescriptionListGroup> |
| 79 |
<DescriptionListTerm>Namespace</DescriptionListTerm> |
| 80 |
<DescriptionListDescription> |
| 81 |
<Flex spaceItems={{ default: 'spaceItemsSm' }}> |
| 82 |
<FlexItem> |
| 83 |
<Label color={LabelColor.teal}>NS</Label> |
| 84 |
</FlexItem> |
| 85 |
<FlexItem> |
| 86 |
<a href="#">knative-serving-ingress</a> |
| 87 |
</FlexItem> |
| 88 |
</Flex> |
| 89 |
</DescriptionListDescription> |
| 90 |
</DescriptionListGroup> |
| 91 |
<DescriptionListGroup> |
| 92 |
<DescriptionListTerm>Restart policy</DescriptionListTerm> |
| 93 |
<DescriptionListDescription>Always restart</DescriptionListDescription> |
| 94 |
</DescriptionListGroup> |
| 95 |
<DescriptionListGroup> |
| 96 |
<DescriptionListTerm>Labels</DescriptionListTerm> |
| 97 |
<DescriptionListDescription> |
| 98 |
<LabelGroup> |
| 99 |
<Label>app=3scale-gateway</Label> |
| 100 |
<Label>pod-template-has=6747686899</Label> |
| 101 |
</LabelGroup> |
| 102 |
</DescriptionListDescription> |
| 103 |
</DescriptionListGroup> |
| 104 |
<DescriptionListGroup> |
| 105 |
<DescriptionListTerm>Active deadline seconds</DescriptionListTerm> |
| 106 |
<DescriptionListDescription>Not configured</DescriptionListDescription> |
| 107 |
</DescriptionListGroup> |
| 108 |
<DescriptionListGroup> |
| 109 |
<DescriptionListTerm>Tolerations</DescriptionListTerm> |
| 110 |
<DescriptionListDescription>stuff</DescriptionListDescription> |
| 111 |
</DescriptionListGroup> |
| 112 |
<DescriptionListGroup> |
| 113 |
<DescriptionListTerm>Pod IP</DescriptionListTerm> |
| 114 |
<DescriptionListDescription>10.345.2.197</DescriptionListDescription> |
| 115 |
</DescriptionListGroup> |
| 116 |
<DescriptionListGroup> |
| 117 |
<DescriptionListTerm>Annotations</DescriptionListTerm> |
| 118 |
<DescriptionListDescription>stuff</DescriptionListDescription> |
| 119 |
</DescriptionListGroup> |
| 120 |
<DescriptionListGroup> |
| 121 |
<DescriptionListTerm>Node</DescriptionListTerm> |
| 122 |
<DescriptionListDescription> |
| 123 |
<Flex spaceItems={{ default: 'spaceItemsSm' }}> |
| 124 |
<FlexItem> |
| 125 |
<Label color={LabelColor.purple}>N</Label> |
| 126 |
</FlexItem> |
| 127 |
<FlexItem>ip-10-0-233-118.us-east-2.computer.external</FlexItem> |
| 128 |
</Flex> |
| 129 |
</DescriptionListDescription> |
| 130 |
</DescriptionListGroup> |
| 131 |
<DescriptionListGroup> |
| 132 |
<DescriptionListTerm>Created at</DescriptionListTerm> |
| 133 |
<DescriptionListDescription> |
| 134 |
<time>Oct 15, 1:51 pm</time> |
| 135 |
</DescriptionListDescription> |
| 136 |
</DescriptionListGroup> |
| 137 |
</DescriptionList> |
| 138 |
</FlexItem> |
| 139 |
</Flex> |
| 140 |
); |
| 141 |
|
| 142 |
return ( |
| 143 |
<DashboardWrapper hasNoBreadcrumb> |
| 144 |
{tabsBreadcrumb} |
| 145 |
<PageSection isWidthLimited aria-label="Pod header"> |
| 146 |
<Flex |
| 147 |
spaceItems={{ default: 'spaceItemsMd' }} |
| 148 |
alignItems={{ default: 'alignItemsFlexStart' }} |
| 149 |
flexWrap={{ default: 'noWrap' }} |
| 150 |
> |
| 151 |
<FlexItem> |
| 152 |
<Label color={LabelColor.blue}>N</Label> |
| 153 |
</FlexItem> |
| 154 |
<FlexItem> |
| 155 |
<Title headingLevel="h1" size="2xl"> |
| 156 |
3scale-control-fccb6ddb9-phyqv9 |
| 157 |
</Title> |
| 158 |
</FlexItem> |
| 159 |
<FlexItem flex={{ default: 'flexNone' }}> |
| 160 |
<Label icon={<RhUiInformationFillIcon />}>Running</Label> |
| 161 |
</FlexItem> |
| 162 |
</Flex> |
| 163 |
</PageSection> |
| 164 |
<PageSection type="tabs" isWidthLimited aria-label="Pod navigation tabs"> |
| 165 |
<Tabs activeKey={activeTabKey} onSelect={handleTabClick} usePageInsets id="open-tabs-example-tabs-list"> |
| 166 |
<Tab eventKey={0} title={<TabTitleText>Details</TabTitleText>} tabContentId={`tabContent${0}`} /> |
| 167 |
<Tab eventKey={1} title={<TabTitleText>YAML</TabTitleText>} tabContentId={`tabContent${1}`} /> |
| 168 |
<Tab eventKey={2} title={<TabTitleText>Environment</TabTitleText>} tabContentId={`tabContent${2}`} /> |
| 169 |
<Tab eventKey={3} title={<TabTitleText>Events</TabTitleText>} tabContentId={`tabContent${3}`} /> |
| 170 |
<Tab eventKey={4} title={<TabTitleText>Terminal</TabTitleText>} tabContentId={`tabContent${4}`} /> |
| 171 |
</Tabs> |
| 172 |
</PageSection> |
| 173 |
<PageSection isWidthLimited padding={{ default: 'noPadding' }} aria-label="Pod content"> |
| 174 |
<TabContent key={0} eventKey={0} id={`tabContent${0}`} activeKey={activeTabKey} hidden={0 !== activeTabKey}> |
| 175 |
<TabContentBody> |
| 176 |
<Tabs |
| 177 |
isSecondary |
| 178 |
activeKey={activeTabKeySecondary} |
| 179 |
onSelect={handleTabClickSecondary} |
| 180 |
usePageInsets |
| 181 |
id="open-with-secondary-tabs-example-tabs-list-secondary" |
| 182 |
> |
| 183 |
<Tab |
| 184 |
eventKey={10} |
| 185 |
title={<TabTitleText>Pod information</TabTitleText>} |
| 186 |
tabContentId={`tabContent${10}`} |
| 187 |
/> |
| 188 |
<Tab |
| 189 |
eventKey={11} |
| 190 |
title={<TabTitleText>Editable aspects</TabTitleText>} |
| 191 |
tabContentId={`tabContent${11}`} |
| 192 |
/> |
| 193 |
</Tabs> |
| 194 |
<TabContent |
| 195 |
key={10} |
| 196 |
eventKey={10} |
| 197 |
id={`tabContent${10}`} |
| 198 |
activeKey={activeTabKeySecondary} |
| 199 |
hidden={10 !== activeTabKeySecondary} |
| 200 |
> |
| 201 |
<TabContentBody hasPadding>{tabContent}</TabContentBody> |
| 202 |
</TabContent> |
| 203 |
<TabContent |
| 204 |
key={11} |
| 205 |
eventKey={11} |
| 206 |
id={`tabContent${11}`} |
| 207 |
activeKey={activeTabKeySecondary} |
| 208 |
hidden={11 !== activeTabKeySecondary} |
| 209 |
> |
| 210 |
<TabContentBody>Editable aspects</TabContentBody> |
| 211 |
</TabContent> |
| 212 |
</TabContentBody> |
| 213 |
</TabContent> |
| 214 |
<TabContent key={1} eventKey={1} id={`tabContent${1}`} activeKey={activeTabKey} hidden={1 !== activeTabKey}> |
| 215 |
<TabContentBody>YAML panel</TabContentBody> |
| 216 |
</TabContent> |
| 217 |
<TabContent key={2} eventKey={2} id={`tabContent${2}`} activeKey={activeTabKey} hidden={2 !== activeTabKey}> |
| 218 |
<TabContentBody>Environment panel</TabContentBody> |
| 219 |
</TabContent> |
| 220 |
<TabContent key={3} eventKey={3} id={`tabContent${3}`} activeKey={activeTabKey} hidden={3 !== activeTabKey}> |
| 221 |
<TabContentBody>Events panel</TabContentBody> |
| 222 |
</TabContent> |
| 223 |
<TabContent key={4} eventKey={4} id={`tabContent${4}`} activeKey={activeTabKey} hidden={4 !== activeTabKey}> |
| 224 |
<TabContentBody>Terminal panel</TabContentBody> |
| 225 |
</TabContent> |
| 226 |
</PageSection> |
| 227 |
</DashboardWrapper> |
| 228 |
); |
| 229 |
}; |