diff --git a/common/app/common/pages.cljc b/common/app/common/pages.cljc index 1b82300f7..2f33c9199 100644 --- a/common/app/common/pages.cljc +++ b/common/app/common/pages.cljc @@ -37,7 +37,7 @@ (d/export helpers/get-container) (d/export helpers/get-shape) (d/export helpers/get-component) -(d/export helpers/is-master-of) +(d/export helpers/is-main-of) (d/export helpers/get-component-root) (d/export helpers/get-children) (d/export helpers/get-children-objects) diff --git a/common/app/common/pages/helpers.cljc b/common/app/common/pages/helpers.cljc index 6dc4ccbf1..3a4414d3b 100644 --- a/common/app/common/pages/helpers.cljc +++ b/common/app/common/pages/helpers.cljc @@ -89,11 +89,11 @@ (get-in libraries [library-id :data]))] (get-in file [:components component-id]))) -(defn is-master-of - [shape-master shape-inst] +(defn is-main-of + [shape-main shape-inst] (and (:shape-ref shape-inst) - (or (= (:shape-ref shape-inst) (:id shape-master)) - (= (:shape-ref shape-inst) (:shape-ref shape-master))))) + (or (= (:shape-ref shape-inst) (:id shape-main)) + (= (:shape-ref shape-inst) (:shape-ref shape-main))))) (defn get-component-root [component] diff --git a/frontend/resources/locales.json b/frontend/resources/locales.json index 5d76be50f..17197f5c5 100644 --- a/frontend/resources/locales.json +++ b/frontend/resources/locales.json @@ -5569,11 +5569,11 @@ }, "used-in" : [ "src/app/main/ui/workspace/context_menu.cljs" ] }, - "workspace.shape.menu.go-master" : { + "workspace.shape.menu.go-main" : { "translations" : { "de" : "Zur Hauptkomponentendatei wechseln", - "en" : "Go to master component file", - "es" : "Ir al archivo del componente maestro", + "en" : "Go to main component file", + "es" : "Ir al archivo del componente principal", "fr" : "Aller au fichier du composant principal", "zh_cn" : "前往主组件文档" }, @@ -5649,11 +5649,11 @@ }, "used-in" : [ "src/app/main/ui/workspace/context_menu.cljs" ] }, - "workspace.shape.menu.show-master" : { + "workspace.shape.menu.show-main" : { "translations" : { "de" : "Hauptkomponente anzeigen", - "en" : "Show master component", - "es" : "Ver componente maestro", + "en" : "Show main component", + "es" : "Ver componente principal", "fr" : "Afficher le composant principal", "zh_cn" : "显示主组件" }, @@ -5689,11 +5689,11 @@ }, "used-in" : [ "src/app/main/ui/workspace/context_menu.cljs" ] }, - "workspace.shape.menu.update-master" : { + "workspace.shape.menu.update-main" : { "translations" : { "de" : "Hauptkomponente aktualisieren", - "en" : "Update master component", - "es" : "Actualizar componente maestro", + "en" : "Update main component", + "es" : "Actualizar componente principal", "fr" : "Actualiser le composant principal", "zh_cn" : "更新主组件" }, diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index 437a5431a..c3c8643aa 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -46,7 +46,7 @@ (declare compare-children) (declare add-shape-to-instance) -(declare add-shape-to-master) +(declare add-shape-to-main) (declare remove-shape) (declare move-shape) (declare change-touched) @@ -498,7 +498,7 @@ ;; Subcomponent-2-2 @--> Component-1 ;; Shape-2-2-1 --> Shape-1-1 ;; -;; * A SUBINSTANCE ACTUALLY HAS TWO MASTERS. For example IShape-2-2-1 +;; * A SUBINSTANCE ACTUALLY HAS TWO MAINS. For example IShape-2-2-1 ;; depends on Shape-2-2-1 (in the "near" component) but also on ;; Shape-1-1-1 (in the "remote" component). The "shape-ref" attribute ;; always refer to the remote shape, and it's guaranteed that it's @@ -557,26 +557,26 @@ (:component-file shape-inst) local-library libraries) - shape-master (cp/get-shape component (:shape-ref shape-inst)) + shape-main (cp/get-shape component (:shape-ref shape-inst)) initial-root? (:component-root? shape-inst) root-inst shape-inst - root-master (cp/get-component-root component)] + root-main (cp/get-component-root component)] (if component (generate-sync-shape-direct-recursive container shape-inst component - shape-master + shape-main root-inst - root-master + root-main reset? initial-root?) empty-changes))) (defn- generate-sync-shape-direct-recursive - [container shape-inst component shape-master root-inst root-master reset? initial-root?] + [container shape-inst component shape-main root-inst root-main reset? initial-root?] (log/debug :msg "Sync shape direct recursive" :shape (str (:name shape-inst)) :component (:name component)) @@ -588,15 +588,15 @@ [rchanges uchanges] (concat-changes (update-attrs shape-inst - shape-master + shape-main root-inst - root-master + root-main container omit-touched?) (concat-changes (if reset? (change-touched shape-inst - shape-master + shape-main container {:reset-touched? true}) empty-changes) @@ -610,8 +610,8 @@ children-inst (mapv #(cp/get-shape container %) (:shapes shape-inst)) - children-master (mapv #(cp/get-shape component %) - (:shapes shape-master)) + children-main (mapv #(cp/get-shape component %) + (:shapes shape-main)) only-inst (fn [child-inst] (when-not (and omit-touched? @@ -621,49 +621,49 @@ container omit-touched?))) - only-master (fn [child-master] - (when-not (and omit-touched? - (contains? (:touched shape-inst) - :shapes-group)) - (add-shape-to-instance child-master - (d/index-of children-master - child-master) - component - container - root-inst - root-master - omit-touched? - set-remote-synced?))) + only-main (fn [child-main] + (when-not (and omit-touched? + (contains? (:touched shape-inst) + :shapes-group)) + (add-shape-to-instance child-main + (d/index-of children-main + child-main) + component + container + root-inst + root-main + omit-touched? + set-remote-synced?))) - both (fn [child-inst child-master] + both (fn [child-inst child-main] (let [sub-root? (and (:component-id shape-inst) (not (:component-root? shape-inst)))] (generate-sync-shape-direct-recursive container child-inst component - child-master + child-main (if sub-root? shape-inst root-inst) (if sub-root? - shape-master - root-master) + shape-main + root-main) reset? initial-root?))) - moved (fn [child-inst child-master] + moved (fn [child-inst child-main] (move-shape child-inst (d/index-of children-inst child-inst) - (d/index-of children-master child-master) + (d/index-of children-main child-main) container omit-touched?)) [child-rchanges child-uchanges] (compare-children children-inst - children-master + children-main only-inst - only-master + only-main both moved false)] @@ -682,25 +682,25 @@ (:component-file shape-inst) local-library libraries) - shape-master (cp/get-shape component (:shape-ref shape-inst)) + shape-main (cp/get-shape component (:shape-ref shape-inst)) initial-root? (:component-root? shape-inst) root-inst shape-inst - root-master (cp/get-component-root component)] + root-main (cp/get-component-root component)] (if component (generate-sync-shape-inverse-recursive container shape-inst component - shape-master + shape-main root-inst - root-master + root-main initial-root?) empty-changes))) (defn- generate-sync-shape-inverse-recursive - [container shape-inst component shape-master root-inst root-master initial-root?] + [container shape-inst component shape-main root-inst root-main initial-root?] (log/trace :msg "Sync shape inverse recursive" :shape (str (:name shape-inst)) :component (:name component)) @@ -713,19 +713,19 @@ [rchanges uchanges] (concat-changes - (update-attrs shape-master + (update-attrs shape-main shape-inst - root-master + root-main root-inst component-container omit-touched?) (concat-changes (change-touched shape-inst - shape-master + shape-main container {:reset-touched? true}) (concat-changes - (change-touched shape-master + (change-touched shape-main shape-inst component-container {:copy-touched? true}) @@ -739,52 +739,52 @@ children-inst (mapv #(cp/get-shape container %) (:shapes shape-inst)) - children-master (mapv #(cp/get-shape component %) - (:shapes shape-master)) + children-main (mapv #(cp/get-shape component %) + (:shapes shape-main)) only-inst (fn [child-inst] - (add-shape-to-master child-inst - (d/index-of children-inst - child-inst) - component - container - root-inst - root-master)) + (add-shape-to-main child-inst + (d/index-of children-inst + child-inst) + component + container + root-inst + root-main)) - only-master (fn [child-master] - (remove-shape child-master - component-container - false)) + only-main (fn [child-main] + (remove-shape child-main + component-container + false)) - both (fn [child-inst child-master] + both (fn [child-inst child-main] (let [sub-root? (and (:component-id shape-inst) (not (:component-root? shape-inst)))] (generate-sync-shape-inverse-recursive container child-inst component - child-master + child-main (if sub-root? shape-inst root-inst) (if sub-root? - shape-master - root-master) + shape-main + root-main) initial-root?))) - moved (fn [child-inst child-master] + moved (fn [child-inst child-main] (move-shape - child-master - (d/index-of children-master child-master) + child-main + (d/index-of children-main child-main) (d/index-of children-inst child-inst) component-container false)) [child-rchanges child-uchanges] (compare-children children-inst - children-master + children-main only-inst - only-master + only-main both moved true) @@ -807,70 +807,70 @@ ; ---- Operation generation helpers ---- (defn- compare-children - [children-inst children-master only-inst-cb only-master-cb both-cb moved-cb inverse?] + [children-inst children-main only-inst-cb only-main-cb both-cb moved-cb inverse?] (loop [children-inst (seq (or children-inst [])) - children-master (seq (or children-master [])) + children-main (seq (or children-main [])) [rchanges uchanges] [[] []]] (let [child-inst (first children-inst) - child-master (first children-master)] + child-main (first children-main)] (cond - (and (nil? child-inst) (nil? child-master)) + (and (nil? child-inst) (nil? child-main)) [rchanges uchanges] (nil? child-inst) (reduce (fn [changes child] - (concat-changes changes (only-master-cb child))) + (concat-changes changes (only-main-cb child))) [rchanges uchanges] - children-master) + children-main) - (nil? child-master) + (nil? child-main) (reduce (fn [changes child] (concat-changes changes (only-inst-cb child))) [rchanges uchanges] children-inst) :else - (if (cp/is-master-of child-master child-inst) + (if (cp/is-main-of child-main child-inst) (recur (next children-inst) - (next children-master) + (next children-main) (concat-changes [rchanges uchanges] - (both-cb child-inst child-master))) + (both-cb child-inst child-main))) - (let [child-inst' (d/seek #(cp/is-master-of child-master %) + (let [child-inst' (d/seek #(cp/is-main-of child-main %) children-inst) - child-master' (d/seek #(cp/is-master-of % child-inst) - children-master)] + child-main' (d/seek #(cp/is-main-of % child-inst) + children-main)] (cond (nil? child-inst') (recur children-inst - (next children-master) + (next children-main) (concat-changes [rchanges uchanges] - (only-master-cb child-master))) + (only-main-cb child-main))) - (nil? child-master') + (nil? child-main') (recur (next children-inst) - children-master + children-main (concat-changes [rchanges uchanges] (only-inst-cb child-inst))) :else (if inverse? (recur (next children-inst) - (remove #(= (:id %) (:id child-master')) children-master) + (remove #(= (:id %) (:id child-main')) children-main) (-> [rchanges uchanges] - (concat-changes (both-cb child-inst' child-master)) - (concat-changes (moved-cb child-inst child-master')))) + (concat-changes (both-cb child-inst' child-main)) + (concat-changes (moved-cb child-inst child-main')))) (recur (remove #(= (:id %) (:id child-inst')) children-inst) - (next children-master) + (next children-main) (-> [rchanges uchanges] - (concat-changes (both-cb child-inst child-master')) - (concat-changes (moved-cb child-inst' child-master)))))))))))) + (concat-changes (both-cb child-inst child-main')) + (concat-changes (moved-cb child-inst' child-main)))))))))))) (defn- add-shape-to-instance - [component-shape index component container root-instance root-master omit-touched? set-remote-synced?] + [component-shape index component container root-instance root-main omit-touched? set-remote-synced?] (log/info :msg (str "ADD [P] " (:name component-shape))) (let [component-parent-shape (cp/get-shape component (:parent-id component-shape)) - parent-shape (d/seek #(cp/is-master-of component-parent-shape %) + parent-shape (d/seek #(cp/is-main-of component-parent-shape %) (cp/get-object-with-children (:id root-instance) (:objects container))) all-parents (vec (cons (:id parent-shape) @@ -879,7 +879,7 @@ update-new-shape (fn [new-shape original-shape] (let [new-shape (reposition-shape new-shape - root-master + root-main root-instance)] (cond-> new-shape true @@ -933,12 +933,12 @@ empty-changes [rchanges uchanges]))) -(defn- add-shape-to-master - [shape index component page root-instance root-master] +(defn- add-shape-to-main + [shape index component page root-instance root-main] (log/info :msg (str "ADD [C] " (:name shape))) (let [parent-shape (cp/get-shape page (:parent-id shape)) - component-parent-shape (d/seek #(cp/is-master-of % parent-shape) - (cp/get-object-with-children (:id root-master) + component-parent-shape (d/seek #(cp/is-main-of % parent-shape) + (cp/get-object-with-children (:id root-main) (:objects component))) all-parents (vec (cons (:id component-parent-shape) (cp/get-parents (:id component-parent-shape) @@ -947,7 +947,7 @@ update-new-shape (fn [new-shape original-shape] (reposition-shape new-shape root-instance - root-master)) + root-main)) update-original-shape (fn [original-shape new-shape] (if-not (:shape-ref original-shape) diff --git a/frontend/src/app/main/ui/workspace/context_menu.cljs b/frontend/src/app/main/ui/workspace/context_menu.cljs index 7d6c99610..e153ccc8f 100644 --- a/frontend/src/app/main/ui/workspace/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/context_menu.cljs @@ -207,9 +207,9 @@ :on-click do-detach-component}] [:& menu-entry {:title (t locale "workspace.shape.menu.reset-overrides") :on-click do-reset-component}] - [:& menu-entry {:title (t locale "workspace.shape.menu.update-master") + [:& menu-entry {:title (t locale "workspace.shape.menu.update-main") :on-click do-update-component}] - [:& menu-entry {:title (t locale "workspace.shape.menu.show-master") + [:& menu-entry {:title (t locale "workspace.shape.menu.show-main") :on-click do-show-component}]] [:* [:& menu-separator] @@ -217,9 +217,9 @@ :on-click do-detach-component}] [:& menu-entry {:title (t locale "workspace.shape.menu.reset-overrides") :on-click do-reset-component}] - [:& menu-entry {:title (t locale "workspace.shape.menu.go-master") + [:& menu-entry {:title (t locale "workspace.shape.menu.go-main") :on-click do-navigate-component-file}] - [:& menu-entry {:title (t locale "workspace.shape.menu.update-master") + [:& menu-entry {:title (t locale "workspace.shape.menu.update-main") :on-click do-update-remote-component}]])) [:& menu-separator] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs index 743b44b4d..b7cb17fc1 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs @@ -94,11 +94,11 @@ :options (if (= (:component-file values) current-file-id) [[(t locale "workspace.shape.menu.detach-instance") do-detach-component] [(t locale "workspace.shape.menu.reset-overrides") do-reset-component] - [(t locale "workspace.shape.menu.update-master") do-update-component] - [(t locale "workspace.shape.menu.show-master") do-show-component]] + [(t locale "workspace.shape.menu.update-main") do-update-component] + [(t locale "workspace.shape.menu.show-main") do-show-component]] [[(t locale "workspace.shape.menu.detach-instance") do-detach-component] [(t locale "workspace.shape.menu.reset-overrides") do-reset-component] - [(t locale "workspace.shape.menu.go-master") do-navigate-component-file] - [(t locale "workspace.shape.menu.update-master") do-update-remote-component]])}]]]]]))) + [(t locale "workspace.shape.menu.go-main") do-navigate-component-file] + [(t locale "workspace.shape.menu.update-main") do-update-remote-component]])}]]]]]))) diff --git a/frontend/tests/app/test_components_basic.cljs b/frontend/tests/app/test_components_basic.cljs index 5f46a3366..31c158c62 100644 --- a/frontend/tests/app/test_components_basic.cljs +++ b/frontend/tests/app/test_components_basic.cljs @@ -33,7 +33,7 @@ (let [shape1 (thp/get-shape new-state :shape1) [[group shape1] [c-group c-shape1] component] - (thl/resolve-instance-and-master + (thl/resolve-instance-and-main new-state (:parent-id shape1)) @@ -79,7 +79,7 @@ [[group shape1 shape2] [c-group c-shape1 c-shape2] component] - (thl/resolve-instance-and-master + (thl/resolve-instance-and-main new-state (:parent-id shape1)) @@ -129,7 +129,7 @@ (let [[[group shape1 shape2] [c-group c-shape1 c-shape2] component] - (thl/resolve-instance-and-master + (thl/resolve-instance-and-main new-state (thp/id :group1)) @@ -221,7 +221,7 @@ [[instance1 shape1] [c-instance1 c-shape1] component1] - (thl/resolve-instance-and-master + (thl/resolve-instance-and-main new-state (:id instance1)) @@ -314,7 +314,7 @@ [[instance2 shape2] [c-instance2 c-shape2] component] - (thl/resolve-instance-and-master + (thl/resolve-instance-and-main new-state new-instance-id)] diff --git a/frontend/tests/app/test_components_sync.cljs b/frontend/tests/app/test_components_sync.cljs index a7ae79ce3..5fa6bcd12 100644 --- a/frontend/tests/app/test_components_sync.cljs +++ b/frontend/tests/app/test_components_sync.cljs @@ -44,7 +44,7 @@ (let [shape1 (thp/get-shape new-state :shape1) [[group shape1] [c-group c-shape1] component] - (thl/resolve-instance-and-master + (thl/resolve-instance-and-main new-state (:id instance1)) @@ -98,7 +98,7 @@ (let [shape1 (thp/get-shape new-state :shape1) [[group shape1] [c-group c-shape1] component] - (thl/resolve-instance-and-master + (thl/resolve-instance-and-main new-state (:id instance1)) diff --git a/frontend/tests/app/test_helpers/libraries.cljs b/frontend/tests/app/test_helpers/libraries.cljs index 7e275f100..aa6289445 100644 --- a/frontend/tests/app/test_helpers/libraries.cljs +++ b/frontend/tests/app/test_helpers/libraries.cljs @@ -79,7 +79,7 @@ shapes-inst)) -(defn resolve-instance-and-master +(defn resolve-instance-and-main [state root-inst-id] (let [page (thp/current-page state) root-inst (cph/get-shape page root-inst-id) @@ -94,26 +94,26 @@ shapes-inst (cph/get-object-with-children root-inst-id (:objects page)) - shapes-master (cph/get-object-with-children + shapes-main (cph/get-object-with-children (:shape-ref root-inst) (:objects component)) unique-refs (into #{} (map :shape-ref shapes-inst)) - master-exists? (fn [shape] - (t/is (some #(= (:id %) (:shape-ref shape)) - shapes-master)))] + main-exists? (fn [shape] + (t/is (some #(= (:id %) (:shape-ref shape)) + shapes-main)))] ;; Validate that the instance tree is well constructed (t/is (is-instance-root (first shapes-inst))) (run! is-instance-child (rest shapes-inst)) - (run! is-noninstance shapes-master) + (run! is-noninstance shapes-main) (t/is (= (count shapes-inst) - (count shapes-master) + (count shapes-main) (count unique-refs))) - (run! master-exists? shapes-inst) + (run! main-exists? shapes-inst) - [shapes-inst shapes-master component])) + [shapes-inst shapes-main component])) (defn resolve-component [state component-id] @@ -126,14 +126,14 @@ file nil) - root-master (cph/get-component-root - component) - shapes-master (cph/get-object-with-children - (:id root-master) - (:objects component))] + root-main (cph/get-component-root + component) + shapes-main (cph/get-object-with-children + (:id root-main) + (:objects component))] ;; Validate that the component tree is well constructed - (run! is-noninstance shapes-master) + (run! is-noninstance shapes-main) - [shapes-master component])) + [shapes-main component]))