@patternfly/react-core#TextListVariants JavaScript Examples
The following examples show how to use
@patternfly/react-core#TextListVariants.
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: 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 #3
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>
);
}