Skip to content

Commit

Permalink
Fixes #33345 - Do not show select all after deselecting a row (#649)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamruzicka authored Aug 26, 2021
1 parent 8636c7e commit b8c879a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
21 changes: 7 additions & 14 deletions webpack/ForemanTasks/Components/TasksTable/TasksTableReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,13 @@ export const TasksTableQueryReducer = (state = initialState, action) => {
case OPEN_SELECT_ALL:
return state.set('showSelectAll', true);
case UNSELECT_ROWS:
if (state.allRowsSelected) {
// User can unselect rows if only the page rows are selected
return state
.set(
'selectedRows',
payload.results.map(row => row.id).filter(row => row !== payload.id)
)
.set('allRowsSelected', false)
.set('showSelectAll', false);
}
return state.set(
'selectedRows',
state.selectedRows.filter(row => row !== payload.id)
);
return state
.set(
'selectedRows',
state.selectedRows.filter(row => row !== payload.id)
)
.set('showSelectAll', false)
.set('allRowsSelected', false);
case UNSELECT_ALL_ROWS:
return state
.set('selectedRows', [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ const fixtures = {
},
},
'should handle UNSELECT_ROWS with all rows selected': {
state: Immutable({ tasksTableQuery: { allRowsSelected: true } }),
state: Immutable({
tasksTableQuery: { allRowsSelected: true, selectedRows: [3, 4, 5] },
}),
action: {
type: UNSELECT_ROWS,
payload: { id: [4], results: [{ id: 3 }, { id: 4 }, { id: 5 }] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ Object {
exports[`TasksTableReducer reducer should handle UNSELECT_ROWS 1`] = `
Object {
"tasksTableQuery": Object {
"allRowsSelected": false,
"selectedRows": Array [],
"showSelectAll": false,
},
}
`;
Expand Down

0 comments on commit b8c879a

Please sign in to comment.