import { ContextMenuAction } from '../../components/context-menu/context-menu';
import { DispatchProp, connect } from 'react-redux';
import actions from "../../store/data-explorer/data-explorer-action";
-import { setProjectItem, ItemMode } from "../../store/navigation/navigation-action";
import { DataColumns } from '../../components/data-table/data-table';
import { ResourceKind } from "../../models/resource";
import { RouteComponentProps } from 'react-router';
+import { RootState } from '../../store/store';
+import DialogProjectCreate from '../../components/dialog-create/dialog-project-create';
export const PROJECT_PANEL_ID = "projectPanel";
-type ProjectPanelProps = { onItemClick: (item: ProjectPanelItem) => void }
+type ProjectPanelProps = {
+ currentItemId: string,
+ onItemClick: (item: ProjectPanelItem) => void,
+ onItemRouteChange: (itemId: string) => void,
+ handleCreationDialogOpen: () => void;
+ handleCreationDialogClose: () => void;
+ isCreationDialogOpen: boolean;
+}
& DispatchProp
- & WithStyles<CssRules>;
+ & WithStyles<CssRules>
+ & RouteComponentProps<{ id: string }>;
class ProjectPanel extends React.Component<ProjectPanelProps> {
+ state = {
+ open: false,
+ };
+
render() {
return <div>
<div className={this.props.classes.toolbar}>
<Button color="primary" variant="raised" className={this.props.classes.button}>
Run a process
</Button>
- <Button color="primary" variant="raised" className={this.props.classes.button}>
+ <Button color="primary" onClick={this.props.handleCreationDialogOpen} variant="raised" className={this.props.classes.button}>
Create a project
</Button>
+ <DialogProjectCreate open={this.props.isCreationDialogOpen} handleClose={this.props.handleCreationDialogClose}/>
</div>
<DataExplorer
id={PROJECT_PANEL_ID}
this.props.dispatch(actions.SET_COLUMNS({ id: PROJECT_PANEL_ID, columns }));
}
+ componentWillReceiveProps({ match, currentItemId }: ProjectPanelProps) {
+ if (match.params.id !== currentItemId) {
+ this.props.onItemRouteChange(match.params.id);
+ }
+ }
+
toggleColumn = (toggledColumn: DataColumn<ProjectPanelItem>) => {
this.props.dispatch(actions.TOGGLE_COLUMN({ id: PROJECT_PANEL_ID, columnName: toggledColumn.name }));
}
changeRowsPerPage = (rowsPerPage: number) => {
this.props.dispatch(actions.SET_ROWS_PER_PAGE({ id: PROJECT_PANEL_ID, rowsPerPage }));
}
+
}
type CssRules = "toolbar" | "button";
},
button: {
marginLeft: theme.spacing.unit
- }
+ },
});
const renderName = (item: ProjectPanelItem) =>
}
]];
-export default withStyles(styles)(connect()(ProjectPanel));
+export default withStyles(styles)(
+ connect((state: RootState) => ({ currentItemId: state.projects.currentItemId }))(
+ ProjectPanel));