import { TablePagination } from "@material-ui/core";
import { ProjectIcon } from '../icon/icon';
import { DefaultView } from '../default-view/default-view';
+import { SortDirection } from '../data-table/data-column';
configure({ adapter: new Adapter() });
it("communicates with <SearchInput/>", () => {
const onSearch = jest.fn();
+ const onSetColumns = jest.fn();
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
items={[{ name: "item 1" }]}
searchValue="search value"
- onSearch={onSearch} />);
+ onSearch={onSearch}
+ onSetColumns={onSetColumns} />);
expect(dataExplorer.find(SearchInput).prop("value")).toEqual("search value");
dataExplorer.find(SearchInput).prop("onSearch")("new value");
expect(onSearch).toHaveBeenCalledWith("new value");
it("communicates with <ColumnSelector/>", () => {
const onColumnToggle = jest.fn();
- const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true }];
+ const onSetColumns = jest.fn();
+ const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true, sortDirection: SortDirection.ASC, filters: [] }];
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
columns={columns}
onColumnToggle={onColumnToggle}
- items={[{ name: "item 1" }]} />);
+ items={[{ name: "item 1" }]}
+ onSetColumns={onSetColumns} />);
expect(dataExplorer.find(ColumnSelector).prop("columns")).toBe(columns);
dataExplorer.find(ColumnSelector).prop("onColumnToggle")("columns");
expect(onColumnToggle).toHaveBeenCalledWith("columns");
const onFiltersChange = jest.fn();
const onSortToggle = jest.fn();
const onRowClick = jest.fn();
- const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true }];
+ const onSetColumns = jest.fn();
+ const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true, sortDirection: SortDirection.ASC, filters: [] }];
const items = [{ name: "item 1" }];
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
items={items}
onFiltersChange={onFiltersChange}
onSortToggle={onSortToggle}
- onRowClick={onRowClick} />);
+ onRowClick={onRowClick}
+ onSetColumns={onSetColumns} />);
expect(dataExplorer.find(DataTable).prop("columns").slice(0, -1)).toEqual(columns);
expect(dataExplorer.find(DataTable).prop("items")).toBe(items);
dataExplorer.find(DataTable).prop("onRowClick")("event", "rowClick");
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
items={[]}
- />);
+ onSetColumns={jest.fn()} />);
expect(dataExplorer.find(DataTable)).toHaveLength(0);
expect(dataExplorer.find(DefaultView)).toHaveLength(1);
});
it("communicates with <TablePagination/>", () => {
const onChangePage = jest.fn();
const onChangeRowsPerPage = jest.fn();
+ const onSetColumns = jest.fn();
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
items={[{ name: "item 1" }]}
rowsPerPage={50}
onChangePage={onChangePage}
onChangeRowsPerPage={onChangeRowsPerPage}
- />);
+ onSetColumns={onSetColumns} />);
expect(dataExplorer.find(TablePagination).prop("page")).toEqual(10);
expect(dataExplorer.find(TablePagination).prop("rowsPerPage")).toEqual(50);
dataExplorer.find(TablePagination).prop("onChangePage")(undefined, 6);
onChangeRowsPerPage: jest.fn(),
onContextMenu: jest.fn(),
defaultIcon: ProjectIcon,
+ onSetColumns: jest.fn(),
defaultMessages: ['testing'],
});
export const COLLECTION_COPY_DIALOG = 'projectCopy';
-export interface CopyFormDialogData {
+export interface CollectionCopyFormDialogData {
name: string;
ownerUuid: string;
uuid: string;
export const openCollectionCopyDialog = (resource: { name: string, uuid: string }) =>
(dispatch: Dispatch) => {
dispatch<any>(resetPickerProjectTree());
- const initialData: CopyFormDialogData = { name: `Copy of: ${resource.name}`, ownerUuid: '', uuid: resource.uuid };
+ const initialData: CollectionCopyFormDialogData = { name: `Copy of: ${resource.name}`, ownerUuid: '', uuid: resource.uuid };
dispatch<any>(initialize(COLLECTION_COPY_DIALOG, initialData));
dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_COPY_DIALOG, data: {} }));
};
-export const copyCollection = (resource: CopyFormDialogData) =>
+export const copyCollection = (resource: CollectionCopyFormDialogData) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
dispatch(startSubmit(COLLECTION_COPY_DIALOG));
try {