-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13574f4
commit d3190c1
Showing
37 changed files
with
1,904 additions
and
452 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
UNCHECKED: 0, | ||
INDETERMINATE: 0.5, | ||
CHECKED: 1 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
import {Checkbox} from 'semantic-ui-react'; | ||
import PropTypes from 'prop-types'; | ||
import {isCheckboxChecked, isCheckboxIndeterminate} from '../../common-utils'; | ||
import {CHECKED, INDETERMINATE, UNCHECKED} from '../../constants/checked-statuses'; | ||
import useLocalStorage from '../hooks/useLocalStorage'; | ||
|
||
const Bullet = ({status, onClick, className}) => { | ||
const [isCheckbox] = useLocalStorage('showCheckboxes', false); | ||
|
||
if (!isCheckbox) { | ||
return <span className={classNames('bullet_type-simple', className)} />; | ||
} | ||
|
||
return <Checkbox | ||
className={classNames('bullet_type-checkbox', className)} | ||
checked={isCheckboxChecked(status)} | ||
indeterminate={isCheckboxIndeterminate(status)} | ||
onClick={onClick} | ||
/>; | ||
}; | ||
|
||
Bullet.propTypes = { | ||
status: PropTypes.oneOf([CHECKED, UNCHECKED, INDETERMINATE]), | ||
onClick: PropTypes.func, | ||
bulletClassName: PropTypes.string | ||
}; | ||
|
||
export default Bullet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
'use strict'; | ||
|
||
import React, {useEffect, useState} from 'react'; | ||
import {bindActionCreators} from 'redux'; | ||
import {isEmpty} from 'lodash'; | ||
import {connect} from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
import * as actions from '../../../modules/actions'; | ||
import Popup from '../../popup'; | ||
import {getFailedTests, getCheckedTests} from '../../../modules/selectors/tree'; | ||
import useLocalStorage from '../../../hooks/useLocalStorage'; | ||
|
||
import './index.styl'; | ||
|
||
const RunMode = Object.freeze({ | ||
ALL: 'All', | ||
FAILED: 'Failed', | ||
CHECKED: 'Checked' | ||
}); | ||
|
||
const RunButton = ({actions, autoRun, isDisabled, isRunning, failedTests, checkedTests}) => { | ||
const [mode, setMode] = useState(RunMode.ALL); | ||
const [showCheckboxes] = useLocalStorage('showCheckboxes', false); | ||
|
||
const btnClassName = classNames('btn', {'button_blink': isRunning}); | ||
|
||
const shouldDisableFailed = isEmpty(failedTests); | ||
const shouldDisableChecked = !showCheckboxes || isEmpty(checkedTests); | ||
|
||
const selectAllTests = () => setMode(RunMode.ALL); | ||
const selectFailedTests = () => !shouldDisableFailed && setMode(RunMode.FAILED); | ||
const selectCheckedTests = () => !shouldDisableChecked && setMode(RunMode.CHECKED); | ||
|
||
const runAllTests = () => actions.runAllTests(); | ||
const runFailedTests = () => actions.runFailedTests(failedTests); | ||
const runCheckedTests = () => actions.retrySuite(checkedTests); | ||
|
||
const handleRunClick = () => { | ||
const action = { | ||
[RunMode.ALL]: runAllTests, | ||
[RunMode.FAILED]: runFailedTests, | ||
[RunMode.CHECKED]: runCheckedTests | ||
}[mode]; | ||
|
||
action(); | ||
}; | ||
|
||
useEffect(() => { | ||
if (autoRun) { | ||
runAllTests(); | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
selectCheckedTests(); | ||
}, [shouldDisableChecked]); | ||
|
||
useEffect(() => { | ||
const shouldResetFailedMode = mode === RunMode.FAILED && shouldDisableFailed; | ||
const shouldResetCheckedMode = mode === RunMode.CHECKED && shouldDisableChecked; | ||
|
||
if (shouldResetFailedMode || shouldResetCheckedMode) { | ||
setMode(RunMode.ALL); | ||
} | ||
}, [shouldDisableFailed, shouldDisableChecked]); | ||
|
||
return ( | ||
<div className='run-button'> | ||
<button disabled={isDisabled} onClick={handleRunClick} className={btnClassName}> | ||
{isRunning ? 'Running' : `Run ${mode.toLowerCase()} tests`} | ||
</button> | ||
{!isDisabled && <Popup | ||
action='hover' | ||
hideOnClick={true} | ||
target={<div className='run-button__dropdown' />} | ||
> | ||
<ul className='run-mode'> | ||
<li | ||
className='run-mode__item' | ||
onClick={selectAllTests} | ||
> | ||
{RunMode.ALL} | ||
</li> | ||
<li | ||
className={classNames('run-mode__item', {'run-mode__item_disabled': shouldDisableFailed})} | ||
onClick={selectFailedTests}>{RunMode.FAILED} | ||
</li> | ||
<li | ||
className={classNames('run-mode__item', {'run-mode__item_disabled': shouldDisableChecked})} | ||
onClick={selectCheckedTests} | ||
> | ||
{RunMode.CHECKED} | ||
</li> | ||
</ul> | ||
</Popup>} | ||
</div> | ||
); | ||
}; | ||
|
||
RunButton.propTypes = { | ||
// from store | ||
autoRun: PropTypes.bool.isRequired, | ||
isDisabled: PropTypes.bool, | ||
isRunning: PropTypes.bool, | ||
failedTests: PropTypes.arrayOf(PropTypes.shape({ | ||
testName: PropTypes.string, | ||
browserName: PropTypes.string | ||
})).isRequired, | ||
checkedTests: PropTypes.arrayOf(PropTypes.shape({ | ||
testName: PropTypes.string, | ||
browserName: PropTypes.string | ||
})).isRequired | ||
}; | ||
|
||
export default connect( | ||
(state) => { | ||
const autoRun = state.autoRun; | ||
const allRootSuiteIds = state.tree.suites.allRootIds; | ||
const processing = state.processing; | ||
const isDisabled = !allRootSuiteIds.length || processing; | ||
const isRunning = state.running; | ||
const failedTests = getFailedTests(state); | ||
const checkedTests = getCheckedTests(state); | ||
|
||
return {autoRun, isDisabled, isRunning, failedTests, checkedTests}; | ||
}, | ||
(dispatch) => ({actions: bindActionCreators(actions, dispatch)}) | ||
)(RunButton); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
.run-button { | ||
display: inline-flex; | ||
align-items: center; | ||
cursor: pointer; | ||
width: 143px; | ||
font-size: 11px; | ||
line-height: 11px; | ||
border: 1px solid #ccc; | ||
border-radius: 2px; | ||
background-color: #ffeba0; | ||
|
||
.btn { | ||
flex-grow: 1; | ||
height: 100%; | ||
background-color: #ffeba0; | ||
cursor: pointer; | ||
border: none; | ||
} | ||
|
||
.run-button__dropdown { | ||
font-family: Dropdown; | ||
|
||
&::before { | ||
content: '\f0d7'; | ||
padding: 5px; | ||
border-left: 1px solid #ccc; | ||
} | ||
} | ||
|
||
.popup__content { | ||
padding: 0; | ||
} | ||
|
||
.run-mode { | ||
padding: 0; | ||
|
||
.run-mode__item { | ||
font-size: 13px; | ||
padding: 5px 10px; | ||
list-style: none; | ||
user-select: none; | ||
|
||
&.run-mode__item_disabled { | ||
color: #939393; | ||
cursor: auto; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
import React from 'react'; | ||
import {Checkbox} from 'semantic-ui-react'; | ||
import useLocalStorage from '../../hooks/useLocalStorage'; | ||
|
||
const ShowCheckboxesInput = () => { | ||
const [showCheckboxes, setShowCheckboxes] = useLocalStorage('showCheckboxes', false); | ||
|
||
const onChange = () => setShowCheckboxes(!showCheckboxes); | ||
|
||
return ( | ||
<div className="toggle-control"> | ||
<Checkbox | ||
toggle | ||
label="Checkboxes" | ||
onChange={onChange} | ||
checked={showCheckboxes} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ShowCheckboxesInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.