<commit_before>(ns shadow.cljs.ui.components.builds
  (:require
    [shadow.experiments.grove :as sg :refer (<< defc)]
    [shadow.cljs.ui.components.build-status :as build-status]
    [shadow.cljs.model :as m]
    ))

(defn build-buttons [build-id build-worker-active]
  (if build-worker-active
    (<< [:button.py-1.px-4.bg-blue-200.hover:bg-blue-300.rounded.shadow
         {:on-click [::m/build-watch-compile! build-id]}
         "force compile"]
        [:button.ml-2.py-1.px-4.bg-blue-200.hover:bg-blue-300.rounded.shadow
         {:on-click [::m/build-watch-stop! build-id]}
         "stop watch"])

    (<< [:button.py-1.px-4.bg-blue-200.hover:bg-blue-300.rounded.shadow
         {:on-click [::m/build-watch-start! build-id]}
         "start watch"]
        [:button.ml-2.py-1.px-4.bg-blue-200.hover:bg-blue-300.rounded.shadow
         {:on-click [::m/build-compile! build-id]}
         "compile"]
        [:button.ml-2.py-1.px-4.bg-blue-200.hover:bg-blue-300.rounded.shadow
         {:on-click [::m/build-release! build-id]}
         "release"]
        [:button.ml-2.py-1.px-4.bg-blue-200.hover:bg-blue-300.rounded.shadow
         {:on-click [::m/build-release-debug! build-id]}
         "release debug"])))

;; https://github.com/sschoger/heroicons-ui

(def icon-build-busy
  (<< [:svg
       {:xmlns "http://www.w3.org/2000/svg" :viewBox "0 0 24 24" :width "24" :height "24"}
       [:g
        [:path
         {:d "M9 4.58V4c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v.58a8 8 0 0 1 1.92 1.11l.5-.29a2 2 0 0 1 2.74.73l1 1.74a2 2 0 0 1-.73 2.73l-.5.29a8.06 8.06 0 0 1 0 2.22l.5.3a2 2 0 0 1 .73 2.72l-1 1.74a2 2 0 0 1-2.73.73l-.5-.3A8 8 0 0 1 15 19.43V20a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-.58a8 8 0 0 1-1.92-1.11l-.5.29a2 2 0 0 1-2.74-.73l-1-1.74a2 2 0 0 1 .73-2.73l.5-.29a8.06 8.06 0 0 1 0-2.22l-.5-.3a2 2 0 0 1-.73-2.72l1-1.74a2 2 0 0 1 2.73-.73l.5.3A8 8 0 0 1 9 4.57zM7.88 7.64l-.54.51-1.77-1.02-1 1.74 1.76 1.01-.17.73a6.02 6.02 0 0 0 0 2.78l.17.73-1.76 1.01 1 1.74 1.77-1.02.54.51a6 6 0 0 0 2.4 1.4l.72.2V20h2v-2.04l.71-.2a6 6 0 0 0 2.41-1.4l.54-.51 1.77 1.02 1-1.74-1.76-1.01.17-.73a6.02 6.02 0 0 0 0-2.78l-.17-.73 1.76-1.01-1-1.74-1.77 1.02-.54-.51a6 6 0 0 0-2.4-1.4l-.72-.2V4h-2v2.04l-.71.2a6 6 0 0 0-2.41 1.4zM12 16a4 4 0 1 1 0-8 4 4 0 0 1 0 8zm0-2a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"}]
        [:animateTransform
         {:attributeType "xml"
          :attributeName "transform"
          :type "rotate"
          :from "0 12 12"
          :to "360 12 12"
          :dur "2s"
          :repeatCount "indefinite"}]]]))

(def icon-build-success
  (<< [:svg {:xmlns "http://www.w3.org/2000/svg" :viewBox "0 0 24 24" :width "24" :height "24" :style "fill: green;"}
       [:path {:d "M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm-3.54-4.46a1 1 0 0 1 1.42-1.42 3 3 0 0 0 4.24 0 1 1 0 0 1 1.42 1.42 5 5 0 0 1-7.08 0zM9 11a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm6 0a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"}]]))

