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

Downloading selected files #42

Merged
merged 42 commits into from
Jun 26, 2024
Merged

Downloading selected files #42

merged 42 commits into from
Jun 26, 2024

Conversation

hetd54
Copy link
Collaborator

@hetd54 hetd54 commented May 6, 2024

Lots of changes in this one, mostly because I uploaded all the codebooks for testing.

Files Added

Codebooks

The PDFs get uploaded to the public folder so users can easily access them (public/files).

MD files are created in src/content so that StaticCMS can display them in its UI

Component

DataForm.tsx : This is a parent react component that passes logic between the table and the download modal

Files Changed

Components

CustomInput and CustomTextarea : added functionality for radix form; passes ref from the form into the custom input

DataTable : receives the state change function from parent (DataForm), passes back the selected files on change

DownloadModal : Uses radix form and react-hook-form for some convenient form logic

Page

data.astro : uses the DataForm component to display reactive components

Upcoming (Next PR)

authentication with firebase
disabled buttons dependent on auth status
better messaging to user in the modal

Questions

For now I threw each file individually in the modal for the user to click on to download, but that feels clunky. Do you have thoughts on a different flow? A zip file would be nice -- any recs?

Copy link

github-actions bot commented May 6, 2024

Visit the preview URL for this PR (updated for commit 2baf747):

https://mmp-site-b1c9b--pr42-download-files-wgzswji2.web.app

(expires Tue, 02 Jul 2024 16:40:09 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 4eb870c89e876f1812e204af417359065d2a23b1

@hetd54 hetd54 requested review from galenwinsor and broarr May 6, 2024 15:42
Copy link

@broarr broarr left a comment

Choose a reason for hiding this comment

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

This looks good! How does this relate to the firebase auth stuff? Let's try and check in sometime soon to go over this stuff! I had a thought around how to handle the split between static cms and firebase

We can have a github action copy data over to firebase storage when new content is pushed to main. Then users can have firebase do the auth stuff. The github action can also make zip files for this stuff too!

public/admin/config.yml Show resolved Hide resolved
Copy link
Contributor

@galenwinsor galenwinsor left a comment

Choose a reason for hiding this comment

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

Looking good! Just a few questions/suggestions.

src/components/DataForm.tsx Outdated Show resolved Hide resolved
src/components/DataTable.tsx Outdated Show resolved Hide resolved
src/components/DataTable.tsx Outdated Show resolved Hide resolved
Copy link

@broarr broarr left a comment

Choose a reason for hiding this comment

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

@galenwinsor made the comments I would have made again. I'm just commenting so when you add in the fixes you won't have to get two approvals

public/admin/config.yml Show resolved Hide resolved
public/admin/config.yml Show resolved Hide resolved
@hetd54 hetd54 requested a review from galenwinsor June 17, 2024 19:17
Copy link
Contributor

@galenwinsor galenwinsor left a comment

Choose a reason for hiding this comment

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

Looks good to me! I just wonder if you could get rid of that useEffect and extra state variable.

Comment on lines 35 to 41
useEffect(() => {
const newSelectedFiles = files.filter((file) => file.selected)
// updateFileList is from parent -- updates parent state to pass to the form
// used for eventual history table to show what files user downloaded
updateFileList(newSelectedFiles.map((file) => file.file))
}, [files])

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you get rid of this useEffect and the files state if you had the fileList state in the parent store the selected field?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup, done!

@hetd54 hetd54 requested a review from galenwinsor June 18, 2024 21:02
@hetd54 hetd54 requested a review from broarr June 25, 2024 16:37
</Form.Field>
</Form.Root>
{filesToDownload.map((file) => {
const name = file.replace(/.+?(?=[^_]+$)/, "").replace(/\.[^.]*$/, "")
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment saying what this does?

@hetd54 hetd54 merged commit 1d6530a into main Jun 26, 2024
2 checks passed
@hetd54 hetd54 deleted the download-files branch June 26, 2024 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants