Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 2148849: Make help text links work, in VM & DataSource details pages #989

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions locales/en/plugin__kubevirt-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
"<0>Donuts chart represent current values.</0><1>Sparkline charts represent data over time</1>": "<0>Donuts chart represent current values.</0><1>Sparkline charts represent data over time</1>",
"<0>Elapsed time</0> {t('{{minutes}}{{seconds}} seconds', {\n seconds,\n minutes: minutes ? `${minutes} minutes, ` : null,\n })}": "<0>Elapsed time</0> {t('{{minutes}}{{seconds}} seconds', {\n seconds,\n minutes: minutes ? `${minutes} minutes, ` : null,\n })}",
"<0>Enter a name for the device to be assigned and select it from the dropdown menu. Click <2> Save</2>.<4></4> Click <7> + Add {type === HARDWARE_DEVICE_TYPE.GPUS ? 'GPU' : 'Host'} device </7> to add another devices.</0>": "<0>Enter a name for the device to be assigned and select it from the dropdown menu. Click <2> Save</2>.<4></4> Click <7> + Add {type === HARDWARE_DEVICE_TYPE.GPUS ? 'GPU' : 'Host'} device </7> to add another devices.</0>",
"<0>List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.</0><1><0>{obj.kind}</0><1>metadata</1><2>ownerReferences</2></1>": "<0>List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.</0><1><0>{obj.kind}</0><1>metadata</1><2>ownerReferences</2></1>",
"<0>List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.</0><1><0>Template</0><1>metadata</1><2>ownerReferences</2></1>": "<0>List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.</0><1><0>Template</0><1>metadata</1><2>ownerReferences</2></1>",
"<0>List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.</0><1><0>{obj?.kind}</0><1>metadata</1><2>ownerReferences</2></1>": "<0>List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.</0><1><0>{obj?.kind}</0><1>metadata</1><2>ownerReferences</2></1>",
"<0>Phase</0> <2></2> {vmim?.status?.phase}": "<0>Phase</0> <2></2> {vmim?.status?.phase}",
"<0>Policy</0> {vmi?.status?.migrationState?.migrationPolicyName ? (\n <ResourceLink\n groupVersionKind={MigrationPolicyModelGroupVersionKind}\n name={vmi.status.migrationState.migrationPolicyName}\n />\n ) : (\n <MutedTextSpan text=\"No MigrationPolicy\" />\n )}": "<0>Policy</0> {vmi?.status?.migrationState?.migrationPolicyName ? (\n <ResourceLink\n groupVersionKind={MigrationPolicyModelGroupVersionKind}\n name={vmi.status.migrationState.migrationPolicyName}\n />\n ) : (\n <MutedTextSpan text=\"No MigrationPolicy\" />\n )}",
"<0>Started</0> {vmi?.status?.migrationState?.startTimestamp &&\n dateTimeFormatter.format(new Date(vmi?.status?.migrationState?.startTimestamp))}": "<0>Started</0> {vmi?.status?.migrationState?.startTimestamp &&\n dateTimeFormatter.format(new Date(vmi?.status?.migrationState?.startTimestamp))}",
Expand Down Expand Up @@ -488,7 +487,6 @@
"Learn more about supported formats": "Learn more about supported formats",
"Learn more about working with projects": "Learn more about working with projects",
"Limitations": "Limitations",
"List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.",
"List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.<1><0>VirtualMachineInstance</0><1>metadata</1><2>ownerReferences</2></1>": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.<1><0>VirtualMachineInstance</0><1>metadata</1><2>ownerReferences</2></1>",
"Live migration": "Live migration",
"Live migration network": "Live migration network",
Expand Down
4 changes: 4 additions & 0 deletions src/utils/components/DescriptionItem/DescriptionItem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
justify-content: space-between;
flex: 1;
}

.margin-top {
margin-top: var(--pf-global--spacer--md);
}
15 changes: 8 additions & 7 deletions src/utils/components/DescriptionItem/DescriptionItemHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { Link } from 'react-router-dom';

