Skip to content

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

feat: configuring tagging method in extconfig, adding isAmplify in extconfig, fix loading default location (#1370)

Ilian428545c2fd00
diff --git a/app/components/dialogs/settings/SettingsGeneral.tsx b/app/components/dialogs/settings/SettingsGeneral.tsx
index 537e84233..fddc43c35 100644
--- a/app/components/dialogs/settings/SettingsGeneral.tsx
+++ b/app/components/dialogs/settings/SettingsGeneral.tsx
@@ -25,13 +25,23 @@ import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import MenuItem from '@material-ui/core/MenuItem';
import Switch from '@material-ui/core/Switch';
+import Tooltip from '@material-ui/core/Tooltip';
import Input from '@material-ui/core/Input';
import Select from '@material-ui/core/Select';
import Button from '@material-ui/core/Button';
+import InfoIcon from '@material-ui/icons/InfoOutlined';
+import ToggleButton from '@material-ui/lab/ToggleButton';
+import ToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup';
import i18n from '-/services/i18n';
-import { actions as SettingsActions, getSettings } from '-/reducers/settings';
+import {
+ actions as SettingsActions,
+ getPersistTagsInSidecarFile,
+ getSettings
+} from '-/reducers/settings';
import ColorPickerDialog from '../ColorPickerDialog';
import TransparentBackground from '../../TransparentBackground';
+import AppConfig from '-/config';
+import Typography from '@material-ui/core/Typography';
const styles: any = {
root: {
@@ -55,6 +65,7 @@ interface Props {
setTagTextColor: (tagTextColor: string) => void;
classes: any;
settings: any;
+ persistTagsInSidecarFile: boolean;
toggleShowUnixHiddenEntries: () => void;
setCurrentTheme: (theme: string) => void;
setLanguage: (language: string) => void;
@@ -129,6 +140,73 @@ const SettingsGeneral = (props: Props) => {
))}
</Select>
</ListItem>
+ <ListItem
+ className={classes.listItem}
+ title={
+ AppConfig.useSidecarsForFileTaggingDisableSetting
+ ? 'This setting is managed with an external configuration'
+ : ''
+ }
+ >
+ <ListItemText primary="File tagging method" />
+ {AppConfig.useSidecarsForFileTaggingDisableSetting ? (
+ <Button size="small" variant="outlined" disabled>
+ {props.persistTagsInSidecarFile
+ ? 'Use Sidecar Files'
+ : 'Rename Files'}
+ </Button>
+ ) : (
+ <ToggleButtonGroup
+ value={props.persistTagsInSidecarFile}
+ size="small"
+ exclusive
+ >
+ <ToggleButton
+ value={false}
+ data-tid="settingsSetPersistTagsInFileName"
+ onClick={() => props.setPersistTagsInSidecarFile(false)}
+ >
+ <Tooltip
+ arrow
+ title={
+ <Typography color="inherit">
+ Use the name of file for saving the tags - Tagging the file{' '}
+ <b>image.jpg</b> with a tag <b>sunset</b> will rename it to{' '}
+ <b>image[sunset].jpg</b>
+ </Typography>
+ }
+ >
+ <div style={{ display: 'flex' }}>
+ Rename Files&nbsp;&nbsp;
+ <InfoIcon />
+ </div>
+ </Tooltip>
+ </ToggleButton>
+ <ToggleButton
+ value={true}
+ data-tid="settingsSetPersistTagsInSidecarFile"
+ onClick={() => props.setPersistTagsInSidecarFile(true)}
+ >
+ <Tooltip
+ arrow
+ title={
+ <Typography color="inherit">
+ Use sidecar file for saving the tags - Tagging the file{' '}
+ <b>image.jpg</b> with a tag <b>sunset</b> will save this tag{' '}
+ in an additional sidecar file called <b>image.jpg.json</b>{' '}
+ located in a sub folder with the name <b>.ts</b>
+ </Typography>
+ }
+ >
+ <div style={{ display: 'flex' }}>
+ Use Sidecar Files&nbsp;&nbsp;
+ <InfoIcon />
+ </div>
+ </Tooltip>
+ </ToggleButton>
+ </ToggleButtonGroup>
+ )}
+ </ListItem>
<ListItem className={classes.listItem}>
<ListItemText primary={i18n.t('core:checkForNewVersionOnStartup')} />
<Switch
@@ -139,18 +217,6 @@ const SettingsGeneral = (props: Props) => {
checked={props.settings.checkForUpdates}
/>
</ListItem>
- <ListItem className={classes.listItem}>
- <ListItemText primary={i18n.t('core:persistTagsInSidecarFile')} />
- <Switch
- data-tid="settingsSetPersistTagsInSidecarFile"
- onClick={() =>
- props.setPersistTagsInSidecarFile(
- !props.settings.persistTagsInSidecarFile
- )
- }
- checked={props.settings.persistTagsInSidecarFile}
- />
- </ListItem>
<ListItem className={classes.listItem}>
<ListItemText primary={i18n.t('core:addTagsToLibrary')} />
<Switch
@@ -223,14 +289,16 @@ const SettingsGeneral = (props: Props) => {
/>
)}
</ListItem>
- <ListItem className={classes.listItem}>
- <ListItemText primary={i18n.t('core:useTrashCan')} />
- <Switch
- data-tid="settingsSetUseTrashCan"
- onClick={() => props.setUseTrashCan(!props.settings.useTrashCan)}
- checked={props.settings.useTrashCan}
- />
- </ListItem>
+ {AppConfig.isElectron && (
+ <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:useTrashCan')} />
+ <Switch
+ data-tid="settingsSetUseTrashCan"
+ onClick={() => props.setUseTrashCan(!props.settings.useTrashCan)}
+ checked={props.settings.useTrashCan}
+ />
+ </ListItem>
+ )}
<ListItem className={classes.listItem}>
<ListItemText primary={i18n.t('core:showUnixHiddenFiles')} />
<Switch
@@ -345,7 +413,8 @@ const SettingsGeneral = (props: Props) => {
function mapStateToProps(state) {
return {
- settings: getSettings(state)
+ settings: getSettings(state),
+ persistTagsInSidecarFile: getPersistTagsInSidecarFile(state)
};
}
diff --git a/app/components/menus/TagGroupMenu.tsx b/app/components/menus/TagGroupMenu.tsx
index 91452acbf..5f4facebb 100644
--- a/app/components/menus/TagGroupMenu.tsx
+++ b/app/components/menus/TagGroupMenu.tsx
@@ -26,7 +26,10 @@ import DeleteTagGroupIcon from '@material-ui/icons/DeleteForever';
import SortTagGroupIcon from '@material-ui/icons/SortByAlpha';
import ShowEntriesWithTagIcon from '@material-ui/icons/SearchOutlined';
import TagIcon from '@material-ui/icons/LocalOffer';
-import InfoIcon from '@material-ui/icons/HelpOutlineOutlined';
+import InfoIcon from '@material-ui/icons/InfoOutlined';
+import Tooltip from '@material-ui/core/Tooltip';
+import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
+import IconButton from '@material-ui/core/IconButton';
import CollectTagsIcon from '@material-ui/icons/Voicemail';
import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
@@ -39,9 +42,6 @@ import { getMaxSearchResults } from '-/reducers/settings';
import { actions as AppActions } from '-/reducers/app';
import { actions as LocationIndexActions } from '-/reducers/location-index';
import { SearchQuery } from '-/services/search';
-import { Tooltip } from '@material-ui/core';
-import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
-import IconButton from '@material-ui/core/IconButton';
interface Props {
classes?: any;
@@ -150,7 +150,7 @@ const TagGroupMenu = (props: Props) => {
</ListItemIcon>
<ListItemText primary={i18n.t('core:showFilesWithTags')} />
<ListItemSecondaryAction>
- <Tooltip title={i18n.t('core:showFilesWithTagsTooltip')}>
+ <Tooltip arrow title={i18n.t('core:showFilesWithTagsTooltip')}>
<IconButton edge="end" aria-label="delete">
<InfoIcon />
</IconButton>
diff --git a/app/config.ts b/app/config.ts
index aecf5bdcf..130e9ea6b 100644
--- a/app/config.ts
+++ b/app/config.ts
@@ -99,6 +99,13 @@ export const AppConfig = {
isCordovaAndroid,
isCordova: isCordovaiOS || isCordovaAndroid,
isMobile: isCordovaiOS || isCordovaAndroid || isIOS || isAndroid,
+ isAmplify: window.ExtIsAmplify !== undefined ? window.ExtIsAmplify : false,
+ useSidecarsForFileTagging:
+ window.ExtUseSidecarsForFileTagging !== undefined
+ ? window.ExtUseSidecarsForFileTagging
+ : false,
+ useSidecarsForFileTaggingDisableSetting:
+ window.ExtUseSidecarsForFileTagging !== undefined,
customLogo: window.ExtLogoURL || false,
showAdvancedSearch:
window.ExtShowAdvancedSearch !== undefined
diff --git a/app/containers/Root.tsx b/app/containers/Root.tsx
index 33b89ea8c..1ac7b6c77 100644
--- a/app/containers/Root.tsx
+++ b/app/containers/Root.tsx
@@ -59,7 +59,7 @@ export default function Root({ store, persistor }: RootType) {
onBeforeLift={() => {
// @ts-ignore
// eslint-disable-next-line react/prop-types
- if (!AppConfig.isWeb) {
+ if (!AppConfig.isAmplify) {
// || store.app.user !== undefined
// @ts-ignore
// eslint-disable-next-line react/prop-types
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index 01b5c62d2..af0e69e18 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -59,7 +59,6 @@ import {
} from '-/utils/misc';
import i18n from '../services/i18n';
import { Pro } from '../pro';
-// import { getThumbnailURLPromise } from '../services/thumbsgenerator';
import { actions as LocationIndexActions } from './location-index';
import { Tag } from './taglibrary';
import {
@@ -111,7 +110,6 @@ export const types = {
TOGGLE_CREATE_FILE_DIALOG: 'APP/TOGGLE_CREATE_FILE_DIALOG',
TOGGLE_DELETE_MULTIPLE_ENTRIES_DIALOG:
'APP/TOGGLE_DELETE_MULTIPLE_ENTRIES_DIALOG',
- // TOGGLE_SELECT_DIRECTORY_DIALOG: 'APP/TOGGLE_SELECT_DIRECTORY_DIALOG',
TOGGLE_UPLOAD_DIALOG: 'APP/TOGGLE_UPLOAD_DIALOG',
CLEAR_UPLOAD_DIALOG: 'APP/CLEAR_UPLOAD_DIALOG',
TOGGLE_PROGRESS_DIALOG: 'APP/TOGGLE_PROGRESS_DIALOG',
diff --git a/app/reducers/settings.ts b/app/reducers/settings.ts
index 48aa5961e..965a074f8 100644
--- a/app/reducers/settings.ts
+++ b/app/reducers/settings.ts
@@ -525,7 +525,9 @@ export const getSupportedLanguages = (state: any) => state.settings.languages;
export const getCalculateTags = (state: any) => state.settings.calculateTags;
export const getUseTrashCan = (state: any) => state.settings.useTrashCan;
export const getPersistTagsInSidecarFile = (state: any) =>
- state.settings.persistTagsInSidecarFile;
+ AppConfig.useSidecarsForFileTaggingDisableSetting
+ ? AppConfig.useSidecarsForFileTagging
+ : state.settings.persistTagsInSidecarFile;
export const getUseGenerateThumbnails = (state: any) =>
state.settings.useGenerateThumbnails;
export const getUseTextExtraction = (state: any) =>
diff --git a/app/reducers/tagging-actions.ts b/app/reducers/tagging-actions.ts
index 25ea11be9..0c1d2f700 100644
--- a/app/reducers/tagging-actions.ts
+++ b/app/reducers/tagging-actions.ts
@@ -36,6 +36,7 @@ import { formatDateTime4Tag, isPlusCode } from '../utils/misc';
import PlatformIO from '../services/platform-io';
import { Pro } from '../pro';
import GlobalSearch from '../services/search-index';
+import { getPersistTagsInSidecarFile } from './settings';
export const defaultTagLocation = OpenLocationCode.encode(51.48, 0, undefined); // default tag coordinate Greenwich
@@ -149,7 +150,7 @@ const actions = {
console.log('No sidecar found ' + error);
}
- if (!entryProperties.isFile || settings.persistTagsInSidecarFile) {
+ if (!entryProperties.isFile || getPersistTagsInSidecarFile(getState())) {
// Handling adding tags in sidecar
if (fsEntryMeta) {
const uniqueTags = getNonExistingTags(
@@ -321,7 +322,7 @@ const actions = {
// Work around solution
delete tag.functionality;
const entryProperties = await PlatformIO.getPropertiesPromise(path);
- if (entryProperties.isFile && !settings.persistTagsInSidecarFile) {
+ if (entryProperties.isFile && !getPersistTagsInSidecarFile(getState())) {
tag.type = 'plain';
}
}