Search in sources :

Example 1 with ColumnActionHandler

use of org.jboss.hal.core.finder.ColumnActionHandler in project console by hal.

the class AssignmentColumn method columnActionHandler.

private ColumnActionHandler<Assignment> columnActionHandler(Role role, boolean include) {
    return column -> {
        Principal principal = findPrincipal(getFinder().getContext().getPath());
        if (principal != null) {
            series(new FlowContext(progress.get()), new CheckRoleMapping(dispatcher, role), new AddRoleMapping(dispatcher, role, status -> status == 404), new AddAssignment(dispatcher, role, principal, include)).subscribe(new SuccessfulOutcome<FlowContext>(eventBus, resources) {

                @Override
                public void onSuccess(FlowContext context) {
                    String type = resources.constants().role();
                    SafeHtml message = include ? resources.messages().assignmentIncludeSuccess(type, role.getName()) : resources.messages().assignmentExcludeSuccess(type, role.getName());
                    MessageEvent.fire(eventBus, Message.success(message));
                    accessControl.reload(() -> {
                        refresh(RefreshMode.RESTORE_SELECTION);
                        if (isCurrentUser(principal)) {
                            eventBus.fireEvent(new UserChangedEvent());
                        }
                    });
                }
            });
        }
    };
}
Also used : ColumnActionHandler(org.jboss.hal.core.finder.ColumnActionHandler) Provider(javax.inject.Provider) AsyncColumn(org.jboss.hal.spi.AsyncColumn) ItemActionFactory(org.jboss.hal.core.finder.ItemActionFactory) MessageEvent(org.jboss.hal.spi.MessageEvent) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) ColumnAction(org.jboss.hal.core.finder.ColumnAction) ItemAction(org.jboss.hal.core.finder.ItemAction) ItemDisplay(org.jboss.hal.core.finder.ItemDisplay) FinderSegment(org.jboss.hal.core.finder.FinderSegment) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) UserChangedEvent(org.jboss.hal.config.UserChangedEvent) FlowContext(org.jboss.hal.flow.FlowContext) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Inject(javax.inject.Inject) AddRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.AddRoleMapping) Progress(org.jboss.hal.flow.Progress) HTMLElement(elemental2.dom.HTMLElement) Message(org.jboss.hal.spi.Message) FinderColumn(org.jboss.hal.core.finder.FinderColumn) User(org.jboss.hal.config.User) Collectors.toSet(java.util.stream.Collectors.toSet) CheckRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.CheckRoleMapping) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) INCLUDE_TEMPLATE(org.jboss.hal.client.accesscontrol.AddressTemplates.INCLUDE_TEMPLATE) EXCLUDE_TEMPLATE(org.jboss.hal.client.accesscontrol.AddressTemplates.EXCLUDE_TEMPLATE) REMOVE(org.jboss.hal.dmr.ModelDescriptionConstants.REMOVE) Set(java.util.Set) EventBus(com.google.web.bindery.event.shared.EventBus) AddAssignment(org.jboss.hal.client.accesscontrol.AccessControlTasks.AddAssignment) FinderPath(org.jboss.hal.core.finder.FinderPath) Sets(com.google.common.collect.Sets) List(java.util.List) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Collectors.toList(java.util.stream.Collectors.toList) Resources(org.jboss.hal.resources.Resources) Flow.series(org.jboss.hal.flow.Flow.series) Role(org.jboss.hal.config.Role) Finder(org.jboss.hal.core.finder.Finder) Footer(org.jboss.hal.spi.Footer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Elements.span(org.jboss.gwt.elemento.core.Elements.span) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) UserChangedEvent(org.jboss.hal.config.UserChangedEvent) AddRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.AddRoleMapping) AddAssignment(org.jboss.hal.client.accesscontrol.AccessControlTasks.AddAssignment) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) FlowContext(org.jboss.hal.flow.FlowContext) CheckRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.CheckRoleMapping)

Example 2 with ColumnActionHandler

use of org.jboss.hal.core.finder.ColumnActionHandler in project console by hal.

the class MembershipColumn method columnActionHandler.

