Skip to content

Commit

Permalink
Empty message "No data available" for Labels and User metadata sectio…
Browse files Browse the repository at this point in the history
…ns missing (#49846)

* Adding missing data message when sections are required

* refactoring test

* fixing unit test
  • Loading branch information
cauemarcondes authored Nov 14, 2019
1 parent 353619b commit 57d090f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
*/

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[];
keyValuePairs: KeyValuePair[];
}

export function Section({ keyValuePairs }: Props) {
if (keyValuePairs) {
if (!isEmpty(keyValuePairs)) {
return <KeyValueTable keyValuePairs={keyValuePairs} />;
}
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { expectTextsInDocument } from '../../../../utils/testHelpers';

describe('Section', () => {
it('shows "empty state message" if no data is available', () => {
const output = render(<Section />);
expectTextsInDocument(output, ['No data available']);
const component = render(<Section keyValuePairs={[]} />);
expectTextsInDocument(component, ['No data available']);
});
});

0 comments on commit 57d090f

Please sign in to comment.