-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App mgmt pages #552
App mgmt pages #552
Changes from 6 commits
2f59a50
783ee7d
1ef96a1
a26f3e4
3ea6097
7d11ed0
16ddf65
7edf71d
332806a
7a2ff1d
22b32d0
6bf33fe
0f825f8
90b146a
5bcf9cd
720b331
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import React from 'react'; | ||
import classnames from 'classnames'; | ||
import PropTypes from 'prop-types'; | ||
import _ from 'lodash'; | ||
|
||
import Icon from '../Icon'; | ||
|
||
|
@@ -12,31 +13,55 @@ export default class Input extends React.Component { | |
disabled: PropTypes.bool, | ||
icon: PropTypes.string, | ||
iconSize: PropTypes.number, | ||
iconType: PropTypes.string | ||
iconType: PropTypes.string, | ||
valueChange: PropTypes.func | ||
}; | ||
|
||
static defaultProps = { | ||
className: '', | ||
icon: '', | ||
iconType: 'light', | ||
iconSize: 16, | ||
valueChange: _.noop, | ||
onChange: _.noop, | ||
disabled: false | ||
}; | ||
|
||
onChange = event => { | ||
const { target } = event; | ||
const value = target.type === 'checkbox' ? target.checked : target.value; | ||
const name = target.name; | ||
|
||
this.props.valueChange(name, value); | ||
this.props.onChange(event); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since you get target value, using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. valueChange pass the name param, I can use a generic function to change the store value |
||
}; | ||
|
||
render() { | ||
const { | ||
className, icon, iconType, iconSize, ...rest | ||
className, | ||
icon, | ||
iconType, | ||
iconSize, | ||
onChange, | ||
valueChange, | ||
...rest | ||
} = this.props; | ||
|
||
if (icon) { | ||
return ( | ||
<div className={classnames(styles.inputGroup, className)}> | ||
<Icon name={icon} type={iconType} size={iconSize} /> | ||
<input className={styles.input} {...rest} /> | ||
<input className={styles.input} onChange={this.onChange} {...rest} /> | ||
</div> | ||
); | ||
} | ||
|
||
return <input className={classnames(styles.input, className)} {...rest} />; | ||
return ( | ||
<input | ||
className={classnames(styles.input, className)} | ||
onChange={this.onChange} | ||
{...rest} | ||
/> | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Link } from 'react-router-dom'; | ||
import { translate } from 'react-i18next'; | ||
|
||
import links from 'config/doc-link'; | ||
|
||
@translate() | ||
export default class BaseLink extends Component { | ||
static propTypes = { | ||
liiil825 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
children: PropTypes.node, | ||
className: PropTypes.string, | ||
isExternal: PropTypes.bool, | ||
to: PropTypes.string, | ||
type: PropTypes.string | ||
}; | ||
|
||
static defaultProps = { | ||
children: null, | ||
className: '', | ||
isExternal: false, | ||
type: '' | ||
}; | ||
|
||
render() { | ||
const { | ||
t, to, type, children, className, isExternal | ||
} = this.props; | ||
let text = t(`LINK_${type}`); | ||
const linkTo = to || links[type]; | ||
if (text === `LINK_${type}`) { | ||
text = linkTo; | ||
} | ||
if (children) { | ||
text = children; | ||
} | ||
if (!text) { | ||
return null; | ||
} | ||
if (!linkTo) { | ||
console.error( | ||
"You should edit a link url in the file of 'config/doc-links'" | ||
); | ||
} | ||
|
||
if (isExternal) { | ||
return ( | ||
<a target="blank" className={className} href={linkTo}> | ||
{text} | ||
liiil825 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</a> | ||
); | ||
} | ||
|
||
return ( | ||
<Link className={className} to={linkTo}> | ||
{text} | ||
</Link> | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ export default class Upload extends Component { | |
|
||
state = { | ||
uid: getUid(), | ||
isDraging: true | ||
isDraging: false | ||
}; | ||
|
||
componentDidMount() { | ||
|
@@ -170,10 +170,9 @@ export default class Upload extends Component { | |
return ( | ||
<span | ||
{...events} | ||
className={classNames('upload', { | ||
className={classNames(className, 'upload', { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. className placed at last is better, since it's a override style There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
'upload-dragover': this.state.isDraging, | ||
'upload-disabled': disabled, | ||
className | ||
'upload-disabled': disabled | ||
})} | ||
role="button" | ||
style={style} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
valueChange is redundant, you only need
onChange
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want a function pass name and it do not affect before