TagSpaces is an offline, open source, document manager with tagging support
feat: Add showEntriesDescription switch in the settings of the grid perspective (#1842)
Stanimire20613cc741b
diff --git a/app/locales/en/core.json b/app/locales/en/core.jsonindex b40cdeba8..f93a31b3e 100644--- a/app/locales/en/core.json+++ b/app/locales/en/core.json@@ -373,8 +373,9 @@"deleteSelectedEntries": "Delete selected entries","showHideDirectories": "Show folders","showHideDescription": "Show folder description",+ "showHideEntriesDescription": "Show description for files and folders","showHideDetails": "Show folder details",- "showTags": "Show tags",+ "showTags": "Show tags for files and folders","sort": "Sort","thirdPartyLibs": "Third Party Libraries","indexLocation": "Refresh Location Index",diff --git a/app/perspectives/grid-perspective/components/CellContent.tsx b/app/perspectives/grid-perspective/components/CellContent.tsxindex 99b7b0272..910c41324 100644--- a/app/perspectives/grid-perspective/components/CellContent.tsx+++ b/app/perspectives/grid-perspective/components/CellContent.tsx@@ -85,6 +85,7 @@ interface Props {reorderTags: boolean;lastThumbnailImageChange: any;exitSearchMode: () => void;+ showEntriesDescription?: boolean;}function CellContent(props: Props) {@@ -117,17 +118,19 @@ function CellContent(props: Props) {PlatformIO.getDirSeparator());- let { description } = fsEntry;-- if (description && description.length > maxDescriptionPreviewLength) {- description = getDescriptionPreview(- description,- maxDescriptionPreviewLength- );- }+ let description;+ if (props.showEntriesDescription) {+ description = fsEntry.description;+ if (description && description.length > maxDescriptionPreviewLength) {+ description = getDescriptionPreview(+ description,+ maxDescriptionPreviewLength+ );+ }- if (description && layoutType === 'row' && fsEntry.isFile) {- description = ' | ' + description;+ if (description && layoutType === 'row' && fsEntry.isFile) {+ description = ' | ' + description;+ }}const fsEntryColor = findColorForEntry(fsEntry, supportedFileTypes);diff --git a/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx b/app/perspectives/grid-perspective/components/GridSettingsDialog.tsxindex d6d0876f7..8e3df11e0 100644--- a/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx+++ b/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx@@ -69,10 +69,12 @@ interface Props {gridPageLimit: number;onClose: (isDefault?: boolean) => void;setGridPageLimit: (number) => void;- toggleShowDescription: () => void;+ toggleShowDescription?: () => void;+ toggleShowEntriesDescription?: () => void;toggleShowDetails: () => void;showDetails: boolean;showDescription: boolean;+ showEntriesDescription?: boolean;toggleShowDirectories: () => void;toggleShowTags: () => void;showDirectories: boolean;@@ -105,6 +107,8 @@ function GridSettingsDialog(props: Props) {showDetails,toggleShowDetails,showDescription,+ showEntriesDescription,+ toggleShowEntriesDescription,toggleShowDescription,toggleShowDirectories,showDirectories,@@ -192,31 +196,45 @@ function GridSettingsDialog(props: Props) {}label={i18n.t('core:showTags')}/>- <Divider /><FormControlLabelcontrol={<Switch- data-tid="gridPerspectiveToggleShowDetails"- defaultChecked={showDetails}- onChange={toggleShowDetails}- name={i18n.t('core:showHideDetails')}+ data-tid="gridPerspectiveToggleShowEntriesDescription"+ defaultChecked={showEntriesDescription}+ onChange={toggleShowEntriesDescription}+ name={i18n.t('core:showHideEntriesDescription')}color="primary"/>}- label={i18n.t('core:showHideDetails')}+ label={i18n.t('core:showHideEntriesDescription')}/>+ <Divider /><FormControlLabelcontrol={<Switch- data-tid="gridPerspectiveToggleShowDescription"- defaultChecked={showDescription}- onChange={toggleShowDescription}- name={i18n.t('core:showHideDescription')}+ data-tid="gridPerspectiveToggleShowDetails"+ defaultChecked={showDetails}+ onChange={toggleShowDetails}+ name={i18n.t('core:showHideDetails')}color="primary"/>}- label={i18n.t('core:showHideDescription')}+ label={i18n.t('core:showHideDetails')}/>+ {toggleShowDescription && (+ <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 6c8fd4018..5353d29fd 100644--- a/app/perspectives/grid-perspective/components/MainContainer.tsx+++ b/app/perspectives/grid-perspective/components/MainContainer.tsx@@ -218,6 +218,11 @@ function GridPerspective(props: Props) {? settings.showDescription: defaultSettings.showDescription);+ const showEntriesDescription = useRef<boolean>(+ settings && typeof settings.showEntriesDescription !== 'undefined'+ ? settings.showEntriesDescription+ : defaultSettings.showEntriesDescription+ );const showTags = useRef<boolean>(settings && typeof settings.showTags !== 'undefined'? settings.showTags@@ -297,6 +302,10 @@ function GridPerspective(props: Props) {perspectiveSettings && perspectiveSettings.showDescription !== undefined? perspectiveSettings.showDescription: defaultSettings.showDescription;+ showEntriesDescription.current =+ perspectiveSettings && perspectiveSettings.showEntriesDescription !== undefined+ ? perspectiveSettings.showEntriesDescription+ : defaultSettings.showEntriesDescription;showDetails.current =perspectiveSettings && perspectiveSettings.showDetails !== undefined? perspectiveSettings.showDetails@@ -340,6 +349,7 @@ function GridPerspective(props: Props) {const perspectiveSettings = {showDirectories: showDirectories.current,showDescription: showDescription.current,+ showEntriesDescription: showEntriesDescription.current,showDetails: showDetails.current,showTags: showTags.current,layoutType: layoutType.current,@@ -371,6 +381,7 @@ function GridPerspective(props: Props) {isDefaultSetting.current,showDirectories.current,showDescription.current,+ showEntriesDescription.current,showDetails.current,showTags.current,layoutType.current,@@ -458,6 +469,11 @@ function GridPerspective(props: Props) {showDescription.current = !showDescription.current;};+ const toggleShowEntriesDescription = () => {+ closeOptionsMenu();+ showEntriesDescription.current = !showEntriesDescription.current;+ };+const toggleShowTags = () => {closeOptionsMenu();showTags.current = !showTags.current;@@ -641,6 +657,7 @@ function GridPerspective(props: Props) {<CellContentselected={selected}fsEntry={fsEntry}+ showEntriesDescription={showEntriesDescription.current}entrySize={entrySize.current}classes={classes}isLast={isLast}@@ -783,8 +800,10 @@ function GridPerspective(props: Props) {toggleShowTags={toggleShowTags}toggleShowDetails={toggleShowDetails}toggleShowDescription={toggleShowDescription}+ toggleShowEntriesDescription={toggleShowEntriesDescription}showDetails={showDetails.current}showDescription={showDescription.current}+ showEntriesDescription={showEntriesDescription.current}showDirectories={showDirectories.current}showTags={showTags.current}toggleThumbnailsMode={toggleThumbnailsMode}diff --git a/app/perspectives/grid-perspective/index.tsx b/app/perspectives/grid-perspective/index.tsxindex d95693e37..6717b6b3c 100644--- a/app/perspectives/grid-perspective/index.tsx+++ b/app/perspectives/grid-perspective/index.tsx@@ -26,6 +26,7 @@ export const defaultSettings = {showDirectories: true,showDetails: true,showDescription: false,+ showEntriesDescription: true,showTags: true,gridPageLimit: 100};diff --git a/app/perspectives/list/components/MainContainer.tsx b/app/perspectives/list/components/MainContainer.tsxindex 6ff5caeed..0c5279233 100644--- a/app/perspectives/list/components/MainContainer.tsx+++ b/app/perspectives/list/components/MainContainer.tsx@@ -72,6 +72,7 @@ import { defaultSettings } from '../index';import { PerspectiveIDs } from '-/perspectives';import { fileOperationsEnabled } from '-/perspectives/common/main-container';import GlobalSearch from '-/services/search-index';+import useFirstRender from '-/utils/useFirstRender';interface Props {classes: any;@@ -79,7 +80,7 @@ interface Props {desktopMode: boolean;currentDirectoryPath: string;lastSelectedEntry: any;- selectedEntries: Array<any>;+ selectedEntries: Array<TS.FileSystemEntry>;supportedFileTypes: Array<any>;isReadOnlyMode: boolean;openFsEntry: (fsEntry?: TS.FileSystemEntry) => void;@@ -211,6 +212,11 @@ function GridPerspective(props: Props) {? settings.showDescription: defaultSettings.showDescription);+ const showEntriesDescription = useRef<boolean>(+ settings && typeof settings.showEntriesDescription !== 'undefined'+ ? settings.showEntriesDescription+ : defaultSettings.showEntriesDescription+ );const showTags = useRef<boolean>(settings && typeof settings.showTags !== 'undefined'? settings.showTags@@ -235,6 +241,7 @@ function GridPerspective(props: Props) {// true: save in default settings; false: save per folder settings; undefined - dont save changesconst isDefaultSetting = useRef<boolean>(undefined);const [ignored, forceUpdate] = useReducer(x => x + 1, 0);+ const firstRender = useFirstRender();useEffect(() => {if (props.selectedEntries.length === 1) {@@ -243,56 +250,65 @@ function GridPerspective(props: Props) {}, [props.selectedEntries]);useEffect(() => {- const perspectiveSettings = getSettings(props.directoryMeta);- showDirectories.current =- perspectiveSettings && perspectiveSettings.showDirectories !== undefined- ? perspectiveSettings.showDirectories- : defaultSettings.showDirectories;- showDescription.current =- perspectiveSettings && perspectiveSettings.showDescription !== undefined- ? perspectiveSettings.showDescription- : defaultSettings.showDescription;- showDetails.current =- perspectiveSettings && perspectiveSettings.showDetails !== undefined- ? perspectiveSettings.showDetails- : defaultSettings.showDetails;- showTags.current =- perspectiveSettings && perspectiveSettings.showTags !== undefined- ? perspectiveSettings.showTags- : defaultSettings.showTags;- layoutType.current = defaultSettings.layoutType;- orderBy.current =- perspectiveSettings && perspectiveSettings.orderBy !== undefined- ? perspectiveSettings.orderBy- : defaultSettings.orderBy;- sortBy.current =- perspectiveSettings && perspectiveSettings.sortBy !== undefined- ? perspectiveSettings.sortBy- : defaultSettings.sortBy;- singleClickAction.current =- perspectiveSettings && perspectiveSettings.singleClickAction !== undefined- ? perspectiveSettings.singleClickAction- : defaultSettings.singleClickAction;- entrySize.current =- perspectiveSettings && perspectiveSettings.entrySize !== undefined- ? perspectiveSettings.entrySize- : defaultSettings.entrySize;- thumbnailMode.current =- perspectiveSettings && perspectiveSettings.thumbnailMode !== undefined- ? perspectiveSettings.thumbnailMode- : defaultSettings.thumbnailMode;- gridPageLimit.current =- perspectiveSettings && perspectiveSettings.gridPageLimit !== undefined- ? perspectiveSettings.gridPageLimit- : defaultSettings.gridPageLimit;- forceUpdate();+ if (!firstRender) {+ const perspectiveSettings = getSettings(props.directoryMeta);+ showDirectories.current =+ perspectiveSettings && perspectiveSettings.showDirectories !== undefined+ ? perspectiveSettings.showDirectories+ : defaultSettings.showDirectories;+ showDescription.current =+ perspectiveSettings && perspectiveSettings.showDescription !== undefined+ ? perspectiveSettings.showDescription+ : defaultSettings.showDescription;+ showEntriesDescription.current =+ perspectiveSettings &&+ perspectiveSettings.showEntriesDescription !== undefined+ ? perspectiveSettings.showEntriesDescription+ : defaultSettings.showEntriesDescription;+ showDetails.current =+ perspectiveSettings && perspectiveSettings.showDetails !== undefined+ ? perspectiveSettings.showDetails+ : defaultSettings.showDetails;+ showTags.current =+ perspectiveSettings && perspectiveSettings.showTags !== undefined+ ? perspectiveSettings.showTags+ : defaultSettings.showTags;+ layoutType.current = defaultSettings.layoutType;+ orderBy.current =+ perspectiveSettings && perspectiveSettings.orderBy !== undefined+ ? perspectiveSettings.orderBy+ : defaultSettings.orderBy;+ sortBy.current =+ perspectiveSettings && perspectiveSettings.sortBy !== undefined+ ? perspectiveSettings.sortBy+ : defaultSettings.sortBy;+ singleClickAction.current =+ perspectiveSettings &&+ perspectiveSettings.singleClickAction !== undefined+ ? perspectiveSettings.singleClickAction+ : defaultSettings.singleClickAction;+ entrySize.current =+ perspectiveSettings && perspectiveSettings.entrySize !== undefined+ ? perspectiveSettings.entrySize+ : defaultSettings.entrySize;+ thumbnailMode.current =+ perspectiveSettings && perspectiveSettings.thumbnailMode !== undefined+ ? perspectiveSettings.thumbnailMode+ : defaultSettings.thumbnailMode;+ gridPageLimit.current =+ perspectiveSettings && perspectiveSettings.gridPageLimit !== undefined+ ? perspectiveSettings.gridPageLimit+ : defaultSettings.gridPageLimit;+ forceUpdate();+ }}, [props.directoryMeta]);useEffect(() => {- if (isDefaultSetting.current !== undefined) {+ if (!firstRender && isDefaultSetting.current !== undefined) {const perspectiveSettings = {showDirectories: showDirectories.current,showDescription: showDescription.current,+ showEntriesDescription: showEntriesDescription.current,showDetails: showDetails.current,showTags: showTags.current,layoutType: layoutType.current,@@ -324,6 +340,7 @@ function GridPerspective(props: Props) {isDefaultSetting.current,showDirectories.current,showDescription.current,+ showEntriesDescription.current,showDetails.current,showTags.current,layoutType.current,@@ -426,6 +443,11 @@ function GridPerspective(props: Props) {showDescription.current = !showDescription.current;};+ const toggleShowEntriesDescription = () => {+ closeOptionsMenu();+ showEntriesDescription.current = !showEntriesDescription.current;+ };+const toggleShowTags = () => {closeOptionsMenu();showTags.current = !showTags.current;@@ -614,6 +636,7 @@ function GridPerspective(props: Props) {<CellContentselected={selected}fsEntry={fsEntry}+ showEntriesDescription={showEntriesDescription.current}entrySize={entrySize.current}classes={classes}isLast={isLast}@@ -754,8 +777,10 @@ function GridPerspective(props: Props) {toggleShowTags={toggleShowTags}toggleShowDetails={toggleShowDetails}toggleShowDescription={toggleShowDescription}+ toggleShowEntriesDescription={toggleShowEntriesDescription}showDetails={showDetails.current}showDescription={showDescription.current}+ showEntriesDescription={showEntriesDescription.current}showDirectories={showDirectories.current}showTags={showTags.current}toggleThumbnailsMode={toggleThumbnailsMode}diff --git a/app/perspectives/list/index.tsx b/app/perspectives/list/index.tsxindex c96767663..20d28369d 100644--- a/app/perspectives/list/index.tsx+++ b/app/perspectives/list/index.tsx@@ -26,6 +26,7 @@ export const defaultSettings = {showDirectories: true,showDetails: true,showDescription: false,+ showEntriesDescription: true,showTags: true,gridPageLimit: 100};