Skip to content
Snippets Groups Projects
Commit ab70f0a9 authored by geant-release-service's avatar geant-release-service
Browse files

Finished release 0.36.

parents 7bc2344e dd8990d3
Branches
Tags 0.36
No related merge requests found
......@@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.
## [0.36] - 2023-09-14
- Fixed bug with sorting in user management page
## [0.35] - 2023-09-12
- Added a publisher for the 2023 survey data
- Added report pages for the traffic volume and institution urls
......
This diff is collapsed.
......@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name='compendium-v2',
version="0.35",
version="0.36",
author='GEANT',
author_email='swd@geant.org',
description='Flask and React project for displaying '
......
......@@ -72,13 +72,13 @@ function UserManagementComponent() {
const [users, setUsers] = useState<User[]>([]);
const [nrens, setNrens] = useState<Nren[]>([]);
const { user: loggedInUser } = useContext(userContext);
const [sortFunc, setSortFunc] = useState({ idx: -1, func: defaultSortFunction, asc: true });
const [sortColumn, setSortColumn] = useState({ idx: -1, asc: true });
const [sortedUsers, setSortedUsers] = useState<User[]>([]);
useEffect(() => {
fetchUsers().then((userList) => {
setUsers(userList);
setSortedUsers(userList.sort(sortFunc.func))
setSortedUsers(userList.sort(defaultSortFunction))
});
fetchNrens().then((nrenList) => {
......@@ -115,75 +115,75 @@ function UserManagementComponent() {
}
const setSort = (index) => {
if (index === sortFunc.idx || ((index === 5 || index === 0) && sortFunc.idx === -1)) {
let func;
if (index === sortColumn.idx || ((index === 5 || index === 0) && sortColumn.idx === -1)) {
// reverse sort
if (index === 5 || index === 0) {
// hack not to show the sort icon on column 0 and 5
index = -1
}
setSortFunc({ idx: index, asc: !sortFunc.asc, func: (a, b) => sortFunc.func(b, a) })
setSortColumn({ idx: index, asc: !sortColumn.asc })
setSortedUsers([...sortedUsers.reverse()])
return
}
if (index === 0) {
// user ID is a UUID which is meaningless to sort by, so use default sort function
setSortFunc({ idx: -1, asc: true, func: defaultSortFunction })
func = defaultSortFunction
setSortColumn({ idx: -1, asc: true })
} else if (index === 1) {
// sort by active
setSortFunc({
idx: index, asc: true, func: (a, b) => {
if (a.permissions.active && !b.permissions.active) {
return -1;
} else if (!a.permissions.active && b.permissions.active) {
return 1;
} else {
return 0;
}
func = (a, b) => {
if (a.permissions.active && !b.permissions.active) {
return -1;
} else if (!a.permissions.active && b.permissions.active) {
return 1;
} else {
return 0;
}
})
}
setSortColumn({ idx: index, asc: true })
} else if (index === 2) {
// sort by role
setSortFunc({
idx: index, asc: true, func: (a, b) => {
return a.role.localeCompare(b.role)
}
})
func = (a, b) => {
return a.role.localeCompare(b.role)
}
setSortColumn({ idx: index, asc: true })
} else if (index === 3) {
// sort by email
setSortFunc({
idx: index, asc: true, func: (a, b) => {
return a.email.localeCompare(b.email)
}
})
func = (a, b) => {
return a.email.localeCompare(b.email)
}
setSortColumn({ idx: index, asc: true })
} else if (index === 4) {
// sort by name
setSortFunc({
idx: index, asc: true, func: (a, b) => {
return a.name.localeCompare(b.name)
}
})
func = (a, b) => {
return a.name.localeCompare(b.name)
}
setSortColumn({ idx: index, asc: true })
} else if (index === 5) {
// use the default sort function, OIDC sub has no meaning when sorting
setSortFunc({ idx: -1, asc: true, func: defaultSortFunction })
func = defaultSortFunction
setSortColumn({ idx: -1, asc: true })
} else if (index === 6) {
// sort by NREN
setSortFunc({
idx: index, asc: true, func: (a, b) => {
if (a.nrens.length === 0 && b.nrens.length === 0) {
return 0;
} else if (a.nrens.length === 0) {
return -1;
} else if (b.nrens.length === 0) {
return 1;
} else {
return a.nrens[0].localeCompare(b.nrens[0])
}
func = (a, b) => {
if (a.nrens.length === 0 && b.nrens.length === 0) {
return 0;
} else if (a.nrens.length === 0) {
return -1;
} else if (b.nrens.length === 0) {
return 1;
} else {
return a.nrens[0].localeCompare(b.nrens[0])
}
})
}
setSortColumn({ idx: index, asc: true })
} else {
setSortFunc({ idx: index, asc: true, func: defaultSortFunction })
func = defaultSortFunction
setSortColumn({ idx: index, asc: true })
}
setSortedUsers(users.sort(sortFunc.func))
setSortedUsers(users.sort(func))
}
// build the aria-sort attribute for each column with spreadable objects..
......@@ -191,7 +191,7 @@ function UserManagementComponent() {
const ariaSort = {}
for (let i = 0; i <= 6; i++) {
ariaSort[i] = sortFunc.idx === i ? ({ 'aria-sort': sortFunc.asc ? 'ascending' : 'descending' }) : null
ariaSort[i] = sortColumn.idx === i ? ({ 'aria-sort': sortColumn.asc ? 'ascending' : 'descending' }) : null
}
return (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment