Skip to content

Commit b53a683

Browse files
MariaAgaadamruzicka
authored andcommitted
Fixes #39059 - Update PageLayout to use PF5
1 parent a6748f7 commit b53a683

4 files changed

Lines changed: 57 additions & 28 deletions

File tree

app/assets/stylesheets/patternfly_and_overrides.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,6 @@ a {
134134
align-items: center;
135135
margin-left: auto;
136136

137-
#toolbar-spinner {
138-
margin-right: 5px;
139-
}
140-
141137
.btn-group,
142138
.btn-docs {
143139
float: none;

webpack/assets/javascripts/react_app/components/SearchBar/SearchBar.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
}
1212

1313
.foreman-search-bar {
14+
width: 100%;
1415
display: flex;
1516
.pf-v5-c-dropdown.pf-m-align-right {
1617
width: unset;

webpack/assets/javascripts/react_app/routes/common/PageLayout/PageLayout.js

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import { Col, Spinner } from 'patternfly-react';
43
import {
4+
Spinner,
5+
Toolbar,
6+
ToolbarContent,
7+
ToolbarGroup,
8+
ToolbarItem,
59
PageSection,
610
PageSectionVariants,
711
TextContent,
@@ -59,32 +63,38 @@ const PageLayout = ({
5963
beforeToolbarComponent ||
6064
isLoading ||
6165
toolbarButtons) && (
62-
<PageSection variant={PageSectionVariants.light}>
66+
<PageSection
67+
variant={PageSectionVariants.light}
68+
className="page-toolbar-section"
69+
>
6370
{beforeToolbarComponent}
64-
<div className="title_filter_parent">
65-
<Col className="title_filter" md={6}>
66-
{!searchable && toolbarButtons && title}
67-
{searchable && (
68-
<SearchBar
69-
data={{
70-
...searchProps,
71-
autocomplete: { ...searchProps.autocomplete, searchQuery },
72-
}}
73-
onSearch={onSearch}
74-
/>
75-
)}
76-
</Col>
77-
<Col md={6}>
78-
<div className="btn-toolbar pull-right">
79-
{isLoading && (
80-
<div id="toolbar-spinner">
81-
<Spinner loading size="sm" />
82-
</div>
71+
<Toolbar ouiaId="page-toolbar">
72+
<ToolbarContent>
73+
<ToolbarItem widths={{ default: '50%' }}>
74+
{!searchable && toolbarButtons && title}
75+
{searchable && (
76+
<SearchBar
77+
data={{
78+
...searchProps,
79+
autocomplete: {
80+
...searchProps.autocomplete,
81+
searchQuery,
82+
},
83+
}}
84+
onSearch={onSearch}
85+
/>
8386
)}
87+
</ToolbarItem>
88+
{isLoading && (
89+
<ToolbarItem alignSelf="center" id="toolbar-spinner">
90+
<Spinner size="md" />
91+
</ToolbarItem>
92+
)}
93+
<ToolbarGroup align={{ default: 'alignRight' }}>
8494
{toolbarButtons}
85-
</div>
86-
</Col>
87-
</div>
95+
</ToolbarGroup>
96+
</ToolbarContent>
97+
</Toolbar>
8898
</PageSection>
8999
)}
90100
<PageSection variant={PageSectionVariants.light} type={pageSectionType}>

webpack/assets/javascripts/react_app/routes/common/PageLayout/PageLayout.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,26 @@ describe('PageLayout', () => {
9292
const contentElement = getByText('Content');
9393
expect(contentElement).toBeInTheDocument();
9494
});
95+
96+
it('should show spinner when isLoading is true', () => {
97+
const { container } = renderWithStore(
98+
<Router>
99+
<PageLayout {...pageLayoutMock} isLoading={true}>
100+
<div>Content</div>
101+
</PageLayout>
102+
</Router>
103+
);
104+
expect(container.querySelector('#toolbar-spinner')).toBeInTheDocument();
105+
});
106+
107+
it('should not show spinner when isLoading is false', () => {
108+
const { container } = renderWithStore(
109+
<Router>
110+
<PageLayout {...pageLayoutMock} isLoading={false}>
111+
<div>Content</div>
112+
</PageLayout>
113+
</Router>
114+
);
115+
expect(container.querySelector('#toolbar-spinner')).toBeNull();
116+
});
95117
});

0 commit comments

Comments
 (0)