Skip to content

Commit ea5eed7

Browse files
committed
initial implementation
1 parent be3f10a commit ea5eed7

File tree

4 files changed

+74
-2
lines changed

4 files changed

+74
-2
lines changed

src/cloud/pages/cooperate.tsx

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { SerializedDoc } from '../interfaces/db/doc'
1919
import { SerializedOpenInvite } from '../interfaces/db/openInvite'
2020
import { boostHubBaseUrl } from '../lib/consts'
2121
import { getOpenInviteURL, getTeamURL } from '../lib/utils/patterns'
22+
import { mdiClose } from '@mdi/js'
23+
import Button from '../../shared/components/atoms/Button'
2224

2325
const CooperatePage = () => {
2426
const [name, setName] = useState<string>('')
@@ -161,7 +163,24 @@ const CooperatePage = () => {
161163
}
162164

163165
if (state === 'usage') {
164-
return <UsagePage onUsage={onUsageCallback} sending={sending} />
166+
return (
167+
<>
168+
{usingElectron && (
169+
<ElectronButtonContainer>
170+
<Button
171+
variant='icon'
172+
iconSize={34}
173+
iconPath={mdiClose}
174+
onClick={() => {
175+
sendToElectron('router', 'back')
176+
}}
177+
className='electron__goback'
178+
/>
179+
</ElectronButtonContainer>
180+
)}
181+
<UsagePage onUsage={onUsageCallback} sending={sending} />
182+
</>
183+
)
165184
}
166185

167186
return (
@@ -170,6 +189,19 @@ const CooperatePage = () => {
170189
subtitle='Please tell us your team information.'
171190
contentWidth={600}
172191
>
192+
{usingElectron && (
193+
<ElectronButtonContainer>
194+
<Button
195+
variant='icon'
196+
iconSize={34}
197+
iconPath={mdiClose}
198+
onClick={() => {
199+
sendToElectron('router', 'back')
200+
}}
201+
className='electron__goback'
202+
/>
203+
</ElectronButtonContainer>
204+
)}
173205
<Container>
174206
<CreateTeamForm
175207
fullPage={true}
@@ -196,6 +228,15 @@ CooperatePage.getInitialProps = async (_params: GetInitialPropsParameters) => {
196228

197229
export default CooperatePage
198230

231+
const ElectronButtonContainer = styled.div`
232+
.electron__goback {
233+
position: fixed;
234+
top: 20px;
235+
right: 20px;
236+
z-index: 100;
237+
}
238+
`
239+
199240
const Container = styled.div`
200241
text-align: left;
201242

src/components/Router.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import BoostHubTeamsShowPage from './pages/BoostHubTeamsShowPage'
1010
import BoostHubTeamsCreatePage from './pages/BoostHubTeamsCreatePage'
1111
import BoostHubAccountDeletePage from './pages/BoostHubAccountDeletePage'
1212
import {
13+
boostHubAppRouterEventEmitter,
1314
BoostHubNavigateRequestEvent,
1415
boostHubNavigateRequestEventEmitter,
16+
BoostHubAppRouterEvent,
1517
} from '../lib/events'
1618
import { parse as parseUrl } from 'url'
1719
import { openNew } from '../lib/platform'
@@ -27,9 +29,28 @@ import NotFoundErrorPage from './pages/NotFoundErrorPage'
2729
const Router = () => {
2830
const routeParams = useRouteParams()
2931
const { storageMap } = useDb()
30-
const { push } = useRouter()
32+
const { push, goBack, goForward } = useRouter()
3133
const { generalStatus } = useGeneralStatus()
3234

35+
useEffect(() => {
36+
const boostHubAppRouterEventHandler = (event: BoostHubAppRouterEvent) => {
37+
switch (event.detail.target) {
38+
case 'forward':
39+
goForward()
40+
return
41+
case 'back':
42+
default:
43+
goBack()
44+
return
45+
}
46+
}
47+
48+
boostHubAppRouterEventEmitter.listen(boostHubAppRouterEventHandler)
49+
return () => {
50+
boostHubAppRouterEventEmitter.unlisten(boostHubAppRouterEventHandler)
51+
}
52+
}, [goBack, goForward])
53+
3354
useEffect(() => {
3455
const boostHubNavigateRequestHandler = (
3556
event: BoostHubNavigateRequestEvent

src/components/atoms/BoostHubWebview.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
boostHubSubscriptionUpdateEventEmitter,
3232
boosthubNotificationCountsEventEmitter,
3333
boostHubSidebarSpaceEventEmitter,
34+
boostHubAppRouterEventEmitter,
3435
} from '../../lib/events'
3536
import { usePreferences } from '../../lib/preferences'
3637
import { openContextMenu, openExternal } from '../../lib/electronOnly'
@@ -142,6 +143,9 @@ const BoostHubWebview = ({
142143

143144
const ipcMessageEventHandler = (event: IpcMessageEvent) => {
144145
switch (event.channel) {
146+
case 'router':
147+
boostHubAppRouterEventEmitter.dispatch({ target: event.args[0] })
148+
break
145149
case 'sidebar-spaces':
146150
boostHubSidebarSpaceEventEmitter.dispatch()
147151
break

src/lib/events.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,9 @@ export const boostHubSubscriptionDeleteEventEmitter = createCustomEventEmitter<
161161
export const boostHubSidebarSpaceEventEmitter = createCustomEventEmitter(
162162
'BoostHub:sidebarSpace'
163163
)
164+
165+
export type BoostHubAppRouterEventDetail = { target: 'back' | 'forward' }
166+
export type BoostHubAppRouterEvent = CustomEvent<BoostHubAppRouterEventDetail>
167+
export const boostHubAppRouterEventEmitter = createCustomEventEmitter<
168+
BoostHubAppRouterEventDetail
169+
>('BoostHub:appRouter')

0 commit comments

Comments
 (0)