Add track workspace as new git repo

pull/5370/head
David Disu 2 years ago
parent 37283d6668
commit a5578b8ea8
  1. 1
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  2. 2
      libs/remix-ui/workspace/src/lib/contexts/index.ts
  3. 4
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx
  4. 22
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -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) => {

@ -9,7 +9,7 @@ export const FileSystemContext = createContext<{
dispatchFetchDirectory:(path: string) => Promise<void>,
dispatchAddInputField:(path: string, type: 'file' | 'folder') => Promise<void>,
dispatchRemoveInputField:(path: string) => Promise<void>,
dispatchCreateWorkspace: (workspaceName: string, workspaceTemplateName: string) => Promise<void>,
dispatchCreateWorkspace: (workspaceName: string, workspaceTemplateName: string, initGitRepo?: boolean) => Promise<void>,
toast: (toasterMsg: string) => void,
dispatchFetchWorkspaceDirectory: (path: string) => Promise<void>,
dispatchSwitchToWorkspace: (name: string) => Promise<void>,

@ -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) => {

@ -19,6 +19,7 @@ export function Workspace () {
const workspaceCreateInput = useRef()
const workspaceCreateTemplateInput = useRef()
const cloneUrlRef = useRef<HTMLInputElement>()
const initGitRepoRef = useRef<HTMLInputElement>()
useEffect(() => {
setCurrentWorkspace(localStorage.getItem('currentWorkspace') ? localStorage.getItem('currentWorkspace') : '')
@ -103,9 +104,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)
@ -168,6 +170,24 @@ export function Workspace () {
<option value='zeroxErc20'>0xProject ERC20</option>
<option value='ozerc721'>OpenZeppelin ERC721</option>
</select>
<div className="d-flex py-2 align-items-center custom-control custom-checkbox">
<input
ref={initGitRepoRef}
id="initGitRepository"
data-id="initGitRepository"
className="form-check-input custom-control-input"
type="checkbox"
onChange={() => {}}
/>
<label
htmlFor="initGitRepository"
data-id="initGitRepositoryLabel"
className="m-0 form-check-label custom-control-label udapp_checkboxAlign"
title="Check option to initialize workspace as a new git repository"
>
Initialize workspace as a new git repository
</label>
</div>
</>
)
}

Loading…
Cancel
Save