🔥 Remove atom wrapping on several config props

This commit is contained in:
Andrey Antukh 2023-06-21 17:51:30 +02:00
parent 0aefd044dc
commit 10205e51cc
14 changed files with 56 additions and 56 deletions

View file

@ -88,11 +88,11 @@
(def themes (obj/get global "penpotThemes")) (def themes (obj/get global "penpotThemes"))
(def build-date (parse-build-date global)) (def build-date (parse-build-date global))
(def flags (atom (parse-flags global))) (def flags (parse-flags global))
(def version (atom (parse-version global))) (def version (parse-version global))
(def target (atom (parse-target global))) (def target (parse-target global))
(def browser (atom (parse-browser))) (def browser (parse-browser))
(def platform (atom (parse-platform))) (def platform (parse-platform))
(def terms-of-service-uri (obj/get global "penpotTermsOfServiceURI" nil)) (def terms-of-service-uri (obj/get global "penpotTermsOfServiceURI" nil))
(def privacy-policy-uri (obj/get global "penpotPrivacyPolicyURI" nil)) (def privacy-policy-uri (obj/get global "penpotPrivacyPolicyURI" nil))
@ -121,11 +121,11 @@
(defn ^boolean check-browser? [candidate] (defn ^boolean check-browser? [candidate]
(dm/assert! (contains? valid-browsers candidate)) (dm/assert! (contains? valid-browsers candidate))
(= candidate @browser)) (= candidate browser))
(defn ^boolean check-platform? [candidate] (defn ^boolean check-platform? [candidate]
(dm/assert! (contains? valid-platforms candidate)) (dm/assert! (contains? valid-platforms candidate))
(= candidate @platform)) (= candidate platform))
(defn resolve-profile-photo-url (defn resolve-profile-photo-url
[{:keys [photo-id fullname name] :as profile}] [{:keys [photo-id fullname name] :as profile}]

View file

@ -36,9 +36,9 @@
(log/setup! {:app :info}) (log/setup! {:app :info})
(when (= :browser @cf/target) (when (= :browser cf/target)
(log/info :message "Welcome to penpot" (log/info :message "Welcome to penpot"
:version (:full @cf/version) :version (:full cf/version)
:asserts *assert* :asserts *assert*
:build-date cf/build-date :build-date cf/build-date
:public-uri (dm/str cf/public-uri))) :public-uri (dm/str cf/public-uri)))

View file

@ -39,7 +39,7 @@
[] []
(let [uagent (UAParser.)] (let [uagent (UAParser.)]
(merge (merge
{:app-version (:full @cf/version) {:app-version (:full cf/version)
:locale @i18n/locale} :locale @i18n/locale}
(let [browser (.getBrowser uagent)] (let [browser (.getBrowser uagent)]
{:browser (obj/get browser "name") {:browser (obj/get browser "name")
@ -230,7 +230,7 @@
(defn initialize (defn initialize
[] []
(when (contains? @cf/flags :audit-log) (when (contains? cf/flags :audit-log)
(ptk/reify ::initialize (ptk/reify ::initialize
ptk/EffectEvent ptk/EffectEvent
(effect [_ _ stream] (effect [_ _ stream]

View file

@ -377,7 +377,7 @@
(ptk/reify ::mark-onboarding-as-viewed (ptk/reify ::mark-onboarding-as-viewed
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]
(let [version (or version (:main @cf/version)) (let [version (or version (:main cf/version))
props {:onboarding-viewed true props {:onboarding-viewed true
:release-notes-viewed version}] :release-notes-viewed version}]
(->> (rp/cmd! :update-profile-props {:props props}) (->> (rp/cmd! :update-profile-props {:props props})

View file

@ -87,7 +87,7 @@
(log/trace :hint "event:initialize" :fn "features") (log/trace :hint "event:initialize" :fn "features")
(rx/concat (rx/concat
;; Enable all features set on the configuration ;; Enable all features set on the configuration
(->> (rx/from @cf/flags) (->> (rx/from cf/flags)
(rx/map name) (rx/map name)
(rx/map (fn [flag] (rx/map (fn [flag]
(when (str/starts-with? flag "frontend-feature-") (when (str/starts-with? flag "frontend-feature-")

View file

@ -98,9 +98,9 @@
[:& app.main.ui.onboarding/onboarding-modal {}] [:& app.main.ui.onboarding/onboarding-modal {}]
(and (:onboarding-viewed props) (and (:onboarding-viewed props)
(not= (:release-notes-viewed props) (:main @cf/version)) (not= (:release-notes-viewed props) (:main cf/version))
(not= "0.0" (:main @cf/version))) (not= "0.0" (:main cf/version)))
[:& app.main.ui.releases/release-notes-modal {:version (:main @cf/version)}])) [:& app.main.ui.releases/release-notes-modal {:version (:main cf/version)}]))
[:& dashboard {:route route :profile profile}]] [:& dashboard {:route route :profile profile}]]

View file

@ -28,7 +28,7 @@
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(def show-alt-login-buttons? (def show-alt-login-buttons?
(some (partial contains? @cf/flags) (some (partial contains? cf/flags)
[:login-with-google [:login-with-google
:login-with-github :login-with-github
:login-with-gitlab :login-with-gitlab
@ -175,13 +175,13 @@
:label (tr "auth.password")}]] :label (tr "auth.password")}]]
[:div.buttons-stack [:div.buttons-stack
(when (or (contains? @cf/flags :login) (when (or (contains? cf/flags :login)
(contains? @cf/flags :login-with-password)) (contains? cf/flags :login-with-password))
[:& fm/submit-button [:& fm/submit-button
{:label (tr "auth.login-submit") {:label (tr "auth.login-submit")
:data-test "login-submit"}]) :data-test "login-submit"}])
(when (contains? @cf/flags :login-with-ldap) (when (contains? cf/flags :login-with-ldap)
[:& fm/submit-button [:& fm/submit-button
{:label (tr "auth.login-with-ldap-submit") {:label (tr "auth.login-with-ldap-submit")
:on-click on-submit-ldap}])]]])) :on-click on-submit-ldap}])]]]))
@ -189,25 +189,25 @@
(mf/defc login-buttons (mf/defc login-buttons
[{:keys [params] :as props}] [{:keys [params] :as props}]
[:div.auth-buttons [:div.auth-buttons
(when (contains? @cf/flags :login-with-google) (when (contains? cf/flags :login-with-google)
[:& bl/button-link {:action #(login-with-oidc % :google params) [:& bl/button-link {:action #(login-with-oidc % :google params)
:icon i/brand-google :icon i/brand-google
:name (tr "auth.login-with-google-submit") :name (tr "auth.login-with-google-submit")
:klass "btn-google-auth"}]) :klass "btn-google-auth"}])
(when (contains? @cf/flags :login-with-github) (when (contains? cf/flags :login-with-github)
[:& bl/button-link {:action #(login-with-oidc % :github params) [:& bl/button-link {:action #(login-with-oidc % :github params)
:icon i/brand-github :icon i/brand-github
:name (tr "auth.login-with-github-submit") :name (tr "auth.login-with-github-submit")
:klass "btn-github-auth"}]) :klass "btn-github-auth"}])
(when (contains? @cf/flags :login-with-gitlab) (when (contains? cf/flags :login-with-gitlab)
[:& bl/button-link {:action #(login-with-oidc % :gitlab params) [:& bl/button-link {:action #(login-with-oidc % :gitlab params)
:icon i/brand-gitlab :icon i/brand-gitlab
:name (tr "auth.login-with-gitlab-submit") :name (tr "auth.login-with-gitlab-submit")
:klass "btn-gitlab-auth"}]) :klass "btn-gitlab-auth"}])
(when (contains? @cf/flags :login-with-oidc) (when (contains? cf/flags :login-with-oidc)
[:& bl/button-link {:action #(login-with-oidc % :oidc params) [:& bl/button-link {:action #(login-with-oidc % :oidc params)
:icon i/brand-openid :icon i/brand-openid
:name (tr "auth.login-with-oidc-submit") :name (tr "auth.login-with-oidc-submit")
@ -215,7 +215,7 @@
(mf/defc login-button-oidc (mf/defc login-button-oidc
[{:keys [params] :as props}] [{:keys [params] :as props}]
(when (contains? @cf/flags :login-with-oidc) (when (contains? cf/flags :login-with-oidc)
[:div.link-entry.link-oidc [:div.link-entry.link-oidc
[:a {:tab-index "0" [:a {:tab-index "0"
:on-key-down (fn [event] :on-key-down (fn [event]
@ -236,17 +236,17 @@
[:& login-buttons {:params params}] [:& login-buttons {:params params}]
(when (or (contains? @cf/flags :login) (when (or (contains? cf/flags :login)
(contains? @cf/flags :login-with-password) (contains? cf/flags :login-with-password)
(contains? @cf/flags :login-with-ldap)) (contains? cf/flags :login-with-ldap))
[:span.separator [:span.separator
[:span.line] [:span.line]
[:span.text (tr "labels.or")] [:span.text (tr "labels.or")]
[:span.line]])]) [:span.line]])])
(when (or (contains? @cf/flags :login) (when (or (contains? cf/flags :login)
(contains? @cf/flags :login-with-password) (contains? cf/flags :login-with-password)
(contains? @cf/flags :login-with-ldap)) (contains? cf/flags :login-with-ldap))
[:& login-form {:params params :on-success-callback on-success-callback}])]) [:& login-form {:params params :on-success-callback on-success-callback}])])
(mf/defc login-page (mf/defc login-page
@ -258,21 +258,21 @@
[:& login-methods {:params params}] [:& login-methods {:params params}]
[:div.links [:div.links
(when (or (contains? @cf/flags :login) (when (or (contains? cf/flags :login)
(contains? @cf/flags :login-with-password)) (contains? cf/flags :login-with-password))
[:div.link-entry [:div.link-entry
[:& lk/link {:action #(st/emit! (rt/nav :auth-recovery-request)) [:& lk/link {:action #(st/emit! (rt/nav :auth-recovery-request))
:data-test "forgot-password"} :data-test "forgot-password"}
(tr "auth.forgot-password")]]) (tr "auth.forgot-password")]])
(when (contains? @cf/flags :registration) (when (contains? cf/flags :registration)
[:div.link-entry [:div.link-entry
[:span (tr "auth.register") " "] [:span (tr "auth.register") " "]
[:& lk/link {:action #(st/emit! (rt/nav :auth-register {} params)) [:& lk/link {:action #(st/emit! (rt/nav :auth-register {} params))
:data-test "register-submit"} :data-test "register-submit"}
(tr "auth.register-submit")]])] (tr "auth.register-submit")]])]
(when (contains? @cf/flags :demo-users) (when (contains? cf/flags :demo-users)
[:div.links.demo [:div.links.demo
[:div.link-entry [:div.link-entry
[:span (tr "auth.create-demo-profile") " "] [:span (tr "auth.create-demo-profile") " "]

View file

@ -141,8 +141,8 @@
[:& login/login-buttons {:params params}] [:& login/login-buttons {:params params}]
(when (or (contains? @cf/flags :login) (when (or (contains? cf/flags :login)
(contains? @cf/flags :login-with-ldap)) (contains? cf/flags :login-with-ldap))
[:span.separator [:span.separator
[:span.line] [:span.line]
[:span.text (tr "labels.or")] [:span.text (tr "labels.or")]
@ -157,7 +157,7 @@
[:h1 {:data-test "registration-title"} (tr "auth.register-title")] [:h1 {:data-test "registration-title"} (tr "auth.register-title")]
[:div.subtitle (tr "auth.register-subtitle")] [:div.subtitle (tr "auth.register-subtitle")]
(when (contains? @cf/flags :demo-warning) (when (contains? cf/flags :demo-warning)
[:& demo-warning]) [:& demo-warning])
[:& register-methods {:params params}] [:& register-methods {:params params}]
@ -170,7 +170,7 @@
:data-test "login-here-link"} :data-test "login-here-link"}
(tr "auth.login-here")]] (tr "auth.login-here")]]
(when (contains? @cf/flags :demo-users) (when (contains? cf/flags :demo-users)
[:div.link-entry [:div.link-entry
[:span (tr "auth.create-demo-profile") " "] [:span (tr "auth.create-demo-profile") " "]
[:& lk/link {:action #(st/emit! (du/create-demo-profile))} [:& lk/link {:action #(st/emit! (du/create-demo-profile))}
@ -207,7 +207,7 @@
(s/def ::accept-terms-and-privacy (s/and ::us/boolean true?)) (s/def ::accept-terms-and-privacy (s/and ::us/boolean true?))
(s/def ::accept-newsletter-subscription ::us/boolean) (s/def ::accept-newsletter-subscription ::us/boolean)
(if (contains? @cf/flags :terms-and-privacy-checkbox) (if (contains? cf/flags :terms-and-privacy-checkbox)
(s/def ::register-validate-form (s/def ::register-validate-form
(s/keys :req-un [::token ::fullname ::accept-terms-and-privacy] (s/keys :req-un [::token ::fullname ::accept-terms-and-privacy]
:opt-un [::accept-newsletter-subscription])) :opt-un [::accept-newsletter-subscription]))
@ -244,7 +244,7 @@
:label (tr "auth.fullname") :label (tr "auth.fullname")
:type "text"}]] :type "text"}]]
(when (contains? @cf/flags :terms-and-privacy-checkbox) (when (contains? cf/flags :terms-and-privacy-checkbox)
[:div.fields-row.input-visible.accept-terms-and-privacy-wrapper [:div.fields-row.input-visible.accept-terms-and-privacy-wrapper
[:& fm/input {:name :accept-terms-and-privacy [:& fm/input {:name :accept-terms-and-privacy
:class "check-primary" :class "check-primary"

View file

@ -376,7 +376,7 @@
:data-test "team-invitations"} :data-test "team-invitations"}
(tr "labels.invitations")] (tr "labels.invitations")]
(when (contains? @cf/flags :webhooks) (when (contains? cf/flags :webhooks)
[:& dropdown-menu-item {:on-click go-webhooks [:& dropdown-menu-item {:on-click go-webhooks
:on-key-down (fn [event] :on-key-down (fn [event]
(when (kbd/enter? event) (when (kbd/enter? event)
@ -459,7 +459,7 @@
can-rename? (or (get-in team [:permissions :is-owner]) (get-in team [:permissions :is-admin])) can-rename? (or (get-in team [:permissions :is-owner]) (get-in team [:permissions :is-admin]))
options-ids ["teams-options-members" options-ids ["teams-options-members"
"teams-options-invitations" "teams-options-invitations"
(when (contains? @cf/flags :webhooks) (when (contains? cf/flags :webhooks)
"teams-options-webhooks") "teams-options-webhooks")
"teams-options-settings" "teams-options-settings"
(when can-rename? (when can-rename?
@ -680,7 +680,7 @@
show-release-notes show-release-notes
(mf/use-callback (mf/use-callback
(fn [event] (fn [event]
(let [version (:main @cf/version)] (let [version (:main cf/version)]
(st/emit! (ptk/event ::ev/event {::ev/name "show-release-notes" :version version})) (st/emit! (ptk/event ::ev/event {::ev/name "show-release-notes" :version version}))
(if (and (kbd/alt? event) (kbd/mod? event)) (if (and (kbd/alt? event) (kbd/mod? event))
(st/emit! (modal/show {:type :onboarding})) (st/emit! (modal/show {:type :onboarding}))
@ -769,7 +769,7 @@
(dom/open-new-window "https://penpot.app/terms")))} (dom/open-new-window "https://penpot.app/terms")))}
[:span (tr "auth.terms-of-service")]] [:span (tr "auth.terms-of-service")]]
(when (contains? @cf/flags :user-feedback) (when (contains? cf/flags :user-feedback)
[:li.separator {:tab-index (if show [:li.separator {:tab-index (if show
"0" "0"
"-1") "-1")

View file

@ -38,7 +38,7 @@
[:div.modal-left.welcome [:div.modal-left.welcome
[:img {:src "images/onboarding-welcome.png" :border "0" :alt (tr "onboarding.welcome.alt")}]] [:img {:src "images/onboarding-welcome.png" :border "0" :alt (tr "onboarding.welcome.alt")}]]
[:div.modal-right [:div.modal-right
[:div.release-container [:span.release "Version " (:main @cf/version)]] [:div.release-container [:span.release "Version " (:main cf/version)]]
[:div.right-content [:div.right-content
[:div.modal-title [:div.modal-title
[:h2 {:data-test "onboarding-welcome"} (tr "onboarding-v2.welcome.title")]] [:h2 {:data-test "onboarding-welcome"} (tr "onboarding-v2.welcome.title")]]
@ -73,7 +73,7 @@
[:div.modal-left.welcome [:div.modal-left.welcome
[:img {:src "images/onboarding-people.png" :border "0" :alt (tr "onboarding.welcome.alt")}]] [:img {:src "images/onboarding-people.png" :border "0" :alt (tr "onboarding.welcome.alt")}]]
[:div.modal-right [:div.modal-right
[:div.release-container [:span.release "Version " (:main @cf/version)]] [:div.release-container [:span.release "Version " (:main cf/version)]]
[:div.right-content [:div.right-content
[:div.modal-title [:div.modal-title
[:h2 {:data-test "onboarding-welcome"} (tr "onboarding-v2.before-start.title")]] [:h2 {:data-test "onboarding-welcome"} (tr "onboarding-v2.before-start.title")]]
@ -112,7 +112,7 @@
skip skip
(mf/use-fn (mf/use-fn
#(st/emit! (modal/hide) #(st/emit! (modal/hide)
(if (contains? @cf/flags :newsletter-subscription) (if (contains? cf/flags :newsletter-subscription)
(modal/show {:type :onboarding-newsletter-modal}) (modal/show {:type :onboarding-newsletter-modal})
(modal/show {:type :onboarding-team})) (modal/show {:type :onboarding-team}))
(du/mark-onboarding-as-viewed)))] (du/mark-onboarding-as-viewed)))]

View file

@ -56,11 +56,11 @@
(mf/use-callback (mf/use-callback
(mf/deps profile) (mf/deps profile)
#(st/emit! (rt/nav :settings-access-tokens))) #(st/emit! (rt/nav :settings-access-tokens)))
show-release-notes show-release-notes
(mf/use-callback (mf/use-callback
(fn [event] (fn [event]
(let [version (:main @cf/version)] (let [version (:main cf/version)]
(st/emit! (ptk/event ::ev/event {::ev/name "show-release-notes" :version version})) (st/emit! (ptk/event ::ev/event {::ev/name "show-release-notes" :version version}))
(if (and (kbd/alt? event) (kbd/mod? event)) (if (and (kbd/alt? event) (kbd/mod? event))
(st/emit! (modal/show {:type :onboarding})) (st/emit! (modal/show {:type :onboarding}))
@ -91,7 +91,7 @@
i/tree i/tree
[:span.element-title (tr "labels.settings")]] [:span.element-title (tr "labels.settings")]]
(when (contains? @cf/flags :access-tokens) (when (contains? cf/flags :access-tokens)
[:li {:class (when access-tokens? "current") [:li {:class (when access-tokens? "current")
:on-click go-settings-access-tokens :on-click go-settings-access-tokens
:data-test "settings-access-tokens"} :data-test "settings-access-tokens"}
@ -104,7 +104,7 @@
i/pencil i/pencil
[:span.element-title (tr "labels.release-notes")]] [:span.element-title (tr "labels.release-notes")]]
(when (contains? @cf/flags :user-feedback) (when (contains? cf/flags :user-feedback)
[:li {:class (when feedback? "current") [:li {:class (when feedback? "current")
:on-click go-settings-feedback} :on-click go-settings-feedback}
i/msg-info i/msg-info

View file

@ -158,7 +158,7 @@
show-release-notes show-release-notes
(mf/use-fn (mf/use-fn
(fn [event] (fn [event]
(let [version (:main @cf/version)] (let [version (:main cf/version)]
(st/emit! (ptk/event ::ev/event {::ev/name "show-release-notes" :version version})) (st/emit! (ptk/event ::ev/event {::ev/name "show-release-notes" :version version}))
(if (and (kbd/alt? event) (kbd/mod? event)) (if (and (kbd/alt? event) (kbd/mod? event))
(st/emit! (modal/show {:type :onboarding})) (st/emit! (modal/show {:type :onboarding}))
@ -186,7 +186,7 @@
[:span (tr "label.shortcuts")] [:span (tr "label.shortcuts")]
[:span.shortcut (sc/get-tooltip :show-shortcuts)]] [:span.shortcut (sc/get-tooltip :show-shortcuts)]]
(when (contains? @cf/flags :user-feedback) (when (contains? cf/flags :user-feedback)
[:* [:*
[:li.feedback {:on-click nav-to-feedback} [:li.feedback {:on-click nav-to-feedback}
[:span (tr "labels.give-feedback")]]])]])) [:span (tr "labels.give-feedback")]]])]]))

View file

@ -51,7 +51,7 @@
(into {} (map vec) (seq (.entries ^js headers)))) (into {} (map vec) (seq (.entries ^js headers))))
(def default-headers (def default-headers
{"x-frontend-version" (:full @cfg/version)}) {"x-frontend-version" (:full cfg/version)})
(defn fetch (defn fetch
[{:keys [method uri query headers body mode omit-default-headers credentials] [{:keys [method uri query headers body mode omit-default-headers credentials]

View file

@ -51,7 +51,7 @@
(defmethod handler :configure (defmethod handler :configure
[{:keys [key val]}] [{:keys [key val]}]
(log/info :hint "configure worker" :key key :val val) (log/info :hint "configure worker" :key key :val (dm/str val))
(case key (case key
:public-uri :public-uri
(set! cf/public-uri val))) (set! cf/public-uri val)))