use of org.jboss.hal.meta.security.Constraint in project console by hal.
the class SecurityManagerView method createPermissionUI.
private void createPermissionUI(Permission permission) {
Metadata metadata = metadataRegistry.lookup(DEPLOYMENT_PERMISSIONS_TEMPLATE).forComplexAttribute(permission.resource);
Constraint constraint = Constraint.writable(DEPLOYMENT_PERMISSIONS_TEMPLATE, permission.resource);
EmptyState emptyState = new EmptyState.Builder(Ids.DEPLOYMENT_PERMISSIONS_EMPTY, Names.DEPLOYMENT_PERMISSIONS).description(resources.messages().noDeploymentPermissions()).primaryAction(resources.constants().add(), () -> presenter.addDeploymentPermissions(), constraint).build();
emptyState.element().classList.add(marginTopLarge);
emptyStates.put(permission, emptyState);
Table<ModelNode> table = new ModelNodeTable.Builder<>(Ids.build(permission.baseId, Ids.TABLE), metadata).button(resources.constants().add(), t -> presenter.addPermission(permission), constraint).button(resources.constants().remove(), t -> presenter.removePermission(permission, t.selectedRow().get(HAL_INDEX).asInt()), Scope.SELECTED, constraint).column(CLASS).build();
tables.put(permission, table);
registerAttachable(table);
Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(permission.baseId, Ids.FORM), metadata).onSave((f, changedValues) -> presenter.savePermission(permission, f.getModel().get(HAL_INDEX).asInt(), changedValues)).build();
forms.put(permission, form);
registerAttachable(form);
HTMLElement masterDetail;
HTMLElement section = section().add(emptyState).add(masterDetail = div().add(h(1).textContent(permission.type)).add(p().textContent(metadata.getDescription().getDescription())).add(table).add(form).element()).element();
masterDetails.put(permission, masterDetail);
navigation.addPrimary(Ids.build(permission.baseId, Ids.ITEM), permission.type, permission.icon, section);
}
use of org.jboss.hal.meta.security.Constraint in project console by hal.
the class GenericOptionsBuilder method options.
@SuppressWarnings({ "HardCodedStringLiteral", "unchecked" })
public Options<T> options() {
if (options != null) {
return options;
}
validate();
options = new Options<>();
options.buttonConstraints = new HashMap<>();
if (!buttons.isEmpty()) {
// override defaults from patternfly.js:77
options.dom = "<'dataTables_header' f B i>" + "<'table-responsive' t>" + "<'dataTables_footer' p>";
options.buttons = new Api.Buttons<>();
options.buttons.dom = new Api.Buttons.Dom();
options.buttons.dom.container = new Api.Buttons.Dom.Factory();
options.buttons.dom.container.tag = "div";
options.buttons.dom.container.className = pullRight + " " + btnGroup + " " + halTableButtons;
options.buttons.dom.button = new Api.Buttons.Dom.Factory();
options.buttons.dom.button.tag = "button";
options.buttons.dom.button.className = btn + " " + btnDefault;
options.buttons.buttons = buttons.toArray(new Api.Button[0]);
for (int i = 0; i < options.buttons.buttons.length; i++) {
if (options.buttons.buttons[i].constraint != null) {
options.buttonConstraints.put(i, options.buttons.buttons[i].constraint);
}
}
}
options.columns = columns.toArray(new Column[0]);
options.keys = keys;
options.paging = paging;
options.pageLength = pageLength;
options.searching = searching;
options.select = select;
// custom options
options.columnActionHandler = columnActionHandler;
return options;
}
Aggregations