TagSpaces is an offline, open source, document manager with tagging support
feat: adding support for folder description and details
Ilian Sapundshiev066cb1f364e0
diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsxindex 09dc2438f..0e0dabcc0 100644--- a/app/components/EntryProperties.tsx+++ b/app/components/EntryProperties.tsx@@ -168,7 +168,7 @@ interface Props {const defaultBackgrounds = ['linear-gradient(43deg, rgb(65, 88, 208) 0%, rgb(200, 80, 190) 45%, rgb(255, 204, 112) 100%)','linear-gradient( 102deg, rgba(253,189,85,1) 8%, rgba(249,131,255,1) 100% )',- 'radial-gradient( circle 321px at 8% 75%, rgba(209,247,241,1) 0%, rgba(249,213,213,1) 80% )',+ 'radial-gradient( circle farthest-corner at 1.4% 2.8%, rgba(240,249,249,1) 0%, rgba(182,199,226,1) 100% )','linear-gradient( 110deg, rgba(48,207,208,1) 11.2%, rgba(51,8,103,1) 90% )'];diff --git a/app/perspectives/grid-perspective/components/CellContent.tsx b/app/perspectives/grid-perspective/components/CellContent.tsxindex 253d3b7a8..c45e7ea22 100644--- a/app/perspectives/grid-perspective/components/CellContent.tsx+++ b/app/perspectives/grid-perspective/components/CellContent.tsx@@ -160,7 +160,8 @@ function CellContent(props: Props) {return (<divstyle={{- background: fsEntryBgColor+ background: fsEntryBgColor,+ borderRadius: 5// opacity: fsEntry.isIgnored ? 0.3 : 1}}>diff --git a/app/perspectives/grid-perspective/components/GridPagination.tsx b/app/perspectives/grid-perspective/components/GridPagination.tsxindex 75c5b1118..f4f50e6f4 100644--- a/app/perspectives/grid-perspective/components/GridPagination.tsx+++ b/app/perspectives/grid-perspective/components/GridPagination.tsx@@ -18,8 +18,11 @@import React, { useEffect, useRef } from 'react';import { connect } from 'react-redux';+import { alpha } from '@mui/material/styles';import Typography from '@mui/material/Typography';import Tooltip from '-/components/Tooltip';+import Grid from '@mui/material/Grid';+import Box from '@mui/material/Box';import Pagination from '@mui/material/Pagination';import { bindActionCreators } from 'redux';import AppConfig from '@tagspaces/tagspaces-platforms/AppConfig';@@ -39,18 +42,18 @@ import {getSearchResultCount,getCurrentDirectoryTags,isLoading,+ getCurrentDirectoryDescription,getLastBackgroundImageChange} from '-/reducers/app';import EntryIcon from '-/components/EntryIcon';import TagsPreview from '-/components/TagsPreview';import { TS } from '-/tagspaces.namespace';-import { getMetaForEntry } from '-/services/utils-io';+import { getMetaForEntry, convertMarkDown } from '-/services/utils-io';import PlatformIO from '-/services/platform-facade';interface Props {isMetaLoaded: boolean;setIsMetaLoaded: (isLoaded: boolean) => void;- className?: string;style?: any;theme: any;// gridRef: Object;@@ -59,6 +62,7 @@ interface Props {showDetails: boolean;showDescription: boolean;showTags: boolean;+ currentDirectoryDescription: string;thumbnailMode: string;entrySize: string;files: Array<TS.FileSystemEntry>;@@ -85,7 +89,6 @@ interface Props {function GridPagination(props: Props) {const {- className,style,theme,directories,@@ -97,6 +100,7 @@ function GridPagination(props: Props) {currentDirectoryColor,currentDirectoryTags,currentDirectoryPath,+ currentDirectoryDescription,gridPageLimit,currentPage,files@@ -316,6 +320,17 @@ function GridPagination(props: Props) {}const dirColor = currentDirectoryColor || 'transparent';+ const folderSummary =+ directories.length + ' folder(s) and ' + allFilesCount + ' file(s) found';++ let descriptionHTML = '';+ if (showDescription && currentDirectoryDescription) {+ descriptionHTML = convertMarkDown(+ currentDirectoryDescription,+ currentDirectoryPath+ );+ }+return (// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions,jsx-a11y/no-static-element-interactions<div@@ -341,70 +356,89 @@ function GridPagination(props: Props) {backgroundRepeat: 'no-repeat'}}>- {showDetails && (- <>- <div- style={{- position: 'relative',- height: 150- }}- >- <img- alt="thumbnail"- src={folderTmbPath}- // @ts-ignore- onError={i => (i.target.style.display = 'none')}- loading="lazy"- style={{- objectFit: 'contain',- position: 'absolute',- width: '100%',- height: 150- }}- />- <EntryIcon isFile={false} />- </div>- <Typography- style={{- display: 'block',- padding: 10,- paddingTop: 55,- borderRadius: 5,- marginBottom: 5,- height: 50,- overflow: 'auto',- textShadow: '1px 1px #8f8f8f',- color: theme.palette.text.primary- }}- role="button"- id="descriptionArea"- >- {folderName}- </Typography>- {(directories.length > 0 || pageFiles.length > 0) && (- <div style={{ padding: 15, bottom: 10 }}>- <Typography+ <Grid container spacing={2}>+ <Grid item xs={12} style={{ height: 70 }} />+ {showDetails && (+ <>+ <Grid xs={8} item>+ <divstyle={{- fontSize: '0.9rem',- color: theme.palette.text.secondary,- textShadow: '1px 1px #8f8f8f'+ padding: 10,+ marginLeft: 10,+ marginRight: 10,+ marginTop: 0,+ marginBottom: 0,+ background: alpha(theme.palette.background.default, 0.9),+ borderRadius: 8,+ height: 130}}>- {directories.length +- ' folder(s) and ' +- allFilesCount +- ' file(s) found'}- </Typography>- </div>- )}- </>- )}- <TagsPreview tags={currentDirectoryTags} />- <div- className={className}- style={style}- data-tid="perspectiveGridFileTable"- >+ <Typography+ style={{+ display: 'flex',+ alignItems: 'center',+ overflow: 'auto',+ fontSize: '1.5rem',+ color: theme.palette.text.primary+ }}+ >+ {folderName}+ <TagsPreview tags={currentDirectoryTags} />+ </Typography>+ {(directories.length > 0 || pageFiles.length > 0) && (+ <Typography+ style={{+ fontSize: '0.9rem',+ paddingBottom: 5,+ color: theme.palette.text.primary+ }}+ >+ {folderSummary}+ </Typography>+ )}+ </div>+ </Grid>+ <Grid xs={4} item>+ <div+ style={{+ borderRadius: 8,+ marginLeft: 'auto',+ marginRight: 'auto',+ height: 150,+ width: 150,+ backgroundImage: 'url(' + folderTmbPath + ')',+ backgroundSize: 'contain',+ backgroundRepeat: 'no-repeat',+ backgroundPosition: 'center center'+ }}+ ></div>+ </Grid>+ </>+ )}+ {showDescription && descriptionHTML && (+ <Grid xs={12}>+ <Typography+ style={{+ display: 'block',+ padding: 10,+ paddingTop: 0,+ margin: '15px 10px 5px 25px',+ background: alpha(theme.palette.background.default, 0.9),+ borderRadius: 8,+ overflow: 'auto',+ color: theme.palette.text.primary+ }}+ role="button"+ id="descriptionArea"+ dangerouslySetInnerHTML={{+ // eslint-disable-next-line no-nested-ternary+ __html: descriptionHTML+ }}+ />+ </Grid>+ )}+ </Grid>+ <div style={style} data-tid="perspectiveGridFileTable">{page.current === 1 && directories.map(entry => renderCell(entry))}{pageFiles.map((entry, index, dArray) =>renderCell(entry, index === dArray.length - 1)@@ -444,14 +478,7 @@ function GridPagination(props: Props) {)}</div>{showPagination && (- <Tooltip- title={- directories.length +- ' folder(s) and ' +- allFilesCount +- ' file(s) found'- }- >+ <Tooltip title={folderSummary}><Paginationstyle={{left: 15,@@ -477,13 +504,10 @@ function GridPagination(props: Props) {<Typographystyle={{fontSize: '0.9rem',- color: theme.palette.text.secondary+ color: theme.palette.text.primary}}>- {directories.length +- ' folder(s) and ' +- allFilesCount +- ' file(s) found'}+ {folderSummary}</Typography></div>)}@@ -500,6 +524,7 @@ function mapStateToProps(state) {// pageEntries: getPageEntries(state),currentDirectoryTags: getCurrentDirectoryTags(state),isMetaLoaded: getIsMetaLoaded(state),+ currentDirectoryDescription: getCurrentDirectoryDescription(state),lastBackgroundImageChange: getLastBackgroundImageChange(state)};}diff --git a/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx b/app/perspectives/grid-perspective/components/GridSettingsDialog.tsxindex 875c68f4f..d6d0876f7 100644--- a/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx+++ b/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx@@ -193,18 +193,6 @@ function GridSettingsDialog(props: Props) {label={i18n.t('core:showTags')}/><Divider />- {/* <FormControlLabel- control={- <Switch- data-tid="gridPerspectiveToggleShowDescription"- defaultChecked={showDescription}- onChange={toggleShowDescription}- name={i18n.t('core:showHideDescription')}- color="primary"- />- }- label={i18n.t('core:showHideDescription')}- /> */}<FormControlLabelcontrol={<Switch@@ -217,6 +205,18 @@ function GridSettingsDialog(props: Props) {}label={i18n.t('core:showHideDetails')}/>+ <FormControlLabel+ control={+ <Switch+ data-tid="gridPerspectiveToggleShowDescription"+ defaultChecked={showDescription}+ onChange={toggleShowDescription}+ name={i18n.t('core:showHideDescription')}+ color="primary"+ />+ }+ label={i18n.t('core:showHideDescription')}+ /></FormGroup><Divider /><MenuItemdiff --git a/app/perspectives/grid-perspective/components/MainContainer.tsx b/app/perspectives/grid-perspective/components/MainContainer.tsxindex 07b20a695..09d7b61dc 100644--- a/app/perspectives/grid-perspective/components/MainContainer.tsx+++ b/app/perspectives/grid-perspective/components/MainContainer.tsx@@ -109,7 +109,6 @@ interface Props {) => void;currentLocation: TS.Location;locations: Array<TS.Location>;- // isDesktopMode: boolean;toggleDeleteMultipleEntriesDialog: () => void;directoryMeta: TS.FileSystemEntryMeta;setDirectoryMeta: (fsEntryMeta: TS.FileSystemEntryMeta) => void;@@ -377,7 +376,6 @@ function GridPerspective(props: Props) {const handleGridPageLimit = (limit: number) => {gridPageLimit.current = limit;- // setIsGridSettingsDialogOpened(false);// forceUpdate();};@@ -696,15 +694,7 @@ function GridPerspective(props: Props) {};const renderCell = (fsEntry: TS.FileSystemEntry, isLast?: boolean) => {- const {- // classes,- // theme,- // selectedEntries,- addTags,- addTag,- supportedFileTypes,- openFsEntry- } = props;+ const { addTags, addTag, supportedFileTypes, openFsEntry } = props;if (!fsEntry.isFile && !showDirectories.current) {return;}@@ -889,14 +879,9 @@ function GridPerspective(props: Props) {><GridPaginationgridPageLimit={gridPageLimit.current}- // className={- // layoutType.current === 'grid'- // ? classes.gridContainer- // : classes.rowContainer- // }style={{margin: 0,- marginTop: 53,+ // marginTop: 53,display: 'grid',gridGap: '5px 5px',padding: 5,@@ -905,11 +890,8 @@ function GridPerspective(props: Props) {layoutType.current === 'grid'? 'repeat(auto-fit,minmax(' + entryWidth + 'px,1fr))': 'none'- // gridTemplateRows:- // layoutType === 'grid' ? 'repeat(auto-fit, 230px)' : 'auto'}}theme={theme}- // gridRef={this.mainGrid}directories={sortedDirectories}showDetails={showDetails.current}showDescription={showDescription.current}@@ -1107,7 +1089,6 @@ function mapStateToProps(state) {keyBindings: getKeyBindingObject(state),currentLocation: getLocation(state, state.app.currentLocationId),locations: getLocations(state),- // isDesktopMode: isDesktopMode(state),isDeleteMultipleEntriesDialogOpened: isDeleteMultipleEntriesDialogOpened(state)diff --git a/app/perspectives/grid-perspective/components/styles.css.tsx b/app/perspectives/grid-perspective/components/styles.css.tsxindex 5c4e83b8a..efa813108 100644--- a/app/perspectives/grid-perspective/components/styles.css.tsx+++ b/app/perspectives/grid-perspective/components/styles.css.tsx@@ -16,23 +16,16 @@**/import AppConfig from '@tagspaces/tagspaces-platforms/AppConfig';+import { alpha } from '@mui/material/styles';export default (theme: any): any => ({- gridContainer: {- display: 'grid',- gridGap: '0px 0px',- padding: 0,- paddingRight: 4,- paddingBottom: 20- },- rowContainer: {- display: 'grid',- gridGap: '0px 0px',- padding: 0,- paddingRight: 4,- margin: 0,- paddingBottom: 10- },+ // rowContainer: {+ // display: 'grid',+ // gridGap: '0px 0px',+ // padding: 0,+ // margin: 0,+ // paddingBottom: 10+ // },gridCell: {border: '2px solid transparent',marginTop: 1,@@ -145,8 +138,7 @@ export default (theme: any): any => ({zIndex: 1,background:'linear-gradient(0deg, ' +- theme.palette.background.default +- (theme.palette.background.default.length === 4 ? 'A' : 'AA') ++ alpha(theme.palette.background.default, 0.67) +' 0%, ' +theme.palette.background.default +' 99%)',diff --git a/app/perspectives/list/components/MainContainer.tsx b/app/perspectives/list/components/MainContainer.tsxindex ebdbaf5c6..21d80481b 100644--- a/app/perspectives/list/components/MainContainer.tsx+++ b/app/perspectives/list/components/MainContainer.tsx@@ -889,22 +889,12 @@ function GridPerspective(props: Props) {><GridPaginationgridPageLimit={gridPageLimit.current}- className={- layoutType.current === 'grid'- ? classes.gridContainer- : classes.rowContainer- }style={{- marginTop: 53,- gridTemplateColumns:- layoutType.current === 'grid'- ? 'repeat(auto-fit,minmax(' + entryWidth + 'px,1fr))'- : 'none'- // gridTemplateRows:- // layoutType === 'grid' ? 'repeat(auto-fit, 230px)' : 'auto'+ marginTop: 5,+ paddingRight: 4,+ gridTemplateColumns: 'none'}}theme={theme}- // gridRef={this.mainGrid}directories={sortedDirectories}showDetails={showDetails.current}showDescription={showDescription.current}