Skip to content

Commit dcd0930

Browse files
authored
chore: add linter & fix errors (#578)
1 parent a6700ff commit dcd0930

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+348
-205
lines changed

lib/static/components/bottom-progress-bar/index.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import {extend, isNumber} from 'lodash';
44
import React from 'react';
5+
import PropTypes from 'prop-types';
56
import {connect} from 'react-redux';
67

78
import {getVisibleRootSuiteIds} from '../../modules/selectors/tree';
@@ -34,6 +35,11 @@ const BottomProgressBar = (props) => {
3435
);
3536
};
3637

38+
BottomProgressBar.propTypes = {
39+
progressBar: PropTypes.object.isRequired,
40+
visibleRootSuiteIds: PropTypes.arrayOf(PropTypes.number)
41+
};
42+
3743
export default connect(
3844
(state) => ({
3945
progressBar: state.progressBar,

lib/static/components/bullet.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ const Bullet = ({status, onClick, className}) => {
3131
Bullet.propTypes = {
3232
status: PropTypes.oneOf([CHECKED, UNCHECKED, INDETERMINATE]),
3333
onClick: PropTypes.func,
34-
bulletClassName: PropTypes.string
34+
bulletClassName: PropTypes.string,
35+
className: PropTypes.string
3536
};
3637

3738
export default Bullet;

lib/static/components/controls/accept-opened-button.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ class AcceptOpenedButton extends Component {
1111
isSuiteContol: PropTypes.bool,
1212
// from store
1313
processing: PropTypes.bool.isRequired,
14-
acceptableOpenedImageIds: PropTypes.arrayOf(PropTypes.string).isRequired
14+
acceptableOpenedImageIds: PropTypes.arrayOf(PropTypes.string).isRequired,
15+
isStaticImageAccepterEnabled: PropTypes.bool,
16+
actions: PropTypes.object.isRequired
1517
};
1618

1719
_acceptOpened = () => {
@@ -39,7 +41,7 @@ export default connect(
3941
return {
4042
processing: state.processing,
4143
acceptableOpenedImageIds: getAcceptableOpenedImageIds(state),
42-
isStaticImageAccepterEnabled: state.staticImageAccepter.enabled,
44+
isStaticImageAccepterEnabled: state.staticImageAccepter.enabled
4345
};
4446
},
4547
(dispatch) => ({actions: bindActionCreators(actions, dispatch)})

lib/static/components/controls/browser-list/index.jsx

Lines changed: 44 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,47 @@
11
'use strict';
22

3-
import React, {useState, useMemo, useEffect, useCallback} from 'react';
4-
import {flatten, isEmpty, get, chain, compact} from 'lodash';
3+
import React, {useState, useMemo, useEffect} from 'react';
4+
import {compact} from 'lodash';
55
import PropTypes from 'prop-types';
6-
import CheckboxTree from 'react-checkbox-tree';
76

87
import {mkBrowserIcon, buildComplexId} from './utils';
9-
import Popup from '../../popup';
10-
import ArrayContainer from '../../../containers/array';
118

129
import 'react-checkbox-tree/lib/react-checkbox-tree.css';
1310
import './index.styl';
14-
import { Button, Select, useSelectOptions } from '@gravity-ui/uikit';
11+
import {Button, Select, useSelectOptions} from '@gravity-ui/uikit';
1512

1613
const BrowserList = ({available, onChange, selected: selectedProp}) => {
1714
const getOptions = () => {
1815
const groups = {};
19-
const DEFAULT_GROUP = "other";
16+
const DEFAULT_GROUP = 'other';
2017
let hasNestedOptions = false;
2118
available.forEach(({id: browserId, versions}) => {
2219
if (!versions || versions.length < 2) {
2320
groups[DEFAULT_GROUP] = groups[DEFAULT_GROUP] || [];
24-
groups[DEFAULT_GROUP].push({value: buildComplexId(browserId),
21+
groups[DEFAULT_GROUP].push({value: buildComplexId(browserId),
2522
content: <div className='browser-name'>{mkBrowserIcon(browserId)}{buildComplexId(browserId)}</div>});
2623
return;
2724
}
2825
hasNestedOptions = true;
2926
versions.forEach((version) => {
3027
groups[browserId] = groups[browserId] || [];
31-
groups[browserId].push({value: buildComplexId(browserId, version),
28+
groups[browserId].push({value: buildComplexId(browserId, version),
3229
content: <div className='browser-name'>{mkBrowserIcon(browserId)}{buildComplexId(browserId, version)}</div>});
33-
})
30+
});
3431
});
3532
if (!hasNestedOptions) {
3633
return groups[DEFAULT_GROUP];
37-
}
38-
else {
34+
} else {
3935
const optionsList = [];
4036
Object.keys(groups).forEach((name) => {
4137
optionsList.push({
4238
label: name,
4339
options: groups[name]
44-
})
45-
})
40+
});
41+
});
4642
return optionsList;
4743
}
48-
49-
}
44+
};
5045
const getMapping = () => {
5146
const mapping = {};
5247
available.forEach(({id: browserId, versions}) => {
@@ -60,10 +55,10 @@ const BrowserList = ({available, onChange, selected: selectedProp}) => {
6055
}
6156
versions.forEach((version) => {
6257
mapping[buildComplexId(browserId, version)] = {id: browserId, version};
63-
})
58+
});
6459
});
6560
return mapping;
66-
}
61+
};
6762
const getSelected = () => {
6863
const selectedOptions = [];
6964
if (!selectedProp || !selectedProp.length) {
@@ -76,23 +71,22 @@ const BrowserList = ({available, onChange, selected: selectedProp}) => {
7671
}
7772
versions.forEach((version) => {
7873
selectedOptions.push(buildComplexId(browserId, version));
79-
})
74+
});
8075
});
8176
return selectedOptions;
82-
}
77+
};
8378
const rawOptions = useMemo(getOptions, [available]);
8479
const getOptionsFrom = (optionsData) => {
8580
const allOptionsList = [];
8681
optionsData.forEach((option) => {
8782
if (option.label) {
8883
getOptionsFrom(option.options).forEach((o) => allOptionsList.push(o));
89-
}
90-
else {
84+
} else {
9185
allOptionsList.push(option.value);
9286
}
93-
})
87+
});
9488
return allOptionsList;
95-
}
89+
};
9690
const allOptions = useMemo(() => getOptionsFrom(rawOptions), [rawOptions]);
9791
const options = useSelectOptions({
9892
options: rawOptions
@@ -102,52 +96,53 @@ const BrowserList = ({available, onChange, selected: selectedProp}) => {
10296

10397
const selectAll = () => {
10498
setSelected(allOptions);
105-
}
99+
};
106100

107101
const formatSelectedData = () => {
108-
const selectedData = {}
102+
const selectedData = {};
109103
selected.forEach((option) => {
110-
if (!mapping[option] || !mapping[option].id) return;
104+
if (!mapping[option] || !mapping[option].id) {
105+
return;
106+
}
111107
const {id: browserId, version} = mapping[option];
112108
selectedData[browserId] = selectedData[browserId] || [];
113109
selectedData[browserId].push(version);
114-
})
115-
return Object.entries(selectedData).map(([id, versions]) => ({id, versions: compact(versions)}))
116-
}
110+
});
111+
return Object.entries(selectedData).map(([id, versions]) => ({id, versions: compact(versions)}));
112+
};
117113

