diff --git a/app/components/Sidebar/Settings.js b/app/components/Sidebar/Settings.js index dc93d5fb..164e42ef 100644 --- a/app/components/Sidebar/Settings.js +++ b/app/components/Sidebar/Settings.js @@ -121,9 +121,9 @@ class SettingsSidebar extends React.Component { /> {can.export && ( } - label={t("Export Data")} + label={t("Import / Export")} /> )} diff --git a/app/routes/settings.js b/app/routes/settings.js index 4e7c362c..bc1471e2 100644 --- a/app/routes/settings.js +++ b/app/routes/settings.js @@ -1,9 +1,9 @@ // @flow import * as React from "react"; import { Switch, Route } from "react-router-dom"; +import ImportExport from "scenes/Settings/ImportExport"; import Settings from "scenes/Settings"; import Details from "scenes/Settings/Details"; -import Export from "scenes/Settings/Export"; import Groups from "scenes/Settings/Groups"; import Notifications from "scenes/Settings/Notifications"; import People from "scenes/Settings/People"; @@ -27,7 +27,7 @@ export default function SettingsRoutes() { - + ); } diff --git a/app/scenes/Settings/Export.js b/app/scenes/Settings/Export.js deleted file mode 100644 index eecfb4e5..00000000 --- a/app/scenes/Settings/Export.js +++ /dev/null @@ -1,73 +0,0 @@ -// @flow -import { observable } from "mobx"; -import { observer, inject } from "mobx-react"; -import * as React from "react"; -import AuthStore from "stores/AuthStore"; -import CollectionsStore from "stores/CollectionsStore"; -import UiStore from "stores/UiStore"; - -import Button from "components/Button"; -import CenteredContent from "components/CenteredContent"; -import HelpText from "components/HelpText"; -import PageTitle from "components/PageTitle"; - -type Props = { - auth: AuthStore, - collections: CollectionsStore, - ui: UiStore, -}; - -@observer -class Export extends React.Component { - @observable isLoading: boolean = false; - @observable isExporting: boolean = false; - - handleSubmit = async (ev: SyntheticEvent<>) => { - ev.preventDefault(); - this.isLoading = true; - - try { - await this.props.collections.export(); - this.isExporting = true; - this.props.ui.showToast("Export in progress…"); - } finally { - this.isLoading = false; - } - }; - - render() { - const { auth } = this.props; - if (!auth.user) return null; - - return ( - - -

Export Data

- - Exporting your team’s documents may take a little time depending on - the size of your knowledge base. Consider exporting a single document - or collection instead. - - - Still want to export everything in your wiki? We’ll put together a zip - file of your collections and documents in Markdown format and email it - to {auth.user.email}. - - -
- ); - } -} - -export default inject("auth", "ui", "collections")(Export); diff --git a/app/scenes/Settings/ImportExport.js b/app/scenes/Settings/ImportExport.js new file mode 100644 index 00000000..69460a79 --- /dev/null +++ b/app/scenes/Settings/ImportExport.js @@ -0,0 +1,78 @@ +// @flow +import { observer } from "mobx-react"; +import * as React from "react"; +import { useTranslation, Trans } from "react-i18next"; +import Button from "components/Button"; +import CenteredContent from "components/CenteredContent"; +import HelpText from "components/HelpText"; +import PageTitle from "components/PageTitle"; +import useCurrentUser from "hooks/useCurrentUser"; +import useStores from "hooks/useStores"; + +function ImportExport() { + const { t } = useTranslation(); + const user = useCurrentUser(); + const { ui, collections } = useStores(); + const { showToast } = ui; + const [isLoading, setLoading] = React.useState(false); + const [isExporting, setExporting] = React.useState(false); + + const handleImport = React.useCallback(async () => { + // TODO + }, []); + + const handleExport = React.useCallback( + async (ev: SyntheticEvent<>) => { + ev.preventDefault(); + setLoading(true); + + try { + await collections.export(); + setExporting(true); + showToast(t("Export in progress…")); + } finally { + setLoading(false); + } + }, + [t, collections, showToast] + ); + + return ( + + +

{t("Import")}

+ + + It is possible to import a zip file of folders and Markdown files. + + + + +

{t("Export")}

+ + + A full export might take some time, consider exporting a single + document or collection if possible. We’ll put together a zip of all + your documents in Markdown format and email it to{" "} + {{ userEmail: user.email }}. + + + +
+ ); +} + +export default observer(ImportExport); diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index 65493998..7dc40db3 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -101,7 +101,7 @@ "People": "People", "Groups": "Groups", "Share Links": "Share Links", - "Export Data": "Export Data", + "Import / Export": "Import / Export", "Integrations": "Integrations", "Installation": "Installation", "Settings": "Settings",