-
Notifications
You must be signed in to change notification settings - Fork 72
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
Showing
39 changed files
with
721 additions
and
1,131 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
File renamed without changes.
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,83 @@ | ||
import React, { Component } from 'react' | ||
import PropTypes from 'prop-types' | ||
import { | ||
Card, | ||
Col, | ||
ControlLabel, | ||
FormGroup, | ||
FieldLevelHelp, | ||
} from 'patternfly-react' | ||
|
||
import style from './style.css' | ||
|
||
const LabelCol = ({ children, tooltip, ...props }) => { | ||
return <Col componentClass={ControlLabel} {...props}> | ||
{ children } { tooltip && <FieldLevelHelp disabled={false} content={tooltip} inline /> } | ||
</Col> | ||
} | ||
LabelCol.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
tooltip: PropTypes.string, | ||
} | ||
|
||
const Item = ({ title, isActive, onClick }) => { | ||
return <li className={`list-group-item ${isActive && 'active'}`}> | ||
<a href='#' onClick={(e) => { e.preventDefault(); onClick() }}> | ||
<span className='list-group-item-value'>{title}</span> | ||
<div className='badge-container-pf' /> | ||
</a> | ||
</li> | ||
} | ||
|
||
Item.propTypes = { | ||
title: PropTypes.string.isRequired, | ||
isActive: PropTypes.bool, | ||
onClick: PropTypes.func.isRequired, | ||
} | ||
|
||
const Section = ({ name, section }) => ( | ||
<React.Fragment> | ||
<h3><a id={name} />{section.title} { section.tooltip && <FieldLevelHelp disabled={false} content={section.tooltip} inline /> }</h3> | ||
{ section.fields.map((field) => ( | ||
<FormGroup key={field.title} className={style['settings-field']}> | ||
<LabelCol tooltip={field.tooltip} sm={3} className={style['field-label']}> | ||
{ field.title } | ||
</LabelCol> | ||
<Col sm={9}> | ||
{field.body} | ||
</Col> | ||
</FormGroup> | ||
)) } | ||
</React.Fragment> | ||
) | ||
|
||
Section.propTypes = { | ||
name: PropTypes.string.isRequired, | ||
section: PropTypes.object.isRequired, | ||
} | ||
|
||
class SettingsBase extends Component { | ||
buildSection (key, section) { | ||
return ( | ||
<Card key={key} className={style['main-content']}> | ||
<div className={style['main-content-container']}> | ||
<Section name={key} section={section} /> | ||
</div> | ||
</Card> | ||
) | ||
} | ||
|
||
render () { | ||
const { sections } = this.props | ||
return ( | ||
<div className={style['search-content-box']}> | ||
{Object.entries(sections).filter(([key, section]) => !!section).map(([key, section]) => this.buildSection(key, section))} | ||
</div> | ||
) | ||
} | ||
} | ||
SettingsBase.propTypes = { | ||
sections: PropTypes.object.isRequired, | ||
} | ||
|
||
export default SettingsBase |
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,64 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import PropTypes from 'prop-types' | ||
import { Toolbar } from 'patternfly-react' | ||
import { msg } from '_/intl' | ||
|
||
import style from './style.css' | ||
|
||
class SettingsToolbar extends React.Component { | ||
constructor (props) { | ||
super(props) | ||
this.el = document.createElement('div') | ||
} | ||
|
||
componentDidMount () { | ||
const root = document.getElementById('settings-toolbar') | ||
if (root) { | ||
root.appendChild(this.el) | ||
} | ||
} | ||
|
||
componentWillUnmount () { | ||
const root = document.getElementById('settings-toolbar') | ||
if (root) { | ||
root.removeChild(this.el) | ||
} | ||
} | ||
render () { | ||
const { onSave, onCancel } = this.props | ||
const body = <Toolbar className={style['toolbar']}> | ||
<Toolbar.RightContent> | ||
<button | ||
onClick={e => { | ||
e.preventDefault() | ||
onCancel() | ||
}} | ||
className='btn btn-default' | ||
> | ||
{msg.cancel()} | ||
</button> | ||
<button | ||
onClick={e => { | ||
e.preventDefault() | ||
onSave() | ||
}} | ||
className='btn btn-primary' | ||
> | ||
{msg.save()} | ||
</button> | ||
</Toolbar.RightContent> | ||
</Toolbar> | ||
return ReactDOM.createPortal( | ||
body, | ||
this.el | ||
) | ||
} | ||
} | ||
|
||
SettingsToolbar.propTypes = { | ||
onSave: PropTypes.func.isRequired, | ||
onCancel: PropTypes.func.isRequired, | ||
} | ||
|
||
export default SettingsToolbar |
Oops, something went wrong.