diff --git a/superset-frontend/spec/javascripts/views/datasetList/DatasetList_spec.jsx b/superset-frontend/spec/javascripts/views/datasetList/DatasetList_spec.jsx index 1ceb5272d7ec5..58b5ef0f574c6 100644 --- a/superset-frontend/spec/javascripts/views/datasetList/DatasetList_spec.jsx +++ b/superset-frontend/spec/javascripts/views/datasetList/DatasetList_spec.jsx @@ -114,7 +114,7 @@ describe('DatasetList', () => { const callsD = fetchMock.calls(/dataset\/\?q/); expect(callsD).toHaveLength(1); expect(callsD[0][0]).toMatchInlineSnapshot( - `"http://localhost/api/v1/dataset/?q=(order_column:changed_on,order_direction:desc,page:0,page_size:25)"`, + `"http://localhost/api/v1/dataset/?q=(order_column:changed_on_delta_humanized,order_direction:desc,page:0,page_size:25)"`, ); }); diff --git a/superset-frontend/src/views/datasetList/DatasetList.tsx b/superset-frontend/src/views/datasetList/DatasetList.tsx index a144c2004b076..aebd465aaf2e5 100644 --- a/superset-frontend/src/views/datasetList/DatasetList.tsx +++ b/superset-frontend/src/views/datasetList/DatasetList.tsx @@ -18,7 +18,6 @@ */ import { SupersetClient } from '@superset-ui/connection'; import { t } from '@superset-ui/translation'; -import moment from 'moment'; import React, { FunctionComponent, useCallback, @@ -26,7 +25,6 @@ import React, { useState, } from 'react'; import rison from 'rison'; -import { SHORT_DATE, SHORT_TIME } from 'src/utils/common'; import ConfirmStatusChange from 'src/components/ConfirmStatusChange'; import DeleteModal from 'src/components/DeleteModal'; import ListView, { ListViewProps } from 'src/components/ListView/ListView'; @@ -55,8 +53,8 @@ type Dataset = { changed_by_name: string; changed_by_url: string; changed_by: string; - changed_on: string; - databse_name: string; + changed_on_delta_humanized: string; + database_name: string; explore_url: string; id: number; owners: Array; @@ -195,7 +193,7 @@ const DatasetList: FunctionComponent = ({ const canDelete = hasPerm('can_delete'); const canCreate = hasPerm('can_add'); - const initialSort = [{ id: 'changed_on', desc: true }]; + const initialSort = [{ id: 'changed_on_delta_humanized', desc: true }]; const handleDatasetEdit = ({ id }: { id: number }) => { window.location.assign(`/tablemodelview/edit/${id}`); @@ -277,30 +275,16 @@ const DatasetList: FunctionComponent = ({ { Header: t('Schema'), accessor: 'schema', - disableSortBy: true, size: 'lg', }, { Cell: ({ row: { - original: { changed_on: changedOn }, + original: { changed_on_delta_humanized: changedOn }, }, - }: any) => { - const momentTime = moment(changedOn); - const time = momentTime.format(SHORT_DATE); - const date = momentTime.format(SHORT_TIME); - return ( - - {date} - - ); - }, - Header: t('Last Modified'), - accessor: 'changed_on', + }: any) => {changedOn}, + Header: t('Modified'), + accessor: 'changed_on_delta_humanized', size: 'xl', }, { @@ -310,8 +294,7 @@ const DatasetList: FunctionComponent = ({ }, }: any) => changedByName, Header: t('Modified By'), - accessor: 'changed_by_fk', - disableSortBy: true, + accessor: 'changed_by.first_name', size: 'xl', }, { diff --git a/superset/datasets/api.py b/superset/datasets/api.py index c6ed752b02b5a..34d08d5fe77dc 100644 --- a/superset/datasets/api.py +++ b/superset/datasets/api.py @@ -74,11 +74,12 @@ class DatasetRestApi(BaseSupersetModelRestApi): "id", "database_id", "database_name", - "changed_by_fk", "changed_by_name", "changed_by_url", + "changed_by.first_name", "changed_by.username", - "changed_on", + "changed_on_utc", + "changed_on_delta_humanized", "default_endpoint", "explore_url", "kind", @@ -90,6 +91,13 @@ class DatasetRestApi(BaseSupersetModelRestApi): "sql", "table_name", ] + list_select_columns = list_columns + ["changed_on", "changed_by_fk"] + order_columns = [ + "table_name", + "schema", + "changed_by.first_name", + "changed_on_delta_humanized", + ] show_columns = [ "database.database_name", "database.id", diff --git a/tests/datasets/api_tests.py b/tests/datasets/api_tests.py index bd634eaa18c73..d5bf9b043e480 100644 --- a/tests/datasets/api_tests.py +++ b/tests/datasets/api_tests.py @@ -88,10 +88,10 @@ def test_get_dataset_list(self): self.assertEqual(response["count"], 1) expected_columns = [ "changed_by", - "changed_by_fk", "changed_by_name", "changed_by_url", - "changed_on", + "changed_on_delta_humanized", + "changed_on_utc", "database_id", "database_name", "default_endpoint",