[ARVADOS-WORKBENCH2] updated: 1.1.4-74-ge25469d
Git user
git at public.curoverse.com
Fri Jun 15 04:25:52 EDT 2018
Summary of changes:
src/components/data-explorer/data-explorer.tsx | 1 -
src/components/data-table/data-table.test.tsx | 107 +++++++++++++++++++++++++
src/components/data-table/data-table.tsx | 5 +-
3 files changed, 109 insertions(+), 4 deletions(-)
create mode 100644 src/components/data-table/data-table.test.tsx
via e25469d58a038391fa16184da4f7078a0eae805a (commit)
via 9f2313889301e05c721d58a8a9c3a667da990495 (commit)
from 7b5dbd45ca461a8c58cfb148980b1ffe3f6d801e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit e25469d58a038391fa16184da4f7078a0eae805a
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Fri Jun 15 10:25:40 2018 +0200
Fix data table usage in data explorer
Feature #13601
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/components/data-explorer/data-explorer.tsx b/src/components/data-explorer/data-explorer.tsx
index 7ea0856..f2fe3be 100644
--- a/src/components/data-explorer/data-explorer.tsx
+++ b/src/components/data-explorer/data-explorer.tsx
@@ -156,7 +156,6 @@ class DataExplorer extends React.Component<DataExplorerProps, DataExplorerState>
<DataTable
columns={this.state.columns}
items={this.props.items}
- onColumnToggle={this.toggleColumn}
/>
);
}
commit 9f2313889301e05c721d58a8a9c3a667da990495
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Fri Jun 15 10:23:47 2018 +0200
Create data table tests
Feature #13601
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/components/data-table/data-table.test.tsx b/src/components/data-table/data-table.test.tsx
new file mode 100644
index 0000000..853aaa9
--- /dev/null
+++ b/src/components/data-table/data-table.test.tsx
@@ -0,0 +1,107 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { mount, configure } from "enzyme";
+import * as Adapter from "enzyme-adapter-react-16";
+import DataTable from "./data-table";
+import { Column } from "./column";
+import { TableHead, TableCell, Typography, TableBody, Button } from "@material-ui/core";
+
+configure({ adapter: new Adapter() });
+
+describe("<DataTable />", () => {
+ it("shows only selected columns", () => {
+ const columns: Array<Column<string>> = [
+ {
+ header: "Column 1",
+ render: () => <span />,
+ selected: true
+ },
+ {
+ header: "Column 2",
+ render: () => <span />,
+ selected: true
+ },
+ {
+ header: "Column 3",
+ render: () => <span />,
+ selected: false
+ }
+ ];
+ const dataTable = mount(<DataTable columns={columns} items={["item 1"]}/>);
+ expect(dataTable.find(TableHead).find(TableCell)).toHaveLength(2);
+ });
+
+ it("renders header label", () => {
+ const columns: Array<Column<string>> = [
+ {
+ header: "Column 1",
+ render: () => <span />,
+ selected: true
+ }
+ ];
+ const dataTable = mount(<DataTable columns={columns} items={["item 1"]}/>);
+ expect(dataTable.find(TableHead).find(TableCell).text()).toBe("Column 1");
+ });
+
+ it("uses renderHeader instead of header prop", () => {
+ const columns: Array<Column<string>> = [
+ {
+ header: "Column 1",
+ renderHeader: () => <span>Column Header</span>,
+ render: () => <span />,
+ selected: true
+ }
+ ];
+ const dataTable = mount(<DataTable columns={columns} items={["item 1"]}/>);
+ expect(dataTable.find(TableHead).find(TableCell).text()).toBe("Column Header");
+ });
+
+ it("passes column key prop to corresponding cells", () => {
+ const columns: Array<Column<string>> = [
+ {
+ header: "Column 1",
+ key: "column-1-key",
+ render: () => <span />,
+ selected: true
+ }
+ ];
+ const dataTable = mount(<DataTable columns={columns} items={["item 1"]}/>);
+ expect(dataTable.find(TableHead).find(TableCell).key()).toBe("column-1-key");
+ expect(dataTable.find(TableBody).find(TableCell).key()).toBe("column-1-key");
+ });
+
+ it("shows information that items array is empty", () => {
+ const columns: Array<Column<string>> = [
+ {
+ header: "Column 1",
+ render: () => <span />,
+ selected: true
+ }
+ ];
+ const dataTable = mount(<DataTable columns={columns} items={[]}/>);
+ expect(dataTable.find(Typography).text()).toBe("No items");
+ });
+
+ it("renders items", () => {
+ const columns: Array<Column<string>> = [
+ {
+ header: "Column 1",
+ render: (item) => <Typography>{item}</Typography>,
+ selected: true
+ },
+ {
+ header: "Column 2",
+ render: (item) => <Button>{item}</Button>,
+ selected: true
+ }
+ ];
+ const dataTable = mount(<DataTable columns={columns} items={["item 1"]}/>);
+ expect(dataTable.find(TableBody).find(Typography).text()).toBe("item 1");
+ expect(dataTable.find(TableBody).find(Button).text()).toBe("item 1");
+ });
+
+
+});
\ No newline at end of file
diff --git a/src/components/data-table/data-table.tsx b/src/components/data-table/data-table.tsx
index d0c6a67..382ce1e 100644
--- a/src/components/data-table/data-table.tsx
+++ b/src/components/data-table/data-table.tsx
@@ -10,13 +10,12 @@ import ColumnsConfigurator from "./columns-configurator/columns-configurator";
export interface DataTableProps<T> {
items: T[];
columns: Array<Column<T>>;
- onColumnToggle: (column: Column<T>) => void;
onItemClick?: (item: T) => void;
}
class DataTable<T> extends React.Component<DataTableProps<T> & WithStyles<CssRules>> {
render() {
- const { items, columns, classes, onItemClick, onColumnToggle } = this.props;
+ const { items, columns, classes, onItemClick } = this.props;
return (
<div className={classes.tableContainer}>
{
@@ -39,7 +38,7 @@ class DataTable<T> extends React.Component<DataTableProps<T> & WithStyles<CssRul
<TableRow key={index} hover onClick={() => onItemClick && onItemClick(item)}>
{
columns.filter(column => column.selected).map((column, index) => (
- <TableCell key={index}>
+ <TableCell key={column.key || index}>
{column.render(item)}
</TableCell>
))
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list