Skip to content

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

chore: refactoring dialogs

Ilian Sapundshieve652f9e6897c
diff --git a/src/renderer/components/CommonIcons.tsx b/src/renderer/components/CommonIcons.tsx
index 0cf7829cd..a8b35a5ae 100644
--- a/src/renderer/components/CommonIcons.tsx
+++ b/src/renderer/components/CommonIcons.tsx
@@ -110,6 +110,8 @@ export { default as SearchIcon } from '@mui/icons-material/Search';
export { default as CloseIcon } from '@mui/icons-material/Close';
+export { default as ArrowBackIcon } from '@mui/icons-material/ArrowBackIos';
+
export { default as SelectedIcon } from '@mui/icons-material/CheckCircle';
export { default as UnSelectedIcon } from '@mui/icons-material/RadioButtonUnchecked';
diff --git a/src/renderer/components/dialogs/AboutDialog.tsx b/src/renderer/components/dialogs/AboutDialog.tsx
index 26f972631..98574f258 100644
--- a/src/renderer/components/dialogs/AboutDialog.tsx
+++ b/src/renderer/components/dialogs/AboutDialog.tsx
@@ -126,7 +126,7 @@ function AboutDialog(props: Props) {
aria-labelledby="draggable-dialog-title"
>
<TsDialogTitle
- title={productName}
+ dialogTitle={productName}
onClose={onClose}
closeButtonTestId="closeAboutDialogTID"
/>
diff --git a/src/renderer/components/dialogs/CreateEditLocationDialog.tsx b/src/renderer/components/dialogs/CreateEditLocationDialog.tsx
index 2257d440c..7cd84d398 100644
--- a/src/renderer/components/dialogs/CreateEditLocationDialog.tsx
+++ b/src/renderer/components/dialogs/CreateEditLocationDialog.tsx
@@ -43,7 +43,8 @@ import CheckIcon from '@mui/icons-material/Check';
import RemoveIcon from '@mui/icons-material/RemoveCircleOutline';
import InputAdornment from '@mui/material/InputAdornment';
import TsIconButton from '-/components/TsIconButton';
-import { useSelector, useDispatch } from 'react-redux';
+import TsDialogTitle from '-/components/dialogs/components/TsDialogTitle';
+import { useSelector } from 'react-redux';
import { locationType } from '@tagspaces/tagspaces-common/misc';
import AppConfig from '-/AppConfig';
import {
@@ -80,19 +81,6 @@ import { CommonLocation } from '-/utils/CommonLocation';
import Visibility from '@mui/icons-material/Visibility';
import VisibilityOff from '@mui/icons-material/VisibilityOff';
import PasswordIcon from '@mui/icons-material/Password';
-import TooltipTS from '-/components/Tooltip';
-
-const PREFIX = 'CreateEditLocationDialog';
-
-const classes = {
- formControl: `${PREFIX}-formControl`,
-};
-
-const StyledDialog = styled(Dialog)(({ theme }) => ({
- [`& .${classes.formControl}`]: {
- marginLeft: 0,
- },
-}));
interface Props {
open: boolean;
@@ -577,8 +565,19 @@ function CreateEditLocationDialog(props: Props) {
locationTypeName = t('core:objectStorage');
}
+ const okButton = (
+ <TsButton
+ disabled={disableConfirmButton()}
+ onClick={preConfirm}
+ data-tid="confirmLocationCreation"
+ variant={fullScreen ? 'outlined' : 'contained'}
+ >
+ {t('core:ok')}
+ </TsButton>
+ );
+
return (
- <StyledDialog
+ <Dialog
open={open}
onClose={onClose}
fullScreen={fullScreen}
@@ -597,13 +596,14 @@ function CreateEditLocationDialog(props: Props) {
// }
}}
>
- <DialogTitle
- style={{ cursor: 'move', paddingBottom: 0 }}
- id="draggable-dialog-title"
+ <TsDialogTitle
+ dialogTitle={t('core:editLocationTitle')}
+ closeButtonTestId="closeCreateEditLocationTID"
+ onClose={onClose}
+ actionSlot={okButton}
>
{selectedLocation ? (
<>
- {t('core:editLocationTitle')}
<Typography
style={{ display: 'block', marginTop: -5 }}
variant="overline"
@@ -614,11 +614,7 @@ function CreateEditLocationDialog(props: Props) {
) : (
t('core:createLocationTitle')
)}
- <DialogCloseButton
- testId="closeCreateEditLocationTID"
- onClose={onClose}
- />
- </DialogTitle>
+ </TsDialogTitle>
<DialogContent
style={{
overflow: 'auto',
@@ -687,7 +683,6 @@ function CreateEditLocationDialog(props: Props) {
)}
{content}
<FormControlLabel
- className={classes.formControl}
labelPlacement="start"
style={{ justifyContent: 'space-between' }}
control={
@@ -703,7 +698,6 @@ function CreateEditLocationDialog(props: Props) {
label={t('core:startupLocation')}
/>
<FormControlLabel
- className={classes.formControl}
labelPlacement="start"
style={{ justifyContent: 'space-between' }}
control={
@@ -753,7 +747,6 @@ function CreateEditLocationDialog(props: Props) {
type === locationType.TYPE_CLOUD ||
AppConfig.isCordova
}
- className={classes.formControl}
labelPlacement="start"
style={{ justifyContent: 'space-between' }}
control={
@@ -788,7 +781,6 @@ function CreateEditLocationDialog(props: Props) {
<AccordionDetails>
<FormGroup style={{ width: '100%' }}>
<FormControlLabel
- className={classes.formControl}
labelPlacement="start"
style={{ justifyContent: 'space-between' }}
control={
@@ -810,7 +802,6 @@ function CreateEditLocationDialog(props: Props) {
}
/>
<FormControlLabel
- className={classes.formControl}
labelPlacement="start"
style={{ justifyContent: 'space-between' }}
control={
@@ -826,7 +817,6 @@ function CreateEditLocationDialog(props: Props) {
label={<>{t('core:disableThumbnailGeneration')}</>}
/>
<FormControlLabel
- className={classes.formControl}
labelPlacement="start"
style={{ justifyContent: 'space-between' }}
control={
@@ -848,7 +838,6 @@ function CreateEditLocationDialog(props: Props) {
}
/>
<FormControlLabel
- className={classes.formControl}
labelPlacement="start"
style={{ justifyContent: 'space-between' }}
control={
@@ -873,7 +862,6 @@ function CreateEditLocationDialog(props: Props) {
/>
{type === locationType.TYPE_CLOUD && (
<FormControlLabel
- className={classes.formControl}
labelPlacement="start"
style={{ justifyContent: 'space-between' }}
control={
@@ -892,7 +880,6 @@ function CreateEditLocationDialog(props: Props) {
)}
{AppConfig.useSidecarsForFileTaggingDisableSetting ? (
<FormControlLabel
- className={classes.formControl}
labelPlacement="start"
style={{ justifyContent: 'space-between' }}
control={
@@ -911,7 +898,6 @@ function CreateEditLocationDialog(props: Props) {
) : (
<FormControlLabel
labelPlacement="top"
- className={classes.formControl}
style={{ alignItems: 'start', marginBottom: 10 }}
control={
<ToggleButtonGroup
@@ -1009,7 +995,6 @@ function CreateEditLocationDialog(props: Props) {
</FormControl>
<>
<FormControlLabel
- className={classes.formControl}
disabled={!Pro}
labelPlacement="start"
style={{ justifyContent: 'space-between', marginTop: 15 }}
@@ -1178,18 +1163,13 @@ function CreateEditLocationDialog(props: Props) {
</Accordion>
)}
</DialogContent>
- <TsDialogActions>
- <TsButton onClick={() => onClose()}>{t('core:cancel')}</TsButton>
- <TsButton
- disabled={disableConfirmButton()}
- onClick={preConfirm}
- data-tid="confirmLocationCreation"
- variant="contained"
- >
- {t('core:ok')}
- </TsButton>
- </TsDialogActions>
- </StyledDialog>
+ {!fullScreen && (
+ <TsDialogActions>
+ <TsButton onClick={() => onClose()}>{t('core:cancel')}</TsButton>
+ {okButton}
+ </TsDialogActions>
+ )}
+ </Dialog>
);
}
diff --git a/src/renderer/components/dialogs/DialogCloseButton.tsx b/src/renderer/components/dialogs/DialogCloseButton.tsx
index 91abefec3..8c2a25bfc 100644
--- a/src/renderer/components/dialogs/DialogCloseButton.tsx
+++ b/src/renderer/components/dialogs/DialogCloseButton.tsx
@@ -35,9 +35,10 @@ function DialogCloseButton(props: Props) {
aria-label="close"
tabIndex={-1}
style={{
+ // float: 'right',
position: 'absolute',
- right: 5,
- top: 5,
+ right: 15,
+ top: 15,
}}
data-tid={testId && testId}
onClick={onClose}
diff --git a/src/renderer/components/dialogs/FilePreviewDialog.tsx b/src/renderer/components/dialogs/FilePreviewDialog.tsx
index e97ee0d88..ee32eaeea 100644
--- a/src/renderer/components/dialogs/FilePreviewDialog.tsx
+++ b/src/renderer/components/dialogs/FilePreviewDialog.tsx
@@ -173,7 +173,7 @@ function FilePreviewDialog(props: Props) {
>
<TsDialogTitle
//data-tid="importDialogTitle"
- title=""
+ dialogTitle=""
closeButtonTestId="closeFilePreviewTID"
onClose={onClose}
/>
diff --git a/src/renderer/components/dialogs/OnboardingDialog.tsx b/src/renderer/components/dialogs/OnboardingDialog.tsx
index 66f67b36e..3cdf73aca 100644
--- a/src/renderer/components/dialogs/OnboardingDialog.tsx
+++ b/src/renderer/components/dialogs/OnboardingDialog.tsx
@@ -122,7 +122,7 @@ function OnboardingDialog(props: Props) {
scroll="paper"
>
<TsDialogTitle
- title={''}
+ dialogTitle={''}
onClose={onClose}
closeButtonTestId="closeOnboardingDialog"
/>
diff --git a/src/renderer/components/dialogs/components/TsDialogTitle.tsx b/src/renderer/components/dialogs/components/TsDialogTitle.tsx
index 3c8cb52bc..abf637645 100644
--- a/src/renderer/components/dialogs/components/TsDialogTitle.tsx
+++ b/src/renderer/components/dialogs/components/TsDialogTitle.tsx
@@ -21,21 +21,29 @@ import { useSelector } from 'react-redux';
import useMediaQuery from '@mui/material/useMediaQuery';
import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';
-import { GoBackIcon } from '-/components/CommonIcons';
+import { ArrowBackIcon } from '-/components/CommonIcons';
import TsIconButton from '-/components/TsIconButton';
import DialogCloseButton from '-/components/dialogs/DialogCloseButton';
import DialogTitle, { DialogTitleProps } from '@mui/material/DialogTitle';
import { isDesktopMode } from '-/reducers/settings';
import AppConfig from '-/AppConfig';
-export type TSDialogActions = DialogTitleProps & {
- title: string;
+export type TSDialogTitle = DialogTitleProps & {
+ dialogTitle: string;
closeButtonTestId: string;
onClose: () => void;
+ actionSlot?: any;
};
-function TsDialogTitle(props: TSDialogActions) {
- const { style, title, onClose, closeButtonTestId, children } = props;
+function TsDialogTitle(props: TSDialogTitle) {
+ const {
+ style,
+ dialogTitle: title,
+ onClose,
+ closeButtonTestId,
+ children,
+ actionSlot,
+ } = props;
const { t } = useTranslation();
const desktopMode = useSelector(isDesktopMode);
const theme = useTheme();
@@ -49,14 +57,12 @@ function TsDialogTitle(props: TSDialogActions) {
aria-label="close"
tabIndex={-1}
style={{
- position: 'absolute',
- left: 15,
- top: 15,
+ float: 'left',
}}
data-tid={closeButtonTestId && closeButtonTestId}
onClick={onClose}
>
- <GoBackIcon />
+ <ArrowBackIcon />
</TsIconButton>
);
@@ -73,6 +79,7 @@ function TsDialogTitle(props: TSDialogActions) {
<div style={{ textAlign: 'center' }}>
{backButton}
{title}
+ {actionSlot && <span style={{ float: 'right' }}>{actionSlot}</span>}
{children}
</div>
) : (
diff --git a/src/renderer/components/dialogs/settings/SettingsDialog.tsx b/src/renderer/components/dialogs/settings/SettingsDialog.tsx
index 965170450..0bb5fe518 100644
--- a/src/renderer/components/dialogs/settings/SettingsDialog.tsx
+++ b/src/renderer/components/dialogs/settings/SettingsDialog.tsx
@@ -16,10 +16,10 @@
*
*/
-import React, { useState, useEffect } from 'react';
-import { styled } from '@mui/material/styles';
+import React, { useState } from 'react';
import { useSelector } from 'react-redux';
import TsButton from '-/components/TsButton';
+import TsDialogTitle from '-/components/dialogs/components/TsDialogTitle';
import useMediaQuery from '@mui/material/useMediaQuery';
import { useTheme } from '@mui/material/styles';
import Tabs from '@mui/material/Tabs';
@@ -27,7 +27,6 @@ import Tab from '@mui/material/Tab';
import Dialog from '@mui/material/Dialog';
import TsDialogActions from '-/components/dialogs/components/TsDialogActions';
import DialogContent from '@mui/material/DialogContent';
-import DialogTitle from '@mui/material/DialogTitle';
import { isDesktopMode } from '-/reducers/settings';
import ConfirmDialog from '-/components/dialogs/ConfirmDialog';
import SettingsGeneral from '-/components/dialogs/settings/SettingsGeneral';
@@ -35,7 +34,6 @@ import SettingsKeyBindings from '-/components/dialogs/settings/SettingsKeyBindin
import SettingsFileTypes from '-/components/dialogs/settings/SettingsFileTypes';
import { clearAllURLParams } from '-/utils/dom';
import SettingsAdvanced from '-/components/dialogs/settings/SettingsAdvanced';
-import DialogCloseButton from '-/components/dialogs/DialogCloseButton';
import Links from 'assets/links';
import SettingsExtensions from '-/components/dialogs/settings/SettingsExtensions';
import { openURLExternally } from '-/services/utils-io';
@@ -63,14 +61,17 @@ function SettingsDialog(props: Props) {
setCurrentTab(tab);
};
- const renderTitle = () => (
- <DialogTitle>
- {t('core:settings')}
- <DialogCloseButton testId="closeSettingsTID" onClose={onClose} />
- </DialogTitle>
+ const helpButton = (
+ <TsButton
+ onClick={() => openURLExternally(Links.documentationLinks.settings, true)}
+ color="secondary"
+ //style={{ float: 'left' }}
+ >
+ {t('core:help')}
+ </TsButton>
);
- const renderContent = () => (
+ const renderContent = (
<DialogContent
style={{
overflowY: 'hidden',
@@ -87,9 +88,10 @@ function SettingsDialog(props: Props) {
scrollButtons="auto"
variant={fullScreen ? 'scrollable' : 'standard'}
orientation={fullScreen ? 'horizontal' : 'vertical'}
- style={{
- width: fullScreen ? '100%' : '170px',
- }}
+ // allowScrollButtonsMobile
+ // style={{
+ // width: fullScreen ? '100%' : '170px',
+ // }}
>
<Tab
style={{
@@ -190,27 +192,6 @@ function SettingsDialog(props: Props) {
</DialogContent>
);
- const renderActions = () => (
- <TsDialogActions
- style={{
- justifyContent: 'space-between',
- }}
- >
- <TsButton
- onClick={() =>
- openURLExternally(Links.documentationLinks.settings, true)
- }
- color="secondary"
- style={{ float: 'left' }}
- >
- {t('core:help')}
- </TsButton>
- <TsButton data-tid="closeSettingsDialog" onClick={props.onClose}>
- {t('core:closeButton')}
- </TsButton>
- </TsDialogActions>
- );
-
return (
<Dialog
sx={{
@@ -230,9 +211,25 @@ function SettingsDialog(props: Props) {
onClose={onClose}
style={{ maxWidth: 'auto' }}
>
- {renderTitle()}
- {renderContent()}
- {renderActions()}
+ <TsDialogTitle
+ dialogTitle={t('core:settings')}
+ closeButtonTestId="closeSettingsTID"
+ onClose={onClose}
+ actionSlot={helpButton}
+ />
+ {renderContent}
+ {!fullScreen && (
+ <TsDialogActions
+ style={{
+ justifyContent: 'space-between',
+ }}
+ >
+ {helpButton}
+ <TsButton data-tid="closeSettingsDialog" onClick={props.onClose}>
+ {t('core:closeButton')}
+ </TsButton>
+ </TsDialogActions>
+ )}
</Dialog>
);
}
diff --git a/src/renderer/locales/en/core.json b/src/renderer/locales/en/core.json
index 95f9e8c2a..863d877d3 100644
--- a/src/renderer/locales/en/core.json
+++ b/src/renderer/locales/en/core.json
@@ -152,6 +152,7 @@
"addRemoveTags": "Add / Remove Tags",
"openFile": "Open File",
"downloadFile": "Download File",
+ "downloadFiles": "Download Files",
"openFileNatively": "Open File Natively",
"openParentFolder": "Open Parent Folder",
"openContainingFolder": "Open Containing Folder",
diff --git a/src/renderer/perspectives/grid/components/GridSettingsDialog.tsx b/src/renderer/perspectives/grid/components/GridSettingsDialog.tsx
index 03f49eda7..d1b103d86 100644
--- a/src/renderer/perspectives/grid/components/GridSettingsDialog.tsx
+++ b/src/renderer/perspectives/grid/components/GridSettingsDialog.tsx
@@ -120,7 +120,7 @@ function GridSettingsDialog(props: Props) {
scroll="paper"
>
<TsDialogTitle
- title={t('core:perspectiveSettingsTitle')}
+ dialogTitle={t('core:perspectiveSettingsTitle')}
onClose={onClose}
closeButtonTestId="closePerspectiveSettingsTID"
/>