forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Empty message "No data available" for Labels and User metadata sectio…
…ns missing (elastic#49846) * Adding missing data message when sections are required * refactoring test * fixing unit test
- Loading branch information
1 parent
49e8a0a
commit 35e2134
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/Section.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,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 <KeyValueTable keyValuePairs={keyValuePairs} />; | ||
} | ||
return ( | ||
<EuiText size="s"> | ||
{i18n.translate( | ||
'xpack.apm.propertiesTable.agentFeature.noDataAvailableLabel', | ||
{ defaultMessage: 'No data available' } | ||
)} | ||
</EuiText> | ||
); | ||
} |
17 changes: 17 additions & 0 deletions
17
x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/__test__/Section.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,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(<Section keyValuePairs={[]} />); | ||
expectTextsInDocument(component, ['No data available']); | ||
}); | ||
}); |