-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: repair SuperscalarConfigModal layout (#130)
- Loading branch information
Showing
11 changed files
with
713 additions
and
699 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
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 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
145 changes: 72 additions & 73 deletions
145
src/interface/components/Superescalar/modal/OptionsModalComponent.tsx
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 |
---|---|---|
@@ -1,82 +1,81 @@ | ||
import * as React from 'react'; | ||
import { Modal, Button } from 'react-bootstrap'; | ||
import { withTranslation } from 'react-i18next'; | ||
import { bindActionCreators } from 'redux'; | ||
import { toggleOptionsModal } from '../../../actions/modals'; | ||
import { connect } from 'react-redux'; | ||
import SuperescalarIntegration from '../../../../integration/superescalar-integration'; | ||
import type * as React from "react"; | ||
import { Alert, Button, Modal } from "react-bootstrap"; | ||
import { type WithTranslation, withTranslation } from "react-i18next"; | ||
import { type Dispatch, type UnknownAction, bindActionCreators } from "redux"; | ||
import { toggleOptionsModal } from "../../../actions/modals"; | ||
import { connect } from "react-redux"; | ||
|
||
class OptionsModalComponent extends React.Component<any, any> { | ||
const mapStateToProps = (state) => { | ||
return { | ||
isOptionsModalOpen: state.Ui.isOptionsModalOpen, | ||
}; | ||
}; | ||
|
||
constructor(public props: any) { | ||
super(props); | ||
|
||
this.close = this.close.bind(this); | ||
this.setOptions = this.setOptions.bind(this); | ||
this.handleChange = this.handleChange.bind(this); | ||
this.state = { | ||
cacheFailPercentage: 0 | ||
} | ||
} | ||
function mapDispatchToProps(dispatch: Dispatch<UnknownAction>) { | ||
return { actions: bindActionCreators({ toggleOptionsModal }, dispatch) }; | ||
} | ||
|
||
close() { | ||
this.props.actions.toggleOptionsModal(false); | ||
}; | ||
export type OptionsModalProps = WithTranslation & | ||
ReturnType<typeof mapStateToProps> & | ||
ReturnType<typeof mapDispatchToProps>; | ||
|
||
handleChange(event) { | ||
let newState = {...this.state}; | ||
newState.cacheFailPercentage = event.target.value; | ||
this.setState(newState); | ||
} | ||
export const OptionsModalComponent: React.FC = ({ | ||
actions, | ||
isOptionsModalOpen, | ||
t, | ||
}: OptionsModalProps) => { | ||
const cacheFailPercentage = 0; | ||
|
||
setOptions() { | ||
// SuperescalarIntegration.setOptions(this.state.cacheFailPercentage); | ||
this.close(); | ||
} | ||
const close = () => { | ||
actions.toggleOptionsModal(false); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<Modal show={this.props.isOptionsModalOpen} onHide={this.close}> | ||
<Modal.Header closeButton> | ||
<Modal.Title>{this.props.t('optionsModal.title')}</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<form className='form form-horizontal'> | ||
<div className='form-group'> | ||
<div className='col-sm-4'> | ||
<label htmlFor='cacheFailPercentage' className='control-label'>{this.props.t('optionsModal.cacheFault')} | ||
</label> | ||
</div> | ||
<div className='col-sm-8'> | ||
<input | ||
className='form-control' | ||
name='cacheFailPercentage' | ||
type='number' | ||
min='0' | ||
max='100' | ||
value={this.state.cacheFailPercentage} | ||
onChange={this.handleChange} | ||
/> | ||
</div> | ||
</div> | ||
</form> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<Button onClick={this.close}>{this.props.t('commonButtons.close')}</Button> | ||
<Button className='btn btn-primary' onClick={this.setOptions}>{this.props.t('commonButtons.save')}</Button> | ||
</Modal.Footer> | ||
</Modal>); | ||
} | ||
} | ||
const handleChange = (event) => { | ||
// setState({ ...state, cacheFailPercentage: event.target.value }); | ||
}; | ||
|
||
const mapStateToProps = state => { | ||
return { | ||
isOptionsModalOpen: state.Ui.isOptionsModalOpen, | ||
} | ||
} | ||
const setOptions = () => { | ||
close(); | ||
}; | ||
|
||
function mapDispatchToProps(dispatch) { | ||
return { actions: bindActionCreators({toggleOptionsModal}, dispatch)}; | ||
} | ||
return ( | ||
<Modal show={isOptionsModalOpen} onHide={close}> | ||
<Modal.Header closeButton> | ||
<Modal.Title>{t("optionsModal.title")}</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<form className="form form-horizontal"> | ||
<div className="form-group"> | ||
<div className="col-sm-4"> | ||
<label htmlFor="cacheFailPercentage" className="control-label"> | ||
{t("optionsModal.cacheFault")} | ||
</label> | ||
</div> | ||
<div className="col-sm-8"> | ||
<input | ||
className="form-control" | ||
name="cacheFailPercentage" | ||
type="number" | ||
min="0" | ||
max="100" | ||
value={cacheFailPercentage} | ||
onChange={handleChange} | ||
/> | ||
</div> | ||
</div> | ||
</form> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<Button onClick={close}>{t("commonButtons.close")}</Button> | ||
<Button className="btn btn-primary" onClick={setOptions}> | ||
{t("commonButtons.save")} | ||
</Button> | ||
</Modal.Footer> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(withTranslation()(OptionsModalComponent)); | ||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps, | ||
)(withTranslation()(OptionsModalComponent)); |
Oops, something went wrong.