diff --git a/src/actions/index.js b/src/actions/index.js
index 7bb308f..1f0c85f 100644
--- a/src/actions/index.js
+++ b/src/actions/index.js
@@ -89,6 +89,14 @@ export const openCreateFolderDialog = () => {
}
}
+export const setUserPopover = anchor => {
+ return {
+ type: 'SET_USER_POPOVER',
+ anchor: anchor,
+ }
+}
+
+
export const openRenameDialog = () => {
return {
type: 'OPEN_RENAME_DIALOG',
diff --git a/src/component/UserAvatar.js b/src/component/UserAvatar.js
index 2f76cf4..ccc226c 100644
--- a/src/component/UserAvatar.js
+++ b/src/component/UserAvatar.js
@@ -5,25 +5,16 @@ import Grow from '@material-ui/core/Grow';
import { connect } from 'react-redux'
import Avatar from '@material-ui/core/Avatar';
import IconButton from '@material-ui/core/IconButton';
-import Popover from '@material-ui/core/Popover';
import SettingIcon from '@material-ui/icons/Settings'
-import Typography from '@material-ui/core/Typography';
-import Chip from '@material-ui/core/Chip';
-import ListItemIcon from '@material-ui/core/ListItemIcon';
-import MenuItem from '@material-ui/core/MenuItem';
-import Divider from '@material-ui/core/Divider';
import SaveIcon from '@material-ui/icons/Save';
import Tooltip from '@material-ui/core/Tooltip';
+import UserAvatarPopover from './UserAvatarPopover';
import {
- LogoutVariant,
- HomeAccount,
- DesktopMacDashboard,
AccountCircle,
- AccountArrowRight,
- AccountPlus
} from 'mdi-material-ui'
import {
- openResaveDialog
+ openResaveDialog,
+ setUserPopover
}from "../actions/index"
const mapStateToProps = state => {
@@ -39,6 +30,9 @@ const mapDispatchToProps = dispatch => {
return {
openResave:()=>{
dispatch(openResaveDialog())
+ },
+ setUserPopover:anchor=>{
+ dispatch(setUserPopover(anchor))
}
}
}
@@ -80,9 +74,7 @@ class UserAvatarCompoment extends Component {
}
showUserInfo = e=>{
- this.setState({
- anchorEl:e.currentTarget
- });
+ this.props.setUserPopover(e.currentTarget);
}
handleClose=()=>{
@@ -119,67 +111,7 @@ class UserAvatarCompoment extends Component {
-
- {window.userInfo.uid===-1&&
-
-
-
-
-
- }
- {window.userInfo.uid!==-1&&
-
-
-
-
- {window.userInfo.nick}
- {window.userInfo.email}
-
-
-
-
-
-
- {(window.userInfo.groupId === 1)&&
-
- }
-
-
-
}
-
+
);
}
diff --git a/src/component/UserAvatarPopover.js b/src/component/UserAvatarPopover.js
new file mode 100644
index 0000000..c0ae4f8
--- /dev/null
+++ b/src/component/UserAvatarPopover.js
@@ -0,0 +1,151 @@
+import React, { Component } from 'react'
+import PropTypes from 'prop-types';
+import { withStyles } from '@material-ui/core/styles';
+import { connect } from 'react-redux'
+import Avatar from '@material-ui/core/Avatar';
+import Popover from '@material-ui/core/Popover';
+import Typography from '@material-ui/core/Typography';
+import Chip from '@material-ui/core/Chip';
+import ListItemIcon from '@material-ui/core/ListItemIcon';
+import MenuItem from '@material-ui/core/MenuItem';
+import Divider from '@material-ui/core/Divider';
+import {
+ LogoutVariant,
+ HomeAccount,
+ DesktopMacDashboard,
+ AccountArrowRight,
+ AccountPlus
+} from 'mdi-material-ui'
+import {
+ setUserPopover
+}from "../actions/index"
+
+const mapStateToProps = state => {
+ return {
+ anchorEl:state.viewUpdate.userPopoverAnchorEl,
+ }
+}
+
+const mapDispatchToProps = dispatch => {
+ return {
+ setUserPopover:anchor=>{
+ dispatch(setUserPopover(anchor))
+ }
+ }
+}
+const styles = theme => ({
+ avatar:{
+ width:"30px",
+ height:"30px",
+ },
+ header:{
+ display:"flex",
+ padding: "20px 20px 20px 20px",
+ },
+ largeAvatar:{
+ height:"90px",
+ width:"90px",
+ },
+ info:{
+ marginLeft: "10px",
+ width: "139px",
+ },
+ badge:{
+ marginTop:"10px",
+ },
+ visitorMenu:{
+ width:200,
+ }
+})
+
+class UserAvatarPopoverCompoment extends Component {
+
+
+
+
+ handleClose=()=>{
+ this.props.setUserPopover(null)
+ }
+
+ openURL = (url)=>{
+ window.location.href=url;
+ }
+
+ render() {
+ const { classes} = this.props;
+ return (
+
+ {window.userInfo.uid===-1&&
+
+
+
+
+
+ }
+ {window.userInfo.uid!==-1&&
+
+
+
+
+ {window.userInfo.nick}
+ {window.userInfo.email}
+
+
+
+
+
+
+ {(window.userInfo.groupId === 1)&&
+
+ }
+
+
+
}
+
+ );
+ }
+}
+
+UserAvatarPopoverCompoment.propTypes = {
+ classes: PropTypes.object.isRequired,
+};
+
+const UserAvatarPopover = connect(
+ mapStateToProps,
+ mapDispatchToProps
+)( withStyles(styles)(UserAvatarPopoverCompoment))
+
+export default UserAvatarPopover
\ No newline at end of file
diff --git a/src/component/UserInfo.js b/src/component/UserInfo.js
index 446e2bb..eb496bc 100644
--- a/src/component/UserInfo.js
+++ b/src/component/UserInfo.js
@@ -4,6 +4,8 @@ import { withStyles } from '@material-ui/core/styles';
import { connect } from 'react-redux'
import Typography from '@material-ui/core/Typography';
import {
+ openResaveDialog,
+ setUserPopover
}from "../actions/index"
const mapStateToProps = state => {
@@ -13,6 +15,9 @@ const mapStateToProps = state => {
const mapDispatchToProps = dispatch => {
return {
+ setUserPopover:anchor=>{
+ dispatch(setUserPopover(anchor))
+ }
}
}
@@ -57,13 +62,17 @@ const styles = theme => ({
class UserInfoCompoment extends Component {
+ showUserInfo = e=>{
+ this.props.setUserPopover(e.currentTarget);
+ }
+
render() {
const { classes} = this.props;
return (
-
+
{(window.userInfo.uid!==-1)&&
}
{(window.userInfo.uid===-1)&&
}
diff --git a/src/index.js b/src/index.js
index a014468..42eb3c0 100644
--- a/src/index.js
+++ b/src/index.js
@@ -23,6 +23,7 @@ const defaultStatus = {
navigatorErrorMsg:null,
modalsLoading:false,
storageRefresh:false,
+ userPopoverAnchorEl:null,
modals:{
createNewFolder:false,
rename:false,
@@ -70,7 +71,3 @@ ReactDOM.render(
-// If you want your app to work offline and load faster, you can change
-// unregister() to register() below. Note this comes with some pitfalls.
-// Learn more about service workers: http://bit.ly/CRA-PWA
-serviceWorker.unregister();
diff --git a/src/reducers/index.js b/src/reducers/index.js
index 6e16910..3e693f1 100644
--- a/src/reducers/index.js
+++ b/src/reducers/index.js
@@ -215,6 +215,12 @@ const cloudreveApp = (state = [], action) => {
contextOpen:false,
}),
});
+ case 'SET_USER_POPOVER':
+ return Object.assign({}, state, {
+ viewUpdate: Object.assign({}, state.viewUpdate, {
+ userPopoverAnchorEl:action.anchor,
+ }),
+ });
case 'OPEN_SHARE_DIALOG':
return Object.assign({}, state, {
viewUpdate: Object.assign({}, state.viewUpdate, {