Skip to content

Commit

Permalink
Merge branch 'master' into DHIS2-15704/password-regex-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tomzemp committed Jan 30, 2025
2 parents d209255 + 15e9973 commit c26c9d9
Show file tree
Hide file tree
Showing 18 changed files with 410 additions and 76 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# [100.5.0](https://github.com/dhis2/user-app/compare/v100.4.0...v100.5.0) (2025-01-30)


### Bug Fixes

* get enforce verification ([a1cb686](https://github.com/dhis2/user-app/commit/a1cb686dd1fecb8ce883dd299fc8d546f85d71f6))
* run yarn format ([be1752a](https://github.com/dhis2/user-app/commit/be1752a129fd0686bad8dcf00ff906a191dcafd6))
* update v42 fixtures ([3c5e07f](https://github.com/dhis2/user-app/commit/3c5e07fdd5458fea8d791817a4c6c128de56e4f9))


### Features

* add email status message component ([487a8f2](https://github.com/dhis2/user-app/commit/487a8f24bfc9dab610d98fefef5ad03a2029a4ba))
* add email verification in user list [DHIS2-18613] ([a52cab0](https://github.com/dhis2/user-app/commit/a52cab02fb8ff8b463896477f10a67d2bc06db48))
* fetch the enforce verified email ([00807cb](https://github.com/dhis2/user-app/commit/00807cb5793cee745321522549e94114d81f925d))
* show user verified status ([0cc7ae3](https://github.com/dhis2/user-app/commit/0cc7ae356a4a3e4db2a50c01794bee25365abb24))
* show user verified status ([585a675](https://github.com/dhis2/user-app/commit/585a675155680857a521f960ab3986c7c1718974))
* update cypress fixtures ([88770a8](https://github.com/dhis2/user-app/commit/88770a8b0055ee06c172cccc741b2ecd391b6c41))

# [100.4.0](https://github.com/dhis2/user-app/compare/v100.3.0...v100.4.0) (2025-01-16)


Expand Down

Large diffs are not rendered by default.

85 changes: 58 additions & 27 deletions cypress/fixtures/network/42/static_resources.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions cypress/fixtures/network/42/summary.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"count": 415,
"totalResponseSize": 434461,
"duplicates": 316,
"count": 401,
"totalResponseSize": 310570,
"duplicates": 307,
"nonDeterministicResponses": 24,
"apiVersion": "42",
"fixtureFiles": [
"static_resources.json",
"show_tiles_with_list_and_add_action_to_all_available_sections.json",
"the_app_has_a_main_navigation.json",
"user_roles_can_be_listed.json",
"the_user_role_list_can_be_searched.json",
"users_can_be_listed.json",
"the_user_list_can_be_searched.json",
"user_groups_can_be_listed.json",
"the_user_group_list_can_be_searched.json"
"the_user_group_list_can_be_searched.json",
"user_roles_can_be_listed.json",
"the_user_role_list_can_be_searched.json"
]
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

149 changes: 138 additions & 11 deletions cypress/fixtures/network/42/the_user_list_can_be_searched.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cypress/fixtures/network/42/user_groups_can_be_listed.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cypress/fixtures/network/42/user_roles_can_be_listed.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cypress/fixtures/network/42/users_can_be_listed.json

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2025-01-09T12:18:17.999Z\n"
"PO-Revision-Date: 2025-01-09T12:18:17.999Z\n"
"POT-Creation-Date: 2025-01-30T10:02:13.474Z\n"
"PO-Revision-Date: 2025-01-30T10:02:13.474Z\n"

msgid "Yes"
msgstr "Yes"
Expand Down Expand Up @@ -536,6 +536,15 @@ msgstr "Telegram"
msgid "Twitter"
msgstr "Twitter"

msgid "This user email has been verified."
msgstr "This user email has been verified."

msgid "This user does not have a verified email."
msgstr "This user does not have a verified email."

msgid "This user does not have a verified email"
msgstr "This user does not have a verified email"

msgid "Invite user"
msgstr "Invite user"

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "user-app",
"version": "100.4.0",
"version": "100.5.0",
"description": "DHIS2 User app",
"license": "BSD-3-Clause",
"private": true,
Expand Down
1 change: 1 addition & 0 deletions src/components/Form.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@
.errorNoticeBox {
max-width: 500px;
}

21 changes: 21 additions & 0 deletions src/components/UserForm/BasicInformationSection.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
import { useDataQuery } from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import { composeValidators, hasValue, email } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React, { useEffect } from 'react'
import { useForm } from 'react-final-form'
import { useFeatureToggle } from '../../hooks/useFeatureToggle.js'
import {
FormSection,
TextField,
EmailField,
SingleSelectField,
CheckboxField,
} from '../Form.js'
import EmailStatusMessage from './EmailStatusMessage.js'
import { useUserNameValidator } from './validators.js'

const hasOption = (options, value) =>
!!options.find((option) => option.value === value)

const INVITE_USER = 'INVITE_USER'

const query = {
data: {
resource: '/systemSettings/enforceVerifiedEmail',
},
}

const BasicInformationSection = React.memo(
({
user,
Expand All @@ -27,6 +36,8 @@ const BasicInformationSection = React.memo(
databaseLanguageOptions,
currentUserId,
}) => {
const { displayEmailVerifiedStatus } = useFeatureToggle()
const { data: enforceVerifiedEmail } = useDataQuery(query)
const { resetFieldState } = useForm()
const validateUserName = useUserNameValidator({
user,
Expand Down Expand Up @@ -72,6 +83,16 @@ const BasicInformationSection = React.memo(
: email
}
/>

{displayEmailVerifiedStatus && user && (
<EmailStatusMessage
emailVerified={user?.emailVerified ?? false}
enforceVerifiedEmail={
enforceVerifiedEmail?.data?.enforceVerifiedEmail ??
false
}
/>
)}
<TextField
required
name="firstName"
Expand Down
54 changes: 54 additions & 0 deletions src/components/UserForm/EmailStatusMessage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import i18n from '@dhis2/d2-i18n'
import {
IconCheckmarkCircle16,
colors,
IconWarning16,
IconInfo16,
} from '@dhis2/ui'
import PropTypes from 'prop-types'
import React from 'react'
import styles from './UserForm.module.css'

const EmailStatusMessage = ({ emailVerified, enforceVerifiedEmail }) => {
let icon
let color
let message

if (enforceVerifiedEmail) {
if (emailVerified) {
color = colors.green600
icon = IconCheckmarkCircle16
message = i18n.t('This user email has been verified.')
}
if (!emailVerified) {
color = colors.red600
icon = IconWarning16
message = i18n.t('This user does not have a verified email.')
}
} else {
if (!emailVerified) {
color = colors.default
icon = IconInfo16
message = i18n.t('This user does not have a verified email')
}
if (emailVerified) {
color = colors.green600
icon = IconCheckmarkCircle16
message = i18n.t('This user email has been verified.')
}
}

return (
<div className={styles.statusMessage}>
<span>{React.createElement(icon, { color })}</span>
<div style={{ color }}>{message}</div>
</div>
)
}

EmailStatusMessage.propTypes = {
emailVerified: PropTypes.bool.isRequired,
enforceVerifiedEmail: PropTypes.bool.isRequired,
}

export default EmailStatusMessage
8 changes: 8 additions & 0 deletions src/components/UserForm/UserForm.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@
max-width: 500px;
margin-bottom: var(--spacers-dp16);
}

.statusMessage {
display: flex;
margin-block: 8px;
gap: 5px;
align-items: center;
font-size: 13px;
}
1 change: 1 addition & 0 deletions src/pages/EditUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const userQuery = {
'teiSearchOrganisationUnits[id,displayName,path]',
'dataViewMaxOrganisationUnitLevel',
'id',
'emailVerified',
'username',
'accountExpiry',
'lastLogin',
Expand Down

0 comments on commit c26c9d9

Please sign in to comment.