Skip to content

Commit 35e48d5

Browse files
committed
Add the ability to delete individual Pilot entries
1 parent 75cc30a commit 35e48d5

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

src/features/pilots/PilotsList/PilotsListHeader.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ const PilotsListHeader = () => (
1616
<Table.HeaderCell width={2}>
1717
Skills
1818
</Table.HeaderCell>
19-
<Table.HeaderCell width={4}>
19+
<Table.HeaderCell width={3}>
2020
Mech
2121
</Table.HeaderCell>
22+
<Table.HeaderCell width={1} />
2223

2324
</Table.Row>
2425
</Table.Header>

src/features/pilots/PilotsList/PilotsListRow.jsx

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import React from "react";
22
import {connect} from "react-redux";
3-
import {Table} from "semantic-ui-react";
3+
import {
4+
Table,
5+
Button,
6+
Icon,
7+
} from "semantic-ui-react";
48
import _ from "lodash";
59

610
import {getEntitiesSession} from "features/entities/entitySelectors";
11+
import {deleteEntity} from "features/entities/entityActions";
12+
713

814
const mapState = (state, ownProps) => {
915
const session = getEntitiesSession(state);
@@ -37,7 +43,12 @@ const mapState = (state, ownProps) => {
3743
return {pilot};
3844
}
3945

40-
const PilotsListRow = ({pilot={}, onPilotClicked=_.noop, selected}) => {
46+
const actions = {
47+
deleteEntity,
48+
};
49+
50+
51+
const PilotsListRow = ({pilot={}, onPilotClicked=_.noop, selected, deleteEntity}) => {
4152
const {
4253
id = null,
4354
name = "",
@@ -48,6 +59,8 @@ const PilotsListRow = ({pilot={}, onPilotClicked=_.noop, selected}) => {
4859
mechType = "",
4960
} = pilot;
5061

62+
const onDeleteClicked = () => deleteEntity("Pilot", id);
63+
5164
return (
5265
<Table.Row onClick={() => onPilotClicked(id)} active={selected}>
5366
<Table.Cell>
@@ -65,8 +78,21 @@ const PilotsListRow = ({pilot={}, onPilotClicked=_.noop, selected}) => {
6578
<Table.Cell>
6679
{mechType}
6780
</Table.Cell>
81+
82+
<Table.Cell>
83+
<Button
84+
compact
85+
basic
86+
circular
87+
size="tiny"
88+
color="red"
89+
icon={<Icon name="delete" />}
90+
onClick={onDeleteClicked}
91+
>
92+
</Button>
93+
</Table.Cell>
6894
</Table.Row>
6995
);
7096
}
7197

72-
export default connect(mapState)(PilotsListRow);
98+
export default connect(mapState, actions)(PilotsListRow);

0 commit comments

Comments
 (0)