+interface ProjectPanelDataProps {
+ currentItemId: string;
+ isSidePanelOpen: boolean;
+}
+
+interface ProjectPanelActionProps {
+ onItemClick: (item: ProjectPanelItem) => void;
+ onContextMenu: (event: React.MouseEvent<HTMLElement>, item: ProjectPanelItem) => void;
+ onProjectCreationDialogOpen: (ownerUuid: string) => void;
+ onCollectionCreationDialogOpen: (ownerUuid: string) => void;
+ onItemDoubleClick: (item: ProjectPanelItem) => void;
+ onItemRouteChange: (itemId: string) => void;
+}
+
+type ProjectPanelProps = ProjectPanelDataProps & ProjectPanelActionProps & DispatchProp
+ & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
+
+export const ProjectPanel = withStyles(styles)(
+ connect((state: RootState) => ({ currentItemId: state.projects.currentItemId, isSidePanelOpen: state.sidePanel[0].open }))(
+ class extends React.Component<ProjectPanelProps> {
+ render() {
+ const { classes } = this.props;
+ return <div>
+ <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}
+ columns={columns}
+ onRowClick={this.props.onItemClick}
+ onRowDoubleClick={this.props.onItemDoubleClick}
+ onContextMenu={this.props.onContextMenu}
+ extractKey={(item: ProjectPanelItem) => item.uuid} />
+ </div>;
+ }
+
+ handleNewProjectClick = () => {
+ this.props.onProjectCreationDialogOpen(this.props.currentItemId);
+ }
+
+ handleNewCollectionClick = () => {
+ this.props.onCollectionCreationDialogOpen(this.props.currentItemId);
+ }
+
+ componentWillReceiveProps({ match, currentItemId, onItemRouteChange }: ProjectPanelProps) {
+ if (match.params.id !== currentItemId) {
+ onItemRouteChange(match.params.id);
+ }
+ }
+
+ componentDidMount() {
+ if (this.props.match.params.id && !this.props.isSidePanelOpen) {
+ this.props.dispatch<any>(restoreBranch(this.props.match.params.id));
+ }
+ }
+ }
+ )
+);