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

Events v2: Implement optimistic file upload and FILE type input #8246

Merged
merged 38 commits into from
Jan 3, 2025

Conversation

rikukissa
Copy link
Member

@rikukissa rikukissa commented Dec 18, 2024

Copy link

Oops! Looks like you forgot to update the changelog. When updating CHANGELOG.md, please consider the following:

  • Changelog is read by country implementors who might not always be familiar with all technical details of OpenCRVS. Keep language high-level, user friendly and avoid technical references to internals.
  • Answer "What's new?", "Why was the change made?" and "Why should I care?" for each change.
  • If it's a breaking change, include a migration guide answering "What do I need to do to upgrade?".

@makelicious
Copy link
Collaborator

Seems to break down:

break-down

@makelicious
Copy link
Collaborator

Fixed some types as requested

Comment on lines 411 to 428
const FIELD_SEPARATOR = '____'
function unflatten<T>(data: Record<string, T>) {
return Object.fromEntries(
Object.entries(data).map(([key, value]) => [
key.replaceAll('.', FIELD_SEPARATOR),
value
])
)
}

function flatten<T>(data: Record<string, T>) {
return Object.fromEntries(
Object.entries(data).map(([key, value]) => [
key.replaceAll(FIELD_SEPARATOR, '.'),
value
])
)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's document this very carefully why we do this, it's so annoying :(

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup :D

Copy link
Collaborator

@makelicious makelicious left a comment

Choose a reason for hiding this comment

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

Some stylistic comments. Will continue soon!

allowedDocType={allowedDocType}
description={description}
error={''}
file={file ? file : undefined}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand that null is easier for browser default, could we have either undefined or null

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 Good point. I changed the default now to be undefined. Was first changing it to null but remembered I wanted to keep "null" as an explicit empty value in the form field generator and undefined more a "this field is not defined (yet)", so went with undefined here as well

description={description}
error={''}
file={file ? file : undefined}
label={file ? file.originalFilename : ''}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we generate a label or make it optional, passing empty strings along the line will contain surprises in the end

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed this to just be undefined or a real label

uploadFiles(newFile)
} else {
setFile(null)
onChange(undefined)
Copy link
Collaborator

Choose a reason for hiding this comment

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

might be a matter of taste, but could be left out

Copy link
Member Author

Choose a reason for hiding this comment

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

setFile needs to want the value to be explicitly set 🤔 Maybe best to have both the same way so explicit?

requiredErrorMessage,
touched
}: IFullProps) {
const [error, setError] = useState('')
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could just use undefined value

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, this was some og code brought back from the core side. Don't want to touch it quite yet

return <></>
}

return <>{value.toString() || ''}</>
Copy link
Collaborator

Choose a reason for hiding this comment

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

will the fallback ever trigger?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea probably doesn't anymore 👍

Copy link
Collaborator

@makelicious makelicious 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!

@rikukissa rikukissa added the 🚀 Ready to deploy Deployment automation should pick this PR up and start auto-deploying it label Dec 19, 2024
@rikukissa rikukissa temporarily deployed to events-v2-file-input December 19, 2024 10:44 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to events-v2-file-input December 19, 2024 10:49 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to events-v2-file-input December 19, 2024 10:55 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to events-v2-file-input December 19, 2024 10:58 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to events-v2-file-input December 19, 2024 11:02 — with GitHub Actions Inactive
@makelicious makelicious temporarily deployed to events-v2-file-input December 20, 2024 09:19 — with GitHub Actions Inactive
@makelicious makelicious temporarily deployed to events-v2-file-input December 20, 2024 09:21 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to events-v2-file-input December 20, 2024 09:48 — with GitHub Actions Inactive
@makelicious makelicious temporarily deployed to events-v2-file-input December 20, 2024 09:57 — with GitHub Actions Inactive
@makelicious makelicious temporarily deployed to events-v2-file-input December 20, 2024 15:00 — with GitHub Actions Inactive
@makelicious makelicious temporarily deployed to events-v2-file-input December 20, 2024 15:02 — with GitHub Actions Inactive
@makelicious makelicious temporarily deployed to events-v2-file-input December 20, 2024 15:53 — with GitHub Actions Inactive
@makelicious makelicious temporarily deployed to events-v2-file-input December 20, 2024 16:16 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to events-v2-file-input January 3, 2025 05:25 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to events-v2-file-input January 3, 2025 05:54 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to events-v2-file-input January 3, 2025 05:57 — with GitHub Actions Inactive
@rikukissa rikukissa temporarily deployed to events-v2-file-input January 3, 2025 06:20 — with GitHub Actions Inactive
@rikukissa rikukissa deployed to events-v2-file-input January 3, 2025 06:48 — with GitHub Actions Active
@rikukissa rikukissa merged commit 1acab85 into develop Jan 3, 2025
64 of 65 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 Ready to deploy Deployment automation should pick this PR up and start auto-deploying it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants