Skip to content

Commit

Permalink
Merge branch 'microsoft:develop' into java-projects-native-deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciusfcf authored Jun 19, 2023
2 parents 6e4af39 + 570830e commit 7bc506a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void deploy(@Nonnull DeployType deployType, @Nonnull File targetFile,
@Nullable
public KuduDeploymentResult pushDeploy(@Nonnull DeployType deployType, @Nonnull File targetFile,
@Nullable DeployOptions deployOptions) {
final WebSiteBase remote = this.getRemote();
final WebSiteBase remote = this.getFullRemote();
if (remote instanceof SupportsOneDeploy) {
final com.azure.resourcemanager.appservice.models.DeployOptions options =
deployOptions == null ? null : AppServiceUtils.toDeployOptions(deployOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import com.microsoft.azure.toolkit.lib.common.bundle.AzureString;
import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException;
import com.microsoft.azure.toolkit.lib.common.model.AbstractAzResource;
import com.microsoft.azure.toolkit.lib.common.model.AbstractAzResourceModule;
import com.microsoft.azure.toolkit.lib.common.model.AzResource;
import com.microsoft.azure.toolkit.lib.common.model.AzResourceModule;
import com.microsoft.azure.toolkit.lib.common.model.Emulatable;
Expand Down Expand Up @@ -50,11 +48,13 @@ public class Action<D> extends OperationBase implements Cloneable {
public static final Action.Id<Object> OPEN_AZURE_SETTINGS = Action.Id.of("user/common.open_azure_settings");
public static final Action.Id<Object> DISABLE_AUTH_CACHE = Action.Id.of("user/account.disable_auth_cache");

public static final String COMMON = "common";

@Nonnull
private final Id<D> id;
@Nonnull
private Predicate<D> enableWhen = o -> true;
private Predicate<Object> visibleWhen = o -> true;
private BiPredicate<Object, String> visibleWhen = (o, place) -> true;
private Function<D, String> iconProvider;
private Function<D, String> labelProvider;
private Function<D, AzureString> titleProvider;
Expand All @@ -64,6 +64,7 @@ public class Action<D> extends OperationBase implements Cloneable {
private List<Function<D, String>> titleParamProviders = new ArrayList<>();

private D source;
private String place;
@Setter

private Predicate<D> authRequiredProvider = Action::isAuthRequiredForAzureResource;
Expand All @@ -87,11 +88,15 @@ public String getId() {
return this.id.id;
}

@Nonnull
public IView.Label getView(D s) {
return getView(s, COMMON);
}

@Nonnull
public IView.Label getView(D s, final String place) {
final D source = Optional.ofNullable(this.source).orElse(s);
try {
final boolean visible = this.visibleWhen.test(source);
final boolean visible = this.visibleWhen.test(source, place);
if (visible) {
final String label = this.labelProvider.apply(source);
final String icon = Optional.ofNullable(this.iconProvider).map(p -> p.apply(source)).orElse(null);
Expand All @@ -110,7 +115,7 @@ public IView.Label getView(D s) {
@SuppressWarnings("unchecked")
public BiConsumer<D, Object> getHandler(D s, Object e) {
final D source = Optional.ofNullable(this.source).orElse(s);
if (!this.visibleWhen.test(source) && !this.enableWhen.test(source)) {
if (!this.visibleWhen.test(source, COMMON) && !this.enableWhen.test(source)) {
return null;
}
for (int i = this.handlers.size() - 1; i >= 0; i--) {
Expand Down Expand Up @@ -203,6 +208,11 @@ public Action<D> enableWhen(@Nonnull Predicate<D> enableWhen) {
}

public Action<D> visibleWhen(@Nonnull Predicate<Object> visibleWhen) {
this.visibleWhen = (object, ignore) -> visibleWhen.test(object);
return this;
}

public Action<D> visibleWhen(@Nonnull BiPredicate<Object, String> visibleWhen) {
this.visibleWhen = visibleWhen;
return this;
}
Expand Down

0 comments on commit 7bc506a

Please sign in to comment.