Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Minor docs cleanup #24325

Merged
merged 7 commits into from
Oct 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
EuiLink
} from '@elastic/eui';

import { ELASTIC_DOCS } from '../../../../utils/documentation';
import { XPACK_DOCS } from '../../../../utils/documentation/xpack';

import { KibanaLink } from '../../../../utils/url';
import { createErrorGroupWatch } from './createErrorGroupWatch';
Expand Down Expand Up @@ -226,10 +226,7 @@ export default class WatcherFlyout extends Component {
This form will assist in creating a Watch that can notify you of error
occurrences from this service. To learn more about Watcher, please
read our{' '}
<EuiLink
target="_blank"
href={_.get(ELASTIC_DOCS, 'watcher-get-started.url')}
>
<EuiLink target="_blank" href={XPACK_DOCS.xpackWatcher}>
documentation
</EuiLink>
.
Expand Down Expand Up @@ -344,10 +341,7 @@ export default class WatcherFlyout extends Component {
helpText={
<span>
If you have not configured email, please see the{' '}
<EuiLink
target="_blank"
href={_.get(ELASTIC_DOCS, 'x-pack-emails.url')}
>
<EuiLink target="_blank" href={XPACK_DOCS.xpackEmails}>
documentation
</EuiLink>
.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {
sortKeysByConfig,
getPropertyTabNames
} from '..';
import { getFeatureDocs } from '../../../../utils/documentation';
import { getAgentFeatureDocsUrl } from '../../../../utils/documentation/agents';

jest.mock('../../../../utils/documentation');
jest.mock('../../../../utils/documentation/agents');
jest.mock('../propertyConfig.json', () => [
{
key: 'testProperty',
Expand Down Expand Up @@ -105,32 +105,13 @@ describe('getPropertyTabNames', () => {
});

describe('AgentFeatureTipMessage component', () => {
let mockDocs;
const featureName = '';
const agentName = '';

beforeEach(() => {
mockDocs = {
text: 'Mock Docs Text',
url: 'mock-url'
};
getFeatureDocs.mockImplementation(() => mockDocs);
});
const featureName = 'user';
const agentName = 'nodejs';

it('should render when docs are returned', () => {
expect(
shallow(
<AgentFeatureTipMessage
featureName={featureName}
agentName={agentName}
/>
)
).toMatchSnapshot();
expect(getFeatureDocs).toHaveBeenCalledWith(featureName, agentName);
});
const mockDocs = 'mock-url';
getAgentFeatureDocsUrl.mockImplementation(() => mockDocs);

it('should render when docs are returned, but missing a url', () => {
delete mockDocs.url;
expect(
shallow(
<AgentFeatureTipMessage
Expand All @@ -139,10 +120,11 @@ describe('AgentFeatureTipMessage component', () => {
/>
)
).toMatchSnapshot();
expect(getAgentFeatureDocsUrl).toHaveBeenCalledWith(featureName, agentName);
});

it('should render null empty string when no docs are returned', () => {
mockDocs = null;
getAgentFeatureDocsUrl.mockImplementation(() => null);
expect(
shallow(
<AgentFeatureTipMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`AgentFeatureTipMessage component should render when docs are returned 1
size="m"
type="iInCircle"
/>
Mock Docs Text
You can configure your agent to add contextual information about your users.

<ExternalLink
href="mock-url"
Expand All @@ -18,17 +18,6 @@ exports[`AgentFeatureTipMessage component should render when docs are returned 1
</styled.div>
`;

exports[`AgentFeatureTipMessage component should render when docs are returned, but missing a url 1`] = `
<styled.div>
<EuiIcon
size="m"
type="iInCircle"
/>
Mock Docs Text

</styled.div>
`;

exports[`PropertiesTable component should render empty when data has no keys 1`] = `
<styled.div>
<styled.div>
Expand Down Expand Up @@ -68,7 +57,7 @@ exports[`PropertiesTable component should render with data 1`] = `
/>
<AgentFeatureTipMessage
agentName="testAgentName"
featureName="context-testPropKey"
featureName="testPropKey"
/>
</styled.div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import styled from 'styled-components';

import { StringMap } from '../../../../typings/common';
import { colors, fontSize, px, unit, units } from '../../../style/variables';
import { getFeatureDocs } from '../../../utils/documentation';
import { getAgentFeatureDocsUrl } from '../../../utils/documentation/agents';
// @ts-ignore
import { ExternalLink } from '../../../utils/url';
import { KeySorter, NestedKeyValueTable } from './NestedKeyValueTable';
Expand All @@ -38,28 +38,36 @@ export function getPropertyTabNames(selected: string[]): string[] {
).map(({ key }: { key: string }) => key);
}

function getAgentFeatureText(featureName: string) {
switch (featureName) {
case 'user':
return 'You can configure your agent to add contextual information about your users.';
case 'tags':
return 'You can configure your agent to add filterable tags on transactions.';
case 'custom':
return 'You can configure your agent to add custom contextual information on transactions.';
}
}

export function AgentFeatureTipMessage({
featureName,
agentName
}: {
featureName: string;
agentName?: string;
}) {
const docs = getFeatureDocs(featureName, agentName);

if (!docs) {
const docsUrl = getAgentFeatureDocsUrl(featureName, agentName);
if (!docsUrl) {
return null;
}

return (
<TableInfo>
<EuiIcon type="iInCircle" />
{docs.text}{' '}
{docs.url && (
<ExternalLink href={docs.url}>
Learn more in the documentation.
</ExternalLink>
)}
{getAgentFeatureText(featureName)}{' '}
<ExternalLink href={docsUrl}>
Learn more in the documentation.
</ExternalLink>
</TableInfo>
);
}
Expand Down Expand Up @@ -100,10 +108,7 @@ export function PropertiesTable({
keySorter={sortKeysByConfig}
depth={1}
/>
<AgentFeatureTipMessage
featureName={`context-${propKey}`}
agentName={agentName}
/>
<AgentFeatureTipMessage featureName={propKey} agentName={agentName} />
</TableContainer>
);
}
192 changes: 0 additions & 192 deletions x-pack/plugins/apm/public/utils/documentation.ts

This file was deleted.

Loading