Skip to content

Commit

Permalink
Revert "Remove additional request and display icon only for the servi…
Browse files Browse the repository at this point in the history
…ce groups"

This reverts commit 7ff2bc9.
  • Loading branch information
kpatticha committed May 17, 2022
1 parent 41b619f commit 29a8250
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
EuiFlexItem,
EuiButtonIcon,
EuiLoadingContent,
EuiLoadingSpinner,
} from '@elastic/eui';
import React from 'react';
import { i18n } from '@kbn/i18n';
Expand All @@ -19,7 +20,7 @@ import {
KibanaPageTemplateProps,
} from '@kbn/kibana-react-plugin/public';
import { enableServiceGroups } from '@kbn/observability-plugin/public';
import { useFetcher } from '../../../hooks/use_fetcher';
import { useFetcher, FETCH_STATUS } from '../../../hooks/use_fetcher';
import { ApmPluginStartDeps } from '../../../plugin';
import { useApmRouter } from '../../../hooks/use_apm_router';
import { useAnyOfApmParams } from '../../../hooks/use_apm_params';
Expand Down Expand Up @@ -60,8 +61,19 @@ export function ServiceGroupTemplate({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const { data: serviceGroupsData, status: serviceGroupsStatus } = useFetcher(
(callApmApi) => {
if (!serviceGroupId && isServiceGroupsEnabled) {
return callApmApi('GET /internal/apm/service-groups');
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);

const serviceGroupName = data?.serviceGroup.groupName;
const loadingServiceGroupName = !!serviceGroupId && !serviceGroupName;
const hasServiceGroups = !!serviceGroupsData?.serviceGroups.length;
const serviceGroupsLink = router.link('/service-groups', {
query: { ...query, serviceGroup: '' },
});
Expand All @@ -74,7 +86,12 @@ export function ServiceGroupTemplate({
justifyContent="flexStart"
responsive={false}
>
{serviceGroupId && (
{serviceGroupsStatus === FETCH_STATUS.LOADING && (
<EuiFlexItem grow={false}>
<EuiLoadingSpinner size="l" />
</EuiFlexItem>
)}
{(serviceGroupId || hasServiceGroups) && (
<EuiFlexItem grow={false}>
<EuiButtonIcon
iconType="layers"
Expand Down

0 comments on commit 29a8250

Please sign in to comment.