1
0
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:
WJH
2023-11-04 17:44:26 +08:00
committed by GitHub
parent 575a0ba516
commit ac7366f939
4 changed files with 114 additions and 15 deletions

View File

@@ -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 (