Skip to content

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

refactoring and migrate to functional components (#1349)

Stanimir766c523d92ec
diff --git a/app/components/FolderContainer.tsx b/app/components/FolderContainer.tsx
index 82f04896c..2088366f2 100644
--- a/app/components/FolderContainer.tsx
+++ b/app/components/FolderContainer.tsx
@@ -199,7 +199,6 @@ interface Props {
removeAllTags: () => void;
editTagForEntry: () => void;
openFileNatively: (path: string) => void;
- toggleCreateFileDialog: () => void;
// deleteFile: () => void;
renameFile: () => void;
openDirectory: () => void;
@@ -545,7 +544,6 @@ const FolderContainer = (props: Props) => {
openDirectory={props.openDirectory}
reflectCreateEntry={props.reflectCreateEntry}
openFsEntry={props.openFsEntry}
- toggleCreateFileDialog={props.toggleCreateFileDialog}
switchPerspective={switchPerspective}
isReadOnlyMode={props.isReadOnlyMode}
/>
@@ -589,7 +587,6 @@ function mapActionCreatorsToProps(dispatch) {
removeAllTags: TaggingActions.removeAllTags,
editTagForEntry: TaggingActions.editTagForEntry,
openFileNatively: AppActions.openFileNatively,
- toggleCreateFileDialog: AppActions.toggleCreateFileDialog,
// deleteFile: AppActions.deleteFile,
renameFile: AppActions.renameFile,
openDirectory: AppActions.openDirectory,
diff --git a/app/components/MobileNavigation.tsx b/app/components/MobileNavigation.tsx
index ecdd5ba5a..25893c1e2 100644
--- a/app/components/MobileNavigation.tsx
+++ b/app/components/MobileNavigation.tsx
@@ -16,7 +16,7 @@
*
*/
-import React from 'react';
+import React, { useState } from 'react';
import uuidv1 from 'uuid';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
@@ -109,180 +109,165 @@ interface Props {
user: CognitoUserInterface;
}
-interface State {
- isProTeaserVisible: boolean;
-}
-
-class MobileNavigation extends React.Component<Props, State> {
- state = {
- isProTeaserVisible: false
- };
+const MobileNavigation = (props: Props) => {
+ const [isProTeaserVisible, setIsProTeaserVisible] = useState<boolean>(false);
- toggleProTeaser = () => {
- this.setState(prevState => ({
- isProTeaserVisible: !prevState.isProTeaserVisible
- }));
+ const toggleProTeaser = () => {
+ setIsProTeaserVisible(!isProTeaserVisible);
};
- render() {
- const {
- classes,
- isLocationManagerPanelOpened,
- isTagLibraryPanelOpened,
- isSearchPanelOpened,
- isHelpFeedbackPanelOpened,
- isReadOnlyMode,
- toggleCreateFileDialog,
- toggleOnboardingDialog,
- toggleSettingsDialog,
- toggleKeysDialog,
- toggleAboutDialog,
- openLocationManagerPanel,
- openTagLibraryPanel,
- openSearchPanel,
- openHelpFeedbackPanel,
- showNotification,
- hideDrawer,
- openFileNatively,
- openURLExternally,
- directoryPath,
- user
- } = this.props;
- return (
- <div style={{ height: '100%' }}>
- <style>
- {`
+ const {
+ classes,
+ toggleCreateFileDialog,
+ toggleOnboardingDialog,
+ toggleSettingsDialog,
+ toggleKeysDialog,
+ toggleAboutDialog,
+ openLocationManagerPanel,
+ openTagLibraryPanel,
+ openSearchPanel,
+ openHelpFeedbackPanel,
+ showNotification,
+ hideDrawer,
+ openFileNatively,
+ openURLExternally,
+ directoryPath,
+ user
+ } = props;
+ return (
+ <div style={{ height: '100%' }}>
+ <style>
+ {`
#verticalNavButton:hover {
background-color: #880E4F;
}
`}
- </style>
- <div style={{ width: 300, maxWidth: 300, height: 'calc(100% - 60px)' }}>
- {isLocationManagerPanelOpened && (
- <LocationManager hideDrawer={hideDrawer} />
- )}
- {isTagLibraryPanelOpened && <TagLibrary />}
- {isSearchPanelOpened && <Search hideDrawer={hideDrawer} />}
- {/* {isPerspectivesPanelOpened && <PerspectiveManager />} */}
- {isHelpFeedbackPanelOpened && (
- <HelpFeedbackPanel
- openFileNatively={openFileNatively}
- openURLExternally={openURLExternally}
- toggleAboutDialog={toggleAboutDialog}
- toggleKeysDialog={toggleKeysDialog}
- toggleOnboardingDialog={toggleOnboardingDialog}
- toggleProTeaser={this.toggleProTeaser}
- />
- )}
- </div>
- <div className={classes.bottomToolbar}>
- <Tooltip title={i18n.t('core:settings')}>
- <IconButton
+ </style>
+ <div style={{ width: 300, maxWidth: 300, height: 'calc(100% - 60px)' }}>
+ {props.isLocationManagerPanelOpened && (
+ <LocationManager hideDrawer={hideDrawer} />
+ )}
+ {props.isTagLibraryPanelOpened && <TagLibrary />}
+ {props.isSearchPanelOpened && <Search hideDrawer={hideDrawer} />}
+ {/* {isPerspectivesPanelOpened && <PerspectiveManager />} */}
+ {props.isHelpFeedbackPanelOpened && (
+ <HelpFeedbackPanel
+ openFileNatively={openFileNatively}
+ openURLExternally={openURLExternally}
+ toggleAboutDialog={toggleAboutDialog}
+ toggleKeysDialog={toggleKeysDialog}
+ toggleOnboardingDialog={toggleOnboardingDialog}
+ toggleProTeaser={toggleProTeaser}
+ />
+ )}
+ </div>
+ <div className={classes.bottomToolbar}>
+ <Tooltip title={i18n.t('core:settings')}>
+ <IconButton
+ id="verticalNavButton"
+ data-tid="settings"
+ onClick={() => {
+ toggleSettingsDialog();
+ hideDrawer();
+ }}
+ style={{ marginTop: -15, marginRight: 2 }}
+ >
+ <SettingsIcon className={classes.buttonIcon} />
+ </IconButton>
+ </Tooltip>
+ <ToggleButtonGroup exclusive>
+ <Tooltip title={i18n.t('core:locationManager')}>
+ <ToggleButton
id="verticalNavButton"
- data-tid="settings"
- onClick={() => {
- toggleSettingsDialog();
- hideDrawer();
- }}
- style={{ marginTop: -15, marginRight: 2 }}
+ onClick={openLocationManagerPanel}
+ className={
+ props.isLocationManagerPanelOpened
+ ? classNames(classes.button, classes.selectedButton)
+ : classes.button
+ }
+ data-tid="locationManager"
>
- <SettingsIcon className={classes.buttonIcon} />
- </IconButton>
+ <LocationsIcon className={classes.buttonIcon} />
+ </ToggleButton>
</Tooltip>
- <ToggleButtonGroup exclusive>
- <Tooltip title={i18n.t('core:locationManager')}>
- <ToggleButton
- id="verticalNavButton"
- onClick={openLocationManagerPanel}
- className={
- isLocationManagerPanelOpened
- ? classNames(classes.button, classes.selectedButton)
- : classes.button
- }
- data-tid="locationManager"
- >
- <LocationsIcon className={classes.buttonIcon} />
- </ToggleButton>
- </Tooltip>
- <Tooltip title={i18n.t('core:tagLibrary')}>
- <ToggleButton
- id="verticalNavButton"
- data-tid="tagLibrary"
- onClick={openTagLibraryPanel}
- className={
- isTagLibraryPanelOpened
- ? classNames(classes.button, classes.selectedButton)
- : classes.button
- }
- >
- <TagLibraryIcon className={classes.buttonIcon} />
- </ToggleButton>
- </Tooltip>
- <Tooltip title={i18n.t('core:searchTitle')}>
- <ToggleButton
- id="verticalNavButton"
- data-tid="search"
- onClick={openSearchPanel}
- className={
- isSearchPanelOpened
- ? classNames(classes.button, classes.selectedButton)
- : classes.button
- }
- >
- <SearchIcon className={classes.buttonIcon} />
- </ToggleButton>
- </Tooltip>
- <Tooltip title={i18n.t('core:helpFeedback')}>
- <ToggleButton
- id="verticalNavButton"
- data-tid="helpFeedback"
- onClick={openHelpFeedbackPanel}
- className={
- isHelpFeedbackPanelOpened
- ? classNames(classes.button, classes.selectedButton)
- : classes.button
- }
- >
- {user ? (
- <AccountCircleIcon className={classes.buttonIcon} />
- ) : (
- <HelpIcon className={classes.buttonIcon} />
- )}
- </ToggleButton>
- </Tooltip>
- </ToggleButtonGroup>
- <Tooltip title={i18n.t('core:createFileTitle')}>
- <IconButton
+ <Tooltip title={i18n.t('core:tagLibrary')}>
+ <ToggleButton
id="verticalNavButton"
- onClick={() => {
- if (isReadOnlyMode || !directoryPath) {
- showNotification(
- 'You are in read-only mode or there is no opened location'
- );
- } else {
- toggleCreateFileDialog();
- hideDrawer();
- }
- }}
- style={{ marginTop: -15, marginLeft: 2 }}
- data-tid="locationManager"
+ data-tid="tagLibrary"
+ onClick={openTagLibraryPanel}
+ className={
+ props.isTagLibraryPanelOpened
+ ? classNames(classes.button, classes.selectedButton)
+ : classes.button
+ }
>
- <NewFileIcon color="primary" />
- </IconButton>
+ <TagLibraryIcon className={classes.buttonIcon} />
+ </ToggleButton>
</Tooltip>
- {this.state.isProTeaserVisible && (
- <ProTeaserDialogAsync
- open={this.state.isProTeaserVisible}
- onClose={this.toggleProTeaser}
- openURLExternally={openURLExternally}
- key={uuidv1()}
- />
- )}
- </div>
+ <Tooltip title={i18n.t('core:searchTitle')}>
+ <ToggleButton
+ id="verticalNavButton"
+ data-tid="search"
+ onClick={openSearchPanel}
+ className={
+ props.isSearchPanelOpened
+ ? classNames(classes.button, classes.selectedButton)
+ : classes.button
+ }
+ >
+ <SearchIcon className={classes.buttonIcon} />
+ </ToggleButton>
+ </Tooltip>
+ <Tooltip title={i18n.t('core:helpFeedback')}>
+ <ToggleButton
+ id="verticalNavButton"
+ data-tid="helpFeedback"
+ onClick={openHelpFeedbackPanel}
+ className={
+ props.isHelpFeedbackPanelOpened
+ ? classNames(classes.button, classes.selectedButton)
+ : classes.button
+ }
+ >
+ {user ? (
+ <AccountCircleIcon className={classes.buttonIcon} />
+ ) : (
+ <HelpIcon className={classes.buttonIcon} />
+ )}
+ </ToggleButton>
+ </Tooltip>
+ </ToggleButtonGroup>
+ <Tooltip title={i18n.t('core:createFileTitle')}>
+ <IconButton
+ id="verticalNavButton"
+ onClick={() => {
+ if (props.isReadOnlyMode || !directoryPath) {
+ showNotification(
+ 'You are in read-only mode or there is no opened location'
+ );
+ } else {
+ toggleCreateFileDialog();
+ hideDrawer();
+ }
+ }}
+ style={{ marginTop: -15, marginLeft: 2 }}
+ data-tid="locationManager"
+ >
+ <NewFileIcon color="primary" />
+ </IconButton>
+ </Tooltip>
+ {isProTeaserVisible && (
+ <ProTeaserDialogAsync
+ open={isProTeaserVisible}
+ onClose={toggleProTeaser}
+ openURLExternally={openURLExternally}
+ key={uuidv1()} // TODO rethink to remove this
+ />
+ )}
</div>
- );
- }
-}
+ </div>
+ );
+};
function mapStateToProps(state) {
return {
diff --git a/app/components/PerspectiveManager.tsx b/app/components/PerspectiveManager.tsx
index 6fd8ff3b7..ca4412b76 100644
--- a/app/components/PerspectiveManager.tsx
+++ b/app/components/PerspectiveManager.tsx
@@ -26,17 +26,15 @@ interface Props {
style: any;
}
-class PerspectiveManager extends React.Component<Props> {
- render() {
- const { classes } = this.props;
+const PerspectiveManager = (props: Props) => {
+ const { classes } = props;
- return (
- <div className={classes.panel} style={this.props.style}>
- <Typography className={classes.panelTitle}>Perspectives</Typography>
- </div>
- );
- }
+ return (
+ <div className={classes.panel} style={props.style}>
+ <Typography className={classes.panelTitle}>Perspectives</Typography>
+ </div>
+ );
// <Button onClick={() => history.push('/login')}>Login</Button>
-}
+};
export default withStyles(styles)(PerspectiveManager);
diff --git a/app/components/VerticalNavigation.tsx b/app/components/VerticalNavigation.tsx
index 6586fe896..7c14c83ef 100644
--- a/app/components/VerticalNavigation.tsx
+++ b/app/components/VerticalNavigation.tsx
@@ -16,7 +16,7 @@
*
*/
-import React from 'react';
+import React, { useState } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import uuidv1 from 'uuid';
@@ -137,176 +137,164 @@ interface Props {
user: CognitoUserInterface;
}
-interface State {
- isProTeaserVisible: boolean;
-}
-
-class VerticalNavigation extends React.Component<Props, State> {
- state = {
- isProTeaserVisible: false
- };
+const VerticalNavigation = (props: Props) => {
+ const [isProTeaserVisible, setIsProTeaserVisible] = useState<boolean>(false);
- toggleProTeaser = () => {
- this.setState(prevState => ({
- isProTeaserVisible: !prevState.isProTeaserVisible
- }));
+ const toggleProTeaser = () => {
+ setIsProTeaserVisible(!isProTeaserVisible);
};
- getProgressValue() {
- const objProgress = this.props.progress.find(
+ const getProgressValue = () => {
+ const objProgress = props.progress.find(
fileProgress => fileProgress.progress < 100 && fileProgress.progress > -1
);
if (objProgress !== undefined) {
return objProgress.progress;
}
return 100;
- }
+ };
- render() {
- const {
- classes,
- isLocationManagerPanelOpened,
- isTagLibraryPanelOpened,
- isSearchPanelOpened,
- isSettingsDialogOpened,
- isHelpFeedbackPanelOpened,
- isReadOnlyMode,
- toggleCreateFileDialog,
- toggleAboutDialog,
- toggleOnboardingDialog,
- toggleSettingsDialog,
- toggleKeysDialog,
- openLocationManagerPanel,
- openTagLibraryPanel,
- openSearchPanel,
- openHelpFeedbackPanel,
- closeAllVerticalPanels,
- switchTheme,
- openFileNatively,
- openURLExternally,
- showNotification,
- directoryPath,
- theme,
- user
- } = this.props;
- return (
- <div>
- <style>
- {`
+ const {
+ classes,
+ isTagLibraryPanelOpened,
+ isSearchPanelOpened,
+ isHelpFeedbackPanelOpened,
+ toggleCreateFileDialog,
+ toggleAboutDialog,
+ toggleOnboardingDialog,
+ toggleSettingsDialog,
+ toggleKeysDialog,
+ openLocationManagerPanel,
+ openTagLibraryPanel,
+ openSearchPanel,
+ openHelpFeedbackPanel,
+ closeAllVerticalPanels,
+ switchTheme,
+ openFileNatively,
+ openURLExternally,
+ showNotification,
+ directoryPath,
+ theme,
+ user
+ } = props;
+ return (
+ <div>
+ <style>
+ {`
#verticalNavButton:hover {
border-radius: 0;
background-color: ${AppConfig.sidebarSelectionColor}
}
`}
- </style>
- {this.state.isProTeaserVisible && (
- <ProTeaserDialogAsync
- open={this.state.isProTeaserVisible}
- onClose={this.toggleProTeaser}
- openURLExternally={openURLExternally}
- key={uuidv1()}
- />
- )}
- <SplitPane
- split="vertical"
- minSize={44}
- maxSize={44}
- defaultSize={44}
- resizerStyle={{ backgroundColor: theme.palette.divider }}
- >
- <div className={classes.panel}>
- <IconButton
- onClick={toggleAboutDialog}
- className={classes.button}
- style={{ marginTop: 10, marginBottom: 16 }}
- title={i18n.t('core:aboutTitle')}
- data-tid="aboutTagSpaces"
- >
- <img
- className={classes.buttonIcon}
- style={{
- color: this.props.theme.palette.text.primary
- }}
- src={LogoIcon}
- alt="TagSpaces Logo"
- />
- </IconButton>
- <IconButton
- id="verticalNavButton"
- onClick={() => {
- if (isReadOnlyMode || !directoryPath) {
- showNotification(
- 'You are in read-only mode or there is no opened location'
- );
- } else {
- toggleCreateFileDialog();
- }
- }}
- className={classes.button}
- style={{ marginBottom: 20 }}
- title={i18n.t('core:createFileTitle')}
- data-tid="locationManager"
- >
- <NewFileIcon className={classes.buttonIcon} />
- </IconButton>
- <IconButton
- id="verticalNavButton"
- onClick={() => {
- if (isLocationManagerPanelOpened) {
- closeAllVerticalPanels();
- } else {
- openLocationManagerPanel();
- }
+ </style>
+ {isProTeaserVisible && (
+ <ProTeaserDialogAsync
+ open={isProTeaserVisible}
+ onClose={toggleProTeaser}
+ openURLExternally={openURLExternally}
+ key={uuidv1()}
+ />
+ )}
+ <SplitPane
+ split="vertical"
+ minSize={44}
+ maxSize={44}
+ defaultSize={44}
+ resizerStyle={{ backgroundColor: theme.palette.divider }}
+ >
+ <div className={classes.panel}>
+ <IconButton
+ onClick={toggleAboutDialog}
+ className={classes.button}
+ style={{ marginTop: 10, marginBottom: 16 }}
+ title={i18n.t('core:aboutTitle')}
+ data-tid="aboutTagSpaces"
+ >
+ <img
+ className={classes.buttonIcon}
+ style={{
+ color: props.theme.palette.text.primary
}}
- className={
- isLocationManagerPanelOpened
- ? [classes.button, classes.selectedButton].join(' ')
- : classes.button
+ src={LogoIcon}
+ alt="TagSpaces Logo"
+ />
+ </IconButton>
+ <IconButton
+ id="verticalNavButton"
+ onClick={() => {
+ if (props.isReadOnlyMode || !directoryPath) {
+ showNotification(
+ 'You are in read-only mode or there is no opened location'
+ );
+ } else {
+ toggleCreateFileDialog();
}
- title={i18n.t('core:locationManager')}
- data-tid="locationManagerPanel"
- >
- <LocationsIcon className={classes.buttonIcon} />
- </IconButton>
- <IconButton
- id="verticalNavButton"
- title={i18n.t('core:tagGroupOperations')}
- data-tid="tagLibrary"
- onClick={() => {
- if (isTagLibraryPanelOpened) {
- closeAllVerticalPanels();
- } else {
- openTagLibraryPanel();
- }
- }}
- className={
- isTagLibraryPanelOpened
- ? [classes.button, classes.selectedButton].join(' ')
- : classes.button
+ }}
+ className={classes.button}
+ style={{ marginBottom: 20 }}
+ title={i18n.t('core:createFileTitle')}
+ data-tid="locationManager"
+ >
+ <NewFileIcon className={classes.buttonIcon} />
+ </IconButton>
+ <IconButton
+ id="verticalNavButton"
+ onClick={() => {
+ if (props.isLocationManagerPanelOpened) {
+ closeAllVerticalPanels();
+ } else {
+ openLocationManagerPanel();
}
- >
- <TagLibraryIcon className={classes.buttonIcon} />
- </IconButton>
- <IconButton
- id="verticalNavButton"
- title={i18n.t('core:searchTitle')}
- data-tid="search"
- onClick={() => {
- if (isSearchPanelOpened) {
- closeAllVerticalPanels();
- } else {
- openSearchPanel();
- }
- }}
- className={
- isSearchPanelOpened
- ? [classes.button, classes.selectedButton].join(' ')
- : classes.button
+ }}
+ className={
+ props.isLocationManagerPanelOpened
+ ? [classes.button, classes.selectedButton].join(' ')
+ : classes.button
+ }
+ title={i18n.t('core:locationManager')}
+ data-tid="locationManagerPanel"
+ >
+ <LocationsIcon className={classes.buttonIcon} />
+ </IconButton>
+ <IconButton
+ id="verticalNavButton"
+ title={i18n.t('core:tagGroupOperations')}
+ data-tid="tagLibrary"
+ onClick={() => {
+ if (isTagLibraryPanelOpened) {
+ closeAllVerticalPanels();
+ } else {
+ openTagLibraryPanel();
}
- >
- <SearchIcon className={classes.buttonIcon} />
- </IconButton>
- {/* <IconButton
+ }}
+ className={
+ isTagLibraryPanelOpened
+ ? [classes.button, classes.selectedButton].join(' ')
+ : classes.button
+ }
+ >
+ <TagLibraryIcon className={classes.buttonIcon} />
+ </IconButton>
+ <IconButton
+ id="verticalNavButton"
+ title={i18n.t('core:searchTitle')}
+ data-tid="search"
+ onClick={() => {
+ if (isSearchPanelOpened) {
+ closeAllVerticalPanels();
+ } else {
+ openSearchPanel();
+ }
+ }}
+ className={
+ isSearchPanelOpened
+ ? [classes.button, classes.selectedButton].join(' ')
+ : classes.button
+ }
+ >
+ <SearchIcon className={classes.buttonIcon} />
+ </IconButton>
+ {/* <IconButton
title={i18n.t('core:perspectiveManager')}
data-tid="perspectiveManager"
onClick={() => {
@@ -325,101 +313,100 @@ class VerticalNavigation extends React.Component<Props, State> {
>
<PerspectivesIcon style={classes.buttonIcon} />
</IconButton> */}
- <IconButton
- id="verticalNavButton"
- title={i18n.t('core:helpFeedback')}
- data-tid="helpFeedback"
- onClick={() => {
- if (isHelpFeedbackPanelOpened) {
- closeAllVerticalPanels();
- } else {
- openHelpFeedbackPanel();
- }
- }}
- className={
- isHelpFeedbackPanelOpened
- ? [classes.button, classes.selectedButton].join(' ')
- : classes.button
+ <IconButton
+ id="verticalNavButton"
+ title={i18n.t('core:helpFeedback')}
+ data-tid="helpFeedback"
+ onClick={() => {
+ if (isHelpFeedbackPanelOpened) {
+ closeAllVerticalPanels();
+ } else {
+ openHelpFeedbackPanel();
}
- >
- {user ? (
- <AccountCircleIcon className={classes.buttonIcon} />
- ) : (
- <HelpIcon className={classes.buttonIcon} />
- )}
- </IconButton>
- {!Pro && (
- <IconButton
- id="verticalNavButton"
- title={i18n.t('core:upgradeToPro')}
- data-tid="upgradeToPro"
- onClick={this.toggleProTeaser}
- // @ts-ignore
- className={[classes.button, classes.upgradeButton].join(' ')}
- >
- <UpgradeIcon className={classes.buttonIcon} />
- </IconButton>
- )}
- {this.props.progress && this.props.progress.length > 0 && (
- <IconButton
- id="progressButton"
- title={i18n.t('core:progress')}
- data-tid="uploadProgress"
- onClick={() => this.props.toggleUploadDialog()}
- // @ts-ignore
- className={[classes.button, classes.upgradeButton].join(' ')}
- >
- <CircularProgressWithLabel value={this.getProgressValue()} />
- </IconButton>
+ }}
+ className={
+ isHelpFeedbackPanelOpened
+ ? [classes.button, classes.selectedButton].join(' ')
+ : classes.button
+ }
+ >
+ {user ? (
+ <AccountCircleIcon className={classes.buttonIcon} />
+ ) : (
+ <HelpIcon className={classes.buttonIcon} />
)}
+ </IconButton>
+ {!Pro && (
<IconButton
id="verticalNavButton"
- title={i18n.t('core:switchTheme')}
- data-tid="switchTheme"
- onClick={switchTheme}
- className={[classes.button, classes.themingButton].join(' ')}
+ title={i18n.t('core:upgradeToPro')}
+ data-tid="upgradeToPro"
+ onClick={toggleProTeaser}
+ // @ts-ignore
+ className={[classes.button, classes.upgradeButton].join(' ')}
>
- <ThemingIcon className={classes.buttonIcon} />
+ <UpgradeIcon className={classes.buttonIcon} />
</IconButton>
+ )}
+ {props.progress && props.progress.length > 0 && (
<IconButton
- id="verticalNavButton"
- title={i18n.t('core:settings')}
- data-tid="settings"
- onClick={toggleSettingsDialog}
+ id="progressButton"
+ title={i18n.t('core:progress')}
+ data-tid="uploadProgress"
+ onClick={() => props.toggleUploadDialog()}
// @ts-ignore
- className={
- isSettingsDialogOpened
- ? [
- classes.button,
- classes.settingsButton,
- classes.selectedButton
- ].join(' ')
- : [classes.button, classes.settingsButton].join(' ')
- }
+ className={[classes.button, classes.upgradeButton].join(' ')}
>
- <SettingsIcon className={classes.buttonIcon} />
+ <CircularProgressWithLabel value={getProgressValue()} />
</IconButton>
- </div>
- <div className={classes.panel}>
- {isLocationManagerPanelOpened && <LocationManager />}
- {isTagLibraryPanelOpened && <TagLibrary />}
- {isSearchPanelOpened && <Search />}
- {isHelpFeedbackPanelOpened && (
- <HelpFeedbackPanel
- openFileNatively={openFileNatively}
- openURLExternally={openURLExternally}
- toggleAboutDialog={toggleAboutDialog}
- toggleKeysDialog={toggleKeysDialog}
- toggleOnboardingDialog={toggleOnboardingDialog}
- toggleProTeaser={this.toggleProTeaser}
- />
- )}
- </div>
- </SplitPane>
- </div>
- );
- }
-}
+ )}
+ <IconButton
+ id="verticalNavButton"
+ title={i18n.t('core:switchTheme')}
+ data-tid="switchTheme"
+ onClick={switchTheme}
+ className={[classes.button, classes.themingButton].join(' ')}
+ >
+ <ThemingIcon className={classes.buttonIcon} />
+ </IconButton>
+ <IconButton
+ id="verticalNavButton"
+ title={i18n.t('core:settings')}
+ data-tid="settings"
+ onClick={toggleSettingsDialog}
+ // @ts-ignore
+ className={
+ props.isSettingsDialogOpened
+ ? [
+ classes.button,
+ classes.settingsButton,
+ classes.selectedButton
+ ].join(' ')
+ : [classes.button, classes.settingsButton].join(' ')
+ }
+ >
+ <SettingsIcon className={classes.buttonIcon} />
+ </IconButton>
+ </div>
+ <div className={classes.panel}>
+ {props.isLocationManagerPanelOpened && <LocationManager />}
+ {isTagLibraryPanelOpened && <TagLibrary />}
+ {isSearchPanelOpened && <Search />}
+ {isHelpFeedbackPanelOpened && (
+ <HelpFeedbackPanel
+ openFileNatively={openFileNatively}
+ openURLExternally={openURLExternally}
+ toggleAboutDialog={toggleAboutDialog}
+ toggleKeysDialog={toggleKeysDialog}
+ toggleOnboardingDialog={toggleOnboardingDialog}
+ toggleProTeaser={toggleProTeaser}
+ />
+ )}
+ </div>
+ </SplitPane>
+ </div>
+ );
+};
function CircularProgressWithLabel(prop) {
return (
diff --git a/app/components/dialogs/AddRemoveTagsDialog.tsx b/app/components/dialogs/AddRemoveTagsDialog.tsx
index 446f5febe..829aa5ab2 100644
--- a/app/components/dialogs/AddRemoveTagsDialog.tsx
+++ b/app/components/dialogs/AddRemoveTagsDialog.tsx
@@ -16,8 +16,7 @@
*
*/
-import React from 'react';
-import uuidv1 from 'uuid';
+import React, { useState } from 'react';
import withMobileDialog from '@material-ui/core/withMobileDialog';
import Button from '@material-ui/core/Button';
import DialogActions from '@material-ui/core/DialogActions';
@@ -45,167 +44,127 @@ interface Props {
removeAllTags: (paths: Array<string>) => void;
}
-interface State {
- disableConfirmButton: boolean;
- open: boolean;
- newlyAddedTags: Array<Tag>;
- isConfirmDialogOpened: boolean;
-}
+const AddRemoveTagsDialog = (props: Props) => {
+ const [newlyAddedTags, setNewlyAddedTags] = useState<Array<Tag>>([]);
-class AddRemoveTagsDialog extends React.Component<Props, State> {
- state = {
- disableConfirmButton: true,
- newlyAddedTags: [],
- open: false,
- isConfirmDialogOpened: false
- };
-
- handleChange = (name: string, value: Array<Tag>, action: string) => {
+ const handleChange = (name: string, value: Array<Tag>, action: string) => {
if (action === 'remove-value') {
const tagsToRemove: Array<string> = value.map(tag => tag.title);
- // eslint-disable-next-line react/no-access-state-in-setstate
- const newlyAddedTags = this.state.newlyAddedTags.filter(
- tag => !tagsToRemove.includes(tag.title)
+ setNewlyAddedTags(
+ newlyAddedTags.filter(tag => !tagsToRemove.includes(tag.title))
);
- this.setState({
- newlyAddedTags
- });
} else {
- this.setState({
- newlyAddedTags: value
- });
+ setNewlyAddedTags(value);
}
};
- onClose = (clearSelection?: boolean) => {
- this.setState({ newlyAddedTags: [] });
- this.props.onClose(clearSelection);
+ const onCloseDialog = (clearSelection?: boolean) => {
+ setNewlyAddedTags([]);
+ props.onClose(clearSelection);
};
- addTags = () => {
- if (this.props.selectedEntries && this.props.selectedEntries.length > 0) {
- const paths = [];
- this.props.selectedEntries.map(entry => {
- paths.push(entry.path);
- return true;
- });
- this.props.addTags(paths, this.state.newlyAddedTags);
+ const addTags = () => {
+ if (props.selectedEntries && props.selectedEntries.length > 0) {
+ props.addTags(
+ selectedEntries.map(entry => entry.path),
+ newlyAddedTags
+ );
}
- this.onClose(true);
+ onCloseDialog(true);
};
- removeTags = () => {
- const { selectedEntries = [], removeTags } = this.props;
- const { newlyAddedTags = [] } = this.state;
+ const removeTags = () => {
+ const { selectedEntries } = props;
if (selectedEntries && selectedEntries.length > 0) {
- const paths = [];
- selectedEntries.map(entry => {
- paths.push(entry.path);
- return true;
- });
- removeTags(paths, newlyAddedTags);
+ props.removeTags(
+ selectedEntries.map(entry => entry.path),
+ newlyAddedTags
+ );
}
- this.onClose(true);
+ onCloseDialog(true);
};
- removeAllTags = () => {
- const { selectedEntries = [], removeAllTags } = this.props;
+ const removeAllTags = () => {
+ const { selectedEntries } = props;
if (selectedEntries && selectedEntries.length > 0) {
- const paths = [];
- selectedEntries.map(entry => {
- paths.push(entry.path);
- return true;
- });
- removeAllTags(paths);
+ props.removeAllTags(selectedEntries.map(entry => entry.path));
}
- this.onClose(true);
+ onCloseDialog(true);
};
- render() {
- const {
- open,
- selectedEntries = [],
- removeTags,
- removeAllTags,
- fullScreen,
- onClose
- } = this.props;
- const { newlyAddedTags = [] } = this.state;
- const disabledButtons =
- !newlyAddedTags ||
- newlyAddedTags.length < 1 ||
- selectedEntries.length < 1;
+ const { open, selectedEntries = [], fullScreen, onClose } = props;
+ const disabledButtons =
+ !newlyAddedTags || newlyAddedTags.length < 1 || selectedEntries.length < 1;
- return (
- <Dialog
- open={open}
- fullScreen={fullScreen}
- onClose={onClose}
- keepMounted
- scroll="paper"
- >
- <DialogTitle>{i18n.t('core:tagOperationTitle')}</DialogTitle>
- <DialogContent style={{ minHeight: 330 }}>
- <TagsSelect
- dataTid="AddRemoveTagsSelectTID"
- placeholderText={i18n.t('core:selectTags')}
- tags={newlyAddedTags}
- handleChange={this.handleChange}
- tagMode="remove"
- />
- <List dense style={{ width: 550 }}>
- {selectedEntries.length > 0 &&
- selectedEntries.map(entry => (
- <ListItem key={uuidv1()} title={entry.path}>
- <ListItemIcon>
- <FileIcon />
- </ListItemIcon>
- <Typography variant="inherit" noWrap>
- {extractFileName(
- entry.path || '',
- PlatformIO.getDirSeparator()
- )}
- </Typography>
- </ListItem>
- ))}
- </List>
- </DialogContent>
- <DialogActions>
- <Button
- data-tid="cancelTagsMultipleEntries"
- onClick={() => this.onClose()}
- color="primary"
- >
- {i18n.t('core:cancel')}
- </Button>
- <Button
- data-tid="cleanTagsMultipleEntries"
- disabled={selectedEntries.length < 1}
- color="primary"
- onClick={this.removeAllTags}
- >
- {i18n.t('core:tagOperationCleanTags')}
- </Button>
- <Button
- data-tid="removeTagsMultipleEntries"
- disabled={disabledButtons}
- color="primary"
- onClick={this.removeTags}
- >
- {i18n.t('core:tagOperationRemoveTag')}
- </Button>
- <Button
- data-tid="addTagsMultipleEntries"
- disabled={disabledButtons}
- color="primary"
- onClick={this.addTags}
- >
- {i18n.t('core:tagOperationAddTag')}
- </Button>
- </DialogActions>
- </Dialog>
- );
- }
-}
+ return (
+ <Dialog
+ open={open}
+ fullScreen={fullScreen}
+ onClose={onClose}
+ keepMounted
+ scroll="paper"
+ >
+ <DialogTitle>{i18n.t('core:tagOperationTitle')}</DialogTitle>
+ <DialogContent style={{ minHeight: 330 }}>
+ <TagsSelect
+ dataTid="AddRemoveTagsSelectTID"
+ placeholderText={i18n.t('core:selectTags')}
+ tags={newlyAddedTags}
+ handleChange={handleChange}
+ tagMode="remove"
+ />
+ <List dense style={{ width: 550 }}>
+ {selectedEntries.length > 0 &&
+ selectedEntries.map(entry => (
+ <ListItem key={entry.path} title={entry.path}>
+ <ListItemIcon>
+ <FileIcon />
+ </ListItemIcon>
+ <Typography variant="inherit" noWrap>
+ {extractFileName(
+ entry.path || '',
+ PlatformIO.getDirSeparator()
+ )}
+ </Typography>
+ </ListItem>
+ ))}
+ </List>
+ </DialogContent>
+ <DialogActions>
+ <Button
+ data-tid="cancelTagsMultipleEntries"
+ onClick={() => onCloseDialog()}
+ color="primary"
+ >
+ {i18n.t('core:cancel')}
+ </Button>
+ <Button
+ data-tid="cleanTagsMultipleEntries"
+ disabled={selectedEntries.length < 1}
+ color="primary"
+ onClick={removeAllTags}
+ >
+ {i18n.t('core:tagOperationCleanTags')}
+ </Button>
+ <Button
+ data-tid="removeTagsMultipleEntries"
+ disabled={disabledButtons}
+ color="primary"
+ onClick={removeTags}
+ >
+ {i18n.t('core:tagOperationRemoveTag')}
+ </Button>
+ <Button
+ data-tid="addTagsMultipleEntries"
+ disabled={disabledButtons}
+ color="primary"
+ onClick={addTags}
+ >
+ {i18n.t('core:tagOperationAddTag')}
+ </Button>
+ </DialogActions>
+ </Dialog>
+ );
+};
export default withMobileDialog()(AddRemoveTagsDialog);
diff --git a/app/components/dialogs/CreateFileDialog.tsx b/app/components/dialogs/CreateFileDialog.tsx
index 4aeace8dc..71801abe5 100644
--- a/app/components/dialogs/CreateFileDialog.tsx
+++ b/app/components/dialogs/CreateFileDialog.tsx
@@ -16,7 +16,7 @@
*
*/
-import React from 'react';
+import React, { useEffect, useRef, useState } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import Button from '@material-ui/core/Button';
@@ -75,7 +75,7 @@ interface Props {
) => void;
}
-interface State {
+/* interface State {
errorTextName: boolean;
errorTextPath: boolean;
disableConfirmButton: boolean;
@@ -83,10 +83,28 @@ interface State {
fileName: string;
fileContent: string;
fileType: string;
-}
-// todo rewrite
-class CreateFileDialog extends React.Component<Props, State> {
- state = {
+} */
+
+/**
+ * @deprecated use CreateDialog instead
+ */
+const CreateFileDialog = (props: Props) => {
+ const [errorTextName, setErrorTextName] = useState<boolean>(false);
+ const [errorTextPath, setErrorTextPath] = useState<boolean>(false);
+ const [fileName, setFileName] = useState<string>(
+ 'note' +
+ AppConfig.beginTagContainer +
+ formatDateTime4Tag(new Date(), true) +
+ AppConfig.endTagContainer
+ );
+ const [fileType, setFileType] = useState<string>('txt');
+ const disableConfirmButton = useRef(
+ !(props.selectedDirectoryPath && props.selectedDirectoryPath.length > 0)
+ );
+ const selectedDirectoryPath = useRef(props.selectedDirectoryPath);
+ const fileContent = useRef('');
+
+ /* state = {
errorTextName: false,
errorTextPath: false,
openFolder: false,
@@ -102,73 +120,57 @@ class CreateFileDialog extends React.Component<Props, State> {
AppConfig.endTagContainer,
fileContent: '',
fileType: 'txt'
- };
+ }; */
- fileName;
+ useEffect(() => {
+ handleValidation();
+ }, [fileName, selectedDirectoryPath]);
- handleTypeChange = (event: React.ChangeEvent<HTMLInputElement>) => {
+ const handleTypeChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { target } = event;
- this.setState({ fileType: target.value });
+ setFileType(target.value);
};
- handleFileNameChange = (event: React.ChangeEvent<HTMLInputElement>) => {
+ const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { target } = event;
const { value, name } = target;
if (name === 'fileName') {
- this.setState({ fileName: value }, this.handleValidation);
+ setFileName(value);
+ setFileName(value);
+ } else if (name === 'fileContent') {
+ fileContent.current = value;
+ } else if (name === 'selectedDirectoryPath') {
+ selectedDirectoryPath.current = value;
}
};
- handleFileContentChange = (event: React.ChangeEvent<HTMLInputElement>) => {
- const { target } = event;
- const { value, name } = target;
-
- if (name === 'fileContent') {
- this.setState({ fileContent: value }, this.handleValidation);
- }
- };
-
- handleFilePathChange = (event: React.ChangeEvent<HTMLInputElement>) => {
- const { target } = event;
- const { value, name } = target;
-
- if (name === 'selectedDirectoryPath') {
- this.setState({ selectedDirectoryPath: value }, this.handleValidation);
- }
- };
-
- handleValidation() {
- if (this.state.fileName && this.state.fileName.length > 0) {
- this.setState({ errorTextName: false });
+ const handleValidation = () => {
+ if (fileName && fileName.length > 0) {
+ setErrorTextName(false);
+ disableConfirmButton.current = false;
} else {
- this.setState({ errorTextName: true });
+ setErrorTextName(true);
+ disableConfirmButton.current = true;
}
if (
- this.state.selectedDirectoryPath &&
- this.state.selectedDirectoryPath.length > 0
+ selectedDirectoryPath.current &&
+ selectedDirectoryPath.current.length > 0
) {
- this.setState({ errorTextPath: false });
+ setErrorTextPath(false);
+ disableConfirmButton.current = false;
} else {
- this.setState({ errorTextPath: true });
+ setErrorTextPath(true);
+ disableConfirmButton.current = true;
}
+ };
- this.setState({
- disableConfirmButton:
- !this.state.fileName || !this.state.selectedDirectoryPath
- });
- }
-
- openFolderChooser = () => {
+ const openFolderChooser = () => {
PlatformIO.selectDirectoryDialog()
.then(selectedPaths => {
- this.setState(
- {
- selectedDirectoryPath: selectedPaths[0]
- },
- this.handleValidation
- );
+ // eslint-disable-next-line prefer-destructuring
+ selectedDirectoryPath.current = selectedPaths[0];
return true;
})
.catch(err => {
@@ -176,57 +178,48 @@ class CreateFileDialog extends React.Component<Props, State> {
});
};
- onConfirm = () => {
- if (!this.state.disableConfirmButton) {
- const {
- fileName,
- fileContent,
- fileType,
- selectedDirectoryPath
- } = this.state;
- this.props.createFileAdvanced(
- selectedDirectoryPath,
+ const onConfirm = () => {
+ if (!disableConfirmButton.current) {
+ props.createFileAdvanced(
+ selectedDirectoryPath.current,
fileName,
- fileContent,
+ fileContent.current,
fileType
);
- this.props.onClose();
+ props.onClose();
}
};
- handleKeyPress = (event: any) => {
+ const handleKeyPress = (event: any) => {
if (event.key === 'Enter' || event.keyCode === 13) {
event.stopPropagation();
}
};
- return = () => {
+ return (
<Dialog
- open={this.props.open}
- onClose={this.props.onClose}
- fullScreen={this.props.fullScreen}
+ open={props.open}
+ onClose={props.onClose}
+ fullScreen={props.fullScreen}
keepMounted
scroll="paper"
// onKeyDown={confirmFunction}
>
<DialogTitle>{i18n.t('core:createFileTitle')}</DialogTitle>
<DialogContent data-tid="createFileDialog">
- <FormControl fullWidth={true} error={this.state.errorTextName}>
+ <FormControl fullWidth={true} error={errorTextName}>
<TextField
fullWidth={true}
- error={this.state.errorTextName}
+ error={errorTextName}
autoFocus
margin="dense"
name="fileName"
label={i18n.t('core:fileName')}
- inputRef={ref => {
- this.fileName = ref;
- }}
- onChange={this.handleFileNameChange}
- value={this.state.fileName}
+ onChange={handleFileChange}
+ value={fileName}
data-tid="createFileDialog_fileName"
/>
- {this.state.errorTextName && (
+ {errorTextName && (
<FormHelperText>{i18n.t('core:fileNameHelp')}</FormHelperText>
)}
</FormControl>
@@ -236,9 +229,9 @@ class CreateFileDialog extends React.Component<Props, State> {
placeholder="Enter the content of your file / note"
multiline
name="fileContent"
- value={this.state.fileContent}
- onChange={this.handleFileContentChange}
- onKeyDown={this.handleKeyPress}
+ defaultValue={fileContent.current}
+ onChange={handleFileChange}
+ onKeyDown={handleKeyPress}
margin="normal"
fullWidth={true}
rows={4}
@@ -247,24 +240,24 @@ class CreateFileDialog extends React.Component<Props, State> {
</FormControl>
<ListItem>
<Radio
- checked={this.state.fileType === 'txt'}
- onChange={this.handleTypeChange}
+ checked={fileType === 'txt'}
+ onChange={handleTypeChange}
value="txt"
name="type"
aria-label={i18n.t('core:createTextFile')}
/>
<FormHelperText>{i18n.t('core:createTextFile')}</FormHelperText>
<Radio
- checked={this.state.fileType === 'md'}
- onChange={this.handleTypeChange}
+ checked={fileType === 'md'}
+ onChange={handleTypeChange}
value="md"
name="type"
aria-label={i18n.t('core:createMarkdown')}
/>
<FormHelperText>{i18n.t('core:createMarkdown')}</FormHelperText>
<Radio
- checked={this.state.fileType === 'html'}
- onChange={this.handleTypeChange}
+ checked={fileType === 'html'}
+ onChange={handleTypeChange}
value="html"
name="html"
aria-label={i18n.t('core:createRichTextFile')}
@@ -279,21 +272,21 @@ class CreateFileDialog extends React.Component<Props, State> {
name="selectedDirectoryPath"
fullWidth={true}
data-tid="createFileDialog_filePath"
- value={this.state.selectedDirectoryPath}
- onChange={this.handleFilePathChange}
+ value={selectedDirectoryPath}
+ onChange={handleFileChange}
endAdornment={
PlatformIO.haveObjectStoreSupport() ? (
undefined
) : (
<InputAdornment position="end" style={{ height: 32 }}>
- <IconButton onClick={this.openFolderChooser}>
+ <IconButton onClick={openFolderChooser}>
<FolderIcon />
</IconButton>
</InputAdornment>
)
}
/>
- {this.state.errorTextPath && (
+ {errorTextPath && (
<FormHelperText>{i18n.t('core:invalidPath')}</FormHelperText>
)}
</FormControl>
@@ -301,23 +294,23 @@ class CreateFileDialog extends React.Component<Props, State> {
<DialogActions>
<Button
data-tid="closeCreateFileDialog"
- onClick={this.props.onClose}
+ onClick={props.onClose}
color="primary"
>
{i18n.t('core:cancel')}
</Button>
<Button
- disabled={this.state.disableConfirmButton}
- onClick={this.onConfirm}
+ disabled={disableConfirmButton.current}
+ onClick={onConfirm}
data-tid="confirmCreateFileDialog"
color="primary"
>
{i18n.t('core:ok')}
</Button>
</DialogActions>
- </Dialog>;
- };
-}
+ </Dialog>
+ );
+};
function mapActionCreatorsToProps(dispatch) {
return bindActionCreators(
diff --git a/app/components/dialogs/CreateTagGroupDialog.tsx b/app/components/dialogs/CreateTagGroupDialog.tsx
index b094e8b81..8858c52d3 100644
--- a/app/components/dialogs/CreateTagGroupDialog.tsx
+++ b/app/components/dialogs/CreateTagGroupDialog.tsx
@@ -16,7 +16,8 @@
*
*/
-import React from 'react';
+import React, { useReducer, useRef, useState } from 'react';
+import uuidv1 from 'uuid';
import Button from '@material-ui/core/Button';
import TextField from '@material-ui/core/TextField';
import DialogActions from '@material-ui/core/DialogActions';
@@ -39,218 +40,215 @@ interface Props {
textcolor: string;
}
-interface State {
- inputError: boolean;
- displayColorPicker: boolean;
- displayTextColorPicker: boolean;
- disableConfirmButton: boolean;
- uuid: string;
- title: string;
- color: string;
- textcolor: string;
-}
-
-class CreateTagGroupDialog extends React.Component<Props, State> {
- state = {
- displayColorPicker: false,
- displayTextColorPicker: false,
- inputError: false,
- disableConfirmButton: true,
- title: '',
- color: this.props.color,
- textcolor: this.props.textcolor,
- uuid: ''
- };
-
- handleTagGroupTitleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
+const CreateTagGroupDialog = (props: Props) => {
+ const [displayColorPicker, setDisplayColorPicker] = useState<boolean>(false);
+ const [displayTextColorPicker, setDisplayTextColorPicker] = useState<boolean>(
+ false
+ );
+ const [inputError, setInputError] = useState<boolean>(false);
+
+ const title = useRef<string>('');
+ const disableConfirmButton = useRef<boolean>(true);
+ const color = useRef<string>(props.color);
+ const textcolor = useRef<string>(props.textcolor);
+ // eslint-disable-next-line no-unused-vars
+ const [ignored, forceUpdate] = useReducer(x => x + 1, 0);
+
+ const handleTagGroupTitleChange = (
+ event: React.ChangeEvent<HTMLInputElement>
+ ) => {
const { target } = event;
const { value, name } = target;
if (name === 'title') {
- this.setState({ title: value }, this.handleValidation);
+ title.current = value;
+ handleValidation();
}
};
- handleValidation() {
- if (this.state.title.length > 0) {
- this.setState({ inputError: false, disableConfirmButton: false });
+ const handleValidation = () => {
+ if (title.current.length > 0) {
+ if (inputError) {
+ setInputError(false);
+ } else { // rerender
+ forceUpdate();
+ }
+ disableConfirmButton.current = false;
} else {
- this.setState({ inputError: true, disableConfirmButton: true });
+ if (!inputError) {
+ setInputError(true);
+ } else { // rerender
+ forceUpdate();
+ }
+ disableConfirmButton.current = true;
}
- }
+ };
- onConfirm = () => {
- if (!this.state.disableConfirmButton) {
- this.props.createTagGroup({
- uuid: this.state.uuid,
- title: this.state.title,
- color: this.state.color,
- textcolor: this.state.textcolor,
+ const onConfirm = () => {
+ if (!disableConfirmButton.current) {
+ props.createTagGroup({
+ uuid: uuidv1(),
+ title: title.current,
+ color: color.current,
+ textcolor: textcolor.current,
children: []
});
- this.setState({ inputError: false, disableConfirmButton: true });
- this.props.onClose();
+ props.onClose();
}
};
- toggleDefaultTagBackgroundColorPicker = () => {
- this.setState(prevState => ({
- displayColorPicker: !prevState.displayColorPicker
- }));
+ const toggleDefaultTagBackgroundColorPicker = () => {
+ setDisplayColorPicker(!displayColorPicker);
};
- toggleDefaultTagTextColorPicker = () => {
- this.setState(prevState => ({
- displayTextColorPicker: !prevState.displayTextColorPicker
- }));
+ const toggleDefaultTagTextColorPicker = () => {
+ setDisplayTextColorPicker(!displayTextColorPicker);
};
- handleChangeColor = (color: string) => {
- this.setState({ color });
+ const handleChangeColor = (value: string) => {
+ color.current = value;
};
- handleChangeTextColor = (color: string) => {
- this.setState({ textcolor: color });
+ const handleChangeTextColor = (value: string) => {
+ textcolor.current = value;
};
- render() {
- const { fullScreen, open, onClose } = this.props;
-
- const styles = {
- color: {
- width: '100%',
- height: 30,
- borderRadius: 2,
- borderWidth: 1,
- borderStyle: 'solid',
- borderColor: 'gray',
- background: this.state.color
- },
- textcolor: {
- width: '100%',
- height: 30,
- borderRadius: 2,
- borderWidth: 1,
- borderStyle: 'solid',
- borderColor: 'gray',
- background: this.state.textcolor
- },
- swatch: {
- padding: '5px',
- borderRadius: '1px',
- boxShadow: '0 0 0 1px rgba(0,0,0,.1)',
- display: 'inline-block',
- cursor: 'pointer'
- },
- helpText: {
- marginBottom: '5px',
- fontSize: '1rem'
- }
- };
+ const { fullScreen, open, onClose } = props;
+
+ const styles = {
+ color: {
+ width: '100%',
+ height: 30,
+ borderRadius: 2,
+ borderWidth: 1,
+ borderStyle: 'solid',
+ borderColor: 'gray',
+ background: color.current
+ },
+ textcolor: {
+ width: '100%',
+ height: 30,
+ borderRadius: 2,
+ borderWidth: 1,
+ borderStyle: 'solid',
+ borderColor: 'gray',
+ background: textcolor.current
+ },
+ swatch: {
+ padding: '5px',
+ borderRadius: '1px',
+ boxShadow: '0 0 0 1px rgba(0,0,0,.1)',
+ display: 'inline-block',
+ cursor: 'pointer'
+ },
+ helpText: {
+ marginBottom: '5px',
+ fontSize: '1rem'
+ }
+ };
- return (
- <Dialog
- open={open}
- onClose={onClose}
- fullScreen={fullScreen}
- keepMounted
- scroll="paper"
- onKeyDown={event => {
- if (event.key === 'Enter' || event.keyCode === 13) {
- event.preventDefault();
- event.stopPropagation();
- this.onConfirm();
- } else if (event.key === 'Escape') {
- onClose();
- }
- }}
- >
- <DialogTitle>{i18n.t('core:createTagGroupTitle')}</DialogTitle>
- <DialogContent>
- <FormControl fullWidth={true} error={this.state.inputError}>
- <TextField
- fullWidth={true}
- error={this.state.inputError}
- autoFocus
- name="title"
- label={i18n.t('core:createTagGroupName')}
- value={this.state.title}
- onChange={this.handleTagGroupTitleChange}
- data-tid="createTagGroupInput"
- />
- {this.state.inputError && (
- <FormHelperText>
- {i18n.t('core:taggroupTitleHelper')}
- </FormHelperText>
- )}
- </FormControl>
- <FormControl fullWidth={true}>
- <FormHelperText style={styles.helpText}>
- {i18n.t('core:tagBackgroundColor')}
+ return (
+ <Dialog
+ open={open}
+ onClose={onClose}
+ fullScreen={fullScreen}
+ keepMounted
+ scroll="paper"
+ onKeyDown={event => {
+ if (event.key === 'Enter' || event.keyCode === 13) {
+ event.preventDefault();
+ event.stopPropagation();
+ onConfirm();
+ } else if (event.key === 'Escape') {
+ onClose();
+ }
+ }}
+ >
+ <DialogTitle>{i18n.t('core:createTagGroupTitle')}</DialogTitle>
+ <DialogContent>
+ <FormControl fullWidth={true} error={inputError}>
+ <TextField
+ fullWidth={true}
+ error={inputError}
+ autoFocus
+ name="title"
+ label={i18n.t('core:createTagGroupName')}
+ defaultValue={title.current}
+ onChange={handleTagGroupTitleChange}
+ data-tid="createTagGroupInput"
+ />
+ {inputError && (
+ <FormHelperText>
+ {i18n.t('core:taggroupTitleHelper')}
</FormHelperText>
- <TransparentBackground>
- <Button
- onClick={this.toggleDefaultTagBackgroundColorPicker}
- data-tid="createTagGroupBackgroundColor"
- style={styles.color}
- role="presentation"
- >
- &nbsp;
- </Button>
- </TransparentBackground>
- {this.state.displayColorPicker && (
- <ColorPickerDialog
- open={this.state.displayColorPicker}
- setColor={this.handleChangeColor}
- onClose={this.toggleDefaultTagBackgroundColorPicker}
- color={this.state.color}
- />
- )}
- </FormControl>
- <FormControl fullWidth={true}>
- <FormHelperText style={styles.helpText}>
- {i18n.t('core:tagForegroundColor')}
- </FormHelperText>
- <TransparentBackground>
- <Button
- onClick={this.toggleDefaultTagTextColorPicker}
- data-tid="createTagGroupForegroundColor"
- style={styles.textcolor}
- role="presentation"
- >
- &nbsp;
- </Button>
- </TransparentBackground>
- {this.state.displayTextColorPicker && (
- <ColorPickerDialog
- open={this.state.displayTextColorPicker}
- setColor={this.handleChangeTextColor}
- onClose={this.toggleDefaultTagTextColorPicker}
- color={this.state.textcolor}
- />
- )}
- </FormControl>
- </DialogContent>
- <DialogActions>
- <Button
- data-tid="createTagGroupCancelButton"
- onClick={this.props.onClose}
- color="primary"
- >
- {i18n.t('core:cancel')}
- </Button>
- <Button
- disabled={this.state.disableConfirmButton}
- onClick={this.onConfirm}
- data-tid="createTagGroupConfirmButton"
- color="primary"
- >
- {i18n.t('core:ok')}
- </Button>
- </DialogActions>
- </Dialog>
- );
- }
-}
+ )}
+ </FormControl>
+ <FormControl fullWidth={true}>
+ <FormHelperText style={styles.helpText}>
+ {i18n.t('core:tagBackgroundColor')}
+ </FormHelperText>
+ <TransparentBackground>
+ <Button
+ onClick={toggleDefaultTagBackgroundColorPicker}
+ data-tid="createTagGroupBackgroundColor"
+ style={styles.color}
+ role="presentation"
+ >
+ &nbsp;
+ </Button>
+ </TransparentBackground>
+ {displayColorPicker && (
+ <ColorPickerDialog
+ open={displayColorPicker}
+ setColor={handleChangeColor}
+ onClose={toggleDefaultTagBackgroundColorPicker}
+ color={color.current}
+ />
+ )}
+ </FormControl>
+ <FormControl fullWidth={true}>
+ <FormHelperText style={styles.helpText}>
+ {i18n.t('core:tagForegroundColor')}
+ </FormHelperText>
+ <TransparentBackground>
+ <Button
+ onClick={toggleDefaultTagTextColorPicker}
+ data-tid="createTagGroupForegroundColor"
+ style={styles.textcolor}
+ role="presentation"
+ >
+ &nbsp;
+ </Button>
+ </TransparentBackground>
+ {displayTextColorPicker && (
+ <ColorPickerDialog
+ open={displayTextColorPicker}
+ setColor={handleChangeTextColor}
+ onClose={toggleDefaultTagTextColorPicker}
+ color={textcolor.current}
+ />
+ )}
+ </FormControl>
+ </DialogContent>
+ <DialogActions>
+ <Button
+ data-tid="createTagGroupCancelButton"
+ onClick={props.onClose}
+ color="primary"
+ >
+ {i18n.t('core:cancel')}
+ </Button>
+ <Button
+ disabled={disableConfirmButton.current}
+ onClick={onConfirm}
+ data-tid="createTagGroupConfirmButton"
+ color="primary"
+ >
+ {i18n.t('core:ok')}
+ </Button>
+ </DialogActions>
+ </Dialog>
+ );
+};
export default CreateTagGroupDialog;
diff --git a/app/components/dialogs/ProTeaserDialog.tsx b/app/components/dialogs/ProTeaserDialog.tsx
index bd43af82d..fb1512a9e 100644
--- a/app/components/dialogs/ProTeaserDialog.tsx
+++ b/app/components/dialogs/ProTeaserDialog.tsx
@@ -16,7 +16,7 @@
*
*/
-import React from 'react';
+import React, { useState } from 'react';
import SwipeableViews from 'react-swipeable-views';
import Button from '@material-ui/core/Button';
import DialogActions from '@material-ui/core/DialogActions';
@@ -42,429 +42,415 @@ interface Props {
onClose: () => void;
}
-interface State {
- activeStep: number;
-}
-
-class ProTeaserDialog extends React.Component<Props, State> {
- state = {
- activeStep: 0
- };
+const ProTeaserDialog = (props: Props) => {
+ const [activeStep, setActiveStep] = useState<number>(0);
- maxSteps = 7;
+ const maxSteps = 7;
- handleNext = () => {
- this.setState(prevState => ({
- activeStep: prevState.activeStep + 1
- }));
+ const handleNext = () => {
+ setActiveStep(activeStep + 1);
};
- handleBack = () => {
- this.setState(prevState => ({
- activeStep: prevState.activeStep - 1
- }));
+ const handleBack = () => {
+ setActiveStep(activeStep - 1);
};
- handleStepChange = activeStep => {
- this.setState({ activeStep });
+ const handleStepChange = step => {
+ setActiveStep(step);
};
- render() {
- const { activeStep } = this.state;
- const slideStyles: any = {
- padding: 5,
- textAlign: 'left'
- };
- const { fullScreen, open, onClose } = this.props;
+ const slideStyles: any = {
+ padding: 5,
+ textAlign: 'left'
+ };
+ const { fullScreen, open, onClose } = props;
- return (
- <Dialog
- open={open}
- onClose={onClose}
- fullScreen={fullScreen}
- keepMounted
- scroll="paper"
- >
- <DialogContent style={{ paddingBottom: 0 }}>
- <SwipeableViews
- index={activeStep}
- onChangeIndex={this.handleStepChange}
- enableMouseEvents
- >
- <div style={slideStyles}>
- <Typography variant="h5" style={{ textAlign: 'center' }}>
- TagSpaces Pro - Key Features
- </Typography>
+ return (
+ <Dialog
+ open={open}
+ onClose={onClose}
+ fullScreen={fullScreen}
+ keepMounted
+ scroll="paper"
+ >
+ <DialogContent style={{ paddingBottom: 0 }}>
+ <SwipeableViews
+ index={activeStep}
+ onChangeIndex={handleStepChange}
+ enableMouseEvents
+ >
+ <div style={slideStyles}>
+ <Typography variant="h5" style={{ textAlign: 'center' }}>
+ TagSpaces Pro - Key Features
+ </Typography>
+ <br />
+ <Typography variant="subtitle1">
+ &#x2605; Connect cloud object storages as locations (e.g. AWS S3
+ Buckets, Minio, DigitalOcean Spaces)
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Global search in all locations (cloud &amp; local ones)
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Advanced search with full text support for some file
+ types
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Description and custom thumbnails for files and folder
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Custom background color for folders
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Advanced tagging with geo location support
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Generating persistent thumbnails
+ </Typography>
+ <Typography variant="subtitle1">&nbsp;</Typography>
+ <div style={{ textAlign: 'center' }}>
+ <img
+ style={{
+ maxHeight: 150,
+ marginTop: 15,
+ marginBottom: 15
+ }}
+ src={DecideImage}
+ alt=""
+ />
<br />
- <Typography variant="subtitle1">
- &#x2605; Connect cloud object storages as locations (e.g. AWS S3
- Buckets, Minio, DigitalOcean Spaces)
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; Global search in all locations (cloud &amp; local ones)
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; Advanced search with full text support for some file
- types
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; Description and custom thumbnails for files and folder
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; Custom background color for folders
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; Advanced tagging with geo location support
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; Generating persistent thumbnails
- </Typography>
- <Typography variant="subtitle1">&nbsp;</Typography>
- <div style={{ textAlign: 'center' }}>
- <img
- style={{
- maxHeight: 150,
- marginTop: 15,
- marginBottom: 15
- }}
- src={DecideImage}
- alt=""
- />
- <br />
- <Button
- onClick={() => {
- this.props.openURLExternally(
- AppConfig.links.productsOverview,
- true
- );
- }}
- variant="contained"
- color="primary"
- >
- Open Product Comparison
- </Button>
- </div>
+ <Button
+ onClick={() => {
+ props.openURLExternally(
+ AppConfig.links.productsOverview,
+ true
+ );
+ }}
+ variant="contained"
+ color="primary"
+ >
+ Open Product Comparison
+ </Button>
</div>
- <div style={slideStyles}>
- <Typography variant="h5" style={{ textAlign: 'center' }}>
- Advanced Search
- </Typography>
+ </div>
+ <div style={slideStyles}>
+ <Typography variant="h5" style={{ textAlign: 'center' }}>
+ Advanced Search
+ </Typography>
+ <br />
+ <Typography variant="h6">Global search</Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Search in all locations at once, regardless if they are
+ local or in the Cloud
+ </Typography>
+ <Typography variant="h6">Full text search</Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Keywords from text files (TXT, HTML, Markdown) will be
+ included in the index
+ </Typography>
+ <Typography variant="h6">Filter by file type</Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Documents, Notes, Audio files, Video files, Archives,
+ Bookmarks, eBooks
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Filter for files, folders and untagged files
+ </Typography>
+ <Typography variant="h6">
+ Filter by size, date and gps-coordinates
+ </Typography>
+ <div style={{ textAlign: 'center' }}>
+ <img
+ style={{
+ maxHeight: 150,
+ marginTop: 15,
+ marginBottom: 15
+ }}
+ src={SearchImage}
+ alt=""
+ />
<br />
- <Typography variant="h6">Global search</Typography>
- <Typography variant="subtitle1">
- &#x2605; Search in all locations at once, regardless if they are
- local or in the Cloud
- </Typography>
- <Typography variant="h6">Full text search</Typography>
- <Typography variant="subtitle1">
- &#x2605; Keywords from text files (TXT, HTML, Markdown) will be
- included in the index
- </Typography>
- <Typography variant="h6">Filter by file type</Typography>
- <Typography variant="subtitle1">
- &#x2605; Documents, Notes, Audio files, Video files, Archives,
- Bookmarks, eBooks
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; Filter for files, folders and untagged files
- </Typography>
- <Typography variant="h6">
- Filter by size, date and gps-coordinates
- </Typography>
- <div style={{ textAlign: 'center' }}>
- <img
- style={{
- maxHeight: 150,
- marginTop: 15,
- marginBottom: 15
- }}
- src={SearchImage}
- alt=""
- />
- <br />
- <Button
- onClick={() =>
- this.props.openURLExternally(
- AppConfig.links.productProAdvancedSearch,
- true
- )
- }
- variant="contained"
- color="primary"
- >
- Learn more
- </Button>
- </div>
+ <Button
+ onClick={() =>
+ props.openURLExternally(
+ AppConfig.links.productProAdvancedSearch,
+ true
+ )
+ }
+ variant="contained"
+ color="primary"
+ >
+ Learn more
+ </Button>
</div>
- <div style={slideStyles}>
- <Typography variant="h5" style={{ textAlign: 'center' }}>
- Connect S3 object storages as locations
- </Typography>
+ </div>
+ <div style={slideStyles}>
+ <Typography variant="h5" style={{ textAlign: 'center' }}>
+ Connect S3 object storages as locations
+ </Typography>
+ <br />
+ <Typography variant="subtitle1">
+ With this feature, TagSpaces Pro supports AWS S3 compatible
+ buckets as file storage. Such buckets are offered by e.g. Amazon
+ AWS, DigitalOcean or Minio. By doing this, you get a full-fledged{' '}
+ <strong>
+ file organizer, browser and navigator for files in the Cloud
+ </strong>
+ , directly in TagSpaces. You do not have to download every file
+ separately and eventually upload it back in order to preview, edit
+ or annotate it.
+ </Typography>
+ <div style={{ textAlign: 'center' }}>
+ <img
+ style={{
+ maxHeight: 120,
+ marginTop: 15,
+ marginBottom: 15
+ }}
+ src={CloudImage}
+ alt=""
+ />
<br />
- <Typography variant="subtitle1">
- With this feature, TagSpaces Pro supports AWS S3 compatible
- buckets as file storage. Such buckets are offered by e.g. Amazon
- AWS, DigitalOcean or Minio. By doing this, you get a
- full-fledged{' '}
- <strong>
- file organizer, browser and navigator for files in the Cloud
- </strong>
- , directly in TagSpaces. You do not have to download every file
- separately and eventually upload it back in order to preview,
- edit or annotate it.
- </Typography>
- <div style={{ textAlign: 'center' }}>
- <img
- style={{
- maxHeight: 120,
- marginTop: 15,
- marginBottom: 15
- }}
- src={CloudImage}
- alt=""
- />
- <br />
- <Button
- onClick={() =>
- this.props.openURLExternally(
- AppConfig.links.productProObjectStore,
- true
- )
- }
- variant="contained"
- color="primary"
- >
- Learn more
- </Button>
- </div>
+ <Button
+ onClick={() =>
+ props.openURLExternally(
+ AppConfig.links.productProObjectStore,
+ true
+ )
+ }
+ variant="contained"
+ color="primary"
+ >
+ Learn more
+ </Button>
</div>
- <div style={slideStyles}>
- <Typography variant="h5" style={{ textAlign: 'center' }}>
- Annotate your files and folders visually
- </Typography>
+ </div>
+ <div style={slideStyles}>
+ <Typography variant="h5" style={{ textAlign: 'center' }}>
+ Annotate your files and folders visually
+ </Typography>
+ <br />
+ <Typography variant="subtitle1">
+ &#x2605; Add <b>custom description</b> to every document, photo or
+ folder
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; The description can be in markdown allowing images and
+ links
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Set a <b>custom thumbnail</b> for every file or folder
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Set a <b>custom background color</b> to folders
+ </Typography>
+ <Typography variant="subtitle1">
+ These features will enable you to find with ease your documents
+ via the build-in search or just visually.
+ </Typography>
+ <div style={{ textAlign: 'center' }}>
+ <img
+ style={{
+ maxHeight: 200,
+ marginTop: 15,
+ marginBottom: 15
+ }}
+ src={AnnotateImage}
+ alt=""
+ />
<br />
- <Typography variant="subtitle1">
- &#x2605; Add <b>custom description</b> to every document, photo
- or folder
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; The description can be in markdown allowing images and
- links
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; Set a <b>custom thumbnail</b> for every file or folder
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; Set a <b>custom background color</b> to folders
- </Typography>
- <Typography variant="subtitle1">
- These features will enable you to find with ease your documents
- via the build-in search or just visually.
- </Typography>
- <div style={{ textAlign: 'center' }}>
- <img
- style={{
- maxHeight: 200,
- marginTop: 15,
- marginBottom: 15
- }}
- src={AnnotateImage}
- alt=""
- />
- <br />
- <Button
- onClick={() =>
- this.props.openURLExternally(
- AppConfig.links.productProFileFolderMeta,
- true
- )
- }
- variant="contained"
- color="primary"
- >
- Learn more
- </Button>
- </div>
+ <Button
+ onClick={() =>
+ props.openURLExternally(
+ AppConfig.links.productProFileFolderMeta,
+ true
+ )
+ }
+ variant="contained"
+ color="primary"
+ >
+ Learn more
+ </Button>
</div>
- <div style={slideStyles}>
- <Typography variant="h5" style={{ textAlign: 'center' }}>
- Tag with geo coordinates
- </Typography>
+ </div>
+ <div style={slideStyles}>
+ <Typography variant="h5" style={{ textAlign: 'center' }}>
+ Tag with geo coordinates
+ </Typography>
+ <br />
+ <Typography variant="subtitle1">
+ &#x2605; This feature can be used to add geo coordinates to every
+ file or folder.{' '}
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Dedicated perspective for showing geo-tags on a build-in
+ map
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Extract geo location data from EXIF in JPGs files.
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Useful for planing or documenting trips and vacations.
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Useful for adding annotations for places on a map.
+ </Typography>
+ <div style={{ textAlign: 'center' }}>
+ <img
+ style={{
+ maxHeight: 200,
+ marginTop: 15,
+ marginBottom: 15
+ }}
+ src={MapImage}
+ alt=""
+ />
<br />
- <Typography variant="subtitle1">
- &#x2605; This feature can be used to add geo coordinates to
- every file or folder.{' '}
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; Dedicated perspective for showing geo-tags on a
- build-in map
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; Extract geo location data from EXIF in JPGs files.
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; Useful for planing or documenting trips and vacations.
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; Useful for adding annotations for places on a map.
- </Typography>
- <div style={{ textAlign: 'center' }}>
- <img
- style={{
- maxHeight: 200,
- marginTop: 15,
- marginBottom: 15
- }}
- src={MapImage}
- alt=""
- />
- <br />
- <Button
- onClick={() =>
- this.props.openURLExternally(
- AppConfig.links.productProGeoTagging,
- true
- )
- }
- variant="contained"
- color="primary"
- >
- Learn more
- </Button>
- </div>
+ <Button
+ onClick={() =>
+ props.openURLExternally(
+ AppConfig.links.productProGeoTagging,
+ true
+ )
+ }
+ variant="contained"
+ color="primary"
+ >
+ Learn more
+ </Button>
</div>
- <div style={slideStyles}>
- <Typography variant="h5" style={{ textAlign: 'center' }}>
- Generating persistent thumbnails
- </Typography>
+ </div>
+ <div style={slideStyles}>
+ <Typography variant="h5" style={{ textAlign: 'center' }}>
+ Generating persistent thumbnails
+ </Typography>
+ <br />
+ <Typography variant="subtitle1">
+ TagSpaces Pro generates persistent thumbnails for many file type
+ such as: images, videos, notes, source code, office documents,
+ bookmarks, ebooks, archives and PDFs.
+ </Typography>
+ <div style={{ textAlign: 'center' }}>
+ <img
+ style={{
+ maxHeight: 200,
+ marginTop: 15,
+ marginBottom: 15
+ }}
+ src={ThumbsImage}
+ alt=""
+ />
<br />
- <Typography variant="subtitle1">
- TagSpaces Pro generates persistent thumbnails for many file type
- such as: images, videos, notes, source code, office documents,
- bookmarks, ebooks, archives and PDFs.
- </Typography>
- <div style={{ textAlign: 'center' }}>
- <img
- style={{
- maxHeight: 200,
- marginTop: 15,
- marginBottom: 15
- }}
- src={ThumbsImage}
- alt=""
- />
- <br />
- <Button
- onClick={() =>
- this.props.openURLExternally(
- AppConfig.links.productProThumbnailsGeneration,
- true
- )
- }
- variant="contained"
- color="primary"
- >
- Learn more
- </Button>
- </div>
+ <Button
+ onClick={() =>
+ props.openURLExternally(
+ AppConfig.links.productProThumbnailsGeneration,
+ true
+ )
+ }
+ variant="contained"
+ color="primary"
+ >
+ Learn more
+ </Button>
</div>
- <div style={slideStyles}>
- <Typography variant="h5" style={{ textAlign: 'center' }}>
- TagSpaces Enterprise
- </Typography>
+ </div>
+ <div style={slideStyles}>
+ <Typography variant="h5" style={{ textAlign: 'center' }}>
+ TagSpaces Enterprise
+ </Typography>
+ <br />
+ <Typography variant="subtitle1">
+ &#x2605; On-prem web based version of TagSpaces Pro
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; PWA version of TagSpaces Pro optimized for use om mobile
+ devices
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; White label packages, with custom colors and logo
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Development of custom viewers for file (e.g. 3D-assets,
+ medical data ...)
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Development of custom perspectives for folders (e.g.
+ graphs, maps, trees)
+ </Typography>
+ <Typography variant="subtitle1">
+ &#x2605; Premium technical support and signed installers
+ </Typography>
+ <div style={{ textAlign: 'center' }}>
+ <img
+ style={{
+ maxHeight: 200,
+ marginTop: 15,
+ marginBottom: 15
+ }}
+ src={EnterpriseImage}
+ alt=""
+ />
<br />
- <Typography variant="subtitle1">
- &#x2605; On-prem web based version of TagSpaces Pro
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; PWA version of TagSpaces Pro optimized for use om
- mobile devices
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; White label packages, with custom colors and logo
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; Development of custom viewers for file (e.g. 3D-assets,
- medical data ...)
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; Development of custom perspectives for folders (e.g.
- graphs, maps, trees)
- </Typography>
- <Typography variant="subtitle1">
- &#x2605; Premium technical support and signed installers
- </Typography>
- <div style={{ textAlign: 'center' }}>
- <img
- style={{
- maxHeight: 200,
- marginTop: 15,
- marginBottom: 15
- }}
- src={EnterpriseImage}
- alt=""
- />
- <br />
- <Button
- onClick={() =>
- this.props.openURLExternally(
- AppConfig.links.productsOverview,
- true
- )
- }
- variant="outlined"
- color="primary"
- >
- Product Landscape
- </Button>
- &nbsp;
- <Button
- onClick={() =>
- this.props.openURLExternally(
- AppConfig.links.emailContact,
- true
- )
- }
- variant="outlined"
- color="primary"
- >
- {i18n.t('core:emailContact')}
- </Button>
- </div>
- </div>
- </SwipeableViews>
- </DialogContent>
- <DialogActions style={{ justifyContent: 'center' }}>
- <MobileStepper
- style={{ marginTop: 10, backgroundColor: 'transparent' }}
- steps={this.maxSteps}
- position="static"
- activeStep={this.state.activeStep}
- nextButton={
- this.state.activeStep === this.maxSteps - 1 ? (
- <Button size="small" onClick={this.props.onClose}>
- {i18n.t('core:closeButton')}
- </Button>
- ) : (
- <Button size="small" onClick={this.handleNext}>
- {i18n.t('core:next')}
- </Button>
- )
- }
- backButton={
<Button
- size="small"
- onClick={this.handleBack}
- disabled={this.state.activeStep === 0}
+ onClick={() =>
+ props.openURLExternally(
+ AppConfig.links.productsOverview,
+ true
+ )
+ }
+ variant="outlined"
+ color="primary"
>
- {i18n.t('core:prev')}
+ Product Landscape
</Button>
- }
- />
- </DialogActions>
- </Dialog>
- );
- }
-}
+ &nbsp;
+ <Button
+ onClick={() =>
+ props.openURLExternally(
+ AppConfig.links.emailContact,
+ true
+ )
+ }
+ variant="outlined"
+ color="primary"
+ >
+ {i18n.t('core:emailContact')}
+ </Button>
+ </div>
+ </div>
+ </SwipeableViews>
+ </DialogContent>
+ <DialogActions style={{ justifyContent: 'center' }}>
+ <MobileStepper
+ style={{ marginTop: 10, backgroundColor: 'transparent' }}
+ steps={maxSteps}
+ position="static"
+ activeStep={activeStep}
+ nextButton={
+ activeStep === maxSteps - 1 ? (
+ <Button size="small" onClick={props.onClose}>
+ {i18n.t('core:closeButton')}
+ </Button>
+ ) : (
+ <Button size="small" onClick={handleNext}>
+ {i18n.t('core:next')}
+ </Button>
+ )
+ }
+ backButton={
+ <Button
+ size="small"
+ onClick={handleBack}
+ disabled={activeStep === 0}
+ >
+ {i18n.t('core:prev')}
+ </Button>
+ }
+ />
+ </DialogActions>
+ </Dialog>
+ );
+};
export default withMobileDialog()(ProTeaserDialog);
diff --git a/app/components/dialogs/RenameDirectoryDialog.tsx b/app/components/dialogs/RenameDirectoryDialog.tsx
index f2c466d5a..58b714513 100644
--- a/app/components/dialogs/RenameDirectoryDialog.tsx
+++ b/app/components/dialogs/RenameDirectoryDialog.tsx
@@ -16,7 +16,7 @@
*
*/
-import React from 'react';
+import React, { useReducer, useRef, useState } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import Button from '@material-ui/core/Button';
@@ -39,120 +39,110 @@ interface Props {
renameDirectory: (directoryPath: string, newDirectoryName: string) => void;
}
-interface State {
- inputError: boolean;
- disableConfirmButton: boolean;
- name: string;
-}
-
-class RenameDirectoryDialog extends React.Component<Props, State> {
- state = {
- inputError: false,
- disableConfirmButton: true,
- name: this.props.selectedDirectoryPath
+const RenameDirectoryDialog = (props: Props) => {
+ const [inputError, setInputError] = useState<boolean>(false);
+ const disableConfirmButton = useRef<boolean>(true);
+ const name = useRef<string>(
+ props.selectedDirectoryPath
? extractDirectoryName(
- this.props.selectedDirectoryPath,
+ props.selectedDirectoryPath,
PlatformIO.getDirSeparator()
)
: ''
- };
+ );
- handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
- this.setState(
- {
- name: event.target.value
- },
- this.handleValidation
- );
+ // eslint-disable-next-line no-unused-vars
+ const [ignored, forceUpdate] = useReducer(x => x + 1, 0);
+
+ const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
+ name.current = event.target.value;
+ handleValidation();
};
- handleValidation() {
+ const handleValidation = () => {
// const nameRegex = this.state.name.match('^[A-Z][-a-zA-Z]+$');
- if (this.state.name.length > 0) {
- this.setState({
- inputError: false,
- disableConfirmButton: false
- });
+ if (name.current.length > 0) {
+ if (inputError) {
+ setInputError(false);
+ } else {
+ // rerender
+ forceUpdate();
+ }
+ disableConfirmButton.current = false;
} else {
- this.setState({
- inputError: true,
- disableConfirmButton: true
- });
+ if (!inputError) {
+ setInputError(true);
+ } else {
+ // rerender
+ forceUpdate();
+ }
+ disableConfirmButton.current = true;
}
- }
+ };
- onConfirm = () => {
- if (!this.state.disableConfirmButton) {
- this.props.renameDirectory(
- this.props.selectedDirectoryPath,
- this.state.name
- );
- this.setState({
- inputError: false,
- disableConfirmButton: true
- });
- this.props.onClose();
+ const onConfirm = () => {
+ if (!disableConfirmButton.current) {
+ props.renameDirectory(props.selectedDirectoryPath, name.current);
+ props.onClose();
}
};
- render() {
- const { open, onClose } = this.props;
+ const { open, onClose } = props;
- return (
- <Dialog
- open={open}
- onClose={onClose}
- keepMounted
- scroll="paper"
- onKeyDown={event => {
- if (event.key === 'Enter' || event.keyCode === 13) {
- event.preventDefault();
- event.stopPropagation();
- this.onConfirm();
- } else if (event.key === 'Escape') {
- onClose();
- }
- }}
- >
- <DialogTitle>{i18n.t('core:renameDirectory')}</DialogTitle>
- <DialogContent>
- <FormControl fullWidth={true} error={this.state.inputError}>
- <TextField
- fullWidth={true}
- autoFocus
- required
- error={this.state.inputError}
- margin="dense"
- name="name"
- label={i18n.t('core:renameDirectoryTitleName')}
- onChange={this.handleInputChange}
- value={this.state.name}
- data-tid="renameDirectoryDialogInput"
- />
- <FormHelperText>{i18n.t('core:directoryNameHelp')}</FormHelperText>
- </FormControl>
- </DialogContent>
- <DialogActions>
- <Button
- data-tid="closeRenameDirectoryDialog"
- onClick={this.props.onClose}
- color="primary"
- >
- {i18n.t('core:cancel')}
- </Button>
- <Button
- disabled={this.state.disableConfirmButton}
- onClick={this.onConfirm}
- data-tid="confirmRenameDirectory"
- color="primary"
- >
- {i18n.t('core:ok')}
- </Button>
- </DialogActions>
- </Dialog>
- );
- }
-}
+ return (
+ <Dialog
+ open={open}
+ onClose={onClose}
+ keepMounted
+ scroll="paper"
+ onKeyDown={event => {
+ if (event.key === 'Enter' || event.keyCode === 13) {
+ event.preventDefault();
+ event.stopPropagation();
+ onConfirm();
+ } else if (event.key === 'Escape') {
+ onClose();
+ }
+ }}
+ >
+ <DialogTitle>{i18n.t('core:renameDirectory')}</DialogTitle>
+ <DialogContent>
+ <FormControl fullWidth={true} error={inputError}>
+ <TextField
+ fullWidth={true}
+ autoFocus
+ required
+ error={inputError}
+ margin="dense"
+ name="name"
+ label={i18n.t('core:renameDirectoryTitleName')}
+ onChange={handleInputChange}
+ defaultValue={name.current}
+ data-tid="renameDirectoryDialogInput"
+ />
+ <FormHelperText>{i18n.t('core:directoryNameHelp')}</FormHelperText>
+ </FormControl>
+ </DialogContent>
+ <DialogActions>
+ <Button
+ data-tid="closeRenameDirectoryDialog"
+ onClick={props.onClose}
+ color="primary"
+ >
+ {i18n.t('core:cancel')}
+ </Button>
+ <Button
+ disabled={disableConfirmButton.current}
+ onClick={onConfirm}
+ data-tid="confirmRenameDirectory"
+ color="primary"
+ >
+ {i18n.t('core:ok')}
+ </Button>
+ </DialogActions>
+ </Dialog>
+ );
+};
function mapActionCreatorsToProps(dispatch) {
return bindActionCreators(
diff --git a/app/components/menus/DirectoryMenu.tsx b/app/components/menus/DirectoryMenu.tsx
index 1b71a18cd..a990a4530 100644
--- a/app/components/menus/DirectoryMenu.tsx
+++ b/app/components/menus/DirectoryMenu.tsx
@@ -526,6 +526,7 @@ function mapDispatchToProps(dispatch) {
onUploadProgress: AppActions.onUploadProgress,
toggleUploadDialog: AppActions.toggleUploadDialog,
toggleProgressDialog: AppActions.toggleProgressDialog,
+ toggleCreateFileDialog: AppActions.toggleCreateFileDialog,
resetProgress: AppActions.resetProgress,
reflectCreateEntries: AppActions.reflectCreateEntries,
extractContent: IOActions.extractContent,
diff --git a/app/components/menus/LocationMenu.tsx b/app/components/menus/LocationMenu.tsx
index ccf3a4ae4..806ad9bb3 100644
--- a/app/components/menus/LocationMenu.tsx
+++ b/app/components/menus/LocationMenu.tsx
@@ -16,7 +16,7 @@
*
*/
-import React from 'react';
+import React, { useState } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import Menu from '@material-ui/core/Menu';
@@ -41,79 +41,56 @@ interface Props {
openLocation: (location: Location) => void;
}
-interface State {
- currentLocation: Location | null;
- locationChooserMenuOpened: boolean;
- locationChooserMenuAnchorEl: Element;
-}
+const LocationMenu = (props: Props) => {
+ const [
+ locationChooserMenuAnchorEl,
+ setLocationChooserMenuAnchorEl
+ ] = useState<null | HTMLElement>(null);
-class LocationMenu extends React.Component<Props, State> {
- state = {
- currentLocation: null,
- locationChooserMenuOpened: false,
- locationChooserMenuAnchorEl: null
+ const openLocation = location => {
+ props.openLocation(location);
+ setLocationChooserMenuAnchorEl(null);
};
- static getDerivedStateFromProps(nextProps, prevState) {
- let currentLocation;
- if (nextProps.currentLocationId && nextProps.locations) {
- nextProps.locations.map((location: Location) => {
- if (location.uuid === nextProps.currentLocationId) {
- currentLocation = location;
- }
- });
- }
- return {
- ...prevState,
- currentLocation
- };
+ let currentLocation;
+ if (props.currentLocationId && props.locations) {
+ currentLocation = props.locations.find(
+ (location: Location) => location.uuid === props.currentLocationId
+ );
}
- openLocation = location => {
- this.props.openLocation(location);
- this.toggleLocationChooser(undefined);
- };
-
- toggleLocationChooser = (event: any) => {
- this.setState({
- locationChooserMenuOpened: !this.state.locationChooserMenuOpened,
- locationChooserMenuAnchorEl: event ? event.currentTarget : null
- });
- };
-
- render() {
- const { theme } = this.props;
- const { currentLocation } = this.state;
- const locationIcon =
- currentLocation && currentLocation.type === locationType.TYPE_CLOUD ? (
- <CloudLocationIcon />
- ) : (
- <LocationIcon />
- );
+ const { theme } = props;
+ const locationIcon =
+ currentLocation && currentLocation.type === locationType.TYPE_CLOUD ? (
+ <CloudLocationIcon />
+ ) : (
+ <LocationIcon />
+ );
- return (
- <div
- style={{
- backgroundColor: theme.palette.background.default
- }}
+ return (
+ <div
+ style={{
+ backgroundColor: theme.palette.background.default
+ }}
+ >
+ <Button
+ data-tid="folderContainerLocationChooser"
+ id="locationMenuButton"
+ onClick={(event) => setLocationChooserMenuAnchorEl(event.currentTarget)}
+ title={currentLocation && currentLocation.name}
+ style={{ paddingRight: 0, paddingLeft: 11 }}
>
- <Button
- data-tid="folderContainerLocationChooser"
- id="locationMenuButton"
- onClick={this.toggleLocationChooser}
- title={this.state.currentLocation && this.state.currentLocation.name}
- style={{ paddingRight: 0, paddingLeft: 11 }}
- >
- {this.state.currentLocation
- ? locationIcon // this.state.currentLocation.name
- : i18n.t('core:pleaseOpenLocation')}
- <ArrowDropDownIcon />
- </Button>
+ {currentLocation
+ ? locationIcon // this.state.currentLocation.name
+ : i18n.t('core:pleaseOpenLocation')}
+ <ArrowDropDownIcon />
+ </Button>
+ {Boolean(locationChooserMenuAnchorEl) && (
<Menu
id="simple-menu"
- open={this.state.locationChooserMenuOpened}
- anchorEl={this.state.locationChooserMenuAnchorEl}
- onClose={this.toggleLocationChooser}
+ open={Boolean(locationChooserMenuAnchorEl)}
+ anchorEl={locationChooserMenuAnchorEl}
+ onClose={() => setLocationChooserMenuAnchorEl(null)}
PaperProps={{
style: {
maxHeight: 48 * 6.5,
@@ -128,11 +105,11 @@ class LocationMenu extends React.Component<Props, State> {
>
{i18n.t('core:chooseLocation')}
</ListSubHeader>
- {this.props.locations.map((location: Location) => (
+ {props.locations.map((location: Location) => (
<MenuItem
data-tid="folderContainerMenuOpenLocation"
key={location.uuid}
- onClick={() => this.openLocation(location)}
+ onClick={() => openLocation(location)}
style={
currentLocation && currentLocation.uuid === location.uuid
? { backgroundColor: theme.palette.primary.light }
@@ -150,10 +127,10 @@ class LocationMenu extends React.Component<Props, State> {
</MenuItem>
))}
</Menu>
- </div>
- );
- }
-}
+ )}
+ </div>
+ );
+};
function mapStateToProps(state) {
return {