Skip to content

Commit

Permalink
Disable save button when saving or running
Browse files Browse the repository at this point in the history
  • Loading branch information
kcze committed Dec 19, 2024
1 parent ed7c937 commit 7214fbd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion autogpt_platform/frontend/src/components/Flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ const FlowEditor: React.FC<{
requestSaveAndRun,
requestStopRun,
scheduleRunner,
isSaving,
isRunning,
isStopping,
isScheduling,
setIsScheduling,
nodes,
Expand Down Expand Up @@ -679,7 +681,8 @@ const FlowEditor: React.FC<{
botChildren={
<SaveControl
agentMeta={savedAgent}
onSave={(isTemplate) => requestSave(isTemplate ?? false)}
canSave={!isSaving && !isRunning && !isStopping}
onSave={() => requestSave()}
agentDescription={agentDescription}
onDescriptionChange={setAgentDescription}
agentName={agentName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface SaveControlProps {
agentMeta: GraphMeta | null;
agentName: string;
agentDescription: string;
canSave: boolean;
onSave: () => void;
onNameChange: (name: string) => void;
onDescriptionChange: (description: string) => void;
Expand All @@ -31,13 +32,17 @@ interface SaveControlProps {
* A SaveControl component to be used within the ControlPanel. It allows the user to save the agent.
* @param {Object} SaveControlProps - The properties of the SaveControl component.
* @param {GraphMeta | null} SaveControlProps.agentMeta - The agent's metadata, or null if creating a new agent.
* @param {string} SaveControlProps.agentName - The agent's name.
* @param {string} SaveControlProps.agentDescription - The agent's description.
* @param {boolean} SaveControlProps.canSave - Whether the button to save the agent should be enabled.
* @param {() => void} SaveControlProps.onSave - Function to save the agent.
* @param {(name: string) => void} SaveControlProps.onNameChange - Function to handle name changes.
* @param {(description: string) => void} SaveControlProps.onDescriptionChange - Function to handle description changes.
* @returns The SaveControl component.
*/
export const SaveControl = ({
agentMeta,
canSave,
onSave,
agentName,
onNameChange,
Expand Down Expand Up @@ -152,6 +157,7 @@ export const SaveControl = ({
onClick={handleSave}
data-id="save-control-save-agent"
data-testid="save-control-save-agent-button"
disabled={!canSave}
>
Save Agent
</Button>
Expand Down
3 changes: 3 additions & 0 deletions autogpt_platform/frontend/src/hooks/useAgentGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,9 @@ export default function useAgentGraph(
}, [_saveAgent, toast]);

const requestSave = useCallback(() => {
if (saveRunRequest.state !== "none") {
return;
}
saveAgent();
setSaveRunRequest({
request: "save",
Expand Down

0 comments on commit 7214fbd

Please sign in to comment.