Stars: Fix infinite loading with no starred items (#116248)
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { isEmpty } from 'lodash';
|
||||
|
||||
import { BASE_URL as v0alphaBaseURL } from '@grafana/api-clients/rtkq/dashboard/v0alpha1';
|
||||
import {
|
||||
API_GROUP as DASHBOARD_API_GROUP,
|
||||
BASE_URL as v0alphaBaseURL,
|
||||
} from '@grafana/api-clients/rtkq/dashboard/v0alpha1';
|
||||
import { generatedAPI as legacyUserAPI } from '@grafana/api-clients/rtkq/legacy/user';
|
||||
import { DataFrame, DataFrameView, getDisplayProcessor, SelectableValue, toDataFrame } from '@grafana/data';
|
||||
import { t } from '@grafana/i18n';
|
||||
@@ -85,10 +88,11 @@ export class UnifiedSearcher implements GrafanaSearcher {
|
||||
fieldSelector: `metadata.name=${name}`,
|
||||
})
|
||||
);
|
||||
starsIds =
|
||||
result.data.items?.[0].spec.resource.find(
|
||||
(info) => info.group === 'dashboard.grafana.app' && info.kind === 'Dashboard'
|
||||
)?.names || [];
|
||||
const items = result.data.items;
|
||||
starsIds = items?.length
|
||||
? items[0].spec.resource.find(({ group, kind }) => group === DASHBOARD_API_GROUP && kind === 'Dashboard')
|
||||
?.names || []
|
||||
: [];
|
||||
} else {
|
||||
starsIds = await dispatch(legacyUserAPI.endpoints.getStars.initiate()).unwrap();
|
||||
}
|
||||
@@ -331,7 +335,7 @@ export class UnifiedSearcher implements GrafanaSearcher {
|
||||
}
|
||||
|
||||
if (query.deleted) {
|
||||
uri = `${getAPIBaseURL('dashboard.grafana.app', 'v1beta1')}/dashboards/?labelSelector=grafana.app/get-trash=true`;
|
||||
uri = `${getAPIBaseURL(DASHBOARD_API_GROUP, 'v1beta1')}/dashboards/?labelSelector=grafana.app/get-trash=true`;
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user