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

feat(TitleColumn): RHINENG-3112 - Allow passing in a link via href prop #2087

Merged
merged 2 commits into from
Nov 23, 2023

Conversation

bastilian
Copy link
Member

@bastilian bastilian commented Nov 10, 2023

This changes the a tag used to a proper react router Link component and allows entities to have a href prop that the Inventory should link the display_name (example in compliance[0]).

[0] https://github.com/RedHatInsights/compliance-frontend/pull/2012/files#diff-09ae52efeffb58d25e728921c02f75f65b9f249855e9eea936ce9e913d6997e1R145

@@ -295,7 +295,6 @@ const ConventionalSystemsTab = ({
],
}}
bulkSelect={bulkSelectConfig}
onRowClick={(_e, id, app) => navigate(`/${id}${app ? `/${app}` : ''}`)}
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what this was meant to link to exactly. When the onRowClick is called it will receive an event, id, but the third argument is not an "app" or anything, but isMetaKey which determines if a certain keyboard key is pressed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, by default the inventory table will link/navigate to the systems details page in the inventory, like it did here in the passed in onRowClick. So this became obsolete.

@@ -40,10 +38,6 @@ const ImmutableDevices = ({
return [...mergeAppColumns(filteredColumns), ...edgeColumns];
};

const onRowClick = (_key, systemId) => {
navigate(`/insights/inventory/${systemId}?appName=vulnerabilities`);
Copy link
Member Author

Choose a reason for hiding this comment

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

This became obsolete with using the Link in the TitleColumn and the react router oddnesses being resolved, not requiring to pass in a navigate ensuring it is referencing the correct router to navigate.

@@ -70,14 +67,6 @@ const EntityTable = ({
[loaded, columns, hasItems, rows, isExpandable]
);

const defaultRowClick = (_event, key) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Same as above.

<div className="ins-composed-col sentry-mask data-hj-suppress">
<div key="os_release">{item?.os_release}</div>
{item?.os_release && <div key="os_release">{item?.os_release}</div>}
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that we are showing/using this anywhere, or?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not 100% sure what it even does. Would it provide another div in the title column with the os version along with the system name? If so, then I've never seen that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it would do just that. I'll leave it in for now, but I think we can eventually remove it.

@bastilian bastilian force-pushed the title_column_href branch 2 times, most recently from 778c36d to 3a578b3 Compare November 13, 2023 11:38
@bastilian bastilian marked this pull request as ready for review November 13, 2023 11:43
@bastilian bastilian requested a review from a team as a code owner November 13, 2023 11:43
@codecov-commenter
Copy link

codecov-commenter commented Nov 13, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (53ebfa8) 59.20% compared to head (b224d5e) 59.21%.

Files Patch % Lines
src/components/InventoryTable/helpers.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2087   +/-   ##
=======================================
  Coverage   59.20%   59.21%           
=======================================
  Files         188      188           
  Lines        5944     5938    -6     
  Branches     1669     1669           
=======================================
- Hits         3519     3516    -3     
+ Misses       2425     2422    -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

.find('.ins-composed-col > :nth-child(2) > a')
.trigger('click');
.find('.ins-composed-col > div > a')
.click();
Copy link
Member Author

Choose a reason for hiding this comment

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

The click() was what fixed the failing Cypress test, which is odd, because I would expect trigger('click') to be the same and click would just be a shorthand.

@bastilian
Copy link
Member Author

/retest

@gkarat gkarat added the enhancement New feature or request label Nov 21, 2023
@bastilian bastilian force-pushed the title_column_href branch 2 times, most recently from ee10d0a to 60bb7eb Compare November 23, 2023 10:51
Copy link
Contributor

@gkarat gkarat left a comment

Choose a reason for hiding this comment

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

LGTM! Have tested it locally for preview and stable routes and didn't find any issues while navigating. Also thanks for updating the tests

@@ -343,7 +341,6 @@ InventoryTable.propTypes = {
tableProps: PropTypes.object,
isRbacEnabled: PropTypes.bool,
hasCheckbox: PropTypes.bool,
onRowClick: PropTypes.func,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit-pick: Since the prop is sent down to EntityTable eventually, I think it makes sense to leave it specified in propTypes here as an indication that InventoryTable generally supports this property.

InsightsLink is not fully working in scenarios where the Link is in another applications.
@bastilian bastilian merged commit f4a9b0d into RedHatInsights:master Nov 23, 2023
2 checks passed
@gkarat
Copy link
Contributor

gkarat commented Nov 23, 2023

🎉 This PR is included in version 1.59.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants