Skip to content

TagSpaces is an offline, open source, document manager with tagging support

add showDescription && showDetails in PerspectiveSettings (#1737)

Stanimirff98747fceba
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index 66c39f983..4c7af0b78 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -360,6 +360,8 @@
"copyMoveSelectedEntries": "Copy or move selected entries",
"deleteSelectedEntries": "Delete selected entries",
"showHideDirectories": "Show folders",
+ "showHideDescription": "Show Description",
+ "showHideDetails": "Show Details",
"showTags": "Show tags",
"sort": "Sort",
"thirdPartyLibs": "Third Party Libraries",
diff --git a/app/perspectives/grid-perspective/components/GridPagination.tsx b/app/perspectives/grid-perspective/components/GridPagination.tsx
index 02f18246b..d981b9224 100644
--- a/app/perspectives/grid-perspective/components/GridPagination.tsx
+++ b/app/perspectives/grid-perspective/components/GridPagination.tsx
@@ -55,6 +55,8 @@ interface Props {
// gridRef: Object;
directories: Array<TS.FileSystemEntry>;
showDirectories: boolean;
+ showDetails: boolean;
+ showDescription: boolean;
showTags: boolean;
thumbnailMode: string;
entrySize: string;
@@ -86,6 +88,8 @@ function GridPagination(props: Props) {
theme,
directories,
showDirectories,
+ showDetails,
+ showDescription,
renderCell,
isAppLoading,
currentDirectoryColor,
@@ -284,7 +288,6 @@ function GridPagination(props: Props) {
}
};
- let showDetails = false;
const folderName = extractDirectoryName(
decodeURIComponent(currentDirectoryPath),
PlatformIO.getDirSeparator()
@@ -498,6 +501,8 @@ const areEqual = (prevProp: Props, nextProp: Props) =>
nextProp.currentDirectoryPath === prevProp.currentDirectoryPath &&
nextProp.isMetaLoaded === prevProp.isMetaLoaded &&
nextProp.showDirectories === prevProp.showDirectories &&
+ nextProp.showDetails === prevProp.showDetails &&
+ nextProp.showDescription === prevProp.showDescription &&
nextProp.showTags === prevProp.showTags &&
nextProp.thumbnailMode === prevProp.thumbnailMode &&
nextProp.entrySize === prevProp.entrySize &&
diff --git a/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx b/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx
index 1e09b83f1..d3d87f676 100644
--- a/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx
+++ b/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx
@@ -69,6 +69,10 @@ interface Props {
gridPageLimit: number;
onClose: (isDefault?: boolean) => void;
setGridPageLimit: (number) => void;
+ toggleShowDescription: () => void;
+ toggleShowDetails: () => void;
+ showDetails: boolean;
+ showDescription: boolean;
toggleShowDirectories: () => void;
toggleShowTags: () => void;
showDirectories: boolean;
@@ -98,6 +102,10 @@ function GridSettingsDialog(props: Props) {
open,
onClose,
gridPageLimit,
+ showDetails,
+ toggleShowDetails,
+ showDescription,
+ toggleShowDescription,
toggleShowDirectories,
showDirectories,
toggleShowTags,
@@ -184,6 +192,30 @@ function GridSettingsDialog(props: Props) {
}
label={i18n.t('core:showTags')}
/>
+ <FormControlLabel
+ control={
+ <Switch
+ data-tid="gridPerspectiveToggleShowDescription"
+ defaultChecked={showDescription}
+ onChange={toggleShowDescription}
+ name={i18n.t('core:showHideDescription')}
+ color="primary"
+ />
+ }
+ label={i18n.t('core:showHideDescription')}
+ />
+ <FormControlLabel
+ control={
+ <Switch
+ data-tid="gridPerspectiveToggleShowDetails"
+ defaultChecked={showDetails}
+ onChange={toggleShowDetails}
+ name={i18n.t('core:showHideDetails')}
+ color="primary"
+ />
+ }
+ label={i18n.t('core:showHideDetails')}
+ />
</FormGroup>
<Divider />
<MenuItem
diff --git a/app/perspectives/grid-perspective/components/MainContainer.tsx b/app/perspectives/grid-perspective/components/MainContainer.tsx
index 9621ddf20..ca08c2f34 100644
--- a/app/perspectives/grid-perspective/components/MainContainer.tsx
+++ b/app/perspectives/grid-perspective/components/MainContainer.tsx
@@ -196,6 +196,16 @@ function GridPerspective(props: Props) {
? settings.showDirectories
: defaultSettings.showDirectories
);
+ const showDetails = useRef<boolean>(
+ settings && typeof settings.showDetails !== 'undefined'
+ ? settings.showDetails
+ : defaultSettings.showDetails
+ );
+ const showDescription = useRef<boolean>(
+ settings && typeof settings.showDescription !== 'undefined'
+ ? settings.showDescription
+ : defaultSettings.showDescription
+ );
const showTags = useRef<boolean>(
settings && typeof settings.showTags !== 'undefined'
? settings.showTags
@@ -231,6 +241,14 @@ function GridPerspective(props: Props) {
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
@@ -267,6 +285,8 @@ function GridPerspective(props: Props) {
if (isDefaultSetting.current !== undefined) {
const perspectiveSettings = {
showDirectories: showDirectories.current,
+ showDescription: showDescription.current,
+ showDetails: showDetails.current,
showTags: showTags.current,
layoutType: layoutType.current,
orderBy: orderBy.current,
@@ -296,6 +316,8 @@ function GridPerspective(props: Props) {
}, [
isDefaultSetting.current,
showDirectories.current,
+ showDescription.current,
+ showDetails.current,
showTags.current,
layoutType.current,
orderBy.current,
@@ -468,6 +490,16 @@ function GridPerspective(props: Props) {
// forceUpdate();
};
+ const toggleShowDetails = () => {
+ closeOptionsMenu();
+ showDetails.current = !showDetails.current;
+ };
+
+ const toggleShowDescription = () => {
+ closeOptionsMenu();
+ showDescription.current = !showDescription.current;
+ };
+
const toggleShowTags = () => {
closeOptionsMenu();
showTags.current = !showTags.current;
@@ -877,6 +909,8 @@ function GridPerspective(props: Props) {
theme={theme}
// gridRef={this.mainGrid}
directories={sortedDirectories}
+ showDetails={showDetails.current}
+ showDescription={showDescription.current}
showDirectories={showDirectories.current}
showTags={showTags.current}
thumbnailMode={thumbnailMode.current}
@@ -921,6 +955,10 @@ function GridPerspective(props: Props) {
gridPageLimit={gridPageLimit.current}
toggleShowDirectories={toggleShowDirectories}
toggleShowTags={toggleShowTags}
+ toggleShowDetails={toggleShowDetails}
+ toggleShowDescription={toggleShowDescription}
+ showDetails={showDetails.current}
+ showDescription={showDescription.current}
showDirectories={showDirectories.current}
showTags={showTags.current}
toggleThumbnailsMode={toggleThumbnailsMode}
diff --git a/app/perspectives/grid-perspective/index.tsx b/app/perspectives/grid-perspective/index.tsx
index def4c0dab..f1e5a4467 100644
--- a/app/perspectives/grid-perspective/index.tsx
+++ b/app/perspectives/grid-perspective/index.tsx
@@ -24,6 +24,8 @@ export const defaultSettings = {
entrySize: 'small', // small, normal, big
thumbnailMode: 'contain', // cover contain
showDirectories: true,
+ showDetails: true,
+ showDescription: true,
showTags: true,
gridPageLimit: 100
};
diff --git a/app/perspectives/list/components/MainContainer.tsx b/app/perspectives/list/components/MainContainer.tsx
index b5248434d..734874d52 100644
--- a/app/perspectives/list/components/MainContainer.tsx
+++ b/app/perspectives/list/components/MainContainer.tsx
@@ -196,6 +196,16 @@ function GridPerspective(props: Props) {
? settings.showDirectories
: defaultSettings.showDirectories
);
+ const showDetails = useRef<boolean>(
+ settings && typeof settings.showDetails !== 'undefined'
+ ? settings.showDetails
+ : defaultSettings.showDetails
+ );
+ const showDescription = useRef<boolean>(
+ settings && typeof settings.showDescription !== 'undefined'
+ ? settings.showDescription
+ : defaultSettings.showDescription
+ );
const showTags = useRef<boolean>(
settings && typeof settings.showTags !== 'undefined'
? settings.showTags
@@ -231,6 +241,14 @@ function GridPerspective(props: Props) {
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
@@ -267,6 +285,8 @@ function GridPerspective(props: Props) {
if (isDefaultSetting.current !== undefined) {
const perspectiveSettings = {
showDirectories: showDirectories.current,
+ showDescription: showDescription.current,
+ showDetails: showDetails.current,
showTags: showTags.current,
layoutType: layoutType.current,
orderBy: orderBy.current,
@@ -296,6 +316,8 @@ function GridPerspective(props: Props) {
}, [
isDefaultSetting.current,
showDirectories.current,
+ showDescription.current,
+ showDetails.current,
showTags.current,
layoutType.current,
orderBy.current,
@@ -468,6 +490,16 @@ function GridPerspective(props: Props) {
// forceUpdate();
};
+ const toggleShowDetails = () => {
+ closeOptionsMenu();
+ showDetails.current = !showDetails.current;
+ };
+
+ const toggleShowDescription = () => {
+ closeOptionsMenu();
+ showDescription.current = !showDescription.current;
+ };
+
const toggleShowTags = () => {
closeOptionsMenu();
showTags.current = !showTags.current;
@@ -872,6 +904,8 @@ function GridPerspective(props: Props) {
theme={theme}
// gridRef={this.mainGrid}
directories={sortedDirectories}
+ showDetails={showDetails.current}
+ showDescription={showDescription.current}
showDirectories={showDirectories.current}
showTags={showTags.current}
thumbnailMode={thumbnailMode.current}
@@ -916,6 +950,10 @@ function GridPerspective(props: Props) {
gridPageLimit={gridPageLimit.current}
toggleShowDirectories={toggleShowDirectories}
toggleShowTags={toggleShowTags}
+ toggleShowDetails={toggleShowDetails}
+ toggleShowDescription={toggleShowDescription}
+ showDetails={showDetails.current}
+ showDescription={showDescription.current}
showDirectories={showDirectories.current}
showTags={showTags.current}
toggleThumbnailsMode={toggleThumbnailsMode}
diff --git a/app/perspectives/list/index.tsx b/app/perspectives/list/index.tsx
index da8e80b75..6d2b0f782 100644
--- a/app/perspectives/list/index.tsx
+++ b/app/perspectives/list/index.tsx
@@ -24,6 +24,8 @@ export const defaultSettings = {
entrySize: 'small', // small, normal, big
thumbnailMode: 'contain', // cover contain
showDirectories: true,
+ showDetails: true,
+ showDescription: true,
showTags: true,
gridPageLimit: 100
};
diff --git a/app/tagspaces.namespace.d.ts b/app/tagspaces.namespace.d.ts
index 06a1eec71..b4c101c41 100644
--- a/app/tagspaces.namespace.d.ts
+++ b/app/tagspaces.namespace.d.ts
@@ -168,6 +168,8 @@ export namespace TS {
interface FolderSettings {
showDirectories?: boolean;
showTags?: boolean;
+ showDetails?: boolean;
+ showDescription?: boolean;
layoutType?: string;
orderBy?: boolean;
sortBy?: string;