mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-12 21:30:39 +00:00
improve admin search repos (#5726)
This commit is contained in:
@@ -120,9 +120,30 @@ class AllRepos extends Component {
|
||||
};
|
||||
|
||||
searchRepos = (repoNameOrID) => {
|
||||
if (this.getValueLength(repoNameOrID) < 3) {
|
||||
toaster.notify(gettext('Required at least three letters.'));
|
||||
return;
|
||||
}
|
||||
navigate(`${siteRoot}sys/search-libraries/?name_or_id=${encodeURIComponent(repoNameOrID)}`);
|
||||
};
|
||||
|
||||
getValueLength(str) {
|
||||
let code, len = 0;
|
||||
for (let i = 0, length = str.length; i < length; i++) {
|
||||
code = str.charCodeAt(i);
|
||||
if (code === 10) { //solve enter problem
|
||||
len += 2;
|
||||
} else if (code < 0x007f) {
|
||||
len += 1;
|
||||
} else if (code >= 0x0080 && code <= 0x07ff) {
|
||||
len += 2;
|
||||
} else if (code >= 0x0800 && code <= 0xffff) {
|
||||
len += 3;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
render() {
|
||||
let { isCreateRepoDialogOpen } = this.state;
|
||||
return (
|
||||
|
Reference in New Issue
Block a user