@patternfly/react-core#TextListItem JavaScript Examples
The following examples show how to use
@patternfly/react-core#TextListItem.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BuildModalReview.js From edge-frontend with Apache License 2.0 | 6 votes |
BuildModalReview = ({ reviewObject, key }) => {
return (
<TextContent>
<Title headingLevel="h3">
<Text component={'b'}>{reviewObject.title}</Text>
</Title>
<TextList component={TextListVariants.dl}>
{reviewObject.rows.map((row) => (
<Fragment key={row.title + key}>
<TextListItem component={TextListItemVariants.dt}>
{row.title}
</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
{row.value}
</TextListItem>
</Fragment>
))}
</TextList>
</TextContent>
);
}
Example #2
Source File: ReviewSection.js From edge-frontend with Apache License 2.0 | 6 votes |
ReviewSection = ({ title, data, testid }) => {
return (
<Grid className="pf-u-pb-xl" data-testid={testid} hasGutter>
<GridItem span={12}>
<Text component={TextVariants.h2}>{title}</Text>
</GridItem>
{data.map(({ name, value }) => (
<Grid key={name}>
<GridItem span={3}>
<TextListItem component={TextListItemVariants.dt}>
{name}
</TextListItem>
</GridItem>
<GridItem span={9}>
<TextListItem component={TextListItemVariants.dd}>
{value}
</TextListItem>
</GridItem>
</Grid>
))}
</Grid>
);
}
Example #3
Source File: UpdateImageModal.js From edge-frontend with Apache License 2.0 | 4 votes |
UpdateImageModal = ({ updateCveModal, setUpdateCveModal, setReload }) => {
const dispatch = useDispatch();
const { getRegistry } = useContext(RegistryContext);
const { data } = useSelector(
({ imageDetailReducer }) => ({
data: imageDetailReducer?.data || null,
}),
shallowEqual
);
useEffect(() => {
const registered = getRegistry().register({
imageDetailReducer,
});
updateCveModal?.imageId &&
loadImageDetail(dispatch, updateCveModal?.imageId);
return () => registered();
}, [dispatch]);
const handleUpdateModal = () => {
const payload = {
Id: data?.image?.ID,
description: data?.image?.Description,
name: data?.image?.Name,
version: data?.image?.Version + 1,
architecture: 'x86_64',
credentials: data?.image?.Installer.SshKey,
username: data?.image?.Installer.Username,
imageType: data?.image?.OutputTypes,
'selected-packages': data?.image?.Packages?.map((pack) => ({
name: pack.Name,
})),
release: data?.image?.Distribution,
};
handleClose();
setReload(true);
createNewImage(dispatch, payload, (resp) => {
dispatch({
...addNotification({
variant: 'info',
title: 'Update image',
description: `${resp.value.Name} image was added to the queue.`,
}),
meta: {
polling: {
id: `FETCH_IMAGE_${resp.value.ID}_BUILD_STATUS`,
fetcher: () => getEdgeImageStatus(resp.value.ID),
condition: (resp) => {
switch (resp.Status) {
case 'BUILDING':
return [true, ''];
case 'ERROR':
return [false, 'failure'];
default:
return [false, 'success'];
}
},
onEvent: {
failure: [
(dispatch) =>
dispatch(
addNotification({
variant: 'danger',
title: 'Image build failed',
description: `${resp.value.Name} image build is completed unsuccessfully`,
})
),
],
success: [
(dispatch) =>
dispatch(
addNotification({
variant: 'success',
title: 'Image is ready',
description: `${resp.value.Name} image build is completed`,
})
),
(dispatch) => loadEdgeImageSets(dispatch),
],
},
},
},
});
loadEdgeImageSets(dispatch);
dispatch(
addImageToPoll({ name: data?.image?.Name, id: data?.image?.ID })
);
});
};
const handleClose = () => {
setUpdateCveModal((prevState) => ({ ...prevState, isOpen: false }));
};
return data ? (
<Modal
variant="medium"
title={`Update image: ${data?.image?.Name}`}
description="Review the information and click Create image to start the build process"
isOpen={updateCveModal.isOpen}
onClose={handleClose}
//onSubmit={handleUpdateModal}
actions={[
<Button key="confirm" variant="primary" onClick={handleUpdateModal}>
Create Image
</Button>,
<Button key="cancel" variant="link" onClick={handleClose}>
Cancel
</Button>,
]}
>
<TextContent>
<TextListItem component={TextVariants.h3}>
<Text component={'b'}>Details</Text>
</TextListItem>
<TextList component={TextListVariants.dl}>
<TextListItem component={TextListItemVariants.dt}>Name</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
{data?.image?.Name}
</TextListItem>
<TextListItem component={TextListItemVariants.dt}>
Version
</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
{data?.image?.Version + 1}
</TextListItem>
<TextListItem component={TextListItemVariants.dt}>
Description
</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
{data?.image?.Description}
</TextListItem>
</TextList>
<TextListItem component={TextVariants.h3}>
<Text component={'b'}>Output</Text>
</TextListItem>
<TextList component={TextListVariants.dl}>
<TextListItem component={TextListItemVariants.dt}>
Release
</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
{releaseMapper[data?.image?.Distribution]}
</TextListItem>
<TextListItem component={TextListItemVariants.dt}>
Output type
</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
{imageTypeMapper[data?.image?.ImageType]}
</TextListItem>
</TextList>
<TextListItem component={TextVariants.h3}>
<Text component={'b'}>Packages</Text>
</TextListItem>
<TextList component={TextListVariants.dl}>
<TextListItem component={TextListItemVariants.dt}>
Updated
</TextListItem>
<TextListItem
className="pf-u-pl-lg"
component={TextListItemVariants.dd}
>
{updateCveModal?.cveCount}
</TextListItem>
</TextList>
</TextContent>
</Modal>
) : (
<Backdrop>
<Bullseye>
<Spinner isSVG diameter="100px" />
</Bullseye>
</Backdrop>
);
}
Example #4
Source File: DetailsHeader.js From edge-frontend with Apache License 2.0 | 4 votes |
DetailsHead = ({ imageData, imageVersion, openUpdateWizard }) => {
const [isOpen, setIsOpen] = useState(false);
const [data, setData] = useState({});
useEffect(() => {
setData(imageData?.data?.Data);
}, [imageData]);
return (
<>
{!imageData.isLoading && imageData.hasError ? (
<Breadcrumb>
<BreadcrumbItem>
<Link to={paths['manage-images']}>Back to Manage Images</Link>
</BreadcrumbItem>
</Breadcrumb>
) : (
<>
<Breadcrumb>
<BreadcrumbItem>
<Link to={paths['manage-images']}>Manage Images</Link>
</BreadcrumbItem>
{imageVersion ? (
<BreadcrumbItem>
<Link to={`${paths['manage-images']}/${data?.image_set?.ID}`}>
{data?.image_set?.Name}
</Link>
</BreadcrumbItem>
) : (
<BreadcrumbItem isActive>
{data?.image_set?.Name || <Skeleton width="100px" />}
</BreadcrumbItem>
)}
{imageVersion && (
<BreadcrumbItem isActive>
{imageVersion?.image?.Version}
</BreadcrumbItem>
)}
</Breadcrumb>
<TextContent>
<Split>
<SplitItem>
<TextList component="dl">
<TextListItem
component="h1"
className="grid-align-center pf-u-mb-0"
>
{data?.image_set?.Name || <Skeleton width="150px" />}
</TextListItem>
<TextListItem className="pf-u-pt-sm" component="dd">
{data?.Status || data?.images?.[0]?.image?.Status ? (
<Status
type={data?.images?.[0]?.image?.Status.toLowerCase()}
/>
) : (
<Skeleton width="100px" />
)}
</TextListItem>
{imageVersion?.image?.UpdatedAt ||
data?.images?.[0].image?.UpdatedAt ? (
<TextListItem component="p">
{`Last updated `}
<DateFormat
date={
imageVersion
? imageVersion?.image?.UpdatedAt
: data?.images?.[0].image?.UpdatedAt
}
/>
</TextListItem>
) : (
<Skeleton width="200px" />
)}
</TextList>
</SplitItem>
<SplitItem isFilled></SplitItem>
<SplitItem>
<Dropdown
position={DropdownPosition.right}
toggle={
<DropdownToggle
id="image-set-details-dropdown"
toggleIndicator={CaretDownIcon}
onToggle={(newState) => setIsOpen(newState)}
isDisabled={
(imageVersion
? imageVersion?.image?.Status
: data?.Images?.[0]?.Status) === 'BUILDING' || false
}
>
Actions
</DropdownToggle>
}
isOpen={isOpen}
dropdownItems={dropdownItems(
data,
imageVersion,
openUpdateWizard
)}
/>
</SplitItem>
</Split>
</TextContent>
</>
)}
</>
);
}
Example #5
Source File: ImageDetailTab.js From edge-frontend with Apache License 2.0 | 4 votes |
ImageDetailTab = ({ imageData, imageVersion }) => {
const [data, setData] = useState({});
useEffect(() => {
imageVersion
? setData(imageVersion)
: setData(imageData?.data?.Data?.images?.[0]);
}, [imageData, imageVersion]);
const createSkeleton = (rows) =>
[...Array(rows * 2)].map((_, key) => <Skeleton width="180px" key={key} />);
const dateFormat = () => <DateFormat date={data?.image?.['CreatedAt']} />;
const detailsMapper = {
Version: 'Version',
Created: () => dateFormat(),
'Type(s)': () =>
data?.image?.['OutputTypes']?.map((outputType, index) => (
<div key={index}>{outputType}</div>
)),
Release: () => distributionMapper?.[data?.image?.['Distribution']],
//Size: 'Size',
Description: 'Description',
};
const userInfoMapper = {
Username: () => data?.image?.Installer?.Username,
'SSH key': () => data?.image?.Installer?.SshKey,
};
const renderAdditionalPackageLink = () => {
return (
<Link
to={`${paths['manage-images']}/${data?.image?.ImageSetID}/versions/${data?.image?.ID}/packages/additional`}
>
{data?.additional_packages}
</Link>
);
};
const renderTotalPackageLink = () => {
return (
<Link
to={`${paths['manage-images']}/${data?.image?.ImageSetID}/versions/${data?.image?.ID}/packages/all`}
>
{data?.packages}
</Link>
);
};
const packageMapper = {
'Total additional packages': renderAdditionalPackageLink,
'Total packages': renderTotalPackageLink,
};
const packageDiffMapper = {
Added: () => data?.update_added,
Removed: () => data?.update_removed,
Updated: () => data?.update_updated,
};
if (data?.image?.Installer?.Checksum) {
detailsMapper['SHA-256 checksum'] = () => data?.image?.Installer?.Checksum;
}
if (data?.image?.Commit?.OSTreeCommit) {
detailsMapper['Ostree commit hash'] = () =>
data?.image?.Commit?.OSTreeCommit;
}
const buildTextList = (labelsToValueMapper) =>
data
? Object.entries(labelsToValueMapper).map(([label, value], index) => {
return (
<Fragment key={index}>
<TextListItem
className="details-label"
component={TextListItemVariants.dt}
>
{label}
</TextListItem>
{label === 'SHA-256 checksum' ||
label === 'Ostree commit hash' ||
(label === 'SSH key' && value()) ? (
<TextListItem component={TextListItemVariants.dd}>
<ClipboardCopy
hoverTip="Copy"
clickTip="Copied"
variant="expansion"
className="pf-u-text-break-word"
id={`${label
.replace(/\s+/g, '-')
.toLowerCase()}-clipboard-copy`}
>
{typeof value === 'function'
? value() || 'Unavailable'
: data?.image?.[value] || 'Unavailable'}
</ClipboardCopy>
</TextListItem>
) : (
<TextListItem
className="pf-u-text-break-word"
component={TextListItemVariants.dd}
>
{typeof value === 'function'
? value() === 0
? 0
: value() || 'Unavailable'
: data?.image?.[value] || 'Unavailable'}
</TextListItem>
)}
</Fragment>
);
})
: null;
return (
<TextContent className="pf-u-ml-lg pf-u-mt-md">
<Grid span={12}>
<GridItem span={5}>
<Text component={TextVariants.h2}>
{imageVersion ? 'Details' : 'Most recent image'}
</Text>
<TextList component={TextListVariants.dl}>
{buildTextList(detailsMapper) || createSkeleton(6)}
</TextList>
<Text component={TextVariants.h2}>User information </Text>
<TextList component={TextListVariants.dl}>
{buildTextList(userInfoMapper) || createSkeleton(2)}
</TextList>
</GridItem>
<GridItem span={1} />
<GridItem span={6}>
<Text component={TextVariants.h2}>Packages </Text>
<TextList component={TextListVariants.dl}>
{buildTextList(packageMapper) || createSkeleton(3)}
</TextList>
<Text component={TextVariants.h2}>Changes from previous version</Text>
<TextList component={TextListVariants.dl}>
{buildTextList(packageDiffMapper) || createSkeleton(3)}
</TextList>
</GridItem>
</Grid>
</TextContent>
);
}
Example #6
Source File: ibutsu-header.js From ibutsu-server with MIT License | 4 votes |
render() {
document.title = 'Ibutsu';
const apiUiUrl = Settings.serverUrl + '/ui/';
const uploadParams = {};
if (this.state.selectedProject && this.state.selectedProject.project) {
uploadParams['project'] = this.state.selectedProject.project.id;
}
const topNav = (
<Flex>
<FlexItem id="project-selector">
<Select
ariaLabelTypeAhead="Select a project"
placeholderText="No active project"
variant={SelectVariant.typeahead}
isOpen={this.state.isProjectSelectorOpen}
selections={this.state.selectedProject}
onToggle={this.onProjectToggle}
onSelect={this.onProjectSelect}
onClear={this.onProjectClear}
onTypeaheadInputChanged={this.onProjectsChanged}
footer={this.state.projects.length == 10 && "Search for more..."}
>
{this.state.projects.map(project => (
<SelectOption key={project.id} value={projectToOption(project)} description={project.name} />
))}
</Select>
</FlexItem>
</Flex>
);
const headerTools = (
<PageHeaderTools>
<PageHeaderToolsGroup className={css(accessibleStyles.srOnly, accessibleStyles.visibleOnLg)}>
<PageHeaderToolsItem>
<Button variant="plain" onClick={this.toggleAbout}><QuestionCircleIcon /></Button>
</PageHeaderToolsItem>
<PageHeaderToolsItem>
<FileUpload component="button" className="pf-c-button pf-m-plain" isUnstyled name="importFile" url={`${Settings.serverUrl}/import`} params={uploadParams} multiple={false} beforeUpload={this.onBeforeUpload} afterUpload={this.onAfterUpload} title="Import xUnit XML or Ibutsu Archive"><UploadIcon /> Import</FileUpload>
</PageHeaderToolsItem>
<PageHeaderToolsItem>
<a href={apiUiUrl} className="pf-c-button pf-m-plain" target="_blank" rel="noopener noreferrer"><ServerIcon/> API</a>
</PageHeaderToolsItem>
<PageHeaderToolsItem>
<Switch id="dark-theme" label={<MoonIcon />} isChecked={this.state.isDarkTheme} onChange={this.onThemeChanged} />
</PageHeaderToolsItem>
<PageHeaderToolsItem id="user-dropdown">
<UserDropdown eventEmitter={this.eventEmitter}/>
</PageHeaderToolsItem>
</PageHeaderToolsGroup>
</PageHeaderTools>
);
return (
<React.Fragment>
<AboutModal
isOpen={this.state.isAboutOpen}
onClose={this.toggleAbout}
brandImageSrc="/images/ibutsu.svg"
brandImageAlt="Ibutsu"
productName="Ibutsu"
backgroundImageSrc="/images/about-bg.jpg"
trademark="Copyright (c) 2021 Red Hat, Inc."
>
<TextContent>
<TextList component="dl">
<TextListItem component="dt">Version</TextListItem>
<TextListItem component="dd">{this.state.version}</TextListItem>
<TextListItem component="dt">Source code</TextListItem>
<TextListItem component="dd"><a href="https://github.com/ibutsu/ibutsu-server" target="_blank" rel="noopener noreferrer">github.com/ibutsu/ibutsu-server</a></TextListItem>
<TextListItem component="dt">Documentation</TextListItem>
<TextListItem component="dd"><a href="https://docs.ibutsu-project.org/" target="_blank" rel="noopener noreferrer">docs.ibutsu-project.org</a></TextListItem>
<TextListItem component="dt">Report bugs</TextListItem>
<TextListItem component="dd"><a href="https://github.com/ibutsu/ibutsu-server/issues/new" target="_blank" rel="noopener noreferrer">Submit an issue</a></TextListItem>
</TextList>
</TextContent>
<p style={{marginTop: "2rem"}}>* Note: artifact files (screenshots, logs) are retained for 3 months</p>
</AboutModal>
<PageHeader
logo={<Brand src="/images/ibutsu-wordart-164.png" alt="Ibutsu"/>}
logoComponent={Link}
logoProps={{to: '/'}}
headerTools={headerTools}
showNavToggle={true}
topNav={topNav}
/>
</React.Fragment>
);
}