Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
MiquelAdell committed Sep 30, 2024
2 parents e7e7748 + 5760285 commit cdbf622
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 72 deletions.
10 changes: 5 additions & 5 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: 2024-07-08T18:07:48.975Z\n"
"PO-Revision-Date: 2024-07-08T18:07:48.975Z\n"
"POT-Creation-Date: 2024-09-24T10:51:56.735Z\n"
"PO-Revision-Date: 2024-09-24T10:51:56.735Z\n"

msgid "ID"
msgstr ""
Expand Down Expand Up @@ -224,6 +224,9 @@ msgstr ""
msgid "Logger"
msgstr ""

msgid "Error saving user"
msgstr ""

msgid "General info"
msgstr ""

Expand All @@ -233,9 +236,6 @@ msgstr ""
msgid "Other information"
msgstr ""

msgid "Error saving user"
msgstr ""

msgid "Cancel"
msgstr ""

Expand Down
8 changes: 4 additions & 4 deletions i18n/es.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
"POT-Creation-Date: 2024-07-08T18:07:48.975Z\n"
"POT-Creation-Date: 2024-09-24T10:51:56.735Z\n"
"PO-Revision-Date: 2018-10-25T09:02:35.143Z\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -228,6 +228,9 @@ msgstr "Configuración"
msgid "Logger"
msgstr ""

msgid "Error saving user"
msgstr "Error al guardar usuario"

msgid "General info"
msgstr "Información General"

Expand All @@ -237,9 +240,6 @@ msgstr ""
msgid "Other information"
msgstr "Otra información"

msgid "Error saving user"
msgstr "Error al guardar usuario"

msgid "Cancel"
msgstr "Cancelar"

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "user-extended-app",
"description": "DHIS2 Extended User app",
"version": "1.5.1",
"version": "1.5.2",
"license": "GPL-3.0",
"author": "EyeSeeTea team",
"homepage": ".",
Expand Down
6 changes: 4 additions & 2 deletions src/legacy/models/userHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const fieldSplitChar = "||";

export const fieldImportSuffix = "Import";

const requiredPropertiesOnImport = ["username", "password", "firstName", "surname", "userRoles"];
// NOTE: UEApp allows to create a user without organisationUnits, but DHIS2 User App does not.
const requiredPropertiesOnImport = ["username", "password", "firstName", "surname", "userRoles", "organisationUnits"];

const propertiesIgnoredOnImport = ["id", "created", "lastUpdated", "lastLogin"];

Expand Down Expand Up @@ -403,7 +404,8 @@ async function saveUsers(d2, users, d2Api, currentUser) {
const usersToSave = getUsersToSave(users, existingUsersToUpdate);
const d2Logger = await buildLogger(d2Api, currentUser);
d2Logger?.log({ users: buildUserWithoutPassword(users) });
const response = await postMetadata(api, { users: users }, d2Logger);
const response = await postMetadata(api, { users: usersToSave }, d2Logger);
// NOTE: this executes even when postMetadata fails
await userRepository.updateUserGroups(usersToSave, existingUsersToUpdate, d2Logger).runAsync();
return response;
}
Expand Down
2 changes: 1 addition & 1 deletion src/webapp/components/form/fields/PreviewInputFF.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { InputField } from "@dhis2/ui";
import { ConfirmationDialog } from "@eyeseetea/d2-ui-components";
import i18n from "@eyeseetea/d2-ui-components/locales";
import i18n from "../../../../locales";
import _ from "lodash";
import React, { useState } from "react";
import { Field, FieldRenderProps } from "react-final-form";
Expand Down
118 changes: 60 additions & 58 deletions src/webapp/components/user-edit-wizard/UserEditWizard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, ButtonStrip, NoticeBox } from "@dhis2/ui";
import i18n from "@eyeseetea/d2-ui-components/locales";
import i18n from "../../../locales";
import { Paper, Step, StepLabel, Stepper } from "@material-ui/core";
import { ArrowBack, ArrowForward } from "@material-ui/icons";
import { FORM_ERROR } from "final-form";
Expand All @@ -11,59 +11,6 @@ import { User } from "../../../domain/entities/User";
import { useGoBack } from "../../hooks/useGoBack";
import { UserEditWizardStep, UserEditWizardStepProps } from "./UserEditWizardStep";

