-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable export action when no valueContext is available (no item sele…
…cted)
- Loading branch information
eschleb
committed
Apr 17, 2024
1 parent
837946d
commit 4b269db
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/com/namics/oss/magnolia/appbuilder/action/rule/HasValueContextRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.namics.oss.magnolia.appbuilder.action.rule; | ||
|
||
import info.magnolia.ui.ValueContext; | ||
import info.magnolia.ui.api.availability.AvailabilityRule; | ||
import info.magnolia.ui.api.availability.AvailabilityRuleType; | ||
import info.magnolia.ui.api.availability.ConfiguredAvailabilityRuleDefinition; | ||
|
||
import java.util.Collection; | ||
|
||
import javax.inject.Inject; | ||
|
||
public class HasValueContextRule implements AvailabilityRule { | ||
private final ValueContext<?> valueContext; | ||
|
||
@Inject | ||
public HasValueContextRule(final ValueContext<?> valueContext) { | ||
this.valueContext = valueContext; | ||
} | ||
|
||
@Override | ||
public boolean isAvailable(final Collection<?> itemIds) { | ||
return valueContext.getSingle().isPresent(); | ||
} | ||
|
||
@AvailabilityRuleType("hasValueContextRule") | ||
public static class Definition extends ConfiguredAvailabilityRuleDefinition { | ||
public Definition() { | ||
setImplementationClass(HasValueContextRule.class); | ||
} | ||
} | ||
} |