From 272bbdd54a300e177e70525f599701bc42b54157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marina=20L=C3=B3pez?= Date: Mon, 17 Feb 2025 11:31:23 +0100 Subject: [PATCH 1/2] :tada: Add AB test for empty workspace set board tool by default --- frontend/src/app/main/data/workspace.cljs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index f870bb254..3fd0083e2 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -270,6 +270,16 @@ (rx/of (dws/select-shapes frames-id) dwz/zoom-to-selected-shape))))) +(defn- select-frame-tool + [page-id file-id] + (ptk/reify ::select-frame-tool + ptk/WatchEvent + (watch [_ state _] + (let [objects (dsh/lookup-page-objects state file-id page-id) + is-page-empty? (= (count objects) 1)] + (when is-page-empty? + (rx/of (dwd/select-for-drawing :frame))))))) + (defn- fetch-bundle "Multi-stage file bundle fetch coordinator" [file-id] @@ -463,7 +473,9 @@ (if-let [page (dsh/lookup-page state file-id page-id)] (rx/of (initialize-page* file-id page-id page) (dwth/watch-state-changes file-id page-id) - (dwl/watch-component-changes)) + (dwl/watch-component-changes) + (when (cf/external-feature-flag "boards-02" "test") + (select-frame-tool page-id file-id))) (rx/of (dcm/go-to-workspace :file-id file-id ::rt/replace true)))))) (defn finalize-page From 7d840722c4f4d8c11db3f56d5b9286334bca9f63 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 18 Feb 2025 16:55:16 +0100 Subject: [PATCH 2/2] :sparkles: Add abstraction for page emptiness checking --- common/src/app/common/types/page.cljc | 6 ++++++ frontend/src/app/main/data/workspace.cljs | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/common/src/app/common/types/page.cljc b/common/src/app/common/types/page.cljc index 8c57f3309..cb0d0e9e0 100644 --- a/common/src/app/common/types/page.cljc +++ b/common/src/app/common/types/page.cljc @@ -5,6 +5,7 @@ ;; Copyright (c) KALEIDOS INC (ns app.common.types.page + (:refer-clojure :exclude [empty?]) (:require [app.common.data :as d] [app.common.geom.point :as-alias gpt] @@ -98,3 +99,8 @@ (defn get-frame-flow [flows frame-id] (d/seek #(= (:starting-frame %) frame-id) (vals flows))) + +(defn is-empty? + "Check if page is empty or contains shapes" + [page] + (= 1 (count (:objects page)))) diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 3fd0083e2..b4f02eabf 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -29,6 +29,7 @@ [app.common.types.components-list :as ctkl] [app.common.types.container :as ctn] [app.common.types.file :as ctf] + [app.common.types.page :as ctp] [app.common.types.shape :as cts] [app.common.types.shape-tree :as ctst] [app.common.types.shape.layout :as ctl] @@ -271,13 +272,12 @@ dwz/zoom-to-selected-shape))))) (defn- select-frame-tool - [page-id file-id] + [file-id page-id] (ptk/reify ::select-frame-tool ptk/WatchEvent (watch [_ state _] - (let [objects (dsh/lookup-page-objects state file-id page-id) - is-page-empty? (= (count objects) 1)] - (when is-page-empty? + (let [page (dsh/lookup-page state file-id page-id)] + (when (ctp/is-empty? page) (rx/of (dwd/select-for-drawing :frame))))))) (defn- fetch-bundle @@ -475,7 +475,7 @@ (dwth/watch-state-changes file-id page-id) (dwl/watch-component-changes) (when (cf/external-feature-flag "boards-02" "test") - (select-frame-tool page-id file-id))) + (select-frame-tool file-id page-id))) (rx/of (dcm/go-to-workspace :file-id file-id ::rt/replace true)))))) (defn finalize-page