-
Notifications
You must be signed in to change notification settings - Fork 4
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
Export records from tables #1646
base: john/20202-page-and-record-counts
Are you sure you want to change the base?
Export records from tables #1646
Conversation
// update the provided query with export settings | ||
return produce(queryConfig, (newQueryConfig) => { | ||
// reset limit and offset | ||
newQueryConfig.limit = MAX_RECORD_EXPORT_LIMIT; |
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.
Hasura will accept a limit
of null
, but modifying this typing to accept null
was a headache i didn't really want to deal with 🤷
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 this is shippable as-is, but I have a couple of suggestions I want to put forth. If you'll see what you think about them, I'm eager to put a ✅ on this.
This is looking good! Thank you John.
* Generate the CSV export filename | ||
*/ | ||
const formatFileName = (exportFilename?: string) => | ||
`${exportFilename || "export"}-${formatDate(new Date().toISOString())}.csv`; |
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.
What would you think about including the time in addition to the date string in this default filename? Maybe <table_name>-20250108-1532.csv
for something downloaded today, the 8th at 3:32PM local time?
I know this bleeds slightly outside of the scope of this work here, as it's contained in that utility formatter, but bringing in that change allows for a user more easily keep multiple files downloaded in a set straight. I'm thinking of the use-case of when someone wants to compare multiple sets of crashes in some BI software or something like that. Being able to open up your file browser and easily sort the files in the order in which they were downloaded is valuable.
I guess put another way -- the filename is the only tiny bit of metadata we get to attach to these CSVs, so let's take as much advantage of that as we can, and avoid the browser's behavior that yields stuff like this: some-name.csv
, some-name (1).csv
, some-name (2).csv
.
<Button | ||
href={downloadUrl || "#"} | ||
download={formatFileName(exportFilename)} | ||
as="a" | ||
> |
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.
Since the data is pulled together as shown by the spinner on the download button before it can be clicked, can we close this modal automatically once or very shortly after the download button is clicked by the user? I can't see any situation where a user needs to download the same data twice in rapid succession. In fact, I think we want to avoid making that easy to do.
The model closing will give the user some visual feedback that the operation has occurred, and as it is, I think this relies too much on the browser's gloss outside of the viewport to telegraph that activity to the user, if it does telegraph it at all.
If we can't close the modal because maybe we need to keep it mounted to preserve the URL held in the useState
, can we do something like a check-mark that has some spinner-like motion, to indicate that something intended and/or positive has happened. If you look in our slack at the :checked:
emoji .. one loop of that is what I'm trying to describe as a good indicator of this type of thing.
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.
{exportable && ( | ||
<Button | ||
variant="outline-primary" | ||
style={{ border: "none" }} |
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 feels weird to me. To use the outline-primary
variant but then override the outline/border entirely. I can see this being pretty fickle and inconsistent over time. So my question/recommendation is can we write a reusable CSS class that would be consistent to apply as an override and as a 1-liner?
Aside from that, why use style
here when bootstrap has good utilities? It doesn't make a big difference but I'd use class="border-0"
in this case. Inline style are bad is a dogma I've inherited. Not sure how well it serves us here.
Associated issues
This PR adds a basic CSV export to the grid table. I decided to hold off on some more sophisticated functionality, which can be addressed via cityofaustin/atd-data-tech#20481. The main thing this export does not do versus the old VZE is allow exporting related records. That will require some bigger changes to the structure of the
queryConfig
and thequeryBuilder
.See also some discussion here about the style of the pagination + record counts 👀
Testing
URL to test: Local
Steps to test:
These tables are now exportable:
Ship list
main
branch