Skip to content

Commit

Permalink
add add new record button to datasets listview
Browse files Browse the repository at this point in the history
  • Loading branch information
nytai committed Mar 13, 2020
1 parent 95b4242 commit 22c68ea
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 20 deletions.
14 changes: 7 additions & 7 deletions superset-frontend/src/components/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import React, { ReactNode } from 'react';
import { OverlayTrigger, Tooltip } from 'react-bootstrap';

interface Props {
children: ReactNode;
className: string;
href: string;
onClick: () => void;
placement: string;
style: object;
tooltip: string | null;
children?: ReactNode;
className?: string;
href?: string;
onClick?: () => void;
placement?: string;
style?: object;
tooltip?: string | null;
}

const Link = ({
Expand Down
44 changes: 31 additions & 13 deletions superset-frontend/src/views/datasetList/DatasetList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import PropTypes from 'prop-types';
import React from 'react';
// @ts-ignore
import { Panel } from 'react-bootstrap';
import Link from 'src/components/Link';
import ConfirmStatusChange from 'src/components/ConfirmStatusChange';
import ListView from 'src/components/ListView/ListView';
import {
Expand Down Expand Up @@ -129,6 +130,10 @@ class DatasetList extends React.PureComponent<Props, State> {
return this.hasPerm('can_delete');
}

get canCreate() {
return this.hasPerm('can_add');
}

initialSort = [{ id: 'changed_on', desc: true }];

columns = [
Expand Down Expand Up @@ -405,19 +410,32 @@ class DatasetList extends React.PureComponent<Props, State> {
});
}
return (
<ListView
className="dataset-list-view"
title={'Datasets'}
columns={this.columns}
data={datasets}
count={datasetCount}
pageSize={PAGE_SIZE}
fetchData={this.fetchData}
loading={loading}
initialSort={this.initialSort}
filters={filters}
bulkActions={bulkActions}
/>
<>
{this.canCreate && (
<span className="list-add-action">
<Link
className="btn btn-sm btn-primary pull-right"
href="/tablemodelview/add"
tooltip="Add a new record"
>
<i className="fa fa-plus" />
</Link>
</span>
)}
<ListView
className="dataset-list-view"
title={'Datasets'}
columns={this.columns}
data={datasets}
count={datasetCount}
pageSize={PAGE_SIZE}
fetchData={this.fetchData}
loading={loading}
initialSort={this.initialSort}
filters={filters}
bulkActions={bulkActions}
/>
</>
);
}}
</ConfirmStatusChange>
Expand Down

0 comments on commit 22c68ea

Please sign in to comment.