refactor(stacks): convert editor to tab (#1374)

This commit is contained in:
Chaim Lev-Ari
2025-11-12 15:44:13 +02:00
committed by GitHub
parent 0075374241
commit 8071641179
24 changed files with 2898 additions and 210 deletions
@@ -0,0 +1,31 @@
import { useEffect } from 'react';
import { useStackFile } from '@/react/common/stacks/queries/useStackFile';
import { Stack } from '@/react/common/stacks/types';
export function useVersionedStackFile({
stackId,
version,
onLoad,
}: {
stackId: Stack['Id'];
version?: string;
onLoad(content: string): void;
}) {
const fileQuery = useStackFile(stackId, { version }, { enabled: !!version });
useEffect(() => {
if (fileQuery.isSuccess && fileQuery.data?.StackFileContent) {
onLoad(fileQuery.data.StackFileContent);
}
}, [
fileQuery.isSuccess,
fileQuery.data?.StackFileContent,
onLoad,
version, // reload on version change
]);
return {
isLoading: fileQuery.isLoading,
content: fileQuery.data?.StackFileContent,
};
}