Skip to content

feat: resources add and edit form - #1037

Open
Chisomchima wants to merge 6 commits into
masterfrom
feat/resources-add-edit-form
Open

Chisomchima wants to merge 6 commits into
masterfrom
feat/resources-add-edit-form

Conversation

@Chisomchima

@Chisomchima Chisomchima commented Sep 15, 2026

Copy link
Copy Markdown
Member

Shared building blocks for the resources add/edit forms: field
components, resource schema, and validation logic.
Wire up the New and Edit routes for resources using the shared form
fields, schema, and validation.
Cover form rendering, validation, and submission for the New and
Edit resource pages.
@netlify

netlify Bot commented Sep 15, 2026

Copy link
Copy Markdown

Deploy Preview for dhis2-maintenance-app-beta ready!

Name Link
🔨 Latest commit c7749b0
🔍 Latest deploy log https://app.netlify.com/projects/dhis2-maintenance-app-beta/deploys/6aad0a6848f3d4000850e23a
😎 Deploy Preview https://deploy-preview-1037.maintenance-app-beta.netlify.dhis2.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

… gating

The edit form now lets a URL resource be switched to a file upload (and
vice versa), matching the field set and payload shape used by the New
form. Both forms now share one ResourceFormFields component and a single
useOnSubmitResource hook/schema instead of near-duplicate New/Edit copies.

Also fixes a bug where clicking a list row navigated to the edit page for
file resources even though the row actions menu correctly hid "Edit" for
them - row-click now respects the same isResourceEditable check via a new
isRowClickable prop on DefaultSectionList/SectionListWrapper.
@Chisomchima
Chisomchima requested a review from tomzemp September 15, 2026 17:02

@tomzemp tomzemp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good @Chisomchima! 🎉

Something I noticed that I think should be addressed:

  • "Save" and "Save and close" both perform the same here (they both save and close). I think it might actually be preferable to only have "Save and close" here? (We could allow "Save" and "Save and close" while editing URLs, but if we have both "Save" and "Save and close" on the new page, the "Save" button for a file resource would have to perform like "Save and close", so maybe just having "Save and close" throughout is easiest)

Other things that I noticed (that don't need to be changed now):
[I think we could ask product/design for input on these]

  • backend rejects certain file types (e.g. it doesn't accept 'html' files), but we allow you to upload them and then get that message (this also happens in the old app). I guess an improvement would be to figure out what file types the backend will take and explain that in the UI / restrict the file uploader
  • I understand that file resources are not editable, but this is a bit non-intuitive from the list view. It might be better to have a disabled edit button for file resources to indicate that something hasn't just gone wrong? Or maybe we want to map the external boolean to "url/file resource" in the list so the distinction is clearer

(Also see a couple of comments)

message: i18n.t('A URL is required'),
path: ['url'],
})
} else if (!z.string().url().safeParse(values.url).success) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we have our own final-form url validator (https://github.com/dhis2/ui/blob/master/collections/forms/src/validators/url.js), but maybe we just want to use this one. I don't know if there's some difference between the parsing

dataEngine: ReturnType<typeof useDataEngine>,
values: ResourceSubmitValues
) => ({
name: values.name,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do you need trim values here? It looks like trailing whitespaces are not being removed

Trim name/code before saving a resource, matching the trimming other
model forms already get via trimTrimmableFields. Also drop the plain
"Save" button on the resources New/Edit forms since it behaved
identically to "Save and close" there, which was confusing.
@sonarqubecloud

Copy link
Copy Markdown

@Chisomchima
Chisomchima requested a review from tomzemp September 18, 2026 10: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.

2 participants