Skip to content

Commit

Permalink
Refactor field types and filters in various components
Browse files Browse the repository at this point in the history
  • Loading branch information
simlarsen committed Apr 12, 2024
1 parent c1150c0 commit 112863a
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 53 deletions.
20 changes: 13 additions & 7 deletions CommonUI/src/Components/Filters/Filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,19 @@ const FilterComponent: FunctionComponent<ComponentProps> = (
if (
changedValue &&
(filter.type ===
FieldType.Text ||
filter.type === FieldType.Email ||
filter.type === FieldType.Phone ||
filter.type === FieldType.Name ||
filter.type === FieldType.Port ||
filter.type === FieldType.URL ||
filter.type === FieldType.ObjectID)
FieldType.Text ||
filter.type ===
FieldType.Email ||
filter.type ===
FieldType.Phone ||
filter.type ===
FieldType.Name ||
filter.type ===
FieldType.Port ||
filter.type ===
FieldType.URL ||
filter.type ===
FieldType.ObjectID)
) {
filterData[
filter.key
Expand Down
36 changes: 17 additions & 19 deletions CommonUI/src/Components/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,26 @@ const List: FunctionComponent<ComponentProps> = (

if (props.error) {
return (
<div className='p-6'>
<ErrorMessage
error={props.error}
onRefreshClick={props.onRefreshClick}
/>
<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
? props.noItemsMessage
: `No ${props.singularLabel.toLocaleLowerCase()}`
}
onRefreshClick={props.onRefreshClick}
/>
<div className="p-6">
<ErrorMessage
error={
props.noItemsMessage
? props.noItemsMessage
: `No ${props.singularLabel.toLocaleLowerCase()}`
}
onRefreshClick={props.onRefreshClick}
/>
</div>
);
}
Expand All @@ -94,8 +94,7 @@ const List: FunctionComponent<ComponentProps> = (
return (
<div data-testid="list-container">
<div className="mt-6">

<div className='bg-white pr-6 pl-6'>
<div className="bg-white pr-6 pl-6">
<Filter
id={`${props.id}-filter`}
showFilter={props.showFilter || false}
Expand All @@ -105,9 +104,8 @@ const List: FunctionComponent<ComponentProps> = (
onFilterRefreshClick={props.onFilterRefreshClick}
filters={props.filters || []}
/>
</div>
<div className="">

</div>
<div className="">
<DragDropContext
onDragEnd={(result: DropResult) => {
result.destination?.index &&
Expand Down
18 changes: 9 additions & 9 deletions CommonUI/src/Components/ModelTable/BaseModelTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,11 @@ const BaseModelTable: <TBaseModel extends BaseModel | AnalyticsBaseModel>(
<Card
{...props.cardProps}
buttons={cardButtons}
bodyClassName={showAs === ShowAs.List ? "-ml-6 -mr-6 bg-gray-50 border-top": ''}
bodyClassName={
showAs === ShowAs.List
? '-ml-6 -mr-6 bg-gray-50 border-top'
: ''
}
title={getCardTitle(props.cardProps.title)}
>
{tableColumns.length === 0 &&
Expand All @@ -1365,19 +1369,15 @@ const BaseModelTable: <TBaseModel extends BaseModel | AnalyticsBaseModel>(
) : (
<></>
)}
{(
tableColumns.length > 0 &&
showAs === ShowAs.Table
) ? (
{tableColumns.length > 0 &&
showAs === ShowAs.Table ? (
getTable()
) : (
<></>
)}

{(
tableColumns.length > 0 &&
showAs === ShowAs.List
) ? (
{tableColumns.length > 0 &&
showAs === ShowAs.List ? (
getList()
) : (
<></>
Expand Down
4 changes: 1 addition & 3 deletions Dashboard/src/Pages/Settings/IncidentSeverity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ const IncidentSeverityPage: FunctionComponent<PageComponentProps> = (
color: true,
order: true,
}}
filters={[

]}
filters={[]}
columns={[
{
field: {
Expand Down
4 changes: 1 addition & 3 deletions Dashboard/src/Pages/Settings/IncidentState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ const IncidentsPage: FunctionComponent<PageComponentProps> = (
isResolvedState: true,
order: true,
}}
filters={[

]}
filters={[]}
columns={[
{
field: {
Expand Down
4 changes: 1 addition & 3 deletions Dashboard/src/Pages/Settings/MonitorStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ const Monitors: FunctionComponent<PageComponentProps> = (
isOfflineState: true,
priority: true,
}}
filters={[

]}
filters={[]}
columns={[
{
field: {
Expand Down
4 changes: 1 addition & 3 deletions Dashboard/src/Pages/Settings/ScheduledMaintenanceState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ const ScheduledMaintenancesPage: FunctionComponent<PageComponentProps> = (
isEndedState: true,
order: true,
}}
filters={[

]}
filters={[]}
columns={[
{
field: {
Expand Down
2 changes: 1 addition & 1 deletion Dashboard/src/Pages/Settings/TeamView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const TeamView: FunctionComponent<PageComponentProps> = (
filters={[
{
field: {
user:true,
user: true,
},
type: FieldType.Entity,
title: 'User',
Expand Down
2 changes: 0 additions & 2 deletions Dashboard/src/Pages/StatusPages/View/Domains.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,11 @@ const StatusPageDelete: FunctionComponent<PageComponentProps> = (
field: {},
title: 'CNAME Valid',
type: FieldType.Boolean,

},
{
field: {},
title: 'SSL Provisioned',
type: FieldType.Boolean,

},
]}
columns={[
Expand Down
3 changes: 1 addition & 2 deletions Dashboard/src/Pages/StatusPages/View/EmailSubscribers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,14 @@ const StatusPageDelete: FunctionComponent<PageComponentProps> = (
},
title: 'Unsubscribed',
type: FieldType.Boolean,

},
{
field: {
createdAt: true,
},
title: 'Subscribed At',
type: FieldType.Date,
}
},
]}
viewPageRoute={Navigation.getCurrentRoute()}
columns={[
Expand Down
5 changes: 4 additions & 1 deletion Dashboard/src/Pages/Workflow/View/Logs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ const Delete: FunctionComponent<PageComponentProps> = (
},
title: 'Workflow Status',
type: FieldType.Dropdown,
filterDropdownOptions: DropdownUtil.getDropdownOptionsFromEnum(WorkflowStatus)
filterDropdownOptions:
DropdownUtil.getDropdownOptionsFromEnum(
WorkflowStatus
),
},
{
field: {
Expand Down

0 comments on commit 112863a

Please sign in to comment.