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

Removed edge customizations in favor of adding more CSS logic to styleEdge component #6874

Merged
merged 9 commits into from
Dec 6, 2023

Conversation

leandroberetta
Copy link
Contributor

@leandroberetta leandroberetta commented Nov 21, 2023

Resolves kiali/openshift-servicemesh-plugin#223

This PR aims to remove the customizations done to the edge component.

This PR uses the DefaultEdge from PF and it's modified by CSS in the StyleEdge component managed by Kiali (can be renamed to KialiEdge really).

@leandroberetta leandroberetta self-assigned this Nov 21, 2023
@leandroberetta leandroberetta marked this pull request as ready for review November 21, 2023 17:09
Copy link
Collaborator

@jshaughn jshaughn left a comment

Choose a reason for hiding this comment

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

This is promising, it seems like you may be able to eliminate the need for us to copy DefaultEdge. But there are some things that have changed or have been lost.

  • Edge width has changed. I'm actually OK thinning the edges a bit, but I don't think it's intentional. I think this is because if pathStyle is supplied we are not applying the entire style, only color. I think we should probably be honoring the entire style (note - the terminator needs only the color).

  • We lost the unhighlighting support

    • Before:
      image

    • After:
      image

  • We lost the add showTag prop and show scaled tag on hover (when showTag is false) customization.

@leandroberetta
Copy link
Contributor Author

This is promising, it seems like you may be able to eliminate the need for us to copy DefaultEdge. But there are some things that have changed or have been lost.

  • Edge width has changed. I'm actually OK thinning the edges a bit, but I don't think it's intentional. I think this is because if pathStyle is supplied we are not applying the entire style, only color. I think we should probably be honoring the entire style (note - the terminator needs only the color).

  • We lost the unhighlighting support

    • Before:
      image
    • After:
      image
  • We lost the add showTag prop and show scaled tag on hover (when showTag is false) customization.

The edge width is intentional, I'm using 2 I guess now, I think it's cleaner.

The rest, yes, is missing, I forgot why this was a draft :). I will add it back.

Copy link
Collaborator

@jshaughn jshaughn left a comment

Choose a reason for hiding this comment

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

The pathStyle issue is fixed, and I like the thinner edges. The unhighlighting is better but there is still a problem with unhighlighting the tags:

image

@leandroberetta
Copy link
Contributor Author

The pathStyle issue is fixed, and I like the thinner edges. The unhighlighting is better but there is still a problem with unhighlighting the tags:

image

Good catch, now is fixed!

image

Copy link
Collaborator

@jshaughn jshaughn left a comment

Choose a reason for hiding this comment

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

Edge tab unhighlighting is fixed, thanks! But, two more things. Hovering over an edge loses the edge coloring, and also does not trigger the unhighlighting:

image

@leandroberetta
Copy link
Contributor Author

Edge tab unhighlighting is fixed, thanks! But, two more things. Hovering over an edge loses the edge coloring, and also does not trigger the unhighlighting:

image

Interesting, it seems to be a problem when hovering, this should be related to the override of css properties. Thanks.

let classes: string[] = [];

