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

AcmTable csv export button addition #3643

Merged

Conversation

Randy424
Copy link
Contributor

Regarding: https://issues.redhat.com/browse/ACM-12099?filter=-1

PR 1/7

Added exportContent prop to AcmTable, enabling the component to consume a callback that returns the column value's export string.

When used (see subsequent PR's for the implementation of this feature) the export button appears at the left end of the toolbar after the Manage columns button.

Screenshot 2024-07-10 at 2 15 24 AM

@Randy424 Randy424 force-pushed the ACM-12099-acmtable-csv-export branch 2 times, most recently from c6d6aac to 00640d0 Compare July 10, 2024 20:20
@KevinFCormier
Copy link
Contributor

/hold
Reviewing...

Copy link
Contributor

@KevinFCormier KevinFCormier left a comment

Choose a reason for hiding this comment

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

Looks great overall. Thank you for organizing into separate PRs!

Please see inline comments.

@@ -95,6 +95,7 @@
"uuid": "8.3.2",
"validator": "13.7.0",
"whatwg-fetch": "3.6.2",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz",
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not think this will work in our downstream builds because Cachito probably does not cache this package. They have not really provided a good explanation of why their package is not being published on npm.
SheetJS/sheetjs#2667

This package does a lot more than we need, and while I'm usually in favour of using a library, since we already have CSV export functionality in our UI that doesn't depend on a package, I think we should share that code instead.

@@ -23,6 +23,14 @@ import { IAcmTableColumn } from './AcmTable'
import { useTranslation } from '../../lib/acm-i18next'
import ColumnsIcon from '@patternfly/react-icons/dist/js/icons/columns-icon'

type PatternFlySpacingSetting = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't duplicate type definitions when possible. We can just refer to ToolbarItemProps['spacer']. However, I have other suggestions that would avoid needing to add a prop for this at all.

@@ -50,7 +60,7 @@ export function AcmManageColumn<T>({
}

return (
<ToolbarItem>
<ToolbarItem spacer={toolbarItemSpacerSetting}>
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the <ToolbarItem> component should be included in this component. I would move it up into the table. This component shouldn't be restricted to only appearing in a toolbar.

@@ -1162,8 +1217,45 @@ export function AcmTable<T>(props: AcmTableProps<T>) {
<AcmManageColumn<T>
{...{ selectedColIds, setSelectedColIds, requiredColIds, defaultColIds, setColOrderIds, colOrderIds }}
allCols={columns.filter((col) => !col.isActionCol)}
toolbarItemSpacerSetting={showExportButton ? { default: 'spacerNone' } : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a more elegant solution than conditionally adding space to the right of this item would be to put the managed columns button and export dropdown in a group of their own:

<ToolbarGroup spaceItems={{ default: 'spaceItemsNone' }}>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Excellent solution, thank you.

isPlain
dropdownItems={[
<DropdownItem
style={{ width: '10rem' }}
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this for? Seems to add space on the right of the "Export as CSV" text.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was for just that...we don't necessarily need it, so I've removed it but it was mostly to agree with the stylization happening on the search page export dropdown.

frontend/src/ui-components/AcmTable/AcmTable.tsx Outdated Show resolved Hide resolved
@Randy424 Randy424 force-pushed the ACM-12099-acmtable-csv-export branch from 78497d6 to 00640d0 Compare July 12, 2024 03:45
@Randy424 Randy424 force-pushed the ACM-12099-acmtable-csv-export branch 3 times, most recently from 2f7b4f8 to 88f4e66 Compare July 12, 2024 05:09
@Randy424
Copy link
Contributor Author

/retest-required

@Randy424
Copy link
Contributor Author

Running into a test failure on this component: src/routes/Infrastructure/Clusters/ManagedClusters/components/DownloadConfigurationDropdown.test.tsx
It's a undefined error caused from attempting to read a ClusterStatus enum from the get-cluster page...

...It's reproducible locally, but I don't yet see how we have caused this issue.

@Randy424
Copy link
Contributor Author

Looks like it's related to my use of the createDownloadFile() from the utils library: frontend/src/resources/utils/utils.ts
Strange.

@Randy424 Randy424 force-pushed the ACM-12099-acmtable-csv-export branch 6 times, most recently from 87fb2f3 to 455634f Compare July 12, 2024 20:24
@Randy424
Copy link
Contributor Author

/retest

Signed-off-by: Randy Bruno Piverger <[email protected]>
@Randy424 Randy424 force-pushed the ACM-12099-acmtable-csv-export branch from 455634f to 6909743 Compare July 12, 2024 21:29
@Randy424
Copy link
Contributor Author

Randy424 commented Jul 12, 2024

I think I fixed the issue, but the pipeline machine pools are shutting down?
Will test again on Monday :/

@KevinFCormier
Copy link
Contributor

/retest-required

Copy link

sonarcloud bot commented Jul 15, 2024

@KevinFCormier
Copy link
Contributor

/lgtm

Copy link

openshift-ci bot commented Jul 15, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: KevinFCormier, Randy424

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [KevinFCormier,Randy424]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@KevinFCormier
Copy link
Contributor

/unhold

@openshift-merge-bot openshift-merge-bot bot merged commit 35100b2 into stolostron:main Jul 15, 2024
7 checks passed
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.

2 participants