Skip to content

Conversation

@bipuladh
Copy link
Contributor

As shown in the screenshot below a external link has been added under System name which redirects the user to an external link.

update_img

@openshift-ci-robot openshift-ci-robot added component/core Related to console core functionality component/noobaa Related to noobaa-storage-plugin needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 28, 2019
@openshift-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 28, 2019

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

Copy link
Contributor

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}

Copy link

@afreen23 afreen23 Aug 28, 2019

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 ?

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link

@afreen23 afreen23 Aug 29, 2019

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.

Copy link
Contributor Author

@bipuladh bipuladh Aug 28, 2019

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

@bipuladh
Copy link
Contributor Author

/assign @cloudbehl @afreen23

Copy link
Contributor

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.

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

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.

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

Copy link

@afreen23 afreen23 Aug 29, 2019

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!

Copy link
Contributor Author

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.

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

@lizsurette
Copy link

I don't remember seeing this in the latest design:
http://openshift.github.io/openshift-origin-design/web-console/4.0-designs/storage/object-storage-dashboard/object-storage-dashboard

@shirimordechay @julienlim - Is this how you would expect a user to jump to the NooBaa console?

@afreen23
Copy link

afreen23 commented Aug 29, 2019

I don't remember seeing this in the latest design:
http://openshift.github.io/openshift-origin-design/web-console/4.0-designs/storage/object-storage-dashboard/object-storage-dashboard

@shirimordechay @julienlim - Is this how you would expect a user to jump to the NooBaa console?

@lizsurette
We are following invision mockups for the UI implementations and it's updated there!.

@lizsurette
Copy link

@lizsurette
We are following invision mockups for the UI implementations and it's updated there!.

Thanks for the updated link, @afreen23 !!

@openshift-ci-robot openshift-ci-robot added component/ceph Related to ceph-storage-plugin size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 30, 2019
@cloudbehl
Copy link
Contributor

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 30, 2019
@cloudbehl
Copy link
Contributor

/approve
@rawagner have a look once again.

Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 2, 2019
@bipuladh
Copy link
Contributor Author

bipuladh commented Sep 2, 2019

/test e2e-aws-console

2 similar comments
@bipuladh
Copy link
Contributor Author

bipuladh commented Sep 2, 2019

/test e2e-aws-console

@bipuladh
Copy link
Contributor Author

bipuladh commented Sep 3, 2019

/test e2e-aws-console

@cloudbehl
Copy link
Contributor

/approve
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 3, 2019
@cloudbehl
Copy link
Contributor

@vojtechszocs can you review this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

@rawagner Please be advised, @jtomasek adds this to console-shared selectors in his PR #2558.

https://github.com/openshift/console/pull/2558/files#diff-25304ce4310324e88754e9516a46ac5c

Once #2558 is merged, we should update our existing code to use this shared selector.

This also applies to code below.

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor

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}

Copy link
Contributor

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).

Copy link
Contributor

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

Copy link
Contributor

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 😃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

Copy link
Contributor

Choose a reason for hiding this comment

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

Good to know

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

Copy link

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)

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L495

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Sep 4, 2019
Copy link

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

@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 4, 2019
Ran lint fix

Fixing conflicts
@christianvogt
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 4, 2019
@openshift-ci-robot
Copy link
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 4, 2019
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

3 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@bipuladh
Copy link
Contributor Author

bipuladh commented Sep 5, 2019

/test e2e-aws

@openshift-merge-robot openshift-merge-robot merged commit beab439 into openshift:master Sep 5, 2019
@mareklibra mareklibra mentioned this pull request Sep 5, 2019
1 task
@spadgett spadgett added this to the v4.2 milestone Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/backend Related to backend component/ceph Related to ceph-storage-plugin component/core Related to console core functionality component/dev-console Related to dev-console component/knative Related to knative-plugin component/kubevirt Related to kubevirt-plugin component/metal3 Related to metal3-plugin component/monitoring Related to monitoring component/noobaa Related to noobaa-storage-plugin component/olm Related to OLM component/sdk Related to console-plugin-sdk component/shared Related to console-shared lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.