mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-06 17:33:18 +00:00
Fix eslint warnings (#5635)
* 01 fix eslint warnings * fix code warnings * fix code warnings * fix code warnings * fix code warnings * fix code warnings
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { css } from 'glamor';
|
||||
|
||||
class Alert extends React.PureComponent {
|
||||
@@ -102,4 +103,11 @@ class Alert extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
export default Alert;
|
||||
Alert.propTypes = {
|
||||
onRemove: PropTypes.func.isRequired,
|
||||
children: PropTypes.any.isRequired,
|
||||
title: PropTypes.string.isRequired,
|
||||
intent: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
export default Alert;
|
||||
|
@@ -2,4 +2,4 @@ import Toaster from './toaster';
|
||||
|
||||
const toaster = new Toaster();
|
||||
|
||||
export default toaster;
|
||||
export default toaster;
|
||||
|
@@ -88,16 +88,16 @@ export default class Toast extends React.PureComponent {
|
||||
* When false, will close the Toast and call onRemove when finished.
|
||||
*/
|
||||
isShown: PropTypes.bool
|
||||
}
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
intent: 'none'
|
||||
}
|
||||
};
|
||||
|
||||
state = {
|
||||
isShown: true,
|
||||
height: 0
|
||||
}
|
||||
};
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (prevProps.isShown !== this.props.isShown) {
|
||||
@@ -121,7 +121,7 @@ export default class Toast extends React.PureComponent {
|
||||
this.setState({
|
||||
isShown: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
startCloseTimer = () => {
|
||||
if (this.props.duration) {
|
||||
@@ -129,22 +129,22 @@ export default class Toast extends React.PureComponent {
|
||||
this.close();
|
||||
}, this.props.duration * 1000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
clearCloseTimer = () => {
|
||||
if (this.closeTimer) {
|
||||
clearTimeout(this.closeTimer);
|
||||
this.closeTimer = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
handleMouseEnter = () => {
|
||||
this.clearCloseTimer();
|
||||
}
|
||||
};
|
||||
|
||||
handleMouseLeave = () => {
|
||||
this.startCloseTimer();
|
||||
}
|
||||
};
|
||||
|
||||
onRef = ref => {
|
||||
if (ref === null) return;
|
||||
@@ -154,7 +154,7 @@ export default class Toast extends React.PureComponent {
|
||||
this.setState({
|
||||
height
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
@@ -191,4 +191,4 @@ export default class Toast extends React.PureComponent {
|
||||
</Transition>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ export default class ToastManager extends React.PureComponent {
|
||||
* Function called with the `this.closeAll` function.
|
||||
*/
|
||||
bindCloseAll: PropTypes.func.isRequired
|
||||
}
|
||||
};
|
||||
|
||||
static idCounter = 0;
|
||||
|
||||
@@ -51,11 +51,11 @@ export default class ToastManager extends React.PureComponent {
|
||||
|
||||
getToasts = () => {
|
||||
return this.state.toasts;
|
||||
}
|
||||
};
|
||||
|
||||
closeAll = () => {
|
||||
this.getToasts().forEach(toast => toast.close());
|
||||
}
|
||||
};
|
||||
|
||||
notify = (title, settings) => {
|
||||
// If there's a custom toast ID passed, close existing toasts with the same custom ID
|
||||
@@ -77,7 +77,7 @@ export default class ToastManager extends React.PureComponent {
|
||||
});
|
||||
|
||||
return instance;
|
||||
}
|
||||
};
|
||||
|
||||
createToastInstance = (title, settings) => {
|
||||
const uniqueId = ++ToastManager.idCounter;
|
||||
@@ -92,7 +92,7 @@ export default class ToastManager extends React.PureComponent {
|
||||
close: () => this.closeToast(id),
|
||||
intent: settings.intent
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This will set isShown on the Toast which will close the toast.
|
||||
@@ -112,7 +112,7 @@ export default class ToastManager extends React.PureComponent {
|
||||
})
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
removeToast = id => {
|
||||
this.setState(previousState => {
|
||||
@@ -120,7 +120,7 @@ export default class ToastManager extends React.PureComponent {
|
||||
toasts: previousState.toasts.filter(toast => toast.id !== id)
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
@@ -135,4 +135,4 @@ export default class ToastManager extends React.PureComponent {
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -29,37 +29,37 @@ export default class Toaster {
|
||||
|
||||
_bindNotify = handler => {
|
||||
this.notifyHandler = handler;
|
||||
}
|
||||
};
|
||||
|
||||
_bindGetToasts = handler => {
|
||||
this.getToastsHandler = handler;
|
||||
}
|
||||
};
|
||||
|
||||
_bindCloseAll = handler => {
|
||||
this.closeAllHandler = handler;
|
||||
}
|
||||
};
|
||||
|
||||
getToasts = () => {
|
||||
return this.getToastsHandler();
|
||||
}
|
||||
};
|
||||
|
||||
closeAll = () => {
|
||||
return this.closeAllHandler();
|
||||
}
|
||||
};
|
||||
|
||||
notify = (title, settings = {}) => {
|
||||
return this.notifyHandler(title, { ...settings, intent: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
success = (title, settings = {}) => {
|
||||
return this.notifyHandler(title, { ...settings, intent: 'success' });
|
||||
}
|
||||
};
|
||||
|
||||
warning = (title, settings = {}) => {
|
||||
return this.notifyHandler(title, { ...settings, intent: 'warning' });
|
||||
}
|
||||
};
|
||||
|
||||
danger = (title, settings = {}) => {
|
||||
return this.notifyHandler(title, { ...settings, intent: 'danger' });
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user