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

feat: [DHIS2-15830] Add orgUnitId and programId to plugin context #3407

Merged
merged 2 commits into from
Sep 20, 2023

Conversation

eirikhaugstulen
Copy link
Contributor

@eirikhaugstulen eirikhaugstulen commented Sep 12, 2023

Tech summary:
We need to pass in ProgramId and orgUnitId as part of the context for the form field plugin.

@eirikhaugstulen eirikhaugstulen marked this pull request as ready for review September 12, 2023 15:09
@eirikhaugstulen eirikhaugstulen requested a review from a team as a code owner September 12, 2023 15:09

export const FormFieldPlugin = (props: ContainerProps) => {
const { pluginSource, fieldsMetadata, formId, onUpdateField, pluginContext } = props;
const metadataByPluginId = useMemo(() => Object.fromEntries(fieldsMetadata), [fieldsMetadata]);
const configuredPluginIds = useMemo(() => Object.keys(metadataByPluginId), [metadataByPluginId]);
const { programId, orgUnitId } = useLocationQuery();
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey,
What about cases where programId is missing from URL parameters (such as on /viewEvent or /enrollmentEventEdit pages)? Should we take it from somewhere else in these cases? 🤔
Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point. Also, I didn't think this quite through I guess. Instead of sending in programId, we should perhaps send in the contextId, i.e. either programId or TETid? Also, they configure the plugin by this contextId, so it should be familiar. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do they need to know if the plugin is injected within a program or a TET context? If not, then a generic contextId makes sense to me.

@github-actions
Copy link

@eirikhaugstulen eirikhaugstulen merged commit b9ec237 into master Sep 20, 2023
33 of 36 checks passed
@eirikhaugstulen eirikhaugstulen deleted the eh/feat/DHIS2-15830_AddIdsToFormFieldContext branch September 20, 2023 11:57
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 100.40.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

4 participants