Skip to content

Commit 1db4243

Browse files
authored
fix(dashboards): dashboards frontend should filter out prebuilt dashboards when calculating limit (#105948)
1 parent 0ef55a6 commit 1db4243

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

static/gsApp/hooks/dashboardsLimit.spec.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ describe('useDashboardsLimit', () => {
107107
{id: '2', title: 'Dashboard 2'},
108108
{id: '3', title: 'Dashboard 3'},
109109
],
110-
match: [MockApiClient.matchQuery({per_page: 11})],
110+
match: [MockApiClient.matchQuery({per_page: 10, filter: 'excludePrebuilt'})],
111111
});
112112

113113
const {result} = renderHookWithProviders(() => useDashboardsLimit(), {
@@ -149,7 +149,7 @@ describe('useDashboardsLimit', () => {
149149
{id: '2', title: 'Dashboard 2'},
150150
{id: '3', title: 'Dashboard 3'},
151151
],
152-
match: [MockApiClient.matchQuery({per_page: 4})],
152+
match: [MockApiClient.matchQuery({per_page: 3, filter: 'excludePrebuilt'})],
153153
});
154154

155155
const {result} = renderHookWithProviders(() => useDashboardsLimit(), {
@@ -195,7 +195,7 @@ describe('useDashboardsLimit', () => {
195195
{id: '2', title: 'Dashboard 2'},
196196
{id: '3', title: 'Dashboard 3'},
197197
],
198-
match: [MockApiClient.matchQuery({per_page: 3})],
198+
match: [MockApiClient.matchQuery({per_page: 2, filter: 'excludePrebuilt'})],
199199
});
200200

201201
const {result} = renderHookWithProviders(() => useDashboardsLimit(), {
@@ -237,7 +237,7 @@ describe('useDashboardsLimit', () => {
237237
const dashboardsRequest = MockApiClient.addMockResponse({
238238
url: '/organizations/org-slug/dashboards/',
239239
body: [],
240-
match: [MockApiClient.matchQuery({per_page: 11})],
240+
match: [MockApiClient.matchQuery({per_page: 10, filter: 'excludePrebuilt'})],
241241
});
242242

243243
const {result} = renderHookWithProviders(() => useDashboardsLimit(), {
@@ -271,7 +271,7 @@ describe('useDashboardsLimit', () => {
271271
MockApiClient.addMockResponse({
272272
url: '/organizations/org-slug/dashboards/',
273273
statusCode: 500,
274-
match: [MockApiClient.matchQuery({per_page: 11})],
274+
match: [MockApiClient.matchQuery({per_page: 10, filter: 'excludePrebuilt'})],
275275
});
276276

277277
const {result} = renderHookWithProviders(() => useDashboardsLimit(), {

static/gsApp/hooks/dashboardsLimit.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ export function useDashboardsLimit(): UseDashboardsLimitResult {
3434
`/organizations/${organization.slug}/dashboards/`,
3535
{
3636
query: {
37+
filter: 'excludePrebuilt',
3738
// We only need to know there are at most the limited # of dashboards.
38-
per_page: dashboardsLimit + 1, // +1 to account for the General dashboard
39+
per_page: dashboardsLimit,
3940
},
4041
},
4142
],
@@ -45,9 +46,8 @@ export function useDashboardsLimit(): UseDashboardsLimitResult {
4546
}
4647
);
4748

48-
// Add 1 to dashboardsLimit to account for the General dashboard
4949
const hasReachedDashboardLimit =
50-
((dashboardsTotalCount?.length ?? 0) >= dashboardsLimit + 1 &&
50+
((dashboardsTotalCount?.length ?? 0) >= dashboardsLimit &&
5151
dashboardsLimit !== UNLIMITED_DASHBOARDS_LIMIT) ||
5252
dashboardsLimit === 0;
5353
const limitMessage = hasReachedDashboardLimit

0 commit comments

Comments
 (0)