From cdf03b9819288e28cb2222e7609f5caf83466a19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bonnet?= Date: Wed, 11 Dec 2024 09:33:06 +0100 Subject: [PATCH] fix(audit-logs): condition organization max limit reached (#1782) --- .../page-general-feature.tsx | 1 + .../src/lib/ui/page-general/page-general.tsx | 42 +++++++------------ .../events/src/lib/ui/row-event/row-event.tsx | 8 ++-- 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/libs/pages/events/src/lib/feature/page-general-feature/page-general-feature.tsx b/libs/pages/events/src/lib/feature/page-general-feature/page-general-feature.tsx index b5dc176249f..94e6ff6068b 100644 --- a/libs/pages/events/src/lib/feature/page-general-feature/page-general-feature.tsx +++ b/libs/pages/events/src/lib/feature/page-general-feature/page-general-feature.tsx @@ -126,6 +126,7 @@ export function PageGeneralFeature() { return ( void handleClearFilter: () => void + organizationMaxLimitReached: boolean events?: OrganizationEventResponse[] placeholderEvents?: OrganizationEventResponse[] onNext: () => void @@ -82,7 +84,7 @@ const dataHead: TableHeadProps[] = [ }, ] -const columnsWidth = '14% 14% 12% 15% 10% 22% 11%' +const columnsWidth = '18% 11% 10% 15% 10% 20% 16%' export function PageGeneral({ isLoading, @@ -99,18 +101,9 @@ export function PageGeneral({ handleClearFilter, organization, showIntercom, + organizationMaxLimitReached, }: PageGeneralProps) { const auditLogsRetentionInDays = organization?.organization_plan?.audit_logs_retention_in_days ?? 30 - const currentDate = new Date().getTime() - const retentionLimitDate = currentDate - auditLogsRetentionInDays * 24 * 60 * 60 * 1000 - - const filteredEvents = - events?.filter((event) => { - if (!event.timestamp) return null - return new Date(event.timestamp).getTime() >= retentionLimitDate - }) || [] - - const checkIfEventsAreFiltered = filteredEvents.length !== events?.length return (
@@ -132,7 +125,7 @@ export function PageGeneral({ placeholderEvents?.map((event) => ( )) - ) : !checkIfEventsAreFiltered && events.length === 0 ? ( + ) : !organizationMaxLimitReached && events?.length === 0 ? (
@@ -142,21 +135,18 @@ export function PageGeneral({

- ) : checkIfEventsAreFiltered ? ( + ) : organizationMaxLimitReached ? (
- {filteredEvents?.map((event) => ( + {events?.map((event) => ( ))}
-

+

{auditLogsRetentionInDays} days limit reached. - {/* TODO: add a real button */} - showIntercom()} - > - Upgrade your plan to see more - +

{[...Array(3)].map((_, index) => ( @@ -166,7 +156,9 @@ export function PageGeneral({ > {[...Array(6)].map((_, index) => (
- {index === 0 ? : null} + {index === 0 ? ( + + ) : null}
))} @@ -174,9 +166,7 @@ export function PageGeneral({ ))}
) : ( - filteredEvents?.map((event) => ( - - )) + events?.map((event) => ) )} diff --git a/libs/pages/events/src/lib/ui/row-event/row-event.tsx b/libs/pages/events/src/lib/ui/row-event/row-event.tsx index e17c050f8c5..5d017039639 100644 --- a/libs/pages/events/src/lib/ui/row-event/row-event.tsx +++ b/libs/pages/events/src/lib/ui/row-event/row-event.tsx @@ -23,7 +23,7 @@ import { SETTINGS_URL, SETTINGS_WEBHOOKS, } from '@qovery/shared/routes' -import { Badge, Icon, IconAwesomeEnum, Skeleton, Tooltip } from '@qovery/shared/ui' +import { Badge, Icon, IconAwesomeEnum, Skeleton, Tooltip, Truncate } from '@qovery/shared/ui' import { dateFullFormat, dateUTCString } from '@qovery/shared/util-dates' import { upperCaseFirstLetter } from '@qovery/shared/util-js' import CopyButton from '../copy-button/copy-button' @@ -240,10 +240,8 @@ export function RowEvent(props: RowEventProps) {
- - - {event.triggered_by} - + +