-
Notifications
You must be signed in to change notification settings - Fork 409
Expand file tree
/
Copy pathExportModal.tsx
More file actions
108 lines (93 loc) · 2.98 KB
/
ExportModal.tsx
File metadata and controls
108 lines (93 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import React, { useCallback, useState } from 'react'
import styled from '../../../../design/lib/styled'
import { usePage } from '../../../lib/stores/pageStore'
import { LoadingButton } from '../../../../design/components/atoms/Button'
import { exportWorkspace } from '../../../api/teams/export'
import Flexbox from '../../../../design/components/atoms/Flexbox'
const ExportModal = () => {
const { team } = usePage()
const [sending, setSending] = useState(false)
const handleExportClick = useCallback(async () => {
if (team == null || sending) {
return
}
setSending(true)
try {
const blob = await exportWorkspace(team.id)
const url = window.URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = `space-${team.name}-export.zip`
document.body.appendChild(a)
a.click()
a.remove()
window.URL.revokeObjectURL(url)
} catch (err) {
console.error('Failed to export space', err)
} finally {
setSending(false)
}
}, [team, sending])
if (team == null) {
return null
}
return (
<Container className='export__modal'>
<header className='export__modal__header'>
<div className='export__modal__title'>Export your space data</div>
</header>
<p className='export__modal__description'>
The service for boostnote is planned to be retired at the end of
September. We recommend exporting your space's data so that you do
not lose any of your information.
</p>
<p>Here is an overview of what can be exported:</p>
<ul>
<li>Public & your accessible private Folders & documents hierarchy</li>
<li>Your Documents' content</li>
<li>Your Documents'attachments</li>
</ul>
<Flexbox justifyContent='center'>
<LoadingButton
disabled={sending || team == null}
spinning={sending}
onClick={handleExportClick}
>
Download ZIP
</LoadingButton>
</Flexbox>
</Container>
)
}
const Container = styled.div`
text-align: center;
.export__modal__subtitle {
span {
font-size: ${({ theme }) => theme.sizes.fonts.md}px;
display: inline-block;
margin-right: ${({ theme }) => theme.sizes.spaces.sm}px;
}
margin-bottom: ${({ theme }) => theme.sizes.spaces.md}px;
}
.export__modal__header {
text-align: center;
}
.export__modal__title {
margin: 0;
margin-top: ${({ theme }) => theme.sizes.spaces.md}px;
font-size: ${({ theme }) => theme.sizes.fonts.l}px;
}
.export__modal__header > * + .export__modal__header > * {
margin-top: ${({ theme }) => theme.sizes.spaces.df}px;
}
.export__modal__description {
margin: ${({ theme }) => theme.sizes.spaces.df}px 0;
text-transform: uppercase;
color: ${({ theme }) => theme.colors.text.subtle};
font-size: ${({ theme }) => theme.sizes.fonts.md};
}
li {
list-style: none;
}
`
export default ExportModal