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());
}
});
}
});
}
};
}
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());
}
});
}
});
}
};
}
Aggregations