Skip to content

Conversation

@tibendadavis
Copy link
Contributor

@tibendadavis tibendadavis commented Nov 27, 2025

Implements LIBS-528


Key features

  1. Added useCurrentUserInfo hook and UserProvider to provide authenticated DHIS2 user info throughout the app.

Description

This PR introduces a new hook, useCurrentUserInfo, to provide the currently authenticated DHIS2 user's information throughout the app.
It also adds a UserProvider to fetch or use pre-provided user info, integrated with the existing ConfigProvider and DataProvider.
Includes tests and documentation following the existing App Runtime structure.


Checklist

  • Have written Documentation
    • Added docs for the new hook and types (CurrentUserState)
  • Has tests coverage
    • Includes integration tests and hook-level tests with mocked data queries

Known issues

  • None

Screenshots

  • Not applicable (no UI changes)

@tibendadavis tibendadavis changed the title Feature/use current user info feat: add useCurrentUserInfo hook Dec 3, 2025
@tibendadavis tibendadavis marked this pull request as ready for review December 8, 2025 06:13
import React, { useContext } from 'react'
import { CurrentUser } from './types'

const defaultUser: CurrentUser = {
Copy link
Contributor

Choose a reason for hiding this comment

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

conceptually, shouldn't the default user be undefined? or at least an empty object?

Copy link
Contributor

Choose a reason for hiding this comment

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

and then I think the type for this should CurrentUser | undefined and the consumers responsible of handling it safely - let me know what you think

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 makes sense. I agree that the default should be undefined conceptually, and consumers should handle that case explicitly. I’ll change the type to CurrentUser | undefined and update the default accordingly

@@ -0,0 +1,11 @@
# DHIS2 App Data Service
Copy link
Contributor

Choose a reason for hiding this comment

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

typo in title - "User Service" not Data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I will fix that.

@tibendadavis tibendadavis requested a review from kabaros December 18, 2025 14:12
type ProviderInput = {
config: Config
userInfo: CurrentUser
userInfo?: CurrentUser
Copy link
Contributor

Choose a reason for hiding this comment

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

small nit: I think it's more accurate to have the type as CurrentUser | undefined, right? - as in userInfo will always be there, but might be undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, CurrentUser | undefined is more accurate here. I’ll update it

@tibendadavis tibendadavis requested a review from kabaros December 20, 2025 14:09
@kabaros
Copy link
Contributor

kabaros commented Dec 20, 2025

@tibendadavis could you run yarn install locally and update the yarn.lock file. Something seems to be broken with the lock file now... (even on master)

@kabaros kabaros force-pushed the feature/useCurrentUserInfo branch 3 times, most recently from 2774e0a to 42d43b3 Compare December 21, 2025 19:40
@kabaros
Copy link
Contributor

kabaros commented Dec 22, 2025

@tibendadavis there is a problem with the build on master (unrelated to your PR) - I am trying to fix it befoe merging yours. I will keep you updated.

@tibendadavis
Copy link
Contributor Author

@kabaros Thanks for the update, appreciate it. Let me know if you need anything from my side.

@kabaros kabaros force-pushed the feature/useCurrentUserInfo branch from 3ffeee9 to 69f1af3 Compare December 30, 2025 11:45
@kabaros kabaros force-pushed the feature/useCurrentUserInfo branch 2 times, most recently from 6e71b0c to efd3500 Compare December 30, 2025 12:18
@kabaros kabaros force-pushed the feature/useCurrentUserInfo branch from ab033c8 to 15c0b8f Compare December 30, 2025 12:27
@sonarqubecloud
Copy link

@kabaros kabaros merged commit e5cbc63 into dhis2:master Dec 30, 2025
10 of 11 checks passed
@kabaros
Copy link
Contributor

kabaros commented Dec 30, 2025

@tibendadavis I had to revert the references to the new service in this commit as it was referencing a new service that wasn't published yet - now once it is merged and published on CI, can you please create another PR off master to re-add the changes there and enable the new service provider?

@tibendadavis
Copy link
Contributor Author

@kabaros Got it. I’ve created a new PR from the updated master branch with the changes, so it’s ready for review.

dhis2-bot added a commit that referenced this pull request Jan 5, 2026
## [3.14.8](v3.14.7...v3.14.8) (2026-01-05)

### Bug Fixes

* rerun pipeline ([0593525](0593525))
* revert yarn.lock ([#1426](#1426)) ([5d4ebde](5d4ebde))

### Features

* add useCurrentUserInfo hook ([#1417](#1417)) ([e5cbc63](e5cbc63)), closes [#1420](#1420)
@dhis2-bot
Copy link
Contributor

kabaros pushed a commit that referenced this pull request Jan 5, 2026
* feat: re-enable user service provider and update dependencies

* fix: separate type import for CurrentUser in Provider component

* chore: revert yarn.lock
dhis2-bot added a commit that referenced this pull request Jan 5, 2026
# [3.15.0](v3.14.8...v3.15.0) (2026-01-05)

### Features

* enable useCurrentUserInfo service and hook ([#1417](#1417)) ([#1425](#1425)) ([1b2550f](1b2550f))
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.

5 participants