Fix upload error file style, close #4810

This commit is contained in:
afc163 2017-02-15 20:58:40 +08:00
parent d8403718f9
commit 5603fa0088
5 changed files with 25 additions and 3 deletions

View File

@ -185,7 +185,10 @@ export default class Upload extends React.Component<UploadProps, any> {
targetItem.error = error;
targetItem.response = response;
targetItem.status = 'error';
this.handleRemove(targetItem);
this.onChange({
file: targetItem,
fileList,
});
}
handleRemove(file) {

View File

@ -16,6 +16,8 @@ export interface File {
percent?: number;
thumbUrl?: string;
originFileObj?: File;
response?: string;
error?: any;
}
export interface UploadChangeParam {

View File

@ -60,7 +60,7 @@
position: relative;
&.@{upload-prefix-cls}-drag-hover:not(.@{upload-prefix-cls}-disabled) {
border: 2px dashed@primary-5;
border: 2px dashed @primary-5;
}
&.@{upload-prefix-cls}-disabled {
@ -158,6 +158,7 @@
&-error .@{iconfont-css-prefix}-cross {
opacity: 1;
color: @error-color!important;
}
&-progress {
@ -182,6 +183,9 @@
&:hover {
background: transparent;
}
&-error {
border-color: @error-color;
}
}
.@{upload-item}-info {

View File

@ -3,3 +3,4 @@ import './index.less';
// style dependencies
import '../../progress/style';
import '../../tooltip/style';

View File

@ -1,6 +1,7 @@
import React from 'react';
import Animate from 'rc-animate';
import Icon from '../icon';
import Tooltip from '../tooltip';
import Progress from '../progress';
import classNames from 'classnames';
import { UploadListProps } from './interface';
@ -147,7 +148,7 @@ export default class UploadList extends React.Component<UploadListProps, any> {
? <span className={`${prefixCls}-list-item-actions`}>{previewIcon}{removeIcon}</span>
: removeIconCross;
return (
const item = (
<div className={infoUploadingClass} key={file.uid}>
<div className={`${prefixCls}-list-item-info`}>
{icon}
@ -157,6 +158,17 @@ export default class UploadList extends React.Component<UploadListProps, any> {
{progress}
</div>
);
if (file.status === 'error') {
const message = file.response || (file.error && file.error.statusText) || 'Upload Error';
return (
<Tooltip title={message} key={file.uid}>
{item}
</Tooltip>
);
}
return item;
});
const listClassNames = classNames({
[`${prefixCls}-list`]: true,