Skip to content

Commit 3b25b37

Browse files
authored
Merge pull request #3247 from bluewave-labs/fix/empty
Fix: empty state
2 parents 1e04345 + 0e149fa commit 3b25b37

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

client/src/Pages/Infrastructure/Monitors/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ const InfrastructureMonitors = () => {
9999
const { summary, count } = monitorsWithChecksData ?? {};
100100
const isLoading = monitorsWithChecksLoading;
101101

102+
// Check if any filters are active
103+
const hasActiveFilters = Boolean(selectedStatus || selectedState || search);
104+
105+
// Show empty state only when there are truly no monitors (not just filtered out)
106+
const effectiveTotalCount =
107+
hasActiveFilters && (summary?.totalMonitors ?? 0) === 0
108+
? 1
109+
: (summary?.totalMonitors ?? 0);
110+
102111
// Delete hook
103112
const { deleteFn, loading: isDeleting } = useDelete();
104113

@@ -117,7 +126,7 @@ const InfrastructureMonitors = () => {
117126
<MonitorBasePageWithStates
118127
loading={isLoading}
119128
error={monitorsWithChecksError}
120-
totalCount={summary?.totalMonitors ?? 0}
129+
totalCount={effectiveTotalCount}
121130
page="infrastructure"
122131
actionLink="/infrastructure/create"
123132
>

client/src/Pages/Uptime/Monitors/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,23 @@ const UptimeMonitorsPage = () => {
122122

123123
const isLoading = monitorsWithChecksLoading;
124124

125+
// Check if any filters are active
126+
const hasActiveFilters = Boolean(
127+
selectedTypes.length > 0 || selectedStatus || selectedState || search
128+
);
129+
130+
// Show empty state only when there are truly no monitors (not just filtered out)
131+
// If filters are active and count is 0, pass 1 to prevent empty state fallback
132+
const effectiveTotalCount =
133+
hasActiveFilters && (summary?.totalMonitors ?? 0) === 0
134+
? 1
135+
: (summary?.totalMonitors ?? 0);
136+
125137
return (
126138
<MonitorBasePageWithStates
127139
loading={isLoading}
128140
error={monitorsWithChecksError}
129-
totalCount={summary?.totalMonitors ?? 0}
141+
totalCount={effectiveTotalCount}
130142
page="uptime"
131143
actionLink="/uptime/create"
132144
>

0 commit comments

Comments
 (0)