|
|
@@ -1,13 +1,28 @@
|
|
|
-import React, { FC } from 'react';
|
|
|
+import React, { FC, useState } from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
|
-import { withTranslation } from 'react-i18next';
|
|
|
+import { useTranslation } from 'react-i18next';
|
|
|
+import { V5PageMigrationModal } from './V5PageMigrationModal';
|
|
|
+import AdminAppContainer from '../../../client/services/AdminAppContainer';
|
|
|
+import { withUnstatedContainers } from '../../UnstatedUtils';
|
|
|
|
|
|
|
|
|
-export const V5PageMigration: FC<any> = (props) => {
|
|
|
- const { t, isV5Compatible } = props;
|
|
|
+const V5PageMigration: FC<any> = (props) => {
|
|
|
+ const [isV5PageMigrationModalShown, setIsV5PageMigrationModalShown] = useState(false);
|
|
|
+ const { adminAppContainer } = props;
|
|
|
+ const { isV5Compatible } = adminAppContainer.state;
|
|
|
+ const { t } = useTranslation();
|
|
|
+
|
|
|
+ const onConfirm = async() => {
|
|
|
+ await adminAppContainer.startV5PageMigrationHandler();
|
|
|
+ };
|
|
|
|
|
|
return (
|
|
|
<>
|
|
|
+ <V5PageMigrationModal
|
|
|
+ isModalOpen={isV5PageMigrationModalShown}
|
|
|
+ onConfirm={onConfirm}
|
|
|
+ onCancel={() => setIsV5PageMigrationModalShown(false)}
|
|
|
+ />
|
|
|
<p className="card well">
|
|
|
GROWI is running with v4 compatible pages.<br />
|
|
|
To use new features such as Page tree or easy renaming, please migrate page schema to v5.<br />
|
|
|
@@ -21,16 +36,20 @@ export const V5PageMigration: FC<any> = (props) => {
|
|
|
<div className="mx-auto">
|
|
|
{
|
|
|
isV5Compatible == null
|
|
|
- && (<button type="button" className="btn btn-secondary mr-3" onClick={() => { /* Set false */ }}>Not now</button>)
|
|
|
+ && (<button type="button" className="btn btn-secondary mr-3" onClick={() => { /* TODO: POST to set false 80202 */ }}>Not now</button>)
|
|
|
}
|
|
|
- <button type="button" className="btn btn-warning" onClick={() => { /* Show modal, then start migration */ }}>Upgrade to v5</button>
|
|
|
+ <button type="button" className="btn btn-warning" onClick={() => setIsV5PageMigrationModalShown(true)}>Upgrade to v5</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</>
|
|
|
);
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * Wrapper component for using unstated
|
|
|
+ */
|
|
|
+export default withUnstatedContainers(V5PageMigration, [AdminAppContainer]);
|
|
|
+
|
|
|
V5PageMigration.propTypes = {
|
|
|
- t: PropTypes.func.isRequired, // i18next
|
|
|
- isV5Compatible: PropTypes.bool,
|
|
|
+ adminAppContainer: PropTypes.instanceOf(AdminAppContainer).isRequired,
|
|
|
};
|