Skip to content

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

Clean-react-errors-in-dev-console (#2247)

Stanimir907bb82a71ff
diff --git a/src/renderer/components/EntryContainerTabs.tsx b/src/renderer/components/EntryContainerTabs.tsx
index 6de742708..db79c70d6 100644
--- a/src/renderer/components/EntryContainerTabs.tsx
+++ b/src/renderer/components/EntryContainerTabs.tsx
@@ -234,6 +234,7 @@ function EntryContainerTabs(props: EntryContainerTabsProps) {
>
{tabsArray.current.map((tab, index) => (
<StyledTab
+ key={'key' + tab.name + index}
data-tid={tab.name + 'TID'}
icon={tab.icon}
title={tab.title}
diff --git a/src/renderer/components/FileSourceDnd.tsx b/src/renderer/components/FileSourceDnd.tsx
index c1a7fd90d..9767d5297 100644
--- a/src/renderer/components/FileSourceDnd.tsx
+++ b/src/renderer/components/FileSourceDnd.tsx
@@ -56,9 +56,10 @@ const FileSourceDnd: React.FC<Props> = ({ children }) => {
captureDraggingState: true,
});
}, [preview]);
+ const { isDragging, ...rest } = collected;
return (
- <span ref={drag} {...collected}>
+ <span ref={drag} {...rest}>
{children}
</span>
);
diff --git a/src/renderer/components/PathBreadcrumbs.tsx b/src/renderer/components/PathBreadcrumbs.tsx
index 51a35890f..f55964c32 100644
--- a/src/renderer/components/PathBreadcrumbs.tsx
+++ b/src/renderer/components/PathBreadcrumbs.tsx
@@ -145,7 +145,8 @@ function PathBreadcrumbs(props: Props) {
);
}
- currentFolderChipIcon = pathParts.length === 1 && locationTypeIcon;
+ currentFolderChipIcon =
+ pathParts.length === 1 ? locationTypeIcon : undefined;
if (pathParts.length >= 1) {
pathParts = pathParts.slice(1, pathParts.length); // remove current directory
@@ -169,13 +170,14 @@ function PathBreadcrumbs(props: Props) {
pathPart,
currentLocation?.getDirSeparator(),
);
+ const icon = index === 0 ? locationTypeIcon : undefined;
return (
<Tooltip key={pathPart} title={t('core:navigateTo') + ' ' + pathPart}>
<StyledBreadcrumb
component="a"
href="#"
label={folderName}
- icon={index === 0 && locationTypeIcon}
+ icon={icon}
onClick={() => openDirectory(pathPart)}
/>
</Tooltip>
diff --git a/src/renderer/components/TagContainerDnd.tsx b/src/renderer/components/TagContainerDnd.tsx
index a585196d3..c996ef78d 100644
--- a/src/renderer/components/TagContainerDnd.tsx
+++ b/src/renderer/components/TagContainerDnd.tsx
@@ -236,12 +236,12 @@ const TagContainerDnd = (props: Props) => {
});
}, [preview]);
- const { isDragging } = collected;
+ const { isDragging, ...rest } = collected;
drag(drop(tagContainerRef));
return (
- <span ref={tagContainerRef} {...collected}>
+ <span ref={tagContainerRef} {...rest}>
<TagContainer
tag={tag}
tagGroup={tagGroup}
diff --git a/src/renderer/components/TsButton.tsx b/src/renderer/components/TsButton.tsx
index 46a4b5a41..100ab7bbe 100644
--- a/src/renderer/components/TsButton.tsx
+++ b/src/renderer/components/TsButton.tsx
@@ -39,16 +39,16 @@ export type TSButtonProps = ButtonProps & {
};
function TsButton(props: TSButtonProps) {
- const { children, style, tooltip, loading, ...rest } = props;
+ const { children, style, tooltip, loading, startIcon, ...rest } = props;
const desktopMode = useSelector(isDesktopMode);
let button;
if (loading !== undefined) {
button = (
<LoadingButton
loading={loading}
- loadingPosition="start"
size={desktopMode ? 'small' : 'medium'}
variant="outlined"
+ {...(startIcon && { startIcon: startIcon, loadingPosition: 'start' })}
{...rest}
style={{
borderRadius: AppConfig.defaultCSSRadius,
diff --git a/src/renderer/components/TsIconButton.tsx b/src/renderer/components/TsIconButton.tsx
index 4cd5b11f7..270eed5cf 100644
--- a/src/renderer/components/TsIconButton.tsx
+++ b/src/renderer/components/TsIconButton.tsx
@@ -29,20 +29,18 @@ export type TSIconButtonProps = IconButtonProps & {
};
function TsIconButton(props: TSIconButtonProps) {
- const { children, style, title, keyBinding, tooltip } = props;
+ const { children, keyBinding, tooltip, disabled, ...restProps } = props;
const desktopMode = useSelector(isDesktopMode);
const iconButton = (
<IconButton
size={desktopMode ? 'medium' : 'large'}
- {...props}
- style={{
- ...style,
- }}
+ disabled={disabled}
+ {...restProps}
>
{children}
</IconButton>
);
- return tooltip ? (
+ return tooltip && !disabled ? (
<TooltipTS keyBinding={keyBinding} title={tooltip}>
{iconButton}
</TooltipTS>
diff --git a/src/renderer/components/TsTextField.tsx b/src/renderer/components/TsTextField.tsx
index 342adb2c7..980afecf6 100644
--- a/src/renderer/components/TsTextField.tsx
+++ b/src/renderer/components/TsTextField.tsx
@@ -34,10 +34,10 @@ type TSTextFieldProps = TextFieldProps & {
};
function TsTextField(props: TSTextFieldProps) {
- const { updateValue, retrieveValue, children, label } = props;
+ const { updateValue, retrieveValue, children, label, ...restProps } = props;
const { t } = useTranslation();
const desktopMode = useSelector(isDesktopMode);
- const textFieldRef = useRef(null);
+ //const textFieldRef = useRef(null);
const [contextMenu, setContextMenu] = React.useState<{
mouseX: number;
@@ -111,8 +111,8 @@ function TsTextField(props: TSTextFieldProps) {
size={desktopMode ? 'small' : 'medium'}
variant="outlined"
fullWidth={true}
- ref={textFieldRef}
- {...props}
+ // ref={textFieldRef}
+ {...restProps}
label={undefined}
>
{children}
diff --git a/src/renderer/components/dialogs/AboutDialog.tsx b/src/renderer/components/dialogs/AboutDialog.tsx
index 43813db5d..343d646ff 100644
--- a/src/renderer/components/dialogs/AboutDialog.tsx
+++ b/src/renderer/components/dialogs/AboutDialog.tsx
@@ -160,8 +160,10 @@ function AboutDialog(props: Props) {
</strong>
is made possible by the TagSpaces project and other open source
software listed in the:
- <p style={{ marginBottom: 5 }} />
- <TsButton onClick={() => openThirdPartyLibsDialog()}>
+ <TsButton
+ style={{ marginTop: 5 }}
+ onClick={() => openThirdPartyLibsDialog()}
+ >
Software Acknowledgements
</TsButton>
<br />
@@ -179,47 +181,45 @@ function AboutDialog(props: Props) {
for more details.
<br />
<br />
- <div>
- {imprintURL && (
- <TsButton
- style={{ marginRight: AppConfig.defaultSpaceBetweenButtons }}
- variant="text"
- onClick={() => {
- openURLExternally(imprintURL, true);
- }}
- >
- Imprint
- </TsButton>
- )}
- {privacyURL && (
- <TsButton
- style={{ marginRight: AppConfig.defaultSpaceBetweenButtons }}
- variant="text"
- onClick={() => {
- openURLExternally(privacyURL, true);
- }}
- >
- Privacy Policy
- </TsButton>
- )}
+ {imprintURL && (
<TsButton
style={{ marginRight: AppConfig.defaultSpaceBetweenButtons }}
variant="text"
onClick={() => {
- openURLExternally(Links.links.changelogURL, true);
+ openURLExternally(imprintURL, true);
}}
>
- Changelog
+ Imprint
</TsButton>
+ )}
+ {privacyURL && (
<TsButton
style={{ marginRight: AppConfig.defaultSpaceBetweenButtons }}
variant="text"
- data-tid="openLicenseDialog"
- onClick={() => openLicenseDialog()}
+ onClick={() => {
+ openURLExternally(privacyURL, true);
+ }}
>
- {t('core:license')}
+ Privacy Policy
</TsButton>
- </div>
+ )}
+ <TsButton
+ style={{ marginRight: AppConfig.defaultSpaceBetweenButtons }}
+ variant="text"
+ onClick={() => {
+ openURLExternally(Links.links.changelogURL, true);
+ }}
+ >
+ Changelog
+ </TsButton>
+ <TsButton
+ style={{ marginRight: AppConfig.defaultSpaceBetweenButtons }}
+ variant="text"
+ data-tid="openLicenseDialog"
+ onClick={() => openLicenseDialog()}
+ >
+ {t('core:license')}
+ </TsButton>
</Typography>
</DialogContent>
<TsDialogActions style={{ justifyContent: 'space-between' }}>
diff --git a/src/renderer/components/dialogs/CreateDirectoryDialog.tsx b/src/renderer/components/dialogs/CreateDirectoryDialog.tsx
index 172de2fd7..99f5557f1 100644
--- a/src/renderer/components/dialogs/CreateDirectoryDialog.tsx
+++ b/src/renderer/components/dialogs/CreateDirectoryDialog.tsx
@@ -16,6 +16,7 @@
*
*/
+import React, { useReducer, useRef, useState } from 'react';
import DraggablePaper from '-/components/DraggablePaper';
import TsButton from '-/components/TsButton';
import TsIconButton from '-/components/TsIconButton';
@@ -42,7 +43,6 @@ import {
} from '@mui/material';
import { styled, useTheme } from '@mui/material/styles';
import { joinPaths } from '@tagspaces/tagspaces-common/paths';
-import { useReducer, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
const FolderColorTextField = styled(TsTextField)(({ theme }) => ({
@@ -243,9 +243,8 @@ function CreateDirectoryDialog(props: Props) {
<InputAdornment position="end" style={{ height: 300 }}>
<Box style={{ padding: 10, width: 300 }}>
{defaultBackgrounds.map((background, cnt) => (
- <>
+ <React.Fragment key={cnt}>
<TsIconButton
- key={cnt}
tooltip={background}
data-tid={'bgTID' + cnt}
aria-label="changeFolderBackground"
@@ -265,7 +264,7 @@ function CreateDirectoryDialog(props: Props) {
<SetBackgroundIcon />
</TsIconButton>
{(cnt + 1) % 5 === 0 && <br />}
- </>
+ </React.Fragment>
))}
</Box>
</InputAdornment>
diff --git a/src/renderer/components/dialogs/CreateEditLocationDialog.tsx b/src/renderer/components/dialogs/CreateEditLocationDialog.tsx
index 13f198e38..64c16b856 100644
--- a/src/renderer/components/dialogs/CreateEditLocationDialog.tsx
+++ b/src/renderer/components/dialogs/CreateEditLocationDialog.tsx
@@ -909,7 +909,11 @@ function CreateEditLocationDialog(props: Props) {
exclusive
>
<ToggleButton
- value={null}
+ value={
+ persistTagsInSidecarFile !== null
+ ? persistTagsInSidecarFile
+ : false
+ }
data-tid="settingsSetPersistTagsDefault"
onClick={() => setPersistTagsInSidecarFile(null)}
>
diff --git a/src/renderer/components/dialogs/ProTeaserDialog.tsx b/src/renderer/components/dialogs/ProTeaserDialog.tsx
index 7f42862c4..63ec84afa 100644
--- a/src/renderer/components/dialogs/ProTeaserDialog.tsx
+++ b/src/renderer/components/dialogs/ProTeaserDialog.tsx
@@ -16,6 +16,7 @@
*
*/
+import React from 'react';
import DraggablePaper from '-/components/DraggablePaper';
import TsButton from '-/components/TsButton';
import TsDialogTitle from '-/components/dialogs/components/TsDialogTitle';
@@ -46,7 +47,7 @@ interface SlideProps {
description?: '';
ctaURL?: string;
ctaTitle?: string;
- items?: Array<string>;
+ items?: Array<React.ReactNode>;
pictureURL?: string;
pictureShadow?: boolean;
videoURL?: string;
@@ -86,8 +87,10 @@ function Slide(props: SlideProps) {
<Typography variant="subtitle1">{description}</Typography>
)}
{items &&
- items.map((item) => (
- <Typography variant="subtitle1">&#x2605;&nbsp;{item}</Typography>
+ items.map((item, index) => (
+ <Typography key={index} variant="subtitle1">
+ &#x2605;&nbsp;{item}
+ </Typography>
))}
<div style={{ textAlign: 'center', paddingTop: 10 }}>
{pictureURL && (
diff --git a/src/renderer/perspectives/grid/components/GridPagination.tsx b/src/renderer/perspectives/grid/components/GridPagination.tsx
index 0698b0080..67fb04eee 100644
--- a/src/renderer/perspectives/grid/components/GridPagination.tsx
+++ b/src/renderer/perspectives/grid/components/GridPagination.tsx
@@ -368,6 +368,7 @@ function GridPagination(props: Props) {
<GridCellsContainer>
{pageFiles.map((entry, index, dArray) => (
<CellView
+ key={entry.uuid + index}
fsEntry={entry}
index={index}
cellContent={getCellContent}