Skip to content

Commit

Permalink
Fixed the issue where long values overflowed the modal in tables in A…
Browse files Browse the repository at this point in the history
…dministration tab (#8640)
  • Loading branch information
Annaseli authored Feb 24, 2025
1 parent b51b7a8 commit 3e22eaf
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 11 deletions.
6 changes: 4 additions & 2 deletions webui/src/lib/components/auth/forms.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {Checkbox, DataTable, DebouncedFormControl, AlertError, Loading} from "..

export const AttachModal = ({
show, searchFn, resolveEntityFn = (ent => ent.id), onAttach, onHide, addText = "Add",
emptyState = 'No matches', modalTitle = 'Add', headers = ['Select', 'ID'],
emptyState = 'No matches', modalTitle = 'Add', headers = ['', 'ID'],
filterPlaceholder = 'Filter...'
}) => {
const search = useRef(null);
Expand Down Expand Up @@ -45,7 +45,9 @@ export const AttachModal = ({
onRemove={() => setSelected(selected.filter(selectedEnt => selectedEnt.id !== ent.id))}
name={'selected'}/>,
<strong>{resolveEntityFn(ent)}</strong>
]}/>
]}
firstFixedCol={true}
/>

<div className="mt-3">
{(selected.length > 0) &&
Expand Down
22 changes: 17 additions & 5 deletions webui/src/lib/components/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -335,18 +335,26 @@ export const RefreshButton = ({ onClick, size = "md", variant = "light", tooltip
);
};

export const DataTable = ({ headers, results, rowFn, keyFn = (row) => row[0], actions = [], emptyState = null }) => {
export const DataTable = ({ headers, results, rowFn, keyFn = (row) => row[0], actions = [],
emptyState = null, firstFixedCol = false }) => {

if ((!results || results.length === 0) && emptyState !== null) {
return <Alert variant="warning">{emptyState}</Alert>;
}

return (
<Table>
<Table className="w-100" style={{ tableLayout: "fixed" }}>
<thead>
<tr>
{headers.map(header => (
<th key={header}>{header}</th>
{headers.map((header, i) => (
<th
key={header}
title={header}
style={firstFixedCol && i === 0 ? { width: "30px" } : {}}
className="text-nowrap overflow-hidden text-truncate align-middle"
>
{header}
</th>
))}
{(!!actions && actions.length > 0) && <th/>}
</tr>
Expand All @@ -355,7 +363,11 @@ export const DataTable = ({ headers, results, rowFn, keyFn = (row) => row[0], ac
{results.map(row => (
<tr key={keyFn(row)}>
{rowFn(row).map((cell, i) => (
<td key={`${keyFn(row)}-${i}`}>
<td
key={`${keyFn(row)}-${i}`}
title={keyFn(row)}
className="text-nowrap overflow-hidden text-truncate align-middle"
>
{cell}
</td>
))}
Expand Down
4 changes: 3 additions & 1 deletion webui/src/pages/auth/groups/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ const GroupsContainer = () => {
elements.push(<FormattedDate dateValue={group.creation_date}/>)

return elements;
}}/>
}}
firstFixedCol={true}
/>

<Paginator
nextPage={nextPage}
Expand Down
4 changes: 3 additions & 1 deletion webui/src/pages/auth/policies/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ const PoliciesContainer = () => {
{policy.id}
</Link>,
<FormattedDate dateValue={policy.creation_date}/>
]}/>
]}
firstFixedCol={true}
/>

<Paginator
nextPage={nextPage}
Expand Down
4 changes: 3 additions & 1 deletion webui/src/pages/auth/users/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ const UsersContainer = ({nextPage, refresh, setRefresh, error, loading, userList
{ resolveUserDisplayName(user) }
</Link>,
<FormattedDate dateValue={user.creation_date}/>
]}/>
]}
firstFixedCol={true}
/>

<Paginator
nextPage={nextPage}
Expand Down
2 changes: 1 addition & 1 deletion webui/src/pages/auth/users/user/groups.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const UserGroupsList = ({ userId, after, onPaginate }) => {
filterPlaceholder={"Find Group..."}
modalTitle={"Add to Groups"}
addText={"Add to Groups"}
headers={["Select", "Group Name"]}
headers={["", "Group Name"]}
searchFn={(prefix) =>
auth.listGroups(prefix, "", 5).then((res) => res.results)
}
Expand Down

0 comments on commit 3e22eaf

Please sign in to comment.