Skip to content
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

Merged
merged 16 commits into from
Dec 5, 2018
6 changes: 5 additions & 1 deletion config/i18n.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ const translations = {
translation: require('../src/locales/en/translation.json')
},
zh: {
translation: require('../src/locales/zh/translation.json')
translation: Object.assign(
{},
require('../src/locales/zh/apps.json'),
require('../src/locales/zh/translation.json')
)
}
};

Expand Down
33 changes: 29 additions & 4 deletions src/components/Base/Input/input.jsx
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';

Expand All @@ -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);
Copy link
Contributor

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

Copy link
Contributor Author

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

this.props.onChange(event);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you get target value, using this.props.onChange(value) is better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  @action
  valueChange = (name, value) => {
    this.attribute[name] = value;
    if (this.attribute.name) {
      this.disableNextStep = false;
    } else {
      this.disableNextStep = true;
    }
    this.errorMessage = '';
  };

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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}
/>
);
}
}
60 changes: 60 additions & 0 deletions src/components/Base/Link/index.jsx
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>
);
}
}
7 changes: 3 additions & 4 deletions src/components/Base/Upload/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class Upload extends Component {

state = {
uid: getUid(),
isDraging: true
isDraging: false
};

componentDidMount() {
Expand Down Expand Up @@ -170,10 +170,9 @@ export default class Upload extends Component {
return (
<span
{...events}
className={classNames('upload', {
className={classNames(className, 'upload', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

className placed at last is better, since it's a override style

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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}
Expand Down
4 changes: 4 additions & 0 deletions src/components/Base/Upload/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@
cursor: not-allowed;
pointer-events: none;
}
&.upload-dragover {
opacity: 0.3;
box-shadow: 0 1px 4px 0 rgba(73, 33, 173, 0.06), 0 4px 8px 0 rgba(35, 35, 36, 0.04);
}
}
}
1 change: 1 addition & 0 deletions src/components/Base/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export Timeline from './Timeline';
export Tooltip from './Tooltip';
export Image from './Image';
export Upload from './Upload';
export Link from './Link';
liiil825 marked this conversation as resolved.
Show resolved Hide resolved
Loading