TagSpaces is an offline, open source, document manager with tagging support
move Logout to User Profile (#1333)
Stanimira848fc779ed4
diff --git a/app/components/HelpFeedbackPanel.tsx b/app/components/HelpFeedbackPanel.tsxindex 179e8fe9d..3db2f3748 100644--- a/app/components/HelpFeedbackPanel.tsx+++ b/app/components/HelpFeedbackPanel.tsx@@ -40,6 +40,9 @@ import SocialIcon from '@material-ui/icons/ThumbUp';import Social2Icon from '@material-ui/icons/Mood';import KeyShortcutsIcon from '@material-ui/icons/Keyboard';import ProTeaserIcon from '@material-ui/icons/FlightTakeoff';+import { AmplifySignOut } from '@aws-amplify/ui-react';+import { connect } from 'react-redux';+import { CognitoUserInterface } from '@aws-amplify/ui-components';import CustomLogo from './CustomLogo';import ProTeaser from '../assets/images/spacerocket_undraw.svg';import styles from './SidePanels.css';@@ -56,6 +59,7 @@ interface Props {toggleKeysDialog: () => void;toggleOnboardingDialog: () => void;toggleProTeaser: () => void;+ user: CognitoUserInterface;style?: any;}@@ -73,6 +77,20 @@ const HelpFeedbackPanel = (props: Props) => {return (<div className={classes.panel} style={props.style}><CustomLogo />+ {props.user && (+ <>+ <Typography+ className={classNames(classes.panelTitle, classes.header)}+ variant="subtitle1"+ >+ User Profile+ </Typography>+ <div>+ <div>Hello, {props.user.attributes.email}</div>+ <AmplifySignOut buttonText="Sign Out" />+ </div>+ </>+ )}<TypographyclassName={classNames(classes.panelTitle, classes.header)}variant="subtitle1"@@ -291,4 +309,12 @@ const HelpFeedbackPanel = (props: Props) => {);};-export default withStyles(styles, { withTheme: true })(HelpFeedbackPanel);+function mapStateToProps(state) {+ return {+ user: state.app.user+ };+}++export default connect(mapStateToProps)(+ withStyles(styles, { withTheme: true })(HelpFeedbackPanel)+);diff --git a/app/components/MobileNavigation.tsx b/app/components/MobileNavigation.tsxindex 82c57b197..ecdd5ba5a 100644--- a/app/components/MobileNavigation.tsx+++ b/app/components/MobileNavigation.tsx@@ -30,8 +30,10 @@ import LocationsIcon from '@material-ui/icons/WorkOutline';import TagLibraryIcon from '@material-ui/icons/LocalOfferOutlined';import SearchIcon from '@material-ui/icons/SearchOutlined';import HelpIcon from '@material-ui/icons/HelpOutline';+import AccountCircleIcon from '@material-ui/icons/AccountCircle';import SettingsIcon from '@material-ui/icons/Settings';import { withStyles } from '@material-ui/core/styles';+import { CognitoUserInterface } from '@aws-amplify/ui-components';import TagLibrary from '../components/TagLibrary';import Search from '../components/Search';import LocationManager from '../components/LocationManager';@@ -104,6 +106,7 @@ interface Props {isReadOnlyMode: boolean;showNotification: (message: string) => void;directoryPath: string;+ user: CognitoUserInterface;}interface State {@@ -142,7 +145,8 @@ class MobileNavigation extends React.Component<Props, State> {hideDrawer,openFileNatively,openURLExternally,- directoryPath+ directoryPath,+ user} = this.props;return (<div style={{ height: '100%' }}>@@ -239,7 +243,11 @@ class MobileNavigation extends React.Component<Props, State> {: classes.button}>- <HelpIcon className={classes.buttonIcon} />+ {user ? (+ <AccountCircleIcon className={classes.buttonIcon} />+ ) : (+ <HelpIcon className={classes.buttonIcon} />+ )}</ToggleButton></Tooltip></ToggleButtonGroup>@@ -286,7 +294,8 @@ function mapStateToProps(state) {isPerspectivesPanelOpened: isPerspectivesPanelOpened(state),isHelpFeedbackPanelOpened: isHelpFeedbackPanelOpened(state),isReadOnlyMode: isReadOnlyMode(state),- directoryPath: getDirectoryPath(state)+ directoryPath: getDirectoryPath(state),+ user: state.app.user};}diff --git a/app/components/VerticalNavigation.tsx b/app/components/VerticalNavigation.tsxindex 5371c0359..6586fe896 100644--- a/app/components/VerticalNavigation.tsx+++ b/app/components/VerticalNavigation.tsx@@ -30,10 +30,12 @@ import SettingsIcon from '@material-ui/icons/Settings';import ThemingIcon from '@material-ui/icons/InvertColors';import UpgradeIcon from '@material-ui/icons/FlightTakeoff';import HelpIcon from '@material-ui/icons/HelpOutline';+import AccountCircleIcon from '@material-ui/icons/AccountCircle';import { withStyles } from '@material-ui/core/styles';import SplitPane from 'react-split-pane';import { CircularProgress, Typography } from '@material-ui/core';import Box from '@material-ui/core/Box';+import { CognitoUserInterface } from '@aws-amplify/ui-components';import LogoIcon from '../assets/images/icon100x100.svg';import TagLibrary from '../components/TagLibrary';import Search from '../components/Search';@@ -132,6 +134,7 @@ interface Props {showNotification: (message: string) => void;isReadOnlyMode: boolean;progress?: Array<any>;+ user: CognitoUserInterface;}interface State {@@ -183,7 +186,8 @@ class VerticalNavigation extends React.Component<Props, State> {openURLExternally,showNotification,directoryPath,- theme+ theme,+ user} = this.props;return (<div>@@ -338,7 +342,11 @@ class VerticalNavigation extends React.Component<Props, State> {: classes.button}>- <HelpIcon className={classes.buttonIcon} />+ {user ? (+ <AccountCircleIcon className={classes.buttonIcon} />+ ) : (+ <HelpIcon className={classes.buttonIcon} />+ )}</IconButton>{!Pro && (<IconButton@@ -450,7 +458,8 @@ function mapStateToProps(state) {isHelpFeedbackPanelOpened: isHelpFeedbackOpened(state),isReadOnlyMode: isReadOnlyMode(state),directoryPath: getDirectoryPath(state),- progress: getProgress(state)+ progress: getProgress(state),+ user: state.app.user};}diff --git a/app/components/WelcomePanel.tsx b/app/components/WelcomePanel.tsxindex f482c3272..b9c154e27 100644--- a/app/components/WelcomePanel.tsx+++ b/app/components/WelcomePanel.tsx@@ -34,11 +34,8 @@ import TranslationIcon from '@material-ui/icons/Translate';import NewFeatureIcon from '@material-ui/icons/Gesture';import SocialIcon from '@material-ui/icons/ThumbUp';import Social2Icon from '@material-ui/icons/Mood';-import LogoutIcon from '@material-ui/icons/MeetingRoom';+// import LogoutIcon from '@material-ui/icons/MeetingRoom';import KeyShortcutsIcon from '@material-ui/icons/Keyboard';-import { AmplifySignOut } from '@aws-amplify/ui-react';-import { CognitoUserInterface } from '@aws-amplify/ui-components';-import { API } from 'aws-amplify';import WelcomeBackground from '../assets/images/background.png';import WelcomeLogo from '../assets/images/welcome-logo.png';import { actions as AppActions } from '../reducers/app';@@ -85,7 +82,6 @@ interface Props {openFileNatively: (url: string) => void;toggleAboutDialog: () => void;isDesktopMode: boolean;- user: CognitoUserInterface;}const WelcomePanel = (props: Props) => {@@ -205,12 +201,6 @@ const WelcomePanel = (props: Props) => {{i18n.t('core:likeUsOnFacebook')}</Button></ListItem>- {props.user && (- <>- <AmplifySignOut buttonText="Sign Out" />- <div>Hello, {props.user.attributes.email}</div>- </>- )}{/* {AppConfig.isWeb && (<ListItembutton@@ -239,9 +229,7 @@ const WelcomePanel = (props: Props) => {function mapStateToProps(state) {return {isFirstRun: isFirstRun(state),- isDesktopMode: getDesktopMode(state),- user: state.app.user- // locations: getLocations(state),+ isDesktopMode: getDesktopMode(state)};}diff --git a/app/components/menus/LocationManagerMenu.tsx b/app/components/menus/LocationManagerMenu.tsxindex 1c71c2ce9..722bda79e 100644--- a/app/components/menus/LocationManagerMenu.tsx+++ b/app/components/menus/LocationManagerMenu.tsx@@ -25,13 +25,17 @@ import CreateLocationIcon from '@material-ui/icons/CreateNewFolder';import ExportImportIcon from '@material-ui/icons/SwapHoriz';import OpenLinkIcon from '@material-ui/icons/Link';import HelpIcon from '@material-ui/icons/Help';+import CloseIcon from '@material-ui/icons/Close';import classNames from 'classnames';import Typography from '@material-ui/core/Typography';import IconButton from '@material-ui/core/IconButton';import MoreVertIcon from '@material-ui/icons/MoreVert';+import { bindActionCreators } from 'redux';+import { connect } from 'react-redux';import AppConfig from '-/config';import i18n from '-/services/i18n';import { Pro } from '../../pro';+import { actions as AppActions } from '-/reducers/app';interface Props {classes: any;@@ -39,6 +43,7 @@ interface Props {importLocations: () => void;showCreateLocationDialog: () => void;toggleOpenLinkDialog: () => void;+ closeAllLocations: () => void;openURLExternally: (url: string, skipConfirmation?: boolean) => void;}@@ -125,6 +130,18 @@ const LocationManagerMenu = (props: Props) => {</MenuItem></>)}+ <MenuItem+ data-tid="locationManagerMenuCloseAll"+ onClick={() => {+ setLocationManagerMenuAnchorEl(null);+ props.closeAllLocations();+ }}+ >+ <ListItemIcon>+ <CloseIcon />+ </ListItemIcon>+ <ListItemText primary={i18n.t('core:closeAllLocations')} />+ </MenuItem><MenuItemdata-tid="locationManagerMenuHelp"onClick={() => {@@ -145,4 +162,12 @@ const LocationManagerMenu = (props: Props) => {);};-export default LocationManagerMenu;+function mapDispatchToProps(dispatch) {+ return bindActionCreators(+ {+ closeAllLocations: AppActions.closeAllLocations+ },+ dispatch+ );+}+export default connect(undefined, mapDispatchToProps)(LocationManagerMenu);diff --git a/app/locales/en/core.json b/app/locales/en/core.jsonindex 2eb0eac20..b995ee263 100644--- a/app/locales/en/core.json+++ b/app/locales/en/core.json@@ -50,6 +50,7 @@"createLocationTitle": "Connect a Location","exportLocationTitle": "Export Location Configuration","importLocationTitle": "Import Location Configuration",+ "closeAllLocations": "Close All Locations","addAES": "Encrypt with AES","aesPassword": "Encryption password","retypePassword": "Retype password",diff --git a/app/reducers/app.ts b/app/reducers/app.tsindex 6cd31d771..80cce5fa5 100644--- a/app/reducers/app.ts+++ b/app/reducers/app.ts@@ -1387,6 +1387,17 @@ export const actions = {});}},+ closeAllLocations: () => (dispatch: (actions: Object) => void) => {+ // location needed evtl. to unwatch many loc. root folders if available+ dispatch(actions.setCurrentLocationId(null));+ dispatch(actions.clearDirectoryContent());+ dispatch(LocationIndexActions.clearDirectoryIndex());+ if (Pro && Pro.Watcher) {+ Pro.Watcher.stopWatching();+ }+ clearAllURLParams();+ return true;+ },clearDirectoryContent: () => ({type: types.CLEAR_DIRECTORY_CONTENT}),