- type: ResourceKind.Project
- }],
- render: item => renderType(item.kind),
- width: "125px"
-}, {
- name: ProjectPanelColumnNames.Owner,
- selected: true,
- render: item => renderOwner(item.owner),
- width: "200px"
-}, {
- name: ProjectPanelColumnNames.FileSize,
- selected: true,
- render: item => renderFileSize(item.fileSize),
- width: "50px"
-}, {
- name: ProjectPanelColumnNames.LastModified,
- selected: true,
- sortDirection: SortDirection.None,
- render: item => renderDate(item.lastModified),
- width: "150px"
-}];
-
-
-export default withStyles(styles)(
- connect((state: RootState) => ({ currentItemId: state.projects.currentItemId }))(
- ProjectPanel));
+ configurable: true,
+ sortDirection: SortDirection.NONE,
+ filters: [],
+ render: uuid => <ResourceLastModifiedDate uuid={uuid} />,
+ width: "150px"
+ }
+];
+
+export const PROJECT_PANEL_ID = "projectPanel";
+
+interface ProjectPanelDataProps {
+ currentItemId: string;
+ resources: ResourcesState;
+}
+
+type ProjectPanelProps = ProjectPanelDataProps & DispatchProp
+ & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
+
+export const ProjectPanel = withStyles(styles)(
+ connect((state: RootState) => ({
+ currentItemId: getProperty(PROJECT_PANEL_CURRENT_UUID)(state.properties),
+ resources: state.resources
+ }))(
+ class extends React.Component<ProjectPanelProps> {
+ render() {
+ const { classes } = this.props;
+ return <div className={classes.root}>
+ <div className={classes.toolbar}>
+ <Button color="primary" onClick={this.handleNewCollectionClick} variant="raised" className={classes.button}>
+ Create a collection
+ </Button>
+ <Button color="primary" variant="raised" className={classes.button}>
+ Run a process
+ </Button>
+ <Button color="primary" onClick={this.handleNewProjectClick} variant="raised" className={classes.button}>
+ New project
+ </Button>
+ </div>
+ <DataExplorer
+ id={PROJECT_PANEL_ID}
+ onRowClick={this.handleRowClick}
+ onRowDoubleClick={this.handleRowDoubleClick}
+ onContextMenu={this.handleContextMenu}
+ defaultIcon={ProjectIcon}
+ defaultMessages={['Your project is empty.', 'Please create a project or create a collection and upload a data.']} />
+ </div>;
+ }
+
+ handleNewProjectClick = () => {
+ this.props.dispatch<any>(openProjectCreator(this.props.currentItemId));
+ }
+
+ handleNewCollectionClick = () => {
+ this.props.dispatch(reset(COLLECTION_CREATE_DIALOG));
+ this.props.dispatch(collectionCreateActions.OPEN_COLLECTION_CREATOR({ ownerUuid: this.props.currentItemId }));
+ }
+
+ handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
+ event.preventDefault();
+ const resource = getResource(resourceUuid)(this.props.resources) as CollectionResource | ProjectResource | undefined;
+ if (resource) {
+ let kind: ContextMenuKind;
+
+ if (resource.kind === ResourceKind.PROJECT) {
+ kind = ContextMenuKind.PROJECT;
+ } else if (resource.kind === ResourceKind.COLLECTION) {
+ kind = ContextMenuKind.COLLECTION_RESOURCE;
+ } else {
+ kind = ContextMenuKind.RESOURCE;
+ }
+ if (kind !== ContextMenuKind.RESOURCE) {
+ this.props.dispatch(
+ contextMenuActions.OPEN_CONTEXT_MENU({
+ position: { x: event.clientX, y: event.clientY },
+ resource: {
+ uuid: resource.uuid,
+ name: resource.name || '',
+ description: resource.description,
+ kind,
+ }
+ })
+ );
+ }
+ }
+ }
+
+ handleRowDoubleClick = (uuid: string) => {
+ this.props.dispatch<any>(navigateToResource(uuid));
+ }
+
+ handleRowClick = (uuid: string) => {
+ this.props.dispatch(loadDetailsPanel(uuid));
+ }
+
+ }
+ )
+);