Members
# constant filtersSerialiser
Takes an AsyncTableToolsTable state and transforms it into a Compliance scoped search filter parameter
# constant sortSerialiser
Returns a string consumable by the Compliance API as a "sort_by" parameter for a given column and direction For columns to be sortable they need to have a "sortable" prop, which corresponds to the field name in the Compliance API
Example
Example of a column with an sortable property
const columns = [
{
title: 'Name',
sortable: 'name' // Corresponds to the attribute/field to sort by in the API
}
];
Methods
# ComplianceRoute(props) → {React.ReactElement}
This is component renders "routes" in Routes.js
Parameters:
Name | Type | Description |
---|---|---|
props |
object
|
Component props |
component |
React.ReactElement
|
Component to render |
title |
string
|
Title to set as browser title |
path |
string
|
Path of the route |
requiredPermissions |
Array
|
An array of RBAC permissions required to render the component |
props |
object
|
Props for the component to render |
Returns the component for this route
React.ReactElement
# ComplianceTable(props) → {React.ReactElement}
This component serves as a place to either use the non-async TableTools or the TableToolsTable And allow preparing the TableToolsTable props/options common across tables in Compliance
Parameters:
Name | Type | Description |
---|---|---|
props |
object
|
Component props |
Returns either a Async table
React.ReactElement
# DeleteReport() → {React.Element}
DeleteReport Component
Renders the modal for deleting a report. It provides buttons for confirming or canceling the deletion.
The rendered DeleteReport component.
React.Element
# LinkWithPermission(props) → {React.ReactElement}
Component to render a InsightsLink if required permissions are met or render a disabled link with tooltip if not.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
props |
object
|
Component props |
|
to |
string
|
object
|
ReactRouter to prop, which will be used to determine the required permissions for this path |
|
Component |
React.ReactElement
|
<optional> |
Alternative "Link" component to render |
componentProps |
object
|
<optional> |
Additional props for the Link component |
children |
React.ReactElement
|
Component children |
Component
React.ReactElement
# RulesTable(propsopt) → {React.ReactElement}
A component to show rules of a policy or test result.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
props |
object
|
<optional> |
React component props |
columns |
Array
|
A set of RulesTable columns |
|
rules |
Array
|
<optional> |
A set of rules (for the current page to show) |
total |
number
|
<optional> |
The overall total number of rules available to go through |
ruleTree |
object
|
<optional> |
A table tree to show the rules in. If provided it will enable the "table view" toggle |
policyId |
string
|
<optional> |
A policy ID used for remediations and as profile for rules |
policyName |
string
|
<optional> |
A policy name used in the profile of rule items |
reportTestResult |
object
|
<optional> |
A report test result used for the remediatons button |
remediationsEnabled |
boolean
|
<optional> |
Enables the "RemediationButton" |
ansibleSupportFilter |
boolean
|
<optional> |
Enables the ansible filter |
selectedFilter |
boolean
|
<optional> |
Enables the "Selected Only" filter |
selectedRules |
Array
|
<optional> |
An array of rule IDs selected |
hidePassed |
boolean
|
<optional> |
Enables a default filter to only show failed rules. |
options |
object
|
<optional> |
TableToolsTable options |
activeFilters |
string
|
<optional> |
Default filter |
ruleValues |
object
|
<optional> |
An object of values to show for certain rule values |
valueDefinitions |
Array
|
<optional> |
An array of value definitons available for rules in the table |
skipValueDefinitions |
boolean
|
<optional> |
TODO |
onRuleValueReset |
function
|
<optional> |
A function called when a rule value is reset |
DedicatedAction |
React.ReactElement
|
<optional> |
A dedicated action to show in the table |
valueOverrides |
object
|
<optional> |
An object of rule values // TODO we should make the name of this more consistent |
onValueOverrideSave |
function
|
<optional> |
A funciton called when a value is saved |
onSelect |
function
|
<optional> |
A function called when a selection action is performed |
defaultTableView |
string
|
<optional> |
A table view to show by default ("row" or "tree") // TODO we should use the table options directly |
loading |
React.ReactElement
# TailoringTab(propsopt) → {React.ReactElement}
This component is used to show either the tailorings with rules of a specific policy, or the rules of a specific security guide and it's rules for a set of minor OS versions
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
props |
object
|
<optional> |
React component props |
policy |
object
|
<optional> |
A policy object from the API |
policy.id |
string
|
<optional> |
The id used to fetch |
tailoring |
object
|
<optional> |
A tailoring object from the API |
tailoring.id |
string
|
<optional> |
A tailorings ID used to fetch the associated rules, rule groups, and value definitions for |
securityGuideId |
string
|
<optional> |
The ID for a security guide that the profile should be queried with |
profileId |
string
|
<optional> |
The ID for a specific profile the rules should fetched for |
osMajorVersion |
string
|
<optional> |
A specific major OS version the profile should be queried with |
osMinorVersion |
string
|
<optional> |
A specific minor OS versions that the profile should be for |
columns |
Array
|
<optional> |
A set of RulesTable columns the table should show |
enableSecurityGuideRulesToggle |
boolean
|
<optional> |
This enabled the "Selected Only" toggle to appear and allows fetching the security guide rule set for the matching profile |
systemCount |
<optional> |
||
rulesPageLink |
<optional> |
||
rulesTableProps |
object
|
React component props to be passed on to the RulesTable component in the tab |
|
resetLink |
|||
setRuleValues |
function
|
<optional> |
A callback called when a custom rule value is saved |
onRuleValueReset |
function
|
<optional> |
A callback called when values for a rule are reset |
onValueOverrideSave |
function
|
<optional> |
deprecated We should be using setRuleValues instead |
onSelect |
function
|
<optional> |
A callback called when a selection is made |
selected |
object
|
<optional> |
An array of currently selected IDs |
skipProfile |
string
|
<optional> |
|
additionalRules |
<optional> |
||
valueOverrides |
<optional> |
||
showResetButton |
<optional> |
Enables reset rules button |
React.ReactElement
# Tailorings(propsopt) → {React.ReactElement}
This component is used to show either a specific policy an it's tailorings, or a specific security guide and specific profiles, or a specific policy with it's existing tailorings and the default ruleset from the security guide for a specified set of minor OS versions.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
props |
object
|
<optional> |
React component props |
policy |
object
|
<optional> |
A policy object from the API |
policy.id |
string
|
<optional> |
The id used to fetch the tailorings associated with it |
profiles |
string
|
<optional> |
An array of objects containing osMajorVersion, osMinorVersion, securityGuideId, profileId props for showing additional tabs. |
defaultTab |
string
|
<optional> |
TODO |
columns |
Array
|
<optional> |
An array of RulesTable columns |
level |
number
|
<optional> |
Sets the level of the tab in the URL anchor |
ouiaId |
string
|
<optional> |
OuiaId to pass to the PatternFly Table |
onValueOverrideSave |
function
|
<optional> |
Callback function called when a value of a rule is saved |
onSelect |
function
|
<optional> |
Callback function called when any selection is made |
selected |
object
|
<optional> |
|
enableSecurityGuideRulesToggle |
boolean
|
<optional> |
Will enable the "Only Selected" toggle. When a policy with tailorings is shown and the toggle is enabled it will request rule data from the tailoring, with it disabled it will load rule data from the security guide. If a profile is provided it will load rules either from the profile, if the toggle is enabled, otherwise from the security guide. |
selectedVersionCounts |
object
|
<optional> |
An object containing minor version as a key and count as a value. Helps to render the system count badge in tab headers. |
valueOverrides |
object
|
<optional> |
|
rulesPageLink |
<optional> |
||
skipProfile |
|||
additionalRules |
|||
showResetButton |
<optional> |
Enables reset rules button |
React.ReactElement
# WithPermission(props) → {React.ReactElement}
Wrapper component to either render a component if required permissions are met,
Show the NotAuthorized
page, or do not render the component at all
Parameters:
Name | Type | Description |
---|---|---|
props |
object
|
Component props |
children |
React.ReactElement
|
Component to render |
requiredPermissions |
Array
|
An array of RBAC permissions required to render the component |
hide |
boolean
|
Boolean to set wether or not to hide the component if required permissions are NOT met |
Returns the component for this route
React.ReactElement
# useComplianceApi(endpointopt) → {object|function}
Hook to get a Compliance javascript-client or specific endpoint function
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
endpoint |
string
|
<optional> |
String of the javascript-clients export for the needed endpoint |
Compliance javascript-client or specific endpoint function
object
|
function
# useComplianceQuery(endpoint, optionsopt) → {useComplianceQueryReturn}
Hook to use a Compliance REST API v2 endpoint with useQuery. Optionally support for using the serialised table state if a <TableStateProvider/>
is available.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
endpoint |
function
|
String of the javascript-clients export for the needed endpoint |
|
options |
object
|
<optional> |
Options for useComplianceQuery & useQuery |
params |
useComplianceQueryParams
|
<optional> |
API endpoint params |
useTableState |
boolean
|
<optional> |
Use the serialised table state |
batched |
boolean
|
<optional> |
Wether or not requests should be batched |
skip |
boolean
|
<optional> |
Wether or not to skip the request |
batch |
object
|
<optional> |
Options to be passed to the useFetchTotalBatched |
onlyTotal |
boolean
|
<optional> |
Enables a predefined "compileResult" function for the useQuery to only return the meta.total as the |
requiredParams |
Array
|
string
|
<optional> |
Parameters required for the endpoint. The request will be "skipped" until all parameters are provided. |
convertArray |
|||
convertToArray |
|||
compileResult |
|||
useQueryOptions |
An object containing a data, loading and error state, as well as a fetch and fetchBatched function.
Example
// Will return a `useQuery` result with data, loading, error
const { data, loading, error } = useComplianceQuery('policies')
// Will return a `useQuery` result with a filter passed to the API
const reportsApi = useComplianceQuery('reports', {
params: { filter: 'name NOT null'}
})
// Will return a `useQuery` result using the sort, pagination and filter state from a TableStateProvider passed as params to the API
const reportsApi = useComplianceQuery('reports', {
useTableState: true
})
// Will do the same as above, but additionally add a default filter to the tables filter
const reportsApi = useComplianceQuery('reports', {
params: { filter: 'name NOT null' },
useTableState: true
})
// Will use the table state for pagination and filters, but always use the 'name:asc' for every request
const reportsApi = useComplianceQuery('reports', {
params: { sortBy: 'name:asc' },
useTableState: true
})
# useFetchTotalBatched(fetchFnopt, optionsopt) → {useFetchTotalBatchedReturn}
This hook allows to provide a fetch function that can be called to perform "batched" requests. In short it means it will make as many requests/calls with the function to fill a total. This "total" is taken from the meta.total or the first response. Responses or returns of the function are expected to contain at least a "data" and a "meta" property The "data" property must be an array, to be able to merge the results. The "meta" property must at least (in the first response/return) contain the total property.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
fetchFn |
function
|
<optional> |
An async function that accepts an offset, a limit and a params argument |
options |
object
|
<optional> |
Hook options |
batchSize |
number
|
<optional> |
The limit or items to be requested per request (Default: 50) |
skip |
boolean
|
<optional> |
Wether or not to skip (all) requests (Default: false) |
params |
object
|
<optional> |
Parameters passed to all calls |
An object to use
Type Definitions
object
# useComplianceQueryParams
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
filter |
string
|
<optional> |
Scoped search filter string for the endpoint |
pagination |
object
|
<optional> |
API pagination params |
offset |
object
|
<optional> |
Pagination offset |
limit |
object
|
<optional> |
Pagination limit (maximum 100) |
sortBy |
object
|
<optional> |
SortBy string for the API (usually 'attribute:desc') |
object
# useComplianceQueryReturn
Properties:
Name | Type | Description |
---|---|---|
data |
object
|
Property that contains the request response |
error |
object
|
Property that contains the request error |
loading |
boolean
|
Wether or not the requests are currently loading |
fetch |
function
|
Fetch function to call fetches on demand |
fetchBatched |
function
|
Fetch function to call batched fetches on demand |
fetchQueue |
function
|
Function that can be called with a "queue"/array of params object or an object with key paramsObject pairs to call fetch with |
fetchBatchedQueue |
function
|
Function that can be called with a "queue"/array of params object or an object with key paramsObject pairs to call fetchBatched with |
fetchAllIds |
function
|
Fetch function to call a batched fetch of all ids (with the idsOnly param) on demand |
exporter |
function
|
Fetch function to call a batched fetch of all data and return the objects on demand (can be passed as exporter to Table Tools) |
object
# useFetchTotalBatchedReturn
Properties:
Name | Type | Description |
---|---|---|
loading |
boolean
|
Wether or not data is loaded |
data |
object
|
Combined result of all requests |
fetch |
function
|
Function to call the batched requests on demand that additional parameters for all requests |