diff --git a/apps/admin-x-settings/src/components/settings/advanced/HistoryModal.tsx b/apps/admin-x-settings/src/components/settings/advanced/HistoryModal.tsx index 8c228994f3..109caea05c 100644 --- a/apps/admin-x-settings/src/components/settings/advanced/HistoryModal.tsx +++ b/apps/admin-x-settings/src/components/settings/advanced/HistoryModal.tsx @@ -1,6 +1,6 @@ import NiceModal, {useModal} from '@ebay/nice-modal-react'; import {Action, getActionTitle, getContextResource, getLinkTarget, isBulkAction, useBrowseActions} from '@tryghost/admin-x-framework/api/actions'; -import {Avatar, Button, Icon, InfiniteScrollListener, List, ListItem, LoadSelectOptions, Modal, NoValueLabel, Popover, Select, SelectOption, Toggle, ToggleGroup, debounce} from '@tryghost/admin-x-design-system'; +import {Avatar, Button, Icon, InfiniteScrollListener, List, ListItem, LoadSelectOptions, LoadingIndicator, Modal, NoValueLabel, Popover, Select, SelectOption, Toggle, ToggleGroup, debounce} from '@tryghost/admin-x-design-system'; import {RoutingModalProps, useRouting} from '@tryghost/admin-x-framework/routing'; import {User} from '@tryghost/admin-x-framework/api/users'; import {generateAvatarColor, getInitials} from '../../../utils/helpers'; @@ -32,7 +32,7 @@ const HistoryAvatar: React.FC<{action: Action}> = ({action}) => { labelColor='white' size='md' /> -
+
@@ -77,7 +77,7 @@ const HistoryFilter: React.FC<{ return (
- }> + }>
@@ -167,7 +167,7 @@ const HistoryModal = NiceModal.create(({params}) => { const [excludedEvents, setExcludedEvents] = useState([]); const [excludedResources, setExcludedResources] = useState(['label']); - const {data, fetchNextPage} = useBrowseActions({ + const {data, fetchNextPage, isFetchingNextPage} = useBrowseActions({ searchParams: { include: 'actor,resource', limit: PAGE_SIZE.toString(), @@ -194,6 +194,8 @@ const HistoryModal = NiceModal.create(({params}) => { setter(values => (included ? values.concat(value) : values.filter(current => current !== value))); }; + const hasActiveFilters = excludedEvents.length > 0 || excludedResources.length > 0 || params?.user; + return ( { @@ -219,32 +221,49 @@ const HistoryModal = NiceModal.create(({params}) => { updateRoute('history'); }} > -
- - {data?.actions ? <> - - {data?.actions.map(action => !action.skip && } - detail={[ - new Date(action.created_at).toLocaleDateString('default', {year: 'numeric', month: 'short', day: '2-digit'}), - new Date(action.created_at).toLocaleTimeString('default', {hour: '2-digit', minute: '2-digit', second: '2-digit'}) - ].join(' | ')} - title={ -
- {getActionTitle(action)}{isBulkAction(action) ? '' : ': '} - {!isBulkAction(action) && } - {action.count ? <> {action.count} times : null} - — by {action.actor?.name || action.actor?.slug} -
- } - separator - />)} - - : - - No entries found. - - } +
+ 0) ? 'End of history log' : undefined}> + {data?.actions ? ( + data.actions.length > 0 ? ( + <> + + {data.actions.map(action => !action.skip && } + detail={[ + new Date(action.created_at).toLocaleDateString('default', {year: 'numeric', month: 'short', day: '2-digit'}), + new Date(action.created_at).toLocaleTimeString('default', {hour: '2-digit', minute: '2-digit', second: '2-digit'}) + ].join(' | ')} + title={ +
+ {getActionTitle(action)}{isBulkAction(action) ? '' : ': '} + {!isBulkAction(action) && } + {action.count ? <> {action.count} times : null} + — by {action.actor?.name || action.actor?.slug} +
+ } + separator + />)} + {isFetchingNextPage && ( +
+ +
+ )} + + ) : ( + + {hasActiveFilters ? + 'No entries match your current filters.' : + 'No history entries found.' + } + + ) + ) : data === undefined ? ( +
+ +
+ ) : ( + No entries found. + )}