(def icon-build-error
  (<< [:svg {:xmlns "http://www.w3.org/2000/svg" :viewBox "0 0 24 24" :width "24" :height "24" :style "fill: red;"}
       [:path {:d "M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm-3.54-4.54a5 5 0 0 1 7.08 0 1 1 0 0 1-1.42 1.42 3 3 0 0 0-4.24 0 1 1 0 0 1-1.42-1.42zM9 11a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm6 0a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"}]]))

(def icon-build-warnings
  (<< [:svg {:xmlns "http://www.w3.org/2000/svg" :viewBox "0 0 24 24" :width "24" :height "24" :style "fill: orange;"}
       [:path {:d "M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm0-9a1 1 0 0 1 1 1v4a1 1 0 0 1-2 0v-4a1 1 0 0 1 1-1zm0-4a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"}]]))

(def icon-build-missing
  (<< [:svg {:xmlns "http://www.w3.org/2000/svg" :viewBox "0 0 24 24" :width "24" :height "24" :style "fill: rgba(0,0,0,0.1);"}
       [:path {:d "M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm0-9a1 1 0 0 1 1 1v4a1 1 0 0 1-2"}]]))

(defc ui-builds-entry [build-ident]
  [{::m/keys [build-id build-worker-active build-warnings-count build-status] :as data}
   (sg/query-ident build-ident
     [::m/build-id
      ::m/build-worker-active
      ::m/build-warnings-count
      {::m/build-status
       [:status]}])]
  (let [{:keys [status]} build-status]
    (<< [:div.px-4.py-2
         [:div.border.rounded.bg-white.p-4
          [:div.flex
           [:div.self-center.pr-4
            [:a.cursor-pointer {:href (str "/build/" (name build-id))}
             (case status
               :compiling
               icon-build-busy

               :completed
               (if (zero? build-warnings-count)
                 icon-build-success
                 icon-build-warnings)

               :failed
               icon-build-error

               :inactive
               icon-build-missing
<commit_msg>[UI] fix svg path error<commit_after>(ns shadow.cljs.ui.components.builds
  (:require
    [shadow.experiments.grove :as sg :refer (<< defc)]
    [shadow.cljs.ui.components.build-status :as build-status]
    [shadow.cljs.model :as m]
    ))

(defn build-buttons [build-id build-worker-active]
  (if build-worker-active
    (<< [:button.py-1.px-4.bg-blue-200.hover:bg-blue-300.rounded.shadow
         {:on-click [::m/build-watch-compile! build-id]}
         "force compile"]
        [:button.ml-2.py-1.px-4.bg-blue-200.hover:bg-blue-300.rounded.shadow
         {:on-click [::m/build-watch-stop! build-id]}
         "stop watch"])

    (<< [:button.py-1.px-4.bg-blue-200.hover:bg-blue-300.rounded.shadow
         {:on-click [::m/build-watch-start! build-id]}
         "start watch"]
        [:button.ml-2.py-1.px-4.bg-blue-200.hover:bg-blue-300.rounded.shadow
         {:on-click [::m/build-compile! build-id]}
         "compile"]
        [:button.ml-2.py-1.px-4.bg-blue-200.hover:bg-blue-300.rounded.shadow
         {:on-click [::m/build-release! build-id]}
         "release"]
        [:button.ml-2.py-1.px-4.bg-blue-200.hover:bg-blue-300.rounded.shadow
         {:on-click [::m/build-release-debug! build-id]}
         "release debug"])))

;; https://github.com/sschoger/heroicons-ui

(def icon-build-busy
  (<< [:svg
       {:xmlns "http://www.w3.org/2000/svg" :viewBox "0 0 24 24" :width "24" :height "24"}
       [:g
        [:path
         {:d "M9 4.58V4c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v.58a8 8 0 0 1 1.92 1.11l.5-.29a2 2 0 0 1 2.74.73l1 1.74a2 2 0 0 1-.73 2.73l-.5.29a8.06 8.06 0 0 1 0 2.22l.5.3a2 2 0 0 1 .73 2.72l-1 1.74a2 2 0 0 1-2.73.73l-.5-.3A8 8 0 0 1 15 19.43V20a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-.58a8 8 0 0 1-1.92-1.11l-.5.29a2 2 0 0 1-2.74-.73l-1-1.74a2 2 0 0 1 .73-2.73l.5-.29a8.06 8.06 0 0 1 0-2.22l-.5-.3a2 2 0 0 1-.73-2.72l1-1.74a2 2 0 0 1 2.73-.73l.5.3A8 8 0 0 1 9 4.57zM7.88 7.64l-.54.51-1.77-1.02-1 1.74 1.76 1.01-.17.73a6.02 6.02 0 0 0 0 2.78l.17.73-1.76 1.01 1 1.74 1.77-1.02.54.51a6 6 0 0 0 2.4 1.4l.72.2V20h2v-2.04l.71-.2a6 6 0 0 0 2.41-1.4l.54-.51 1.77 1.02 1-1.74-1.76-1.01.17-.73a6.02 6.02 0 0 0 0-2.78l-.17-.73 1.76-1.01-1-1.74-1.77 1.02-.54-.51a6 6 0 0 0-2.4-1.4l-.72-.2V4h-2v2.04l-.71.2a6 6 0 0 0-2.41 1.4zM12 16a4 4 0 1 1 0-8 4 4 0 0 1 0 8zm0-2a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"}]
        [:animateTransform
         {:attributeType "xml"
          :attributeName "transform"
          :type "rotate"
          :from "0 12 12"
          :to "360 12 12"
          :dur "2s"
          :repeatCount "indefinite"}]]]))

(def icon-build-success
  (<< [:svg {:xmlns "http://www.w3.org/2000/svg" :viewBox "0 0 24 24" :width "24" :height "24" :style "fill: green;"}
       [:path {:d "M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm-3.54-4.46a1 1 0 0 1 1.42-1.42 3 3 0 0 0 4.24 0 1 1 0 0 1 1.42 1.42 5 5 0 0 1-7.08 0zM9 11a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm6 0a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"}]]))

(def icon-build-error
  (<< [:svg {:xmlns "http://www.w3.org/2000/svg" :viewBox "0 0 24 24" :width "24" :height "24" :style "fill: red;"}
       [:path {:d "M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm-3.54-4.54a5 5 0 0 1 7.08 0 1 1 0 0 1-1.42 1.42 3 3 0 0 0-4.24 0 1 1 0 0 1-1.42-1.42zM9 11a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm6 0a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"}]]))

(def icon-build-warnings
  (<< [:svg {:xmlns "http://www.w3.org/2000/svg" :viewBox "0 0 24 24" :width "24" :height "24" :style "fill: orange;"}
       [:path {:d "M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm0-9a1 1 0 0 1 1 1v4a1 1 0 0 1-2 0v-4a1 1 0 0 1 1-1zm0-4a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"}]]))

(def icon-build-missing
  (<< [:svg {:xmlns "http://www.w3.org/2000/svg" :viewBox "0 0 24 24" :width "24" :height "24" :style "fill: rgba(0,0,0,0.1);"}
       [:path {:d "M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm0-9a1 1 0 0 1 1 1v4a1 1 0 0 1-2 0v-4a1 1 0 0 1 1-1zm0-4a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"}]]))

(defc ui-builds-entry [build-ident]
  [{::m/keys [build-id build-worker-active build-warnings-count build-status] :as data}
   (sg/query-ident build-ident
     [::m/build-id
      ::m/build-worker-active
      ::m/build-warnings-count
      {::m/build-status
       [:status]}])]
  (let [{:keys [status]} build-status]
    (<< [:div.px-4.py-2
         [:div.border.rounded.bg-white.p-4
          [:div.flex
           [:div.self-center.pr-4
            [:a.cursor-pointer {:href (str "/build/" (name build-id))}
             (case status
               :compiling
               icon-build-busy

               :completed
               (if (zero? build-warnings-count)
                 icon-build-success
                 icon-build-warnings)

               :failed
               icon-build-error

               :inactive
               icon-build-missing

{'fraction_non_alphanumeric': 0.1799937933174718, 'fraction_numerical': 0.20533774697424226, 'mean_word_length': 1.885108922709639, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 10, 'xml': 12}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5518324', 'n_tokens_mistral': 5756, 'n_tokens_neox': 4384, 'n_words': 1250}