Skip to content

Commit

Permalink
Refactor date fields to use FieldType.Date instead of FieldType.DateTime
Browse files Browse the repository at this point in the history
  • Loading branch information
simlarsen committed Apr 11, 2024
1 parent f95ab83 commit 03ad9bf
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 50 deletions.
5 changes: 3 additions & 2 deletions CommonUI/src/Components/Filters/Filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,9 @@ const FilterComponent: FunctionComponent<ComponentProps> = (

if (
changedValue &&
filter.type ===
FieldType.Text
(filter.type ===
FieldType.Text ||
filter.type === FieldType.Email)
) {
filterData[
filter.key
Expand Down
4 changes: 4 additions & 0 deletions CommonUI/src/Components/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,18 @@ const List: FunctionComponent<ComponentProps> = (

if (props.error) {
return (
<div className='p-6'>
<ErrorMessage
error={props.error}
onRefreshClick={props.onRefreshClick}
/>
</div>
);
}

if (props.data.length === 0) {
return (
<div className='p-6'>
<ErrorMessage
error={
props.noItemsMessage
Expand All @@ -69,6 +72,7 @@ const List: FunctionComponent<ComponentProps> = (
}
onRefreshClick={props.onRefreshClick}
/>
</div>
);
}

Expand Down
19 changes: 14 additions & 5 deletions Dashboard/src/Pages/Incidents/View/InternalNote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<PageComponentProps> = (
props: PageComponentProps
Expand Down Expand Up @@ -175,12 +176,20 @@ const IncidentDelete: FunctionComponent<PageComponentProps> = (
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: {
Expand All @@ -193,7 +202,7 @@ const IncidentDelete: FunctionComponent<PageComponentProps> = (
field: {
createdAt: true,
},
type: FieldType.DateTime,
type: FieldType.Date,
title: 'Created At',
},
]}
Expand Down
25 changes: 17 additions & 8 deletions Dashboard/src/Pages/Incidents/View/PublicNote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<PageComponentProps> = (
props: PageComponentProps
Expand Down Expand Up @@ -205,26 +206,34 @@ const PublicNote: FunctionComponent<PageComponentProps> = (
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={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PageComponentProps> = (
props: PageComponentProps
Expand Down Expand Up @@ -183,28 +184,35 @@ const ScheduledMaintenanceDelete: FunctionComponent<PageComponentProps> = (
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,
},
type: FieldType.Text,
title: 'Note',
},
{
field: {
createdAt: true,
},
type: FieldType.Date,
title: 'Created At',
},
]}
columns={[
{
Expand Down
38 changes: 19 additions & 19 deletions Dashboard/src/Pages/ScheduledMaintenanceEvents/View/PublicNote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<PageComponentProps> = (
props: PageComponentProps
Expand Down Expand Up @@ -212,35 +213,34 @@ const PublicNote: FunctionComponent<PageComponentProps> = (
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={[
Expand Down
4 changes: 2 additions & 2 deletions Dashboard/src/Pages/StatusPages/View/Announcements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ const StatusPageDelete: FunctionComponent<PageComponentProps> = (
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: {
Expand Down
25 changes: 24 additions & 1 deletion Dashboard/src/Pages/StatusPages/View/EmailSubscribers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,30 @@ const StatusPageDelete: FunctionComponent<PageComponentProps> = (
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={[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const TracesList: FunctionComponent<PageComponentProps> = (
field: {
startTime: true,
},
type: FieldType.DateTime,
type: FieldType.Date,
title: 'Seen At',
},
]}
Expand Down

0 comments on commit 03ad9bf

Please sign in to comment.