import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
import {
Expand Down Expand Up @@ -37,15 +36,17 @@ export const DescriptionItemHeader: React.FC<DescriptionItemHeaderProps> = ({
{moreInfoURL && (
<>
{t('More info: ')}
<Link to={moreInfoURL}>{moreInfoURL}</Link>
<a href={moreInfoURL}>{moreInfoURL}</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why replacing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because Link does not work as we would expect. It "looks" at the history. That's not what we want in here.
Also because everywhere where this works without issues, we already use a element exactly like this. It's so simple that it doesn't worth to create a new React element, IMO.

</>
)}
{breadcrumb && (
<Breadcrumb>
{breadcrumb.split('.').map((item) => (
<BreadcrumbItem key={item}>{item}</BreadcrumbItem>
))}
</Breadcrumb>
<div className="margin-top">
<Breadcrumb>
{breadcrumb.split('.').map((item) => (
<BreadcrumbItem key={item}>{item}</BreadcrumbItem>
))}
</Breadcrumb>
</div>
)}
</>
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/components/OwnerDetailsItem/OwnerDetailsItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const OwnerDetailsItem: React.FC<OwnerDetailsItemProps> = ({ obj }) => {
controller field set to true. There cannot be more than one managing controller.
</div>
<Breadcrumb className="margin-top">
<BreadcrumbItem>{obj.kind}</BreadcrumbItem>
<BreadcrumbItem>{obj?.kind}</BreadcrumbItem>
<BreadcrumbItem>metadata</BreadcrumbItem>
<BreadcrumbItem>ownerReferences</BreadcrumbItem>
</Breadcrumb>
Expand Down
57 changes: 0 additions & 57 deletions src/views/templates/details/tabs/details/components/Owner.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import DescriptionItem from 'src/views/templates/details/tabs/details/components
import Labels from 'src/views/templates/details/tabs/details/components/Labels';
import Name from 'src/views/templates/details/tabs/details/components/Name';
import Namespace from 'src/views/templates/details/tabs/details/components/Namespace';
import Owner from 'src/views/templates/details/tabs/details/components/Owner';
import { TemplateDetailsGridProps } from 'src/views/templates/details/tabs/details/TemplateDetailsPage';

import OwnerDetailsItem from '@kubevirt-utils/components/OwnerDetailsItem/OwnerDetailsItem';
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
import { getTemplateVirtualMachineObject } from '@kubevirt-utils/resources/template';
import { getMachineType } from '@kubevirt-utils/resources/vm';
Expand Down Expand Up @@ -44,7 +44,7 @@ const TemplateDetailsLeftGrid: React.FC<TemplateDetailsGridProps> = ({ template
<BootMethod template={template} />
<BaseTemplate template={template} />
<CreatedAt template={template} />
<Owner template={template} />
<OwnerDetailsItem obj={template} />
</DescriptionList>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
justify-content: space-between;
flex: 1;
}

.margin-top {
margin-top: var(--pf-global--spacer--md);
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import * as React from 'react';
import { Link } from 'react-router-dom';

import { DescriptionItemHeader } from '@kubevirt-utils/components/DescriptionItem/DescriptionItemHeader';
import MutedTextSpan from '@kubevirt-utils/components/MutedTextSpan/MutedTextSpan';
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
import {
Breadcrumb,
BreadcrumbItem,
Button,
DescriptionListDescription,
DescriptionListGroup,
DescriptionListTerm,
DescriptionListTermHelpText,
DescriptionListTermHelpTextButton,
Flex,
FlexItem,
Popover,
} from '@patternfly/react-core';
import { PencilAltIcon } from '@patternfly/react-icons';

Expand Down Expand Up @@ -52,41 +47,6 @@ const VirtualMachineDescriptionItem: React.FC<VirtualMachineDescriptionItemProps
const { t } = useKubevirtTranslation();
const NotAvailable = <MutedTextSpan text={t('Not available')} />;

const getItemHeader = () => {
if (isPopover && bodyContent) {
return (
<Popover
headerContent={descriptionHeader}
bodyContent={
<>
{bodyContent}
{moreInfoURL && (
<>
{t('More info: ')}
<Link to={moreInfoURL}>{moreInfoURL}</Link>
</>
)}
{breadcrumb && (
<Breadcrumb>
{breadcrumb.split('.').map((item) => (
<BreadcrumbItem key={item}>{item}</BreadcrumbItem>
))}
</Breadcrumb>
)}
</>
}
>
<DescriptionListTermHelpTextButton>
{' '}
{descriptionHeader}{' '}
</DescriptionListTermHelpTextButton>
</Popover>
);
}

return <DescriptionListTerm>{descriptionHeader}</DescriptionListTerm>;
};

const description = (
<Button
type="button"
Expand Down Expand Up @@ -114,7 +74,15 @@ const VirtualMachineDescriptionItem: React.FC<VirtualMachineDescriptionItemProps
default: editOnTitleJustify ? 'justifyContentSpaceBetween' : 'justifyContentFlexStart',
}}
>
<FlexItem>{getItemHeader()}</FlexItem>
<FlexItem>
<DescriptionItemHeader
isPopover={isPopover}
bodyContent={bodyContent}
moreInfoURL={moreInfoURL}
breadcrumb={breadcrumb}
descriptionHeader={descriptionHeader}
/>
</FlexItem>
{isEdit && showEditOnTitle && (
<FlexItem>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import GuestAgentIsRequiredText from '@kubevirt-utils/components/GuestAgentIsReq
import { LabelsModal } from '@kubevirt-utils/components/LabelsModal/LabelsModal';
import { useModal } from '@kubevirt-utils/components/ModalProvider/ModalProvider';
import MutedTextSpan from '@kubevirt-utils/components/MutedTextSpan/MutedTextSpan';
import OwnerReferences from '@kubevirt-utils/components/OwnerReferences/OwnerReferences';
import OwnerDetailsItem from '@kubevirt-utils/components/OwnerDetailsItem/OwnerDetailsItem';
import StartPauseModal from '@kubevirt-utils/components/StartPauseModal/StartPauseModal';
import Timestamp from '@kubevirt-utils/components/Timestamp/Timestamp';
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
Expand Down Expand Up @@ -308,16 +308,7 @@ const VirtualMachineDetailsLeftGrid: React.FC<VirtualMachineDetailsLeftGridProps
)}
breadcrumb="VirtualMachine.metadata.creationTimestamp"
/>
<VirtualMachineDescriptionItem
descriptionData={<OwnerReferences obj={vm} />}
descriptionHeader={t('Owner')}
isPopover
// body-content text copied from: https://github.com/kubevirt-ui/kubevirt-api/blob/main/containerized-data-importer/models/V1ObjectMeta.ts#L110
bodyContent={t(
'List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.',
)}
breadcrumb="VirtualMachine.metadata.ownerReferences"
/>
<OwnerDetailsItem obj={vm} />
</DescriptionList>
</GridItem>
);
Expand Down