forked from 5afe/safe-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add export data button to settings page (5afe#4114)
* fix: Add export data button to settings page * fix: Export the whole local storage * fix: typo * fix: Add export route * fix: Export versioned data * refactor: Extract const * fix: Wording
- Loading branch information
1 parent
5723858
commit 1927709
Showing
5 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ReactElement } from 'react' | ||
|
||
import Page from 'src/components/layout/Page' | ||
import Block from 'src/components/layout/Block' | ||
import DataExport from 'src/routes/safe/components/Settings/DataExport' | ||
|
||
function Export(): ReactElement { | ||
return ( | ||
<Page> | ||
<Block> | ||
<DataExport /> | ||
</Block> | ||
</Page> | ||
) | ||
} | ||
|
||
export default Export |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ReactElement } from 'react' | ||
import Button from 'src/components/layout/Button' | ||
import Heading from 'src/components/layout/Heading' | ||
import Paragraph from 'src/components/layout/Paragraph' | ||
|
||
const EXPORT_VERSION = '1.0' | ||
|
||
const DataExport = (): ReactElement => { | ||
const handleExport = () => { | ||
const filename = `safe-data-${new Date().toISOString().slice(0, 10)}.json` | ||
|
||
const data = JSON.stringify({ version: EXPORT_VERSION, data: localStorage }) | ||
|
||
const blob = new Blob([data], { type: 'text/json' }) | ||
const link = document.createElement('a') | ||
|
||
link.download = filename | ||
link.href = window.URL.createObjectURL(blob) | ||
link.dataset.downloadurl = ['text/json', link.download, link.href].join(':') | ||
link.dispatchEvent(new MouseEvent('click')) | ||
} | ||
|
||
return ( | ||
<> | ||
<Heading tag="h2">Export your data</Heading> | ||
<Paragraph> | ||
Download your local data with your added Safes and address book. You can import it on app.safe.global. | ||
</Paragraph> | ||
<Button onClick={handleExport} color="primary" size="small" variant="outlined"> | ||
Download | ||
</Button> | ||
</> | ||
) | ||
} | ||
|
||
export default DataExport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters