- 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.']}
+ contextMenuColumn={true}/>
+ </div>;
+ }
+
+ handleNewProjectClick = () => {
+ this.props.dispatch<any>(openProjectCreateDialog(this.props.currentItemId));
+ }
+
+ handleNewCollectionClick = () => {
+ this.props.dispatch<any>(openCollectionCreateDialog(this.props.currentItemId));
+ }
+
+ handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
+ const menuKind = resourceKindToContextMenuKind(resourceUuid);
+ const resource = getResource<ProjectResource>(resourceUuid)(this.props.resources);
+ if (menuKind && resource) {
+ this.props.dispatch<any>(openContextMenu(event, {
+ name: resource.name,
+ uuid: resource.uuid,
+ ownerUuid: resource.ownerUuid,
+ isTrashed: resource.isTrashed,
+ kind: resource.kind,
+ menuKind
+ }));
+ }
+ }
+
+ handleRowDoubleClick = (uuid: string) => {
+ this.props.dispatch<any>(navigateTo(uuid));
+ }
+
+ handleRowClick = (uuid: string) => {
+ this.props.dispatch(loadDetailsPanel(uuid));
+ }
+
+ }
+ )
+);