Skip to content

Commit

Permalink
fix issue with delegated only execution options
Browse files Browse the repository at this point in the history
  • Loading branch information
ritch committed Jan 7, 2025
1 parent bd739fd commit 3583202
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function TooltipProvider(props: TooltipProps) {
if (!title) return children;
return (
<Tooltip title={title} {...tooltipProps}>
<Box>{children}</Box>
<Box component="span">{children}</Box>
</Tooltip>
);
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import TooltipProvider from "@fiftyone/core/src/plugins/SchemaIO/components/TooltipProvider";
import { Button } from "@mui/material";
import { OperatorExecutionTrigger } from "../OperatorExecutionTrigger";
import React, { useCallback, useMemo } from "react";
import {
ExecutionCallback,
ExecutionErrorCallback,
OperatorExecutorOptions,
} from "../../types-internal";
import {
OperatorExecutionOption,
useOperatorExecutionOptions,
useOperatorExecutor,
usePromptOperatorInput,
} from "../../state";
import {
ExecutionCallback,
ExecutionErrorCallback,
OperatorExecutorOptions,
} from "../../types-internal";
import { OperatorExecutionTrigger } from "../OperatorExecutionTrigger";

/**
* Button which acts as a trigger for opening an `OperatorExecutionMenu`.
Expand Down Expand Up @@ -84,10 +85,23 @@ export const OperatorExecutionButton = ({
[executorOptions, operator, executionParams]
);

const { executionOptions } = useOperatorExecutionOptions({
operatorUri,
onExecute,
});
const { executionOptions, warningMessage, showWarning, isLoading } =
useOperatorExecutionOptions({
operatorUri,
onExecute,
});

if (isLoading) return null;

if (showWarning) {
return (
<TooltipProvider title={warningMessage}>
<Button disabled={true} variant={props.variant}>
{children}
</Button>
</TooltipProvider>
);
}

if (prompt) {
return (
Expand All @@ -107,6 +121,7 @@ export const OperatorExecutionButton = ({
prompt={prompt}
executionParams={executionParams}
onOptionSelected={onOptionSelected}
executionOptions={executionOptions}
disabled={disabled}
>
<Button disabled={disabled} {...props}>
Expand Down
8 changes: 8 additions & 0 deletions app/packages/operators/src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,10 @@ export const useOperatorExecutionOptions = ({
onExecute: (opts: OperatorExecutorOptions) => void;
}): {
executionOptions: OperatorExecutionOption[];
hasOptions: boolean;
warningMessage: React.ReactNode;
showWarning: boolean;
isLoading: boolean;
} => {
const ctx = useExecutionContext(operatorUri);
const { isRemote } = getLocalOrRemoteOperator(operatorUri);
Expand All @@ -434,6 +438,10 @@ export const useOperatorExecutionOptions = ({

return {
executionOptions: submitOptions.options,
hasOptions: submitOptions.hasOptions,
warningMessage: submitOptions.warningMessage,
showWarning: submitOptions.showWarning,
isLoading: execDetails.isLoading,
};
};

Expand Down

0 comments on commit 3583202

Please sign in to comment.