[ARVADOS-WORKBENCH2] updated: 1.1.4-526-g7a398ca

Git user git at public.curoverse.com
Mon Aug 6 15:27:15 EDT 2018


Summary of changes:
 .../collection-panel-files.tsx                     | 25 +++++++++++++++++-----
 .../collection-files-service.ts                    | 24 +++++++++++++++------
 2 files changed, 37 insertions(+), 12 deletions(-)

       via  7a398ca38d58b3f81c05cb72a241095a94fe0ca9 (commit)
      from  be4d5a950e31200e907cd379cf9210a7c3dd8643 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 7a398ca38d58b3f81c05cb72a241095a94fe0ca9
Author: Daniel Kos <daniel.kos at contractors.roche.com>
Date:   Mon Aug 6 21:27:09 2018 +0200

    Fix renaming collection files
    
    Feature #13967
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos at contractors.roche.com>

diff --git a/src/components/collection-panel-files/collection-panel-files.tsx b/src/components/collection-panel-files/collection-panel-files.tsx
index 17bbe85..afe9e85 100644
--- a/src/components/collection-panel-files/collection-panel-files.tsx
+++ b/src/components/collection-panel-files/collection-panel-files.tsx
@@ -8,6 +8,10 @@ import { FileTreeData } from '../file-tree/file-tree-data';
 import { FileTree } from '../file-tree/file-tree';
 import { IconButton, Grid, Typography, StyleRulesCallback, withStyles, WithStyles, CardHeader, CardContent, Card, Button } from '@material-ui/core';
 import { CustomizeTableIcon } from '../icon/icon';
+import { connect, DispatchProp } from "react-redux";
+import { Dispatch } from "redux";
+import { RootState } from "../../store/store";
+import { ServiceRepository } from "../../services/services";
 
 export interface CollectionPanelFilesProps {
     items: Array<TreeItem<FileTreeData>>;
@@ -36,14 +40,24 @@ const styles: StyleRulesCallback<CssRules> = theme => ({
     }
 });
 
-export const CollectionPanelFiles = withStyles(styles)(
-    ({ onItemMenuOpen, onOptionsMenuOpen, classes, ...treeProps }: CollectionPanelFilesProps & WithStyles<CssRules>) =>
+const renameFile = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+  services.collectionFilesService.renameTest();
+};
+
+
+export const CollectionPanelFiles =
+    connect()(
+    withStyles(styles)(
+    ({ onItemMenuOpen, onOptionsMenuOpen, classes, dispatch, ...treeProps }: CollectionPanelFilesProps & DispatchProp & WithStyles<CssRules>) =>
         <Card className={classes.root}>
             <CardHeader
                 title="Files"
                 action={
-                    <Button 
-                        variant='raised' 
+                    <Button onClick={
+                        () => {
+                            dispatch<any>(renameFile());
+                        }}
+                        variant='raised'
                         color='primary'
                         size='small'>
                         Upload data
@@ -65,4 +79,5 @@ export const CollectionPanelFiles = withStyles(styles)(
                     </Typography>
             </Grid>
             <FileTree onMenuOpen={onItemMenuOpen} {...treeProps} />
-        </Card>);
+        </Card>)
+);
diff --git a/src/services/collection-files-service/collection-files-service.ts b/src/services/collection-files-service/collection-files-service.ts
index 3b320eb..dfeed0b 100644
--- a/src/services/collection-files-service/collection-files-service.ts
+++ b/src/services/collection-files-service/collection-files-service.ts
@@ -6,6 +6,8 @@ import { CollectionService } from "../collection-service/collection-service";
 import { parseKeepManifestText, stringifyKeepManifest } from "./collection-manifest-parser";
 import { mapManifestToCollectionFilesTree } from "./collection-manifest-mapper";
 import { CollectionFile } from "../../models/collection-file";
+import { CommonResourceService } from "../../common/api/common-resource-service";
+import * as _ from "lodash";
 
 export class CollectionFilesService {
 
@@ -26,19 +28,21 @@ export class CollectionFilesService {
     async renameFile(collectionUuid: string, file: { name: string, path: string }, newName: string) {
         const collection = await this.collectionService.get(collectionUuid);
         const manifest = parseKeepManifestText(collection.manifestText);
-        const updatedManifest = manifest.map(stream =>
-            stream.name === file.path
+        const updatedManifest = manifest.map(
+            stream => stream.name === file.path
                 ? {
                     ...stream,
-                    files: stream.files.map(f =>
-                        f.name === file.name
+                    files: stream.files.map(
+                        f => f.name === file.name
                             ? { ...f, name: newName }
-                            : f)
+                            : f
+                    )
                 }
                 : stream
         );
         const manifestText = stringifyKeepManifest(updatedManifest);
-        return this.collectionService.update(collectionUuid, { ...collection, manifestText });
+        const data = { ...collection, manifestText };
+        return this.collectionService.update(collectionUuid, CommonResourceService.mapKeys(_.snakeCase)(data));
     }
 
     async deleteFile(collectionUuid: string, file: { name: string, path: string }) {
@@ -56,4 +60,10 @@ export class CollectionFilesService {
         return this.collectionService.update(collectionUuid, { manifestText });
     }
 
-}
\ No newline at end of file
+    renameTest() {
+        const u = this.renameFile('qr1hi-4zz18-n0sx074erl4p0ph', {
+            name: 'extracted2.txt.png',
+            path: ''
+        }, 'extracted-new.txt.png');
+    }
+}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list