Search in sources :

Example 1 with LUMO_TERTIARY

use of com.vaadin.flow.component.button.ButtonVariant.LUMO_TERTIARY in project furms by unity-idm.

the class UserContextMenuFactory method get.

public Component get(UserGridItem gridItem, Runnable gridReloader, Supplier<Long> gridSizeLoader) {
    GridActionMenu contextMenu = new GridActionMenu();
    if (removeUserAction != null && gridItem.getStatus().equals(UserUIStatus.ENABLED)) {
        Button button = new Button(getTranslation("component.administrators.context.menu.remove"), MINUS_CIRCLE.create());
        button.addThemeVariants(LUMO_TERTIARY);
        contextMenu.addItem(button, event -> {
            if (gridItem.getId().isPresent() && gridItem.getId().get().equals(currentUserId))
                doRemoveYourself(gridReloader, gridSizeLoader);
            else
                doRemoveItemAction(gridItem, gridReloader, gridSizeLoader);
        });
    }
    if (resendInvitationAction != null && gridItem.getStatus().equals(UserUIStatus.AWAITS_APPROVAL)) {
        Button button = new Button(getTranslation("component.administrators.context.menu.resend.invitation"), PAPERPLANE.create());
        button.addThemeVariants(LUMO_TERTIARY);
        contextMenu.addItem(button, event -> resendInvitationAction.accept(gridItem.getInvitationId().get()));
    }
    if (removeInvitationAction != null && gridItem.getStatus().equals(UserUIStatus.AWAITS_APPROVAL)) {
        Button button = new Button(getTranslation("component.administrators.context.menu.remove.invitation"), TRASH.create());
        button.addThemeVariants(LUMO_TERTIARY);
        contextMenu.addItem(button, event -> removeInvitationAction.accept(gridItem.getInvitationId().get()));
    }
    customContextMenuItems.stream().filter(item -> item.confirmer.test(gridItem)).forEach(item -> contextMenu.addItem(item.buttonProvider.apply(gridItem), event -> item.menuButtonHandler.accept(gridItem)));
    if (contextMenu.getChildren().count() == 0)
        return new Div();
    return contextMenu.getTarget();
}
Also used : VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) VaadinExceptionHandler.getResultOrException(io.imunity.furms.ui.utils.VaadinExceptionHandler.getResultOrException) VaadinTranslator.getTranslation(io.imunity.furms.ui.utils.VaadinTranslator.getTranslation) PAPERPLANE(com.vaadin.flow.component.icon.VaadinIcon.PAPERPLANE) PersistentId(io.imunity.furms.domain.users.PersistentId) Component(com.vaadin.flow.component.Component) LandingPageView(io.imunity.furms.ui.views.landing.LandingPageView) TRASH(com.vaadin.flow.component.icon.VaadinIcon.TRASH) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) Predicate(java.util.function.Predicate) Div(com.vaadin.flow.component.html.Div) FurmsDialog(io.imunity.furms.ui.components.FurmsDialog) MenuButton(io.imunity.furms.ui.components.MenuButton) GridActionMenu(io.imunity.furms.ui.components.GridActionMenu) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) Button(com.vaadin.flow.component.button.Button) List(java.util.List) LUMO_TERTIARY(com.vaadin.flow.component.button.ButtonVariant.LUMO_TERTIARY) InvitationId(io.imunity.furms.domain.invitations.InvitationId) UI(com.vaadin.flow.component.UI) MINUS_CIRCLE(com.vaadin.flow.component.icon.VaadinIcon.MINUS_CIRCLE) Div(com.vaadin.flow.component.html.Div) GridActionMenu(io.imunity.furms.ui.components.GridActionMenu) MenuButton(io.imunity.furms.ui.components.MenuButton) Button(com.vaadin.flow.component.button.Button)

Aggregations

Component (com.vaadin.flow.component.Component)1 UI (com.vaadin.flow.component.UI)1 Button (com.vaadin.flow.component.button.Button)1 LUMO_TERTIARY (com.vaadin.flow.component.button.ButtonVariant.LUMO_TERTIARY)1 Div (com.vaadin.flow.component.html.Div)1 MINUS_CIRCLE (com.vaadin.flow.component.icon.VaadinIcon.MINUS_CIRCLE)1 PAPERPLANE (com.vaadin.flow.component.icon.VaadinIcon.PAPERPLANE)1 TRASH (com.vaadin.flow.component.icon.VaadinIcon.TRASH)1 InvitationId (io.imunity.furms.domain.invitations.InvitationId)1 PersistentId (io.imunity.furms.domain.users.PersistentId)1 FurmsDialog (io.imunity.furms.ui.components.FurmsDialog)1 GridActionMenu (io.imunity.furms.ui.components.GridActionMenu)1 MenuButton (io.imunity.furms.ui.components.MenuButton)1 NotificationUtils.showErrorNotification (io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification)1 VaadinExceptionHandler.getResultOrException (io.imunity.furms.ui.utils.VaadinExceptionHandler.getResultOrException)1 VaadinExceptionHandler.handleExceptions (io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions)1 VaadinTranslator.getTranslation (io.imunity.furms.ui.utils.VaadinTranslator.getTranslation)1 LandingPageView (io.imunity.furms.ui.views.landing.LandingPageView)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1