Skip to content

Commit 925f8a0

Browse files
committed
Lint & Modernize Header.jsx
1 parent 05fd92b commit 925f8a0

File tree

2 files changed

+67
-49
lines changed

2 files changed

+67
-49
lines changed

.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"no-shadow": ["warn"],
1111
"no-case-declarations": ["warn"],
1212
"no-use-before-define": ["warn"],
13-
"no-restricted-globals": ["warn"]
13+
"no-restricted-globals": ["warn"],
14+
"react/button-has-type": ["warn"],
15+
"react/prop-types": ["warn"],
16+
"jsx-a11y/heading-has-content": ["warn"]
1417
},
1518
"env": {
1619
"browser": true,
Lines changed: 63 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,87 @@
1-
import React from 'react';
1+
import React from "react";
22
import { connect } from "react-redux";
33
import "react-dom";
44

55
import Spinner from "react-svg-spinner";
66

7+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
8+
import { faFile } from "@fortawesome/free-solid-svg-icons";
9+
import { faGithub } from "@fortawesome/free-brands-svg-icons";
10+
import classNames from "classnames";
711
import DateRangePicker from "./DateRangePicker";
8-
import DownloadButton from './DownloadButton';
9-
import RefreshButton from './RefreshButton';
10-
import SlackIcon from './SlackIcon';
12+
import RefreshButton from "./RefreshButton";
13+
import SlackIcon from "./SlackIcon";
1114
import Label from "./Label";
1215
import NameSelector from "./NameSelector";
1316

14-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
15-
import { faFile } from '@fortawesome/free-solid-svg-icons';
16-
import { faGithub } from '@fortawesome/free-brands-svg-icons';
17-
18-
import classNames from "classnames";
19-
2017
import { fetchNames } from "../redux/actions";
2118

22-
class Header extends React.Component {
23-
constructor(props) {
24-
super(props);
25-
}
26-
27-
28-
29-
render() {
30-
return <div className="navbar">
31-
<h1 className="logo"></h1>
32-
<div className={
33-
classNames("labels", { visible: !this.props.areNamesLoading })
34-
}>
35-
<NameSelector/>
36-
{this.props.labels.filter(x => x.name !== "__name__").map(function(label) {
37-
return <Label key={label.name} label={label}></Label>;
19+
function Header(props) {
20+
const { areNamesLoading, isJSONLoading, labels } = props;
21+
return (
22+
<div className="navbar">
23+
<h1 className="logo" />
24+
<div
25+
className={classNames("labels", {
26+
visible: !areNamesLoading,
3827
})}
28+
>
29+
<NameSelector />
30+
{labels
31+
.filter((x) => x.name !== "__name__")
32+
.map((label) => (
33+
<Label key={label.name} label={label} />
34+
))}
3935
</div>
4036
{/* <div className={
41-
classNames("navbar-spinner-container", {
42-
visible: this.props.areNamesLoading
43-
})
44-
}>
45-
<Spinner color="rgba(255,255,255,0.6)" size="20px"/>
46-
</div> */}
37+
classNames("navbar-spinner-container", {
38+
visible: this.props.areNamesLoading
39+
})
40+
}>
41+
<Spinner color="rgba(255,255,255,0.6)" size="20px"/>
42+
</div> */}
4743
{/* <LabelsFilter /> */}
48-
<div className="navbar-space-filler"></div>
44+
<div className="navbar-space-filler" />
4945
<div className="navbar-links">
50-
<span className="navbar-link"><FontAwesomeIcon icon={faFile} />&nbsp;<a target="_blank" href="https://pyroscope.io/docs">Docs</a></span>
51-
<span className="navbar-link"><SlackIcon/>&nbsp;<a target="_blank" href="https://pyroscope.io/slack">Slack</a></span>
52-
<span className="navbar-link"><FontAwesomeIcon icon={faGithub} />&nbsp;<a target="_blank" href="https://github.com/pyroscope-io/pyroscope">GitHub</a></span>
46+
<span className="navbar-link">
47+
<FontAwesomeIcon icon={faFile} />
48+
&nbsp;
49+
<a rel="noreferrer" target="_blank" href="https://pyroscope.io/docs">
50+
Docs
51+
</a>
52+
</span>
53+
<span className="navbar-link">
54+
<SlackIcon />
55+
&nbsp;
56+
<a rel="noreferrer" target="_blank" href="https://pyroscope.io/slack">
57+
Slack
58+
</a>
59+
</span>
60+
<span className="navbar-link">
61+
<FontAwesomeIcon icon={faGithub} />
62+
&nbsp;
63+
<a
64+
rel="noreferrer"
65+
target="_blank"
66+
href="https://github.com/pyroscope-io/pyroscope"
67+
>
68+
GitHub
69+
</a>
70+
</span>
5371
</div>
54-
<div className={
55-
classNames("navbar-spinner-container", {
56-
visible: this.props.isJSONLoading
57-
})
58-
}>
59-
<Spinner color="rgba(255,255,255,0.6)" size="20px"/>
72+
<div
73+
className={classNames("navbar-spinner-container", {
74+
visible: isJSONLoading,
75+
})}
76+
>
77+
<Spinner color="rgba(255,255,255,0.6)" size="20px" />
6078
</div>
6179
&nbsp;
62-
<RefreshButton/>
80+
<RefreshButton />
6381
&nbsp;
6482
<DateRangePicker />
6583
</div>
66-
}
84+
);
6785
}
6886

69-
export default connect(
70-
(x) => x,
71-
{ fetchNames }
72-
)(Header);
87+
export default connect((x) => x, { fetchNames })(Header);

0 commit comments

Comments
 (0)