mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
fix TableListView empty view trapping users with no action to create new item (#109345)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
c736d99c87
commit
3669aad41f
3 changed files with 60 additions and 0 deletions
|
@ -42,6 +42,52 @@ exports[`TableListView render default empty prompt 1`] = `
|
|||
</KibanaPageTemplate>
|
||||
`;
|
||||
|
||||
exports[`TableListView render default empty prompt with create action when createItem supplied 1`] = `
|
||||
<KibanaPageTemplate
|
||||
data-test-subj="testLandingPage"
|
||||
isEmptyState={true}
|
||||
pageBodyProps={
|
||||
Object {
|
||||
"aria-labelledby": undefined,
|
||||
}
|
||||
}
|
||||
>
|
||||
<EuiEmptyPrompt
|
||||
actions={
|
||||
<EuiButton
|
||||
data-test-subj="newItemButton"
|
||||
fill={true}
|
||||
iconType="plusInCircleFilled"
|
||||
onClick={[Function]}
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage="Create {entityName}"
|
||||
id="kibana-react.tableListView.listing.createNewItemButtonLabel"
|
||||
values={
|
||||
Object {
|
||||
"entityName": "test",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</EuiButton>
|
||||
}
|
||||
title={
|
||||
<h1>
|
||||
<FormattedMessage
|
||||
defaultMessage="No {entityNamePlural} available."
|
||||
id="kibana-react.tableListView.listing.noAvailableItemsMessage"
|
||||
values={
|
||||
Object {
|
||||
"entityNamePlural": "tests",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</h1>
|
||||
}
|
||||
/>
|
||||
</KibanaPageTemplate>
|
||||
`;
|
||||
|
||||
exports[`TableListView render list view 1`] = `
|
||||
<KibanaPageTemplate
|
||||
data-test-subj="testLandingPage"
|
||||
|
|
|
@ -39,6 +39,19 @@ describe('TableListView', () => {
|
|||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
// avoid trapping users in empty prompt that can not create new items
|
||||
test('render default empty prompt with create action when createItem supplied', async () => {
|
||||
const component = shallowWithIntl(<TableListView {...requiredProps} createItem={() => {}} />);
|
||||
|
||||
// Using setState to check the final render while sidestepping the debounced promise management
|
||||
component.setState({
|
||||
hasInitialFetchReturned: true,
|
||||
isFetchingItems: false,
|
||||
});
|
||||
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('render custom empty prompt', () => {
|
||||
const component = shallowWithIntl(
|
||||
<TableListView {...requiredProps} emptyPrompt={<EuiEmptyPrompt />} />
|
||||
|
|
|
@ -362,6 +362,7 @@ class TableListView extends React.Component<TableListViewProps, TableListViewSta
|
|||
}
|
||||
</h1>
|
||||
}
|
||||
actions={this.renderCreateButton()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue