Merge pull request #3711 from akhilmhdh/feat/sort-access-control

feat: added sort for roles in both user and identity details view
This commit is contained in:
Maidul Islam
2025-06-03 12:59:21 -04:00
committed by GitHub
2 changed files with 19 additions and 3 deletions

View File

@@ -412,7 +412,15 @@ export const identityProjectDALFactory = (db: TDbClient) => {
}
]
});
return members;
return members.map((el) => ({
...el,
roles: el.roles.sort((a, b) => {
const roleA = (a.customRoleName || a.role).toLowerCase();
const roleB = (b.customRoleName || b.role).toLowerCase();
return roleA.localeCompare(roleB);
})
}));
} catch (error) {
throw new DatabaseError({ error, name: "FindByProjectId" });
}

View File

@@ -92,7 +92,8 @@ export const projectMembershipDALFactory = (db: TDbClient) => {
db.ref("temporaryAccessEndTime").withSchema(TableName.ProjectUserMembershipRole),
db.ref("name").as("projectName").withSchema(TableName.Project)
)
.where({ isGhost: false });
.where({ isGhost: false })
.orderBy(`${TableName.Users}.username` as "username");
const members = sqlNestRelationships({
data: docs,
@@ -149,7 +150,14 @@ export const projectMembershipDALFactory = (db: TDbClient) => {
}
]
});
return members;
return members.map((el) => ({
...el,
roles: el.roles.sort((a, b) => {
const roleA = (a.customRoleName || a.role).toLowerCase();
const roleB = (b.customRoleName || b.role).toLowerCase();
return roleA.localeCompare(roleB);
})
}));
} catch (error) {
throw new DatabaseError({ error, name: "Find all project members" });
}