implement blank workspace logic

pull/5179/head
Joseph Izang 3 months ago committed by ryestew
parent 97bdb2536c
commit 07962422a6
  1. 3
      libs/remix-ui/workspace/src/lib/components/workspace-hamburger.tsx
  2. 18
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -7,6 +7,7 @@ import { WorkspaceMetadata } from '../types'
export interface HamburgerMenuProps {
selectedWorkspace: WorkspaceMetadata
createWorkspace: () => void
createBlankWorkspace: () => Promise<void>
renameCurrentWorkspace: () => void
downloadCurrentWorkspace: () => void
deleteCurrentWorkspace: () => void
@ -41,7 +42,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) {
fa="far fa-plus"
hideOption={hideWorkspaceOptions}
actionOnClick={() => {
props.createWorkspace()
props.createBlankWorkspace()
props.hideIconsMenu(!showIconsMenu)
}}
platforms={[appPlatformTypes.web]}

@ -18,6 +18,7 @@ import { AppContext, appPlatformTypes, platformContext } from '@remix-ui/app'
import { ElectronMenu } from './components/electron-menu'
import { ElectronWorkspaceName } from './components/electron-workspace-name'
import { branch, GitHubUser, gitUIPanels, userEmails } from '@remix-ui/git'
import { createModalMessage } from './components/createModal'
const _paq = (window._paq = window._paq || [])
@ -335,9 +336,23 @@ export function Workspace() {
)
}
const [counter, setCounter] = useState(0)
const createBlankWorkspace = async () => {
const username = await global.plugin.call('settings', 'get', 'settings/github-user-name')
const email = await global.plugin.call('settings', 'get', 'settings/github-email')
const gitNotSet = !username || !email
const defaultName = await global.plugin.call('filePanel', 'getAvailableWorkspaceName', 'blank')
let workspace = defaultName
let gitInit = false
setCounter((previous) => {
return previous + 1
})
global.modal(
intl.formatMessage({ id: 'filePanel.workspace.createBlank' }),
await createModalMessage(`blank - 1`, gitNotSet, (value) => { workspace = value }, (value) => gitInit = false),
intl.formatMessage({ id: 'filePanel.ok' }),
() => global.dispatchCreateWorkspace(`blank - ${counter}`, 'blank', false),
intl.formatMessage({ id: 'filePanel.cancel' })
)
}
@ -932,6 +947,7 @@ export function Workspace() {
<HamburgerMenu
selectedWorkspace={selectedWorkspace}
createWorkspace={createWorkspace}
createBlankWorkspace={createBlankWorkspace}
renameCurrentWorkspace={renameCurrentWorkspace}
downloadCurrentWorkspace={downloadCurrentWorkspace}
deleteCurrentWorkspace={deleteCurrentWorkspace}

Loading…
Cancel
Save