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

Icon refactoring and Summary spacing fix #6951

Merged
merged 5 commits into from Dec 14, 2023

Conversation

ferhoyos
Copy link
Contributor

@ferhoyos ferhoyos commented Dec 12, 2023

Describe the change

Currently in Kiali there are multiple ways to create an icon:

  • SVG Icon component -> E.g., Status icon in IstioComponentStatus
  • PF Icon component (wrapper of SVG Icon component) -> E.g., Info icon in HealthDetails
  • KialiIcon component (wrapper of PF Icon component) -> E.g. Close icon in NamespaceDropdown
  • createIcon function (another wrapper of PF Icon component) -> E.g, Status icon in HealthDetails

Having many ways creates confusion to developers and can have different structure (SVG icon vs PF icon) that affects CSS styles.

For this reason I think it is good to have only one structure through Kiali application (PF icon) and simplify icon creation:

  • Convert SVG icon to PF icon
  • Replace direct PF icons with Kiali wrapper (KialiIcon or createIcon)
  • Instead of having two independent PF Icon wrappers, use createIcon to create KialiIcon components. Then we will have two ways to create an icon in Kiali ( and createIcon), but only one implementation.

From now the icon criteria should be:

  • Fixed icon -> KialiIcon component
  • Dynamic icon -> createIcon function

Icons used in graphs (config/Icons for cytoscape and styleGroup and styleNode for PF) are excluded from this refactoring.

More stuff done in this PR:

  • Fix Summary graph spacing (Remove
    from HTML)

Before:
image

After:
image

  • Icon size according to font size in Service Summary Panel Graph:

Before:
image

After:
image

  • Tooltip title in Pod card consistent with other tooltips:

Before:
image

After:
image

  • Adapt IstioComponentStatus to PF5:

Before:
image

After:
image

  • Fix lint errors

Issue reference

Fixes #6946

@ferhoyos ferhoyos self-assigned this Dec 12, 2023
@@ -35,7 +35,7 @@ describe('scoreNodes', () => {
color: 'any',
priority: 1,
icon: WarningTriangleIcon,
class: 'any'
className: 'any'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to className to be consistent with React className field.

@@ -51,7 +51,7 @@
"cypress:delete:reports": "rm cypress/results/* || true",
"cypress:combine:reports": "jrm cypress/results/combined-report.xml \"cypress/results/*.xml\"",
"lint": "eslint --ext js,ts,tsx src",
"lint:precommit": "eslint -c .eslintrc_precommit $(git diff --staged --name-only HEAD | grep -E '\\.tsx?$' | cut -d'/' -f2-)",
"lint:precommit": "eslint -c .eslintrc_precommit $(git diff --staged --name-only HEAD --diff-filter=AM | grep -E '\\.tsx?$' | cut -d'/' -f2-)",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Filter added to apply precommit lint only to added and modified files (it was throwing lint error because of deleted file)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like these author-written review comments, it's helpful without having to add comments in the code.

import { healthIndicatorStyle } from '../../styles/HealthStyle';

interface HealthIndicatorProps {
health?: H.Health;
id: string;
size?: Size;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Health indicator size should be aligned wiith current text next to indicator (font-size). For this reason I have removed specific size property.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

createIcon function moved to config/KialiIcon file

@ferhoyos ferhoyos marked this pull request as ready for review December 13, 2023 16:17
hhovsepy
hhovsepy previously approved these changes Dec 14, 2023
Copy link
Contributor

@hhovsepy hhovsepy left a comment

Choose a reason for hiding this comment

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

looks better now

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.

It's a bit hard to find the core changes within all of the linting changes, but I'm happy that you touched so many files so that other people (like me) didn't have to do all of the fixes :-) I definitely like the centralized Icon management, it should reduce surprises in icon rendering across the UI. In the code changes you can already see places where we were able to remove single-point styling, which is always good.

@@ -51,7 +51,7 @@
"cypress:delete:reports": "rm cypress/results/* || true",
"cypress:combine:reports": "jrm cypress/results/combined-report.xml \"cypress/results/*.xml\"",
"lint": "eslint --ext js,ts,tsx src",
"lint:precommit": "eslint -c .eslintrc_precommit $(git diff --staged --name-only HEAD | grep -E '\\.tsx?$' | cut -d'/' -f2-)",
"lint:precommit": "eslint -c .eslintrc_precommit $(git diff --staged --name-only HEAD --diff-filter=AM | grep -E '\\.tsx?$' | cut -d'/' -f2-)",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like these author-written review comments, it's helpful without having to add comments in the code.


type ReduxProps = {
type ReduxStateProps = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure splitting ReduxProps is necessary but it's fine, it's still clear that these are connected props.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The split is not really needed in a functional point of view. It is just a way to fix lint issue (define return type of redux methods):

const mapStateToProps = (state: KialiAppState): ReduxStateProps

const mapDispatchToProps = (dispatch: KialiDispatch): ReduxDispatchProps

Since all fields are mandatory you cannot just assign ReduxProps to both methods

Copy link
Collaborator

@aljesusg aljesusg left a comment

Choose a reason for hiding this comment

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

LGFM

@ferhoyos ferhoyos merged commit 7e8cfa6 into kiali:master Dec 14, 2023
8 checks passed
@ferhoyos ferhoyos deleted the 6946-spacing-icon-summary-graph branch December 14, 2023 15:51
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.

Incorrect spacing and icon sizing in Graph Summary Panel
4 participants