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
adrianq committed Oct 21, 2024
2 parents cdbf622 + ab2bf10 commit 5bda3cb
Show file tree
Hide file tree
Showing 19 changed files with 1,187 additions and 189 deletions.
92 changes: 66 additions & 26 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-09-24T10:51:56.735Z\n"
"PO-Revision-Date: 2024-09-24T10:51:56.735Z\n"
"POT-Creation-Date: 2024-10-21T20:07:31.924Z\n"
"PO-Revision-Date: 2024-10-21T20:07:31.924Z\n"

msgid "ID"
msgstr ""
Expand Down Expand Up @@ -161,6 +161,66 @@ msgstr ""
msgid "Export empty template"
msgstr ""

msgid "{{n}} invalid users found, check in-line errors in table"
msgstr ""

msgid "{{n}} warning(s) while importing file"
msgstr ""

msgid "Importing users"
msgstr ""

msgid "Users imported successfully"
msgstr ""

msgid "User already exists: {{id}}"
msgstr ""

msgid "Add user"
msgstr ""

msgid "Overwrite existing users"
msgstr ""

msgid "Cancel"
msgstr ""

msgid "Error on metadata action"
msgstr ""

msgid "Remove user"
msgstr ""

msgid "Duplicated username: {{username}}"
msgstr ""

msgid "Please provide a username"
msgstr ""

msgid "User already exists"
msgstr ""

msgid "Please provide a valid email"
msgstr ""

msgid "Please provide a password"
msgstr ""

msgid "Password should contain at least one lowercase letter"
msgstr ""

msgid "Password should contain at least one UPPERCASE letter"
msgstr ""

msgid "Password should contain at least one number"
msgstr ""

msgid "Password should have at least one special character"
msgstr ""

msgid "Please provide a valid phone number"
msgstr ""

msgid "Type"
msgstr ""

Expand Down Expand Up @@ -236,30 +296,9 @@ msgstr ""
msgid "Other information"
msgstr ""

msgid "Cancel"
msgstr ""

msgid "Please provide a valid identifier"
msgstr ""

msgid "Please provide a valid email"
msgstr ""

msgid "Password should contain at least one lowercase letter"
msgstr ""

msgid "Password should contain at least one UPPERCASE letter"
msgstr ""

msgid "Password should contain at least one number"
msgstr ""

msgid "Password should have at least one special character"
msgstr ""

msgid "Please provide a valid phone number"
msgstr ""

msgid "Please provide a valid international phone number (+0123456789)"
msgstr ""

Expand Down Expand Up @@ -487,9 +526,6 @@ msgstr ""
msgid "Error saving users"
msgstr ""

msgid "Add user"
msgstr ""

msgid "Delete"
msgstr ""

Expand All @@ -510,3 +546,7 @@ msgstr ""

msgid " and {{overflow}} more..."
msgstr ""

msgctxt "warnings"
msgid "and_n_more"
msgstr ""
101 changes: 74 additions & 27 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-09-24T10:51:56.735Z\n"
"POT-Creation-Date: 2024-10-21T20:05:12.594Z\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 @@ -165,6 +165,66 @@ msgstr ""
msgid "Export empty template"
msgstr ""

msgid "{{n}} invalid users found, check in-line errors in table"
msgstr ""

msgid "{{n}} warning(s) while importing file"
msgstr ""

msgid "Importing users"
msgstr "Importar usuarios"

msgid "Users imported successfully"
msgstr "Usuarios importados correctamente"

msgid "User already exists: {{id}}"
msgstr ""

msgid "Add user"
msgstr "Agregar usuario"

msgid "Overwrite existing users"
msgstr "Actualizar usuarios existentes"

msgid "Cancel"
msgstr "Cancelar"

msgid "Error on metadata action"
msgstr ""

msgid "Remove user"
msgstr "Eliminar usuario"

msgid "Duplicated username: {{username}}"
msgstr "Usuario duplicado: {{user}}"

msgid "Please provide a username"
msgstr "Por favor proporcione un nombre de usuario"

msgid "User already exists"
msgstr ""

