From 03ad9bf3499073db77834e3488b9e436fbfe0b2e Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Thu, 11 Apr 2024 21:33:18 +0100 Subject: [PATCH] Refactor date fields to use FieldType.Date instead of FieldType.DateTime --- CommonUI/src/Components/Filters/Filter.tsx | 5 ++- CommonUI/src/Components/List/List.tsx | 4 ++ .../src/Pages/Incidents/View/InternalNote.tsx | 19 +++++++--- .../src/Pages/Incidents/View/PublicNote.tsx | 25 ++++++++---- .../View/InternalNote.tsx | 32 ++++++++++------ .../View/PublicNote.tsx | 38 +++++++++---------- .../Pages/StatusPages/View/Announcements.tsx | 4 +- .../StatusPages/View/EmailSubscribers.tsx | 25 +++++++++++- .../Telemetry/Services/View/Traces/Index.tsx | 2 +- 9 files changed, 104 insertions(+), 50 deletions(-) diff --git a/CommonUI/src/Components/Filters/Filter.tsx b/CommonUI/src/Components/Filters/Filter.tsx index 896fdb59044..d82c22fc181 100644 --- a/CommonUI/src/Components/Filters/Filter.tsx +++ b/CommonUI/src/Components/Filters/Filter.tsx @@ -280,8 +280,9 @@ const FilterComponent: FunctionComponent = ( if ( changedValue && - filter.type === - FieldType.Text + (filter.type === + FieldType.Text || + filter.type === FieldType.Email) ) { filterData[ filter.key diff --git a/CommonUI/src/Components/List/List.tsx b/CommonUI/src/Components/List/List.tsx index b074dfbf9ed..875a4bf0ceb 100644 --- a/CommonUI/src/Components/List/List.tsx +++ b/CommonUI/src/Components/List/List.tsx @@ -52,15 +52,18 @@ const List: FunctionComponent = ( if (props.error) { return ( +
+
); } if (props.data.length === 0) { return ( +
= ( } onRefreshClick={props.onRefreshClick} /> +
); } diff --git a/Dashboard/src/Pages/Incidents/View/InternalNote.tsx b/Dashboard/src/Pages/Incidents/View/InternalNote.tsx index 6677957982a..c5af2552c85 100644 --- a/Dashboard/src/Pages/Incidents/View/InternalNote.tsx +++ b/Dashboard/src/Pages/Incidents/View/InternalNote.tsx @@ -29,6 +29,7 @@ import DropdownUtil from 'CommonUI/src/Utils/Dropdown'; import BasicFormModal from 'CommonUI/src/Components/FormModal/BasicFormModal'; import ConfirmModal from 'CommonUI/src/Components/Modal/ConfirmModal'; import IncidentNoteTemplate from 'Model/Models/IncidentNoteTemplate'; +import ProjectUser from '../../../Utils/ProjectUser'; const IncidentDelete: FunctionComponent = ( props: PageComponentProps @@ -175,12 +176,20 @@ const IncidentDelete: FunctionComponent = ( filters={[ { field: { - createdByUser: { - name: true, - }, + createdByUser: true, }, - type: FieldType.Text, + type: FieldType.Entity, title: 'Created By', + filterEntityType: User, + fetchFilterDropdownOptions: async () => { + return await ProjectUser.fetchProjectUsersAsDropdownOptions( + DashboardNavigation.getProjectId()! + ); + }, + filterDropdownField: { + label: 'name', + value: '_id', + }, }, { field: { @@ -193,7 +202,7 @@ const IncidentDelete: FunctionComponent = ( field: { createdAt: true, }, - type: FieldType.DateTime, + type: FieldType.Date, title: 'Created At', }, ]} diff --git a/Dashboard/src/Pages/Incidents/View/PublicNote.tsx b/Dashboard/src/Pages/Incidents/View/PublicNote.tsx index d7978195bd0..5d7c3866ad8 100644 --- a/Dashboard/src/Pages/Incidents/View/PublicNote.tsx +++ b/Dashboard/src/Pages/Incidents/View/PublicNote.tsx @@ -31,6 +31,7 @@ import BasicFormModal from 'CommonUI/src/Components/FormModal/BasicFormModal'; import ConfirmModal from 'CommonUI/src/Components/Modal/ConfirmModal'; import OneUptimeDate from 'Common/Types/Date'; import CheckboxViewer from 'CommonUI/src/Components/Checkbox/CheckboxViewer'; +import ProjectUser from '../../../Utils/ProjectUser'; const PublicNote: FunctionComponent = ( props: PageComponentProps @@ -205,26 +206,34 @@ const PublicNote: FunctionComponent = ( filters={[ { field: { - createdByUser: { - name: true, - }, + createdByUser: true, }, + type: FieldType.Entity, title: 'Created By', - type: FieldType.Text, + filterEntityType: User, + fetchFilterDropdownOptions: async () => { + return await ProjectUser.fetchProjectUsersAsDropdownOptions( + DashboardNavigation.getProjectId()! + ); + }, + filterDropdownField: { + label: 'name', + value: '_id', + }, }, { field: { note: true, }, - title: 'Note', type: FieldType.Text, + title: 'Note', }, { field: { - postedAt: true, + createdAt: true, }, - title: 'Posted At', - type: FieldType.DateTime, + type: FieldType.Date, + title: 'Created At', }, ]} columns={[ diff --git a/Dashboard/src/Pages/ScheduledMaintenanceEvents/View/InternalNote.tsx b/Dashboard/src/Pages/ScheduledMaintenanceEvents/View/InternalNote.tsx index 072a5b7637c..116cca4d10c 100644 --- a/Dashboard/src/Pages/ScheduledMaintenanceEvents/View/InternalNote.tsx +++ b/Dashboard/src/Pages/ScheduledMaintenanceEvents/View/InternalNote.tsx @@ -29,6 +29,7 @@ import BasicFormModal from 'CommonUI/src/Components/FormModal/BasicFormModal'; import ConfirmModal from 'CommonUI/src/Components/Modal/ConfirmModal'; import ScheduledMaintenanceNoteTemplate from 'Model/Models/ScheduledMaintenanceNoteTemplate'; import BaseModel from 'Common/Models/BaseModel'; +import ProjectUser from '../../../Utils/ProjectUser'; const ScheduledMaintenanceDelete: FunctionComponent = ( props: PageComponentProps @@ -183,21 +184,21 @@ const ScheduledMaintenanceDelete: FunctionComponent = ( filters={[ { field: { - createdByUser: { - name: true, - }, + createdByUser: true, }, - type: FieldType.Text, - title: 'User', - }, - { - field: { - createdAt: true, + type: FieldType.Entity, + title: 'Created By', + filterEntityType: User, + fetchFilterDropdownOptions: async () => { + return await ProjectUser.fetchProjectUsersAsDropdownOptions( + DashboardNavigation.getProjectId()! + ); + }, + filterDropdownField: { + label: 'name', + value: '_id', }, - type: FieldType.DateTime, - title: 'Created At', }, - { field: { note: true, @@ -205,6 +206,13 @@ const ScheduledMaintenanceDelete: FunctionComponent = ( type: FieldType.Text, title: 'Note', }, + { + field: { + createdAt: true, + }, + type: FieldType.Date, + title: 'Created At', + }, ]} columns={[ { diff --git a/Dashboard/src/Pages/ScheduledMaintenanceEvents/View/PublicNote.tsx b/Dashboard/src/Pages/ScheduledMaintenanceEvents/View/PublicNote.tsx index cb03e1ab043..f80f225013b 100644 --- a/Dashboard/src/Pages/ScheduledMaintenanceEvents/View/PublicNote.tsx +++ b/Dashboard/src/Pages/ScheduledMaintenanceEvents/View/PublicNote.tsx @@ -31,6 +31,7 @@ import ConfirmModal from 'CommonUI/src/Components/Modal/ConfirmModal'; import ScheduledMaintenanceNoteTemplate from 'Model/Models/ScheduledMaintenanceNoteTemplate'; import OneUptimeDate from 'Common/Types/Date'; import CheckboxViewer from 'CommonUI/src/Components/Checkbox/CheckboxViewer'; +import ProjectUser from '../../../Utils/ProjectUser'; const PublicNote: FunctionComponent = ( props: PageComponentProps @@ -212,35 +213,34 @@ const PublicNote: FunctionComponent = ( filters={[ { field: { - note: true, + createdByUser: true, }, - title: 'Note', - type: FieldType.Text, - }, - { - field: { - postedAt: true, + type: FieldType.Entity, + title: 'Created By', + filterEntityType: User, + fetchFilterDropdownOptions: async () => { + return await ProjectUser.fetchProjectUsersAsDropdownOptions( + DashboardNavigation.getProjectId()! + ); + }, + filterDropdownField: { + label: 'name', + value: '_id', }, - title: 'Posted At', - type: FieldType.DateTime, }, { field: { - shouldStatusPageSubscribersBeNotifiedOnNoteCreated: - true, + note: true, }, - title: 'Notify Status Page Subscribers', - type: FieldType.Boolean, + type: FieldType.Text, + title: 'Note', }, { field: { - createdByUser: { - name: true, - email: true, - }, + createdAt: true, }, - title: 'Created By', - type: FieldType.Text, + type: FieldType.Date, + title: 'Created At', }, ]} columns={[ diff --git a/Dashboard/src/Pages/StatusPages/View/Announcements.tsx b/Dashboard/src/Pages/StatusPages/View/Announcements.tsx index 699543e5dcb..d8a68d884e5 100644 --- a/Dashboard/src/Pages/StatusPages/View/Announcements.tsx +++ b/Dashboard/src/Pages/StatusPages/View/Announcements.tsx @@ -135,14 +135,14 @@ const StatusPageDelete: FunctionComponent = ( showAnnouncementAt: true, }, title: 'Show Announcement At', - type: FieldType.DateTime, + type: FieldType.Date, }, { field: { endAnnouncementAt: true, }, title: 'End Announcement At', - type: FieldType.DateTime, + type: FieldType.Date, }, { field: { diff --git a/Dashboard/src/Pages/StatusPages/View/EmailSubscribers.tsx b/Dashboard/src/Pages/StatusPages/View/EmailSubscribers.tsx index 36ec73349be..a2f728c2e08 100644 --- a/Dashboard/src/Pages/StatusPages/View/EmailSubscribers.tsx +++ b/Dashboard/src/Pages/StatusPages/View/EmailSubscribers.tsx @@ -219,7 +219,30 @@ const StatusPageDelete: FunctionComponent = ( noItemsMessage={'No subscribers found.'} formFields={formFields} showRefreshButton={true} - filters={[]} + filters={[ + { + field: { + subscriberEmail: true, + }, + title: 'Email', + type: FieldType.Text, + }, + { + field: { + isUnsubscribed: true, + }, + title: 'Unsubscribed', + type: FieldType.Boolean, + + }, + { + field: { + createdAt: true, + }, + title: 'Subscribed At', + type: FieldType.Date, + } + ]} viewPageRoute={Navigation.getCurrentRoute()} columns={[ { diff --git a/Dashboard/src/Pages/Telemetry/Services/View/Traces/Index.tsx b/Dashboard/src/Pages/Telemetry/Services/View/Traces/Index.tsx index a981032fbbd..5fe371f9945 100644 --- a/Dashboard/src/Pages/Telemetry/Services/View/Traces/Index.tsx +++ b/Dashboard/src/Pages/Telemetry/Services/View/Traces/Index.tsx @@ -76,7 +76,7 @@ const TracesList: FunctionComponent = ( field: { startTime: true, }, - type: FieldType.DateTime, + type: FieldType.Date, title: 'Seen At', }, ]}