Skip to content

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

chore: introducing tsselect element, cleaning up UI

Ilian Sapundshiev6d9ceca07fd4
diff --git a/src/renderer/components/PerspectiveSelector.tsx b/src/renderer/components/PerspectiveSelector.tsx
index fea202c92..de672dc64 100644
--- a/src/renderer/components/PerspectiveSelector.tsx
+++ b/src/renderer/components/PerspectiveSelector.tsx
@@ -21,7 +21,7 @@ import { useSelector } from 'react-redux';
import ListItemIcon from '@mui/material/ListItemIcon';
import LayersClearIcon from '@mui/icons-material/LayersClear';
import ListItemText from '@mui/material/ListItemText';
-import TsTextField from '-/components/TsTextField';
+import TsSelect from '-/components/TsSelect';
import MenuItem from '@mui/material/MenuItem';
import { AvailablePerspectives, PerspectiveIDs } from '-/perspectives';
import { Pro } from '-/pro';
@@ -32,12 +32,13 @@ import { isDesktopMode } from '-/reducers/settings';
interface Props {
defaultValue: string;
onChange: (event: any) => void;
+ fullWidth?: boolean;
testId: string;
label?: string;
}
function PerspectiveSelector(props: Props) {
- const { defaultValue, onChange, testId, label } = props;
+ const { defaultValue, onChange, testId, label, fullWidth = true } = props;
const desktopMode = useSelector(isDesktopMode);
const { t } = useTranslation();
@@ -80,16 +81,15 @@ function PerspectiveSelector(props: Props) {
});
return (
- <TsTextField
+ <TsSelect
data-tid={testId}
defaultValue={defaultValue}
onChange={onChange}
- select
label={label}
- size={desktopMode ? 'small' : 'medium'}
+ fullWidth={fullWidth}
>
{perspectiveSelectorMenuItems}
- </TsTextField>
+ </TsSelect>
);
}
diff --git a/src/renderer/components/TsSelect.tsx b/src/renderer/components/TsSelect.tsx
new file mode 100644
index 000000000..053df04f0
--- /dev/null
+++ b/src/renderer/components/TsSelect.tsx
@@ -0,0 +1,55 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2024-present TagSpaces GmbH
+ *
+ * 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 from 'react';
+import { useSelector } from 'react-redux';
+import TextField, { TextFieldProps } from '@mui/material/TextField';
+import FormHelperText from '@mui/material/FormHelperText';
+import { isDesktopMode } from '-/reducers/settings';
+
+type TSTextFieldProps = TextFieldProps & {
+ updateValue?: (string) => void;
+ retrieveValue?: () => string;
+};
+
+function TsSelect(props: TSTextFieldProps) {
+ const { children, label } = props;
+ const desktopMode = useSelector(isDesktopMode);
+
+ return (
+ <>
+ <FormHelperText style={{ marginLeft: 0, marginTop: 0 }}>
+ {label}
+ </FormHelperText>
+ <TextField
+ style={{ cursor: 'context-menu', marginTop: 0 }}
+ margin="dense"
+ size={desktopMode ? 'small' : 'medium'}
+ variant="outlined"
+ select
+ fullWidth={true}
+ {...props}
+ label={undefined}
+ >
+ {children}
+ </TextField>
+ </>
+ );
+}
+
+export default TsSelect;
diff --git a/src/renderer/components/dialogs/AboutDialog.tsx b/src/renderer/components/dialogs/AboutDialog.tsx
index d39a3d4fa..1135605c7 100644
--- a/src/renderer/components/dialogs/AboutDialog.tsx
+++ b/src/renderer/components/dialogs/AboutDialog.tsx
@@ -221,7 +221,7 @@ function AboutDialog(props: Props) {
data-tid="openLicenseDialog"
onClick={() => openLicenseDialog()}
>
- License Agreement
+ {t('core:license')}
</Button>
</Typography>
</DialogContent>
diff --git a/src/renderer/components/dialogs/EditTagGroupDialog.tsx b/src/renderer/components/dialogs/EditTagGroupDialog.tsx
index 48d6157df..58a235b41 100644
--- a/src/renderer/components/dialogs/EditTagGroupDialog.tsx
+++ b/src/renderer/components/dialogs/EditTagGroupDialog.tsx
@@ -35,6 +35,7 @@ import { TS } from '-/tagspaces.namespace';
import { Pro } from '-/pro';
import DialogCloseButton from '-/components/dialogs/DialogCloseButton';
import TsTextField from '-/components/TsTextField';
+import TsSelect from '-/components/TsSelect';
import Tag from '-/components/Tag';
import { getSaveTagInLocation } from '-/reducers/settings';
import { useTranslation } from 'react-i18next';
@@ -168,9 +169,7 @@ function EditTagGroupDialog(props: Props) {
<FormHelperText style={{ marginLeft: 0, marginTop: 0 }}>
{t('core:tagGroupLocation')}
</FormHelperText>
- <TsTextField
- variant="outlined"
- select
+ <TsSelect
fullWidth={false}
defaultValue={locationId}
onChange={(event: ChangeEvent<HTMLInputElement>) => {
@@ -188,7 +187,7 @@ function EditTagGroupDialog(props: Props) {
{t('core:location') + ': ' + location.name}
</MenuItem>
))}
- </TsTextField>
+ </TsSelect>
</FormControl>
)}
<ListItem style={{ paddingLeft: 0, paddingRight: 0 }}>
diff --git a/src/renderer/components/dialogs/LinkGeneratorDialog.tsx b/src/renderer/components/dialogs/LinkGeneratorDialog.tsx
index e36b3cffd..0aa35bc7d 100644
--- a/src/renderer/components/dialogs/LinkGeneratorDialog.tsx
+++ b/src/renderer/components/dialogs/LinkGeneratorDialog.tsx
@@ -31,6 +31,7 @@ import InputAdornment from '@mui/material/InputAdornment';
import MenuItem from '@mui/material/MenuItem';
import Links from 'assets/links';
import TsTextField from '-/components/TsTextField';
+import TsSelect from '-/components/TsSelect';
import { extractTitle } from '@tagspaces/tagspaces-common/paths';
import { useTranslation } from 'react-i18next';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
@@ -90,9 +91,7 @@ function LinkGeneratorDialog(props: Props) {
<DialogCloseButton testId="closeLinkGeneratorTID" onClose={onClose} />
</DialogTitle>
<DialogContent style={{ overflow: 'auto', height: 450 }}>
- <TsTextField
- style={{ marginTop: 8 }}
- select
+ <TsSelect
label={
<>
{t('core:linkValidity')}
@@ -110,10 +109,9 @@ function LinkGeneratorDialog(props: Props) {
<MenuItem value={60 * 60 * 24}>1 {t('core:day')}</MenuItem>
<MenuItem value={60 * 60 * 24 * 3}>3 {t('core:days')}</MenuItem>
<MenuItem value={60 * 60 * 24 * 7}>7 {t('core:days')}</MenuItem>
- </TsTextField>
+ </TsSelect>
<TsTextField
name="path"
- style={{ marginTop: 15 }}
InputProps={{
readOnly: true,
endAdornment: (
@@ -141,12 +139,12 @@ function LinkGeneratorDialog(props: Props) {
</InputAdornment>
),
}}
- // label={t('core:downloadLink')}
+ label={t('core:downloadLink')}
value={signedLink.current}
/>
<TsTextField
name="path"
- // label={t('core:qrCode')}
+ label={t('core:qrCode')}
value={' '}
InputProps={{
readOnly: true,
diff --git a/src/renderer/components/dialogs/settings/SettingsAdvanced.tsx b/src/renderer/components/dialogs/settings/SettingsAdvanced.tsx
index c8f81975e..9c7291ce9 100644
--- a/src/renderer/components/dialogs/settings/SettingsAdvanced.tsx
+++ b/src/renderer/components/dialogs/settings/SettingsAdvanced.tsx
@@ -28,8 +28,6 @@ import EditIcon from '@mui/icons-material/Edit';
import IconButton from '@mui/material/IconButton';
import ListItemSecondaryAction from '@mui/material/ListItemSecondaryAction';
import Switch from '@mui/material/Switch';
-import Select from '@mui/material/Select';
-import Input from '@mui/material/Input';
import MenuItem from '@mui/material/MenuItem';
import AppConfig from '-/AppConfig';
import {
@@ -41,6 +39,7 @@ import {
import { TS } from '-/tagspaces.namespace';
import MapTileServerDialog from '-/components/dialogs/settings/MapTileServerDialog';
import TsTextField from '-/components/TsTextField';
+import TsSelect from '-/components/TsSelect';
import { Pro } from '-/pro';
import { ProLabel } from '-/components/HelperComponents';
import InfoIcon from '-/components/InfoIcon';
@@ -196,10 +195,8 @@ function SettingsAdvanced(props: Props) {
</IconButton>
</Tooltip>
</ListItemIcon>
- <TsTextField
+ <TsSelect
data-tid="fileOpenTID"
- variant="outlined"
- select
fullWidth={false}
title={t('core:fileOpenHistoryTitle')}
value={settings[historyKeys.fileOpenKey]}
@@ -211,7 +208,7 @@ function SettingsAdvanced(props: Props) {
<MenuItem value={10}>10</MenuItem>
<MenuItem value={50}>50</MenuItem>
<MenuItem value={100}>100</MenuItem>
- </TsTextField>
+ </TsSelect>
</ListItem>
<ListItem>
<ListItemText primary={t('core:folderOpenHistory')} />
@@ -227,10 +224,8 @@ function SettingsAdvanced(props: Props) {
</IconButton>
</Tooltip>
</ListItemIcon>
- <TsTextField
+ <TsSelect
data-tid="folderOpenTID"
- variant="outlined"
- select
fullWidth={false}
title={t('core:folderOpenHistoryTitle')}
value={settings[historyKeys.folderOpenKey]}
@@ -242,7 +237,7 @@ function SettingsAdvanced(props: Props) {
<MenuItem value={10}>10</MenuItem>
<MenuItem value={50}>50</MenuItem>
<MenuItem value={100}>100</MenuItem>
- </TsTextField>
+ </TsSelect>
</ListItem>
<ListItem>
<ListItemText primary={t('core:fileEditHistory')} />
@@ -258,10 +253,8 @@ function SettingsAdvanced(props: Props) {
</IconButton>
</Tooltip>
</ListItemIcon>
- <TsTextField
+ <TsSelect
data-tid="fileEditTID"
- variant="outlined"
- select
fullWidth={false}
title={t('core:fileEditHistoryTitle')}
value={settings[historyKeys.fileEditKey]}
@@ -273,7 +266,7 @@ function SettingsAdvanced(props: Props) {
<MenuItem value={10}>10</MenuItem>
<MenuItem value={50}>50</MenuItem>
<MenuItem value={100}>100</MenuItem>
- </TsTextField>
+ </TsSelect>
</ListItem>
<ListItem>
<ListItemText primary={t('core:searchHistory')} />
@@ -291,10 +284,8 @@ function SettingsAdvanced(props: Props) {
</IconButton>
</Tooltip>
</ListItemIcon>
- <TsTextField
+ <TsSelect
data-tid="searchHistoryTID"
- variant="outlined"
- select
fullWidth={false}
title={t('core:searchHistoryTitle')}
value={settings[historyKeys.searchHistoryKey]}
@@ -306,7 +297,7 @@ function SettingsAdvanced(props: Props) {
<MenuItem value={10}>10</MenuItem>
<MenuItem value={50}>50</MenuItem>
<MenuItem value={100}>100</MenuItem>
- </TsTextField>
+ </TsSelect>
</ListItem>
<ConfirmDialog
open={confirmDialogKey !== null}
@@ -364,10 +355,8 @@ function SettingsAdvanced(props: Props) {
</ListItem>
<ListItem>
<ListItemText primary={t('core:geoTaggingFormat')} />
- <TsTextField
+ <TsSelect
disabled={geoTaggingFormatDisabled}
- variant="outlined"
- select
fullWidth={false}
data-tid="geoTaggingFormatTID"
title={
@@ -387,7 +376,7 @@ function SettingsAdvanced(props: Props) {
{geoTagging.toUpperCase()}
</MenuItem>
))}
- </TsTextField>
+ </TsSelect>
</ListItem>
<ListItem>
<ListItemText primary={t('core:tileServerTitle')} />
diff --git a/src/renderer/components/dialogs/settings/SettingsGeneral.tsx b/src/renderer/components/dialogs/settings/SettingsGeneral.tsx
index 43a07cd24..f090652d4 100644
--- a/src/renderer/components/dialogs/settings/SettingsGeneral.tsx
+++ b/src/renderer/components/dialogs/settings/SettingsGeneral.tsx
@@ -42,6 +42,7 @@ import ColorPickerDialog from '-/components/dialogs/ColorPickerDialog';
import PerspectiveSelector from '-/components/PerspectiveSelector';
import TransparentBackground from '-/components/TransparentBackground';
import TsTextField from '-/components/TsTextField';
+import TsSelect from '-/components/TsSelect';
import { BetaLabel } from '-/components/HelperComponents';
import { PerspectiveIDs } from '-/perspectives';
import { AppDispatch } from '-/reducers/app';
@@ -86,10 +87,8 @@ function SettingsGeneral() {
<List style={{ overflowX: 'hidden', overflowY: 'auto', height: '100%' }}>
<ListItem>
<ListItemText primary={t('core:interfaceLanguage')} />
- <TsTextField
+ <TsSelect
data-tid="settingsSetLanguage"
- variant="outlined"
- select
fullWidth={false}
value={settings.interfaceLanguage}
onChange={(event: any) => {
@@ -105,14 +104,12 @@ function SettingsGeneral() {
{language.title}
</MenuItem>
))}
- </TsTextField>
+ </TsSelect>
</ListItem>
<ListItem>
<ListItemText primary={t('core:themeSelector')} />
- <TsTextField
+ <TsSelect
data-tid="settingsSetCurrentTheme"
- variant="outlined"
- select
fullWidth={false}
value={settings.currentTheme}
onChange={(event: any) =>
@@ -126,14 +123,12 @@ function SettingsGeneral() {
{theme === 'system' && t('core:systemScheme')}
</MenuItem>
))}
- </TsTextField>
+ </TsSelect>
</ListItem>
<ListItem>
<ListItemText primary={t('core:themeRegularSelector')} />
- <TsTextField
+ <TsSelect
data-tid="settingsCurrentRegularThemeTID"
- variant="outlined"
- select
fullWidth={false}
value={settings.currentRegularTheme}
onChange={(event: any) =>
@@ -145,14 +140,12 @@ function SettingsGeneral() {
{theme.charAt(0).toUpperCase() + theme.slice(1)}
</MenuItem>
))}
- </TsTextField>
+ </TsSelect>
</ListItem>
<ListItem>
<ListItemText primary={t('core:themeDarkSelector')} />
- <TsTextField
+ <TsSelect
data-tid="settingsCurrentDarkThemeTID"
- variant="outlined"
- select
fullWidth={false}
value={settings.currentDarkTheme}
onChange={(event: any) =>
@@ -164,11 +157,12 @@ function SettingsGeneral() {
{theme.charAt(0).toUpperCase() + theme.slice(1)}
</MenuItem>
))}
- </TsTextField>
+ </TsSelect>
</ListItem>
<ListItem>
<ListItemText primary={t('createLocationDefaultPerspective')} />
<PerspectiveSelector
+ fullWidth={false}
onChange={changePerspective}
defaultValue={defaultPerspective}
testId="changePerspectiveInSettingsTID"
diff --git a/src/renderer/perspectives/grid/components/GridSettingsDialog.tsx b/src/renderer/perspectives/grid/components/GridSettingsDialog.tsx
index 38e95b6af..9a8cbcda4 100644
--- a/src/renderer/perspectives/grid/components/GridSettingsDialog.tsx
+++ b/src/renderer/perspectives/grid/components/GridSettingsDialog.tsx
@@ -31,7 +31,6 @@ import {
Button,
FormHelperText,
Typography,
- TextField,
Paper,
Box,
} from '@mui/material';
@@ -45,6 +44,7 @@ import RadioUncheckedIcon from '@mui/icons-material/RadioButtonUnchecked';
import DraggablePaper from '-/components/DraggablePaper';
import DialogCloseButton from '-/components/dialogs/DialogCloseButton';
import TsTextField from '-/components/TsTextField';
+import TsSelect from '-/components/TsSelect';
import { Pro } from '-/pro';
import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';
@@ -338,13 +338,9 @@ function GridSettingsDialog(props: Props) {
<ListItemText primary={t('core:singleClickSelects')} />
</MenuItem>
<Divider />
- <FormControl
- fullWidth={true}
- style={{ overflow: 'visible', marginTop: 20 }}
- >
- <TsTextField
- select
- label={t('core:pageLimit')}
+ <FormControl fullWidth={true}>
+ <TsSelect
+ label={t('core:pageLimitHelp')}
name="limit"
defaultValue={gridPageLimit}
onChange={handleGridPaginationLimit}
@@ -354,8 +350,8 @@ function GridSettingsDialog(props: Props) {
<MenuItem value={100}>100</MenuItem>
<MenuItem value={500}>500</MenuItem>
<MenuItem value={1000}>1000</MenuItem>
- </TsTextField>
- <FormHelperText>{t('core:pageLimitHelp')}</FormHelperText>
+ </TsSelect>
+ {/* <FormHelperText>{t('core:pageLimitHelp')}</FormHelperText> */}
</FormControl>
</DialogContent>
<DialogActions style={{ justifyContent: 'space-between' }}>