Merge remote-tracking branch 'origin/staging' into develop

This commit is contained in:
Andrey Antukh 2022-10-04 15:33:00 +02:00
commit fadb1dfba6
6 changed files with 28 additions and 69 deletions

View file

@ -41,13 +41,12 @@
;; --- MUTATION: Update Profile (own) ;; --- MUTATION: Update Profile (own)
(s/def ::newsletter-subscribed ::us/boolean)
(s/def ::update-profile (s/def ::update-profile
(s/keys :req-un [::fullname ::profile-id] (s/keys :req-un [::fullname ::profile-id]
:opt-un [::lang ::theme ::newsletter-subscribed])) :opt-un [::lang ::theme]))
(sv/defmethod ::update-profile (sv/defmethod ::update-profile
[{:keys [pool] :as cfg} {:keys [profile-id fullname lang theme newsletter-subscribed] :as params}] [{:keys [pool] :as cfg} {:keys [profile-id fullname lang theme] :as params}]
(db/with-atomic [conn pool] (db/with-atomic [conn pool]
;; NOTE: we need to retrieve the profile independently if we use ;; NOTE: we need to retrieve the profile independently if we use
;; it or not for explicit locking and avoid concurrent updates of ;; it or not for explicit locking and avoid concurrent updates of
@ -60,13 +59,7 @@
(assoc :fullname fullname) (assoc :fullname fullname)
(assoc :lang lang) (assoc :lang lang)
(assoc :theme theme)) (assoc :theme theme))
]
;; Update profile props if the indirect prop is coming in
;; the params map and update the profile props data
;; accordingly.
profile (cond-> profile
(some? newsletter-subscribed)
(update :props assoc :newsletter-subscribed newsletter-subscribed))]
(db/update! conn :profile (db/update! conn :profile
{:fullname fullname {:fullname fullname

View file

@ -25,7 +25,8 @@
(declare get-stats) (declare get-stats)
(declare send!) (declare send!)
(declare get-subscriptions) (declare get-subscriptions-newsletter-updates)
(declare get-subscriptions-newsletter-news)
(s/def ::http-client fn?) (s/def ::http-client fn?)
(s/def ::version ::us/string) (s/def ::version ::us/string)
@ -40,7 +41,8 @@
(defmethod ig/init-key ::handler (defmethod ig/init-key ::handler
[_ {:keys [pool sprops version] :as cfg}] [_ {:keys [pool sprops version] :as cfg}]
(fn [{:keys [send? enabled?] :or {send? true enabled? false}}] (fn [{:keys [send? enabled?] :or {send? true enabled? false}}]
(let [subs (get-subscriptions pool) (let [subs {:newsletter-updates (get-subscriptions-newsletter-updates pool)
:newsletter-news (get-subscriptions-newsletter-news pool)}
enabled? (or enabled? enabled? (or enabled?
(contains? cf/flags :telemetry) (contains? cf/flags :telemetry)
(cf/get :telemetry-enabled)) (cf/get :telemetry-enabled))
@ -90,9 +92,15 @@
:response-status (:status response) :response-status (:status response)
:response-body (:body response))))) :response-body (:body response)))))
(defn- get-subscriptions (defn- get-subscriptions-newsletter-updates
[conn] [conn]
(let [sql "select email from profile where props->>'~:newsletter-subscribed' = 'true'"] (let [sql "select email from profile where props->>'~:newsletter-updates' = 'true'"]
(->> (db/exec! conn [sql])
(mapv :email))))
(defn- get-subscriptions-newsletter-news
[conn]
(let [sql "select email from profile where props->>'~:newsletter-news' = 'true'"]
(->> (db/exec! conn [sql]) (->> (db/exec! conn [sql])
(mapv :email)))) (mapv :email))))

View file

@ -22,7 +22,7 @@
:return nil}] :return nil}]
(let [task-fn (-> th/*system* :app.worker/registry :telemetry) (let [task-fn (-> th/*system* :app.worker/registry :telemetry)
prof (th/create-profile* 1 {:is-active true prof (th/create-profile* 1 {:is-active true
:props {:newsletter-subscribed true}})] :props {:newsletter-news true}})]
;; run the task ;; run the task
(task-fn {:send? true :enabled? true}) (task-fn {:send? true :enabled? true})
@ -30,7 +30,7 @@
(t/is (:called? @mock)) (t/is (:called? @mock))
(let [[_ data] (-> @mock :call-args)] (let [[_ data] (-> @mock :call-args)]
(t/is (contains? data :subscriptions)) (t/is (contains? data :subscriptions))
(t/is (= [(:email prof)] (get data :subscriptions))) (t/is (= [(:email prof)] (get-in data [:subscriptions :newsletter-news])))
(t/is (contains? data :total-fonts)) (t/is (contains? data :total-fonts))
(t/is (contains? data :total-users)) (t/is (contains? data :total-users))
(t/is (contains? data :total-projects)) (t/is (contains? data :total-projects))

View file

@ -32,7 +32,7 @@
(fn [] (fn []
(st/emit! (dm/success message) (st/emit! (dm/success message)
(modal/show {:type :onboarding-team}) (modal/show {:type :onboarding-team})
(du/update-profile-props {:newsletter-updates true :newsletter-news true}))))] (du/update-profile-props {:newsletter-updates @newsletter-updates :newsletter-news @newsletter-news}))))]
[:div.modal-overlay [:div.modal-overlay
[:div.modal-container.onboarding.newsletter.animated.fadeInDown [:div.modal-container.onboarding.newsletter.animated.fadeInDown

View file

@ -42,13 +42,7 @@
(mf/defc profile-form (mf/defc profile-form
[] []
(let [profile (mf/deref refs/profile) (let [profile (mf/deref refs/profile)
initial (mf/with-memo [profile] form (fm/use-form :spec ::profile-form :initial profile)]
(let [subscribed? (-> profile
:props
:newsletter-subscribed
boolean)]
(assoc profile :newsletter-subscribed subscribed?)))
form (fm/use-form :spec ::profile-form :initial initial)]
[:& fm/form {:on-submit on-submit [:& fm/form {:on-submit on-submit
:form form :form form
@ -72,17 +66,6 @@
[:a {:on-click #(modal/show! :change-email {})} [:a {:on-click #(modal/show! :change-email {})}
(tr "dashboard.change-email")]]]] (tr "dashboard.change-email")]]]]
(when (contains? @cf/flags :newsletter-subscription)
[:div.newsletter-subs
[:p.newsletter-title (tr "dashboard.newsletter-title")]
[:& fm/input {:name :newsletter-subscribed
:class "check-primary"
:type "checkbox"
:label (tr "dashboard.newsletter-msg")}]
[:p.info (tr "onboarding.newsletter.privacy1")
[:a {:target "_blank" :href "https://penpot.app/privacy.html"} (tr "onboarding.newsletter.policy")]]
[:p.info (tr "onboarding.newsletter.privacy2")]])
[:& fm/submit-button [:& fm/submit-button
{:label (tr "dashboard.save-settings") {:label (tr "dashboard.save-settings")
:disabled (empty? (:touched @form))}] :disabled (empty? (:touched @form))}]

View file

@ -12,11 +12,7 @@ export CURRENT_HASH=$(git rev-parse --short HEAD);
export CURRENT_COMMITS=$(git rev-list --count HEAD) export CURRENT_COMMITS=$(git rev-list --count HEAD)
function print-current-version { function print-current-version {
if [ $CURRENT_BRANCH != "main" ]; then echo -n "$CURRENT_VERSION-$CURRENT_COMMITS-g$CURRENT_HASH"
echo -n "$CURRENT_BRANCH-$CURRENT_VERSION-$CURRENT_COMMITS-g$CURRENT_HASH"
else
echo -n "$CURRENT_VERSION-$CURRENT_COMMITS-g$CURRENT_HASH"
fi
} }
function build-devenv { function build-devenv {
@ -114,15 +110,16 @@ This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/. file, You can obtain one at http://mozilla.org/MPL/2.0/.
Copyright (c) UXBOX Labs SL Copyright (c) KALEIDOS INC
EOF EOF
} }
function build-frontend-bundle { function build-frontend-bundle {
echo ">> bundle frontend start"; echo ">> bundle frontend start";
mkdir -p ./bundles
local version=$(print-current-version); local version=$(print-current-version);
local bundle_dir="./bundle-frontend"; local bundle_dir="./bundles/frontend";
build "frontend"; build "frontend";
@ -136,8 +133,9 @@ function build-frontend-bundle {
function build-backend-bundle { function build-backend-bundle {
echo ">> bundle backend start"; echo ">> bundle backend start";
mkdir -p ./bundles
local version=$(print-current-version); local version=$(print-current-version);
local bundle_dir="./bundle-backend"; local bundle_dir="./bundles/backend";
build "backend"; build "backend";
@ -150,8 +148,10 @@ function build-backend-bundle {
function build-exporter-bundle { function build-exporter-bundle {
echo ">> bundle exporter start"; echo ">> bundle exporter start";
mkdir -p ./bundles
local version=$(print-current-version); local version=$(print-current-version);
local bundle_dir="./bundle-exporter"; local bundle_dir="./bundles/exporter";
build "exporter"; build "exporter";
@ -164,27 +164,6 @@ function build-exporter-bundle {
echo ">> bundle exporter end"; echo ">> bundle exporter end";
} }
# DEPRECATED: temporary maintained for backward compatibility.
function build-app-bundle {
echo ">> bundle app start";
local version=$(print-current-version);
local bundle_dir="./bundle-app";
build "frontend";
build "backend";
rm -rf $bundle_dir
mkdir -p $bundle_dir;
mv ./frontend/target/dist $bundle_dir/frontend;
mv ./backend/target/dist $bundle_dir/backend;
echo $version > $bundle_dir/version.txt
put-license-file $bundle_dir;
echo ">> bundle app end";
}
function usage { function usage {
echo "PENPOT build & release manager" echo "PENPOT build & release manager"
echo "USAGE: $0 OPTION" echo "USAGE: $0 OPTION"
@ -237,10 +216,6 @@ case $1 in
;; ;;
# production builds # production builds
build-app-bundle)
build-app-bundle;
;;
build-frontend-bundle) build-frontend-bundle)
build-frontend-bundle; build-frontend-bundle;
;; ;;