118114
const renderFilter = () => {
119-
const allSelected = selected.length == options.length;
120115
return (
121116
<div className='browserlist__filter'>
122-
<Button onClick={selectAll} width='max'>
117+
<Button onClick={selectAll} width='max'>
123118
Select All
124-
</Button>
119+
</Button>
125120
</div>
126-
)
127-
}
121+
);
122+
};
128123

129124
const renderOption = (option) => {
130-
const isTheOnlySelected = selected.includes(option.value) && selected.length == 1;
125+
const isTheOnlySelected = selected.includes(option.value) && selected.length === 1;
131126
const selectOnly = (e) => {
132127
e.preventDefault();
133128
e.stopPropagation();
134129
setSelected([option.value]);
135-
}
130+
};
136131
const selectExcept = (e) => {
137132
e.preventDefault();
138133
e.stopPropagation();
139-
setSelected(allOptions.filter(o => o != option.value));
140-
}
134+
setSelected(allOptions.filter(o => o !== option.value));
135+
};
141136
return (
142-
<div className='browserlist__row'>
143-
<div className='browserlist__row_content'>
144-
{option.content}
137+
<div className='browserlist__row'>
138+
<div className='browserlist__row_content'>
139+
{option.content}
140+
</div>
141+
<Button size='s' onClick={isTheOnlySelected ? selectExcept : selectOnly} className='action-button'>{isTheOnlySelected ? 'Except' : 'Only'}</Button>
145142
</div>
146-
<Button size='s' onClick={isTheOnlySelected ? selectExcept : selectOnly} className='action-button'>{isTheOnlySelected ? 'Except' : 'Only'}</Button>
147-
</div>
148-
)
149-
}
150-
143+
);
144+
};
145+
151146
useEffect(() => {
152147
onChange && onChange(formatSelectedData(selected));
153148
}, [selected]);
@@ -166,8 +161,8 @@ const BrowserList = ({available, onChange, selected: selectedProp}) => {
166161
popupClassName='browserlist__popup'
167162
className='browserlist'
168163
/>
169-
)
170-
}
164+
);
165+
};
171166

