Update RunFlow and RefreshButton components

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-03-04 10:37:13 -03:00
commit 9244db0c24
2 changed files with 10 additions and 3 deletions

View file

@ -21,8 +21,8 @@ class RunFlowComponent(CustomComponent):
"multiline": True, "multiline": True,
}, },
"flow_name": { "flow_name": {
"display_name": "Flow ID", "display_name": "Flow Name",
"info": "The ID of the flow to run.", "info": "The name of the flow to run.",
"options": self.get_flow_names, "options": self.get_flow_names,
}, },
"tweaks": { "tweaks": {

View file

@ -1,7 +1,8 @@
import { useState } from "react"; import { useEffect, useState } from "react";
import IconComponent from "../../components/genericIconComponent"; import IconComponent from "../../components/genericIconComponent";
import { NodeDataType } from "../../types/flow"; import { NodeDataType } from "../../types/flow";
import { cn } from "../../utils/utils"; import { cn } from "../../utils/utils";
function RefreshButton({ function RefreshButton({
disabled, disabled,
name, name,
@ -15,6 +16,10 @@ function RefreshButton({
}) { }) {
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
useEffect(() => {
handleUpdateValues(name, data);
}, []); // Empty dependency array to run only once
const handleClick = async () => { const handleClick = async () => {
if (disabled) return; if (disabled) return;
setIsLoading(true); setIsLoading(true);
@ -31,10 +36,12 @@ function RefreshButton({
setIsLoading(false); setIsLoading(false);
} }
}; };
const className = cn( const className = cn(
"extra-side-bar-buttons ml-2 mt-1 w-1/6", "extra-side-bar-buttons ml-2 mt-1 w-1/6",
disabled ? "cursor-not-allowed" : "cursor-pointer" disabled ? "cursor-not-allowed" : "cursor-pointer"
); );
// icon class name should take into account the disabled state and the loading state // icon class name should take into account the disabled state and the loading state
const disabledIconTextClass = disabled ? "text-muted-foreground" : ""; const disabledIconTextClass = disabled ? "text-muted-foreground" : "";
const iconClassName = cn( const iconClassName = cn(