Compare commits

...

2 Commits

Author SHA1 Message Date
wxiaoguang
86c1a33369
Fix some UI bugs and clean up unused tests (#34088)
1. Make the material icon falls back to basic theme correctly
2. Remove `TestAttributeReader`, the problem has been resolved.
3. Fix `toggleElem` bug and add tests
2025-04-01 07:02:30 +00:00
GiteaBot
d54418a7d3 [skip ci] Updated translations via Crowdin 2025-04-01 00:39:56 +00:00
23 changed files with 33 additions and 88 deletions

View File

@ -99,12 +99,9 @@ func (m *MaterialIconProvider) FileIcon(ctx reqctx.RequestContext, entry *git.Tr
}
name := m.findIconNameByGit(entry)
if name == "folder" {
// the material icon pack's "folder" icon doesn't look good, so use our built-in one
// keep the old "octicon-xxx" class name to make some "theme plugin selector" could still work
return svg.RenderHTML("material-folder-generic", 16, "octicon-file-directory-fill")
}
if iconSVG, ok := m.svgs[name]; ok && iconSVG != "" {
// the material icon pack's "folder" icon doesn't look good, so use our built-in one
// keep the old "octicon-xxx" class name to make some "theme plugin selector" could still work
if iconSVG, ok := m.svgs[name]; ok && name != "folder" && iconSVG != "" {
// keep the old "octicon-xxx" class name to make some "theme plugin selector" could still work
extraClass := "octicon-file"
switch {
@ -115,7 +112,8 @@ func (m *MaterialIconProvider) FileIcon(ctx reqctx.RequestContext, entry *git.Tr
}
return m.renderFileIconSVG(ctx, name, iconSVG, extraClass)
}
return svg.RenderHTML("octicon-file")
// TODO: use an interface or wrapper for git.Entry to make the code testable.
return BasicThemeIcon(entry)
}
func (m *MaterialIconProvider) findIconNameWithLangID(s string) string {

View File

@ -4,16 +4,10 @@
package git
import (
"context"
mathRand "math/rand/v2"
"path/filepath"
"slices"
"sync"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_nulSeparatedAttributeWriter_ReadAttribute(t *testing.T) {
@ -101,57 +95,3 @@ func Test_nulSeparatedAttributeWriter_ReadAttribute(t *testing.T) {
Value: "unspecified",
}, attr)
}
func TestAttributeReader(t *testing.T) {
t.Skip() // for debug purpose only, do not run in CI
ctx := t.Context()
timeout := 1 * time.Second
repoPath := filepath.Join(testReposDir, "language_stats_repo")
commitRef := "HEAD"
oneRound := func(t *testing.T, roundIdx int) {
ctx, cancel := context.WithTimeout(ctx, timeout)
_ = cancel
gitRepo, err := OpenRepository(ctx, repoPath)
require.NoError(t, err)
defer gitRepo.Close()
commit, err := gitRepo.GetCommit(commitRef)
require.NoError(t, err)
files, err := gitRepo.LsFiles()
require.NoError(t, err)
randomFiles := slices.Clone(files)
randomFiles = append(randomFiles, "any-file-1", "any-file-2")
t.Logf("Round %v with %d files", roundIdx, len(randomFiles))
attrReader, deferrable := gitRepo.CheckAttributeReader(commit.ID.String())
defer deferrable()
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
for {
file := randomFiles[mathRand.IntN(len(randomFiles))]
_, err := attrReader.CheckPath(file)
if err != nil {
for i := 0; i < 10; i++ {
_, _ = attrReader.CheckPath(file)
}
break
}
}
wg.Done()
}()
wg.Wait()
}
for i := 0; i < 100; i++ {
oneRound(t, i)
}
}

View File

@ -1529,7 +1529,6 @@ issues.filter_project=Projekt
issues.filter_project_all=Všechny projekty
issues.filter_project_none=Žádný projekt
issues.filter_assignee=Zpracovatel
issues.filter_assginee_no_assignee=Bez zpracovatele
issues.filter_poster=Autor
issues.filter_user_placeholder=Hledat uživatele
issues.filter_user_no_select=Všichni uživatelé

View File

@ -1530,7 +1530,6 @@ issues.filter_project=Projekt
issues.filter_project_all=Alle Projekte
issues.filter_project_none=Kein Projekt
issues.filter_assignee=Zuständig
issues.filter_assginee_no_assignee=Niemand zuständig
issues.filter_poster=Autor
issues.filter_user_placeholder=Benutzer suchen
issues.filter_user_no_select=Alle Benutzer

View File

@ -1377,7 +1377,6 @@ issues.filter_project=Έργο
issues.filter_project_all=Όλα τα έργα
issues.filter_project_none=Χωρίς έργα
issues.filter_assignee=Αποδέκτης
issues.filter_assginee_no_assignee=Κανένας Αποδέκτης
issues.filter_poster=Συγγραφέας
issues.filter_type=Τύπος
issues.filter_type.all_issues=Όλα τα ζητήματα

View File

@ -1367,7 +1367,6 @@ issues.filter_project=Proyecto
issues.filter_project_all=Todos los proyectos
issues.filter_project_none=Ningún proyecto
issues.filter_assignee=Asignada a
issues.filter_assginee_no_assignee=Sin asignado
issues.filter_poster=Autor
issues.filter_type=Tipo
issues.filter_type.all_issues=Todas las incidencias

View File

@ -1059,7 +1059,6 @@ issues.filter_label_no_select=تمامی برچسب‎ها
issues.filter_milestone=نقطه عطف
issues.filter_project_none=هیچ پروژه ثبت نشده
issues.filter_assignee=مسئول رسیدگی
issues.filter_assginee_no_assignee=بدون مسئول رسیدگی
issues.filter_type=نوع
issues.filter_type.all_issues=همه مسائل
issues.filter_type.assigned_to_you=به شما محول شده

View File

@ -926,6 +926,9 @@ permission_not_set=Níl leagtha
permission_no_access=Gan rochtain
permission_read=Léigh
permission_write=Léigh agus Scríobh
permission_anonymous_read=Léamh gan Ainm
permission_everyone_read=Léigh gach duine
permission_everyone_write=Scríobh gach duine
access_token_desc=Ní chuireann ceadchomharthaí roghnaithe ach teorainn leis an údarú do na bealaí <a %s>API</a> comhfhreagracha. Léigh <a %s>doiciméadúchán</a> chun tuilleadh eolais a fháil.
at_least_one_permission=Ní mór duit cead amháin ar a laghad a roghnú chun comhartha a chruthú
permissions_list=Ceadanna:
@ -1138,6 +1141,7 @@ transfer.no_permission_to_reject=Níl cead agat an aistriú seo a dhiúltú.
desc.private=Príobháideach
desc.public=Poiblí
desc.public_access=Rochtain Phoiblí
desc.template=Teimpléad
desc.internal=Inmheánach
desc.archived=Cartlannaithe
@ -1546,7 +1550,6 @@ issues.filter_project=Tionscadal
issues.filter_project_all=Gach tionscadal
issues.filter_project_none=Gan aon tionscadal
issues.filter_assignee=Sannaitheoir
issues.filter_assginee_no_assignee=Sannta do dhuine ar bith
issues.filter_assignee_any_assignee=Sannta do dhuine ar bith
issues.filter_poster=Údar
issues.filter_user_placeholder=Cuardaigh úsáideoirí
@ -2132,6 +2135,12 @@ contributors.contribution_type.deletions=Scriosadh
settings=Socruithe
settings.desc=Is é socruithe an áit ar féidir leat na socruithe don stóras a bhainistiú
settings.options=Stóras
settings.public_access=Rochtain Phoiblí
settings.public_access_desc=Cumraigh ceadanna rochtana an chuairteora phoiblí chun réamhshocruithe an stóras seo a shárú.
settings.public_access.docs.not_set=Gan Socrú: níl cead rochtana poiblí breise ar bith. Leanann cead an chuairteora infheictheacht an stór agus ceadanna na mball.
settings.public_access.docs.anonymous_read=Léamh gan Ainm: is féidir le húsáideoirí nach bhfuil logáilte isteach rochtain a fháil ar an aonad le cead léite.
settings.public_access.docs.everyone_read=Léamh ag Gach Duine: is féidir le gach úsáideoir logáilte isteach rochtain a fháil ar an aonad le cead léite. Ciallaíonn cead léite na n-aonad eisiúna/iarrataí tarraingthe freisin gur féidir le húsáideoirí saincheisteanna nua/iarratais tarraingthe a chruthú.
settings.public_access.docs.everyone_write=Scríobh Gach Duine: tá cead scríofa ag gach úsáideoir logáilte isteach don aonad. Ní thacaíonn ach aonad Vicí leis an gcead seo.
settings.collaboration=Comhoibritheoirí
settings.collaboration.admin=Riarthóir
settings.collaboration.write=Scríobh

View File

@ -1143,7 +1143,6 @@ issues.filter_milestone=Traguardo
issues.filter_project=Progetto
issues.filter_project_none=Nessun progetto
issues.filter_assignee=Assegnatario
issues.filter_assginee_no_assignee=Nessun assegnatario
issues.filter_poster=Autore
issues.filter_type=Tipo
issues.filter_type.all_issues=Tutti i problemi

View File

@ -1546,7 +1546,6 @@ issues.filter_project=プロジェクト
issues.filter_project_all=すべてのプロジェクト
issues.filter_project_none=プロジェクトなし
issues.filter_assignee=担当者
issues.filter_assginee_no_assignee=担当者なし
issues.filter_assignee_any_assignee=担当者あり
issues.filter_poster=作成者
issues.filter_user_placeholder=ユーザーを検索

View File

@ -707,7 +707,6 @@ issues.filter_label=레이블
issues.filter_label_no_select=모든 레이블
issues.filter_milestone=마일스톤
issues.filter_assignee=담당자
issues.filter_assginee_no_assignee=담당자 없음
issues.filter_type=유형
issues.filter_type.all_issues=모든 이슈
issues.filter_type.assigned_to_you=나에게 할당됨

View File

@ -1383,7 +1383,6 @@ issues.filter_project=Projekts
issues.filter_project_all=Visi projekti
issues.filter_project_none=Nav projekta
issues.filter_assignee=Atbildīgais
issues.filter_assginee_no_assignee=Nav atbildīgā
issues.filter_poster=Autors
issues.filter_type=Veids
issues.filter_type.all_issues=Visas problēmas

View File

@ -1141,7 +1141,6 @@ issues.filter_milestone=Mijlpaal
issues.filter_project=Project
issues.filter_project_none=Geen project
issues.filter_assignee=Aangewezene
issues.filter_assginee_no_assignee=Geen verantwoordelijke
issues.filter_poster=Auteur
issues.filter_type=Type
issues.filter_type.all_issues=Alle kwesties

View File

@ -1054,7 +1054,6 @@ issues.filter_label_no_select=Wszystkie etykiety
issues.filter_milestone=Kamień milowy
issues.filter_project_none=Brak projektu
issues.filter_assignee=Przypisany
issues.filter_assginee_no_assignee=Brak przypisania
issues.filter_type=Typ
issues.filter_type.all_issues=Wszystkie zgłoszenia
issues.filter_type.assigned_to_you=Przypisane do Ciebie

View File

@ -1550,7 +1550,6 @@ issues.filter_project=Planeamento
issues.filter_project_all=Todos os planeamentos
issues.filter_project_none=Nenhum planeamento
issues.filter_assignee=Encarregado
issues.filter_assginee_no_assignee=Sem encarregado
issues.filter_assignee_any_assignee=Atribuído a qualquer pessoa
issues.filter_poster=Autor(a)
issues.filter_user_placeholder=Procurar utilizadores

View File

@ -1355,7 +1355,6 @@ issues.filter_project=Проект
issues.filter_project_all=Все проекты
issues.filter_project_none=Нет проекта
issues.filter_assignee=Назначено
issues.filter_assginee_no_assignee=Нет ответственного
issues.filter_poster=Автор
issues.filter_type=Тип
issues.filter_type.all_issues=Все задачи

View File

@ -1025,7 +1025,6 @@ issues.filter_label_no_select=සියලු ලේබල
issues.filter_milestone=සන්ධිස්ථානය
issues.filter_project_none=ව්‍යාපෘති නැත
issues.filter_assignee=අස්ගිනී
issues.filter_assginee_no_assignee=කිසිදු අස්වැද්දුමක්
issues.filter_type=වර්ගය
issues.filter_type.all_issues=සියලු ගැටළු
issues.filter_type.assigned_to_you=ඔබට පවරා ඇත

View File

@ -873,7 +873,6 @@ issues.filter_label_no_select=Alla etiketter
issues.filter_milestone=Milsten
issues.filter_project_none=Inget projekt
issues.filter_assignee=Förvärvare
issues.filter_assginee_no_assignee=Ingen tilldelad
issues.filter_type=Typ
issues.filter_type.all_issues=Alla ärenden
issues.filter_type.assigned_to_you=Tilldelad dig

View File

@ -1484,7 +1484,6 @@ issues.filter_project=Proje
issues.filter_project_all=Tüm projeler
issues.filter_project_none=Proje yok
issues.filter_assignee=Atanan
issues.filter_assginee_no_assignee=Atanan yok
issues.filter_poster=Yazar
issues.filter_type=Tür
issues.filter_type.all_issues=Tüm konular

View File

@ -1071,7 +1071,6 @@ issues.filter_milestone=Етап
issues.filter_project=Проєкт
issues.filter_project_none=Проєкт відсутній
issues.filter_assignee=Виконавець
issues.filter_assginee_no_assignee=Немає виконавця
issues.filter_type=Тип
issues.filter_type.all_issues=Всі задачі
issues.filter_type.assigned_to_you=Призначене вам

View File

@ -416,7 +416,6 @@ issues.delete_branch_at=`刪除分支 <b>%s</b> %s`
issues.filter_label=標籤篩選
issues.filter_milestone=里程碑篩選
issues.filter_assignee=指派人篩選
issues.filter_assginee_no_assignee=無負責人
issues.filter_type=類型篩選
issues.filter_type.all_issues=所有問題
issues.filter_type.assigned_to_you=指派給您的

View File

@ -1,4 +1,10 @@
import {createElementFromAttrs, createElementFromHTML, queryElemChildren, querySingleVisibleElem} from './dom.ts';
import {
createElementFromAttrs,
createElementFromHTML,
queryElemChildren,
querySingleVisibleElem,
toggleElem,
} from './dom.ts';
test('createElementFromHTML', () => {
expect(createElementFromHTML('<a>foo<span>bar</span></a>').outerHTML).toEqual('<a>foo<span>bar</span></a>');
@ -32,3 +38,13 @@ test('queryElemChildren', () => {
const children = queryElemChildren(el, '.a');
expect(children.length).toEqual(1);
});
test('toggleElem', () => {
const el = createElementFromHTML('<p><div>a</div><div class="tw-hidden">b</div></p>');
toggleElem(el.children);
expect(el.outerHTML).toEqual('<p><div class="tw-hidden">a</div><div class="">b</div></p>');
toggleElem(el.children, false);
expect(el.outerHTML).toEqual('<p><div class="tw-hidden">a</div><div class="tw-hidden">b</div></p>');
toggleElem(el.children, true);
expect(el.outerHTML).toEqual('<p><div class="">a</div><div class="">b</div></p>');
});

View File

@ -44,7 +44,7 @@ export function toggleClass(el: ElementArg, className: string, force?: boolean)
* @param force force=true to show or force=false to hide, undefined to toggle
*/
export function toggleElem(el: ElementArg, force?: boolean) {
toggleClass(el, 'tw-hidden', !force);
toggleClass(el, 'tw-hidden', force === undefined ? force : !force);
}
export function showElem(el: ElementArg) {