Update implementation of IndexList in tasks page
parent
4936d1184d
commit
2f4c7ed216
|
@ -13,10 +13,6 @@ import {
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import {Task} from 'src/types/v2/tasks'
|
import {Task} from 'src/types/v2/tasks'
|
||||||
import {
|
|
||||||
IndexListColumn,
|
|
||||||
IndexListRow,
|
|
||||||
} from 'src/shared/components/index_views/IndexListTypes'
|
|
||||||
import EmptyTasksList from 'src/tasks/components/EmptyTasksList'
|
import EmptyTasksList from 'src/tasks/components/EmptyTasksList'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -29,83 +25,51 @@ interface Props {
|
||||||
export default class TasksList extends PureComponent<Props> {
|
export default class TasksList extends PureComponent<Props> {
|
||||||
public render() {
|
public render() {
|
||||||
const {searchTerm, onCreate} = this.props
|
const {searchTerm, onCreate} = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IndexList
|
<IndexList>
|
||||||
columns={this.columns}
|
<IndexList.Header>
|
||||||
rows={this.rows}
|
<IndexList.HeaderCell columnName="Name" width="65%" />
|
||||||
emptyState={
|
<IndexList.HeaderCell columnName="Organization" width="15%" />
|
||||||
<EmptyTasksList searchTerm={searchTerm} onCreate={onCreate} />
|
<IndexList.HeaderCell columnName="Status" width="10%" />
|
||||||
}
|
<IndexList.HeaderCell columnName="" width="10%" />
|
||||||
/>
|
</IndexList.Header>
|
||||||
|
<IndexList.Body
|
||||||
|
emptyState={
|
||||||
|
<EmptyTasksList searchTerm={searchTerm} onCreate={onCreate} />
|
||||||
|
}
|
||||||
|
columnCount={4}
|
||||||
|
>
|
||||||
|
{this.rows}
|
||||||
|
</IndexList.Body>
|
||||||
|
</IndexList>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private get columns(): IndexListColumn[] {
|
private get rows(): JSX.Element[] {
|
||||||
return [
|
|
||||||
{
|
|
||||||
key: 'task--name',
|
|
||||||
title: 'Name',
|
|
||||||
size: 500,
|
|
||||||
showOnHover: false,
|
|
||||||
align: Alignment.Left,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'task--organization',
|
|
||||||
title: 'Organization',
|
|
||||||
size: 100,
|
|
||||||
showOnHover: false,
|
|
||||||
align: Alignment.Left,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'task--status',
|
|
||||||
title: 'Status',
|
|
||||||
size: 90,
|
|
||||||
showOnHover: false,
|
|
||||||
align: Alignment.Left,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'task--actions',
|
|
||||||
title: '',
|
|
||||||
size: 200,
|
|
||||||
showOnHover: true,
|
|
||||||
align: Alignment.Right,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
private get rows(): IndexListRow[] {
|
|
||||||
const {tasks} = this.props
|
const {tasks} = this.props
|
||||||
|
|
||||||
return tasks.map(t => ({
|
return tasks.map(t => (
|
||||||
disabled: false,
|
<IndexList.Row key={`task-id--${t.id}`}>
|
||||||
columns: [
|
<IndexList.Cell>
|
||||||
{
|
<a href="#">{t.name}</a>
|
||||||
key: 'task--name',
|
</IndexList.Cell>
|
||||||
contents: <a href="#">{t.name}</a>,
|
<IndexList.Cell>
|
||||||
},
|
<a href="#">{t.organization.name}</a>
|
||||||
{
|
</IndexList.Cell>
|
||||||
key: 'task--organization',
|
<IndexList.Cell>Enabled</IndexList.Cell>
|
||||||
contents: t.organization.name,
|
<IndexList.Cell alignment={Alignment.Right} revealOnHover={true}>
|
||||||
},
|
<ComponentSpacer align={Alignment.Right}>
|
||||||
{
|
<Button
|
||||||
key: 'task--status',
|
size={ComponentSize.ExtraSmall}
|
||||||
contents: 'Enabled',
|
color={ComponentColor.Danger}
|
||||||
},
|
text="Delete"
|
||||||
{
|
onClick={this.handleDeleteTask(t)}
|
||||||
key: 'task--actions',
|
/>
|
||||||
contents: (
|
</ComponentSpacer>
|
||||||
<ComponentSpacer align={Alignment.Right}>
|
</IndexList.Cell>
|
||||||
<Button
|
</IndexList.Row>
|
||||||
size={ComponentSize.ExtraSmall}
|
))
|
||||||
color={ComponentColor.Danger}
|
|
||||||
text="Delete"
|
|
||||||
onClick={this.handleDeleteTask(t)}
|
|
||||||
/>
|
|
||||||
</ComponentSpacer>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleDeleteTask = (task: Task) => (): void => {
|
private handleDeleteTask = (task: Task) => (): void => {
|
||||||
|
|
Loading…
Reference in New Issue