Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Add getting file size and number of collection files in main panel an… #128

Merged
merged 2 commits into from Oct 23, 2018

Conversation

unodgs
Copy link
Contributor

@unodgs unodgs commented Oct 16, 2018

…d side panel

Feature #14349

Arvados-DCO-1.1-Signed-off-by: Daniel Kos daniel.kos@contractors.roche.com

…d side panel

Feature #14349

Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos@contractors.roche.com>
@@ -207,11 +207,12 @@ const toggleParentNodeSelection = (id: string) => <T>(tree: Tree<T>) => {
const mapNodeValue = <T, R>(mapFn: (value: T) => R) => (node: TreeNode<T>): TreeNode<R> =>
({ ...node, value: mapFn(node.value) });

const getRootNodeChildren = <T>(tree: Tree<T>) =>
const getRootNodeChildrenIds = <T>(tree: Tree<T>) =>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getRootNodeChildrenIds = getNodeDescendantsIds(TREE_ROOT_ID)

fileSize = flattenFiles.reduce((acc, f) => {
return acc + (f && f.value.type === CollectionFileType.FILE ? f.value.size : 0);
}, 0);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the most of reduce capabilities it could also be written as:

const [fileCount, fileSize] = flattenFiles.reduce(
    ([fileCount, fileSize], f) =>
        f.value.type === CollectionFileType.FILE
             ? [fileCount +1, fileSize + 1]
             : [fileCount, fileSize], [0, 0])

@@ -14,6 +14,8 @@ export interface CollectionResource extends TrashableResource {
replicationDesired: number;
replicationConfirmed: number;
replicationConfirmedAt: string;
fileSize: number;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it's not the best idea to extend CollectionResource since it's purpose was to represent API collection structure 1:1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what's your proposal?

Feature #14349

Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos@contractors.roche.com>
@arvados-bot arvados-bot merged commit 3f51c12 into master Oct 23, 2018
@tetron tetron deleted the 14349-files-placeholders branch February 27, 2020 17:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants