Small refactor (#232)
because `canSelectAll` is false there is no need for this check
This commit is contained in:
parent
17b1fab80e
commit
cf95b7184d
1 changed files with 19 additions and 31 deletions
|
@ -59,19 +59,8 @@ export const GroupsList = ({
|
|||
setFormattedData(formatData(list!));
|
||||
}, [list]);
|
||||
|
||||
function onSelect(
|
||||
_: React.FormEvent<HTMLInputElement>,
|
||||
isSelected: boolean,
|
||||
rowId: number
|
||||
) {
|
||||
let localRow;
|
||||
if (rowId === undefined) {
|
||||
localRow = formattedData.map((row: { [key: string]: any }) => {
|
||||
row.selected = isSelected;
|
||||
return row;
|
||||
});
|
||||
} else {
|
||||
localRow = [...formattedData];
|
||||
function onSelect(isSelected: boolean, rowId: number) {
|
||||
const localRow = [...formattedData];
|
||||
const localTableRow = [...tableRowSelectedArray];
|
||||
if (localRow[rowId].selected !== isSelected) {
|
||||
localRow[rowId].selected = isSelected;
|
||||
|
@ -90,7 +79,6 @@ export const GroupsList = ({
|
|||
}
|
||||
setFormattedData(localRow);
|
||||
}
|
||||
}
|
||||
|
||||
const tableHeader = [{ title: t("groupName") }, { title: t("members") }];
|
||||
const actions = [
|
||||
|
@ -122,7 +110,7 @@ export const GroupsList = ({
|
|||
<Table
|
||||
actions={actions}
|
||||
variant={TableVariant.compact}
|
||||
onSelect={onSelect}
|
||||
onSelect={(_, isSelected, rowId) => onSelect(isSelected, rowId)}
|
||||
canSelectAll={false}
|
||||
aria-label={t("tableOfGroups")}
|
||||
cells={tableHeader}
|
||||
|
|
Loading…
Reference in a new issue