// Change edge color according to the pathStyle
const edgeClass = style({
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use kialiStyle wrapper instead of style. It adds a prefix to CSS class name to fulfill Openshift plugin CSS requirement for OSSMC

@@ -31,7 +124,7 @@ const StyleEdgeComponent: React.FC<StyleEdgeProps> = ({ element, ...rest }) => {
return newData;
}, [data, detailsLevel]);

return <BaseEdge element={element} tagClass={tagClass} {...rest} {...passedData} />;
return <DefaultEdge className={classes?.join(' ')} element={element} {...rest} {...passedData} />;
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of join(' ') I would use classes method of typestyle library, a utility to join CSS classes conditionally

<DefaultEdge className={classes(...cssClasses)} element={element} {...rest} {...passedData} />;

@leandroberetta
Copy link
Contributor Author

leandroberetta commented Nov 28, 2023

Edge tab unhighlighting is fixed, thanks! But, two more things. Hovering over an edge loses the edge coloring, and also does not trigger the unhighlighting:
image

Interesting, it seems to be a problem when hovering, this should be related to the override of css properties. Thanks.

@jshaughn I found the issue, there is a missing part due to the removal of the custom edge code, but sadly, I don't see yet how I can do it without touching the edge. At some point, in the edge, when hover is true, we are calling a Kiali function:

https://github.com/kiali/kiali/blob/master/frontend/src/pages/GraphPF/components/edge.tsx#L105

Probably we can think this a as contribution to PF's code, like adding a hover callback or something like this.

@jshaughn
Copy link
Collaborator

but sadly, I don't see yet how I can do it without touching the edge. At some point, in the edge, when hover is true, we are calling a Kiali function:

Right, this is what I meant in the file comment:

// add showTag prop and show scaled tag on hover (when showTag is false)

We need to decide what to do for this PR. We can:

  1. Eliminate our custom Edge.tsx and regress with respect to this tag feature.
  2. Re-introduce a more minimal Edge.tsx, that maintains the feature while we work with PFT for a supported alternative.

My preference would probably be option 2 because in addition to Edge.tsx we still have out customized versions for Node and Groups, so it's not the end of our customization. I think we should go through the same exercise for Nodes and Groups, seeing what we can move to the Style classes, and work with PFT for anything remaining.

@leandroberetta
Copy link
Contributor Author

@jshaughn I finally could make the unhighlighting part:

image

I also fixed the edge style when hovering.

@ferhoyos you're feedback is addressed too. Thanks!.

// Change edge color according to the pathStyle
const edgeClass = kialiStyle({
$nest: {
'.pf-topology__edge__link': data.pathStyle
Copy link
Contributor

Choose a reason for hiding this comment

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

According to typestyle documentation (https://typestyle.github.io/#/core), it is best practice to add symbol $ to overwrite third party nested CSS classes:

const container = style({
  $nest: {
    '& .third-party-class': {
      color: 'red'
    }
  }
});

Most of the times it works fine without the & symbol, but not in all cases (if the third party CSS class has more specifity than yours). More information here: #6562

$nest: {
'& .pf-topology__edge.pf-m-hover': {
$nest: {
'& .pf-topology__edge__link, .pf-topology-connector-arrow': data.pathStyle
Copy link
Contributor

Choose a reason for hiding this comment

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

Each selector is independent, so you have to add '&' for each selector:
'& .pf-topology__edge__link, & .pf-topology-connector-arrow': data.pathStyle

ferhoyos
ferhoyos previously approved these changes Dec 5, 2023
Copy link
Contributor

@ferhoyos ferhoyos left a comment

Choose a reason for hiding this comment

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

LGTM from the CSS point of view, you have learnt a lot in the process and done a great job @leandroberetta ;-). Anyway I would wait for @jshaughn review from topology features point of view.

Copy link
Collaborator

@jshaughn jshaughn left a comment

Choose a reason for hiding this comment

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

I think all of the prior comments are resolved! And we have decided to temporarily remove the tag hide/hover customization and contribute that feature to PFT itself. So that feature is expected to not be there.

There is a regression in showing lock icons on edge labels, this can be fixed by accepting the recommended changes in my comments.

Also, I'm seeing maybe an issue in trace overlay, but I don't think it has to do with this PR, it may be nothing, but it seems sometimes the overlay stops before the selected node. Anyway, not a blocker for this.

I think if you fix the lock icon issue we can approve.


// This is the registered Edge component override that utilizes our customized Edge.tsx component.
// This is our styled edge component registered in stylesComponentFactory.tsx. It is responsible for adding our custom customizations that get passed down to DefaultEdge. The current customizations:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// This is our styled edge component registered in stylesComponentFactory.tsx. It is responsible for adding our custom customizations that get passed down to DefaultEdge. The current customizations:
// This is our styled edge component registered in stylesComponentFactory.tsx. It is responsible for adding customizations that then get passed down to DefaultEdge. The current customizations:

Comment on lines 13 to 15
const tagClass = kialiStyle({
fontFamily: 'Verdana,Arial,Helvetica,sans-serif,pficon'
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is needed to support the lock icons on edge tags.

return <BaseEdge element={element} tagClass={tagClass} {...rest} {...passedData} />;
return (
<g style={{ opacity: opacity }} onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}>
<DefaultEdge className={classes(...cssClasses)} element={element} {...rest} {...passedData} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<DefaultEdge className={classes(...cssClasses)} element={element} {...rest} {...passedData} />
<DefaultEdge className={classes(...cssClasses)} element={element} tagClass={tagClass} {...rest} {...passedData} />

This is needed to support the lock icons on edge tags.

@leandroberetta
Copy link
Contributor Author

I think all of the prior comments are resolved! And we have decided to temporarily remove the tag hide/hover customization and contribute that feature to PFT itself. So that feature is expected to not be there.

There is a regression in showing lock icons on edge labels, this can be fixed by accepting the recommended changes in my comments.

Also, I'm seeing maybe an issue in trace overlay, but I don't think it has to do with this PR, it may be nothing, but it seems sometimes the overlay stops before the selected node. Anyway, not a blocker for this.

I think if you fix the lock icon issue we can approve.

Thanks for your review @jshaughn.

I vote for remove for now the hide/hover feature (there is a PR already for that in PF repo: patternfly/react-topology#123, this issue is mentioned in the epic: kiali/openshift-servicemesh-plugin#99).

I will address the feedback.

Copy link
Collaborator

@jshaughn jshaughn left a comment

Choose a reason for hiding this comment

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

LGTM (one non-blocking comment)

// data.isFind?: boolean // adds graph-find overlay
// data.isUnhighlighted?: boolean // adds unhighlight effects
// data.hasSpans?: Span[] // adds trace overlay
// add showTag prop and show scaled tag on hover (when showTag is false)
Copy link
Collaborator

Choose a reason for hiding this comment

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

not a blocker - please remove this line in a future PR, this is not done here, we are deferring to our PFT contribution for this, right?

@leandroberetta leandroberetta merged commit 2ed984f into kiali:master Dec 6, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Remove customizations done in PF edges
3 participants