18559: Remove dead code
[arvados-workbench2.git] / src / views / user-profile-panel / user-profile-panel.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { RootState } from 'store/store';
6 import { compose, Dispatch } from 'redux';
7 import { reduxForm, isPristine, isValid } from 'redux-form';
8 import { connect } from 'react-redux';
9 import { UserResource } from 'models/user';
10 import { saveEditedUser } from 'store/user-profile/user-profile-actions';
11 import { UserProfilePanelRoot, UserProfilePanelRootDataProps } from 'views/user-profile-panel/user-profile-panel-root';
12 import { USER_PROFILE_FORM } from "store/user-profile/user-profile-actions";
13 import { matchUserProfileRoute } from 'routes/routes';
14 import { openUserContextMenu } from 'store/context-menu/context-menu-actions';
15
16 const mapStateToProps = (state: RootState): UserProfilePanelRootDataProps => {
17   const pathname = state.router.location ? state.router.location.pathname : '';
18   const match = matchUserProfileRoute(pathname);
19   const uuid = match ? match.params.id : state.auth.user?.uuid || '';
20
21   return {
22     isAdmin: state.auth.user!.isAdmin,
23     isSelf: state.auth.user!.uuid === uuid,
24     isPristine: isPristine(USER_PROFILE_FORM)(state),
25     isValid: isValid(USER_PROFILE_FORM)(state),
26     localCluster: state.auth.localCluster,
27     userUuid: uuid,
28     resources: state.resources,
29 }};
30
31 const mapDispatchToProps = (dispatch: Dispatch) => ({
32     handleContextMenu: (event, resource: UserResource) => dispatch<any>(openUserContextMenu(event, resource)),
33 });
34
35 export const UserProfilePanel = compose(
36     connect(mapStateToProps, mapDispatchToProps),
37     reduxForm({
38         form: USER_PROFILE_FORM,
39         onSubmit: (data, dispatch) => {
40             dispatch(saveEditedUser(data));
41         }
42     }))(UserProfilePanelRoot);