Skip to content

Commit 1839110

Browse files
authored
Fix some log and UI problems (#34863)
Remove the misleading error log, fix #34738 Make the "search" input auto-focused, fix #34807
1 parent 35a8e6f commit 1839110

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
@@ -39,7 +39,7 @@ export default defineComponent({
3939
return {
4040
tab,
4141
repos: [],
42-
reposTotalCount: 0,
42+
reposTotalCount: null,
4343
reposFilter,
4444
archivedFilter,
4545
privateFilter,
@@ -113,9 +113,6 @@ export default defineComponent({
113113
const el = document.querySelector('#dashboard-repo-list');
114114
this.changeReposFilter(this.reposFilter);
115115
fomanticQuery(el.querySelector('.ui.dropdown')).dropdown();
116-
nextTick(() => {
117-
this.$refs.search?.focus();
118-
});
119116
120117
this.textArchivedFilterTitles = {
121118
'archived': this.textShowOnlyArchived,
@@ -243,12 +240,20 @@ export default defineComponent({
243240
244241
let response, json;
245242
try {
243+
const firstLoad = this.reposTotalCount === null;
246244
if (!this.reposTotalCount) {
247245
const totalCountSearchURL = `${this.subUrl}/repo/search?count_only=1&uid=${this.uid}&team_id=${this.teamId}&q=&page=1&mode=`;
248246
response = await GET(totalCountSearchURL);
249247
this.reposTotalCount = parseInt(response.headers.get('X-Total-Count') ?? '0');
250248
}
251-
249+
if (firstLoad && this.reposTotalCount) {
250+
nextTick(() => {
251+
// MDN: If there's no focused element, this is the Document.body or Document.documentElement.
252+
if ((document.activeElement === document.body || document.activeElement === document.documentElement)) {
253+
this.$refs.search.focus({preventScroll: true});
254+
}
255+
});
256+
}
252257
response = await GET(searchedURL);
253258
json = await response.json();
254259
} catch {
@@ -350,7 +355,7 @@ export default defineComponent({
350355
<h4 class="ui top attached header tw-flex tw-items-center">
351356
<div class="tw-flex-1 tw-flex tw-items-center">
352357
{{ textMyRepos }}
353-
<span class="ui grey label tw-ml-2">{{ reposTotalCount }}</span>
358+
<span v-if="reposTotalCount" class="ui grey label tw-ml-2">{{ reposTotalCount }}</span>
354359
</div>
355360
<a class="tw-flex tw-items-center muted" :href="subUrl + '/repo/create' + (isOrganization ? '?org=' + organizationId : '')" :data-tooltip-content="textNewRepo">
356361
<svg-icon name="octicon-plus"/>
@@ -421,7 +426,7 @@ export default defineComponent({
421426
</div>
422427
<div v-if="repos.length" class="ui attached table segment tw-rounded-b">
423428
<ul class="repo-owner-name-list">
424-
<li class="tw-flex tw-items-center tw-py-2" v-for="repo, index in repos" :class="{'active': index === activeIndex}" :key="repo.id">
429+
<li class="tw-flex tw-items-center tw-py-2" v-for="(repo, index) in repos" :class="{'active': index === activeIndex}" :key="repo.id">
425430
<a class="repo-list-link muted" :href="repo.link">
426431
<svg-icon :name="repoIcon(repo)" :size="16" class="repo-list-icon"/>
427432
<div class="text truncate">{{ repo.full_name }}</div>

0 commit comments

Comments
 (0)