Skip to content

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

refactoring the vertical toolbar moving state members to redux adding help feedback panel

Ilian Sapundshiev76d38e16f341
diff --git a/app/components/HelpFeedbackPanel.js b/app/components/HelpFeedbackPanel.js
new file mode 100644
index 000000000..3b4a44cad
--- /dev/null
+++ b/app/components/HelpFeedbackPanel.js
@@ -0,0 +1,46 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License (version 3) as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * @flow
+ */
+
+import React from 'react';
+import { withStyles } from '@material-ui/core/styles';
+import Typography from '@material-ui/core/Typography';
+import CustomLogo from './CustomLogo';
+import styles from './SidePanels.css';
+
+type Props = {
+ classes: Object,
+ style: Object
+};
+
+type State = {};
+
+class HelpFeedbackPanel extends React.Component<Props, State> {
+ render() {
+ const classes = this.props.classes;
+
+ return (
+ <div className={classes.panel} style={this.props.style}>
+ <CustomLogo />
+ <Typography className={classes.panelTitle} type="subtitle1">Help</Typography>
+ </div>
+ );
+ }
+}
+
+export default withStyles(styles)(HelpFeedbackPanel);
diff --git a/app/components/TagLibrary.js b/app/components/TagLibrary.js
index 7ab2b0a68..3efaa44d3 100644
--- a/app/components/TagLibrary.js
+++ b/app/components/TagLibrary.js
@@ -68,7 +68,6 @@ type Props = {
tagBackgroundColor: string,
tagGroups: Array<TagGroup>,
allTags: Array<Tag>,
- togglePanel: () => void,
toggleTagGroup: (expanded: boolean, uuid: string) => void,
removeTagGroup: (uuid: string) => void,
moveTagGroupUp: (uuid: string) => void,
@@ -371,10 +370,8 @@ class TagLibrary extends React.Component<Props, State> {
importTagGroups={this.props.importTagGroups}
exportTagGroups={this.props.exportTagGroups}
showCreateTagGroupDialog={this.showCreateTagGroupDialog}
- toggleTagGroup={this.props.toggleTagGroup}
/>
<TagMenu
- togglePanel={this.props.togglePanel}
anchorEl={this.state.tagMenuAnchorEl}
open={this.state.tagMenuOpened}
onClose={this.handleCloseTagMenu}
diff --git a/app/components/VerticalNavigation.js b/app/components/VerticalNavigation.js
index 7549e2a33..12f08e2e2 100644
--- a/app/components/VerticalNavigation.js
+++ b/app/components/VerticalNavigation.js
@@ -30,6 +30,7 @@ import SearchIcon from '@material-ui/icons/SearchOutlined';
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 { withTheme } from '@material-ui/core/styles';
import SplitPane from 'react-split-pane';
import LogoIcon from '../assets/images/icon100x100.svg';
@@ -41,6 +42,7 @@ import TagLibrary from '../components/TagLibrary';
import Search from '../components/Search';
import PerspectiveManager from '../components/PerspectiveManager';
import LocationManager from '../components/LocationManager';
+import HelpFeedbackPanel from '../components/HelpFeedbackPanel';
import i18n from '../services/i18n';
import { Pro } from '../pro';
import { type Tag } from '../reducers/taglibrary';
@@ -57,6 +59,11 @@ import {
isCreateFileDialogOpened,
isCreateDirectoryOpened,
isSelectDirectoryDialogOpened,
+ isLocationManagerPanelOpened,
+ isTagLibraryPanelOpened,
+ isSearchPanelOpened,
+ isPerspectivesPanelOpened,
+ isHelpFeedbackPanelOpened,
isReadOnlyMode,
} from '../reducers/app';
import { actions as SettingsActions, isFirstRun } from '../reducers/settings';
@@ -125,14 +132,6 @@ const OnboardingDialogAsync = props => (
</React.Suspense>
);
-export const AppVerticalPanels = {
- tagLibrary: 'tagLibrary',
- search: 'search',
- perspectiveManager: 'perspectiveManager',
- locationManager: 'locationManager',
- settings: 'settings'
-};
-
type Props = {
isFirstRun: boolean,
setFirstRun: (isFirstRun: boolean) => void,
@@ -159,6 +158,17 @@ type Props = {
setManagementPanelVisibility: boolean => void,
isSelectDirectoryDialogOpened: boolean,
toggleSelectDirectoryDialog: () => void,
+ isLocationManagerPanelOpened: boolean,
+ openLocationManagerPanel: () => void,
+ isTagLibraryPanelOpened: boolean,
+ openTagLibraryPanel: () => void,
+ isSearchPanelOpened: boolean,
+ openSearchPanel: () => void,
+ isPerspectivesPanelOpened: boolean,
+ openPerspectivesPanel: () => void,
+ isHelpFeedbackPanelOpened: boolean,
+ openHelpFeedbackPanel: () => void,
+ closeAllVerticalPanels: () => void,
switchTheme: () => void,
shouldTogglePanel: string,
currentDirectory: string,
@@ -167,10 +177,6 @@ type Props = {
type State = {
selectedDirectoryPath?: string,
- isLocationManagerVisible?: boolean,
- isTagLibraryVisible?: boolean,
- isSearchVisible?: boolean,
- isPerspectiveManagerVisible?: boolean,
isManagementPanelVisible?: boolean, // evtl. redux migration
CreateFileDialogKey: string,
isProTeaserVisible: boolean
@@ -178,24 +184,11 @@ type State = {
class VerticalNavigation extends React.Component<Props, State> {
state = {
- isLocationManagerVisible: true,
- isTagLibraryVisible: false,
- isSearchVisible: false,
- isPerspectiveManagerVisible: false,
isManagementPanelVisible: true,
CreateFileDialogKey: uuidv1(),
isProTeaserVisible: false
};
- componentWillReceiveProps(nextProps: Props) {
- if (
- nextProps.shouldTogglePanel &&
- this.props.shouldTogglePanel !== nextProps.shouldTogglePanel
- ) {
- this.togglePanel(nextProps.shouldTogglePanel);
- }
- }
-
styles = {
panel: {
height: '100%',
@@ -232,74 +225,6 @@ class VerticalNavigation extends React.Component<Props, State> {
}
};
- hideAllPanels() {
- this.setState({
- isLocationManagerVisible: false,
- isTagLibraryVisible: false,
- isSearchVisible: false,
- isPerspectiveManagerVisible: false,
- isManagementPanelVisible: false
- });
- this.props.setManagementPanelVisibility(false);
- }
-
- togglePanel = panelName => {
- switch (panelName) {
- case AppVerticalPanels.locationManager:
- this.props.setManagementPanelVisibility(
- !this.state.isLocationManagerVisible
- );
- this.setState({
- isLocationManagerVisible: !this.state.isLocationManagerVisible,
- isTagLibraryVisible: false,
- isSearchVisible: false,
- isPerspectiveManagerVisible: false
- });
- break;
- case AppVerticalPanels.tagLibrary:
- this.props.setManagementPanelVisibility(
- !this.state.isTagLibraryVisible
- );
- this.setState({
- isLocationManagerVisible: false,
- isTagLibraryVisible: !this.state.isTagLibraryVisible,
- isSearchVisible: false,
- isPerspectiveManagerVisible: false
- });
- break;
- case AppVerticalPanels.search:
- this.props.setManagementPanelVisibility(!this.state.isSearchVisible);
- this.setState({
- isLocationManagerVisible: false,
- isTagLibraryVisible: false,
- isSearchVisible: !this.state.isSearchVisible,
- isPerspectiveManagerVisible: false
- });
- break;
- case AppVerticalPanels.perspectiveManager:
- this.props.setManagementPanelVisibility(
- !this.state.isPerspectiveManagerVisible
- );
- this.setState({
- isLocationManagerVisible: false,
- isTagLibraryVisible: false,
- isSearchVisible: false,
- isPerspectiveManagerVisible: true
- });
- break;
- default:
- // this.props.setManagementPanelVisibility(false);
- // this.setState({
- // isLocationManagerVisible: false,
- // isTagLibraryVisible: false,
- // isSearchVisible: false,
- // isPerspectiveManagerVisible: false,
- // isSettingsVisible: false
- // });
- break;
- }
- };
-
toggleProTeaser = () => {
this.setState({ isProTeaserVisible: !this.state.isProTeaserVisible });
}
@@ -317,6 +242,44 @@ class VerticalNavigation extends React.Component<Props, State> {
};
render() {
+ const {
+ isFirstRun,
+ isEditTagDialogOpened,
+ isAboutDialogOpened,
+ isKeysDialogOpened,
+ isOnboardingDialogOpened,
+ isLicenseDialogOpened,
+ isThirdPartyLibsDialogOpened,
+ isSettingsDialogOpened,
+ isCreateDirectoryOpened,
+ isCreateFileDialogOpened,
+ isSelectDirectoryDialogOpened,
+ isLocationManagerPanelOpened,
+ isTagLibraryPanelOpened,
+ isSearchPanelOpened,
+ isPerspectivesPanelOpened,
+ isHelpFeedbackPanelOpened,
+ currentDirectory,
+ isReadOnlyMode,
+ toggleCreateDirectoryDialog,
+ toggleCreateFileDialog,
+ toggleSelectDirectoryDialog,
+ toggleOnboardingDialog,
+ toggleSettingsDialog,
+ toggleKeysDialog,
+ toggleLicenseDialog,
+ toggleThirdPartyLibsDialog,
+ toggleAboutDialog,
+ toggleEditTagDialog,
+ openLocationManagerPanel,
+ openTagLibraryPanel,
+ openSearchPanel,
+ openHelpFeedbackPanel,
+ closeAllVerticalPanels,
+ switchTheme,
+ setManagementPanelVisibility,
+ setFirstRun
+ } = this.props;
return (
<div>
<style>
@@ -328,62 +291,62 @@ class VerticalNavigation extends React.Component<Props, State> {
`}
</style>
<CreateDirectoryDialog
- open={this.props.isCreateDirectoryOpened}
- onClose={this.props.toggleCreateDirectoryDialog}
- selectedDirectoryPath={this.props.currentDirectory}
+ open={isCreateDirectoryOpened}
+ onClose={toggleCreateDirectoryDialog}
+ selectedDirectoryPath={currentDirectory}
/>
- {this.props.isEditTagDialogOpened && (
+ {isEditTagDialogOpened && (
<EditEntryTagDialogAsync
key={uuidv1()}
- open={this.props.isEditTagDialogOpened}
- onClose={this.props.toggleEditTagDialog}
+ open={isEditTagDialogOpened}
+ onClose={toggleEditTagDialog}
currentEntryPath={this.props.currentEntryPath}
selectedTag={this.props.selectedTag}
/>
)}
- {this.props.isSelectDirectoryDialogOpened && (
+ {isSelectDirectoryDialogOpened && (
<SelectDirectoryAsync
- open={this.props.isSelectDirectoryDialogOpened}
- onClose={this.props.toggleSelectDirectoryDialog}
+ open={isSelectDirectoryDialogOpened}
+ onClose={toggleSelectDirectoryDialog}
chooseDirectoryPath={this.chooseDirectoryPath}
selectedDirectoryPath={
- this.state.selectedDirectoryPath || this.props.currentDirectory
+ this.state.selectedDirectoryPath || currentDirectory
}
/>
)}
- {this.props.isAboutDialogOpened && (
+ {isAboutDialogOpened && (
<AboutDialogAsync
- open={this.props.isAboutDialogOpened}
- toggleLicenseDialog={this.props.toggleLicenseDialog}
- toggleThirdPartyLibsDialog={this.props.toggleThirdPartyLibsDialog}
- onClose={this.props.toggleAboutDialog}
+ open={isAboutDialogOpened}
+ toggleLicenseDialog={toggleLicenseDialog}
+ toggleThirdPartyLibsDialog={toggleThirdPartyLibsDialog}
+ onClose={toggleAboutDialog}
/>
)}
- {this.props.isKeysDialogOpened && (
+ {isKeysDialogOpened && (
<KeyboardDialogAsync
- open={this.props.isKeysDialogOpened}
- onClose={this.props.toggleKeysDialog}
+ open={isKeysDialogOpened}
+ onClose={toggleKeysDialog}
/>
)}
- {(this.props.isLicenseDialogOpened) && (
+ {(isLicenseDialogOpened) && (
<LicenseDialogAsync
- open={this.props.isLicenseDialogOpened}
+ open={isLicenseDialogOpened}
onClose={() => {
- this.props.setFirstRun(false);
- this.props.toggleLicenseDialog();
+ setFirstRun(false);
+ toggleLicenseDialog();
}}
/>
)}
- {(this.props.isOnboardingDialogOpened) && (
+ {(isOnboardingDialogOpened) && (
<OnboardingDialogAsync
- open={this.props.isOnboardingDialogOpened}
- onClose={this.props.toggleOnboardingDialog}
+ open={isOnboardingDialogOpened}
+ onClose={toggleOnboardingDialog}
/>
)}
- {this.props.isThirdPartyLibsDialogOpened && (
+ {isThirdPartyLibsDialogOpened && (
<ThirdPartyLibsDialogAsync
- open={this.props.isThirdPartyLibsDialogOpened}
- onClose={this.props.toggleThirdPartyLibsDialog}
+ open={isThirdPartyLibsDialogOpened}
+ onClose={toggleThirdPartyLibsDialog}
/>
)}
{this.state.isProTeaserVisible && (
@@ -393,24 +356,24 @@ class VerticalNavigation extends React.Component<Props, State> {
key={uuidv1()}
/>
)}
- {/* {this.props.isSettingsDialogOpened && (
+ {/* {isSettingsDialogOpened && (
<SettingsDialogAsync
- open={this.props.isSettingsDialogOpened}
- onClose={this.props.toggleSettingsDialog}
+ open={isSettingsDialogOpened}
+ onClose={toggleSettingsDialog}
/>
)} */}
<SettingsDialog
- open={this.props.isSettingsDialogOpened}
- onClose={this.props.toggleSettingsDialog}
+ open={isSettingsDialogOpened}
+ onClose={toggleSettingsDialog}
/>
<CreateFileDialog
key={uuidv1()}
- open={this.props.isCreateFileDialogOpened}
+ open={isCreateFileDialogOpened}
selectedDirectoryPath={
- this.state.selectedDirectoryPath || this.props.currentDirectory
+ this.state.selectedDirectoryPath || currentDirectory
}
chooseDirectoryPath={this.chooseDirectoryPath}
- onClose={this.props.toggleCreateFileDialog}
+ onClose={toggleCreateFileDialog}
/>
<SplitPane
split="vertical"
@@ -421,7 +384,7 @@ class VerticalNavigation extends React.Component<Props, State> {
>
<div style={this.styles.panel}>
<IconButton
- onClick={this.props.toggleAboutDialog}
+ onClick={toggleAboutDialog}
style={{ ...this.styles.button, marginTop: 10, marginBottom: 16 }}
title={i18n.t('core:aboutTitle')}
data-tid="aboutTagSpaces"
@@ -435,10 +398,10 @@ class VerticalNavigation extends React.Component<Props, State> {
alt="TagSpaces Logo"
/>
</IconButton>
- { !this.props.isReadOnlyMode && (
+ { !isReadOnlyMode && (
<IconButton
id="verticalNavButton"
- onClick={this.props.toggleCreateFileDialog}
+ onClick={toggleCreateFileDialog}
style={{ ...this.styles.button, marginBottom: 20 }}
title={i18n.t('core:createFileTitle')}
data-tid="locationManager"
@@ -449,10 +412,14 @@ class VerticalNavigation extends React.Component<Props, State> {
<IconButton
id="verticalNavButton"
onClick={() => {
- this.togglePanel(AppVerticalPanels.locationManager);
+ if (isLocationManagerPanelOpened) {
+ closeAllVerticalPanels();
+ } else {
+ openLocationManagerPanel();
+ }
}}
style={
- this.state.isLocationManagerVisible
+ isLocationManagerPanelOpened
? { ...this.styles.button, ...this.styles.selectedButton }
: this.styles.button
}
@@ -466,10 +433,14 @@ class VerticalNavigation extends React.Component<Props, State> {
title={i18n.t('core:tagGroupOperations')}
data-tid="tagLibrary"
onClick={() => {
- this.togglePanel(AppVerticalPanels.tagLibrary);
+ if (isTagLibraryPanelOpened) {
+ closeAllVerticalPanels();
+ } else {
+ openTagLibraryPanel();
+ }
}}
style={
- this.state.isTagLibraryVisible
+ isTagLibraryPanelOpened
? { ...this.styles.button, ...this.styles.selectedButton }
: this.styles.button
}
@@ -481,10 +452,14 @@ class VerticalNavigation extends React.Component<Props, State> {
title={i18n.t('core:searchTitle')}
data-tid="search"
onClick={() => {
- this.togglePanel(AppVerticalPanels.search);
+ if (isSearchPanelOpened) {
+ closeAllVerticalPanels();
+ } else {
+ openSearchPanel();
+ }
}}
style={
- this.state.isSearchVisible
+ isSearchPanelOpened
? { ...this.styles.button, ...this.styles.selectedButton }
: this.styles.button
}
@@ -495,17 +470,40 @@ class VerticalNavigation extends React.Component<Props, State> {
title={i18n.t('core:perspectiveManager')}
data-tid="perspectiveManager"
onClick={() => {
- this.togglePanel(AppVerticalPanels.perspectiveManager);
+ if (isPerspectivePanelOpened) {
+ closeAllVerticalPanels();
+ } else {
+ openPerspectivesPanel();
+ }
}}
disabled={false}
style={
- this.state.isPerspectiveManagerVisible
+ isPerspectivePanelOpened
? { ...this.styles.button, ...this.styles.selectedButton }
: this.styles.button
}
>
<PerspectivesIcon style={this.styles.buttonIcon} />
</IconButton> */}
+ <IconButton
+ id="verticalNavButton"
+ title={i18n.t('core:helpFeedback')}
+ data-tid="helpFeedback"
+ onClick={() => {
+ if (isHelpFeedbackPanelOpened) {
+ closeAllVerticalPanels();
+ } else {
+ openHelpFeedbackPanel();
+ }
+ }}
+ style={
+ isHelpFeedbackPanelOpened
+ ? { ...this.styles.button, ...this.styles.selectedButton }
+ : this.styles.button
+ }
+ >
+ <HelpIcon style={this.styles.buttonIcon} />
+ </IconButton>
{!Pro && (
<IconButton
id="verticalNavButton"
@@ -521,7 +519,7 @@ class VerticalNavigation extends React.Component<Props, State> {
id="verticalNavButton"
title={i18n.t('core:switchTheme')}
data-tid="switchTheme"
- onClick={this.props.switchTheme}
+ onClick={switchTheme}
style={{ ...this.styles.button, ...this.styles.themingButton }}
>
<ThemingIcon style={this.styles.buttonIcon} />
@@ -530,9 +528,9 @@ class VerticalNavigation extends React.Component<Props, State> {
id="verticalNavButton"
title={i18n.t('core:settings')}
data-tid="settings"
- onClick={this.props.toggleSettingsDialog}
+ onClick={toggleSettingsDialog}
style={
- this.props.isSettingsDialogOpened
+ isSettingsDialogOpened
? {
...this.styles.button,
...this.styles.settingsButton,
@@ -548,10 +546,11 @@ class VerticalNavigation extends React.Component<Props, State> {
</div>
{this.state.isManagementPanelVisible && (
<div style={this.styles.panel}>
- { this.state.isLocationManagerVisible && <LocationManager /> }
- { this.state.isTagLibraryVisible && <TagLibrary togglePanel={this.togglePanel} /> }
- { this.state.isSearchVisible && <Search /> }
- { this.state.isPerspectiveManagerVisible && <PerspectiveManager /> }
+ <LocationManager style={{ display: isLocationManagerPanelOpened ? 'block' : 'none' }} />
+ { isTagLibraryPanelOpened && <TagLibrary /> }
+ <Search style={{ display: isSearchPanelOpened ? 'block' : 'none' }} />
+ { isPerspectivesPanelOpened && <PerspectiveManager /> }
+ { isHelpFeedbackPanelOpened && <HelpFeedbackPanel /> }
</div>
)}
</SplitPane>
@@ -573,6 +572,11 @@ function mapStateToProps(state) {
isCreateDirectoryOpened: isCreateDirectoryOpened(state),
isCreateFileDialogOpened: isCreateFileDialogOpened(state),
isSelectDirectoryDialogOpened: isSelectDirectoryDialogOpened(state),
+ isLocationManagerPanelOpened: isLocationManagerPanelOpened(state),
+ isTagLibraryPanelOpened: isTagLibraryPanelOpened(state),
+ isSearchPanelOpened: isSearchPanelOpened(state),
+ isPerspectivesPanelOpened: isPerspectivesPanelOpened(state),
+ isHelpFeedbackPanelOpened: isHelpFeedbackPanelOpened(state),
currentDirectory: getDirectoryPath(state),
isReadOnlyMode: isReadOnlyMode(state)
};
@@ -591,6 +595,12 @@ function mapActionCreatorsToProps(dispatch) {
toggleThirdPartyLibsDialog: AppActions.toggleThirdPartyLibsDialog,
toggleAboutDialog: AppActions.toggleAboutDialog,
toggleEditTagDialog: AppActions.toggleEditTagDialog,
+ openLocationManagerPanel: AppActions.openLocationManagerPanel,
+ openTagLibraryPanel: AppActions.openTagLibraryPanel,
+ openSearchPanel: AppActions.openSearchPanel,
+ openPerspectivesPanel: AppActions.openPerspectivesPanel,
+ openHelpFeedbackPanel: AppActions.openHelpFeedbackPanel,
+ closeAllVerticalPanels: AppActions.closeAllVerticalPanels,
switchTheme: SettingsActions.switchTheme,
setFirstRun: SettingsActions.setFirstRun,
},
diff --git a/app/components/menus/EntryTagMenu.js b/app/components/menus/EntryTagMenu.js
index 92e855c6d..502c72be4 100644
--- a/app/components/menus/EntryTagMenu.js
+++ b/app/components/menus/EntryTagMenu.js
@@ -46,6 +46,7 @@ type Props = {
editTagForEntry: (path: string, tag: Tag) => void,
searchLocationIndex: (searchQuery: SearchQuery) => void,
maxSearchResults: number,
+ openSearchPanel: () => void,
isReadOnlyMode: boolean
};
@@ -67,7 +68,7 @@ const EntryTagMenu = (props: Props) => {
function showFilesWithThisTag() {
if (props.selectedTag) {
- // this.props.togglePanel(AppVerticalPanels.search);
+ props.openSearchPanel();
props.searchLocationIndex({
tagsAND: [props.selectedTag],
maxSearchResults: props.maxSearchResults
@@ -148,6 +149,7 @@ function mapStateToProps(state) {
function mapDispatchToProps(dispatch) {
return bindActionCreators({
searchLocationIndex: LocationIndexActions.searchLocationIndex,
+ openSearchPanel: AppActions.openSearchPanel,
toggleEditTagDialog: AppActions.toggleEditTagDialog,
}, dispatch);
}
diff --git a/app/components/menus/TagMenu.js b/app/components/menus/TagMenu.js
index 88f6f10bb..4bf306dc0 100644
--- a/app/components/menus/TagMenu.js
+++ b/app/components/menus/TagMenu.js
@@ -34,7 +34,7 @@ import { actions as LocationIndexActions } from '../../reducers/location-index';
import i18n from '../../services/i18n';
import { type SearchQuery } from '../../services/search';
import { getMaxSearchResults } from '../../reducers/settings';
-import { AppVerticalPanels } from '../VerticalNavigation';
+import { actions as AppActions } from '../../reducers/app';
const isTagLibraryReadOnly = (window.ExtTagLibrary && window.ExtTagLibrary.length > 0);
@@ -47,7 +47,7 @@ type Props = {
deleteTag: (uuid: string, tagGroupUuid: string) => void,
searchLocationIndex: (searchQuery: SearchQuery) => void,
editTag: () => void,
- togglePanel: () => void,
+ openSearchPanel: () => void,
maxSearchResults: number
};
@@ -62,7 +62,7 @@ const TagLibraryMenu = (props: Props) => {
function showFilesWithThisTag() {
if (props.selectedTag) {
- props.togglePanel(AppVerticalPanels.search);
+ props.openSearchPanel();
props.searchLocationIndex({
tagsAND: [props.selectedTag],
maxSearchResults: props.maxSearchResults
@@ -163,6 +163,7 @@ function mapStateToProps(state) {
function mapDispatchToProps(dispatch) {
return bindActionCreators({
+ openSearchPanel: AppActions.openSearchPanel,
searchLocationIndex: LocationIndexActions.searchLocationIndex,
}, dispatch);
}
diff --git a/app/containers/MainPage.js b/app/containers/MainPage.js
index 476eb0dc8..002a47aa8 100644
--- a/app/containers/MainPage.js
+++ b/app/containers/MainPage.js
@@ -32,9 +32,7 @@ import CloseIcon from '@material-ui/icons/Close';
import { HotKeys } from 'react-hotkeys';
import HTML5Backend, { NativeTypes } from 'react-dnd-html5-backend';
import { DragDropContext } from 'react-dnd';
-import VerticalNavigation, {
- AppVerticalPanels
-} from '../components/VerticalNavigation';
+import VerticalNavigation from '../components/VerticalNavigation';
import FolderContainer from '../components/FolderContainer';
import EntryContainer from '../components/EntryContainer';
import {
@@ -54,6 +52,11 @@ import {
isEntryInFullWidth,
isUpdateAvailable,
getDirectoryPath,
+ isLocationManagerPanelOpened,
+ isTagLibraryPanelOpened,
+ isSearchPanelOpened,
+ isPerspectivesPanelOpened,
+ isHelpFeedbackPanelOpened,
isReadOnlyMode
} from '../reducers/app';
import { actions as LocationIndexActions, isIndexing } from '../reducers/location-index';
@@ -137,11 +140,22 @@ type Props = {
openFileNatively: () => void, // needed by electron-menus
getNextFile: () => void, // needed by electron-menus
getPrevFile: () => void, // needed by electron-menus
+ openLocationManagerPanel: () => void,
+ openTagLibraryPanel: () => void,
+ openSearchPanel: () => void,
+ openPerspectivesPanel: () => void,
+ openHelpFeedbackPanel: () => void,
+ closeAllVerticalPanels: () => void,
leftSplitSize: number,
mainSplitSize: any,
toggleShowUnixHiddenEntries: () => void,
setLeftVerticalSplitSize: (splitSize: number) => void,
setMainVerticalSplitSize: (splitSize: string) => void,
+ isLocationManagerPanelOpened: boolean,
+ isTagLibraryPanelOpened: boolean,
+ isSearchPanelOpened: boolean,
+ isPerspectivesPanelOpened: boolean,
+ isHelpFeedbackPanelOpened: boolean,
directoryPath?: string,
showNotification: (
text: string,
@@ -155,7 +169,6 @@ type State = {
isManagementPanelVisible?: boolean, // optionality because of https://github.com/codemix/flow-runtime/issues/149
mainSplitSize?: any,
isDrawerOpened?: boolean,
- shouldTogglePanel?: string,
width?: number,
height?: number
};
@@ -165,7 +178,6 @@ class MainPage extends Component<Props, State> {
isManagementPanelVisible: true,
mainSplitSize: '100%',
isDrawerOpened: true,
- shouldTogglePanel: AppVerticalPanels.locationManager,
width: 1000,
height: 1000
};
@@ -177,12 +189,7 @@ class MainPage extends Component<Props, State> {
componentDidMount = () => {
window.addEventListener('resize', this.updateDimensions);
// this.setupDesktopMenu();
- buildDesktopMenu({
- ...this.props,
- toggleTagLibrary: this.toggleTagLibrary,
- toggleLocationManager: this.toggleLocationManager,
- toggleSearch: this.toggleSearch,
- });
+ buildDesktopMenu(this.props);
buildTrayIconMenu(this.props);
};
@@ -198,6 +205,9 @@ class MainPage extends Component<Props, State> {
// isManagementPanelVisible: !nextProps.isEntryInFullWidth
});
} else if (isEntryOpenedFullWidthChanged) {
+ if (nextProps.isEntryInFullWidth) {
+ this.props.closeAllVerticalPanels();
+ }
this.setState({
mainSplitSize: nextProps.isEntryInFullWidth ? '0%' : this.props.mainSplitSize,
isManagementPanelVisible: !nextProps.isEntryInFullWidth
@@ -213,24 +223,28 @@ class MainPage extends Component<Props, State> {
mainSplitSize: '100%'
});
}
+ if (nextProps.isLocationManagerPanelOpened ||
+ nextProps.isTagLibraryPanelOpened ||
+ nextProps.isSearchPanelOpened ||
+ nextProps.isPerspectivesPanelOpened ||
+ nextProps.isHelpFeedbackPanelOpened) {
+ this.setManagementPanelVisibility(true);
+ }
+
+ if (!nextProps.isLocationManagerPanelOpened &&
+ !nextProps.isTagLibraryPanelOpened &&
+ !nextProps.isSearchPanelOpened &&
+ !nextProps.isPerspectivesPanelOpened &&
+ !nextProps.isHelpFeedbackPanelOpened) {
+ this.setManagementPanelVisibility(false);
+ }
+
}
componentWillUnmount() {
window.removeEventListener('resize', this.updateDimensions);
}
- toggleLocationManager = () => {
- this.setState({ shouldTogglePanel: AppVerticalPanels.locationManager });
- };
-
- toggleTagLibrary = () => {
- this.setState({ shouldTogglePanel: AppVerticalPanels.tagLibrary });
- };
-
- toggleSearch = () => {
- this.setState({ shouldTogglePanel: AppVerticalPanels.search });
- };
-
updateDimensions = () => {
const width = window.innerWidth || document.documentElement.clientWidth || body.clientWidth;
const height = window.innerHeight || document.documentElement.clientHeight || body.clientHeight;
@@ -374,11 +388,11 @@ class MainPage extends Component<Props, State> {
keyBindingHandlers = {
toggleShowHiddenEntries: this.props.toggleShowUnixHiddenEntries,
- showFolderNavigator: this.toggleLocationManager,
- showTagLibrary: this.toggleTagLibrary,
- openSearch: this.toggleSearch,
+ showFolderNavigator: this.props.openLocationManagerPanel,
+ showTagLibrary: this.props.openTagLibraryPanel,
+ openSearch: this.props.openSearchPanel,
showHelp: () => {
- PlatformIO.openFile('https://docs.tagspaces.org');
+ PlatformIO.openFile(AppConfig.documentationLinks.general);
},
};
@@ -411,10 +425,7 @@ class MainPage extends Component<Props, State> {
bufferedLeftSplitResize(() => this.props.setLeftVerticalSplitSize(size));
}}
>
- <VerticalNavigation
- setManagementPanelVisibility={this.setManagementPanelVisibility}
- shouldTogglePanel={this.state.shouldTogglePanel}
- />
+ <VerticalNavigation />
<SplitPane
split="vertical"
minSize="200"
@@ -434,7 +445,6 @@ class MainPage extends Component<Props, State> {
<FolderContainer
windowHeight={this.state.height}
windowWidth={this.state.width}
- toggleSearchPanel={this.toggleSearch}
/>
<EntryContainer />
</SplitPane>
@@ -448,10 +458,7 @@ class MainPage extends Component<Props, State> {
paper: classes.drawerPaper
}}
>
- <VerticalNavigation
- setManagementPanelVisibility={this.setManagementPanelVisibility}
- shouldTogglePanel={this.state.shouldTogglePanel}
- />
+ <VerticalNavigation />
</Drawer>
<SplitPane
className={classNames(
@@ -573,6 +580,11 @@ function mapStateToProps(state) {
isUpdateAvailable: isUpdateAvailable(state),
lastPublishedVersion: getLastPublishedVersion(state),
notificationStatus: getNotificationStatus(state),
+ isLocationManagerPanelOpened: isLocationManagerPanelOpened(state),
+ isTagLibraryPanelOpened: isTagLibraryPanelOpened(state),
+ isSearchPanelOpened: isSearchPanelOpened(state),
+ isPerspectivesPanelOpened: isPerspectivesPanelOpened(state),
+ isHelpFeedbackPanelOpened: isHelpFeedbackPanelOpened(state),
directoryPath: getDirectoryPath(state),
};
}
@@ -606,6 +618,12 @@ function mapDispatchToProps(dispatch) {
setMainVerticalSplitSize: SettingsActions.setMainVerticalSplitSize,
showNotification: AppActions.showNotification,
reflectCreateEntry: AppActions.reflectCreateEntry,
+ openLocationManagerPanel: AppActions.openLocationManagerPanel,
+ openTagLibraryPanel: AppActions.openTagLibraryPanel,
+ openSearchPanel: AppActions.openSearchPanel,
+ openPerspectivesPanel: AppActions.openPerspectivesPanel,
+ openHelpFeedbackPanel: AppActions.openHelpFeedbackPanel,
+ closeAllVerticalPanels: AppActions.closeAllVerticalPanels
}, dispatch);
}
diff --git a/app/reducers/app.js b/app/reducers/app.js
index 6461877ef..b22b7ec50 100644
--- a/app/reducers/app.js
+++ b/app/reducers/app.js
@@ -81,6 +81,12 @@ export const types = {
TOGGLE_CREATE_DIRECTORY_DIALOG: 'APP/TOGGLE_CREATE_DIRECTORY_DIALOG',
TOGGLE_CREATE_FILE_DIALOG: 'APP/TOGGLE_CREATE_FILE_DIALOG',
TOGGLE_SELECT_DIRECTORY_DIALOG: 'APP/TOGGLE_SELECT_DIRECTORY_DIALOG',
+ OPEN_LOCATIONMANAGER_PANEL: 'APP/OPEN_LOCATIONMANAGER_PANEL',
+ OPEN_TAGLIBRARY_PANEL: 'APP/OPEN_TAGLIBRARY_PANEL',
+ OPEN_SEARCH_PANEL: 'APP/OPEN_SEARCH_PANEL',
+ OPEN_PERSPECTIVES_PANEL: 'APP/OPEN_PERSPECTIVES_PANEL',
+ OPEN_HELPFEEDBACK_PANEL: 'APP/OPEN_HELPFEEDBACK_PANEL',
+ CLOSE_ALLVERTICAL_PANELS: 'APP/CLOSE_ALLVERTICAL_PANELS',
REFLECT_DELETE_ENTRY: 'APP/REFLECT_DELETE_ENTRY',
REFLECT_RENAME_ENTRY: 'APP/REFLECT_RENAME_ENTRY',
REFLECT_CREATE_ENTRY: 'APP/REFLECT_CREATE_ENTRY',
@@ -143,7 +149,12 @@ export const initialState = {
lastSelectedEntry: null,
selectedEntries: [],
isEntryInFullWidth: false,
- isGeneratingThumbs: false
+ isGeneratingThumbs: false,
+ locationManagerPanelOpened: true,
+ tagLibraryPanelOpened: false,
+ searchPanelOpened: false,
+ perspectivesPanelOpened: false,
+ helpFeedbackPanelOpened: false,
};
// The state described here will not be persisted
@@ -422,6 +433,66 @@ export default (state: Object = initialState, action: Object) => {
isEntryInFullWidth: false
};
}
+ case types.OPEN_LOCATIONMANAGER_PANEL: {
+ return {
+ ...state,
+ locationManagerPanelOpened: true,
+ tagLibraryPanelOpened: false,
+ searchPanelOpened: false,
+ perspectivesPanelOpened: false,
+ helpFeedbackPanelOpened: false,
+ };
+ }
+ case types.OPEN_TAGLIBRARY_PANEL: {
+ return {
+ ...state,
+ locationManagerPanelOpened: false,
+ tagLibraryPanelOpened: true,
+ searchPanelOpened: false,
+ perspectivesPanelOpened: false,
+ helpFeedbackPanelOpened: false,
+ };
+ }
+ case types.OPEN_SEARCH_PANEL: {
+ return {
+ ...state,
+ locationManagerPanelOpened: false,
+ tagLibraryPanelOpened: false,
+ searchPanelOpened: true,
+ perspectivesPanelOpened: false,
+ helpFeedbackPanelOpened: false,
+ };
+ }
+ case types.OPEN_PERSPECTIVES_PANEL: {
+ return {
+ ...state,
+ locationManagerPanelOpened: false,
+ tagLibraryPanelOpened: false,
+ searchPanelOpened: false,
+ perspectivesPanelOpened: true,
+ helpFeedbackPanelOpened: false,
+ };
+ }
+ case types.OPEN_HELPFEEDBACK_PANEL: {
+ return {
+ ...state,
+ locationManagerPanelOpened: false,
+ tagLibraryPanelOpened: false,
+ searchPanelOpened: false,
+ perspectivesPanelOpened: false,
+ helpFeedbackPanelOpened: true,
+ };
+ }
+ case types.CLOSE_ALLVERTICAL_PANELS: {
+ return {
+ ...state,
+ locationManagerPanelOpened: false,
+ tagLibraryPanelOpened: false,
+ searchPanelOpened: false,
+ perspectivesPanelOpened: false,
+ helpFeedbackPanelOpened: false,
+ };
+ }
default: {
return state;
}
@@ -473,6 +544,12 @@ export const actions = {
toggleCreateDirectoryDialog: () => ({ type: types.TOGGLE_CREATE_DIRECTORY_DIALOG }),
toggleCreateFileDialog: () => ({ type: types.TOGGLE_CREATE_FILE_DIALOG }),
toggleSelectDirectoryDialog: () => ({ type: types.TOGGLE_SELECT_DIRECTORY_DIALOG }),
+ openLocationManagerPanel: () => ({ type: types.OPEN_LOCATIONMANAGER_PANEL }),
+ openTagLibraryPanel: () => ({ type: types.OPEN_TAGLIBRARY_PANEL }),
+ openSearchPanel: () => ({ type: types.OPEN_SEARCH_PANEL }),
+ openPerspectivesPanel: () => ({ type: types.OPEN_PERSPECTIVES_PANEL }),
+ openHelpFeedbackPanel: () => ({ type: types.OPEN_HELPFEEDBACK_PANEL }),
+ closeAllVerticalPanels: () => ({ type: types.CLOSE_ALLVERTICAL_PANELS }),
loadParentDirectoryContent: () => (
dispatch: (actions: Object) => void,
getState: () => Object
@@ -1295,3 +1372,8 @@ export const getSearchResultCount = (state: Object) => state.app.currentDirector
export const getCurrentLocationId = (state: Object) => state.app.currentLocationId;
export const isEntryInFullWidth = (state: Object) => state.app.isEntryInFullWidth;
export const isLoading = (state: Object) => state.app.isLoading;
+export const isLocationManagerPanelOpened = (state: Object) => state.app.locationManagerPanelOpened;
+export const isTagLibraryPanelOpened = (state: Object) => state.app.tagLibraryPanelOpened;
+export const isSearchPanelOpened = (state: Object) => state.app.searchPanelOpened;
+export const isPerspectivesPanelOpened = (state: Object) => state.app.perspectivesPanelOpened;
+export const isHelpFeedbackPanelOpened = (state: Object) => state.app.helpFeedbackPanelOpened;
diff --git a/app/services/electron-menus.js b/app/services/electron-menus.js
index a24994d54..633768e91 100644
--- a/app/services/electron-menus.js
+++ b/app/services/electron-menus.js
@@ -179,21 +179,21 @@ export default function buildDesktopMenu(mainPageProps: Object) {
label: i18n.t('core:showLocationManager'),
accelerator: mainPageProps.keyBindings.showLocationManager,
click: () => {
- mainPageProps.toggleLocationManager();
+ mainPageProps.openLocationManagerPanel();
}
},
{
label: i18n.t('core:showTagLibrary'),
accelerator: mainPageProps.keyBindings.showTagLibrary,
click: () => {
- mainPageProps.toggleTagLibrary();
+ mainPageProps.openTagLibraryPanel();
}
},
{
label: i18n.t('core:showSearch'),
accelerator: mainPageProps.keyBindings.showSearch,
click: () => {
- mainPageProps.toggleSearch();
+ mainPageProps.openSearchPanel();
}
},
{