mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-25 16:42:34 +00:00
Fixed showing actions for event auth and representation (#35561)
* Extended KeyckloakDataTable to make the actions available for expandable rows Signed-off-by: Agnieszka Gancarczyk <agagancarczyk@gmail.com> * Extended KeyckloakDataTable to make the actions available for expandable rows Signed-off-by: Agnieszka Gancarczyk <agagancarczyk@gmail.com> --------- Signed-off-by: Agnieszka Gancarczyk <agagancarczyk@gmail.com>
This commit is contained in:
committed by
GitHub
parent
24fab37519
commit
dc5535f8c0
@@ -75,15 +75,34 @@ type DataTableProps<T> = {
|
||||
|
||||
type CellRendererProps = {
|
||||
row: IRow;
|
||||
index?: number;
|
||||
actions?: IActions;
|
||||
actionResolver?: IActionsResolver;
|
||||
};
|
||||
|
||||
const isRow = (c: ReactNode | IRowCell): c is IRowCell =>
|
||||
!!c && (c as IRowCell).title !== undefined;
|
||||
|
||||
const CellRenderer = ({ row }: CellRendererProps) =>
|
||||
row.cells!.map((c, i) => (
|
||||
<Td key={`cell-${i}`}>{(isRow(c) ? c.title : c) as ReactNode}</Td>
|
||||
));
|
||||
const CellRenderer = ({
|
||||
row,
|
||||
index,
|
||||
actions,
|
||||
actionResolver,
|
||||
}: CellRendererProps) => (
|
||||
<>
|
||||
{row.cells!.map((c, i) => (
|
||||
<Td key={`cell-${i}`}>{(isRow(c) ? c.title : c) as ReactNode}</Td>
|
||||
))}
|
||||
{(actions || actionResolver) && (
|
||||
<Td isActionCell>
|
||||
<ActionsColumn
|
||||
items={actions || actionResolver?.(row, {})!}
|
||||
extraData={{ rowIndex: index }}
|
||||
/>
|
||||
</Td>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
const ExpandableRowRenderer = ({ row }: CellRendererProps) =>
|
||||
row.cells!.map((c, i) => (
|
||||
@@ -212,15 +231,12 @@ function DataTable<T>({
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<CellRenderer row={row} />
|
||||
{(actions || actionResolver) && (
|
||||
<Td isActionCell>
|
||||
<ActionsColumn
|
||||
items={actions || actionResolver?.(row, {})!}
|
||||
extraData={{ rowIndex: index }}
|
||||
/>
|
||||
</Td>
|
||||
)}
|
||||
<CellRenderer
|
||||
row={row}
|
||||
index={index}
|
||||
actions={actions}
|
||||
actionResolver={actionResolver}
|
||||
/>
|
||||
</Tr>
|
||||
))}
|
||||
</Tbody>
|
||||
@@ -242,7 +258,12 @@ function DataTable<T>({
|
||||
},
|
||||
}}
|
||||
/>
|
||||
<CellRenderer row={row} />
|
||||
<CellRenderer
|
||||
row={row}
|
||||
index={index}
|
||||
actions={actions}
|
||||
actionResolver={actionResolver}
|
||||
/>
|
||||
</Tr>
|
||||
) : (
|
||||
<Tr isExpanded={!!expandedRows[index - 1]}>
|
||||
|
||||
Reference in New Issue
Block a user