Skip to content

Conversation

@tlabaj
Copy link

@tlabaj tlabaj commented Oct 30, 2025

Fixes: #38879

This PR updates the Bar Chart to use the PF5 components.
API's have been maintained as to not introduce breaking changes to any plugins that may be using the component.
Tests have been updated to use RTL.

Before:
Screenshot 2025-10-29 at 4 21 00 PM

After:
Screenshot 2025-10-30 at 10 31 37 AM

@adamruzicka
Copy link
Contributor

Looking at those screenshots, could the chart fill the entire width of the card like it used to?

@tlabaj tlabaj changed the title Barchart Fixes #38879 - Update BarChart to Patternfly5 Nov 3, 2025
@lhellebr lhellebr self-requested a review November 24, 2025 12:17
Copy link
Contributor

@kmalyjur kmalyjur left a comment

Choose a reason for hiding this comment

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

Thank you, I'm leaving some comments.
I haven't tested the chart in the foreman_openscap yet.

import React from 'react';
import PropTypes from 'prop-types';
import { BarChart as PfBarChart } from 'patternfly-react';
import { getBarChartConfig } from '../../../../../services/charts/BarChartService';
Copy link
Contributor

Choose a reason for hiding this comment

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

The BarChartService.js file could be deleted when it's not used anymore

noDataMsg,
config,
title,
unloadData,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not used

return <MessageBox msg={noDataMsg} icontype="info" />;

// Configuration based on size
const getChartDimensions = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

As Adam noticed, it would be nice if it filled the space

Copy link
Author

Choose a reason for hiding this comment

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

I do not have data in my bar chart, but this is how it looks filling the space.

image

Comment on lines 25 to 34
const transformData = rawData => {
if (!rawData || !Array.isArray(rawData)) return [];

return rawData.map((item, index) => ({
x: item[0], // label
y: item[1], // value
name: item[0],
color: item[2] || undefined, // custom color if provided
}));
};
Copy link
Contributor

Choose a reason for hiding this comment

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

This function could be moved outside of the BarChart component

x: item[0], // label
y: item[1], // value
name: item[0],
color: item[2] || undefined, // custom color if provided
Copy link
Contributor

Choose a reason for hiding this comment

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

The custom coloring doesn't work

@@ -1,27 +1,139 @@
import { shallow } from 'enzyme';
import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
Copy link
Contributor

Choose a reason for hiding this comment

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

fireEvent is not used

});

it('renders empty state when no data provided', () => {
const { container } = render(<BarChart data={emptyData} noDataMsg="No data available" />);
Copy link
Contributor

Choose a reason for hiding this comment

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

'container' is declared but its value is never read.ts(6133)

The same happens for "renders with custom axis labels" test

@lhellebr
Copy link
Contributor

lhellebr commented Dec 2, 2025

@kmalyjur Is this ~finished enough to test with packit?

@kmalyjur
Copy link
Contributor

kmalyjur commented Dec 3, 2025

@kmalyjur Is this ~finished enough to test with packit?

@lhellebr I'm not sure, to be honest. I would wait for the changes.

Copy link
Contributor

@kmalyjur kmalyjur left a comment

Choose a reason for hiding this comment

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

Everything is great now, but I forgot that when deleting functions (getBarChartConfig) in foreman core, we need to add a deprecation message first. I'm sorry for not mentioning this before.

There is a deprecation function for that, here is an example of usage: https://github.com/theforeman/foreman/pull/8267/files.
The message could be something like "Please use COMPONENT_NAME from IMPORT_PATH instead".
Could you please not delete getBarChartConfig (and the tests) and deprecate it instead?

Also, the file foreman/config/irbrc_history could be deleted.

@kmalyjur
Copy link
Contributor

kmalyjur commented Jan 2, 2026

Thank you, now it just needs to be verified

@lhellebr
Copy link
Contributor

lhellebr commented Jan 7, 2026

/packit build

@lhellebr
Copy link
Contributor

lhellebr commented Jan 7, 2026

@adamruzicka
Copy link
Contributor

/packit build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants