Conditionally disable auth

This commit is contained in:
Gregory Schier
2025-11-26 10:30:16 -08:00
parent dfa6f1c5b4
commit 79dd50474d
11 changed files with 348 additions and 117 deletions

View File

@@ -6,20 +6,33 @@ import { invokeCmd } from '../lib/tauri';
import { useActiveEnvironment } from './useActiveEnvironment';
import { activeWorkspaceIdAtom } from './useActiveWorkspace';
export function useRenderTemplate(
template: string,
enabled: boolean,
purpose: RenderPurpose,
refreshKey: string | null,
) {
export function useRenderTemplate({
template,
enabled,
purpose,
refreshKey,
ignoreError,
preservePreviousValue,
}: {
template: string;
enabled: boolean;
purpose: RenderPurpose;
refreshKey?: string | null;
ignoreError?: boolean;
preservePreviousValue?: boolean;
}) {
const workspaceId = useAtomValue(activeWorkspaceIdAtom) ?? 'n/a';
const environmentId = useActiveEnvironment()?.id ?? null;
return useQuery<string>({
refetchOnWindowFocus: false,
enabled,
queryKey: ['render_template', workspaceId, environmentId, refreshKey, purpose],
placeholderData: preservePreviousValue ? (prev) => prev : undefined,
queryKey: ['render_template', workspaceId, environmentId, refreshKey, purpose, ignoreError],
queryFn: () =>
minPromiseMillis(renderTemplate({ template, workspaceId, environmentId, purpose }), 300),
minPromiseMillis(
renderTemplate({ template, workspaceId, environmentId, purpose, ignoreError }),
300,
),
});
}
@@ -28,13 +41,21 @@ export async function renderTemplate({
workspaceId,
environmentId,
purpose,
ignoreError,
}: {
template: string;
workspaceId: string;
environmentId: string | null;
purpose: RenderPurpose;
ignoreError?: boolean;
}): Promise<string> {
return invokeCmd('cmd_render_template', { template, workspaceId, environmentId, purpose });
return invokeCmd('cmd_render_template', {
template,
workspaceId,
environmentId,
purpose,
ignoreError,
});
}
export async function decryptTemplate({