From b7a4d46fe2b011cdb6e38ed42e9f886fee8290b8 Mon Sep 17 00:00:00 2001 From: Pawel Kromplewski Date: Mon, 3 Dec 2018 08:30:45 +0100 Subject: [PATCH] Use redux-form in my account view Feature #14452 Arvados-DCO-1.1-Signed-off-by: Pawel Kromplewski --- src/routes/route-change-handlers.ts | 6 +-- .../my-account-panel-root.tsx | 42 ++++++++++--------- .../my-account-panel/my-account-panel.tsx | 13 ++++-- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/routes/route-change-handlers.ts b/src/routes/route-change-handlers.ts index 1f3bd93f..400866e3 100644 --- a/src/routes/route-change-handlers.ts +++ b/src/routes/route-change-handlers.ts @@ -4,10 +4,8 @@ import { History, Location } from 'history'; import { RootStore } from '~/store/store'; -import { matchProcessRoute, matchProcessLogRoute, matchProjectRoute, matchCollectionRoute, matchFavoritesRoute, matchTrashRoute, matchRootRoute, matchSharedWithMeRoute, matchRunProcessRoute, matchWorkflowRoute, matchSearchResultsRoute, matchSshKeysRoute, matchRepositoriesRoute, matchMyAccountRoute } from './routes'; -import { loadProject, loadCollection, loadFavorites, loadTrash, loadProcess, loadProcessLog, loadSshKeys, loadRepositories, loadMyAccount } from '~/store/workbench/workbench-actions'; -import { matchProcessRoute, matchProcessLogRoute, matchProjectRoute, matchCollectionRoute, matchFavoritesRoute, matchTrashRoute, matchRootRoute, matchSharedWithMeRoute, matchRunProcessRoute, matchWorkflowRoute, matchSearchResultsRoute, matchSshKeysRoute, matchRepositoriesRoute, matchVirtualMachineRoute } from './routes'; -import { loadProject, loadCollection, loadFavorites, loadTrash, loadProcess, loadProcessLog, loadSshKeys, loadRepositories, loadVirtualMachines } from '~/store/workbench/workbench-actions'; +import { matchProcessRoute, matchProcessLogRoute, matchProjectRoute, matchCollectionRoute, matchFavoritesRoute, matchTrashRoute, matchRootRoute, matchSharedWithMeRoute, matchRunProcessRoute, matchWorkflowRoute, matchSearchResultsRoute, matchSshKeysRoute, matchRepositoriesRoute, matchMyAccountRoute, matchVirtualMachineRoute } from './routes'; +import { loadProject, loadCollection, loadFavorites, loadTrash, loadProcess, loadProcessLog, loadSshKeys, loadRepositories, loadMyAccount, loadVirtualMachines } from '~/store/workbench/workbench-actions'; import { navigateToRootProject } from '~/store/navigation/navigation-action'; import { loadSharedWithMe, loadRunProcess, loadWorkflow, loadSearchResults } from '~//store/workbench/workbench-actions'; diff --git a/src/views/my-account-panel/my-account-panel-root.tsx b/src/views/my-account-panel/my-account-panel-root.tsx index c12f01aa..45875770 100644 --- a/src/views/my-account-panel/my-account-panel-root.tsx +++ b/src/views/my-account-panel/my-account-panel-root.tsx @@ -3,7 +3,9 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; -import { StyleRulesCallback, WithStyles, withStyles, Card, CardContent, TextField, Button, Typography, Grid, Table, TableHead, TableRow, TableCell, TableBody, Tooltip, IconButton } from '@material-ui/core'; +import { Field, InjectedFormProps } from "redux-form"; +import { TextField } from "~/components/text-field/text-field"; +import { StyleRulesCallback, WithStyles, withStyles, Card, CardContent, Button, Typography, Grid, Table, TableHead, TableRow, TableCell, TableBody, Tooltip, IconButton } from '@material-ui/core'; import { ArvadosTheme } from '~/common/custom-theme'; import { User } from "~/models/user"; @@ -15,7 +17,7 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ overflow: 'auto' }, gridItem: { - minHeight: 45, + height: 45, marginBottom: 20 }, title: { @@ -30,7 +32,9 @@ export interface MyAccountPanelRootDataProps { user?: User; } -type MyAccountPanelRootProps = MyAccountPanelRootActionProps & MyAccountPanelRootDataProps & WithStyles; +export const MY_ACCOUNT_FORM = 'myAccountForm'; + +type MyAccountPanelRootProps = InjectedFormProps & MyAccountPanelRootDataProps & WithStyles; export const MyAccountPanelRoot = withStyles(styles)( ({ classes, user }: MyAccountPanelRootProps) => { @@ -41,75 +45,75 @@ export const MyAccountPanelRoot = withStyles(styles)( - - - - - - - - diff --git a/src/views/my-account-panel/my-account-panel.tsx b/src/views/my-account-panel/my-account-panel.tsx index 508a4c7e..adc2f694 100644 --- a/src/views/my-account-panel/my-account-panel.tsx +++ b/src/views/my-account-panel/my-account-panel.tsx @@ -3,9 +3,10 @@ // SPDX-License-Identifier: AGPL-3.0 import { RootState } from '~/store/store'; -import { Dispatch } from 'redux'; +import { Dispatch, compose } from 'redux'; +import { reduxForm, reset } from 'redux-form'; import { connect } from 'react-redux'; -import { MyAccountPanelRoot, MyAccountPanelRootDataProps, MyAccountPanelRootActionProps } from '~/views/my-account-panel/my-account-panel-root'; +import { MyAccountPanelRoot, MyAccountPanelRootDataProps, MyAccountPanelRootActionProps, MY_ACCOUNT_FORM } from '~/views/my-account-panel/my-account-panel-root'; const mapStateToProps = (state: RootState): MyAccountPanelRootDataProps => ({ user: state.auth.user @@ -15,4 +16,10 @@ const mapDispatchToProps = (dispatch: Dispatch): MyAccountPanelRootActionProps = }); -export const MyAccountPanel = connect(mapStateToProps, mapDispatchToProps)(MyAccountPanelRoot); \ No newline at end of file +export const MyAccountPanel = compose(connect(mapStateToProps, mapDispatchToProps), reduxForm({ + form: MY_ACCOUNT_FORM, + onSubmit: (data, dispatch) => { + // dispatch(moveProject(data)); + + } +}))(MyAccountPanelRoot); \ No newline at end of file -- 2.30.2