mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +00:00
Build automatically after cloning (if applicable)
This commit is contained in:
2 files changed
+28
-4
No files matched your search
@@ -21,6 +21,7 @@ import {
|
|||||||
import { FileTree } from './FileTree';
|
import { FileTree } from './FileTree';
|
||||||
import { FileEditor } from './FileEditor';
|
import { FileEditor } from './FileEditor';
|
||||||
import { DeployDialog } from '@/components/DeployDialog';
|
import { DeployDialog } from '@/components/DeployDialog';
|
||||||
|
import { useSearchParams } from 'react-router-dom';
|
||||||
|
|
||||||
// Get iframe domain from environment variable
|
// Get iframe domain from environment variable
|
||||||
const IFRAME_DOMAIN = import.meta.env.VITE_IFRAME_DOMAIN || 'local-shakespeare.dev';
|
const IFRAME_DOMAIN = import.meta.env.VITE_IFRAME_DOMAIN || 'local-shakespeare.dev';
|
||||||
@@ -89,13 +90,36 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
|
|||||||
const projectsManager = useProjectsManager();
|
const projectsManager = useProjectsManager();
|
||||||
const { mutate: buildProject, isPending: isBuildLoading } = useBuildProject(projectId);
|
const { mutate: buildProject, isPending: isBuildLoading } = useBuildProject(projectId);
|
||||||
|
|
||||||
const handleBuildProject = () => {
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
|
const [shouldBuild, setShouldBuild] = useState(false);
|
||||||
|
|
||||||
|
const handleBuildProject = useCallback(() => {
|
||||||
buildProject(undefined, {
|
buildProject(undefined, {
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
console.error('Build failed:', error);
|
console.error('Build failed:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
}, [buildProject]);
|
||||||
|
|
||||||
|
// Handle "build" URL parameter on initial load
|
||||||
|
useEffect(() => {
|
||||||
|
if (searchParams.has('build')) {
|
||||||
|
setShouldBuild(true);
|
||||||
|
|
||||||
|
// Remove the build parameter from URL
|
||||||
|
const newSearchParams = new URLSearchParams(searchParams);
|
||||||
|
newSearchParams.delete('build');
|
||||||
|
setSearchParams(newSearchParams, { replace: true });
|
||||||
|
}
|
||||||
|
}, [searchParams, setSearchParams]);
|
||||||
|
|
||||||
|
// Build automatically if "build" parameter was present
|
||||||
|
useEffect(() => {
|
||||||
|
if (shouldBuild && isPreviewable && !isBuildLoading) {
|
||||||
|
setShouldBuild(false);
|
||||||
|
handleBuildProject();
|
||||||
|
}
|
||||||
|
}, [isBuildLoading, isPreviewable, handleBuildProject, shouldBuild]);
|
||||||
|
|
||||||
const loadFileContent = useCallback(async (filePath: string) => {
|
const loadFileContent = useCallback(async (filePath: string) => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|||||||
+2
-2
@@ -116,8 +116,8 @@ export default function Clone() {
|
|||||||
description: successDescription,
|
description: successDescription,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Navigate to the new project
|
// Navigate to the new project with build parameter
|
||||||
navigate(`/project/${project.id}`);
|
navigate(`/project/${project.id}?build`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to clone repository:', error);
|
console.error('Failed to clone repository:', error);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user