From 2d3e0977037bec3f84621592bbe978f15bbb7c70 Mon Sep 17 00:00:00 2001 From: jerger Date: Thu, 10 Feb 2022 16:53:47 +0100 Subject: [PATCH] grouped inputs --- src/main/cljs/dda/c4k_shynet/browser.cljs | 70 +++++++++---------- .../cljc/dda/c4k_shynet/browser_test.cljc | 11 +++ 2 files changed, 46 insertions(+), 35 deletions(-) create mode 100644 src/test/cljc/dda/c4k_shynet/browser_test.cljc diff --git a/src/main/cljs/dda/c4k_shynet/browser.cljs b/src/main/cljs/dda/c4k_shynet/browser.cljs index d6063b2..f776839 100644 --- a/src/main/cljs/dda/c4k_shynet/browser.cljs +++ b/src/main/cljs/dda/c4k_shynet/browser.cljs @@ -6,51 +6,51 @@ [dda.c4k-common.browser :as br] [dda.c4k-common.postgres :as pgc])) +;; TODO: Move these fkt up to common +(defn concat-vec [& vs] + (into [] + (apply concat vs))) + (defn generate-group [name content] {:type :element :tag :div - :attrs {:class "rounded border border-3 m-2 p-2"} + :attrs {:class "rounded border border-3 m-3 p-2"} :content [{:type :element + :tag :b + :attrs {:style "z-index: 1; position: relative; top: -1.3rem;"} + :content name} + {:type :element :tag :fieldset - :content - content}]}) + :content content}]}) -(defn generate-content - [] - (into - [] - (concat - [(assoc - (br/generate-needs-validation) :content - (into - [] - (concat - [(generate-group - "domain" - (into - [] - (concat - (br/generate-input-field "fqdn" "Your fqdn:" "shynet.prod.meissa-gmbh.de") - (br/generate-input-field "issuer" "(Optional) Your issuer prod/staging:" "")))) - (generate-group - "provider" - (into - [] - (concat - (br/generate-input-field "postgres-data-volume-path" "(Optional) Your postgres-data-volume-path:" "/var/postgres")))) - (generate-group - "credentials" - (br/generate-text-area - "auth" "Your auth.edn:" - "{:postgres-db-user \"shynet\" +(defn generate-content [] + (concat-vec + [(assoc + (br/generate-needs-validation) :content + (concat-vec + [(generate-group + "domain" + (concat-vec + (br/generate-input-field "fqdn" "Your fqdn:" "shynet.prod.meissa-gmbh.de") + (br/generate-input-field "issuer" "(Optional) Your issuer prod/staging:" ""))) + (generate-group + "provider" + (concat-vec + (br/generate-input-field "ingress-type" "(Optional) Your ingress type (traefik/ngingx):" "traefik") + (br/generate-input-field "postgres-data-volume-path" "(Optional) Your postgres-data-volume-path:" "/var/postgres"))) + (generate-group + "credentials" + (br/generate-text-area + "auth" "Your auth.edn:" + "{:postgres-db-user \"shynet\" :postgres-db-password \"shynet-db-password\" :django-secret-key \"djangosecretkey\"}" - "5"))] - [(br/generate-br)] - (br/generate-button "generate-button" "Generate c4k yaml"))))] - (br/generate-output "c4k-shynet-output" "Your c4k deployment.yaml:" "25")))) + "5"))] + [(br/generate-br)] + (br/generate-button "generate-button" "Generate c4k yaml")))] + (br/generate-output "c4k-shynet-output" "Your c4k deployment.yaml:" "25"))) (defn generate-content-div [] diff --git a/src/test/cljc/dda/c4k_shynet/browser_test.cljc b/src/test/cljc/dda/c4k_shynet/browser_test.cljc new file mode 100644 index 0000000..2a3dbb6 --- /dev/null +++ b/src/test/cljc/dda/c4k_shynet/browser_test.cljc @@ -0,0 +1,11 @@ +(ns dda.c4k-shynet.browser-test + (:require + #?(:clj [clojure.test :refer [deftest is are testing run-tests]] + :cljs [cljs.test :refer-macros [deftest is are testing run-tests]]) + [hickory.render :as hr] + [dda.c4k-shynet.browser :as cut])) + +(deftest should-generate-group + (is (= "
id1
content
" + (hr/hickory-to-html + (cut/generate-group "id1" "content")))))