Skip to content

Commit 06a06c1

Browse files
committed
display total file & folder counts for the selected workspace beneath the workspace title
1 parent 5bde946 commit 06a06c1

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

frontend/src/js/components/Uploads/CaptureFromUrl.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export const CaptureFromUrl = connect(
249249
align: 'left',
250250
render: (entry) =>
251251
isWorkspaceNode(entry.data)
252-
? <>{entry.name || '--'}<FileAndFolderCounts {...entry.data} /></>
252+
? <>{entry.name || '--'}<FileAndFolderCounts marginLeft="5px" {...entry.data} /></>
253253
: <></>, // don't render leaves since they can't be selected
254254
sort: (a, b) => a.name.localeCompare(b.name),
255255
style: {},

frontend/src/js/components/UtilComponents/TreeBrowser/FileAndFolderCounts.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ interface FileAndFolderCountsProps {
44
descendantsNodeCount: number;
55
descendantsLeafCount: number;
66
prefix?: string;
7+
marginLeft?: string | number;
78
}
89

9-
export const FileAndFolderCounts = ({descendantsNodeCount, descendantsLeafCount, prefix}: FileAndFolderCountsProps) => (
10-
<span style={{marginLeft: prefix ? undefined : "5px", fontSize: "smaller", color: "#8b8b8b"}}>
10+
export const FileAndFolderCounts = ({marginLeft, descendantsNodeCount, descendantsLeafCount, prefix}: FileAndFolderCountsProps) => (
11+
<span style={{marginLeft, fontSize: "smaller", color: "#8b8b8b"}}>
1112
({prefix}{prefix && " "}{descendantsNodeCount === 0 && descendantsLeafCount === 0
1213
? 'empty'
1314
: `${descendantsNodeCount.toLocaleString()} folders & ${descendantsLeafCount.toLocaleString()} files`

frontend/src/js/components/workspace/WorkspaceSummary.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { WorkspaceMetadata, WorkspaceEntry, Workspace } from '../../types/Workspaces';
2+
import {WorkspaceMetadata, WorkspaceEntry, Workspace, isWorkspaceNode} from '../../types/Workspaces';
33
import ModalAction from '../UtilComponents/ModalAction';
44
import { Label, Popup } from 'semantic-ui-react';
55
import { PartialUser } from '../../types/User';
@@ -17,6 +17,8 @@ import MdDelete from "react-icons/lib/md/delete";
1717
import TakeOwnershipOfWorkspaceModal from "./TakeOwnershipOfWorkspaceModal";
1818
import {takeOwnershipOfWorkspace} from "../../actions/workspaces/takeOwnershipOfWorkspace";
1919
import {CaptureFromUrl} from "../Uploads/CaptureFromUrl";
20+
import {EuiText} from "@elastic/eui";
21+
import {FileAndFolderCounts} from "../UtilComponents/TreeBrowser/FileAndFolderCounts";
2022

2123
type Props = {
2224
workspace: Workspace,
@@ -57,8 +59,18 @@ export default function WorkspaceSummary({
5759
&& follower.username !== workspace.owner.username
5860
)
5961

62+
const maybeRootNodeData = isWorkspaceNode(workspace.rootNode.data) && workspace.rootNode.data;
63+
6064
return <div className='page-title workspace__header'>
61-
<h1 className='workspace__title'>{workspace.name}</h1>
65+
<h1 className='workspace__title'>
66+
{workspace.name}{maybeRootNodeData && <>
67+
<br/>
68+
<EuiText size="s"><FileAndFolderCounts
69+
descendantsNodeCount={maybeRootNodeData.descendantsNodeCount}
70+
descendantsLeafCount={maybeRootNodeData.descendantsLeafCount}
71+
/></EuiText>
72+
</>}
73+
</h1>
6274
<div className='workspace__badges'>
6375
{workspace.owner.username !== workspace.creator.username && (<Label>Created&nbsp;by {workspace.creator.displayName}</Label>)}
6476
<Label>Owned&nbsp;by {workspace.owner.displayName}</Label>

frontend/src/js/components/workspace/Workspaces.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class WorkspacesUnconnected extends React.Component<Props, State> {
234234
</ReactTooltip>
235235
</>}
236236
<ItemName canEdit={canEdit} id={entry.id} name={entry.name} onFinishRename={curryRename}/>
237-
{isWorkspaceNode(entry.data) && <FileAndFolderCounts {...entry.data} />}
237+
{isWorkspaceNode(entry.data) && <FileAndFolderCounts marginLeft="5px" {...entry.data} />}
238238
</React.Fragment>;
239239
},
240240
sort: (a: TreeEntry<WorkspaceEntry>, b: TreeEntry<WorkspaceEntry>) => {

0 commit comments

Comments
 (0)