Skip to content

Commit 6423e1e

Browse files
author
david califf
committed
linted, cleaned
1 parent 15f1d60 commit 6423e1e

File tree

4 files changed

+116
-116
lines changed

4 files changed

+116
-116
lines changed

Diff for: packages/selenium-ide/src/neo/components/TestRow/index.jsx

+38-40
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
// under the License.
1717

1818
import React from 'react'
19-
import Modifier from 'modifier-keys'
2019
import PropTypes from 'prop-types'
2120
import { observer } from 'mobx-react'
2221
import classNames from 'classnames'
@@ -135,23 +134,23 @@ class TestRow extends React.Component {
135134
setContextMenu: PropTypes.func,
136135
level: PropTypes.number,
137136
scrollToLastPos: PropTypes.func,
138-
selectCommandByRange: PropTypes.func
137+
selectCommandByRange: PropTypes.func,
139138
}
140139
componentDidMount() {
141140
if (this.props.selected) {
142-
console.log('focus')
143141
this.node.focus()
144142
this.props.scrollToLastPos()
145143
this.props.setSectionFocus('editor', () => {
146-
console.log('set section focus')
147144
this.node.focus()
148145
})
149146
}
150147
}
151148
componentDidUpdate(prevProps) {
152-
console.log('should focus', this.props.selected, !prevProps.selected,this.props.lastSelected)
153-
if (this.props.selected && !prevProps.selected && this.props.lastSelected) {
154-
console.log('focus')
149+
if (
150+
this.props.selected &&
151+
!prevProps.lastSelected &&
152+
this.props.lastSelected
153+
) {
155154
this.scrollToRowIfNeeded(this.node)
156155
this.node.focus()
157156
this.props.setSectionFocus('editor', () => {
@@ -178,7 +177,7 @@ class TestRow extends React.Component {
178177
noModifiers &&
179178
(e.key === 'Delete' || e.key == 'Backspace')
180179
) {
181-
this.remove()
180+
this.remove(this.props.index)
182181
} else if (!this.props.isPristine && noModifiers && key === 'B') {
183182
this.props.command.toggleBreakpoint()
184183
} else if (!this.props.isPristine && noModifiers && key === 'S') {
@@ -193,8 +192,8 @@ class TestRow extends React.Component {
193192
this.props.executeCommand(this.props.command)
194193
} else if (this.props.moveSelection && noModifiers && e.key === 'ArrowUp') {
195194
e.preventDefault()
196-
if(!e.shiftKey){
197-
this.props.clearAllSelectedCommands();
195+
if (!e.shiftKey) {
196+
this.props.clearAllSelectedCommands()
198197
}
199198
this.props.moveSelection(this.props.index - 1)
200199
} else if (
@@ -203,8 +202,8 @@ class TestRow extends React.Component {
203202
e.key === 'ArrowDown'
204203
) {
205204
e.preventDefault()
206-
if(!e.shiftKey){
207-
this.props.clearAllSelectedCommands();
205+
if (!e.shiftKey) {
206+
this.props.clearAllSelectedCommands()
208207
}
209208
this.props.moveSelection(this.props.index + 1)
210209
} else if (!this.props.isPristine && onlyPrimary && key === 'X') {
@@ -242,43 +241,37 @@ class TestRow extends React.Component {
242241
}
243242
}
244243
select(e) {
245-
console.log('select event')
246-
if((e.type == 'contextmenu' || e.type == 'mousedown') && this.props.selected){
244+
if (
245+
(e.type == 'contextmenu' || e.type == 'mousedown') &&
246+
this.props.selected
247+
) {
247248
return
248249
}
249-
if(e.type == 'click' && (e.shiftKey||this.props.lastSelected)){
250-
if(!e.shiftKey){
251-
this.props.clearAllSelectedCommands();
250+
251+
if (e.type == 'click' && (e.shiftKey || this.props.lastSelected)) {
252+
if (!e.shiftKey) {
253+
this.props.clearAllSelectedCommands()
252254
this.props.select(this.props.command)
253255
}
254-
return;
256+
return
255257
}
256-
if( e && e.shiftKey===false){
257-
this.props.clearAllSelectedCommands();
258+
259+
if (e && e.shiftKey === false) {
260+
this.props.clearAllSelectedCommands()
258261
}
259-
if(this.props.isPristine){
260-
this.props.clearAllSelectedCommands();
262+
if (this.props.isPristine) {
263+
this.props.clearAllSelectedCommands()
261264
}
262-
if(e && e.shiftKey){
263-
if(this.props.isPristine){
264-
this.props.clearAllSelectedCommands();
265-
this.props.select(this.props.command)
266-
}
267-
else{
268-
console.log('selectcommandbyrange')
269-
this.props.selectCommandByRange(this.props.command, this.props.index)
270-
this.props.select(this.props.command)
271-
}
272-
}
273-
else{
274-
console.log('select')
275-
this.props.select(this.props.command)
265+
if (e && e.shiftKey && !this.props.isPristine) {
266+
this.props.selectCommandByRange(this.props.index)
276267
}
268+
269+
this.props.select(this.props.command)
277270
}
278-
279-
remove() {
271+
272+
remove(index) {
280273
if (!this.props.readOnly) {
281-
this.props.remove()
274+
this.props.remove(index)
282275
}
283276
}
284277
async clearAll() {
@@ -324,7 +317,12 @@ class TestRow extends React.Component {
324317
>
325318
Paste
326319
</ListMenuItem>
327-
<ListMenuItem label="Del" onClick={this.remove}>
320+
<ListMenuItem
321+
label="Del"
322+
onClick={() => {
323+
this.remove(this.props.index)
324+
}}
325+
>
328326
Delete
329327
</ListMenuItem>
330328
<ListMenuSeparator />

Diff for: packages/selenium-ide/src/neo/components/TestTable/index.jsx

+29-19
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default class TestTable extends React.Component {
4242
)
4343
this.commandLevels = []
4444
this.node = null
45-
this.selectCommandByRange = this.selectCommandByRange.bind(this);
45+
this.selectCommandByRange = this.selectCommandByRange.bind(this)
4646
}
4747
static propTypes = {
4848
commands: MobxPropTypes.arrayOrObservableArray,
@@ -51,10 +51,10 @@ export default class TestTable extends React.Component {
5151
selectedCommands: MobxPropTypes.arrayOrObservableArray,
5252
selectCommand: PropTypes.func,
5353
addCommand: PropTypes.func,
54-
removeCommand: PropTypes.func,
54+
removeSelectedCommands: PropTypes.func,
5555
swapCommands: PropTypes.func,
5656
clearAllCommands: PropTypes.func,
57-
clearAllSelectedCommand: PropTypes.func
57+
clearAllSelectedCommand: PropTypes.func,
5858
}
5959
detectNewCommand(change) {
6060
this.newCommand = change.added[0]
@@ -80,16 +80,17 @@ export default class TestTable extends React.Component {
8080
}
8181
}
8282
}
83-
selectCommandByRange(lastCommandSelected,index){
84-
if(this.props.selectedCommands.length > 0){
85-
let fromIndex = this.props.commands.indexOf(this.props.selectedCommands[0])
86-
fromIndex = fromIndex == -1 ? index : fromIndex
83+
selectCommandByRange(index) {
84+
if (this.props.selectedCommands.length > 0) {
85+
let fromIndex = this.props.commands.indexOf(
86+
this.props.selectedCommands[0]
87+
)
88+
fromIndex = fromIndex == -1 ? index : fromIndex
8789
const toIndex = index
88-
const from = fromIndex > toIndex ? toIndex : fromIndex;
89-
const to = fromIndex > toIndex ? fromIndex : toIndex;
90-
for(let i = from; i <= to; i++){
91-
console.log('adding')
92-
UiState.addToSelectedCommands(this.props.commands[i]);
90+
const from = fromIndex > toIndex ? toIndex : fromIndex
91+
const to = fromIndex > toIndex ? fromIndex : toIndex
92+
for (let i = from; i <= to; i++) {
93+
UiState.addToSelectedCommands(this.props.commands[i])
9394
}
9495
}
9596
}
@@ -146,8 +147,13 @@ export default class TestTable extends React.Component {
146147
).state
147148
: ''
148149
)}
149-
selected= {this.props.selectedCommand === command.id || !!this.props.selectedCommands.find((cmd) => (cmd.id === command.id))}
150-
lastSelected = { this.props.selectedCommand === command.id }
150+
selected={
151+
this.props.selectedCommand === command.id ||
152+
!!this.props.selectedCommands.find(
153+
cmd => cmd.id === command.id
154+
)
155+
}
156+
lastSelected={this.props.selectedCommand === command.id}
151157
readOnly={PlaybackState.isPlaying}
152158
singleCommandExecutionEnabled={
153159
PlaybackState.isSingleCommandExecutionEnabled
@@ -162,17 +168,19 @@ export default class TestTable extends React.Component {
162168
scrollToLastPos={this.scrollToLastPos}
163169
isPristine={false}
164170
select={this.props.selectCommand}
165-
selectCommandByRange = {this.selectCommandByRange}
171+
selectCommandByRange={this.selectCommandByRange}
166172
startPlayingHere={PlaybackState.startPlaying}
167173
executeCommand={PlaybackState.playCommand}
168174
moveSelection={UiState.selectCommandByIndex}
169175
addCommand={this.props.addCommand}
170-
remove={this.props.removeCommand}
176+
remove={this.props.removeSelectedCommands}
171177
swapCommands={this.props.swapCommands}
172178
copyToClipboard={UiState.copyToClipboard}
173179
pasteFromClipboard={UiState.pasteFromClipboard}
174-
clearAllCommands= {this.props.clearAllCommands}
175-
clearAllSelectedCommands = {this.props.clearAllSelectedCommands}
180+
clearAllCommands={this.props.clearAllCommands}
181+
clearAllSelectedCommands={
182+
this.props.clearAllSelectedCommands
183+
}
176184
setSectionFocus={UiState.setSectionFocus}
177185
level={this.commandLevels[index]}
178186
/>
@@ -193,7 +201,9 @@ export default class TestTable extends React.Component {
193201
moveSelection={UiState.selectCommandByIndex}
194202
pasteFromClipboard={UiState.pasteFromClipboard}
195203
setSectionFocus={UiState.setSectionFocus}
196-
clearAllSelectedCommands = {this.props.clearAllSelectedCommands}
204+
clearAllSelectedCommands={
205+
this.props.clearAllSelectedCommands
206+
}
197207
/>
198208
)
199209
: null}

Diff for: packages/selenium-ide/src/neo/containers/Editor/index.jsx

+12-16
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default class Editor extends React.Component {
3838
constructor(props) {
3939
super(props)
4040
this.addCommand = this.addCommand.bind(this)
41-
this.removeCommand = this.removeCommand.bind(this)
41+
this.removeSelectedCommands = this.removeSelectedCommands.bind(this)
4242
}
4343
addCommand(index, command) {
4444
if (command) {
@@ -50,18 +50,18 @@ export default class Editor extends React.Component {
5050
return newCommand
5151
}
5252
}
53-
removeCommand() {
54-
const { test } = this.props;
55-
UiState.selectedCommands.forEach((command) =>
56-
test.removeCommand(command)
57-
);
53+
removeSelectedCommands(index) {
54+
const { test } = this.props
55+
index = index - (UiState.selectedCommands.length - 1)
56+
index = Math.max(index, 0)
57+
UiState.selectedCommands.forEach(command => test.removeCommand(command))
5858
UiState.clearAllSelectedCommands()
5959
if (test.commands.length > index) {
60-
UiState.selectCommand(test.commands[index]);
60+
UiState.selectCommand(test.commands[index])
6161
} else if (test.commands.length) {
62-
UiState.selectCommand(test.commands[test.commands.length - 1]);
62+
UiState.selectCommand(test.commands[test.commands.length - 1])
6363
} else {
64-
UiState.selectCommand(UiState.pristineCommand);
64+
UiState.selectCommand(UiState.pristineCommand)
6565
}
6666
}
6767
handleKeyDown(event) {
@@ -95,18 +95,14 @@ export default class Editor extends React.Component {
9595
selectedCommand={
9696
UiState.selectedCommand ? UiState.selectedCommand.id : null
9797
}
98-
selectedCommands = {
99-
UiState.selectedCommands
100-
}
98+
selectedCommands={UiState.selectedCommands}
10199
selectCommand={UiState.selectCommand}
102100
addCommand={this.addCommand}
103-
removeCommand={this.removeCommand}
101+
removeSelectedCommands={this.removeSelectedCommands}
104102
clearAllCommands={
105103
this.props.test ? this.props.test.clearAllCommands : null
106104
}
107-
clearAllSelectedCommands={
108-
UiState.clearAllSelectedCommands
109-
}
105+
clearAllSelectedCommands={UiState.clearAllSelectedCommands}
110106
swapCommands={this.props.test ? this.props.test.swapCommands : null}
111107
/>
112108
<CommandForm

0 commit comments

Comments
 (0)