diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 3ef203644e..083d9ce67c 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -53,6 +53,7 @@ export const createWorkspace = async (workspaceName: string, workspaceTemplateNa await plugin.setWorkspace({ name: workspaceName, isLocalhost: false }) await plugin.setWorkspaces(await getWorkspaces()) await plugin.workspaceCreated(workspaceName) + if (isGitRepo) await plugin.call('dGitProvider', 'init') if (!isEmpty) await loadWorkspacePreset(workspaceTemplateName) cb && cb(null, workspaceName) }).catch((error) => { diff --git a/libs/remix-ui/workspace/src/lib/contexts/index.ts b/libs/remix-ui/workspace/src/lib/contexts/index.ts index 1724ca7c29..27f46391c4 100644 --- a/libs/remix-ui/workspace/src/lib/contexts/index.ts +++ b/libs/remix-ui/workspace/src/lib/contexts/index.ts @@ -9,7 +9,7 @@ export const FileSystemContext = createContext<{ dispatchFetchDirectory:(path: string) => Promise, dispatchAddInputField:(path: string, type: 'file' | 'folder') => Promise, dispatchRemoveInputField:(path: string) => Promise, - dispatchCreateWorkspace: (workspaceName: string, workspaceTemplateName: string) => Promise, + dispatchCreateWorkspace: (workspaceName: string, workspaceTemplateName: string, initGitRepo?: boolean) => Promise, toast: (toasterMsg: string) => void, dispatchFetchWorkspaceDirectory: (path: string) => Promise, dispatchSwitchToWorkspace: (name: string) => Promise, diff --git a/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx b/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx index 2d4010ca31..736811af00 100644 --- a/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx +++ b/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx @@ -45,8 +45,8 @@ export const FileSystemProvider = (props: WorkspaceProps) => { await removeInputField(path) } - const dispatchCreateWorkspace = async (workspaceName: string, workspaceTemplateName: WorkspaceTemplate) => { - await createWorkspace(workspaceName, workspaceTemplateName) + const dispatchCreateWorkspace = async (workspaceName: string, workspaceTemplateName: WorkspaceTemplate, initGitRepo?: boolean) => { + await createWorkspace(workspaceName, workspaceTemplateName, null, null, initGitRepo) } const dispatchFetchWorkspaceDirectory = async (path: string) => { diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 512fd2ec65..acfb888e62 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -20,6 +20,7 @@ export function Workspace () { const workspaceCreateInput = useRef() const workspaceCreateTemplateInput = useRef() const cloneUrlRef = useRef() + const initGitRepoRef = useRef() useEffect(() => { setCurrentWorkspace(localStorage.getItem('currentWorkspace') ? localStorage.getItem('currentWorkspace') : '') @@ -104,9 +105,10 @@ export function Workspace () { const workspaceName = workspaceCreateInput.current.value // @ts-ignore: Object is possibly 'null'. const workspaceTemplateName = workspaceCreateTemplateInput.current.value || 'remixDefault' + const initGitRepo = initGitRepoRef.current.checked try { - await global.dispatchCreateWorkspace(workspaceName, workspaceTemplateName) + await global.dispatchCreateWorkspace(workspaceName, workspaceTemplateName, initGitRepo) } catch (e) { global.modal('Create Workspace', e.message, 'OK', () => {}, '') console.error(e) @@ -169,6 +171,24 @@ export function Workspace () { +
+ {}} + /> + +
) }