Skip to content

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

Create tab Advanced in the settings (#1441)

Stanimir1115d06722e2
diff --git a/app/components/dialogs/settings/SettingsAdvanced.tsx b/app/components/dialogs/settings/SettingsAdvanced.tsx
new file mode 100644
index 000000000..5b106e54b
--- /dev/null
+++ b/app/components/dialogs/settings/SettingsAdvanced.tsx
@@ -0,0 +1,225 @@
+/**
+ * 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/>.
+ *
+ */
+
+import React, { useState } from 'react';
+import { connect } from 'react-redux';
+import { bindActionCreators } from 'redux';
+import { withStyles } from '@material-ui/core/styles';
+import Paper from '@material-ui/core/Paper';
+import List from '@material-ui/core/List';
+import ListItem from '@material-ui/core/ListItem';
+import ListItemText from '@material-ui/core/ListItemText';
+import Tooltip from '@material-ui/core/Tooltip';
+import Button from '@material-ui/core/Button';
+import CheckIcon from '@material-ui/icons/Check';
+import EditIcon from '@material-ui/icons/Edit';
+import IconButton from '@material-ui/core/IconButton';
+import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
+import AddIcon from '@material-ui/icons/Add';
+import Switch from '@material-ui/core/Switch';
+import i18n from '-/services/i18n';
+import {
+ actions as SettingsActions,
+ getSettings,
+ getMapTileServers
+} from '-/reducers/settings';
+import { TS } from '-/tagspaces.namespace';
+import MapTileServerDialog from '-/components/dialogs/settings/MapTileServerDialog';
+
+const styles: any = {
+ root: {
+ overflowX: 'hidden'
+ },
+ listItem: {
+ paddingLeft: 0,
+ paddingRight: 0
+ },
+ pro: {
+ backgroundColor: '#1DD19F'
+ },
+ colorChooserButton: {
+ minHeight: 30,
+ border: '1px solid lightgray'
+ }
+};
+
+interface Props {
+ classes: any;
+ settings: any;
+ setDesktopMode: (desktopMode: boolean) => void;
+ showResetSettings: (showDialog: boolean) => void;
+ tileServers: Array<TS.MapTileServer>;
+}
+
+const SettingsAdvanced = (props: Props) => {
+ const [tileServerDialog, setTileServerDialog] = useState<any>(undefined);
+
+ const handleEditTileServerClick = (
+ event: any,
+ tileServer: any,
+ isDefault: boolean
+ ) => {
+ event.preventDefault();
+ event.stopPropagation();
+ setTileServerDialog({ ...tileServer, isDefault });
+ };
+
+ const { classes } = props;
+
+ return (
+ <div style={{ width: '100%' }}>
+ <List className={classes.root}>
+ <ListItem className={classes.listItem}>
+ <Button
+ data-tid="resetSettingsTID"
+ onClick={() => props.showResetSettings(true)}
+ color="secondary"
+ style={{ marginLeft: -7 }}
+ >
+ {i18n.t('core:resetSettings')}
+ </Button>
+ <Button
+ data-tid="reloadAppTID"
+ onClick={() => {
+ window.location.reload();
+ }}
+ color="secondary"
+ >
+ {i18n.t('core:reloadApplication')}
+ </Button>
+ </ListItem>
+
+ <ListItem className={classes.listItem}>
+ <ListItemText primary="Enable mobile (small screen) mode" />
+ <Switch
+ data-tid="settingsSetDesktopMode"
+ disabled={!(typeof window.ExtDisplayMode === 'undefined')}
+ onClick={() => props.setDesktopMode(!props.settings.desktopMode)}
+ checked={!props.settings.desktopMode}
+ />
+ </ListItem>
+ <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:tileServerTitle')} />
+ <ListItemSecondaryAction>
+ <IconButton
+ aria-label={i18n.t('core:add')}
+ aria-haspopup="true"
+ edge="end"
+ data-tid="addTileServerTID"
+ onClick={event => handleEditTileServerClick(event, {}, true)}
+ >
+ <AddIcon />
+ </IconButton>
+ </ListItemSecondaryAction>
+ </ListItem>
+ <Paper elevation={2} style={{ margin: 2, padding: 5 }}>
+ {props.tileServers.length > 0 ? (
+ props.tileServers.map((tileServer, index) => (
+ <ListItem key={tileServer.uuid} className={classes.listItem}>
+ <ListItemText
+ primary={tileServer.name}
+ secondary={tileServer.serverURL}
+ />
+ <ListItemSecondaryAction>
+ {index === 0 && (
+ <Tooltip title={i18n.t('core:serverIsDefaultHelp')}>
+ <CheckIcon
+ data-tid="tileServerDefaultIndication"
+ style={{ marginLeft: 10 }}
+ />
+ </Tooltip>
+ )}
+ <IconButton
+ aria-label={i18n.t('core:options')}
+ aria-haspopup="true"
+ edge="end"
+ data-tid={'tileServerEdit_' + tileServer.name}
+ onClick={event =>
+ handleEditTileServerClick(event, tileServer, index === 0)
+ }
+ >
+ <EditIcon />
+ </IconButton>
+ </ListItemSecondaryAction>
+ </ListItem>
+ ))
+ ) : (
+ <ListItem key="noTileServers" className={classes.listItem}>
+ <ListItemText
+ primary={i18n.t('core:noTileServersTitle')}
+ secondary={i18n.t('core:addTileServersHelp')}
+ />
+ </ListItem>
+ )}
+ </Paper>
+ {/* <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:coloredFileExtensionsEnabled')} />
+ <Switch
+ data-tid="settingsSetColoredFileExtension"
+ onClick={() =>
+ this.props.setColoredFileExtension(
+ !this.props.settings.coloredFileExtension
+ )
+ }
+ checked={this.props.settings.coloredFileExtension}
+ />
+ </ListItem> */}
+ {/* <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:loadLocationMetaData')} />
+ <Switch
+ data-tid="settingsSetLoadsLocationMetaData"
+ onClick={() =>
+ this.props.setLoadsLocationMetaData(
+ !this.props.settings.loadsLocationMetaData
+ )
+ }
+ checked={this.props.settings.loadsLocationMetaData}
+ />
+ </ListItem> */}
+ </List>
+ {tileServerDialog && (
+ <MapTileServerDialog
+ open={tileServerDialog !== undefined}
+ onClose={() => setTileServerDialog(undefined)}
+ tileServer={tileServerDialog}
+ isDefault={tileServerDialog.isDefault}
+ />
+ )}
+ </div>
+ );
+};
+
+function mapStateToProps(state) {
+ return {
+ settings: getSettings(state),
+ tileServers: getMapTileServers(state)
+ };
+}
+
+function mapActionCreatorsToProps(dispatch) {
+ return bindActionCreators(
+ { setDesktopMode: SettingsActions.setDesktopMode },
+ dispatch
+ );
+}
+
+export default connect(
+ mapStateToProps,
+ mapActionCreatorsToProps
+ // @ts-ignore
+)(withStyles(styles, { withTheme: true })(SettingsAdvanced));
diff --git a/app/components/dialogs/settings/SettingsDialog.tsx b/app/components/dialogs/settings/SettingsDialog.tsx
index ac0579146..9ad2aef9e 100644
--- a/app/components/dialogs/settings/SettingsDialog.tsx
+++ b/app/components/dialogs/settings/SettingsDialog.tsx
@@ -40,6 +40,7 @@ import i18n from '-/services/i18n';
import { actions, getSupportedFileTypes } from '-/reducers/settings';
import { extend } from '-/utils/misc';
import AppConfig from '-/config';
+import SettingsAdvanced from '-/components/dialogs/settings/SettingsAdvanced';
const styles: any = () => ({
mainContent: {
@@ -206,7 +207,7 @@ const SettingsDialog = (props: Props) => {
value={currentTab}
onChange={handleTabClick}
indicatorColor="primary"
- variant="fullWidth"
+ // variant="scrollable"
>
<Tab
data-tid="generalSettingsDialog"
@@ -220,6 +221,10 @@ const SettingsDialog = (props: Props) => {
data-tid="keyBindingsSettingsDialog"
label={i18n.t('core:keyBindingsTab')}
/>
+ <Tab
+ data-tid="advancedSettingsDialogTID"
+ label={i18n.t('core:advancedSettingsTab')}
+ />
</Tabs>
</AppBar>
</>
@@ -277,9 +282,7 @@ const SettingsDialog = (props: Props) => {
className={props.classes.mainContent}
ref={settingsFileTypeRef}
>
- {currentTab === 0 && (
- <SettingsGeneral showResetSettings={setIsResetSettingsDialogOpened} />
- )}
+ {currentTab === 0 && <SettingsGeneral />}
{currentTab === 1 && (
<SettingsFileTypes
items={items}
@@ -294,6 +297,11 @@ const SettingsDialog = (props: Props) => {
/>
)}
{currentTab === 2 && <SettingsKeyBindings />}
+ {currentTab === 3 && (
+ <SettingsAdvanced
+ showResetSettings={setIsResetSettingsDialogOpened}
+ />
+ )}
</div>
</DialogContent>
);
diff --git a/app/components/dialogs/settings/SettingsGeneral.tsx b/app/components/dialogs/settings/SettingsGeneral.tsx
index 9a913055b..5916fe6b5 100644
--- a/app/components/dialogs/settings/SettingsGeneral.tsx
+++ b/app/components/dialogs/settings/SettingsGeneral.tsx
@@ -34,22 +34,15 @@ import InfoIcon from '@material-ui/icons/InfoOutlined';
import CheckIcon from '@material-ui/icons/Check';
import ToggleButton from '@material-ui/lab/ToggleButton';
import ToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup';
-import EditIcon from '@material-ui/icons/Edit';
-import IconButton from '@material-ui/core/IconButton';
-import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
-import AddIcon from '@material-ui/icons/Add';
import i18n from '-/services/i18n';
import {
actions as SettingsActions,
getPersistTagsInSidecarFile,
- getSettings,
- getMapTileServers
+ getSettings
} from '-/reducers/settings';
import ColorPickerDialog from '../ColorPickerDialog';
import TransparentBackground from '../../TransparentBackground';
import AppConfig from '-/config';
-import { TS } from '-/tagspaces.namespace';
-import MapTileServerDialog from '-/components/dialogs/settings/MapTileServerDialog';
const styles: any = {
root: {
@@ -84,14 +77,10 @@ interface Props {
setUseGenerateThumbnails: (useGenerateThumbnails: boolean) => void;
setTagDelimiter: (tagDelimiter: string) => void;
setMaxSearchResult: (maxResult: string) => void;
- setDesktopMode: (desktopMode: boolean) => void;
- showResetSettings: (showDialog: boolean) => void;
- tileServers: Array<TS.MapTileServer>;
}
const SettingsGeneral = (props: Props) => {
const [displayColorPicker, setDisplayColorPicker] = useState<boolean>(false);
- const [tileServerDialog, setTileServerDialog] = useState<any>(undefined);
const [displayTextColorPicker, setDisplayTextColorPicker] = useState<boolean>(
false
);
@@ -116,16 +105,6 @@ const SettingsGeneral = (props: Props) => {
props.setMaxSearchResult(event.target.value);
};
- const handleEditTileServerClick = (
- event: any,
- tileServer: any,
- isDefault: boolean
- ) => {
- event.preventDefault();
- event.stopPropagation();
- setTileServerDialog({ ...tileServer, isDefault });
- };
-
const { classes, persistTagsInSidecarFile } = props;
return (
@@ -337,15 +316,6 @@ const SettingsGeneral = (props: Props) => {
checked={props.settings.showUnixHiddenEntries}
/>
</ListItem>
- <ListItem className={classes.listItem}>
- <ListItemText primary="Enable mobile (small screen) mode" />
- <Switch
- data-tid="settingsSetDesktopMode"
- disabled={!(typeof window.ExtDisplayMode === 'undefined')}
- onClick={() => props.setDesktopMode(!props.settings.desktopMode)}
- checked={!props.settings.desktopMode}
- />
- </ListItem>
{/* <ListItem className={classes.listItem}>
<ListItemText style={{ maxWidth: '300px' }} primary={i18n.t('core:tagDelimiterChoose')} />
<Select
@@ -373,110 +343,7 @@ const SettingsGeneral = (props: Props) => {
onChange={handleMaxSearchResult}
/>
</ListItem>
- <ListItem className={classes.listItem}>
- <ListItemText primary={i18n.t('core:tileServerTitle')} />
- <ListItemSecondaryAction>
- <IconButton
- aria-label={i18n.t('core:add')}
- aria-haspopup="true"
- edge="end"
- data-tid="addTileServerTID"
- onClick={event => handleEditTileServerClick(event, {}, true)}
- >
- <AddIcon />
- </IconButton>
- </ListItemSecondaryAction>
- </ListItem>
- {props.tileServers.length > 0 ? (
- props.tileServers.map((tileServer, index) => (
- <ListItem key={tileServer.uuid} className={classes.listItem}>
- <ListItemText
- primary={tileServer.name}
- secondary={tileServer.serverURL}
- />
- <ListItemSecondaryAction>
- {index === 0 && (
- <Tooltip title={i18n.t('core:serverIsDefaultHelp')}>
- <CheckIcon
- data-tid="tileServerDefaultIndication"
- style={{ marginLeft: 10 }}
- />
- </Tooltip>
- )}
- <IconButton
- aria-label={i18n.t('core:options')}
- aria-haspopup="true"
- edge="end"
- data-tid={'tileServerEdit_' + tileServer.name}
- onClick={event =>
- handleEditTileServerClick(event, tileServer, index === 0)
- }
- >
- <EditIcon />
- </IconButton>
- </ListItemSecondaryAction>
- </ListItem>
- ))
- ) : (
- <ListItem key="noTileServers" className={classes.listItem}>
- <ListItemText
- primary={i18n.t('core:noTileServersTitle')}
- secondary={i18n.t('core:addTileServersHelp')}
- />
- </ListItem>
- )}
- {/* <ListItem className={classes.listItem}>
- <ListItemText primary={i18n.t('core:coloredFileExtensionsEnabled')} />
- <Switch
- data-tid="settingsSetColoredFileExtension"
- onClick={() =>
- this.props.setColoredFileExtension(
- !this.props.settings.coloredFileExtension
- )
- }
- checked={this.props.settings.coloredFileExtension}
- />
- </ListItem> */}
- {/* <ListItem className={classes.listItem}>
- <ListItemText primary={i18n.t('core:loadLocationMetaData')} />
- <Switch
- data-tid="settingsSetLoadsLocationMetaData"
- onClick={() =>
- this.props.setLoadsLocationMetaData(
- !this.props.settings.loadsLocationMetaData
- )
- }
- checked={this.props.settings.loadsLocationMetaData}
- />
- </ListItem> */}
- <ListItem className={classes.listItem}>
- <Button
- data-tid="resetSettingsTID"
- onClick={() => props.showResetSettings(true)}
- color="secondary"
- style={{ marginLeft: -7 }}
- >
- {i18n.t('core:resetSettings')}
- </Button>
- <Button
- data-tid="reloadAppTID"
- onClick={() => {
- window.location.reload();
- }}
- color="secondary"
- >
- {i18n.t('core:reloadApplication')}
- </Button>
- </ListItem>
</List>
- {tileServerDialog && (
- <MapTileServerDialog
- open={tileServerDialog !== undefined}
- onClose={() => setTileServerDialog(undefined)}
- tileServer={tileServerDialog}
- isDefault={tileServerDialog.isDefault}
- />
- )}
</>
);
};
@@ -484,8 +351,7 @@ const SettingsGeneral = (props: Props) => {
function mapStateToProps(state) {
return {
settings: getSettings(state),
- persistTagsInSidecarFile: getPersistTagsInSidecarFile(state),
- tileServers: getMapTileServers(state)
+ persistTagsInSidecarFile: getPersistTagsInSidecarFile(state)
};
}
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index 83a0d80c5..85b38c4fe 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -72,6 +72,7 @@
"generalTab": "General",
"fileTypeTab": "File Types",
"keyBindingsTab": "Key Bindings",
+ "advancedSettingsTab": "Advanced",
"fileViewer": "File Viewer",
"reloadDocument": "Reload Document",
"selectAllFiles": "Select all files",