private ColumnActionHandler<Assignment> columnActionHandler(Principal principal, boolean include) {
    return column -> {
        Role role = findRole(getFinder().getContext().getPath());
        if (role != null) {
            series(new FlowContext(progress.get()), new CheckRoleMapping(dispatcher, role), new AddRoleMapping(dispatcher, role, status -> status == 404), new AddAssignment(dispatcher, role, principal, include)).subscribe(new org.jboss.hal.core.SuccessfulOutcome<FlowContext>(eventBus, resources) {

                @Override
                public void onSuccess(FlowContext context) {
                    String type = principal.getType() == Principal.Type.USER ? resources.constants().user() : resources.constants().group();
                    SafeHtml message = include ? resources.messages().assignmentIncludeSuccess(type, principal.getName()) : resources.messages().assignmentExcludeSuccess(type, principal.getName());
                    MessageEvent.fire(eventBus, Message.success(message));
                    accessControl.reload(() -> {
                        refresh(RefreshMode.RESTORE_SELECTION);
                        if (isCurrentUser(principal)) {
                            eventBus.fireEvent(new UserChangedEvent());
                        }
                    });
                }
            });
        }
    };
}
Also used : ColumnActionHandler(org.jboss.hal.core.finder.ColumnActionHandler) Provider(javax.inject.Provider) AsyncColumn(org.jboss.hal.spi.AsyncColumn) ItemActionFactory(org.jboss.hal.core.finder.ItemActionFactory) MessageEvent(org.jboss.hal.spi.MessageEvent) ColumnAction(org.jboss.hal.core.finder.ColumnAction) ItemAction(org.jboss.hal.core.finder.ItemAction) ItemDisplay(org.jboss.hal.core.finder.ItemDisplay) FinderSegment(org.jboss.hal.core.finder.FinderSegment) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) UserChangedEvent(org.jboss.hal.config.UserChangedEvent) FlowContext(org.jboss.hal.flow.FlowContext) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Inject(javax.inject.Inject) AddRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.AddRoleMapping) Progress(org.jboss.hal.flow.Progress) HTMLElement(elemental2.dom.HTMLElement) Message(org.jboss.hal.spi.Message) FinderColumn(org.jboss.hal.core.finder.FinderColumn) User(org.jboss.hal.config.User) Comparator.comparing(java.util.Comparator.comparing) Collectors.toSet(java.util.stream.Collectors.toSet) CheckRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.CheckRoleMapping) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) INCLUDE_TEMPLATE(org.jboss.hal.client.accesscontrol.AddressTemplates.INCLUDE_TEMPLATE) EXCLUDE_TEMPLATE(org.jboss.hal.client.accesscontrol.AddressTemplates.EXCLUDE_TEMPLATE) REMOVE(org.jboss.hal.dmr.ModelDescriptionConstants.REMOVE) Set(java.util.Set) EventBus(com.google.web.bindery.event.shared.EventBus) AddAssignment(org.jboss.hal.client.accesscontrol.AccessControlTasks.AddAssignment) FinderPath(org.jboss.hal.core.finder.FinderPath) Sets(com.google.common.collect.Sets) List(java.util.List) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Collectors.toList(java.util.stream.Collectors.toList) Resources(org.jboss.hal.resources.Resources) Flow.series(org.jboss.hal.flow.Flow.series) Role(org.jboss.hal.config.Role) Finder(org.jboss.hal.core.finder.Finder) Footer(org.jboss.hal.spi.Footer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Elements.span(org.jboss.gwt.elemento.core.Elements.span) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) Role(org.jboss.hal.config.Role) UserChangedEvent(org.jboss.hal.config.UserChangedEvent) AddRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.AddRoleMapping) AddAssignment(org.jboss.hal.client.accesscontrol.AccessControlTasks.AddAssignment) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) FlowContext(org.jboss.hal.flow.FlowContext) CheckRoleMapping(org.jboss.hal.client.accesscontrol.AccessControlTasks.CheckRoleMapping)

Aggregations

Sets (com.google.common.collect.Sets)2 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)2 EventBus (com.google.web.bindery.event.shared.EventBus)2 HTMLElement (elemental2.dom.HTMLElement)2 ArrayList (java.util.ArrayList)2 Collections.singletonList (java.util.Collections.singletonList)2 List (java.util.List)2 Set (java.util.Set)2 Collectors.toList (java.util.stream.Collectors.toList)2 Collectors.toSet (java.util.stream.Collectors.toSet)2 Inject (javax.inject.Inject)2 Provider (javax.inject.Provider)2 Elements.span (org.jboss.gwt.elemento.core.Elements.span)2 AddAssignment (org.jboss.hal.client.accesscontrol.AccessControlTasks.AddAssignment)2 AddRoleMapping (org.jboss.hal.client.accesscontrol.AccessControlTasks.AddRoleMapping)2 CheckRoleMapping (org.jboss.hal.client.accesscontrol.AccessControlTasks.CheckRoleMapping)2 EXCLUDE_TEMPLATE (org.jboss.hal.client.accesscontrol.AddressTemplates.EXCLUDE_TEMPLATE)2 INCLUDE_TEMPLATE (org.jboss.hal.client.accesscontrol.AddressTemplates.INCLUDE_TEMPLATE)2 Role (org.jboss.hal.config.Role)2 User (org.jboss.hal.config.User)2