Skip to content

Commit

Permalink
fix: Show loading indicator in recents popover button (opensearch-pro…
Browse files Browse the repository at this point in the history
…ject#8430)

Signed-off-by: Viraj Sanghvi <[email protected]>
  • Loading branch information
virajsanghvi authored Oct 2, 2024
1 parent 391e2ac commit 7378738
Show file tree
Hide file tree
Showing 6 changed files with 272 additions and 19 deletions.
178 changes: 176 additions & 2 deletions src/core/public/chrome/ui/header/__snapshots__/header.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/core/public/chrome/ui/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ export function Header({
navigateToUrl={application.navigateToUrl}
renderBreadcrumbs={renderBreadcrumbs(true, true)}
buttonSize={useApplicationHeader ? 's' : 'xs'}
loadingCount$={observables.loadingCount$}
/>
</EuiHeaderSectionItem>
);
Expand Down
9 changes: 9 additions & 0 deletions src/core/public/chrome/ui/header/recent_items.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@
.primaryApplicationHeader & {
margin-top: $euiSizeXS;
}

// Make the spinner the same size as an xs icon button
&.headerRecentItemsButton--loadingIndicator {
width: $euiButtonHeightXSmall;

& > span {
padding: 0;
}
}
}
8 changes: 8 additions & 0 deletions src/core/public/chrome/ui/header/recent_items.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const defaultMockProps = {
basePath: httpServiceMock.createStartContract().basePath,
http: httpServiceMock.createSetupContract(),
renderBreadcrumbs: <></>,
loadingCount$: new BehaviorSubject(0),
};

jest.spyOn(defaultMockProps.http, 'get').mockImplementation(
Expand Down Expand Up @@ -150,4 +151,11 @@ describe('Recent items', () => {
fireEvent.click(preferencesButton);
expect(screen.getByTestId('preferencesSettingPopover')).toBeInTheDocument();
});

it('should show loading indicator if loading count > 0', () => {
const { baseElement } = render(
<RecentItems {...defaultMockProps} loadingCount$={new BehaviorSubject(1)} />
);
expect(baseElement).toMatchSnapshot();
});
});
Loading

0 comments on commit 7378738

Please sign in to comment.