Skip to content

Commit 7e6f5e2

Browse files
wxiaoguangGiteaBot
authored andcommitted
Fix some log and UI problems (go-gitea#34863)
Remove the misleading error log, fix go-gitea#34738 Make the "search" input auto-focused, fix go-gitea#34807
1 parent 9339661 commit 7e6f5e2

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

models/asymkey/gpg_key_add.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func AddGPGKey(ctx context.Context, ownerID int64, content, token, signature str
9191
signer, err = openpgp.CheckArmoredDetachedSignature(ekeys, strings.NewReader(token+"\r\n"), strings.NewReader(signature), nil)
9292
}
9393
if err != nil {
94-
log.Error("Unable to validate token signature. Error: %v", err)
94+
log.Debug("AddGPGKey CheckArmoredDetachedSignature failed: %v", err)
9595
return nil, ErrGPGInvalidTokenSignature{
9696
ID: ekeys[0].PrimaryKey.KeyIdString(),
9797
Wrapped: err,

models/asymkey/gpg_key_verify.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func VerifyGPGKey(ctx context.Context, ownerID int64, keyID, token, signature st
8585
}
8686

8787
if signer == nil {
88-
log.Error("Unable to validate token signature. Error: %v", err)
88+
log.Debug("VerifyGPGKey failed: no signer")
8989
return "", ErrGPGInvalidTokenSignature{
9090
ID: key.KeyID,
9191
}

models/asymkey/ssh_key_verify.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func VerifySSHKey(ctx context.Context, ownerID int64, fingerprint, token, signat
3535
// edge case for Windows based shells that will add CR LF if piped to ssh-keygen command
3636
// see https://github.com/PowerShell/PowerShell/issues/5974
3737
if sshsig.Verify(strings.NewReader(token+"\r\n"), []byte(signature), []byte(key.Content), "gitea") != nil {
38-
log.Error("Unable to validate token signature. Error: %v", err)
38+
log.Debug("VerifySSHKey sshsig.Verify failed: %v", err)
3939
return "", ErrSSHInvalidTokenSignature{
4040
Fingerprint: key.Fingerprint,
4141
}

web_src/js/components/DashboardRepoList.vue

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default defineComponent({
3838
return {
3939
tab,
4040
repos: [],
41-
reposTotalCount: 0,
41+
reposTotalCount: null,
4242
reposFilter,
4343
archivedFilter,
4444
privateFilter,
@@ -112,9 +112,6 @@ export default defineComponent({
112112
const el = document.querySelector('#dashboard-repo-list');
113113
this.changeReposFilter(this.reposFilter);
114114
fomanticQuery(el.querySelector('.ui.dropdown')).dropdown();
115-
nextTick(() => {
116-
this.$refs.search?.focus();
117-
});
118115
119116
this.textArchivedFilterTitles = {
120117
'archived': this.textShowOnlyArchived,
@@ -242,12 +239,20 @@ export default defineComponent({
242239
243240
let response, json;
244241
try {
242+
const firstLoad = this.reposTotalCount === null;
245243
if (!this.reposTotalCount) {
246244
const totalCountSearchURL = `${this.subUrl}/repo/search?count_only=1&uid=${this.uid}&team_id=${this.teamId}&q=&page=1&mode=`;
247245
response = await GET(totalCountSearchURL);
248246
this.reposTotalCount = parseInt(response.headers.get('X-Total-Count') ?? '0');
249247
}
250-
248+
if (firstLoad && this.reposTotalCount) {
249+
nextTick(() => {
250+
// MDN: If there's no focused element, this is the Document.body or Document.documentElement.
251+
if ((document.activeElement === document.body || document.activeElement === document.documentElement)) {
252+
this.$refs.search.focus({preventScroll: true});
253+
}
254+
});
255+
}
251256
response = await GET(searchedURL);
252257
json = await response.json();
253258
} catch {
@@ -349,7 +354,7 @@ export default defineComponent({
349354
<h4 class="ui top attached header tw-flex tw-items-center">
350355
<div class="tw-flex-1 tw-flex tw-items-center">
351356
{{ textMyRepos }}
352-
<span class="ui grey label tw-ml-2">{{ reposTotalCount }}</span>
357+
<span v-if="reposTotalCount" class="ui grey label tw-ml-2">{{ reposTotalCount }}</span>
353358
</div>
354359
<a class="tw-flex tw-items-center muted" :href="subUrl + '/repo/create' + (isOrganization ? '?org=' + organizationId : '')" :data-tooltip-content="textNewRepo">
355360
<svg-icon name="octicon-plus"/>
@@ -420,7 +425,7 @@ export default defineComponent({
420425
</div>
421426
<div v-if="repos.length" class="ui attached table segment tw-rounded-b">
422427
<ul class="repo-owner-name-list">
423-
<li class="tw-flex tw-items-center tw-py-2" v-for="repo, index in repos" :class="{'active': index === activeIndex}" :key="repo.id">
428+
<li class="tw-flex tw-items-center tw-py-2" v-for="(repo, index) in repos" :class="{'active': index === activeIndex}" :key="repo.id">
424429
<a class="repo-list-link muted" :href="repo.link">
425430
<svg-icon :name="repoIcon(repo)" :size="16" class="repo-list-icon"/>
426431
<div class="text truncate">{{ repo.full_name }}</div>

0 commit comments

Comments
 (0)