diff --git a/superset-frontend/package-lock.json b/superset-frontend/package-lock.json index bc202b898..300e0793b 100644 --- a/superset-frontend/package-lock.json +++ b/superset-frontend/package-lock.json @@ -4921,7 +4921,6 @@ "version": "0.6.11", "resolved": "https://registry.npmjs.org/@types/react-json-tree/-/react-json-tree-0.6.11.tgz", "integrity": "sha512-HP0Sf0ZHjCi1FHLJxh/pLaxaevEW6ILlV2C5Dn3EZFTkLjWkv+EVf/l/zvtmoU9ZwuO/3TKVeWK/700UDxunTw==", - "dev": true, "requires": { "@types/react": "*" } diff --git a/superset-frontend/src/components/ListView/TableCollection.tsx b/superset-frontend/src/components/ListView/TableCollection.tsx index d3fa085f3..0ec2b5e66 100644 --- a/superset-frontend/src/components/ListView/TableCollection.tsx +++ b/superset-frontend/src/components/ListView/TableCollection.tsx @@ -18,17 +18,16 @@ */ import React from 'react'; import cx from 'classnames'; -import { Cell, HeaderGroup, Row } from 'react-table'; +import { TableInstance } from 'react-table'; -interface Props { +interface Props { getTableProps: (userProps?: any) => any; getTableBodyProps: (userProps?: any) => any; - prepareRow: (row: Row) => any; - headerGroups: Array>; - rows: Array>; + prepareRow: TableInstance['prepareRow']; + headerGroups: TableInstance['headerGroups']; + rows: TableInstance['rows']; loading: boolean; } -/* tslint:disable:jsx-key */ export default function TableCollection({ getTableProps, getTableBodyProps, @@ -36,30 +35,32 @@ export default function TableCollection({ headerGroups, rows, loading, -}: Props) { +}: Props) { return ( {headerGroups.map(headerGroup => ( - {headerGroup.headers.map((column: any) => ( - - ))} + {headerGroup.headers.map(column => + column.hidden ? null : ( + + ), + )} ))} @@ -76,7 +77,9 @@ export default function TableCollection({ row.setState && row.setState({ hover: false }) } > - {row.cells.map((cell: Cell) => { + {row.cells.map(cell => { + if (cell.column.hidden) return null; + const columnCellProps = cell.column.cellProps || {}; return ( diff --git a/superset-frontend/src/types/react-table-config.d.ts b/superset-frontend/src/types/react-table-config.d.ts index 262f4e371..a16a69564 100644 --- a/superset-frontend/src/types/react-table-config.d.ts +++ b/superset-frontend/src/types/react-table-config.d.ts @@ -116,6 +116,8 @@ declare module 'react-table' { UseGroupByColumnOptions, UseResizeColumnsColumnOptions, UseSortByColumnOptions { + hidden?: boolean; + sortable?: boolean; cellProps?: any; } diff --git a/superset-frontend/src/views/chartList/ChartList.tsx b/superset-frontend/src/views/chartList/ChartList.tsx index aea0aace8..e5ec774bf 100644 --- a/superset-frontend/src/views/chartList/ChartList.tsx +++ b/superset-frontend/src/views/chartList/ChartList.tsx @@ -147,7 +147,7 @@ class ChartList extends React.PureComponent { }, }: any) => {dsNameTxt}, Header: t('Datasource'), - accessor: 'datasource_name_text', + accessor: 'datasource_name', sortable: true, }, { @@ -158,9 +158,9 @@ class ChartList extends React.PureComponent { changed_by_url: changedByUrl, }, }, - }: any) => {changedByUrl}, + }: any) => {changedByName}, Header: t('Creator'), - accessor: 'creator', + accessor: 'changed_by_fk', sortable: true, }, { @@ -173,6 +173,14 @@ class ChartList extends React.PureComponent { accessor: 'changed_on', sortable: true, }, + { + accessor: 'description', + hidden: true, + }, + { + accessor: 'owners', + hidden: true, + }, { Cell: ({ row: { state, original } }: any) => { const handleDelete = () => this.handleChartDelete(original); @@ -280,11 +288,20 @@ class ChartList extends React.PureComponent { }; fetchData = ({ pageIndex, pageSize, sortBy, filters }: FetchDataConfig) => { - this.setState({ loading: true }); - const filterExps = Object.keys(filters).map(fk => ({ - col: fk, - opr: filters[fk].filterId, - value: filters[fk].filterValue, + // set loading state, cache the last config for fetching data in this component. + this.setState({ + lastFetchDataConfig: { + filters, + pageIndex, + pageSize, + sortBy, + }, + loading: true, + }); + const filterExps = filters.map(({ id: col, operator: opr, value }) => ({ + col, + opr, + value, })); const queryParams = JSON.stringify({ @@ -329,7 +346,6 @@ class ChartList extends React.PureComponent { { Header: 'Description', id: 'description', - input: 'textarea', operators: filterOperators.slice_name.map(convertFilter), }, { diff --git a/superset-frontend/src/views/dashboardList/DashboardList.tsx b/superset-frontend/src/views/dashboardList/DashboardList.tsx index aec63c73d..ec29d1ba3 100644 --- a/superset-frontend/src/views/dashboardList/DashboardList.tsx +++ b/superset-frontend/src/views/dashboardList/DashboardList.tsx @@ -174,9 +174,11 @@ class DashboardList extends React.PureComponent { }, { accessor: 'slug', + hidden: true, }, { accessor: 'owners', + hidden: true, }, { Cell: ({ row: { state, original } }: any) => { diff --git a/superset/views/chart/api.py b/superset/views/chart/api.py index 6389b9352..ca0a37e83 100644 --- a/superset/views/chart/api.py +++ b/superset/views/chart/api.py @@ -159,12 +159,18 @@ class ChartRestApi(SliceMixin, BaseOwnedModelRestApi): "params", "cache_timeout", ] + order_columns = [ + "slice_name", + "viz_type", + "datasource_name", + "changed_by_fk", + "changed_on", + ] + # Will just affect _info endpoint edit_columns = ["slice_name"] add_columns = edit_columns - # exclude_route_methods = ("info",) - add_model_schema = ChartPostSchema() edit_model_schema = ChartPutSchema()
- {column.render('Header')} - {' '} - {column.sortable && ( - - )} - + {column.render('Header')} + {' '} + {column.sortable && ( + + )} +