Merge branch 'master' into wscat

pull/2895/head
Aniket 2 years ago committed by GitHub
commit efa74523c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      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. 24
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -52,7 +52,10 @@ 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, opts)
cb && cb(null, workspaceName)
}).catch((error) => {
dispatch(createWorkspaceError({ 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, opts?) => Promise<void>,
dispatchCreateWorkspace: (workspaceName: string, workspaceTemplateName: string, opts?, 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, opts?) => {
await createWorkspace(workspaceName, workspaceTemplateName, opts)
const dispatchCreateWorkspace = async (workspaceName: string, workspaceTemplateName: WorkspaceTemplate, opts?, initGitRepo?: boolean) => {
await createWorkspace(workspaceName, workspaceTemplateName, opts, null, null, initGitRepo)
}
const dispatchFetchWorkspaceDirectory = async (path: string) => {

@ -22,6 +22,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') : '')
@ -106,13 +107,14 @@ 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
const opts = {
upgradeable: upgradeable.current
}
try {
await global.dispatchCreateWorkspace(workspaceName, workspaceTemplateName, opts)
await global.dispatchCreateWorkspace(workspaceName, workspaceTemplateName, opts, initGitRepo)
} catch (e) {
global.modal('Create Workspace', e.message, 'OK', () => {}, '')
console.error(e)
@ -211,6 +213,26 @@ export function Workspace () {
<label id="wsName" className="form-check-label">Workspace name</label>
<input type="text" data-id="modalDialogCustomPromptTextCreate" defaultValue={`remixDefault_${Date.now()}`} ref={workspaceCreateInput} className="form-control" />
<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