@patternfly/react-core#ClipboardCopy JavaScript Examples
The following examples show how to use
@patternfly/react-core#ClipboardCopy.
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: RegisterWithActivationKey.js From sed-frontend with Apache License 2.0 | 6 votes |
RegisterWithActivationKey = () => (
<FormGroup
label={
<span>
Register with an activation key
<Tooltip
content={
<div>
Organization administrators can view, create, and edit activation
keys on the "Activation keys" section of
console.redhat.com. The organization ID is a Candlepin-specific
identifier, which can be accessed from the activation keys page.
</div>
}
>
<OutlinedQuestionCircleIcon />
</Tooltip>
</span>
}
helperText={<CopyHelperText />}
>
<ClipboardCopy>
rhc connect -a <activation-key> -o <organization-id>
</ClipboardCopy>
</FormGroup>
)
Example #2
Source File: RegisterWithUserName.js From sed-frontend with Apache License 2.0 | 5 votes |
RegisterWithUserName = () => {
return (
<FormGroup
label={
<span>
Register with a username and password
<Popover
position="right"
bodyContent={
<TextContent>
<Text>
Recommended for users with accounts with Simple Content Access
(SCA) enabled. If SCA is not enabled for your account,
subscriptions will be auto-attached.
<Text
href="https://access.redhat.com/articles/simple-content-access"
component="a"
target="_blank"
rel="noopener noreferrer"
>
Learn about Simple Content Access
<ExternalLinkAltIcon />
</Text>
</Text>
<Text>
Any credentials of a user with a valid subscription can be
used.
</Text>
</TextContent>
}
>
<OutlinedQuestionCircleIcon />
</Popover>
</span>
}
helperText={<CopyHelperText />}
>
<ClipboardCopy>
rhc connect -u <username> -p <password>
</ClipboardCopy>
</FormGroup>
);
}
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>
);
}