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)
(s/def ::newsletter-subscribed ::us/boolean)
(s/def ::update-profile
(s/keys :req-un [::fullname ::profile-id]
:opt-un [::lang ::theme ::newsletter-subscribed]))
:opt-un [::lang ::theme]))
(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]
;; NOTE: we need to retrieve the profile independently if we use
;; it or not for explicit locking and avoid concurrent updates of
@ -60,13 +59,7 @@
(assoc :fullname fullname)
(assoc :lang lang)
(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
{:fullname fullname

View file

@ -25,7 +25,8 @@
(declare get-stats)
(declare send!)
(declare get-subscriptions)
(declare get-subscriptions-newsletter-updates)
(declare get-subscriptions-newsletter-news)
(s/def ::http-client fn?)
(s/def ::version ::us/string)
@ -40,7 +41,8 @@
(defmethod ig/init-key ::handler
[_ {:keys [pool sprops version] :as cfg}]
(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?
(contains? cf/flags :telemetry)
(cf/get :telemetry-enabled))
@ -90,9 +92,15 @@
:response-status (:status response)
:response-body (:body response)))))
(defn- get-subscriptions
(defn- get-subscriptions-newsletter-updates
[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])
(mapv :email))))

View file

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

View file

@ -32,7 +32,7 @@
(fn []
(st/emit! (dm/success message)
(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-container.onboarding.newsletter.animated.fadeInDown

View file

@ -42,13 +42,7 @@
(mf/defc profile-form
[]
(let [profile (mf/deref refs/profile)
initial (mf/with-memo [profile]
(let [subscribed? (-> profile
:props
:newsletter-subscribed
boolean)]
(assoc profile :newsletter-subscribed subscribed?)))
form (fm/use-form :spec ::profile-form :initial initial)]
form (fm/use-form :spec ::profile-form :initial profile)]
[:& fm/form {:on-submit on-submit
:form form
@ -72,17 +66,6 @@
[:a {:on-click #(modal/show! :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
{:label (tr "dashboard.save-settings")
: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)
function print-current-version {
if [ $CURRENT_BRANCH != "main" ]; then
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 {
@ -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
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Copyright (c) UXBOX Labs SL
Copyright (c) KALEIDOS INC
EOF
}
function build-frontend-bundle {
echo ">> bundle frontend start";
mkdir -p ./bundles
local version=$(print-current-version);
local bundle_dir="./bundle-frontend";
local bundle_dir="./bundles/frontend";
build "frontend";
@ -136,8 +133,9 @@ function build-frontend-bundle {
function build-backend-bundle {
echo ">> bundle backend start";
mkdir -p ./bundles
local version=$(print-current-version);
local bundle_dir="./bundle-backend";
local bundle_dir="./bundles/backend";
build "backend";
@ -150,8 +148,10 @@ function build-backend-bundle {
function build-exporter-bundle {
echo ">> bundle exporter start";
mkdir -p ./bundles
local version=$(print-current-version);
local bundle_dir="./bundle-exporter";
local bundle_dir="./bundles/exporter";
build "exporter";
@ -164,27 +164,6 @@ function build-exporter-bundle {
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 {
echo "PENPOT build & release manager"
echo "USAGE: $0 OPTION"
@ -237,10 +216,6 @@ case $1 in
;;
# production builds
build-app-bundle)
build-app-bundle;
;;
build-frontend-bundle)
build-frontend-bundle;
;;