[ARVADOS-WORKBENCH2] updated: 1.1.4-270-ga0b33ac

Git user git at public.curoverse.com
Thu Jul 12 03:26:31 EDT 2018


Summary of changes:
 .../details-panel-factory.tsx                      | 19 +++++------
 .../details-panel-factory/items/abstract-item.tsx  |  4 +--
 .../items/collection-item.tsx                      |  6 ++--
 .../details-panel-factory/items/empty-item.tsx     | 25 ++++++++++++++
 .../details-panel-factory/items/process-item.tsx   |  6 ++--
 .../details-panel-factory/items/project-item.tsx   |  6 ++--
 src/models/empty.ts                                | 10 ++++++
 .../details-panel/details-panel.tsx                | 39 +++++++---------------
 8 files changed, 66 insertions(+), 49 deletions(-)
 create mode 100644 src/components/details-panel-factory/items/empty-item.tsx
 create mode 100644 src/models/empty.ts

       via  a0b33ac652512852570f2805ee85fb902334010b (commit)
      from  6fddc846a57888e77f95c7377469f681596cedbb (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 a0b33ac652512852570f2805ee85fb902334010b
Author: Janicki Artur <artur.janicki at contractors.roche.com>
Date:   Wed Jul 11 12:45:11 2018 +0200

    set export as default abstract class
    
    Feature #13705
    
    Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki at contractors.roche.com>
    
    Feature #13705
    
    Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki at contractors.roche.com>

diff --git a/src/components/details-panel-factory/details-panel-factory.tsx b/src/components/details-panel-factory/details-panel-factory.tsx
index aa9d777..a9e5a21 100644
--- a/src/components/details-panel-factory/details-panel-factory.tsx
+++ b/src/components/details-panel-factory/details-panel-factory.tsx
@@ -1,17 +1,14 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
 
-
-import * as React from 'react';
-import { ProjectResource } from "../../models/project";
-import { CollectionResource } from "../../models/collection";
-import { ProcessResource } from "../../models/process";
 import { ResourceKind } from '../../models/kinds';
 import ProjectItem from './items/project-item';
 import CollectionItem from './items/collection-item';
 import ProcessItem from './items/process-item';
-import { AbstractItem } from './items/abstract-item';
-
-// TODO: move to models
-export type DetailsPanelResource = ProjectResource | CollectionResource | ProcessResource;
+import AbstractItem from './items/abstract-item';
+import EmptyItem from './items/empty-item';
+import { DetailsPanelResource } from '../../views-components/details-panel/details-panel';
 
 export default class DetailsPanelFactory {
     static createItem(res: DetailsPanelResource): AbstractItem {
@@ -20,10 +17,10 @@ export default class DetailsPanelFactory {
                 return new ProjectItem(res);
             case ResourceKind.Collection:
                 return new CollectionItem(res);
-            case ResourceKind.Collection:
+            case ResourceKind.Process:
                 return new ProcessItem(res);
             default:
-                return new ProjectItem(res);
+                return new EmptyItem(res);
         }
     }
 }
\ No newline at end of file
diff --git a/src/components/details-panel-factory/items/abstract-item.tsx b/src/components/details-panel-factory/items/abstract-item.tsx
index 5e7d159..fb30e84 100644
--- a/src/components/details-panel-factory/items/abstract-item.tsx
+++ b/src/components/details-panel-factory/items/abstract-item.tsx
@@ -3,10 +3,10 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { DetailsPanelResource } from "./../details-panel-factory";
 import { IconTypes } from '../../icon/icon';
+import { DetailsPanelResource } from '../../../views-components/details-panel/details-panel';
 
-export abstract class AbstractItem {
+export default abstract class AbstractItem {
     protected item: DetailsPanelResource;
 
     constructor(item: DetailsPanelResource) {
diff --git a/src/components/details-panel-factory/items/collection-item.tsx b/src/components/details-panel-factory/items/collection-item.tsx
index d9504e4..448eebb 100644
--- a/src/components/details-panel-factory/items/collection-item.tsx
+++ b/src/components/details-panel-factory/items/collection-item.tsx
@@ -3,14 +3,14 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { DetailsPanelResource } from "./../details-panel-factory";
 import IconBase, { IconTypes } from '../../icon/icon';
 import Attribute from '../../attribute/attribute';
-import { AbstractItem } from './abstract-item';
+import AbstractItem from './abstract-item';
+import { CollectionResource } from '../../../models/collection';
 
 export default class CollectionItem extends AbstractItem {
     
-    constructor(item: DetailsPanelResource) {
+    constructor(item: CollectionResource) {
         super(item);
     }
 
diff --git a/src/components/details-panel-factory/items/empty-item.tsx b/src/components/details-panel-factory/items/empty-item.tsx
new file mode 100644
index 0000000..5d6e3d4
--- /dev/null
+++ b/src/components/details-panel-factory/items/empty-item.tsx
@@ -0,0 +1,25 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { IconTypes } from '../../icon/icon';
+import AbstractItem from './abstract-item';
+import EmptyState from '../../empty-state/empty-state';
+import { EmptyResource } from '../../../models/empty';
+
+export default class EmptyItem extends AbstractItem {
+
+    constructor(item: EmptyResource) {
+        super(item);
+    }
+
+    getIcon(): IconTypes {
+        return IconTypes.FOLDER;
+    }
+
+    buildDetails(): React.ReactElement<any> {
+        return <EmptyState icon={IconTypes.ANNOUNCEMENT}
+            message='Select a file or folder to view its details.' />;
+    }
+}
\ No newline at end of file
diff --git a/src/components/details-panel-factory/items/process-item.tsx b/src/components/details-panel-factory/items/process-item.tsx
index ebbebb9..c8eab0a 100644
--- a/src/components/details-panel-factory/items/process-item.tsx
+++ b/src/components/details-panel-factory/items/process-item.tsx
@@ -3,14 +3,14 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { DetailsPanelResource } from "./../details-panel-factory";
 import IconBase, { IconTypes } from '../../icon/icon';
 import Attribute from '../../attribute/attribute';
-import { AbstractItem } from './abstract-item';
+import AbstractItem from './abstract-item';
+import { ProcessResource } from '../../../models/process';
 
 export default class ProcessItem extends AbstractItem {
     
-    constructor(item: DetailsPanelResource) {
+    constructor(item: ProcessResource) {
         super(item);
     }
 
diff --git a/src/components/details-panel-factory/items/project-item.tsx b/src/components/details-panel-factory/items/project-item.tsx
index 9b96f84..10402ed 100644
--- a/src/components/details-panel-factory/items/project-item.tsx
+++ b/src/components/details-panel-factory/items/project-item.tsx
@@ -3,14 +3,14 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { DetailsPanelResource } from "./../details-panel-factory";
 import IconBase, { IconTypes } from '../../icon/icon';
 import Attribute from '../../attribute/attribute';
-import { AbstractItem } from './abstract-item';
+import AbstractItem from './abstract-item';
+import { ProjectResource } from '../../../models/project';
 
 export default class ProjectItem extends AbstractItem {
 
-    constructor(item: DetailsPanelResource) {
+    constructor(item: ProjectResource) {
         super(item);
     }
 
diff --git a/src/models/empty.ts b/src/models/empty.ts
new file mode 100644
index 0000000..76b42b4
--- /dev/null
+++ b/src/models/empty.ts
@@ -0,0 +1,10 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { ResourceKind } from "./resource";
+
+export interface EmptyResource {
+    name: string;
+    kind: ResourceKind;
+}
\ No newline at end of file
diff --git a/src/views-components/details-panel/details-panel.tsx b/src/views-components/details-panel/details-panel.tsx
index d0bc974..7a087ad 100644
--- a/src/views-components/details-panel/details-panel.tsx
+++ b/src/views-components/details-panel/details-panel.tsx
@@ -13,7 +13,6 @@ import Typography from '@material-ui/core/Typography';
 import Grid from '@material-ui/core/Grid';
 import * as classnames from "classnames";
 import { connect, Dispatch } from 'react-redux';
-import EmptyState from '../../components/empty-state/empty-state';
 import { RootState } from '../../store/store';
 import actions from "../../store/details-panel/details-panel-action";
 import { ProjectResource } from '../../models/project';
@@ -21,13 +20,14 @@ import { CollectionResource } from '../../models/collection';
 import IconBase, { IconTypes } from '../../components/icon/icon';
 import { ProcessResource } from '../../models/process';
 import DetailsPanelFactory from '../../components/details-panel-factory/details-panel-factory';
+import AbstractItem from '../../components/details-panel-factory/items/abstract-item';
+import { ResourceKind } from '../../models/resource';
+import { EmptyResource } from '../../models/empty';
 
 export interface DetailsPanelDataProps {
     onCloseDrawer: () => void;
     isOpened: boolean;
-    icon: IconTypes;
-    title: string;
-    details: React.ReactElement<any>;
+    item: AbstractItem;
 }
 
 type DetailsPanelProps = DetailsPanelDataProps & WithStyles<CssRules>;
@@ -47,16 +47,16 @@ class DetailsPanel extends React.Component<DetailsPanelProps, {}> {
         </Typography>
 
     render() {
-        const { classes, onCloseDrawer, isOpened, icon, title, details } = this.props;
+        const { classes, onCloseDrawer, isOpened, item } = this.props;
         const { tabsValue } = this.state;
         return (
             <Typography component="div" className={classnames([classes.container, { [classes.opened]: isOpened }])}>
                 <Drawer variant="permanent" anchor="right" classes={{ paper: classes.drawerPaper }}>
                     <Typography component="div" className={classes.headerContainer}>
                         <Grid container alignItems='center' justify='space-around'>
-                            <IconBase className={classes.headerIcon} icon={icon} />
+                            <IconBase className={classes.headerIcon} icon={item.getIcon()} />
                             <Typography variant="title">
-                                {title}
+                                {item.getTitle()}
                             </Typography>
                             <IconButton color="inherit" onClick={onCloseDrawer}>
                                 <IconBase icon={IconTypes.CLOSE} />
@@ -69,7 +69,7 @@ class DetailsPanel extends React.Component<DetailsPanelProps, {}> {
                     </Tabs>
                     {tabsValue === 0 && this.renderTabContainer(
                         <Grid container direction="column">
-                            {details}
+                            {item.buildDetails()}
                         </Grid>
                     )}
                     {tabsValue === 1 && this.renderTabContainer(
@@ -113,36 +113,21 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
 });
 
 // TODO: move to models
-type DetailsPanelResource = ProjectResource | CollectionResource | ProcessResource;
-
-const getEmptyState = () => {
-    return <EmptyState icon={ IconTypes.ANNOUNCEMENT } 
-        message='Select a file or folder to view its details.' />;
-};
+export type DetailsPanelResource = ProjectResource | CollectionResource | ProcessResource | EmptyResource;
 
 const getItem = (res: DetailsPanelResource) => {
-    const item = DetailsPanelFactory.createItem(res);
-    return {
-        title: item.getTitle(),
-        icon: item.getIcon(),
-        details: item.buildDetails() 
-    };    
+    return DetailsPanelFactory.createItem(res);
 };
 
 const getDefaultItem = () => {
-    return {
-        title: 'Projects',
-        icon: IconTypes.FOLDER,
-        details: getEmptyState()
-    };
+    return DetailsPanelFactory.createItem({ kind: ResourceKind.UNKNOWN, name: 'Projects'});
 };
 
 const mapStateToProps = ({ detailsPanel }: RootState) => {
     const { isOpened, item } = detailsPanel;
-    const newItem = item ? getItem(item as DetailsPanelResource) : getDefaultItem();
     return {
         isOpened,
-        ...newItem
+        item: item ? getItem(item as DetailsPanelResource) : getDefaultItem()
     };
 };
 

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list