const steps: WizardStep[] = [
{
key: `general-info`,
label: i18n.t("General info"),
component: UserEditWizardStep,
props: {
fields: [
"username",
"firstName",
"surname",
"email",
"externalAuth",
"password",
"openId",
"ldapId",
"accountExpiry",
],
},
},

{
key: `assignment`,
label: i18n.t("Assignment"),
component: UserEditWizardStep,
props: {
fields: [
"userRoles",
"organisationUnits",
"dataViewOrganisationUnits",
"searchOrganisationsUnits",
"userGroups",
],
},
},
{
key: `other`,
label: i18n.t("Other information"),
component: UserEditWizardStep,
props: {
fields: [
"uiLocale",
"dbLocale",
"phoneNumber",
"whatsApp",
"facebookMessenger",
"skype",
"telegram",
"twitter",
],
},
},
];

interface WizardStep {
key: string;
label: string;
Expand Down Expand Up @@ -94,6 +41,61 @@ export const UserEditWizard: React.FC<UserEditWizardProps> = ({ user, onSave, on
[onSave, goBack]
);

const steps = React.useMemo((): WizardStep[] => {
return [
{
key: `general-info`,
label: i18n.t("General info"),
component: UserEditWizardStep,
props: {
fields: [
"username",
"firstName",
"surname",
"email",
"externalAuth",
"password",
"openId",
"ldapId",
"accountExpiry",
],
},
},

{
key: `assignment`,
label: i18n.t("Assignment"),
component: UserEditWizardStep,
props: {
fields: [
"userRoles",
"organisationUnits",
"dataViewOrganisationUnits",
"searchOrganisationsUnits",
"userGroups",
],
},
},
{
key: `other`,
label: i18n.t("Other information"),
component: UserEditWizardStep,
props: {
fields: [
"uiLocale",
"dbLocale",
"phoneNumber",
"whatsApp",
"facebookMessenger",
"skype",
"telegram",
"twitter",
],
},
},
];
}, []);

return (
<Form<{ users: User[] }>
autocomplete="off"
Expand All @@ -107,7 +109,7 @@ export const UserEditWizard: React.FC<UserEditWizardProps> = ({ user, onSave, on
</NoticeBox>
)}

<Wizard onCancel={onCancel}>
<Wizard steps={steps} onCancel={onCancel}>
{steps.map(({ component: Component, props, key }) => (
<Component key={key} isEdit={isEdit} {...props} />
))}
Expand All @@ -118,7 +120,7 @@ export const UserEditWizard: React.FC<UserEditWizardProps> = ({ user, onSave, on
);
};

const Wizard: React.FC<{ onCancel: any }> = ({ children, onCancel }) => {
const Wizard: React.FC<{ steps: WizardStep[]; onCancel: any }> = ({ children, onCancel, steps }) => {
const [step, setStep] = useState<string>(steps[0]?.key ?? "");
const index = _.findIndex(steps, ({ key }) => key === step);
const page = index > 0 ? index : 0;
Expand All @@ -129,14 +131,14 @@ const Wizard: React.FC<{ onCancel: any }> = ({ children, onCancel }) => {
const index = steps.findIndex(({ key }) => key === step);
return steps[index + 1]?.key ?? step;
});
}, []);
}, [steps]);

const onPrev = useCallback(() => {
setStep(step => {
const index = steps.findIndex(({ key }) => key === step);
return steps[index - 1]?.key ?? step;
});
}, []);
}, [steps]);

const jumpStep = useCallback((currentStep: string) => setStep(currentStep), []);

Expand Down
2 changes: 1 addition & 1 deletion src/webapp/utils/list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import i18n from "@eyeseetea/d2-ui-components/locales";
import i18n from "../../locales";
import _ from "lodash";

export function ellipsizedList(items: string[], limit = 3): string {
Expand Down

0 comments on commit cdbf622

Please sign in to comment.