Skip to content

Commit c1deae9

Browse files
author
Joel Worrall
committed
fix: unused binding calls.
1 parent ff88f74 commit c1deae9

27 files changed

+338
-685
lines changed

.eslintrc.js

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
module.exports = {
2-
env: {
3-
browser: true,
4-
es6: true,
2+
"env": {
3+
"browser": true,
4+
"es6": true
55
},
6-
extends: ['prettier', 'prettier/react'],
7-
globals: {
8-
Atomics: 'readonly',
9-
SharedArrayBuffer: 'readonly',
6+
"extends": [
7+
'plugin:@newrelic/eslint-plugin-newrelic/react',
8+
'plugin:@newrelic/eslint-plugin-newrelic/jest',
9+
'plugin:@newrelic/eslint-plugin-newrelic/prettier'
10+
],
11+
"globals": {
12+
"Atomics": "readonly",
13+
"SharedArrayBuffer": "readonly"
1014
},
11-
parser: 'babel-eslint',
12-
parserOptions: {
13-
ecmaFeatures: {
14-
jsx: true,
15-
},
16-
ecmaVersion: 2018,
17-
sourceType: 'module',
15+
"parser": "babel-eslint",
16+
"parserOptions": {
17+
"ecmaFeatures": {
18+
"jsx": true
19+
},
20+
"ecmaVersion": 2018,
21+
"sourceType": "module"
1822
},
19-
plugins: ['react', 'prettier'],
20-
rules: {
21-
'prettier/prettier': 'error',
22-
},
23-
};
23+
"plugins": [
24+
"react",
25+
"prettier"
26+
],
27+
"rules": {
28+
"prettier/prettier": "error"
29+
}
30+
};

components/account-picker.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,24 @@ import {
77
DropdownItem,
88
UserStorageMutation,
99
UserStorageQuery,
10-
TextField,
10+
TextField
1111
} from 'nr1';
1212

1313
const USER_ACCOUNT_COLLECTION = 'user_account_collection_v1';
1414
const USER_SELECTED_ACCOUNT_ID = 'user_account_id';
1515

16-
export default class AccountPicker extends React.Component {
16+
export default class AccountPicker extends React.PureComponent {
1717
static propTypes = {
18-
hostname: PropTypes.string,
18+
accountChangedCallback: PropTypes.func,
19+
disabled: PropTypes.bool
1920
};
2021

2122
constructor(props) {
2223
super(props);
2324
this.state = {
2425
selectedAccount: { name: '' },
2526
accounts: [],
26-
filter: '',
27+
filter: ''
2728
};
2829
this.onAccountChange = this.onAccountChange.bind(this);
2930
}
@@ -55,7 +56,7 @@ export default class AccountPicker extends React.Component {
5556
async getLastChoseAccountId() {
5657
const userStorageQuery = {
5758
collection: USER_ACCOUNT_COLLECTION,
58-
documentId: USER_SELECTED_ACCOUNT_ID,
59+
documentId: USER_SELECTED_ACCOUNT_ID
5960
};
6061
// TODO: Add error handling
6162
const queryResults = await UserStorageQuery.query(userStorageQuery);
@@ -67,7 +68,7 @@ export default class AccountPicker extends React.Component {
6768
actionType: UserStorageMutation.ACTION_TYPE.WRITE_DOCUMENT,
6869
collection: USER_ACCOUNT_COLLECTION,
6970
document: { account: accountId },
70-
documentId: USER_SELECTED_ACCOUNT_ID,
71+
documentId: USER_SELECTED_ACCOUNT_ID
7172
};
7273
UserStorageMutation.mutate(userMutation);
7374
}

components/configure/custom-hostnames.js

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,40 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
const uuid = require('uuid/v4');
4-
53
import {
64
NerdGraphQuery,
75
Button,
86
HeadingText,
97
Icon,
108
TextField,
119
Stack,
12-
StackItem,
10+
StackItem
1311
} from 'nr1';
1412

1513
import { saveHostNamesToNerdStorage } from '../../utilities/nerdlet-storage';
1614
import TagsModal from './modal-tag';
1715

18-
export default class CustomHostNames extends React.Component {
16+
const uuid = require('uuid/v4');
17+
18+
export default class CustomHostNames extends React.PureComponent {
19+
static propTypes = {
20+
entityGuid: PropTypes.string,
21+
accountId: PropTypes.number,
22+
addHostNameCallback: PropTypes.func,
23+
deleteHostNameCallback: PropTypes.func,
24+
hostNames: PropTypes.array
25+
};
26+
1927
constructor(props) {
2028
super(props);
2129
this.state = {
22-
hidden: true,
2330
tagHidden: true,
24-
mounted: false,
2531
selectedProvider: 'statusPageIo',
2632
tags: [],
2733
keyObject: {
2834
key: props.entityGuid ? props.entityGuid : props.accountId,
29-
type: props.entityGuid ? 'entity' : 'account',
35+
type: props.entityGuid ? 'entity' : 'account'
3036
},
31-
selectedEditHost: undefined,
37+
selectedEditHost: undefined
3238
};
3339
this.addHostName = this.addHostName.bind(this);
3440
this.onTextInputChange = this.onTextInputChange.bind(this);
@@ -54,7 +60,7 @@ export default class CustomHostNames extends React.Component {
5460
id: uuid(),
5561
hostName: addHostNameText,
5662
provider: selectedProvider,
57-
tags: tags,
63+
tags: tags
5864
};
5965
this.setState({ tags: [] });
6066
addHostNameCallback(hostNameObject);
@@ -64,7 +70,7 @@ export default class CustomHostNames extends React.Component {
6470
generateListHostNames() {
6571
const { deleteHostNameCallback, hostNames } = this.props;
6672

67-
if (!hostNames) return <div></div>;
73+
if (!hostNames) return <div />;
6874
return hostNames.map(hostNameObject => (
6975
<li key={hostNameObject.id} className="modal-list-item">
7076
<div className="modal-list-item-name"> {hostNameObject.hostName} </div>
@@ -73,15 +79,19 @@ export default class CustomHostNames extends React.Component {
7379
type={Button.TYPE.DESTRUCTIVE}
7480
sizeType={Button.SIZE_TYPE.SMALL}
7581
iconType={Button.ICON_TYPE.INTERFACE__SIGN__TIMES}
76-
onClick={deleteHostNameCallback.bind(this, hostNameObject.hostName)}
82+
onClick={() => {
83+
deleteHostNameCallback(hostNameObject.hostName);
84+
}}
7785
>
7886
Delete
7987
</Button>
8088
<Button
8189
type={Button.TYPE.NORMAL}
8290
sizeType={Button.SIZE_TYPE.SMALL}
8391
iconType={Button.ICON_TYPE.INTERFACE__OPERATIONS__EDIT}
84-
onClick={this.editTags.bind(this, hostNameObject)}
92+
onClick={() => {
93+
this.editTags(hostNameObject);
94+
}}
8595
>
8696
Edit
8797
</Button>
@@ -100,24 +110,23 @@ export default class CustomHostNames extends React.Component {
100110
try {
101111
// const accountsResults = await AccountsQuery.query();
102112
const accountsResults = await NerdGraphQuery.query({
103-
query: '{ actor { accounts { id name } }}',
113+
query: '{ actor { accounts { id name } }}'
104114
});
105115
if (
106116
accountsResults.data &&
107117
accountsResults.data.actor &&
108118
accountsResults.data.actor.accounts
109119
) {
110-
accountsResults.data.actor.accounts.forEach(
111-
async account =>
112-
await saveHostNamesToNerdStorage(
113-
{ key: account.id, type: 'account' },
114-
hostNames
115-
)
120+
accountsResults.data.actor.accounts.forEach(async account =>
121+
saveHostNamesToNerdStorage(
122+
{ key: account.id, type: 'account' },
123+
hostNames
124+
)
116125
);
117126
this._displaySaveMessage();
118127
}
119128
} catch (err) {
120-
console.log(err);
129+
console.log(err); // eslint-disable-line no-console
121130
}
122131
}
123132

@@ -140,7 +149,7 @@ export default class CustomHostNames extends React.Component {
140149
tagHidden,
141150
selectedEditHost,
142151
showSaved,
143-
selectedProvider,
152+
selectedProvider
144153
} = this.state;
145154
const hostnames = this.generateListHostNames();
146155
return (

components/configure/modal-tag.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import { Button, HeadingText, Modal, TextField, Stack, StackItem } from 'nr1';
34

4-
export default class TagsModal extends React.Component {
5+
export default class TagsModal extends React.PureComponent {
6+
static propTypes = {
7+
hostName: PropTypes.string,
8+
hidden: PropTypes.bool,
9+
onClose: PropTypes.func
10+
};
11+
512
constructor(props) {
613
super(props);
714
this.state = {
815
addTagName: '',
9-
tagHidden: props.tagHidden,
10-
tags: props.hostName ? props.hostName.tags : [],
16+
tags: props.hostName ? props.hostName.tags : []
1117
};
1218
this.addTag = this.addTag.bind(this);
1319
this.deleteTag = this.deleteTag.bind(this);
@@ -28,20 +34,25 @@ export default class TagsModal extends React.Component {
2834
this.props.hostName.tags.findIndex(tag => tag === tagName),
2935
1
3036
);
31-
tags.splice(tags.findIndex(tag => tag === tagName), 1);
37+
tags.splice(
38+
tags.findIndex(tag => tag === tagName),
39+
1
40+
);
3241
this.setState({ tags: tags });
3342
}
3443

3544
generateListHostNames() {
36-
if (!this.props.hostName || !this.props.hostName.tags) return <div></div>;
45+
if (!this.props.hostName || !this.props.hostName.tags) return <div />;
3746
return this.props.hostName.tags.map(tag => (
3847
<li key={tag} className="modal-list-item">
3948
<div className="modal-list-item-name"> {tag} </div>
4049
<Button
4150
className="btn-white modal-list-item-delete"
4251
iconType={Button.ICON_TYPE.INTERFACE__SIGN__TIMES}
43-
onClick={this.deleteTag.bind(this, tag)}
44-
></Button>
52+
onClick={() => {
53+
this.deleteTag(tag);
54+
}}
55+
/>
4556
</li>
4657
));
4758
}
@@ -77,7 +88,9 @@ export default class TagsModal extends React.Component {
7788
<StackItem>
7889
<Button
7990
type={Button.TYPE.NORMAL}
80-
onClick={onClose.bind(this, tags)}
91+
onClick={() => {
92+
onClose(tags);
93+
}}
8194
>
8295
Close
8396
</Button>

components/current-incidents.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@ import dayjs from 'dayjs';
55

66
import { navigation, Icon, Button } from 'nr1';
77
import FormatService from '../utilities/format-service';
8-
import { hostname } from 'os';
8+
// import { hostname } from 'os';
99

10-
export default class CurrentIncidents extends React.Component {
10+
export default class CurrentIncidents extends React.PureComponent {
1111
static propTypes = {
1212
hostname: PropTypes.string.isRequired,
1313
provider: PropTypes.string.isRequired,
1414
refreshRate: PropTypes.number,
15+
handleTileClick: PropTypes.func
1516
};
1617

1718
constructor(props) {
1819
super(props);
1920
this.state = {
2021
currentIncidents: undefined,
21-
isPolling: false,
22+
isPolling: false
2223
};
2324
this.FormatService = new FormatService(this.props.provider);
2425
this.statusPageNetwork = new Network(
@@ -29,24 +30,27 @@ export default class CurrentIncidents extends React.Component {
2930
this.seeMore = this.seeMore.bind(this);
3031
}
3132

33+
componentDidMount() {
34+
this.statusPageNetwork.pollCurrentIncidents(
35+
this.setIncidentData.bind(this),
36+
() => {
37+
const { isPolling } = this.state;
38+
this.setState({ isPolling: !isPolling });
39+
}
40+
);
41+
}
42+
3243
seeMore() {
3344
const nerdletWithState = {
3445
id: 'incident-details',
3546
urlState: {
3647
hostname: this.props.hostname,
37-
provider: this.props.provider,
38-
},
48+
provider: this.props.provider
49+
}
3950
};
4051
navigation.openStackedNerdlet(nerdletWithState);
4152
}
4253

43-
componentDidMount() {
44-
this.statusPageNetwork.pollCurrentIncidents(
45-
this.setIncidentData.bind(this),
46-
() => this.setState({ isPolling: !this.state.isPolling })
47-
);
48-
}
49-
5054
setTimelineSymbol(incidentImpact) {
5155
switch (incidentImpact) {
5256
case 'none':
@@ -93,7 +97,7 @@ export default class CurrentIncidents extends React.Component {
9397
setIncidentData(data) {
9498
this.setState({
9599
currentIncidents: this.FormatService.uniformIncidentData(data),
96-
isPolling: false,
100+
isPolling: false
97101
});
98102
}
99103

@@ -138,7 +142,7 @@ export default class CurrentIncidents extends React.Component {
138142
{dayjs(incident.created_at).format('h:mm a')}
139143
</span>
140144
</div>
141-
<div className="timeline-item-dot"></div>
145+
<div className="timeline-item-dot" />
142146
<div className="timeline-item-body">
143147
<div className="timeline-item-body-header">
144148
<div

0 commit comments

Comments
 (0)