mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-22 08:47:22 +00:00
fix set repo history validation (#7563)
This commit is contained in:
parent
a8727ae408
commit
df4e04d427
@ -48,7 +48,16 @@ class LibHistorySetting extends React.Component {
|
||||
days = this.state.expireDays;
|
||||
}
|
||||
let repoID = this.props.repoID;
|
||||
if (Number(days) > 0) {
|
||||
// If it's allHistory, days is always -1, no validation is needed;
|
||||
// If it's noHistory, days is always 0, no validation is needed;
|
||||
// If it's autoHistory, days needs to be validated to be greater than 0."
|
||||
if (this.state.autoHistory && Number(days) <= 0) {
|
||||
this.setState({
|
||||
errorInfo: gettext('Please enter a non-negative integer'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let message = gettext('Successfully set library history.');
|
||||
seafileAPI.setRepoHistoryLimit(repoID, parseInt(days)).then(res => {
|
||||
toaster.success(message);
|
||||
@ -58,11 +67,6 @@ class LibHistorySetting extends React.Component {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
errorInfo: gettext('Please enter a non-negative integer'),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
handleKeyDown = (e) => {
|
||||
|
@ -50,7 +50,16 @@ class SysAdminLibHistorySettingDialog extends React.Component {
|
||||
days = this.state.expireDays;
|
||||
}
|
||||
let repoID = this.props.repoID;
|
||||
if (Number(days) > 0) {
|
||||
// If it's allHistory, days is always -1, no validation is needed;
|
||||
// If it's noHistory, days is always 0, no validation is needed;
|
||||
// If it's autoHistory, days needs to be validated to be greater than 0."
|
||||
if (this.state.autoHistory && Number(days) <= 0) {
|
||||
this.setState({
|
||||
errorInfo: gettext('Please enter a non-negative integer'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let message = gettext('Successfully set library history.');
|
||||
systemAdminAPI.sysAdminUpdateRepoHistorySetting(repoID, parseInt(days)).then(res => {
|
||||
toaster.success(message);
|
||||
@ -60,11 +69,6 @@ class SysAdminLibHistorySettingDialog extends React.Component {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
errorInfo: gettext('Please enter a non-negative integer'),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
handleKeyDown = (e) => {
|
||||
|
Loading…
Reference in New Issue
Block a user