-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow no results component, don't require series (#936)
- Loading branch information
1 parent
94534a5
commit 4766c23
Showing
14 changed files
with
195 additions
and
35 deletions.
There are no files selected for viewing
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
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
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
Binary file added
BIN
+3.66 KB
...test-ts-test-cases-stories-should-render-custom-no-results-component-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.85 KB
...est-ts-test-cases-stories-should-render-default-no-results-component-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,39 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { common } from '../page_objects'; | ||
|
||
describe('Test cases stories', () => { | ||
it('should render custom no results component', async () => { | ||
await common.expectChartAtUrlToMatchScreenshot( | ||
'http://localhost:9001/?path=/story/test-cases--no-series&knob-Show custom no results=true', | ||
{ | ||
waitSelector: '.echReactiveChart_noResults .euiIcon:not(.euiIcon-isLoading)', | ||
delay: 500, // wait for icon to load | ||
}, | ||
); | ||
}); | ||
|
||
it('should render default no results component', async () => { | ||
await common.expectChartAtUrlToMatchScreenshot( | ||
'http://localhost:9001/?path=/story/test-cases--no-series&knob-Show custom no results=false', | ||
{ waitSelector: '.echReactiveChart_noResults' }, | ||
); | ||
}); | ||
}); |
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
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
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
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
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,32 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import React, { FC, Suspense } from 'react'; | ||
|
||
import { SettingsSpecProps } from '../specs'; | ||
|
||
interface NoResultsProps { | ||
renderFn?: SettingsSpecProps['noResults']; | ||
} | ||
|
||
export const NoResults: FC<NoResultsProps> = ({ renderFn }) => ( | ||
<Suspense fallback={() => null}> | ||
<div className="echReactiveChart_noResults">{renderFn ?? <p>No data to display</p>}</div> | ||
</Suspense> | ||
); |
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
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,50 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiSpacer } from '@elastic/eui'; | ||
import { boolean, text } from '@storybook/addon-knobs'; | ||
import React, { FC } from 'react'; | ||
|
||
import { Chart, Settings, Axis, Position } from '../../src'; | ||
|
||
const NoResults: FC<{ msg: string }> = ({ msg }) => ( | ||
<EuiFlexItem> | ||
<EuiFlexGroup direction="column" alignItems="center" justifyContent="center"> | ||
<EuiIcon type="visualizeApp" /> | ||
<EuiSpacer size="s" /> | ||
<p>{msg}</p> | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
); | ||
|
||
/** | ||
* Should render no data value | ||
*/ | ||
export const Example = () => { | ||
const customNoResults = boolean('Show custom no results', true); | ||
const noResultsMsg = text('Custom No Results message', 'No Results'); | ||
|
||
return ( | ||
<Chart className="story-chart"> | ||
<Axis id="count" title="count" position={Position.Left} /> | ||
<Axis id="x" title="goods" position={Position.Bottom} /> | ||
<Settings noResults={customNoResults ? <NoResults msg={noResultsMsg} /> : undefined} /> | ||
</Chart> | ||
); | ||
}; |
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,29 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { SB_SOURCE_PANEL } from '../utils/storybook'; | ||
|
||
export default { | ||
title: 'Test Cases', | ||
parameters: { | ||
options: { selectedPanel: SB_SOURCE_PANEL }, | ||
}, | ||
}; | ||
|
||
export { Example as noSeries } from './1_no_series'; |