Add indications for no translations available in the lint warnings page

Signed-off-by: Christopher Baines <mail@cbaines.net>
This commit is contained in:
Danjela Lura 2020-06-24 14:52:45 +02:00 committed by Christopher Baines
parent d442d408ee
commit bd3aa98620
3 changed files with 38 additions and 5 deletions

View file

@ -16,12 +16,16 @@
;;; <http://www.gnu.org/licenses/>.
(define-module (guix-data-service model lint-warning)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (squee)
#:use-module (guix-data-service model utils)
#:export (lint-warnings-data->lint-warning-ids
insert-guix-revision-lint-warnings
lint-warnings-for-guix-revision
select-lint-warnings-by-revision-package-name-and-version))
select-lint-warnings-by-revision-package-name-and-version
any-translated-lint-warnings?))
(define (lint-warnings-data->lint-warning-ids
conn
@ -206,3 +210,13 @@ WHERE packages.id IN (
(exec-query conn
query
(list commit-hash name version locale)))
(define (any-translated-lint-warnings? lint-warnings-data locale)
(any
(match-lambda
((lint-warnings-id lint-checker-name lint-checker-description
description-locale network-dependent package-name
packages-version file line column message message-locale)
(or (string=? description-locale locale)
(string=? message-locale locale))))
lint-warnings-data))

View file

@ -1071,7 +1071,9 @@
#:locale locale
#:package-query package-query
#:linters linters
#:message-query message-query)))
#:message-query message-query))
(any-translated-lint-warnings?
(any-translated-lint-warnings? lint-warnings locale)))
(case (most-appropriate-mime-type
'(application/json text/html)
mime-types)
@ -1113,6 +1115,7 @@
git-repositories
lint-checker-options
lint-warnings-locale-options
any-translated-lint-warnings?
#:path-base path-base
#:header-text header-text
#:header-link header-link)

View file

@ -1848,6 +1848,7 @@ figure {
git-repositories
lint-checker-options
lint-warnings-locale-options
any-translated-lint-warnings?
#:key path-base
header-text header-link)
(define field-options
@ -1886,7 +1887,10 @@ figure {
#:options lint-warnings-locale-options
#:allow-selecting-multiple-options #f
#:help-text
"Language")
(if any-translated-lint-warnings?
"Language"
'((span (@ (class "text-danger"))
"No translations available in this page"))))
,(form-horizontal-control
"Package query" query-parameters
#:help-text
@ -1961,10 +1965,22 @@ figure {
`((td (span (@ (style "font-family: monospace; display: block;"))
,lint-checker-name)
(p (@ (style "font-size: small; margin: 6px 0 0px;"))
,lint-checker-description)))
,lint-checker-description)
,(if (string=? lint-checker-description-locale
(assq-ref query-parameters 'locale))
""
'((span (@ (class "text-danger")
(style "font-size: small; display: block;"))
"No translation available for lint checker description.")))))
'())
,@(if (member "message" fields)
`((td ,message))
`((td ,message
,(if (string=? message-locale
(assq-ref query-parameters 'locale))
""
'((span (@ (class "text-danger")
(style "font-size: small; display: block;"))
"\nNo translation available for lint warning message.")))))
'())
,@(if (member "location" fields)
`((td