Skip to content

Commit

Permalink
Merge branch 'feature/invitation-pagination'
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Dec 13, 2024
2 parents 68db4eb + 166878d commit 7c19c3f
Show file tree
Hide file tree
Showing 25 changed files with 507 additions and 246 deletions.
4 changes: 2 additions & 2 deletions client/src/__tests__/utils/UserRole.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ test("Allowed to delete Invitation", () => {
role: {id: "2", applicationUsages: applicationUsagesForManageId("11")}
};
const user = {userRoles: [mail, research]}
const invitation = {intendedAuthority: AUTHORITIES.GUEST, roles: [mail, research]};
const invitation = {intended_authority: AUTHORITIES.GUEST, roles: [mail, research]};
expect(allowedToDeleteInvitation(user, invitation)).toBeTruthy();

invitation.intendedAuthority = AUTHORITIES.INVITER;
invitation.intended_authority = AUTHORITIES.INVITER;
expect(allowedToDeleteInvitation(user, invitation)).toBeFalsy();
});

Expand Down
8 changes: 8 additions & 0 deletions client/src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ export function allInvitations() {
return fetchJson(`/api/v1/invitations/all`, {}, {}, false);
}

export function searchInvitations(roleId, pagination = {}) {
if (roleId) {
pagination.roleId = roleId;
}
const queryPart = paginationQueryParams(pagination, {})
return fetchJson(`/api/v1/invitations/search?${queryPart}`, {}, {}, false);
}

//Manage
export function allProviders() {
return fetchJson("/api/v1/manage/providers");
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Entities.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export const Entities = ({
</tbody>
</table>
</div>}
{(!hasEntities && !initial && !customEmptySearch && !loading && !hideTitle) &&
{(!hasEntities && !initial && !customEmptySearch && !loading && !hideTitle && !busy) &&
<p className="no-entities">{customNoEntities || I18n.t(`${modelName}.noEntities`)}</p>}
<Pagination currentPage={page}
onChange={nbr => {
Expand Down
7 changes: 2 additions & 5 deletions client/src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,7 @@ const en = {
delete: "Remove"
},
invitations: {
found: "{{count}} {{plural}} found",
foundWithStatus: "{{count}} {{status}} {{plural}}",
singleInvitation: "invitation",
multipleInvitations: "invitations",
title: "Invitations",
searchPlaceHolder: "Search for invitation...",
noResults: "No invitation where found",
inviter: "Invited by",
Expand All @@ -254,7 +251,7 @@ const en = {
roles: "Roles",
inviterRoles: "Select the roles for the new invitation",
rolesPlaceHolder: "Choose one or more roles",
expiryDate: "Invite valid till",
expiryDate: "Valid till",
acceptedAt: "Date accepted",
roleExpiryDate: "Role expiry date",
roleExpiryDateQuestion: "Set a custom role expiration period",
Expand Down
7 changes: 2 additions & 5 deletions client/src/locale/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,7 @@ const nl = {
delete: "Verwijder"
},
invitations: {
found: "{{count}} {{plural}} gevonden",
foundWithStatus: "{{count}} {{status}} {{plural}}",
singleInvitation: "uitnodiging",
multipleInvitations: "uitnodigingen",
title: "Uitnodigingen",
searchPlaceHolder: "Zoek uitnodiging...",
noResults: "Geen uitnodigingen gevonden",
inviter: "Uitgenodigd door",
Expand All @@ -254,7 +251,7 @@ const nl = {
roles: "Rollen",
inviterRoles: "Selecteer de rollen voor de nieuwe uitnodiging",
rolesPlaceHolder: "Kies een of meer rollen",
expiryDate: "Uitnodiging geldig tot",
expiryDate: "Geldig tot",
acceptedAt: "Datum geaccepteeerd",
roleExpiryDate: "Verloopdatum rol",
roleExpiryDateQuestion: "Zet een specifieke verloopdatum voor de rol",
Expand Down
13 changes: 5 additions & 8 deletions client/src/pages/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {rolesPerApplicationManageId} from "../api";
import I18n from "../locale/I18n";
import "./Application.scss";
import {ReactComponent as WebsiteIcon} from "../icons/network-information.svg";
import {Chip, Loader} from "@surfnet/sds";
import {Chip} from "@surfnet/sds";
import {useNavigate, useParams} from "react-router-dom";
import {useAppStore} from "../stores/AppStore";
import {UnitHeader} from "../components/UnitHeader";
Expand All @@ -18,7 +18,7 @@ export const Application = () => {
const {manageId} = useParams();
const navigate = useNavigate();
const {user} = useAppStore(state => state);
const [roles, setRoles] = useState({});
const [roles, setRoles] = useState([]);
const [application, setApplication] = useState({});
const [loading, setLoading] = useState(true);

Expand All @@ -40,7 +40,6 @@ export const Application = () => {
app.name = I18n.locale === "en" ? app["name:en"] || app["name:nl"] : app["name:nl"] || app["name:en"];
app.description = I18n.locale === "en" ? app["OrganizationName:en"] || app["OrganizationName:nl"] : app["OrganizationName:nl"] || app["OrganizationName:en"];
setApplication(app);
setLoading(false);
const paths = [
{path: "/home", value: I18n.t("tabs.home")},
{path: "/home/applications", value: I18n.t("tabs.applications")},
Expand All @@ -49,17 +48,13 @@ export const Application = () => {
useAppStore.setState({
breadcrumbPath: paths
});
// setTimeout(() => setLoading(false), 40);
setLoading(false);
})
.catch(() => navigate("/"))
},
[user]); // eslint-disable-line react-hooks/exhaustive-deps


if (loading) {
return <Loader/>
}

const openRole = (e, role) => {
const path = `/roles/${role.id}`
if (e.metaKey || e.ctrlKey) {
Expand Down Expand Up @@ -128,6 +123,8 @@ export const Application = () => {
modelName="applicationRoles"
title={I18n.t("applications.title", {nbr: roles.length})}
showNew={true}
busy={loading}
loading={false}
newLabel={I18n.t("applications.new")}
newEntityFunc={() => navigate("/role/new", {state: application.id})}
defaultSort="name"
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/System.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const System = () => {
name="invitations"
label={I18n.t("tabs.invitations")}
>
<Invitations standAlone={true} systemView={true}/>
<Invitations systemView={true}/>
</Page>,
<Page key="unknownRoles"
name="unknownRoles"
Expand Down
4 changes: 1 addition & 3 deletions client/src/tabs/ApplicationUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ export const ApplicationUsers = () => {
results.forEach(user => user.roleSummaries
.sort((r1, r2) => (r1.endDate || Number.MAX_VALUE) - (r2.endDate || Number.MAX_VALUE)));
setUsers(results);
//we need to avoid flickerings
setTimeout(() => setSearching(false), 75);
setTotalElements(page.totalElements);
setSearching(false);
setTotalElements(page.totalElements);
});
}, [paginationQueryParams]);

Expand Down
3 changes: 1 addition & 2 deletions client/src/tabs/Applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ const Applications = () => {
const mergedApps = mergeProvidersProvisioningsRoles(
res[0].providers, res[0].provisionings, res[1].content);
setApplications(mergedApps);
//we need to avoid flickerings
setTimeout(() => setSearching(false), 75);
setSearching(false);
})
},
[]) // eslint-disable-line react-hooks/exhaustive-deps
Expand Down
Loading

0 comments on commit 7c19c3f

Please sign in to comment.