diff --git a/app/src/main/java/org/jboss/hal/client/deployment/AbstractDeploymentColumn.java b/app/src/main/java/org/jboss/hal/client/deployment/AbstractDeploymentColumn.java index 184e4294cb..321b1e02c2 100644 --- a/app/src/main/java/org/jboss/hal/client/deployment/AbstractDeploymentColumn.java +++ b/app/src/main/java/org/jboss/hal/client/deployment/AbstractDeploymentColumn.java @@ -251,8 +251,11 @@ public AbstractDeploymentColumn(Builder builder, ColumnActionFactory columnAc COLUMN_UPLOAD_ACTION = createColumnAction(columnProps.actionDeploymentId, columnProps.actionDeploymentTitle, column -> uploadDeployment()); - COLUMN_ADD_UNMANAGED_ACTION = createColumnAction(columnProps.actionUnmanagedId, - resources.messages().addResourceTitle(Names.UNMANAGED_DEPLOYMENT), column -> addUnmanaged()); + COLUMN_ADD_UNMANAGED_ACTION = new ColumnAction.Builder(columnProps.actionUnmanagedId) + .title(Names.UNMANAGED_DEPLOYMENT) + .handler(column -> addUnmanaged()) + .constraint(Constraint.executable(DEPLOYMENT_TEMPLATE, ADD)) + .build(); COLUMN_ADD_EMPTY_ACTION = createColumnAction(Ids.DEPLOYMENT_EMPTY_CREATE, resources.constants().deploymentEmptyCreate(), column -> createEmpty()); COLUMN_ADD_FROM_REPOSITORY_ACTION = createColumnAction(Ids.SERVER_GROUP_DEPLOYMENT_ADD, @@ -607,11 +610,11 @@ private String extractDataSources(List dataSourceList) { /* unmanaged deployment */ protected void addUnmanaged() { - Metadata metadata = metadataRegistry.lookup(columnProps.template); + Metadata metadata = metadataRegistry.lookup(DEPLOYMENT_TEMPLATE); AddUnmanagedDialog dialog = new AddUnmanagedDialog(metadata, resources, (name, model) -> { if (model != null) { - String runtimeName = model.get(RUNTIME_NAME).asString(); + String runtimeName = model.hasDefined(RUNTIME_NAME) ? model.get(RUNTIME_NAME).asString() : null; List> tasks = new ArrayList<>(); tasks.add(new DeploymentTasks.AddUnmanagedDeployment(dispatcher, name, model)); if (columnProps.columnType == ColumnType.SERVER_GROUP) { @@ -623,6 +626,12 @@ protected void addUnmanaged() { MessageEvent.fire(eventBus, Message.success(resources.messages() .addResourceSuccess(Names.UNMANAGED_DEPLOYMENT, name))); return null; + }) + .catch_(error -> { + MessageEvent.fire(eventBus, + Message.error(columnProps.getDeploymentErrorText.apply(name), + String.valueOf(error))); + return null; }); } }); @@ -857,6 +866,12 @@ void deploy(Content content) { refresh(CLEAR_SELECTION); MessageEvent.fire(eventBus, Message.success(resources.messages().contentDeployed1(content.getName()))); + }, (__, error) -> { + if (enable) { + ItemMonitor.stopProgress(Ids.content(cnt.getName())); + } + MessageEvent.fire(eventBus, + Message.error(columnProps.getDeploymentErrorText.apply(content.getName()), error)); }); }).show(); } diff --git a/app/src/main/java/org/jboss/hal/client/deployment/DeploymentTasks.java b/app/src/main/java/org/jboss/hal/client/deployment/DeploymentTasks.java index 786e4cdff8..75be926560 100644 --- a/app/src/main/java/org/jboss/hal/client/deployment/DeploymentTasks.java +++ b/app/src/main/java/org/jboss/hal/client/deployment/DeploymentTasks.java @@ -250,7 +250,7 @@ public Promise apply(final FlowContext context) { } } - /** Deploys the specified content to the specified server group. The deployment is not enable on the server group. */ + /** Deploys the specified content to the specified server group. The deployment will be enabled on the server group. */ static final class AddServerGroupDeployment implements Task { private final Environment environment; @@ -282,10 +282,12 @@ public Promise apply(final FlowContext context) { ResourceAddress address = new ResourceAddress() .add(SERVER_GROUP, serverGroup) .add(DEPLOYMENT, name); - Operation operation = new Operation.Builder(address, ADD) - .param(RUNTIME_NAME, runtimeName) - .param(ENABLED, true) - .build(); + Operation.Builder builder = new Operation.Builder(address, ADD) + .param(ENABLED, true); + if (runtimeName != null) { + builder.param(RUNTIME_NAME, runtimeName); + } + Operation operation = builder.build(); return dispatcher.execute(operation).then(__ -> Promise.resolve(context)); } }