Skip to content

Commit

Permalink
Allow omitting optional consumable resources in Vidarr SubmitAction
Browse files Browse the repository at this point in the history
This replaces the temporary hack introduced in
02304ef with a permanent solution.
  • Loading branch information
apmasell authored and avarsava committed Feb 8, 2024
1 parent 9e4001d commit 805bf7a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions changes/change_vidarr_resource.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Allow optional consumable resources to be omitted in Vidarr submit actions
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import ca.on.oicr.gsi.shesmu.plugin.json.PackJsonObject;
import ca.on.oicr.gsi.shesmu.plugin.types.Imyhat;
import ca.on.oicr.gsi.shesmu.plugin.types.Imyhat.ObjectImyhat;
import ca.on.oicr.gsi.shesmu.plugin.types.Imyhat.OptionalImyhat;
import ca.on.oicr.gsi.status.SectionRenderer;
import ca.on.oicr.gsi.vidarr.BasicType;
import ca.on.oicr.gsi.vidarr.BasicType.Visitor;
Expand Down Expand Up @@ -307,13 +308,14 @@ public void store(SubmitAction action, Object value) {
if (target.getValue().getConsumableResources() != null
&& !target.getValue().getConsumableResources().isEmpty()) {
for (final var resource : target.getValue().getConsumableResources().entrySet()) {
final var type = resource.getValue().apply(SIMPLE_TO_IMYHAT);
targetParameters.add(
new CustomActionParameter<>(
sanitise("resource_" + resource.getKey()),
// temporary workaround for making 'priority' resource optional
// TODO: update this when releasing a Vidarr version with GP-4042 enabled
("priority".equals(resource.getKey()) ? false : true),
resource.getValue().apply(SIMPLE_TO_IMYHAT)) {
// Optional resources can be absent from the request and Vidarr will
// behave properly, so we can safely make them not required
!(type instanceof OptionalImyhat),
type) {
private final String name = resource.getKey();

@Override
Expand Down

0 comments on commit 805bf7a

Please sign in to comment.