-
Notifications
You must be signed in to change notification settings - Fork 667
Added a external link to noobaa details card #2520
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
Added a external link to noobaa details card #2520
Conversation
|
Hi @bipuladh. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to handle the case when the systemName and systemAddress will be not defined and hence systemLink will be broken.
can refer https://github.com/openshift/console/blob/master/frontend/packages/noobaa-storage-plugin/src/components/buckets-card/buckets-card.tsx#L70
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The systemError variable below should handle such case, unless I'm missing something.
The systemLink variable could be defined as
const systemLink = !systemError ? `${systemAddress}fe/systems/${systemName}` : undefined;to make it clear that systemLink as a whole is undefined unless both systemName and systemAddress are valid.
Anyway, I'd suggest to simplify it further, just use
const systemLink = (systemName && systemAddress) ? `${systemAddress}fe/systems/${systemName}` : undefined;and in JSX code below
error={!systemLink}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cloudbehl @rawagner @gnehapk perceptions on this custom details link ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, i'd like to use the same approach as we do for InventoryItem where we have a generic component, which takes isLoading, error and children https://github.com/openshift/console/blob/master/frontend/public/components/dashboard/inventory-card/inventory-item.tsx#L47.
In this case the child would be either string or ExternalLink or any other component if we need in the future. If error is true, then the unavailable is shown etc.
the basic component would be just Item and we will have DetailItem and DetailItemExternalLink
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rawagner for pointing that out. However I will not be adding any required types to it and make error state detectable from the current parameters and also from the error parameter(optional) so that these changes do not break any existing references(However there are not many references and making changes to them is possible allowing us to make error a required parameter). Following your approach I don't think we will need to create a new component DetailItemExternalLink since we will be passing ExternalLink or other similar components as children.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright @rawagner , not aware of the implementation in InventoryItem.Thank you!
Late to comment but I just did not find it appropriate and rather expecting something like that the ExternalLink to be passed in value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
systemName being tested to see if it is undefined. Since systemName and systemAddress are queried from the same object, at the same depth. @afreen23
7bc578b to
53371f7
Compare
|
/assign @cloudbehl @afreen23 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, seems to me that the contract is a bit unclear. I would remove the value prop and just keep the children. I know it will mean that we need to update all usages, but we dont have that many yet so better do it sooner than later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 removing value . Using children sounds good for future changes like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is already a getMetric function in utils.ts. We must reuse that here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we implement something like this:
const noobaaSystemAddress = getMetric(queryResult, 'system_address');
const noobaaSystemName = getMetric(queryResult, 'system_name');
let link = null;
if (noobaaSystemAddress && noobaaSystemName)
link = `${noobaaSystemAddress}/fe/systems/${noobaaSystemName}/buckets/data-buckets`;
We don't need to pass then the error prop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally these lines should be wrapped in a function now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@afreen23 will use the function for metric. However for the other link issue, I need to use the error prop because if link is undefined (which is passed through ExternalLink) then DetailItem will not figure out that the values are missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 removing value . Using children sounds good for future changes like this
|
I don't remember seeing this in the latest design: @shirimordechay @julienlim - Is this how you would expect a user to jump to the NooBaa console? |
@lizsurette |
Thanks for the updated link, @afreen23 !! |
|
/ok-to-test |
|
/approve |
frontend/packages/noobaa-storage-plugin/src/components/details-card/details-card.tsx
Outdated
Show resolved
Hide resolved
frontend/public/components/dashboard/details-card/detail-item.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you extract the getName(_.get(cephClusterData, 0)) so we dont have to call it twice for error and value ?
Same for other values (in other details cards too)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
f222591 to
e7f3e1e
Compare
|
/test e2e-aws-console |
2 similar comments
|
/test e2e-aws-console |
|
/test e2e-aws-console |
|
/approve |
|
@vojtechszocs can you review this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I will update the existing code then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm wondering if there are any duplicate code detectors for TypeScript / JavaScript, which can calculate code similarity (e.g. percentage) between files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The systemError variable below should handle such case, unless I'm missing something.
The systemLink variable could be defined as
const systemLink = !systemError ? `${systemAddress}fe/systems/${systemName}` : undefined;to make it clear that systemLink as a whole is undefined unless both systemName and systemAddress are valid.
Anyway, I'd suggest to simplify it further, just use
const systemLink = (systemName && systemAddress) ? `${systemAddress}fe/systems/${systemName}` : undefined;and in JSX code below
error={!systemLink}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rawagner If DetailItem has error prop set to a truthy value, does the child content (i.e. ExternalLink above) actually render?
If yes, the systemLink will be either invalid or undefined (see my suggestion above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, child is not rendered then. DetailItem will render unavailable string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, so we can simply use the error={!systemLink} as a guard for the system link 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI there is a React helper type to avoid repeating children in your component props:
// node_modules/@types/react/index.d.ts
type PropsWithChildren<P> = P & { children?: ReactNode };You can use it like so:
type DetailItemProps = React.PropsWithChildren<{
title: string;
isLoading: boolean;
error: boolean;
}>;and it will add an optional children prop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React.FC already includes optional children prop as it uses that helper internally, so it is not necessary to deal with children prop at all (except for the cases when we want to explicitly define children prop as specific type or make it required)
8d05108 to
4a126ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned here #2520 (comment), React.PropsWithChildren is not needed as it is already included in React.FC
frontend/public/components/dashboard/details-card/detail-item.tsx
Outdated
Show resolved
Hide resolved
6c6b89c to
9ed54e5
Compare
Ran lint fix Fixing conflicts
9ed54e5 to
3a02c4b
Compare
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bipuladh, christianvogt, cloudbehl The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
3 similar comments
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/test e2e-aws |
As shown in the screenshot below a external link has been added under System name which redirects the user to an external link.