-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
When only one node is displayed, show an empty message. Also: * Start adding a basic Jest test for the ServiceMap component * Fix bug where EuiDocsLink was rendering "children" instead of the actual children Closes #59326. Closes #59128.
- Loading branch information
Showing
4 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
x-pack/legacy/plugins/apm/public/components/app/ServiceMap/EmptyBanner.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { EuiCallOut } from '@elastic/eui'; | ||
import lightTheme from '@elastic/eui/dist/eui_theme_light.json'; | ||
import { i18n } from '@kbn/i18n'; | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { ElasticDocsLink } from '../../shared/Links/ElasticDocsLink'; | ||
|
||
const EmptyBannerCallOut = styled(EuiCallOut)` | ||
margin: ${lightTheme.gutterTypes.gutterSmall}; | ||
/* Add some extra margin so it displays to the right of the controls. */ | ||
margin-left: calc( | ||
${lightTheme.gutterTypes.gutterLarge} + | ||
${lightTheme.gutterTypes.gutterExtraLarge} | ||
); | ||
position: absolute; | ||
z-index: 1; | ||
`; | ||
|
||
export function EmptyBanner() { | ||
return ( | ||
<EmptyBannerCallOut | ||
title={i18n.translate('xpack.apm.serviceMap.emptyBanner.title', { | ||
defaultMessage: "Looks like there's only a single service." | ||
})} | ||
> | ||
{i18n.translate('xpack.apm.serviceMap.emptyBanner.message', { | ||
defaultMessage: | ||
"We will map out connected services and external requests if we can detect them. Please make sure you're running the latest version of the APM agent." | ||
})}{' '} | ||
<ElasticDocsLink section="/apm/get-started" path="/agents.html"> | ||
{i18n.translate('xpack.apm.serviceMap.emptyBanner.docsLink', { | ||
defaultMessage: 'Learn more in the docs' | ||
})} | ||
</ElasticDocsLink> | ||
</EmptyBannerCallOut> | ||
); | ||
} |
45 changes: 45 additions & 0 deletions
45
x-pack/legacy/plugins/apm/public/components/app/ServiceMap/index.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { render } from '@testing-library/react'; | ||
import React, { FunctionComponent } from 'react'; | ||
import { License } from '../../../../../../../plugins/licensing/common/license'; | ||
import { LicenseContext } from '../../../context/LicenseContext'; | ||
import { MockApmPluginContextWrapper } from '../../../utils/testHelpers'; | ||
import { ServiceMap } from './'; | ||
|
||
const expiredLicense = new License({ | ||
signature: 'test signature', | ||
license: { | ||
expiryDateInMillis: 0, | ||
mode: 'platinum', | ||
status: 'expired', | ||
type: 'platinum', | ||
uid: '1' | ||
} | ||
}); | ||
|
||
const Wrapper: FunctionComponent = ({ children }) => { | ||
return ( | ||
<LicenseContext.Provider value={expiredLicense}> | ||
<MockApmPluginContextWrapper>{children}</MockApmPluginContextWrapper> | ||
</LicenseContext.Provider> | ||
); | ||
}; | ||
|
||
describe('ServiceMap', () => { | ||
describe('with an inactive license', () => { | ||
it('renders the license banner', async () => { | ||
expect( | ||
( | ||
await render(<ServiceMap />, { | ||
wrapper: Wrapper | ||
}).findAllByText(/Platinum/) | ||
).length | ||
).toBeGreaterThan(0); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters