-
Notifications
You must be signed in to change notification settings - Fork 479
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
Removed edge customizations in favor of adding more CSS logic to styleEdge component #6874
Conversation
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.
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
-
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. |
…nhighlighted feature
Co-authored-by: Jay Shaughnessy <jshaughn@redhat.com>
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.
let classes: string[] = []; | ||
|
||
// Change edge color according to the pathStyle | ||
const edgeClass = style({ |
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.
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} />; |
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.
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} />;
@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. |
Right, this is what I meant in the file comment:
We need to decide what to do for this PR. We can:
My preference would probably be option 2 because in addition to |
// Change edge color according to the pathStyle | ||
const edgeClass = kialiStyle({ | ||
$nest: { | ||
'.pf-topology__edge__link': data.pathStyle |
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.
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 |
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.
Each selector is independent, so you have to add '&' for each selector:
'& .pf-topology__edge__link, & .pf-topology-connector-arrow': data.pathStyle
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.
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.
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.
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: |
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.
// 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: |
const tagClass = kialiStyle({ | ||
fontFamily: 'Verdana,Arial,Helvetica,sans-serif,pficon' | ||
}); |
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.
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} /> |
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.
<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.
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. |
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.
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) |
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.
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?
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).