rowsPerPage: number;
rowsPerPageOptions: number[];
page: number;
- defaultIcon: IconType;
- defaultMessages: string[];
contextMenuColumn: boolean;
noItemsPlaceholder?: React.ReactNode;
}
const {
columns, onContextMenu, onFiltersChange, onSortToggle, extractKey,
rowsPerPage, rowsPerPageOptions, onColumnToggle, searchValue, onSearch,
- items, itemsAvailable, onRowClick, onRowDoubleClick, defaultIcon, defaultMessages, classes,
+ items, itemsAvailable, onRowClick, onRowDoubleClick, classes,
noItemsPlaceholder
} = this.props;
return <Paper>
import { loadDetailsPanel } from '~/store/details-panel/details-panel-action';
import { navigateTo } from '~/store/navigation/navigation-action';
import { ContainerRequestState } from "~/models/container-request";
+import { DefaultView } from '~/components/default-view/default-view';
+import { FavoritesState } from '../../store/favorites/favorites-reducer';
+import { RootState } from '~/store/store';
type CssRules = "toolbar" | "button";
];
interface FavoritePanelDataProps {
- currentItemId: string;
+ favorites: FavoritesState;
}
interface FavoritePanelActionProps {
onDialogOpen: (ownerUuid: string) => void;
onItemDoubleClick: (item: string) => void;
}
+const mapStateToProps = ({ favorites }: RootState): FavoritePanelDataProps => ({
+ favorites
+});
const mapDispatchToProps = (dispatch: Dispatch): FavoritePanelActionProps => ({
onContextMenu: (event, resourceUuid) => {
& WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
export const FavoritePanel = withStyles(styles)(
- connect(undefined, mapDispatchToProps)(
+ connect(mapStateToProps, mapDispatchToProps)(
class extends React.Component<FavoritePanelProps> {
render() {
- return <DataExplorer
- id={FAVORITE_PANEL_ID}
- onRowClick={this.props.onItemClick}
- onRowDoubleClick={this.props.onItemDoubleClick}
- onContextMenu={this.props.onContextMenu}
- defaultIcon={FavoriteIcon}
- defaultMessages={['Your favorites list is empty.']}
- contextMenuColumn={true}/>;
+ return this.hasAnyFavorites()
+ ? <DataExplorer
+ id={FAVORITE_PANEL_ID}
+ onRowClick={this.props.onItemClick}
+ onRowDoubleClick={this.props.onItemDoubleClick}
+ onContextMenu={this.props.onContextMenu}
+ contextMenuColumn={true} />
+ : <DefaultView
+ icon={FavoriteIcon}
+ messages={['Your favorites list is empty.']} />;
+ }
+
+ hasAnyFavorites = () => {
+ return Object
+ .keys(this.props.favorites)
+ .find(uuid => this.props.favorites[uuid]);
}
}
)
import { DataTableFilterItem } from '~/components/data-table-filters/data-table-filters';
import { ContainerRequestState } from '~/models/container-request';
import { SortDirection } from '~/components/data-table/data-column';
-import { ResourceKind } from '~/models/resource';
+import { ResourceKind, Resource } from '~/models/resource';
import { resourceLabel } from '~/common/labels';
import { ArvadosTheme } from '~/common/custom-theme';
import { ResourceFileSize, ResourceLastModifiedDate, ProcessStatus, ResourceType, ResourceOwner } from '~/views-components/data-explorer/renderers';
import { PROJECT_PANEL_CURRENT_UUID } from '~/store/project-panel/project-panel-action';
import { openCollectionCreateDialog } from '../../store/collections/collection-create-actions';
import { openProjectCreateDialog } from '~/store/projects/project-create-actions';
+import { filterResources } from '../../store/resources/resources';
+import { DefaultView } from '~/components/default-view/default-view';
type CssRules = 'root' | "toolbar" | "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}/>
+ {this.hasAnyItems()
+ ? <DataExplorer
+ id={PROJECT_PANEL_ID}
+ onRowClick={this.handleRowClick}
+ onRowDoubleClick={this.handleRowDoubleClick}
+ onContextMenu={this.handleContextMenu}
+ contextMenuColumn={true} />
+ : <DefaultView
+ icon={ProjectIcon}
+ messages={['Your project is empty.', 'Please create a project or create a collection and upload a data.']} />
+ }
+
</div>;
}
+ hasAnyItems = () => {
+ const resources = filterResources(this.isCurrentItemChild)(this.props.resources);
+ return resources.length > 0;
+ }
+
+ isCurrentItemChild = (resource: Resource) => {
+ return resource.ownerUuid === this.props.currentItemId;
+ }
+
handleNewProjectClick = () => {
this.props.dispatch<any>(openProjectCreateDialog(this.props.currentItemId));
}
import { toggleCollectionTrashed, toggleProjectTrashed, toggleTrashed } from "~/store/trash/trash-actions";
import { ContextMenuKind } from "~/views-components/context-menu/context-menu";
import { Dispatch } from "redux";
+import { DefaultView } from '~/components/default-view/default-view';
type CssRules = "toolbar" | "button";
));
}
}}>
- <RestoreFromTrashIcon/>
+ <RestoreFromTrashIcon />
</IconButton>
);
configurable: true,
sortDirection: SortDirection.ASC,
filters: [],
- render: uuid => <ResourceName uuid={uuid}/>,
+ render: uuid => <ResourceName uuid={uuid} />,
width: "450px"
},
{
type: ResourceKind.PROJECT
}
],
- render: uuid => <ResourceType uuid={uuid}/>,
+ render: uuid => <ResourceType uuid={uuid} />,
width: "125px"
},
{
configurable: false,
sortDirection: SortDirection.NONE,
filters: [],
- render: uuid => <ResourceRestore uuid={uuid}/>,
+ render: uuid => <ResourceRestore uuid={uuid} />,
width: "50px"
}
];
}))(
class extends React.Component<TrashPanelProps> {
render() {
- return <DataExplorer
- id={TRASH_PANEL_ID}
- onRowClick={this.handleRowClick}
- onRowDoubleClick={this.handleRowDoubleClick}
- onContextMenu={this.handleContextMenu}
- defaultIcon={TrashIcon}
- defaultMessages={['Your trash list is empty.']}
- contextMenuColumn={false}/>
- ;
+ return this.hasAnyTrashedResources()
+ ? <DataExplorer
+ id={TRASH_PANEL_ID}
+ onRowClick={this.handleRowClick}
+ onRowDoubleClick={this.handleRowDoubleClick}
+ onContextMenu={this.handleContextMenu}
+ contextMenuColumn={false} />
+ : <DefaultView
+ icon={TrashIcon}
+ messages={['Your trash list is empty.']} />;
+ }
+
+ hasAnyTrashedResources = () => {
+ // TODO: implement check if there is anything in the trash,
+ // without taking pagination into the account
+ return true;
}
handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {