Skip to content

Commit 0da7f15

Browse files
authored
feat: Migrate dashboard to Material (#1959)
* Fix Signed-off-by: at670475 <andrea.tabone@broadcom.com> * Fix error font size Signed-off-by: at670475 <andrea.tabone@broadcom.com> * Migrate SearchBar and Tile - wip Signed-off-by: at670475 <andrea.tabone@broadcom.com> * Fix css and test Signed-off-by: at670475 <andrea.tabone@broadcom.com> * Fix tests and components Signed-off-by: at670475 <andrea.tabone@broadcom.com> * Fix bug Signed-off-by: at670475 <andrea.tabone@broadcom.com> * Fix code smell Signed-off-by: at670475 <andrea.tabone@broadcom.com> * Address changes and other fix Signed-off-by: at670475 <andrea.tabone@broadcom.com> * Replace back icon to use material Signed-off-by: at670475 <andrea.tabone@broadcom.com>
1 parent c60371d commit 0da7f15

File tree

12 files changed

+148
-56
lines changed

12 files changed

+148
-56
lines changed

api-catalog-ui/frontend/src/components/Dashboard/Dashboard.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,16 @@ a {
128128
#dash-buttons > span {
129129
margin-right: 10px;
130130
}
131+
132+
#refresh-api-button {
133+
font-size: 16px;
134+
height: 2em;
135+
color: #3272d9;
136+
background-color: #ffffff;
137+
}
138+
139+
#refresh-api-button:hover {
140+
background-color: #F4F7FA;
141+
border: none;
142+
}
143+

api-catalog-ui/frontend/src/components/Dashboard/Dashboard.jsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Text, Button } from 'mineral-ui';
1+
import { Typography, IconButton } from '@material-ui/core';
22
import { Component } from 'react';
33
import SearchCriteria from '../Search/SearchCriteria';
44
import Shield from '../ErrorBoundary/Shield/Shield';
@@ -68,9 +68,15 @@ export default class Dashboard extends Component {
6868
toggleWizard={this.toggleWizard}
6969
visible
7070
/>
71-
<Button id="refresh-api-button" size="medium" onClick={this.refreshStaticApis}>
71+
<IconButton
72+
id="refresh-api-button"
73+
size="medium"
74+
variant="outlined"
75+
onClick={this.refreshStaticApis}
76+
style={{ borderRadius: '0.1875em' }}
77+
>
7278
Refresh Static APIs
73-
</Button>
79+
</IconButton>
7480
</div>
7581
<WizardContainer />
7682
<ConfirmDialogContainer />
@@ -79,7 +85,9 @@ export default class Dashboard extends Component {
7985
<div className="no-tiles-container">
8086
<br />
8187
<br />
82-
<Text element="h3">Tile details could not be retrieved, the following error was returned:</Text>
88+
<Typography data-testid="error" variant="subtitle1">
89+
Tile details could not be retrieved, the following error was returned:
90+
</Typography>
8391
{error}
8492
</div>
8593
)}
@@ -96,9 +104,9 @@ export default class Dashboard extends Component {
96104
{hasTiles && tiles.map(tile => <Tile key={tile.id} tile={tile} history={history} />)}
97105
{!hasTiles &&
98106
hasSearchCriteria && (
99-
<Text id="search_no_results" element="h4" color="#1d5bbf">
107+
<Typography id="search_no_results" variant="subtitle2" style={{ color: '#1d5bbf' }}>
100108
No tiles found matching search criteria
101-
</Text>
109+
</Typography>
102110
)}
103111
</div>
104112
</div>

api-catalog-ui/frontend/src/components/Dashboard/Dashboard.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('>>> Dashboard component tests', () => {
6565
);
6666
expect(
6767
dashboard
68-
.find('Text')
68+
.find('[data-testid="error"]')
6969
.first()
7070
.children()
7171
.text()

api-catalog-ui/frontend/src/components/Login/Login.css

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ form#login-form {
8181
margin: 150px 0px;
8282
}
8383

84-
8584
.MuiButton-label {
8685
flex-direction: row;
8786
align-items: flex-start;
@@ -94,7 +93,7 @@ form#login-form {
9493
width: 50%;
9594
height: 36px;
9695
left: 218px;
97-
ine-height: 16px;
96+
line-height: 16px;
9897
/* identical to box height, or 114% */
9998
letter-spacing: 1.25px;
10099
text-transform: uppercase;
@@ -104,10 +103,15 @@ form#login-form {
104103
flex: none;
105104
order: 0;
106105
flex-grow: 0;
107-
margin: 25px -14px 20px 0px;
106+
margin: 25px -14px 10px 14px;
108107
position: static;
109108
}
110109

110+
.MuiButton-label:hover {
111+
background-color: rgb(50, 114, 217);
112+
border: none;
113+
}
114+
111115
.MuiTypography-gutterBottom {
112116
color: #57606E;
113117
}

api-catalog-ui/frontend/src/components/Login/Login.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,22 +190,24 @@ export default class Login extends React.Component {
190190
InputProps={{
191191
endAdornment: (
192192
<InputAdornment position="end">
193+
{messageText && <ErrorOutlineIcon className="errorIcon" />}
193194
<IconButton
194195
aria-label="toggle password visibility"
195196
edge="end"
196197
onClick={() => this.handleClickShowPassword(showPassword)}
197198
>
198199
{showPassword ? <VisibilityOff /> : <Visibility />}
199200
</IconButton>
200-
{messageText && <ErrorOutlineIcon className="errorIcon" />}
201201
</InputAdornment>
202202
),
203203
}}
204204
/>
205205
{warning && <Link underline="hover"> Caps Lock is ON! </Link>}
206206
<Button
207+
variant="outlined"
207208
className="loginButton"
208209
label=""
210+
style={{ border: 'none' }}
209211
type="submit"
210212
data-testid="submit"
211213
disabled={this.isDisabled()}

api-catalog-ui/frontend/src/components/PageNotFound/PageNotFound.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,31 @@
22
color: #58606e ;
33
text-align: left;
44
}
5+
6+
#go-back-button {
7+
font-weight: bold;
8+
font-size: 14px;
9+
width: fit-content;
10+
padding-left: .6rem;
11+
padding-right: .6rem;
12+
height: 32px;
13+
margin-left: 20px;
14+
border-radius: 3px;
15+
background-color: #fff;
16+
cursor: pointer;
17+
color: #0c7bb3;
18+
transition: .3s background-color;
19+
}
20+
21+
#go-back-button:hover {
22+
background-color: #f5f7fa;
23+
}
24+
25+
#go-back-button > span > svg {
26+
margin: 0;
27+
}
28+
29+
#label {
30+
margin-left: 20px;
31+
margin-bottom: 20px;
32+
}

api-catalog-ui/frontend/src/components/PageNotFound/PageNotFound.jsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { Component } from 'react';
2-
import { Button, Text } from 'mineral-ui';
3-
import IconChevronLeft from 'mineral-ui-icons/IconChevronLeft';
2+
import { IconButton, Typography } from '@material-ui/core';
3+
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
4+
5+
import './PageNotFound.css';
46

57
export default class PageNotFound extends Component {
68
handleGoToHome = () => {
@@ -9,20 +11,23 @@ export default class PageNotFound extends Component {
911
};
1012

1113
render() {
12-
const iconBack = <IconChevronLeft />;
14+
const iconBack = <ChevronLeftIcon />;
1315
return (
1416
<div>
15-
<Text element="h1">Page Not Found</Text>
17+
<br />
18+
<Typography id="label" variant="h5">
19+
Page Not Found
20+
</Typography>
1621
<div>
17-
<Button
18-
primary
22+
<IconButton
23+
id="go-back-button"
1924
data-testid="go-home-button"
2025
onClick={this.handleGoToHome}
2126
size="medium"
22-
iconStart={iconBack}
2327
>
28+
{iconBack}
2429
Go to Dashboard
25-
</Button>
30+
</IconButton>
2631
</div>
2732
</div>
2833
);

api-catalog-ui/frontend/src/components/Search/SearchCriteria.jsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Component } from 'react';
1+
import React, { Component } from 'react';
22
import { debounce } from 'lodash';
3-
import { TextInput } from 'mineral-ui';
4-
import IconSearch from 'mineral-ui-icons/IconSearch';
5-
import { IconClear } from 'mineral-ui-icons';
3+
import { InputAdornment, TextField } from '@material-ui/core';
4+
import SearchIcon from '@material-ui/icons/Search';
5+
import ClearIcon from '@material-ui/icons/Clear';
66
import './search.css';
77

88
export default class SearchCriteria extends Component {
@@ -37,16 +37,18 @@ export default class SearchCriteria extends Component {
3737
render() {
3838
const { criteria } = this.state;
3939
const { placeholder } = this.props;
40-
const iconSearch = <IconSearch />;
40+
const iconSearch = <SearchIcon />;
4141
const iconClear = (
42-
<IconClear data-testid="clear-button" className="clear-text-search" onClick={this.clearSearch} />
42+
<ClearIcon data-testid="clear-button" className="clear-text-search" onClick={this.clearSearch} />
4343
);
4444
const icon = criteria.length === 0 ? iconSearch : iconClear;
4545
return (
46-
<TextInput
46+
<TextField
4747
className="search-bar"
4848
data-testid="search-bar"
49-
iconEnd={icon}
49+
InputProps={{
50+
endAdornment: <InputAdornment position="end">{icon}</InputAdornment>,
51+
}}
5052
placeholder={placeholder}
5153
value={criteria}
5254
onChange={this.handleCriteriaChange}

api-catalog-ui/frontend/src/components/Search/SearchCriteria.test.jsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
import { ThemeProvider } from 'mineral-ui';
2-
import { debounce } from 'lodash';
31
// tslint:disable-next-line:no-implicit-dependencies
42
import * as enzyme from 'enzyme';
53
import SearchCriteria from './SearchCriteria';
64

75
describe('>>> Search bar component tests', () => {
86
it('should render all fields with initial state', () => {
97
const wrapper = enzyme.shallow(
10-
<ThemeProvider>
11-
<SearchCriteria />
12-
</ThemeProvider>
8+
<SearchCriteria />
139
);
1410
expect(wrapper.find('.header')).toBeDefined();
1511
expect(wrapper.find('.search-bar')).toBeDefined();

api-catalog-ui/frontend/src/components/Tile/Tile.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,27 @@
5050
left: 0;
5151
}
5252

53+
.MuiSvgIcon-root {
54+
margin-right: 10px;
55+
margin-left: 10px;
56+
}
57+
58+
.MuiTypography-root {
59+
margin: 5px;
60+
margin-bottom: 11px;
61+
}
62+
63+
h6.MuiTypography-root.MuiTypography-subtitle1 {
64+
margin-bottom: 11px;
65+
margin: 1px;
66+
}
67+
5368
.grid-tile-sso {
5469
position: absolute;
5570
right: 0;
5671
bottom: 0;
72+
font-size: 16px;
73+
margin-right: 12px;
5774
font-weight: 700;
5875
}
5976

0 commit comments

Comments
 (0)