diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/Section.tsx b/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/Section.tsx new file mode 100644 index 0000000000000..0aaeae3e4ce44 --- /dev/null +++ b/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/Section.tsx @@ -0,0 +1,30 @@ +/* + * 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 React from 'react'; +import { isEmpty } from 'lodash'; +import { i18n } from '@kbn/i18n'; +import { EuiText } from '@elastic/eui'; +import { KeyValueTable } from '../KeyValueTable'; +import { KeyValuePair } from '../../../utils/flattenObject'; + +interface Props { + keyValuePairs: KeyValuePair[]; +} + +export function Section({ keyValuePairs }: Props) { + if (!isEmpty(keyValuePairs)) { + return ; + } + return ( + + {i18n.translate( + 'xpack.apm.propertiesTable.agentFeature.noDataAvailableLabel', + { defaultMessage: 'No data available' } + )} + + ); +} diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/__test__/Section.test.tsx b/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/__test__/Section.test.tsx new file mode 100644 index 0000000000000..4378c7fdeee0c --- /dev/null +++ b/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/__test__/Section.test.tsx @@ -0,0 +1,17 @@ +/* + * 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 React from 'react'; +import 'jest-dom/extend-expect'; +import { render } from 'react-testing-library'; +import { Section } from '../Section'; +import { expectTextsInDocument } from '../../../../utils/testHelpers'; + +describe('Section', () => { + it('shows "empty state message" if no data is available', () => { + const component = render(
); + expectTextsInDocument(component, ['No data available']); + }); +});