Skip to content

Commit

Permalink
Fixes #32748 - add pf4 table template
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaAga committed Sep 19, 2023
1 parent 6a29200 commit 93ac77a
Show file tree
Hide file tree
Showing 36 changed files with 628 additions and 1,207 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const Bookmarks = ({
searchQuery={searchQuery}
/>
<Dropdown
position="right"
ouiaId="bookmarks-dropdown"
isOpen={isDropdownOpen}
onSelect={() => setIsDropdownOpen(false)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@ export const useTableSort = ({
}) => {
const translatedInitialSortColumnName = initialSortColumnName
? __(initialSortColumnName)
: allColumns[0];
: Object.keys(columnsToSortParams)[0];

const [activeSortColumn, setActiveSortColumn] = useState(
translatedInitialSortColumnName
);
const [activeSortDirection, setActiveSortDirection] = useState('asc');

if (Object.keys(columnsToSortParams).length === 0) {
return {};
}
if (
!Object.keys(columnsToSortParams).includes(translatedInitialSortColumnName)
) {
throw new Error(
`translatedInitialSortColumnName '${translatedInitialSortColumnName}' must also be defined in columnsToSortParams`
);
}
const [activeSortColumn, setActiveSortColumn] = useState(
translatedInitialSortColumnName
);
const [activeSortDirection, setActiveSortDirection] = useState('asc');

if (!allColumns.includes(activeSortColumn)) {
setActiveSortColumn(translatedInitialSortColumnName);
}
Expand All @@ -30,7 +34,7 @@ export const useTableSort = ({
const onSort = (_event, index, direction) => {
setActiveSortColumn(allColumns?.[index]);
setActiveSortDirection(direction);
_onSort(_event, index, direction);
_onSort && _onSort(_event, index, direction);
};

// Patternfly sort params to pass to the <Th> component.
Expand Down
Loading

0 comments on commit 93ac77a

Please sign in to comment.