use of com.vaadin.flow.component.icon.VaadinIcon.CLOSE_CIRCLE in project furms by unity-idm.
the class UsersView method loadPageContent.
private void loadPageContent() {
String projectId = getCurrentResourceId();
project = projectService.findById(projectId).orElseThrow(() -> new IllegalStateException("Project not found: " + getCurrentResourceId()));
currentUserId = authzService.getCurrentUserId();
InviteUserComponent inviteUser = new InviteUserComponent(() -> projectService.findAllAdmins(project.getCommunityId(), project.getId()).stream().filter(IS_ELIGIBLE_FOR_PROJECT_MEMBERSHIP).collect(Collectors.toList()), () -> projectService.findAllUsers(project.getCommunityId(), project.getId()));
membershipLayout = new MembershipChangerComponent(getTranslation("view.project-admin.users.button.join"), getTranslation("view.project-admin.users.button.demit"), () -> projectService.isUser(project.getId()));
userService.findById(currentUserId).ifPresent(user -> membershipLayout.setEnabled(IS_ELIGIBLE_FOR_PROJECT_MEMBERSHIP.test(user)));
UserContextMenuFactory userContextMenuFactory = UserContextMenuFactory.builder().withCurrentUserId(currentUserId).allowRemovalOfLastUser().withConfirmRemovalMessageKey("view.project-admin.users.remove.confirm").withConfirmSelfRemovalMessageKey("view.project-admin.users.remove.yourself.confirm").withRemoveInvitationAction(invitationId -> {
projectService.removeInvitation(projectId, invitationId);
gridReload();
}).withResendInvitationAction(invitationId -> {
projectService.resendInvitation(projectId, invitationId);
gridReload();
}).withRemoveUserAction(userId -> {
try {
projectService.removeUser(project.getCommunityId(), project.getId(), userId);
} catch (UserInstallationOnSiteIsNotTerminalException e) {
showErrorNotification(getTranslation("user.currently.de-installing"));
}
}).withPostRemoveUserAction(userId -> {
membershipLayout.loadAppropriateButton();
inviteUser.reload();
}).addCustomContextMenuItem((UserGridItem userGridItem) -> new MenuButton(getTranslation("view.project-admin.users.requested.accept"), CHECK_CIRCLE), userGridItem -> {
try {
projectApplicationsService.accept(projectId, userGridItem.getFenixUserId().get());
showSuccessNotification(getTranslation("view.project-admin.users.application.accept"));
} catch (ApplicationNotExistingException e) {
showErrorNotification(getTranslation("application.already.not.existing"));
}
grid.reloadGrid();
}, userGridItem -> UserUIStatus.ACCESS_REQUESTED.equals(userGridItem.getStatus())).addCustomContextMenuItem((UserGridItem userGridItem) -> new MenuButton(getTranslation("view.project-admin.users.requested.reject"), CLOSE_CIRCLE), userGridItem -> {
try {
projectApplicationsService.remove(projectId, userGridItem.getFenixUserId().get());
showSuccessNotification(getTranslation("view.project-admin.users.application.reject"));
} catch (ApplicationNotExistingException e) {
showErrorNotification(getTranslation("application.already.not.existing"));
}
grid.reloadGrid();
}, userGridItem -> UserUIStatus.ACCESS_REQUESTED.equals(userGridItem.getStatus())).build();
UserGrid.Builder userGrid = UserGrid.defaultInit(userContextMenuFactory);
grid = UsersGridComponent.defaultInit(() -> projectService.findAllUsers(project.getCommunityId(), project.getId()), () -> projectService.findAllUsersInvitations(projectId), () -> projectApplicationsService.findAllApplyingUsers(projectId), userGrid);
membershipLayout.addJoinButtonListener(event -> {
projectService.addUser(project.getCommunityId(), project.getId(), currentUserId);
grid.reloadGrid();
inviteUser.reload();
});
membershipLayout.addDemitButtonListener(event -> {
projectService.removeUser(project.getCommunityId(), project.getId(), currentUserId);
grid.reloadGrid();
inviteUser.reload();
membershipLayout.loadAppropriateButton();
});
inviteUser.addInviteAction(event -> doInviteAction(inviteUser, projectId));
ViewHeaderLayout headerLayout = new ViewHeaderLayout(getTranslation("view.project-admin.users.header", project.getName()), membershipLayout);
getContent().add(headerLayout, inviteUser, grid);
}
use of com.vaadin.flow.component.icon.VaadinIcon.CLOSE_CIRCLE in project furms by unity-idm.
the class InvitationsView method createMainContextMenu.
private Component createMainContextMenu(InviteeService inviteeService, Map<InvitationId, Checkbox> checkboxes) {
GridActionMenu contextMenu = new GridActionMenu();
contextMenu.addItem(new MenuButton(getTranslation("view.user-settings.invitations.main.context-menu.confirm"), CHECK_CIRCLE), event -> {
try {
checkboxes.entrySet().stream().filter(x -> x.getValue().getValue()).forEach(x -> inviteeService.acceptBy(x.getKey()));
} catch (InvitationNotExistingException e) {
showErrorNotification(getTranslation("invitation.already.removed"));
} catch (Exception e) {
LOG.warn("Could not accept Invitations. ", e);
showErrorNotification(getTranslation("base.error.message"));
}
loadGrid();
});
contextMenu.addItem(new MenuButton(getTranslation("view.user-settings.invitations.main.context-menu.reject"), CLOSE_CIRCLE), event -> {
if (checkboxes.entrySet().stream().anyMatch(x -> x.getValue().getValue()))
createMainConfirmDialog(checkboxes).open();
});
return contextMenu.getTarget();
}
Aggregations