TagSpaces is an offline, open source, document manager with tagging support
chore: fix tag preview, added edit tag description in the edit tag dialog
Ilian Sapundshiev13fa07ddfabb
diff --git a/src/renderer/components/InfoIcon.tsx b/src/renderer/components/InfoIcon.tsxindex 727ed9adf..d7792aaf1 100644--- a/src/renderer/components/InfoIcon.tsx+++ b/src/renderer/components/InfoIcon.tsx@@ -20,7 +20,6 @@ import React from 'react';import { InfoTooltipIcon } from '-/components/CommonIcons';import NotListedLocationIcon from '@mui/icons-material/NotListedLocation';import Tooltip from '-/components/Tooltip';-import { opacity } from 'html2canvas/dist/types/css/property-descriptors/opacity';interface Props {tooltip?: string;diff --git a/src/renderer/components/Tag.tsx b/src/renderer/components/Tag.tsxnew file mode 100644index 000000000..21dac5d51--- /dev/null+++ b/src/renderer/components/Tag.tsx@@ -0,0 +1,64 @@+/**+ * 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 { InfoTooltipIcon } from '-/components/CommonIcons';+import Button from '@mui/material/Button';+import Tooltip from '-/components/Tooltip';++interface Props {+ tagTitle?: string;+ textColor?: string;+ backgroundColor?: string;+ isDragging?: boolean;+ children?: any;+}++function Tag(props: Props) {+ const { tagTitle, textColor, backgroundColor, isDragging, children } = props;+ return (+ <Tooltip title={tagTitle}>+ <Button+ size="small"+ style={{+ opacity: isDragging ? 0.5 : 1,+ fontSize: 13,+ fontWeight: 'normal',+ lineHeight: '10px',+ textTransform: 'none',+ textWrap: 'nowrap',+ whiteSpace: 'nowrap',+ color: textColor,+ backgroundColor: backgroundColor,+ minHeight: 18,+ minWidth: 0,+ margin: 2,+ paddingTop: 0,+ paddingBottom: 0,+ paddingRight: 0,+ paddingLeft: 5,+ borderRadius: 5,+ }}+ >+ {children}+ </Button>+ </Tooltip>+ );+}++export default Tag;diff --git a/src/renderer/components/TagContainer.tsx b/src/renderer/components/TagContainer.tsxindex f193349a5..42f9bbdd5 100644--- a/src/renderer/components/TagContainer.tsx+++ b/src/renderer/components/TagContainer.tsx@@ -29,6 +29,7 @@ import { isDateTimeTag, convertToTimestamp } from '-/utils/dates';import { TS } from '-/tagspaces.namespace';import { getTagColors } from '-/services/taglibrary-utils';import TagContainerMenu from '-/components/TagContainerMenu';+import Tag from '-/components/Tag';import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';interface Props {@@ -197,64 +198,46 @@ function TagContainer(props: Props) {display: 'inline-block',}}>- <Tooltip title={tagTitle}>- <Button- size="small"+ <Tag+ isDragging={isDragging}+ tagTitle={tagTitle}+ textColor={textColor}+ backgroundColor={backgroundColor}+ >+ <spanstyle={{- opacity: isDragging ? 0.5 : 1,- fontSize: 13,- fontWeight: 'normal',- lineHeight: '10px',- textTransform: 'none',- textWrap: 'nowrap',- whiteSpace: 'nowrap',- color: textColor,- backgroundColor,- minHeight: 18,- minWidth: 0,- margin: 2,- paddingTop: 0,- paddingBottom: 0,- paddingRight: 0,- paddingLeft: 5,- borderRadius: 5,+ flexGrow: 1,+ display: 'flex',+ alignItems: 'center',}}>- <span- style={{- flexGrow: 1,- display: 'flex',- alignItems: 'center',- }}- >- {(isTagGeo || isGeoSmartTag) && (- <PlaceIcon- style={{- color: textColor,- height: 16,- marginLeft: -5,- }}- />- )}- {(isTagDate || isDateSmartTag) && (- <DateIcon- style={{- color: textColor,- height: 16,- marginLeft: -5,- }}- />- )}- {!isTagGeo && <span>{title}</span>}- </span>- <TagContainerMenu- handleRemoveTag={handleRemoveTag}- tag={tag}- tagMode={tagMode}- deleteIcon={deleteIcon}- />- </Button>- </Tooltip>+ {(isTagGeo || isGeoSmartTag) && (+ <PlaceIcon+ style={{+ color: textColor,+ height: 16,+ marginLeft: -5,+ }}+ />+ )}+ {(isTagDate || isDateSmartTag) && (+ <DateIcon+ style={{+ color: textColor,+ height: 16,+ marginLeft: -5,+ }}+ />+ )}+ {!isTagGeo && <span>{title}</span>}+ </span>+ <TagContainerMenu+ handleRemoveTag={handleRemoveTag}+ tag={tag}+ tagMode={tagMode}+ deleteIcon={deleteIcon}+ />+ </Tag></div>);}diff --git a/src/renderer/components/dialogs/EditTagDialog.tsx b/src/renderer/components/dialogs/EditTagDialog.tsxindex 4d99c6852..5368b30cb 100644--- a/src/renderer/components/dialogs/EditTagDialog.tsx+++ b/src/renderer/components/dialogs/EditTagDialog.tsx@@ -26,7 +26,7 @@ import FormControl from '@mui/material/FormControl';import FormHelperText from '@mui/material/FormHelperText';import Dialog from '@mui/material/Dialog';import ColorPickerDialog from './ColorPickerDialog';-import TagContainer from '-/components/TagContainer';+import Tag from '-/components/Tag';import TransparentBackground from '../TransparentBackground';import TsTextField from '-/components/TsTextField';import { TS } from '-/tagspaces.namespace';@@ -49,6 +49,9 @@ function EditTagDialog(props: Props) {useState<boolean>(false);const [inputError, setInputError] = useState<boolean>(false);const [title, setTitle] = useState<string>(props.selectedTag.title);+ const [description, setDescription] = useState<string>(+ props.selectedTag.description,+ );const [color, setColor] = useState<string>(props.selectedTag.color);const [textcolor, setTextcolor] = useState<string>(props.selectedTag.textcolor,@@ -67,6 +70,17 @@ function EditTagDialog(props: Props) {}};+ const handleTagDescriptionChange = (+ event: React.ChangeEvent<HTMLInputElement>,+ ) => {+ const { target } = event;+ const { value, name } = target;++ if (name === 'description') {+ setDescription(value);+ }+ };+const handleValidation = () => {const tagCheck = RegExp(/^[^#/\\ [\]]{1,}$/);if (title && tagCheck.test(title)) {@@ -84,6 +98,7 @@ function EditTagDialog(props: Props) {title,color,textcolor,+ description,},props.selectedTagGroupEntry.uuid,props.selectedTag.title,@@ -142,7 +157,15 @@ function EditTagDialog(props: Props) {<DialogTitle style={{ overflow: 'visible' }}>{t('core:editTagTitle')}{` `}- <TagContainer tag={{ title, color, textcolor }} tagMode="display" />+ <Tag+ backgroundColor={color}+ textColor={textcolor}+ isDragging={false}+ tagTitle={description}+ >+ {title}+ <span style={{ margin: 3 }} />+ </Tag><DialogCloseButton testId="closeEditTagTID" onClose={onClose} /></DialogTitle><DialogContent style={{ overflow: 'visible' }}>@@ -187,6 +210,15 @@ function EditTagDialog(props: Props) {</FormHelperText>)}</FormControl>+ <FormControl fullWidth={true} style={{ overflow: 'visible' }}>+ <TsTextField+ name="description"+ label={t('core:editDescription')}+ onChange={handleTagDescriptionChange}+ value={description}+ data-tid="editTagDescription"+ />+ </FormControl><FormControl fullWidth={true}><FormHelperText style={styles.helpText}>{t('core:tagBackgroundColor')}