view: Define issue details.
authorRicardo Wurmus <rekado@elephly.net>
Wed, 6 May 2020 09:02:59 +0000 (11:02 +0200)
committerRicardo Wurmus <rekado@elephly.net>
Wed, 6 May 2020 09:02:59 +0000 (11:02 +0200)
mumi/web/view/html.scm

index 8f6307f27dbe3d0ec32df9a60c9f48ec6b1304d3..da3b519c25551e150aded809556d45e9eead4d77 100644 (file)
@@ -316,6 +316,89 @@ failed to process associated messages.")
                         (lambda (a b)
                           (string< (extract-email a)
                                    (extract-email b)))))
+  (define issue-details
+    `(span (@ (class "details"))
+           ,(status-tag bug)
+           ,(string-append "Submitted by "
+                           ;; We don't use bug-originator here
+                           ;; because it includes the email address.
+                           ;; We cannot use extract-name on the
+                           ;; return value, because it swallows
+                           ;; non-ASCII characters.
+                           (sender-name (first messages))
+                           ".")
+           (details
+            (@ (class "info"))
+            (summary "Details")
+            (dl
+             (@ (class "stat"))
+             ,@(let ((num (length parties)))
+                 `((dt ,(if (= num 1)
+                            "One participant"
+                            (string-append (number->string num)
+                                           " participants")))
+                   (dd
+                    (ul ,(map (lambda (name)
+                                `(li (span (@ (class "name")))
+                                     ,name))
+                              (map extract-name parties)))))))
+            (dl
+             (@ (class "stat"))
+             (dt "Owner")
+             (dd
+              ,(or (and=> (bug-owner bug) extract-name) "unassigned")))
+            (dl
+             (@ (class "stat"))
+             (dt "Severity")
+             (dd ,(bug-severity bug)))
+            ,@(if (bug-mergedwith bug)
+                  `((dl
+                     (@ (class "stat"))
+                     (dt "Merged with")
+                     (dd (ul ,(map (lambda (id)
+                                     `(li (a (@ (href ,(string-append "/" id)))
+                                             ,id)))
+                                   ;; XXX: This field can either hold a
+                                   ;; string of multiple ids, or a single
+                                   ;; number.  Deal with this mess.
+                                   (match (bug-mergedwith bug)
+                                     ((? string? str)
+                                      (string-split str #\space))
+                                     ((? number? n)
+                                      (list (number->string n)))))))))
+                  '())
+            ,@(if (bug-blocks bug)
+                  `((dl
+                     (@ (class "stat"))
+                     (dt "Blocks")
+                     (dd (ul ,(map (lambda (id)
+                                     `(li (a (@ (href ,(string-append "/" id)))
+                                             ,id)))
+                                   ;; XXX: This field can either hold a
+                                   ;; string of multiple ids, or a single
+                                   ;; number.  Deal with this mess.
+                                   (match (bug-blocks bug)
+                                     ((? string? str)
+                                      (string-split str #\space))
+                                     ((? number? n)
+                                      (list (number->string n)))))))))
+                  '())
+            ,@(if (bug-blockedby bug)
+                  `((dl
+                     (@ (class "stat"))
+                     (dt "Blocked by")
+                     (dd (ul ,(map (lambda (id)
+                                     `(li (a (@ (href ,(string-append "/" id)))
+                                             ,id)))
+                                   ;; XXX: This field can either hold a
+                                   ;; string of multiple ids, or a single
+                                   ;; number.  Deal with this mess.
+                                   (match (bug-blockedby bug)
+                                     ((? string? str)
+                                      (string-split str #\space))
+                                     ((? number? n)
+                                      (list (number->string n)))))))))
+                  '()))))
   (define (show-message message-number message previous-subject)
     `((div (@ (class "mb-5"))
            (a (@ (id ,(number->string message-number))))
@@ -390,88 +473,7 @@ failed to process associated messages.")
           (div
            (@ (class "title col-12"))
            (h1 (@ (class "h3")) ,(bug-subject* bug))
-           (span (@ (class "details"))
-                 ,(status-tag bug)
-                 ,(string-append "Submitted by "
-                                 ;; We don't use bug-originator here
-                                 ;; because it includes the email address.
-                                 ;; We cannot use extract-name on the
-                                 ;; return value, because it swallows
-                                 ;; non-ASCII characters.
-                                 (sender-name (first messages))
-                                 ".")
-                 (details
-                  (@ (class "info"))
-                  (summary "Details")
-                  (dl
-                   (@ (class "stat"))
-                   ,@(let ((num (length parties)))
-                       `((dt ,(if (= num 1)
-                                  "One participant"
-                                  (string-append (number->string num)
-                                                 " participants")))
-                         (dd
-                          (ul ,(map (lambda (name)
-                                      `(li (span (@ (class "name")))
-                                           ,name))
-                                    (map extract-name parties)))))))
-                  (dl
-                   (@ (class "stat"))
-                   (dt "Owner")
-                   (dd
-                    ,(or (and=> (bug-owner bug) extract-name) "unassigned")))
-                  (dl
-                   (@ (class "stat"))
-                   (dt "Severity")
-                   (dd ,(bug-severity bug)))
-                  ,@(if (bug-mergedwith bug)
-                        `((dl
-                           (@ (class "stat"))
-                           (dt "Merged with")
-                           (dd (ul ,(map (lambda (id)
-                                           `(li (a (@ (href ,(string-append "/" id)))
-                                                   ,id)))
-                                         ;; XXX: This field can either hold a
-                                         ;; string of multiple ids, or a single
-                                         ;; number.  Deal with this mess.
-                                         (match (bug-mergedwith bug)
-                                           ((? string? str)
-                                            (string-split str #\space))
-                                           ((? number? n)
-                                            (list (number->string n)))))))))
-                        '())
-                  ,@(if (bug-blocks bug)
-                        `((dl
-                           (@ (class "stat"))
-                           (dt "Blocks")
-                           (dd (ul ,(map (lambda (id)
-                                           `(li (a (@ (href ,(string-append "/" id)))
-                                                   ,id)))
-                                         ;; XXX: This field can either hold a
-                                         ;; string of multiple ids, or a single
-                                         ;; number.  Deal with this mess.
-                                         (match (bug-blocks bug)
-                                           ((? string? str)
-                                            (string-split str #\space))
-                                           ((? number? n)
-                                            (list (number->string n)))))))))
-                        '())
-                  ,@(if (bug-blockedby bug)
-                        `((dl
-                           (@ (class "stat"))
-                           (dt "Blocked by")
-                           (dd (ul ,(map (lambda (id)
-                                           `(li (a (@ (href ,(string-append "/" id)))
-                                                   ,id)))
-                                         ;; XXX: This field can either hold a
-                                         ;; string of multiple ids, or a single
-                                         ;; number.  Deal with this mess.
-                                         (match (bug-blockedby bug)
-                                           ((? string? str)
-                                            (string-split str #\space))
-                                           ((? number? n)
-                                            (list (number->string n)))))))))
-                        '()))))
+           ,issue-details)
           (div (@ (class "row"))
                (div
                 (@ (class "conversation col-12"))