TagSpaces is an offline, open source, document manager with tagging support
chore: migration to mui's grid2
Ilian Sapundshievd1842be8bc54
diff --git a/src/renderer/components/RenderHistory.tsx b/src/renderer/components/RenderHistory.tsxindex 2701dac25..2a7c74872 100644--- a/src/renderer/components/RenderHistory.tsx+++ b/src/renderer/components/RenderHistory.tsx@@ -16,25 +16,23 @@**/-import { TS } from '-/tagspaces.namespace';-import Grid from '@mui/material/Grid';-import React, { useContext } from 'react';+import AppConfig from '-/AppConfig';+import { HistoryIcon, RemoveIcon } from '-/components/CommonIcons';import TsButton from '-/components/TsButton';-import ListItem from '@mui/material/ListItem';-import { Tooltip } from '@mui/material';+import TsIconButton from '-/components/TsIconButton';+import { useBrowserHistoryContext } from '-/hooks/useBrowserHistoryContext';import { Pro } from '-/pro';+import { dataTidFormat } from '-/services/test';+import { TS } from '-/tagspaces.namespace';import BookmarkTwoToneIcon from '@mui/icons-material/BookmarkTwoTone';+import { Tooltip } from '@mui/material';+import ListItem from '@mui/material/ListItem';import {extractDirectoryName,extractFileName,} from '@tagspaces/tagspaces-common/paths';-import TsIconButton from '-/components/TsIconButton';-import { RemoveIcon, HistoryIcon } from '-/components/CommonIcons';-import { dataTidFormat } from '-/services/test';+import { useContext } from 'react';import { useTranslation } from 'react-i18next';-import AppConfig from '-/AppConfig';-import TooltipTS from '-/components/Tooltip';-import { useBrowserHistoryContext } from '-/hooks/useBrowserHistoryContext';interface Props {historyKey: string;@@ -67,73 +65,71 @@ function RenderHistory(props: Props) {style={{ paddingLeft: 0 }}key={item.creationTimeStamp}>- <Grid item xs={10} style={{ minWidth: 245, maxWidth: 245 }}>- <TsButton- data-tid={historyKey + 'TID' + dataTidFormat(itemName)}- variant="text"+ <TsButton+ data-tid={historyKey + 'TID' + dataTidFormat(itemName)}+ variant="text"+ style={{+ textTransform: 'none',+ fontWeight: 'normal',+ justifyContent: 'start',+ minWidth: 245,+ maxWidth: 245,+ }}+ onClick={() => openHistoryItem(item as TS.HistoryItem)}+ >+ <Tooltip+ title={+ <span style={{ fontSize: 14 }}>+ <b>{t('core:filePath')}:</b> {item.path}+ <br />+ <br />+ {/* <b>Opened on: </b>{' '} */}+ {new Date(item.creationTimeStamp)+ .toISOString()+ .substring(0, 19)+ .split('T')+ .join(' ')}+ </span>+ }+ >+ {historyKey === Pro.keys.bookmarksKey ? (+ <BookmarkTwoToneIcon />+ ) : (+ <HistoryIcon />+ )}+ </Tooltip>+ + <spanstyle={{- textTransform: 'none',- fontWeight: 'normal',- justifyContent: 'start',+ whiteSpace: 'nowrap',+ textOverflow: 'ellipsis',+ overflow: 'hidden',+ maxWidth: 220,}}- onClick={() => openHistoryItem(item as TS.HistoryItem)}>- <Tooltip- title={- <span style={{ fontSize: 14 }}>- <b>{t('core:filePath')}:</b> {item.path}- <br />- <br />- {/* <b>Opened on: </b>{' '} */}- {new Date(item.creationTimeStamp)- .toISOString()- .substring(0, 19)- .split('T')- .join(' ')}- </span>- }- >- {historyKey === Pro.keys.bookmarksKey ? (- <BookmarkTwoToneIcon />- ) : (- <HistoryIcon />- )}- </Tooltip>- - <span- style={{- whiteSpace: 'nowrap',- textOverflow: 'ellipsis',- overflow: 'hidden',- maxWidth: 220,- }}- >- {itemName}- </span>- </TsButton>- </Grid>+ {itemName}+ </span>+ </TsButton>{showDelete && (- <Grid item xs={2}>- <TsIconButton- tooltip={t('delete')}- aria-label={t('core:clearHistory')}- onClick={() => {- if (historyKey === Pro.keys.bookmarksKey) {- //del bookmarks- bookmarksContext.delBookmark(item.path);- } else {- historyContext.delHistory(- historyKey,- item.creationTimeStamp,- );- }- update();- }}- data-tid="deleteHistoryItemTID"- >- <RemoveIcon />- </TsIconButton>- </Grid>+ <TsIconButton+ tooltip={t('delete')}+ aria-label={t('core:clearHistory')}+ onClick={() => {+ if (historyKey === Pro.keys.bookmarksKey) {+ //del bookmarks+ bookmarksContext.delBookmark(item.path);+ } else {+ historyContext.delHistory(+ historyKey,+ item.creationTimeStamp,+ );+ }+ update();+ }}+ data-tid="deleteHistoryItemTID"+ >+ <RemoveIcon />+ </TsIconButton>)}</ListItem>);diff --git a/src/renderer/components/SplitButton.tsx b/src/renderer/components/SplitButton.tsxdeleted file mode 100644index 9a0b59190..000000000--- a/src/renderer/components/SplitButton.tsx+++ /dev/null@@ -1,111 +0,0 @@-/**-import React from 'react';-import Grid from '@mui/material/Grid';-import Button from '@mui/material/Button';-import ButtonGroup from '@mui/material/ButtonGroup';-import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';-import ClickAwayListener from '@mui/material/ClickAwayListener';-import Grow from '@mui/material/Grow';-import Paper from '@mui/material/Paper';-import Popper from '@mui/material/Popper';-import MenuItem from '@mui/material/MenuItem';-import TsMenuList from '-/components/TsMenuList';--interface Props {- options: Array<any>;- selected: string;- onChange: (selected: string) => void;-}--export default function SplitButton(props: Props) {- const { options, selected, onChange } = props;- const [open, setOpen] = React.useState(false);- const anchorRef = React.useRef<HTMLDivElement>(null);- const sel = options.findIndex((option) => option.key === selected);- const [selectedIndex, setSelectedIndex] = React.useState(sel);-- const handleClick = () => {- console.info(`You clicked ${options[selectedIndex].key}`);- };-- const handleMenuItemClick = (- event: React.MouseEvent<HTMLLIElement, MouseEvent>,- index: number,- ) => {- setSelectedIndex(index);- onChange(options[index].key);- setOpen(false);- };-- const handleToggle = () => {- setOpen((prevOpen) => !prevOpen);- };-- const handleClose = (event: React.MouseEvent<Document, MouseEvent>) => {- if (- anchorRef.current &&- anchorRef.current.contains(event.target as HTMLElement)- ) {- return;- }-- setOpen(false);- };-- return (- <Grid container direction="column" alignItems="center">- <Grid item xs={12}>- <ButtonGroup- variant="contained"- ref={anchorRef}- aria-label="split button"- >- <Button onClick={handleToggle}>{options[selectedIndex].value}</Button>- <Button- aria-controls={open ? 'split-button-menu' : undefined}- aria-expanded={open ? 'true' : undefined}- aria-label="select merge strategy"- aria-haspopup="menu"- onClick={handleToggle}- >- <ArrowDropDownIcon />- </Button>- </ButtonGroup>- <Popper- open={open}- anchorEl={anchorRef.current}- role={undefined}- transition- disablePortal- >- {({ TransitionProps, placement }) => (- <Grow- {...TransitionProps}- style={{- transformOrigin:- placement === 'bottom' ? 'center top' : 'center bottom',- }}- >- <Paper>- <TsMenuList id="split-button-menu">- {options.map((option, index) => (- <MenuItem- key={option.key}- disabled={index === 2}- selected={index === selectedIndex}- onClick={(event) => handleMenuItemClick(event, index)}- >- {option.value}- </MenuItem>- ))}- </TsMenuList>- </Paper>- </Grow>- )}- </Popper>- </Grid>- </Grid>- );-}--*/diff --git a/src/renderer/components/WelcomePanel.tsx b/src/renderer/components/WelcomePanel.tsxindex d34081d55..4da41b166 100644--- a/src/renderer/components/WelcomePanel.tsx+++ b/src/renderer/components/WelcomePanel.tsx@@ -16,46 +16,45 @@**/-import React, { useContext, useReducer } from 'react';-import { useSelector, useDispatch } from 'react-redux';-import Typography from '@mui/material/Typography';-import List from '@mui/material/List';-import ListItem from '@mui/material/ListItem';-import ListItemIcon from '@mui/material/ListItemIcon';-import ListItemText from '@mui/material/ListItemText';-import Box from '@mui/material/Box';-import Grid from '@mui/material/Grid';-import Divider from '@mui/material/Divider';-import ChangeLogIcon from '@mui/icons-material/ImportContacts';-import WebClipperIcon from '@mui/icons-material/Transform';-import EmailIcon from '@mui/icons-material/Email';-import IssueIcon from '@mui/icons-material/BugReport';-import TranslationIcon from '@mui/icons-material/Translate';-import NewFeatureIcon from '@mui/icons-material/Gesture';-import XIcon from '@mui/icons-material/X';-import WelcomeBackground from '-/assets/images/background.png';import WelcomeLogo from '-/assets/images/welcome-logo.png';import {CreateFileIcon,+ HelpIcon,+ KeyShortcutsIcon,LocalLocationIcon,OpenLinkIcon,- KeyShortcutsIcon,- HelpIcon,} from '-/components/CommonIcons';-import { getDesktopMode } from '-/reducers/settings';-import Links from 'assets/links';-import { Pro } from '-/pro';-import { TS } from '-/tagspaces.namespace';import HowToStart from '-/components/HowToStart';-import { openURLExternally } from '-/services/utils-io';-import { styled, useTheme } from '@mui/material/styles';-import { useTranslation } from 'react-i18next';import RenderHistory from '-/components/RenderHistory';-import { useCreateEditLocationDialogContext } from '-/components/dialogs/hooks/useCreateEditLocationDialogContext';-import { useNewFileDialogContext } from '-/components/dialogs/hooks/useNewFileDialogContext';import { useAboutDialogContext } from '-/components/dialogs/hooks/useAboutDialogContext';+import { useCreateEditLocationDialogContext } from '-/components/dialogs/hooks/useCreateEditLocationDialogContext';import { useKeyboardDialogContext } from '-/components/dialogs/hooks/useKeyboardDialogContext';import { useLinkDialogContext } from '-/components/dialogs/hooks/useLinkDialogContext';+import { useNewFileDialogContext } from '-/components/dialogs/hooks/useNewFileDialogContext';+import { Pro } from '-/pro';+import { getDesktopMode } from '-/reducers/settings';+import { openURLExternally } from '-/services/utils-io';+import { TS } from '-/tagspaces.namespace';+import IssueIcon from '@mui/icons-material/BugReport';+import EmailIcon from '@mui/icons-material/Email';+import NewFeatureIcon from '@mui/icons-material/Gesture';+import ChangeLogIcon from '@mui/icons-material/ImportContacts';+import WebClipperIcon from '@mui/icons-material/Transform';+import TranslationIcon from '@mui/icons-material/Translate';+import XIcon from '@mui/icons-material/X';+import Box from '@mui/material/Box';+import Divider from '@mui/material/Divider';+import Grid from '@mui/material/Grid2';+import List from '@mui/material/List';+import ListItem from '@mui/material/ListItem';+import ListItemIcon from '@mui/material/ListItemIcon';+import ListItemText from '@mui/material/ListItemText';+import Typography from '@mui/material/Typography';+import { styled, useTheme } from '@mui/material/styles';+import Links from 'assets/links';+import { useContext, useReducer } from 'react';+import { useTranslation } from 'react-i18next';+import { useSelector } from 'react-redux';const PREFIX = 'WelcomePanel';@@ -341,36 +340,19 @@ function WelcomePanel() {height: '100%',}}>- {/* <div- style={{- backgroundColor: theme.palette.background.default,- backgroundImage: 'url(' + WelcomeBackground + ')',- backgroundRepeat: 'repeat',- opacity: '0.4',- position: 'absolute',- left: 0,- top: 0,- width: '100%',- height: '100%',- }}- /> */}<Gridstyle={{position: 'relative',height: '100%',}}container- spacing={3}+ spacing={2}>- <Grid- item- xs="auto"- style={{ height: '100%', zIndex: 1, minWidth: 300 }}- >+ <Grid style={{ height: '100%', zIndex: 1, minWidth: 300 }}>{renderQuickLinks()}</Grid>{desktopMode && (- <Grid item xs="auto" style={{ height: '100%' }}>+ <Grid style={{ height: '100%' }}><divstyle={{margin: 'auto',@@ -386,7 +368,7 @@ function WelcomePanel() {</Grid>)}{Pro && (- <Grid item xs="auto" style={{ height: '100%', minWidth: 330 }}>+ <Grid style={{ height: '100%', minWidth: 300 }}><divstyle={{margin: 'auto',diff --git a/src/renderer/perspectives/list/components/RowCell.tsx b/src/renderer/perspectives/list/components/RowCell.tsxindex c4fa74f02..aa3a6d889 100644--- a/src/renderer/perspectives/list/components/RowCell.tsx+++ b/src/renderer/perspectives/list/components/RowCell.tsx@@ -16,47 +16,47 @@**/-import React, { useMemo } from 'react';-import { useSelector, useDispatch } from 'react-redux';-import { useTheme, styled } from '@mui/material/styles';-import classNames from 'classnames';-import Grid from '@mui/material/Grid';-import Typography from '@mui/material/Typography';-import Paper from '@mui/material/Paper';-import Tooltip from '-/components/Tooltip';-import IconButton from '@mui/material/IconButton';+import AppConfig from '-/AppConfig';import {- SelectedIcon,- UnSelectedIcon,FolderOutlineIcon,MoreMenuIcon,+ SelectedIcon,+ UnSelectedIcon,} from '-/components/CommonIcons';+import TagContainer from '-/components/TagContainer';+import TagContainerDnd from '-/components/TagContainerDnd';+import TagsPreview from '-/components/TagsPreview';+import Tooltip from '-/components/Tooltip';+import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';+import { usePerspectiveSettingsContext } from '-/hooks/usePerspectiveSettingsContext';+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';+import { useTaggingActionsContext } from '-/hooks/useTaggingActionsContext';+import { getSupportedFileTypes, isReorderTags } from '-/reducers/settings';+import i18n from '-/services/i18n';+import {+ findBackgroundColorForFolder,+ findColorForEntry,+ getDescriptionPreview,+} from '-/services/utils-io';+import { TS } from '-/tagspaces.namespace';+import Grid from '@mui/material/Grid2';+import IconButton from '@mui/material/IconButton';+import Paper from '@mui/material/Paper';+import Typography from '@mui/material/Typography';+import { styled, useTheme } from '@mui/material/styles';import {- formatFileSize,formatDateTime,+ formatFileSize,} from '@tagspaces/tagspaces-common/misc';import {extractTagsAsObjects,extractTitle,} from '@tagspaces/tagspaces-common/paths';-import AppConfig from '-/AppConfig';-import {- findBackgroundColorForFolder,- findColorForEntry,- getDescriptionPreview,-} from '-/services/utils-io';-import TagContainerDnd from '-/components/TagContainerDnd';-import TagContainer from '-/components/TagContainer';-import TagsPreview from '-/components/TagsPreview';-import { TS } from '-/tagspaces.namespace';-import { getSupportedFileTypes, isReorderTags } from '-/reducers/settings';-import { defaultSettings } from '../index';+import classNames from 'classnames';+import { useMemo } from 'react';import { useTranslation } from 'react-i18next';-import { useTaggingActionsContext } from '-/hooks/useTaggingActionsContext';-import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';-import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';-import { usePerspectiveSettingsContext } from '-/hooks/usePerspectiveSettingsContext';-import i18n from '-/services/i18n';+import { useSelector } from 'react-redux';+import { defaultSettings } from '../index';const PREFIX = 'RowStyles';export const classes = {@@ -374,7 +374,6 @@ function RowCell(props: Props) {sx={{ backgroundColor, borderRadius: '4px' }}><Grid- itemstyle={{minHeight: entryHeight,width: 45,@@ -390,11 +389,10 @@ function RowCell(props: Props) {</Grid>{isSmall ? (<Grid- item- xs- zeroMinWidthstyle={{display: 'flex',+ width: '100%',+ marginLeft: 5,}}><Typography@@ -418,7 +416,7 @@ function RowCell(props: Props) {</Typography></Grid>) : (- <Grid item xs zeroMinWidth style={{ alignSelf: 'center' }}>+ <Grid style={{ alignSelf: 'center', width: '100%', marginLeft: 5 }}><Typographyvariant="body1"title={fsEntry.name}@@ -452,7 +450,6 @@ function RowCell(props: Props) {)}{fsEntry.meta && fsEntry.meta.thumbPath && (<Grid- itemstyle={{display: 'flex',width: entryHeight,@@ -487,10 +484,10 @@ function RowCell(props: Props) {</Grid>)}<Grid- itemstyle={{display: 'flex',alignItems: 'center',+ marginRight: 5,}}><IconButton