Skip to content

Commit

Permalink
implement blank workspace logic
Browse files Browse the repository at this point in the history
  • Loading branch information
joeizang committed Sep 4, 2024
1 parent 75c9b45 commit 45b9a37
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { WorkspaceMetadata } from '../types'
export interface HamburgerMenuProps {
selectedWorkspace: WorkspaceMetadata
createWorkspace: () => void
createBlankWorkspace: () => Promise<void>
renameCurrentWorkspace: () => void
downloadCurrentWorkspace: () => void
deleteCurrentWorkspace: () => void
Expand Down Expand Up @@ -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]}
Expand Down
18 changes: 17 additions & 1 deletion libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 || [])

Expand Down Expand Up @@ -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' })
)
}

Expand Down Expand Up @@ -932,6 +947,7 @@ export function Workspace() {
<HamburgerMenu
selectedWorkspace={selectedWorkspace}
createWorkspace={createWorkspace}
createBlankWorkspace={createBlankWorkspace}
renameCurrentWorkspace={renameCurrentWorkspace}
downloadCurrentWorkspace={downloadCurrentWorkspace}
deleteCurrentWorkspace={deleteCurrentWorkspace}
Expand Down

0 comments on commit 45b9a37

Please sign in to comment.