Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[App Search] DataPanel & LoadingOverlay component tweaks #94251

Merged
merged 3 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.dataPanel {
position: relative;
overflow: hidden;

// TODO: This CSS can be removed once EUI supports tables in `subdued` panels
&--filled {
.euiTable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { shallow } from 'enzyme';

import { EuiIcon, EuiButton } from '@elastic/eui';

import { LoadingOverlay } from '../../../shared/loading';

import { DataPanel } from './data_panel';

describe('DataPanel', () => {
Expand Down Expand Up @@ -80,6 +82,18 @@ describe('DataPanel', () => {
expect(wrapper.prop('className')).toEqual('dataPanel dataPanel--filled');
});

it('renders a loading overlay based on isLoading flag', () => {
const wrapper = shallow(<DataPanel title={<h1>Test</h1>} />);

expect(wrapper.prop('aria-busy')).toBeFalsy();
expect(wrapper.find(LoadingOverlay)).toHaveLength(0);

wrapper.setProps({ isLoading: true });

expect(wrapper.prop('aria-busy')).toBeTruthy();
expect(wrapper.find(LoadingOverlay)).toHaveLength(1);
});

it('passes class names', () => {
const wrapper = shallow(<DataPanel title={<h1>Test</h1>} className="testing" />);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
EuiTitle,
} from '@elastic/eui';

import { LoadingOverlay } from '../../../shared/loading';

import './data_panel.scss';

interface Props {
Expand All @@ -27,6 +29,7 @@ interface Props {
iconType?: string;
action?: React.ReactNode;
filled?: boolean;
isLoading?: boolean;
className?: string;
}

Expand All @@ -36,6 +39,7 @@ export const DataPanel: React.FC<Props> = ({
iconType,
action,
filled,
isLoading,
className,
children,
...props // e.g., data-test-subj
Expand All @@ -45,29 +49,36 @@ export const DataPanel: React.FC<Props> = ({
});

return (
<EuiPanel {...props} color={filled ? 'subdued' : 'plain'} className={classes} hasShadow={false}>
<EuiPanel
{...props}
color={filled ? 'subdued' : 'plain'}
className={classes}
hasShadow={false}
aria-busy={isLoading}
>
<EuiFlexGroup justifyContent="spaceBetween" alignItems="center" responsive={false}>
<EuiFlexItem>
<EuiFlexGroup>
<EuiFlexGroup gutterSize="s" alignItems="center" responsive={false}>
{iconType && (
<EuiFlexItem>
<EuiFlexItem grow={false}>
Comment on lines +61 to +63
Copy link
Contributor Author

@cee-chen cee-chen Mar 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the icon position. It should now look like so:

Note that the icon prop isn't currently in use however, but will be in an upcoming Curation PR.

<EuiIcon type={iconType} />
</EuiFlexItem>
)}
<EuiFlexItem>
<EuiTitle size="xs">{title}</EuiTitle>
{subtitle && (
<EuiText size="s" color="subdued">
<p>{subtitle}</p>
</EuiText>
)}
</EuiFlexItem>
</EuiFlexGroup>
{subtitle && (
<EuiText size="s" color="subdued">
<p>{subtitle}</p>
</EuiText>
)}
</EuiFlexItem>
{action && <EuiFlexItem grow={false}>{action}</EuiFlexItem>}
</EuiFlexGroup>
<EuiSpacer />
{children}
{isLoading && <LoadingOverlay />}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what the LoadingOverlay should eventually look like when in use by the Curation view:

This should look very similar to the current loading indicator for the promoted documents section in the standalone UI.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My name is Davey and I approve of this loading overlay. 😀

</EuiPanel>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
* 2.0.
*/

export { Loading } from './loading';
export { Loading, LoadingOverlay } from './loading';
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,19 @@
*/

.enterpriseSearchLoading {
z-index: $euiZLevel2;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%);
}

.enterpriseSearchLoadingOverlay {
z-index: $euiZLevel1;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba($euiColorEmptyShade, .75);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@ import { shallow } from 'enzyme';

import { EuiLoadingSpinner } from '@elastic/eui';

import { Loading } from './';
import { Loading, LoadingOverlay } from './';

describe('Loading', () => {
it('renders', () => {
const wrapper = shallow(<Loading />);
expect(wrapper.hasClass('enterpriseSearchLoading')).toBe(true);
expect(wrapper.find(EuiLoadingSpinner)).toHaveLength(1);
});
});

describe('LoadingOverlay', () => {
it('renders', () => {
const wrapper = shallow(<LoadingOverlay />);
expect(wrapper.hasClass('enterpriseSearchLoadingOverlay')).toBe(true);
expect(wrapper.find(Loading)).toHaveLength(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ export const Loading: React.FC = () => (
<EuiLoadingSpinner size="xl" />
</div>
);

export const LoadingOverlay: React.FC = () => (
<div className="enterpriseSearchLoadingOverlay">
<Loading />
</div>
);