TagSpaces is an offline, open source, document manager with tagging support
chore: ui polishing
Ilian Sapundshievfe2840efeebb
diff --git a/src/renderer/components/EditDescriptionButtons.tsx b/src/renderer/components/EditDescriptionButtons.tsxindex 1ac6d844c..13fe41b75 100644--- a/src/renderer/components/EditDescriptionButtons.tsx+++ b/src/renderer/components/EditDescriptionButtons.tsx@@ -1,13 +1,14 @@import AppConfig from '-/AppConfig';import { ProTooltip } from '-/components/HelperComponents';import TsButton from '-/components/TsButton';+import AiGenDescButton from '-/components/chat/AiGenDescButton';+import AiGenTagsButton from '-/components/chat/AiGenTagsButton';import { useFilePropertiesContext } from '-/hooks/useFilePropertiesContext';+import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';import { Pro } from '-/pro';+import { ButtonGroup } from '@mui/material';import React from 'react';import { useTranslation } from 'react-i18next';-import AiGenDescButton from '-/components/chat/AiGenDescButton';-import AiGenTagsButton from '-/components/chat/AiGenTagsButton';-import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';const EditDescriptionButtons: React.FC = () => {const { t } = useTranslation();@@ -55,49 +56,79 @@ const EditDescriptionButtons: React.FC = () => {<divstyle={{float: 'left',+ display: 'flex',marginBottom: AppConfig.defaultSpaceBetweenButtons,}}>- {isEditDescriptionMode && (- <TsButton- style={{ marginRight: AppConfig.defaultSpaceBetweenButtons }}- onClick={() => {- setEditDescriptionMode(false);- }}- >- {t('core:cancel')}- {/* {t(isDescriptionChanged ? 'core:cancel' : 'core:close')} */}- </TsButton>- )}- {/* {!editMode && (- <TsButton className={classes.button} onClick={printHTML}>- {t('core:print')}- </TsButton>- )} */}- <ProTooltip tooltip={t('editDescription')}>- <TsButton- data-tid="editDescriptionTID"- disabled={!Pro || isEditMode}- onClick={() => {- if (isEditDescriptionMode) {- saveDescription();- }- setEditDescriptionMode(!isEditDescriptionMode);- }}+ <ButtonGroup>+ {isEditDescriptionMode && (+ <TsButton+ style={{ borderTopRightRadius: 0, borderBottomRightRadius: 0 }}+ onClick={() => {+ setEditDescriptionMode(false);+ }}+ >+ {t('core:cancel')}+ {/* {t(isDescriptionChanged ? 'core:cancel' : 'core:close')} */}+ </TsButton>+ )}+ <ProTooltip tooltip={t('editDescription')}>+ <TsButton+ data-tid="editDescriptionTID"+ disabled={!Pro || isEditMode}+ style={{+ borderTopLeftRadius: isEditDescriptionMode+ ? 0+ : AppConfig.defaultCSSRadius,+ borderBottomLeftRadius: isEditDescriptionMode+ ? 0+ : AppConfig.defaultCSSRadius,+ }}+ onClick={() => {+ if (isEditDescriptionMode) {+ saveDescription();+ }+ setEditDescriptionMode(!isEditDescriptionMode);+ }}+ >+ {isEditDescriptionMode+ ? t('core:confirmSaveButton')+ : t('core:editDescription')}+ </TsButton>+ </ProTooltip>+ </ButtonGroup>+ <ButtonGroup style={{ marginLeft: AppConfig.defaultSpaceBetweenButtons }}>+ <ProTooltip+ tooltip={'Add AI generated description based on the file content'}>- {isEditDescriptionMode- ? t('core:confirmSaveButton')- : t('core:editDescription')}- </TsButton>- </ProTooltip>- <span style={{ marginLeft: AppConfig.defaultSpaceBetweenButtons }}>- <AiGenDescButton />- </span>- {openedEntry.meta.description && (- <span style={{ marginLeft: AppConfig.defaultSpaceBetweenButtons }}>- <AiGenTagsButton fromDescription={true} variant="outlined" />- </span>- )}+ <AiGenDescButton+ disabled={!Pro}+ style={{+ borderTopRightRadius: openedEntry.meta.description+ ? 0+ : AppConfig.defaultCSSRadius,+ borderBottomRightRadius: openedEntry.meta.description+ ? 0+ : AppConfig.defaultCSSRadius,+ }}+ />+ </ProTooltip>+ {openedEntry.meta.description && (+ <ProTooltip+ tooltip={'Add AI generated tags based on the description'}+ >+ <AiGenTagsButton+ disabled={!Pro}+ style={{+ borderTopLeftRadius: 0,+ borderBottomLeftRadius: 0,+ }}+ fromDescription={true}+ variant="outlined"+ />+ </ProTooltip>+ )}+ </ButtonGroup></div>);};diff --git a/src/renderer/components/EntryContainerTabs.tsx b/src/renderer/components/EntryContainerTabs.tsxindex e18c462f3..66a47ff00 100644--- a/src/renderer/components/EntryContainerTabs.tsx+++ b/src/renderer/components/EntryContainerTabs.tsx@@ -16,14 +16,15 @@**/-import React, { useEffect, useReducer, useRef } from 'react';-import { useTranslation } from 'react-i18next';-import { useDispatch, useSelector } from 'react-redux';-import { AppDispatch } from '-/reducers/app';+import LoadingLazy from '-/components/LoadingLazy';import Tooltip from '-/components/Tooltip';import TsTabPanel from '-/components/TsTabPanel';+import { TabItem, TabNames } from '-/hooks/EntryPropsTabsContextProvider';+import { useChatContext } from '-/hooks/useChatContext';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';+import { useEntryPropsTabsContext } from '-/hooks/useEntryPropsTabsContext';import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';+import { AppDispatch } from '-/reducers/app';import {actions as SettingsActions,getEntryContainerTab,@@ -31,11 +32,10 @@ import {isDevMode,} from '-/reducers/settings';import { Box, Tab, Tabs, useMediaQuery } from '@mui/material';-import { useEntryPropsTabsContext } from '-/hooks/useEntryPropsTabsContext';-import { TabItem, TabNames } from '-/hooks/EntryPropsTabsContextProvider';import { styled, useTheme } from '@mui/material/styles';-import LoadingLazy from '-/components/LoadingLazy';-import { useChatContext } from '-/hooks/useChatContext';+import React, { useEffect, useReducer, useRef } from 'react';+import { useTranslation } from 'react-i18next';+import { useDispatch, useSelector } from 'react-redux';interface StyledTabsProps {children?: React.ReactNode;@@ -75,7 +75,7 @@ const StyledTab = styled((props: StyledTabProps) => {const { title, tinyMode, ...tabProps } = props; // Extract title and tinyModereturn (- <Tooltip title={!tinyMode && title}>+ <Tooltip title={tinyMode && title}><Tablabel={!tinyMode && title}disableRipplediff --git a/src/renderer/components/HelperComponents.tsx b/src/renderer/components/HelperComponents.tsxindex 7871d8851..526ad3917 100644--- a/src/renderer/components/HelperComponents.tsx+++ b/src/renderer/components/HelperComponents.tsx@@ -16,10 +16,9 @@**/-import React from 'react';+import { Pro } from '-/pro';import Tooltip from '@mui/material/Tooltip';import Typography from '@mui/material/Typography';-import { Pro } from '-/pro';import { useTranslation } from 'react-i18next';export function BetaLabel() {@@ -71,7 +70,7 @@ export function ProSign() {}export function ProTooltip(props) {- const { tooltip, placement } = props;+ const { tooltip, placement, children } = props;const { t } = useTranslation();const proTooltip = tooltip && tooltip;const tooltipPlacement = placement || 'top';@@ -84,7 +83,7 @@ export function ProTooltip(props) {placement={tooltipPlacement}title={Pro ? proTooltip : noProTooltip}>- <span {...props} />+ <div style={{ display: 'flex' }} children={children}></div></Tooltip>);}diff --git a/src/renderer/components/ProTeaser.tsx b/src/renderer/components/ProTeaser.tsxindex bb451cb3b..311573200 100644--- a/src/renderer/components/ProTeaser.tsx+++ b/src/renderer/components/ProTeaser.tsx@@ -16,22 +16,20 @@**/-import React from 'react';-import IconButton from '@mui/material/IconButton';import TsButton from '-/components/TsButton';+import { useProTeaserDialogContext } from '-/components/dialogs/hooks/useProTeaserDialogContext';+import { openURLExternally } from '-/services/utils-io';+import CameraTwoToneIcon from '@mui/icons-material/CameraTwoTone';+import CloseIcon from '@mui/icons-material/Close';+import MapTwoToneIcon from '@mui/icons-material/MapTwoTone';+import ViewKanbanTwoToneIcon from '@mui/icons-material/ViewKanbanTwoTone';+import { ButtonGroup } from '@mui/material';import CardActions from '@mui/material/CardActions';import CardContent from '@mui/material/CardContent';+import IconButton from '@mui/material/IconButton';import Typography from '@mui/material/Typography';-import CloseIcon from '@mui/icons-material/Close';-import ProTeaserImage from '-/assets/images/pro-teaser.svg';-import ViewKanbanTwoToneIcon from '@mui/icons-material/ViewKanbanTwoTone';-import CameraTwoToneIcon from '@mui/icons-material/CameraTwoTone';-import MapTwoToneIcon from '@mui/icons-material/MapTwoTone';import Links from 'assets/links';-import { openURLExternally } from '-/services/utils-io';import { useTranslation } from 'react-i18next';-import { useProTeaserDialogContext } from '-/components/dialogs/hooks/useProTeaserDialogContext';-import AppConfig from '-/AppConfig';interface Props {setShowTeaserBanner: (teaserVisibility: boolean) => void;@@ -54,7 +52,9 @@ function ProTeaser(props: Props) {}}><Typography color="textSecondary" variant="caption">- achieve more with+ <span style={{ textTransform: 'lowercase' }}>+ {t('core:achieveMore')}+ </span><IconButtonstyle={{ right: 5, marginTop: -10, position: 'absolute' }}size="small"@@ -97,25 +97,28 @@ function ProTeaser(props: Props) {marginTop: -10,}}>- <TsButton- onClick={(event: any) => {- event.preventDefault();- event.stopPropagation();- openProTeaserDialog();- }}- >- {t('showMeMore')}- </TsButton>- <TsButton- style={{ marginLeft: AppConfig.defaultSpaceBetweenButtons }}- onClick={(event: any) => {- event.preventDefault();- event.stopPropagation();- openURLExternally(Links.links.productsOverview, true);- }}- >- {t('upgrade')}- </TsButton>+ <ButtonGroup>+ <TsButton+ style={{ borderTopRightRadius: 0, borderBottomRightRadius: 0 }}+ onClick={(event: any) => {+ event.preventDefault();+ event.stopPropagation();+ openProTeaserDialog();+ }}+ >+ {t('showMeMore')}+ </TsButton>+ <TsButton+ style={{ borderTopLeftRadius: 0, borderBottomLeftRadius: 0 }}+ onClick={(event: any) => {+ event.preventDefault();+ event.stopPropagation();+ openURLExternally(Links.links.productsOverview, true);+ }}+ >+ {t('upgrade')}+ </TsButton>+ </ButtonGroup></CardActions></>);diff --git a/src/renderer/components/chat/AiGenDescButton.tsx b/src/renderer/components/chat/AiGenDescButton.tsxindex 89adbc0e0..13161575f 100644--- a/src/renderer/components/chat/AiGenDescButton.tsx+++ b/src/renderer/components/chat/AiGenDescButton.tsx@@ -16,24 +16,25 @@**/-import { useState } from 'react';import AppConfig from '-/AppConfig';-import TsButton from '-/components/TsButton';+import TsButton, { TSButtonProps } from '-/components/TsButton';+import { TabNames } from '-/hooks/EntryPropsTabsContextProvider';import { useChatContext } from '-/hooks/useChatContext';+import { useEntryPropsTabsContext } from '-/hooks/useEntryPropsTabsContext';import { useFilePropertiesContext } from '-/hooks/useFilePropertiesContext';import { useNotificationContext } from '-/hooks/useNotificationContext';import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';+import { formatDateTime } from '@tagspaces/tagspaces-common/misc';import { extractFileExtension } from '@tagspaces/tagspaces-common/paths';+import { useState } from 'react';import { useTranslation } from 'react-i18next';import { AIIcon } from '../CommonIcons';-import { TabNames } from '-/hooks/EntryPropsTabsContextProvider';-import { useEntryPropsTabsContext } from '-/hooks/useEntryPropsTabsContext';-interface Props {}+type Props = TSButtonProps & {};function AiGenDescButton(props: Props) {const { t } = useTranslation();-+ const { style, disabled } = props;const { setOpenedTab } = useEntryPropsTabsContext();const { openedEntry } = useOpenedEntryContext();const { generate, openedEntryModel } = useChatContext();@@ -60,25 +61,32 @@ function AiGenDescButton(props: Props) {setIsLoading(false);if (response) {setOpenedTab(TabNames.descriptionTab, openedEntry);-+ response =+ response ++ '\\\n *Generated with AI on ' ++ formatDateTime(new Date(), true) ++ '* \n';if (openedEntry.meta.description) {- setDescription(openedEntry.meta.description + '\n---\n' + response);+ setDescription(openedEntry.meta.description + '\n *** \n' + response);} else {setDescription(response);}saveDescription();//openEntry(openedEntry.path).then(() => {- showNotification('Description for ' + openedEntry.path + ' generated');+ showNotification(+ 'Description for ' + openedEntry.name + ' generated by an AI.',+ );}}return (<TsButtonloading={isLoading}- disabled={isLoading}+ disabled={isLoading || disabled}tooltip="Uses currently configured AI model to generate description for this file"startIcon={<AIIcon />}data-tid="generateDescriptionAITID"+ style={style}onClick={() => {setIsLoading(true);if (AppConfig.aiSupportedFiletypes.image.includes(ext)) {diff --git a/src/renderer/components/chat/AiGenTagsButton.tsx b/src/renderer/components/chat/AiGenTagsButton.tsxindex 0ab9cf34d..b2acb5610 100644--- a/src/renderer/components/chat/AiGenTagsButton.tsx+++ b/src/renderer/components/chat/AiGenTagsButton.tsx@@ -17,8 +17,12 @@*/import AppConfig from '-/AppConfig';-import TsButton from '-/components/TsButton';+import TsButton, { TSButtonProps } from '-/components/TsButton';+import { AIProvider } from '-/components/chat/ChatTypes';+import { TabNames } from '-/hooks/EntryPropsTabsContextProvider';import { useChatContext } from '-/hooks/useChatContext';+import { useEntryPropsTabsContext } from '-/hooks/useEntryPropsTabsContext';+import { useNotificationContext } from '-/hooks/useNotificationContext';import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';import { useTaggingActionsContext } from '-/hooks/useTaggingActionsContext';import { getDefaultAIProvider } from '-/reducers/settings';@@ -30,26 +34,24 @@ import { useState } from 'react';import { useTranslation } from 'react-i18next';import { useSelector } from 'react-redux';import { AIIcon } from '../CommonIcons';-import { AIProvider } from '-/components/chat/ChatTypes';-import { TabNames } from '-/hooks/EntryPropsTabsContextProvider';-import { useEntryPropsTabsContext } from '-/hooks/useEntryPropsTabsContext';-interface Props {+type Props = TSButtonProps & {variant?: OverridableStringUnion<'text' | 'outlined' | 'contained',ButtonPropsVariantOverrides>;fromDescription?: boolean;-}+};function AiGenTagsButton(props: Props) {- const { fromDescription, variant } = props;+ const { fromDescription, variant, style, disabled } = props;const { t } = useTranslation();const { setOpenedTab } = useEntryPropsTabsContext();const { openedEntry } = useOpenedEntryContext();const defaultAiProvider: AIProvider = useSelector(getDefaultAIProvider);const { generate, openedEntryModel, newChatMessage } = useChatContext();const { addTagsToFsEntry } = useTaggingActionsContext();+ const { showNotification } = useNotificationContext();const [isLoading, setIsLoading] = useState<boolean>(false);@@ -79,6 +81,9 @@ function AiGenTagsButton(props: Props) {addTagsToFsEntry(openedEntry, tags).then(() =>setOpenedTab(TabNames.propertiesTab, openedEntry),);+ showNotification(+ 'Tags for ' + openedEntry.name + ' generated by an AI.',+ );} catch (e) {console.error('parse response ' + response, e);}@@ -88,9 +93,10 @@ function AiGenTagsButton(props: Props) {return (<TsButtonloading={isLoading}- disabled={isLoading}+ disabled={isLoading || disabled}tooltip="Uses currently configured AI model to generate tags for this file"startIcon={<AIIcon />}+ style={style}data-tid="generateTagsAITID"onClick={() => {setIsLoading(true);diff --git a/src/renderer/components/chat/ChatView.tsx b/src/renderer/components/chat/ChatView.tsxindex 6e22c6fab..85703fa17 100644--- a/src/renderer/components/chat/ChatView.tsx+++ b/src/renderer/components/chat/ChatView.tsx@@ -164,7 +164,7 @@ function ChatView() {images +'\n' +response +- '\n *** \n '+ '\n *** \n');});const markdown = formattedItems.join(' ');