Skip to content

Commit

Permalink
feat(RHINENG-1840): Support sort by group column (#679)
Browse files Browse the repository at this point in the history
Implements https://issues.redhat.com/browse/RHINENG-1840.

Recognise group column sort parameter (when available).
  • Loading branch information
gkarat committed Nov 14, 2023
1 parent aa3c54b commit b0f4f25
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/SmartComponents/ComplianceSystems/ComplianceSystems.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const ComplianceSystems = () => {
}),
Columns.inventoryColumn('groups', {
requiresDefault: true,
sortBy: ['groups'],
}),
Columns.inventoryColumn('tags'),
Columns.OS,
Expand Down
1 change: 1 addition & 0 deletions src/SmartComponents/CreatePolicy/EditPolicySystems.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const EditPolicySystems = ({
},
Columns.inventoryColumn('groups', {
requiresDefault: true,
sortBy: ['groups'],
}),
Columns.inventoryColumn('tags'),
Columns.OperatingSystem,
Expand Down
1 change: 1 addition & 0 deletions src/SmartComponents/ReportDetails/ReportDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export const ReportDetails = ({ route }) => {
}),
Columns.inventoryColumn('groups', {
requiresDefault: true,
sortBy: ['groups'],
}),
Columns.inventoryColumn('tags'),
Columns.SsgVersion,
Expand Down
8 changes: 6 additions & 2 deletions src/SmartComponents/SystemsTable/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,12 @@ export const useGetEntities = (fetchEntities, { selected, columns } = {}) => {
const appendDirection = (attributes, direction) =>
attributes.map((attribute) => `${attribute}:${direction}`);

const findColumnByKey = (key) =>
(columns || []).find((column) => column.key === key);
const findColumnByKey = (sortKey) =>
(columns || []).find(
(column) =>
column.key === sortKey || // group column has a sort key different to its main key
(column.key === 'groups' && sortKey === 'group_name')
);

return async (
_ids,
Expand Down

0 comments on commit b0f4f25

Please sign in to comment.