Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/audit-log-table
- Loading branch information
Showing
25 changed files
with
475 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* eslint-disable no-undef */ | ||
|
||
'use strict'; | ||
|
||
// Codemirror inner dependency, reference: https://github.com/jsdom/jsdom/issues/3002 | ||
// Otherwise it throws: TypeError: range(...).getBoundingClientRect is not a function | ||
|
||
document.createRange = () => { | ||
const range = new Range(); | ||
range.getClientRects = jest.fn(() => ({ | ||
item: () => null, | ||
length: 0, | ||
})); | ||
|
||
return range; | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...s/core/admin/ee/admin/pages/SettingsPage/pages/AuditLogs/ListView/ComboboxFilter/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { useIntl } from 'react-intl'; | ||
import { Combobox, ComboboxOption } from '@strapi/design-system'; | ||
|
||
const ComboboxFilter = ({ value, options, onChange }) => { | ||
const { formatMessage } = useIntl(); | ||
const ariaLabel = formatMessage({ | ||
id: 'Settings.permissions.auditLogs.filter.aria-label', | ||
defaultMessage: 'Search and select an option to filter', | ||
}); | ||
|
||
return ( | ||
<Combobox aria-label={ariaLabel} value={value} onChange={onChange}> | ||
{options.map(({ label, customValue }) => { | ||
return ( | ||
<ComboboxOption key={customValue} value={customValue}> | ||
{label} | ||
</ComboboxOption> | ||
); | ||
})} | ||
</Combobox> | ||
); | ||
}; | ||
|
||
ComboboxFilter.defaultProps = { | ||
value: null, | ||
}; | ||
|
||
ComboboxFilter.propTypes = { | ||
value: PropTypes.string, | ||
options: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
label: PropTypes.string.isRequired, | ||
customValue: PropTypes.string.isRequired, | ||
}).isRequired | ||
).isRequired, | ||
onChange: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default ComboboxFilter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...core/admin/ee/admin/pages/SettingsPage/pages/AuditLogs/ListView/hooks/useAuditLogsData.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { useQuery } from 'react-query'; | ||
import { useNotification, useFetchClient } from '@strapi/helper-plugin'; | ||
import { useLocation } from 'react-router-dom'; | ||
|
||
const useAuditLogsData = ({ canRead }) => { | ||
const { get } = useFetchClient(); | ||
const { search } = useLocation(); | ||
const toggleNotification = useNotification(); | ||
|
||
const fetchAuditLogsPage = async ({ queryKey }) => { | ||
const search = queryKey[1]; | ||
const { data } = await get(`/admin/audit-logs${search}`); | ||
|
||
return data; | ||
}; | ||
|
||
const fetchAllUsers = async () => { | ||
const { data } = await get(`/admin/users`); | ||
|
||
return data; | ||
}; | ||
|
||
const queryOptions = { | ||
enabled: canRead, | ||
keepPreviousData: true, | ||
retry: false, | ||
staleTime: 1000 * 20, // 20 seconds | ||
onError: (error) => toggleNotification({ type: 'warning', message: error.message }), | ||
}; | ||
|
||
const { | ||
data: auditLogs, | ||
isLoading, | ||
isError: isAuditLogsError, | ||
} = useQuery(['auditLogs', search], fetchAuditLogsPage, queryOptions); | ||
|
||
const { data: users, isError: isUsersError } = useQuery(['auditLogsUsers'], fetchAllUsers, { | ||
...queryOptions, | ||
staleTime: 2 * (1000 * 60), // 2 minutes | ||
}); | ||
|
||
const hasError = isAuditLogsError || isUsersError; | ||
|
||
return { auditLogs, users: users?.data, isLoading, hasError }; | ||
}; | ||
|
||
export default useAuditLogsData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.