Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(datasets): sort and humanized modified by #10380

Merged
merged 6 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)"`,
);
});

Expand Down
33 changes: 8 additions & 25 deletions superset-frontend/src/views/datasetList/DatasetList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
*/
import { SupersetClient } from '@superset-ui/connection';
import { t } from '@superset-ui/translation';
import moment from 'moment';
import React, {
FunctionComponent,
useCallback,
useEffect,
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';
Expand Down Expand Up @@ -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<Owner>;
Expand Down Expand Up @@ -195,7 +193,7 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
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}`);
Expand Down Expand Up @@ -277,30 +275,16 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
{
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 (
<TooltipWrapper
label="last-modified"
tooltip={time}
placement="right"
>
<span>{date}</span>
</TooltipWrapper>
);
},
Header: t('Last Modified'),
accessor: 'changed_on',
}: any) => <span className="no-wrap">{changedOn}</span>,
Header: t('Modified'),
accessor: 'changed_on_delta_humanized',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add back the size: 'xl' property which should ensure even spacing between columns

size: 'xl',
},
{
Expand All @@ -310,8 +294,7 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
},
}: any) => changedByName,
Header: t('Modified By'),
accessor: 'changed_by_fk',
disableSortBy: true,
accessor: 'changed_by.first_name',
size: 'xl',
},
{
Expand Down
12 changes: 10 additions & 2 deletions superset/datasets/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions tests/datasets/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down