Skip to content

TagSpaces is an offline, open source, document manager with tagging support

moving location menu button in LocationMenu.js

Mladen Sapundshiev5328f7e6dc61
diff --git a/app/components/LocationMenu.js b/app/components/LocationMenu.js
index b80b4e8f4..13f35cdce 100644
--- a/app/components/LocationMenu.js
+++ b/app/components/LocationMenu.js
@@ -27,6 +27,8 @@ import MenuItem from '@material-ui/core/MenuItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import ListSubHeader from '@material-ui/core/ListSubheader';
+import Button from '@material-ui/core/Button';
+import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown';
// import DirectoryMenu from './menus/DirectoryMenu';
import i18n from '../services/i18n';
import { getLocations, type Location } from '../reducers/locations';
@@ -41,41 +43,65 @@ import { getLocations, type Location } from '../reducers/locations';
} from '../reducers/app'; */
// import { extractDirectoryName } from '../utils/paths';
+type Props = {
+ classes: Object
+};
+
class LocationMenu extends React.Component { // <Props, State> {
openLocation = locationId => {
this.props.openLocation(locationId);
this.props.toggleLocationChooser();
};
+ toggleLocationChooser = (event?: Object) => {
+ this.setState({
+ locationChooserMenuOpened: !this.state.locationChooserMenuOpened,
+ locationChooserMenuAnchorEl: event ? event.currentTarget : null
+ });
+ };
+
render() {
+ const { classes } = this.props;
return (
- <Menu
- id="simple-menu"
- open={this.props.open}
- anchorEl={this.props.menuAnchorEl}
- onClose={this.props.toggleLocationChooser}
- PaperProps={{
- style: {
- maxHeight: 48 * 6.5,
- width: 300
- }
- }}
- >
- <div style={{ display: 'none' }} />
- <ListSubHeader>{i18n.t('core:chooseLocation')}</ListSubHeader>
- {this.props.locations.map((location: Location) => (
- <MenuItem
- data-tid="folderContainerMenuOpenLocation"
- key={location.uuid}
- onClick={() => this.openLocation(location.uuid)}
- >
- <ListItemIcon>
- <FolderIcon />
- </ListItemIcon>
- <ListItemText inset primary={location.name} />
- </MenuItem>
- ))}
- </Menu>
+ <div>
+ <Button
+ data-tid="folderContainerLocationChooser"
+ className={classes.locationSelectorButton}
+ onClick={this.toggleLocationChooser}
+ >
+ {this.state.currentLocation
+ ? this.state.currentLocation.name
+ : i18n.t('core:pleaseOpenLocation')}
+ <ArrowDropDownIcon />
+ </Button>
+ <Menu
+ id="simple-menu"
+ open={this.props.open}
+ anchorEl={this.props.menuAnchorEl}
+ onClose={this.props.toggleLocationChooser}
+ PaperProps={{
+ style: {
+ maxHeight: 48 * 6.5,
+ width: 300
+ }
+ }}
+ >
+ <div style={{ display: 'none' }} />
+ <ListSubHeader>{i18n.t('core:chooseLocation')}</ListSubHeader>
+ {this.props.locations.map((location: Location) => (
+ <MenuItem
+ data-tid="folderContainerMenuOpenLocation"
+ key={location.uuid}
+ onClick={() => this.openLocation(location.uuid)}
+ >
+ <ListItemIcon>
+ <FolderIcon />
+ </ListItemIcon>
+ <ListItemText inset primary={location.name} />
+ </MenuItem>
+ ))}
+ </Menu>
+ </div>
);
}
}