|
1 | 1 | import React from 'react'; |
2 | | -import { Button, Dialog, DialogTrigger, Heading, Modal, ModalOverlay } from 'react-aria-components'; |
3 | | -import { ActionFunction, Link, redirect, useFetcher, useNavigate } from 'react-router-dom'; |
| 2 | +import { Button } from 'react-aria-components'; |
| 3 | +import { ActionFunction, redirect, useFetcher, useNavigate } from 'react-router-dom'; |
4 | 4 |
|
5 | | -import { getAppWebsiteBaseURL } from '../../common/constants'; |
6 | | -import { exportAllData } from '../../common/export-all-data'; |
7 | 5 | import { SegmentEvent } from '../analytics'; |
8 | 6 | import { getLoginUrl } from '../auth-session-provider'; |
9 | 7 | import { Icon } from '../components/icon'; |
10 | | -import { showAlert } from '../components/modals'; |
11 | | -import { useRootLoaderData } from './root'; |
| 8 | +import { showModal } from '../components/modals'; |
| 9 | +import { SettingsModal } from '../components/modals/settings-modal'; |
12 | 10 |
|
13 | 11 | const GoogleIcon = (props: React.ReactSVGElement['props']) => { |
14 | 12 | return ( |
@@ -52,15 +50,14 @@ export const action: ActionFunction = async ({ |
52 | 50 | const Login = () => { |
53 | 51 | const loginFetcher = useFetcher(); |
54 | 52 | const navigate = useNavigate(); |
55 | | - const { workspaceCount } = useRootLoaderData(); |
56 | 53 |
|
57 | 54 | const login = (provider: string) => { |
58 | | - loginFetcher.submit({ |
59 | | - provider, |
60 | | - }, { |
61 | | - action: '/auth/login', |
62 | | - method: 'POST', |
63 | | - }); |
| 55 | + loginFetcher.submit({ |
| 56 | + provider, |
| 57 | + }, { |
| 58 | + action: '/auth/login', |
| 59 | + method: 'POST', |
| 60 | + }); |
64 | 61 | }; |
65 | 62 |
|
66 | 63 | return ( |
@@ -178,117 +175,18 @@ const Login = () => { |
178 | 175 | Use the local Scratch Pad |
179 | 176 | </span> |
180 | 177 | </Button> |
181 | | - <DialogTrigger> |
182 | | - <Button |
183 | | - aria-label='Export data and more' |
184 | | - className='flex transition-colors justify-center text-[rgba(var(--color-font-rgb),0.8)] text-sm gap-[--padding-xs] hover:text-[--color-font] focus:text-[--color-font]' |
185 | | - > |
186 | | - <div> |
187 | | - <i className='fa fa-database' /> |
188 | | - </div> |
189 | | - <span> |
190 | | - Export data and more |
191 | | - </span> |
192 | | - </Button> |
193 | | - <ModalOverlay isDismissable className="w-full h-[--visual-viewport-height] fixed top-0 left-0 flex items-center justify-center bg-black/30"> |
194 | | - <Modal className="max-w-lg w-full rounded-md border border-solid border-[--hl-sm] p-[--padding-lg] max-h-full bg-[--color-bg] text-[--color-font]"> |
195 | | - <Dialog className="outline-none"> |
196 | | - {({ close }) => ( |
197 | | - <div className='flex flex-col gap-4'> |
198 | | - <div className='flex gap-2 items-center justify-between'> |
199 | | - <Heading className='text-2xl'>Export data and more</Heading> |
200 | | - <Button |
201 | | - className="flex flex-shrink-0 items-center justify-center aspect-square h-6 aria-pressed:bg-[--hl-sm] rounded-sm text-[--color-font] hover:bg-[--hl-xs] focus:ring-inset ring-1 ring-transparent focus:ring-[--hl-md] transition-all text-sm" |
202 | | - onPress={close} |
203 | | - > |
204 | | - <Icon icon="x" /> |
205 | | - </Button> |
206 | | - </div> |
207 | | - <p className='text-sm text-[rgba(var(--color-font-rgb),0.8)]'> |
208 | | - With Insomnia you can choose where to store your projects: locally with Local Vault, in the cloud with Cloud Sync or in a Git repository (Git Sync). Even with an account, your data is stored based on your settings. |
209 | | - </p> |
210 | | - <p className='text-sm text-[rgba(var(--color-font-rgb),0.8)]'> |
211 | | - You can get started with an account which gives you access to the best Insomnia experience (recommended): |
212 | | - </p> |
213 | | - <Button |
214 | | - onPress={() => { |
215 | | - window.main.openInBrowser(`${getAppWebsiteBaseURL()}/app/subscribe?plan=free`); |
216 | | - }} |
217 | | - aria-label='Get started for free' |
218 | | - className="px-4 py-1 font-semibold border border-solid border-[--hl-md] flex items-center justify-center gap-2 aria-pressed:bg-[--hl-sm] rounded-sm text-[--color-font] hover:bg-[--hl-xs] focus:ring-inset ring-1 ring-transparent focus:ring-[--hl-md] transition-all text-base" |
219 | | - > |
220 | | - <span> |
221 | | - Get started for free |
222 | | - </span> |
223 | | - <Icon icon='arrow-right' /> |
224 | | - </Button> |
225 | | - |
226 | | - <p className='text-sm text-[rgba(var(--color-font-rgb),0.8)]'> |
227 | | - You can use Insomnia without an account in a limited way (only 1 collection) with the local Scratch Pad: |
228 | | - </p> |
229 | | - |
230 | | - <Link |
231 | | - to="/organization/org_scratchpad/project/proj_scratchpad/workspace/wrk_scratchpad/debug" |
232 | | - aria-label='Go to Scratch Pad' |
233 | | - className="px-4 py-1 outline-none font-semibold border border-solid border-[--hl-md] flex items-center justify-center gap-2 aria-pressed:bg-[--hl-sm] rounded-sm text-[--color-font] hover:bg-[--hl-xs] focus:ring-inset ring-1 ring-transparent focus:ring-[--hl-md] transition-all text-base" |
234 | | - > |
235 | | - <span> |
236 | | - Go to Scratch Pad |
237 | | - </span> |
238 | | - <Icon icon='arrow-right' /> |
239 | | - </Link> |
240 | | - |
241 | | - <p className='text-sm text-[rgba(var(--color-font-rgb),0.8)]'> |
242 | | - Finally, you can export your local Insomnia data (projects, collections and other files) for portability: |
243 | | - |
244 | | - </p> |
245 | | - |
246 | | - <Button |
247 | | - onPress={async () => { |
248 | | - const { filePaths, canceled } = await window.dialog.showOpenDialog({ |
249 | | - properties: ['openDirectory', 'createDirectory', 'promptToCreate'], |
250 | | - buttonLabel: 'Select', |
251 | | - title: 'Export All Insomnia Data', |
252 | | - }); |
253 | | - |
254 | | - if (canceled) { |
255 | | - return; |
256 | | - } |
257 | | - |
258 | | - const [dirPath] = filePaths; |
259 | | - |
260 | | - try { |
261 | | - dirPath && await exportAllData({ |
262 | | - dirPath, |
263 | | - }); |
264 | | - } catch (e) { |
265 | | - showAlert({ |
266 | | - title: 'Export Failed', |
267 | | - message: 'An error occurred while exporting data. Please try again.', |
268 | | - }); |
269 | | - console.error(e); |
270 | | - } |
271 | | - |
272 | | - showAlert({ |
273 | | - title: 'Export Complete', |
274 | | - message: 'All your data have been successfully exported', |
275 | | - }); |
276 | | - window.main.trackSegmentEvent({ |
277 | | - event: SegmentEvent.exportAllCollections, |
278 | | - }); |
279 | | - }} |
280 | | - aria-label='Export all data' |
281 | | - className="px-4 py-1 font-semibold border border-solid border-[--hl-md] flex items-center justify-center gap-2 aria-pressed:bg-[--hl-sm] rounded-sm text-[--color-font] hover:bg-[--hl-xs] focus:ring-inset ring-1 ring-transparent focus:ring-[--hl-md] transition-all text-base" |
282 | | - > |
283 | | - <Icon icon="file-export" /> |
284 | | - <span>Export all data {`(${workspaceCount} files)`}</span> |
285 | | - </Button> |
286 | | - </div> |
287 | | - )} |
288 | | - </Dialog> |
289 | | - </Modal> |
290 | | - </ModalOverlay> |
291 | | - </DialogTrigger> |
| 178 | + <Button |
| 179 | + onPress={() => showModal(SettingsModal)} |
| 180 | + aria-label='Preferences' |
| 181 | + className='flex transition-colors justify-center text-[rgba(var(--color-font-rgb),0.8)] text-sm gap-[--padding-xs] hover:text-[--color-font] focus:text-[--color-font]' |
| 182 | + > |
| 183 | + <div> |
| 184 | + <Icon icon="cog" /> |
| 185 | + </div> |
| 186 | + <span> |
| 187 | + Preferences |
| 188 | + </span> |
| 189 | + </Button> |
292 | 190 | </div> |
293 | 191 | </div> |
294 | 192 | ); |
|
0 commit comments