allow Show Code controls to render on OSS builds without auth (#4065)
This commit is contained in:
@@ -19,7 +19,6 @@ import {
|
|||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from "@/components/ui/tooltip";
|
} from "@/components/ui/tooltip";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { useUser } from "@/hooks/useUser";
|
|
||||||
import { statusIsRunningOrQueued } from "@/routes/tasks/types";
|
import { statusIsRunningOrQueued } from "@/routes/tasks/types";
|
||||||
import { useGlobalWorkflowsQuery } from "../hooks/useGlobalWorkflowsQuery";
|
import { useGlobalWorkflowsQuery } from "../hooks/useGlobalWorkflowsQuery";
|
||||||
import { EditableNodeTitle } from "./nodes/components/EditableNodeTitle";
|
import { EditableNodeTitle } from "./nodes/components/EditableNodeTitle";
|
||||||
@@ -85,7 +84,6 @@ function WorkflowHeader({
|
|||||||
const debugStore = useDebugStore();
|
const debugStore = useDebugStore();
|
||||||
const workflowRunIsRunningOrQueued =
|
const workflowRunIsRunningOrQueued =
|
||||||
workflowRun && statusIsRunningOrQueued(workflowRun);
|
workflowRun && statusIsRunningOrQueued(workflowRun);
|
||||||
const user = useUser().get();
|
|
||||||
const [chosenCacheKeyValue, setChosenCacheKeyValue] = useState<string | null>(
|
const [chosenCacheKeyValue, setChosenCacheKeyValue] = useState<string | null>(
|
||||||
cacheKeyValue ?? null,
|
cacheKeyValue ?? null,
|
||||||
);
|
);
|
||||||
@@ -107,6 +105,9 @@ function WorkflowHeader({
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [cacheKeyValue]);
|
}, [cacheKeyValue]);
|
||||||
|
|
||||||
|
const shouldShowCacheControls =
|
||||||
|
!isGeneratingCode && (cacheKeyValues?.total_count ?? 0) > 0;
|
||||||
|
|
||||||
if (!globalWorkflows) {
|
if (!globalWorkflows) {
|
||||||
return null; // this should be loaded already by some other components
|
return null; // this should be loaded already by some other components
|
||||||
}
|
}
|
||||||
@@ -134,79 +135,77 @@ function WorkflowHeader({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex h-full items-center justify-end gap-4">
|
<div className="flex h-full items-center justify-end gap-4">
|
||||||
{user &&
|
{shouldShowCacheControls && (
|
||||||
!isGeneratingCode &&
|
<>
|
||||||
(cacheKeyValues?.total_count ?? 0) > 0 && (
|
{debugStore.isDebugMode && (
|
||||||
<>
|
<Button
|
||||||
{debugStore.isDebugMode && (
|
className="pl-2 pr-3"
|
||||||
<Button
|
size="lg"
|
||||||
className="pl-2 pr-3"
|
variant={!showAllCode ? "tertiary" : "default"}
|
||||||
size="lg"
|
onClick={handleShowAllCode}
|
||||||
variant={!showAllCode ? "tertiary" : "default"}
|
|
||||||
onClick={handleShowAllCode}
|
|
||||||
>
|
|
||||||
<CodeIcon className="mr-2 h-6 w-6" />
|
|
||||||
Show Code
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
<div
|
|
||||||
tabIndex={1}
|
|
||||||
className="flex max-w-[10rem] items-center justify-center gap-1 rounded-md border border-input pr-1 focus-within:ring-1 focus-within:ring-ring"
|
|
||||||
>
|
>
|
||||||
<Input
|
<CodeIcon className="mr-2 h-6 w-6" />
|
||||||
ref={dom.input}
|
Show Code
|
||||||
className="focus-visible:transparent focus-visible:none h-[2.75rem] text-ellipsis whitespace-nowrap border-none focus-visible:outline-none focus-visible:ring-0"
|
</Button>
|
||||||
onChange={(e) => {
|
)}
|
||||||
setChosenCacheKeyValue(e.target.value);
|
<div
|
||||||
onCacheKeyValuesFilter(e.target.value);
|
tabIndex={1}
|
||||||
}}
|
className="flex max-w-[10rem] items-center justify-center gap-1 rounded-md border border-input pr-1 focus-within:ring-1 focus-within:ring-ring"
|
||||||
onMouseDown={() => {
|
>
|
||||||
if (!cacheKeyValuesPanelOpen) {
|
<Input
|
||||||
onCacheKeyValuesClick();
|
ref={dom.input}
|
||||||
}
|
className="focus-visible:transparent focus-visible:none h-[2.75rem] text-ellipsis whitespace-nowrap border-none focus-visible:outline-none focus-visible:ring-0"
|
||||||
}}
|
onChange={(e) => {
|
||||||
onKeyDown={(e) => {
|
setChosenCacheKeyValue(e.target.value);
|
||||||
if (e.key === "Enter") {
|
onCacheKeyValuesFilter(e.target.value);
|
||||||
const numFiltered = cacheKeyValues?.values?.length ?? 0;
|
}}
|
||||||
|
onMouseDown={() => {
|
||||||
|
if (!cacheKeyValuesPanelOpen) {
|
||||||
|
onCacheKeyValuesClick();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Enter") {
|
||||||
|
const numFiltered = cacheKeyValues?.values?.length ?? 0;
|
||||||
|
|
||||||
if (numFiltered === 1) {
|
if (numFiltered === 1) {
|
||||||
const first = cacheKeyValues?.values?.[0];
|
const first = cacheKeyValues?.values?.[0];
|
||||||
if (first) {
|
if (first) {
|
||||||
setChosenCacheKeyValue(first);
|
setChosenCacheKeyValue(first);
|
||||||
onCacheKeyValueAccept(first);
|
onCacheKeyValueAccept(first);
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
setChosenCacheKeyValue(chosenCacheKeyValue);
|
|
||||||
onCacheKeyValueAccept(chosenCacheKeyValue);
|
|
||||||
}
|
}
|
||||||
onCacheKeyValuesKeydown(e);
|
|
||||||
}}
|
setChosenCacheKeyValue(chosenCacheKeyValue);
|
||||||
placeholder="Code Key Value"
|
onCacheKeyValueAccept(chosenCacheKeyValue);
|
||||||
value={chosenCacheKeyValue ?? undefined}
|
}
|
||||||
onBlur={(e) => {
|
onCacheKeyValuesKeydown(e);
|
||||||
onCacheKeyValuesBlurred(e.target.value);
|
}}
|
||||||
setChosenCacheKeyValue(e.target.value);
|
placeholder="Code Key Value"
|
||||||
|
value={chosenCacheKeyValue ?? undefined}
|
||||||
|
onBlur={(e) => {
|
||||||
|
onCacheKeyValuesBlurred(e.target.value);
|
||||||
|
setChosenCacheKeyValue(e.target.value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{cacheKeyValuesPanelOpen ? (
|
||||||
|
<ChevronUpIcon
|
||||||
|
className="h-6 w-6 cursor-pointer"
|
||||||
|
onClick={onCacheKeyValuesClick}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<ChevronDownIcon
|
||||||
|
className="h-6 w-6 cursor-pointer"
|
||||||
|
onClick={() => {
|
||||||
|
dom.input.current?.focus();
|
||||||
|
onCacheKeyValuesClick();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{cacheKeyValuesPanelOpen ? (
|
)}
|
||||||
<ChevronUpIcon
|
</div>
|
||||||
className="h-6 w-6 cursor-pointer"
|
</>
|
||||||
onClick={onCacheKeyValuesClick}
|
)}
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<ChevronDownIcon
|
|
||||||
className="h-6 w-6 cursor-pointer"
|
|
||||||
onClick={() => {
|
|
||||||
dom.input.current?.focus();
|
|
||||||
onCacheKeyValuesClick();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{isGeneratingCode && (
|
{isGeneratingCode && (
|
||||||
<Button
|
<Button
|
||||||
className="size-10 min-w-[6rem]"
|
className="size-10 min-w-[6rem]"
|
||||||
|
|||||||
Reference in New Issue
Block a user