Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion src/cloud/pages/cooperate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { SerializedDoc } from '../interfaces/db/doc'
import { SerializedOpenInvite } from '../interfaces/db/openInvite'
import { boostHubBaseUrl } from '../lib/consts'
import { getOpenInviteURL, getTeamURL } from '../lib/utils/patterns'
import { mdiClose } from '@mdi/js'
import Button from '../../shared/components/atoms/Button'

const CooperatePage = () => {
const [name, setName] = useState<string>('')
Expand Down Expand Up @@ -161,7 +163,24 @@ const CooperatePage = () => {
}

if (state === 'usage') {
return <UsagePage onUsage={onUsageCallback} sending={sending} />
return (
<>
{usingElectron && (
<ElectronButtonContainer>
<Button
variant='icon'
iconSize={34}
iconPath={mdiClose}
onClick={() => {
sendToElectron('router', 'back')
}}
className='electron__goback'
/>
</ElectronButtonContainer>
)}
<UsagePage onUsage={onUsageCallback} sending={sending} />
</>
)
}

return (
Expand All @@ -170,6 +189,19 @@ const CooperatePage = () => {
subtitle='Please tell us your team information.'
contentWidth={600}
>
{usingElectron && (
<ElectronButtonContainer>
<Button
variant='icon'
iconSize={34}
iconPath={mdiClose}
onClick={() => {
sendToElectron('router', 'back')
}}
className='electron__goback'
/>
</ElectronButtonContainer>
)}
<Container>
<CreateTeamForm
fullPage={true}
Expand All @@ -196,6 +228,15 @@ CooperatePage.getInitialProps = async (_params: GetInitialPropsParameters) => {

export default CooperatePage

const ElectronButtonContainer = styled.div`
.electron__goback {
position: fixed;
top: 20px;
right: 20px;
z-index: 100;
}
`

const Container = styled.div`
text-align: left;

Expand Down
23 changes: 22 additions & 1 deletion src/components/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import BoostHubTeamsShowPage from './pages/BoostHubTeamsShowPage'
import BoostHubTeamsCreatePage from './pages/BoostHubTeamsCreatePage'
import BoostHubAccountDeletePage from './pages/BoostHubAccountDeletePage'
import {
boostHubAppRouterEventEmitter,
BoostHubNavigateRequestEvent,
boostHubNavigateRequestEventEmitter,
BoostHubAppRouterEvent,
} from '../lib/events'
import { parse as parseUrl } from 'url'
import { openNew } from '../lib/platform'
Expand All @@ -27,9 +29,28 @@ import NotFoundErrorPage from './pages/NotFoundErrorPage'
const Router = () => {
const routeParams = useRouteParams()
const { storageMap } = useDb()
const { push } = useRouter()
const { push, goBack, goForward } = useRouter()
const { generalStatus } = useGeneralStatus()

useEffect(() => {
const boostHubAppRouterEventHandler = (event: BoostHubAppRouterEvent) => {
switch (event.detail.target) {
case 'forward':
goForward()
return
case 'back':
default:
goBack()
return
}
}

boostHubAppRouterEventEmitter.listen(boostHubAppRouterEventHandler)
return () => {
boostHubAppRouterEventEmitter.unlisten(boostHubAppRouterEventHandler)
}
}, [goBack, goForward])

useEffect(() => {
const boostHubNavigateRequestHandler = (
event: BoostHubNavigateRequestEvent
Expand Down
4 changes: 4 additions & 0 deletions src/components/atoms/BoostHubWebview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
boostHubSubscriptionUpdateEventEmitter,
boosthubNotificationCountsEventEmitter,
boostHubSidebarSpaceEventEmitter,
boostHubAppRouterEventEmitter,
} from '../../lib/events'
import { usePreferences } from '../../lib/preferences'
import { openContextMenu, openExternal } from '../../lib/electronOnly'
Expand Down Expand Up @@ -142,6 +143,9 @@ const BoostHubWebview = ({

const ipcMessageEventHandler = (event: IpcMessageEvent) => {
switch (event.channel) {
case 'router':
boostHubAppRouterEventEmitter.dispatch({ target: event.args[0] })
break
case 'sidebar-spaces':
boostHubSidebarSpaceEventEmitter.dispatch()
break
Expand Down
6 changes: 6 additions & 0 deletions src/lib/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,9 @@ export const boostHubSubscriptionDeleteEventEmitter = createCustomEventEmitter<
export const boostHubSidebarSpaceEventEmitter = createCustomEventEmitter(
'BoostHub:sidebarSpace'
)

export type BoostHubAppRouterEventDetail = { target: 'back' | 'forward' }
export type BoostHubAppRouterEvent = CustomEvent<BoostHubAppRouterEventDetail>
export const boostHubAppRouterEventEmitter = createCustomEventEmitter<
BoostHubAppRouterEventDetail
>('BoostHub:appRouter')