- 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.DESC,
+ filters: createTree(),
+ render: uuid => <ResourceLastModifiedDate uuid={uuid} />
+ }
+];
+
+export const PROJECT_PANEL_ID = "projectPanel";
+
+const DEFAULT_VIEW_MESSAGES = [
+ 'Your project is empty.',
+ 'Please create a project or create a collection and upload a data.',
+];
+
+interface ProjectPanelDataProps {
+ currentItemId: string;
+ resources: ResourcesState;
+ isAdmin: boolean;
+ userUuid: string;
+}
+
+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,
+ userUuid: state.auth.user!.uuid,
+ }))(
+ class extends React.Component<ProjectPanelProps> {
+ render() {
+ const { classes } = this.props;
+ return <div className={classes.root}>
+ <DataExplorer
+ id={PROJECT_PANEL_ID}
+ onRowClick={this.handleRowClick}
+ onRowDoubleClick={this.handleRowDoubleClick}
+ onContextMenu={this.handleContextMenu}
+ contextMenuColumn={true}
+ dataTableDefaultView={
+ <DataTableDefaultView
+ icon={ProjectIcon}
+ messages={DEFAULT_VIEW_MESSAGES} />
+ } />
+ </div>;
+ }
+
+ isCurrentItemChild = (resource: Resource) => {
+ return resource.ownerUuid === this.props.currentItemId;
+ }
+
+ handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
+ const { resources } = this.props;
+ const resource = getResource<GroupContentsResource>(resourceUuid)(resources);
+ // When viewing the contents of a filter group, all contents should be treated as read only.
+ let readonly = false;
+ const project = getResource<GroupResource>(this.props.currentItemId)(resources);
+ if (project && project.groupClass === GroupClass.FILTER) {
+ readonly = true;
+ }
+
+ const menuKind = this.props.dispatch<any>(resourceUuidToContextMenuKind(resourceUuid, readonly));
+ if (menuKind && resource) {
+ this.props.dispatch<any>(openContextMenu(event, {
+ name: resource.name,
+ uuid: resource.uuid,
+ ownerUuid: resource.ownerUuid,
+ isTrashed: ('isTrashed' in resource) ? resource.isTrashed: false,
+ kind: resource.kind,
+ menuKind,
+ description: resource.description,
+ storageClassesDesired: (resource as CollectionResource).storageClassesDesired,
+ }));
+ }
+ this.props.dispatch<any>(loadDetailsPanel(resourceUuid));
+ }
+
+ handleRowDoubleClick = (uuid: string) => {
+ this.props.dispatch<any>(navigateTo(uuid));
+ }
+
+ handleRowClick = (uuid: string) => {
+ this.props.dispatch<any>(loadDetailsPanel(uuid));
+ }
+
+ }
+ )
+);