Skip to content

Commit

Permalink
add config tab to build UI
Browse files Browse the repository at this point in the history
not really super useful, mostly wanted to test how the edn
components from grove look in a different context and verifying
that the shadow.css library index inclusion works.
  • Loading branch information
thheller committed Apr 24, 2024
1 parent 236e357 commit 531b64f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
3 changes: 1 addition & 2 deletions src/dev/build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
(cb/index-path (io/file "src" "main") {})
(cb/generate
'{:ui
{:include
[shadow.cljs.ui*]}})
{:entries [shadow.cljs.ui.main]}})
(cb/minify)
(cb/write-outputs-to (io/file "src" "ui-release" "shadow" "cljs" "ui" "dist" "css")))]

Expand Down
1 change: 0 additions & 1 deletion src/main/shadow/build/npm.clj
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,6 @@
nil
(:exports-prefix package)))

;; FIXME: this very much looks like the above, should this be one function?
(defn find-resource-from-exports-by-wildcard
[npm {:keys [package-dir] :as package} rel-require]
(reduce
Expand Down
29 changes: 21 additions & 8 deletions src/main/shadow/cljs/ui/components/build.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
[shadow.cljs.ui.components.build-status :as build-status]
[shadow.cljs.ui.components.runtimes :as runtimes]
[shadow.cljs.model :as m]
[shadow.cljs.ui.components.builds :as builds]))
[shadow.cljs.ui.components.builds :as builds]
[shadow.grove.ui.edn :as edn]))

(defc tab-status [build-ident]
(bind {::m/keys [build-status] :as data}
Expand All @@ -26,6 +27,14 @@
(<< [:div {:class (css :flex-1 :overflow-y-auto)}
(runtimes/ui-runtime-list build-runtimes)])))

(defc tab-config [build-ident]
(bind build-config-raw
(sg/db-read [build-ident ::m/build-config-raw]))

(render
(<< [:div {:class (css :flex-1 :overflow-y-auto :bg-white)}
(edn/render-edn build-config-raw)])))

(def $tab-selected
(css :whitespace-nowrap :py-3 :px-5 :border-b-2 :font-medium))

Expand Down Expand Up @@ -57,16 +66,20 @@
{:class (if (= tab :status) $tab-selected $tab-normal)
:ui/href link-root}
"Status"]
[:a
{:class (if (= tab :config) $tab-selected $tab-normal)
:ui/href (str link-root "/config")}
"Config"]
(when build-worker-active
(<< [:a
{:class (if (= tab :runtimes) $tab-selected $tab-normal)
:ui/href (str link-root "/runtimes")}
(str "Runtimes (" build-runtime-count ")")]))]]]]))))

(defn ui-page-runtimes [build-ident]
(<< (page-header build-ident :runtimes)
(tab-runtimes build-ident)))

(defn ui-page-status [build-ident]
(<< (page-header build-ident :status)
(tab-status build-ident)))
(defn ui-page [build-ident tab]
(<< (page-header build-ident tab)
(case tab
:runtimes (tab-runtimes build-ident)
:config (tab-config build-ident)
(tab-status build-ident)
)))
13 changes: 7 additions & 6 deletions src/main/shadow/cljs/ui/db/generic.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,18 @@
(let [[build-id-token sub-page] more
build-id (keyword build-id-token)
build-ident (db/make-ident ::m/build build-id)
build-page-id
build-tab
(case sub-page
"runtimes"
:build+runtimes
:build+status)]
"runtimes" :runtimes
"config" :config
:status)]
(update env :db
(fn [db]
(-> db
(assoc ::m/current-page
{:id build-page-id
:ident build-ident})
{:id :build
:ident build-ident
:tab build-tab})
(assoc ::m/current-build build-ident)))))

"dashboard"
Expand Down
7 changes: 2 additions & 5 deletions src/main/shadow/cljs/ui/main.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,8 @@
:builds
(builds/ui-builds-page)

:build+status
(build/ui-page-status (:ident current-page))

:build+runtimes
(build/ui-page-runtimes (:ident current-page))
:build
(build/ui-page (:ident current-page) (:tab current-page))

:dashboard
(dashboard/ui-page)
Expand Down

0 comments on commit 531b64f

Please sign in to comment.