172167
BrowserList.propTypes = {
173168
available: PropTypes.arrayOf(PropTypes.shape({

lib/static/components/controls/common-controls.jsx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, {Component} from 'react';
2+
import PropTypes from 'prop-types';
23
import {bindActionCreators} from 'redux';
34
import {connect} from 'react-redux';
4-
import {capitalize, pull} from 'lodash';
5+
import {capitalize} from 'lodash';
56
import * as actions from '../../modules/actions';
6-
import ControlButton from './control-button';
77
import ControlSelect from './selects/control';
88
import GroupTestsSelect from './selects/group-tests';
99
import BaseHostInput from './base-host-input';
@@ -12,20 +12,30 @@ import ReportInfo from './report-info';
1212
import {ViewMode} from '../../../constants/view-modes';
1313
import {DiffModes} from '../../../constants/diff-modes';
1414
import {EXPAND_ALL, COLLAPSE_ALL, EXPAND_ERRORS, EXPAND_RETRIES} from '../../../constants/expand-modes';
15-
import { RadioButton, Select } from '@gravity-ui/uikit';
1615

1716
class ControlButtons extends Component {
17+
static propTypes = {
18+
view: PropTypes.shape({
19+
expand: PropTypes.string.isRequired,
20+
viewMode: PropTypes.string.isRequired,
21+
diffMode: PropTypes.string.isRequired,
22+
changeViewMode: PropTypes.func.isRequired
23+
}),
24+
isStatisImageAccepterEnabled: PropTypes.bool,
25+
actions: PropTypes.object.isRequired
26+
};
27+
1828
_onUpdateExpand = (value) => {
1929
const {actions} = this.props;
2030
const actionsDict = {
2131
[EXPAND_ALL]: actions.expandAll,
2232
[COLLAPSE_ALL]: actions.collapseAll,
2333
[EXPAND_ERRORS]: actions.expandErrors,
2434
[EXPAND_RETRIES]: actions.expandRetries
25-
}
35+
};
2636
actionsDict[value].call();
27-
}
28-
37+
};
38+
2939
_getShowTestsOptions() {
3040
const viewModes = Object.values(ViewMode).map(value => ({value, content: capitalize(value)}));
3141

@@ -46,17 +56,17 @@ class ControlButtons extends Component {
4656
handler={actions.changeViewMode}
4757
options = {this._getShowTestsOptions()}
4858
/>
49-
<ControlSelect
59+
<ControlSelect
5060
size='m'
5161
label="Expand"
5262
value={view.expand}
53-
handler={this._onUpdateExpand}
63+
handler={this._onUpdateExpand}
5464
qa='expand-dropdown'
5565
options={[
56-
{value: EXPAND_ALL, content: "All"},
57-
{value: COLLAPSE_ALL, content: "None"},
58-
{value: EXPAND_ERRORS, content: "Errors"},
59-
{value: EXPAND_RETRIES, content: "Retries"}
66+
{value: EXPAND_ALL, content: 'All'},
67+
{value: COLLAPSE_ALL, content: 'None'},
68+
{value: EXPAND_ERRORS, content: 'Errors'},
69+
{value: EXPAND_RETRIES, content: 'Retries'}
6070
]}
6171
extendClassNames='expand-dropdown'
6272
extendPopupClassNames='expand-popup'

lib/static/components/controls/common-filters.jsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
import React from 'react';
4+
import PropTypes from 'prop-types';
45
import {bindActionCreators} from 'redux';
56
import {connect} from 'react-redux';
67
import * as actions from '../../modules/actions';
@@ -10,11 +11,12 @@ import ShowCheckboxesInput from './show-checkboxes-input';
1011
import BrowserList from './browser-list';
1112
import ControlButton from './control-button';
1213
import AcceptOpenedButton from './accept-opened-button';
14+
import {staticImageAccepterPropType} from '../../modules/static-image-accepter';
1315

1416
const CommonFilters = (props) => {
1517
const onCommitChanges = () => {
1618
props.actions.staticAccepterOpenConfirm();
17-
}
19+
};
1820

1921
const renderStaticImageAccepterControls = () => {
2022
const {staticImageAccepter} = props;
@@ -34,8 +36,8 @@ const CommonFilters = (props) => {
3436
handler={onCommitChanges}
3537
/>
3638
</div>
37-
)
38-
}
39+
);
40+
};
3941

4042
return (
4143
<div className="control-container control-filters">
@@ -50,14 +52,28 @@ const CommonFilters = (props) => {
5052
{renderStaticImageAccepterControls()}
5153
</div>
5254
);
53-
}
55+
};
56+
57+
CommonFilters.propTypes = {
58+
gui: PropTypes.bool.isRequired,
59+
browsers: PropTypes.arrayOf(PropTypes.shape({
60+
id: PropTypes.string,
61+
versions: PropTypes.arrayOf(PropTypes.string)
62+
})).isRequired,
63+
filteredBrowsers: PropTypes.arrayOf(PropTypes.shape({
64+
id: PropTypes.string,
65+
versions: PropTypes.arrayOf(PropTypes.string)
66+
})),
67+
staticImageAccepter: staticImageAccepterPropType,
68+
actions: PropTypes.object.isRequired
69+
};
5470

5571
export default connect(
5672
({view, browsers, gui, staticImageAccepter}) => ({
5773
filteredBrowsers: view.filteredBrowsers,
5874
browsers,
5975
gui,
60-
staticImageAccepter,
76+
staticImageAccepter
6177
}),
6278
(dispatch) => ({actions: bindActionCreators(actions, dispatch)})
6379
)(CommonFilters);

0 commit comments

Comments
 (0)