import { DataTable } from "../data-table/data-table";
import { SearchInput } from "../search-input/search-input";
import { TablePagination } from "@material-ui/core";
+import { ProjectIcon } from '../icon/icon';
+import { DefaultView } from '../default-view/default-view';
configure({ adapter: new Adapter() });
expect(onRowClick).toHaveBeenCalledWith("rowClick");
});
- it("does not render <TablePagination/> if there is no items", () => {
+ it("does not render <DataTable/> if there is no items", () => {
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
items={[]}
/>);
- expect(dataExplorer.find(TablePagination)).toHaveLength(0);
+ expect(dataExplorer.find(DataTable)).toHaveLength(0);
+ expect(dataExplorer.find(DefaultView)).toHaveLength(1);
});
it("communicates with <TablePagination/>", () => {
searchValue: "",
page: 0,
rowsPerPage: 0,
- rowsPerPageOptions: [],
+ rowsPerPageOptions: [0],
onSearch: jest.fn(),
onFiltersChange: jest.fn(),
onSortToggle: jest.fn(),
onColumnToggle: jest.fn(),
onChangePage: jest.fn(),
onChangeRowsPerPage: jest.fn(),
- onContextMenu: jest.fn()
+ onContextMenu: jest.fn(),
+ defaultIcon: ProjectIcon,
+ defaultMessages: ['testing'],
});
import { DataTableFilterItem } from '../data-table-filters/data-table-filters';
import { SearchInput } from '../search-input/search-input';
import { ArvadosTheme } from "~/common/custom-theme";
+import { DefaultView } from '../default-view/default-view';
+import { IconType } from '../icon/icon';
-type CssRules = "searchBox" | "toolbar";
+type CssRules = 'searchBox' | "toolbar" | 'defaultRoot' | 'defaultMessage' | 'defaultIcon';
const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
searchBox: {
},
toolbar: {
paddingTop: theme.spacing.unit * 2
+ },
+ defaultRoot: {
+ position: 'absolute',
+ width: '80%',
+ left: '50%',
+ top: '50%',
+ transform: 'translate(-50%, -50%)'
+ },
+ defaultMessage: {
+ fontSize: '1.75rem',
+ },
+ defaultIcon: {
+ fontSize: '6rem'
}
});
rowsPerPage: number;
rowsPerPageOptions: number[];
page: number;
+ defaultIcon: IconType;
+ defaultMessages: string[];
+}
+
+interface DataExplorerActionProps<T> {
onSearch: (value: string) => void;
onRowClick: (item: T) => void;
onRowDoubleClick: (item: T) => void;
extractKey?: (item: T) => React.Key;
}
-type DataExplorerProps<T> = DataExplorerDataProps<T> & WithStyles<CssRules>;
+type DataExplorerProps<T> = DataExplorerDataProps<T> & DataExplorerActionProps<T> & WithStyles<CssRules>;
export const DataExplorer = withStyles(styles)(
class DataExplorerGeneric<T> extends React.Component<DataExplorerProps<T>> {
render() {
- return <Paper>
- <Toolbar className={this.props.classes.toolbar}>
- <Grid container justify="space-between" wrap="nowrap" alignItems="center">
- <div className={this.props.classes.searchBox}>
- <SearchInput
- value={this.props.searchValue}
- onSearch={this.props.onSearch}/>
- </div>
- <ColumnSelector
- columns={this.props.columns}
- onColumnToggle={this.props.onColumnToggle}/>
- </Grid>
- </Toolbar>
- <DataTable
- columns={[...this.props.columns, this.contextMenuColumn]}
- items={this.props.items}
- onRowClick={(_, item: T) => this.props.onRowClick(item)}
- onContextMenu={this.props.onContextMenu}
- onRowDoubleClick={(_, item: T) => this.props.onRowDoubleClick(item)}
- onFiltersChange={this.props.onFiltersChange}
- onSortToggle={this.props.onSortToggle}
- extractKey={this.props.extractKey}/>
- <Toolbar>
- {this.props.items.length > 0 &&
- <Grid container justify="flex-end">
- <TablePagination
- count={this.props.itemsAvailable}
- rowsPerPage={this.props.rowsPerPage}
- rowsPerPageOptions={this.props.rowsPerPageOptions}
- page={this.props.page}
- onChangePage={this.changePage}
- onChangeRowsPerPage={this.changeRowsPerPage}
- component="div"
- />
- </Grid>}
- </Toolbar>
- </Paper>;
+ const {
+ columns, onContextMenu, onFiltersChange, onSortToggle, extractKey,
+ rowsPerPage, rowsPerPageOptions, onColumnToggle, searchValue, onSearch,
+ items, itemsAvailable, onRowClick, onRowDoubleClick, defaultIcon, defaultMessages, classes
+ } = this.props;
+ return <div>
+ { items.length > 0 ? (
+ <Paper>
+ <Toolbar className={classes.toolbar}>
+ <Grid container justify="space-between" wrap="nowrap" alignItems="center">
+ <div className={classes.searchBox}>
+ <SearchInput
+ value={searchValue}
+ onSearch={onSearch}/>
+ </div>
+ <ColumnSelector
+ columns={columns}
+ onColumnToggle={onColumnToggle}/>
+ </Grid>
+ </Toolbar>
+ <DataTable
+ columns={[...columns, this.contextMenuColumn]}
+ items={items}
+ onRowClick={(_, item: T) => onRowClick(item)}
+ onContextMenu={onContextMenu}
+ onRowDoubleClick={(_, item: T) => onRowDoubleClick(item)}
+ onFiltersChange={onFiltersChange}
+ onSortToggle={onSortToggle}
+ extractKey={extractKey}/>
+ <Toolbar>
+ <Grid container justify="flex-end">
+ <TablePagination
+ count={itemsAvailable}
+ rowsPerPage={rowsPerPage}
+ rowsPerPageOptions={rowsPerPageOptions}
+ page={this.props.page}
+ onChangePage={this.changePage}
+ onChangeRowsPerPage={this.changeRowsPerPage}
+ component="div" />
+ </Grid>
+ </Toolbar>
+ </Paper>
+ ) : (
+ <DefaultView
+ classRoot={classes.defaultRoot}
+ icon={defaultIcon}
+ classIcon={classes.defaultIcon}
+ messages={defaultMessages}
+ classMessage={classes.defaultMessage} />
+ )}
+ </div>;
}
changePage = (event: React.MouseEvent<HTMLButtonElement>, page: number) => {
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
+import { ArvadosTheme } from '../../common/custom-theme';
+import { Typography } from '@material-ui/core';
+import { IconType } from '../icon/icon';
+import * as classnames from "classnames";
+
+type CssRules = 'root' | 'icon' | 'message';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+ root: {
+ textAlign: 'center'
+ },
+ icon: {
+ color: theme.palette.grey["500"],
+ fontSize: '4.5rem'
+ },
+ message: {
+ color: theme.palette.grey["500"]
+ }
+});
+
+export interface DefaultViewDataProps {
+ classRoot?: string;
+ messages: string[];
+ classMessage?: string;
+ icon: IconType;
+ classIcon?: string;
+}
+
+type DefaultViewProps = DefaultViewDataProps & WithStyles<CssRules>;
+
+export const DefaultView = withStyles(styles)(
+ ({ classes, classRoot, messages, classMessage, icon: Icon, classIcon }: DefaultViewProps) =>
+ <Typography className={classnames([classes.root, classRoot])} component="div">
+ <Icon className={classnames([classes.icon, classIcon])} />
+ {messages.map((msg: string, index: number) => {
+ return <Typography key={index} variant="body1"
+ className={classnames([classes.message, classMessage])}>{msg}</Typography>;
+ })}
+ </Typography>
+);
\ No newline at end of file
type DetailsAttributeProps = DetailsAttributeDataProps & WithStyles<CssRules>;
-export const DetailsAttribute = withStyles(styles)(({ label, link, value, children, classes, classLabel, classValue }: DetailsAttributeProps) =>
- <Typography component="div" className={classes.attribute}>
- <Typography component="span" className={classnames([classes.label, classLabel])}>{label}</Typography>
- { link
- ? <a href={link} className={classes.link} target='_blank'>{value}</a>
- : <Typography component="span" className={classnames([classes.value, classValue])}>
- {value}
- {children}
- </Typography> }
- </Typography>
+export const DetailsAttribute = withStyles(styles)(
+ ({ label, link, value, children, classes, classLabel, classValue }: DetailsAttributeProps) =>
+ <Typography component="div" className={classes.attribute}>
+ <Typography component="span" className={classnames([classes.label, classLabel])}>{label}</Typography>
+ { link
+ ? <a href={link} className={classes.link} target='_blank'>{value}</a>
+ : <Typography component="span" className={classnames([classes.value, classValue])}>
+ {value}
+ {children}
+ </Typography> }
+ </Typography>
);
open?: boolean;
margin?: boolean;
openAble?: boolean;
- activeAction?: (dispatch: Dispatch) => void;
+ activeAction?: (dispatch: Dispatch, uuid?: string) => void;
}
interface SidePanelDataProps {
}
export const setProjectItem = (itemId: string, itemMode: ItemMode) =>
- (dispatch: Dispatch, getState: () => RootState) => {
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
const { projects, router } = getState();
const treeItem = findTreeItem(projects.items, itemId);
if (treeItem) {
-
const resourceUrl = getResourceUrl(treeItem.data);
if (itemMode === ItemMode.ACTIVE || itemMode === ItemMode.BOTH) {
dispatch(projectPanelActions.RESET_PAGINATION());
dispatch(projectPanelActions.REQUEST_ITEMS());
}));
+ } else {
+ const uuid = services.authService.getUuid();
+ if (itemId === uuid) {
+ dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(uuid));
+ dispatch(projectPanelActions.RESET_PAGINATION());
+ dispatch(projectPanelActions.REQUEST_ITEMS());
+ }
}
};
value: 'payload'
});
-export const getProjectList = (parentUuid: string = '') => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- dispatch(projectActions.PROJECTS_REQUEST(parentUuid));
- return services.projectService.list({
- filters: FilterBuilder
- .create()
- .addEqual("ownerUuid", parentUuid)
- }).then(({ items: projects }) => {
- dispatch(projectActions.PROJECTS_SUCCESS({ projects, parentItemId: parentUuid }));
- dispatch<any>(checkPresenceInFavorites(projects.map(project => project.uuid)));
- return projects;
- });
-};
+export const getProjectList = (parentUuid: string = '') =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ dispatch(projectActions.PROJECTS_REQUEST(parentUuid));
+ return services.projectService.list({
+ filters: FilterBuilder
+ .create()
+ .addEqual("ownerUuid", parentUuid)
+ }).then(({ items: projects }) => {
+ dispatch(projectActions.PROJECTS_SUCCESS({ projects, parentItemId: parentUuid }));
+ dispatch<any>(checkPresenceInFavorites(projects.map(project => project.uuid)));
+ return projects;
+ });
+ };
export const createProject = (project: Partial<ProjectResource>) =>
(dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
import { Dispatch } from "redux";
import { push } from "react-router-redux";
import { favoritePanelActions } from "../favorite-panel/favorite-panel-action";
+import { projectPanelActions } from "../project-panel/project-panel-action";
+import { projectActions } from "../project/project-action";
+import { getProjectUrl } from "../../models/project";
export type SidePanelState = SidePanelItem[];
open: false,
active: false,
margin: true,
- openAble: true
+ openAble: true,
+ activeAction: (dispatch: Dispatch, uuid: string) => {
+ dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(uuid));
+ dispatch(push(getProjectUrl(uuid)));
+ dispatch(projectPanelActions.RESET_PAGINATION());
+ dispatch(projectPanelActions.REQUEST_ITEMS());
+ }
},
{
id: SidePanelIdentifiers.SHARED_WITH_ME,
import { ContextMenuActionSet } from "../context-menu-action-set";
import { projectActions } from "~/store/project/project-action";
import { NewProjectIcon } from "~/components/icon/icon";
+import { collectionCreateActions } from "../../../store/collections/creator/collection-creator-action";
import { PROJECT_CREATE_DIALOG } from "../../dialog-create/dialog-project-create";
+import { COLLECTION_CREATE_DIALOG } from "../../dialog-create/dialog-collection-create";
+import { NewProjectIcon, CollectionIcon } from "../../../components/icon/icon";
-export const rootProjectActionSet: ContextMenuActionSet = [[{
- icon: NewProjectIcon,
- name: "New project",
- execute: (dispatch, resource) => {
- dispatch(reset(PROJECT_CREATE_DIALOG));
- dispatch(projectActions.OPEN_PROJECT_CREATOR({ ownerUuid: resource.uuid }));
+export const rootProjectActionSet: ContextMenuActionSet = [[
+ {
+ icon: NewProjectIcon,
+ name: "New project",
+ execute: (dispatch, resource) => {
+ dispatch(reset(PROJECT_CREATE_DIALOG));
+ dispatch(projectActions.OPEN_PROJECT_CREATOR({ ownerUuid: resource.uuid }));
+ }
+ },
+ {
+ icon: CollectionIcon,
+ name: "New Collection",
+ execute: (dispatch, resource) => {
+ dispatch(reset(COLLECTION_CREATE_DIALOG));
+ dispatch(collectionCreateActions.OPEN_COLLECTION_CREATOR({ ownerUuid: resource.uuid }));
+ }
}
-}]];
+]];
// SPDX-License-Identifier: AGPL-3.0
import * as React from 'react';
-import { DefaultIcon, IconType, ProjectsIcon } from '~/components/icon/icon';
+import { DefaultIcon, ProjectsIcon } from '~/components/icon/icon';
import { EmptyResource } from '~/models/empty';
import { DetailsData } from "./details-data";
-import Typography from "@material-ui/core/Typography";
-import { StyleRulesCallback, WithStyles, withStyles } from "@material-ui/core/styles";
-import { ArvadosTheme } from "~/common/custom-theme";
-import Icon from "@material-ui/core/Icon/Icon";
-
-type CssRules = 'container' | 'icon';
-
-const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
- container: {
- textAlign: 'center'
- },
- icon: {
- color: theme.palette.grey["500"],
- fontSize: '72px'
- }
-});
-
-export interface EmptyStateDataProps {
- message: string;
- icon: IconType;
- details?: string;
- children?: React.ReactNode;
-}
-
-type EmptyStateProps = EmptyStateDataProps & WithStyles<CssRules>;
-
-const EmptyState = withStyles(styles)(
- ({ classes, details, message, children, icon: Icon }: EmptyStateProps) =>
- <Typography className={classes.container} component="div">
- <Icon className={classes.icon}/>
- <Typography variant="body1" gutterBottom>{message}</Typography>
- {details && <Typography gutterBottom>{details}</Typography>}
- {children && <Typography gutterBottom>{children}</Typography>}
- </Typography>
-);
+import { DefaultView } from '~/components/default-view/default-view';
export class EmptyDetails extends DetailsData<EmptyResource> {
getIcon(className?: string) {
}
getDetails() {
- return <EmptyState icon={DefaultIcon} message='Select a file or folder to view its details.'/>;
+ return <DefaultView icon={DefaultIcon} messages={['Select a file or folder to view its details.']} />;
}
}
import { ArvadosTheme } from '~/common/custom-theme';
import { renderName, renderStatus, renderType, renderOwner, renderFileSize, renderDate } from '~/views-components/data-explorer/renderers';
import { FAVORITE_PANEL_ID } from "~/store/favorite-panel/favorite-panel-action";
+import { FavoriteIcon } from '~/components/icon/icon';
type CssRules = "toolbar" | "button";
onRowClick={this.props.onItemClick}
onRowDoubleClick={this.props.onItemDoubleClick}
onContextMenu={this.props.onContextMenu}
- extractKey={(item: FavoritePanelItem) => item.uuid} />
+ extractKey={(item: FavoritePanelItem) => item.uuid}
+ defaultIcon={FavoriteIcon}
+ defaultMessages={['Your favorites list is empty.']}/>
;
}
import { ArvadosTheme } from '~/common/custom-theme';
import { renderName, renderStatus, renderType, renderOwner, renderFileSize, renderDate } from '~/views-components/data-explorer/renderers';
import { restoreBranch } from '~/store/navigation/navigation-action';
+import { ProjectIcon } from '~/components/icon/icon';
-type CssRules = "toolbar" | "button";
+type CssRules = 'root' | "toolbar" | "button";
const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+ root: {
+ position: 'relative',
+ width: '100%',
+ height: '100%'
+ },
toolbar: {
paddingBottom: theme.spacing.unit * 3,
textAlign: "right"
class extends React.Component<ProjectPanelProps> {
render() {
const { classes } = this.props;
- return <div>
+ return <div className={classes.root}>
<div className={classes.toolbar}>
<Button color="primary" onClick={this.handleNewCollectionClick} variant="raised" className={classes.button}>
Create a collection
onRowClick={this.props.onItemClick}
onRowDoubleClick={this.props.onItemDoubleClick}
onContextMenu={this.props.onContextMenu}
- extractKey={(item: ProjectPanelItem) => item.uuid} />
+ extractKey={(item: ProjectPanelItem) => item.uuid}
+ defaultIcon={ProjectIcon}
+ defaultMessages={['Your project is empty.', 'Please create a project or create a collection and upload a data.']} />
</div>;
}
it('renders without crashing', () => {
const div = document.createElement('div');
const services = createServices("/arvados/v1");
+ services.authService.getUuid = jest.fn().mockReturnValueOnce('test');
const store = configureStore(createBrowserHistory(), services);
ReactDOM.render(
<MuiThemeProvider theme={CustomTheme}>
import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import { connect, DispatchProp } from "react-redux";
-import { Route, RouteComponentProps, Switch } from "react-router";
+import { Route, RouteComponentProps, Switch, Redirect } from "react-router";
import { login, logout } from "~/store/auth/auth-action";
import { User } from "~/models/user";
import { RootState } from "~/store/store";
content: {
padding: `${theme.spacing.unit}px ${theme.spacing.unit * 3}px`,
overflowY: "auto",
- flexGrow: 1
+ flexGrow: 1,
+ position: 'relative'
},
toolbar: theme.mixins.toolbar
});
<main className={classes.contentWrapper}>
<div className={classes.content}>
<Switch>
+ <Route path='/' exact render={() => <Redirect to={`/projects/${this.props.authService.getUuid()}`} />} />
<Route path="/projects/:id" render={this.renderProjectPanel} />
<Route path="/favorites" render={this.renderFavoritePanel} />
<Route path="/collections/:id" render={this.renderCollectionPanel} />
toggleSidePanelActive = (itemId: string) => {
this.props.dispatch(sidePanelActions.TOGGLE_SIDE_PANEL_ITEM_ACTIVE(itemId));
this.props.dispatch(projectActions.RESET_PROJECT_TREE_ACTIVITY(itemId));
+
const panelItem = this.props.sidePanelItems.find(it => it.id === itemId);
if (panelItem && panelItem.activeAction) {
- panelItem.activeAction(this.props.dispatch);
+ panelItem.activeAction(this.props.dispatch, this.props.authService.getUuid());
}
}