msgid "Please provide a valid email"
msgstr "Por favor proporcione un correo electrónico válido"

msgid "Please provide a password"
msgstr "Por favor proporcione una contraseña"

msgid "Password should contain at least one lowercase letter"
msgstr "La contraseña debe contener al menos una letra minúscula"

msgid "Password should contain at least one UPPERCASE letter"
msgstr "La contraseña debe contener al menos una letra MAYÚSCULA"

msgid "Password should contain at least one number"
msgstr "La contraseña debe contener al menos un número"

msgid "Password should have at least one special character"
msgstr "La contraseña debe contener al menos un carácter especial"

msgid "Please provide a valid phone number"
msgstr "Por favor proporcione un número de teléfono válido"

msgid "Type"
msgstr ""

Expand Down Expand Up @@ -240,32 +300,9 @@ msgstr ""
msgid "Other information"
msgstr "Otra información"

msgid "Cancel"
msgstr "Cancelar"

msgid "Please provide a valid identifier"
msgstr "Por favor proporcione un identificador válido"

msgid "Please provide a valid email"
msgstr "Por favor proporcione un correo electrónico válido"

msgid "Password should contain at least one lowercase letter"
msgstr "La contraseña debe contener al menos una letra minúscula"

#, fuzzy
msgid "Password should contain at least one UPPERCASE letter"
msgstr "La contraseña debe contener al menos una letra minúscula"

msgid "Password should contain at least one number"
msgstr "La contraseña debe contener al menos un número"

#, fuzzy
msgid "Password should have at least one special character"
msgstr "La contraseña debe contener al menos una letra minúscula"

msgid "Please provide a valid phone number"
msgstr "Por favor proporcione un número de teléfono válido"

msgid "Please provide a valid international phone number (+0123456789)"
msgstr ""
"Por favor proporcione un número de teléfono internacional válido "
Expand Down Expand Up @@ -499,9 +536,6 @@ msgstr "Gestionar columnas"
msgid "Error saving users"
msgstr "Error al guardar usuarios"

msgid "Add user"
msgstr "Agregar usuario"

msgid "Delete"
msgstr "Eliminar Delete"

Expand All @@ -522,3 +556,16 @@ msgstr "Abrir en Administración de usuarios"

msgid " and {{overflow}} more..."
msgstr " y {{overflow}} más..."

msgctxt "warnings"
msgid "and_n_more"
msgstr ""

#, fuzzy
#~ msgid "close"
#~ msgstr "Cerrar"

#, fuzzy
#~ msgctxt "user"
#~ msgid "remove"
#~ msgstr "Eliminar"
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.2",
"version": "1.6.0",
"license": "GPL-3.0",
"author": "EyeSeeTea team",
"homepage": ".",
Expand Down
2 changes: 2 additions & 0 deletions src/CompositionRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { SaveUserStatusUseCase } from "./domain/usecases/SaveUserStatusUseCase";
import { SaveUsersUseCase } from "./domain/usecases/SaveUsersUseCase";
import { UpdateUserPropUseCase } from "./domain/usecases/UpdateUserPropUseCase";
import { CopyInUserUseCase } from "./domain/usecases/CopyInUserUseCase";
import { ImportUsersUseCase } from "./domain/usecases/ImportUsersUseCase";
import { GetProgramsUseCase } from "./domain/usecases/GetProgramsUseCase";
import { ProgramD2Repository } from "./data/repositories/ProgramD2Repository";
import { getD2APiFromInstance } from "./utils/d2-api";
Expand Down Expand Up @@ -60,6 +61,7 @@ export function getCompositionRoot(instance: Instance) {
saveOrgUnits: new SaveUserOrgUnitUseCase(userRepository),
export: new ExportUsersUseCase(userRepository),
copyInUser: new CopyInUserUseCase(userRepository),
import: new ImportUsersUseCase(userRepository),
}),
metadata: getExecute({
list: new ListMetadataUseCase(metadataRepository),
Expand Down
2 changes: 1 addition & 1 deletion src/data/models/DHIS2Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const NamedRefModel: Codec<NamedRef> = Schema.object({
export const OrgUnitModel = Schema.object({
id: Schema.string,
name: Schema.string,
code: Schema.string,
code: Schema.optionalSafe(Schema.string, ""),
path: Schema.string,
});

Expand Down
24 changes: 15 additions & 9 deletions src/data/repositories/UserD2ApiRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { PaginatedResponse } from "../../domain/entities/PaginatedResponse";
import { Id, NamedRef } from "../../domain/entities/Ref";
import { Stats } from "../../domain/entities/Stats";
import { LocaleCode, User } from "../../domain/entities/User";
import { UserLogic } from "../../domain/entities/UserLogic";
import { ListOptions, UpdateStrategy, UserRepository } from "../../domain/repositories/UserRepository";
import { Maybe } from "../../types/utils";
import { cache } from "../../utils/cache";
Expand Down Expand Up @@ -65,9 +66,9 @@ export class UserD2ApiRepository implements UserRepository {
private getLocaleValueByType(user: User, keyLocale: KeyLocale): string {
switch (keyLocale) {
case DB_LOCALE_KEY:
return user.dbLocale;
return UserLogic.setDefaultLanguage(user.dbLocale);
case UI_LOCALE_KEY:
return user.uiLocale;
return UserLogic.setDefaultLanguage(user.uiLocale);
}
}

Expand Down Expand Up @@ -287,9 +288,10 @@ export class UserD2ApiRepository implements UserRepository {

return this.getLogger().flatMap(logger => {
return this.getFullUsers({ filters: { id: ["in", userIds] } }).flatMap(existingUsers => {
const usersToSend = _(existingUsers)
.map(existingUser => {
const user = users.find(user => user.id === existingUser.id);
const usersToSend = _(userIds)
.map(userId => {
const existingUser = existingUsers.find(user => user.id === userId);
const user = users.find(user => user.id === userId);
if (!user) return undefined;
return this.buildUsersToSave(existingUser, user);
})
Expand Down Expand Up @@ -322,9 +324,9 @@ export class UserD2ApiRepository implements UserRepository {
});
}

private buildUsersToSave(existingUser: ApiUser, user: ApiUser) {
private buildUsersToSave(existingUser: Maybe<ApiUser>, user: ApiUser) {
return {
...existingUser,
...(existingUser || {}),
...user,
// include these fields here and in userCredentials due to a bug in v2.38
userRoles: user.userCredentials.userRoles,
Expand All @@ -333,7 +335,7 @@ export class UserD2ApiRepository implements UserRepository {
openId: user.userCredentials.openId,
password: user.userCredentials.password,
userCredentials: {
...existingUser.userCredentials,
...(existingUser || {}).userCredentials,
...user.userCredentials,
id: user.id,
accountExpiry: user.userCredentials.accountExpiry ? user.userCredentials.accountExpiry : undefined,
Expand Down Expand Up @@ -587,7 +589,11 @@ export class UserD2ApiRepository implements UserRepository {
}

private getApiOrgUnits(orgUnits: OrgUnit[]): ApiD2OrgUnit[] {
return orgUnits.map(orgUnit => ({ ...orgUnit, path: joinPaths(orgUnit) }));
return _.compact(
orgUnits.map(orgUnit => {
return orgUnit.id === "" ? undefined : { ...orgUnit, path: joinPaths(orgUnit) };
})
);
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/domain/entities/ImportUser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export class ImportUser {
static MAX_USERS = 500;
}
17 changes: 17 additions & 0 deletions src/domain/entities/UserLogic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Maybe } from "../../types/utils";
import { Struct } from "./generic/Struct";
import { User } from "./User";

export class UserLogic extends Struct<User>() {
static DEFAULT_PASSWORD = "District123$";

static setDefaultLanguage(language: Maybe<string>): string {
return language || "en";
}

static validateHasRequiredFields(users: User[]): boolean {
return users.every(
user => user.organisationUnits.length > 0 && user.userRoles.length > 0 && user.userGroups.length > 0
);
}
}
Loading

0 comments on commit 5bda3cb

Please sign in to comment.