diff --git a/backend/src/app/migrations.clj b/backend/src/app/migrations.clj
index 95a2ebfb92..b6a912fd95 100644
--- a/backend/src/app/migrations.clj
+++ b/backend/src/app/migrations.clj
@@ -590,7 +590,10 @@
:fn (mg/resource "app/migrations/sql/0813-mod-file-task-add-comment.sql")}
{:name "0814-mod-file-task-give-thread"
- :fn (mg/resource "app/migrations/sql/0814-mod-file-task-give-thread.sql")}])
+ :fn (mg/resource "app/migrations/sql/0814-mod-file-task-give-thread.sql")}
+
+ {:name "0815-add-file-branch-change-review-table"
+ :fn (mg/resource "app/migrations/sql/0815-add-file-branch-change-review-table.sql")}])
(defn apply-migrations!
[pool name migrations]
diff --git a/backend/src/app/migrations/sql/0815-add-file-branch-change-review-table.sql b/backend/src/app/migrations/sql/0815-add-file-branch-change-review-table.sql
new file mode 100644
index 0000000000..8e093f2b15
--- /dev/null
+++ b/backend/src/app/migrations/sql/0815-add-file-branch-change-review-table.sql
@@ -0,0 +1,29 @@
+-- The changes of a branch a person has marked as reviewed while comparing
+-- it with main: one row per profile, branch, direction of the comparison
+-- and change.
+--
+-- `change_key` names the change in the comparison
+-- (`app.common.files.branch-merge/change-key`) and `fingerprint` is a
+-- digest of what the change was when it was marked. The reader of the
+-- comparison drops a mark whose fingerprint no longer matches, so a
+-- layer that changes again asks to be reviewed again without anything
+-- being invalidated when the branch is saved.
+--
+-- `direction` is `branch->main` for the changes of the branch and
+-- `main->branch` for the ones main has: the same layer can change on
+-- both sides, and each change is reviewed on its own.
+
+CREATE TABLE file_branch_change_review (
+ file_branch_id uuid NOT NULL REFERENCES file_branch(id) ON DELETE CASCADE DEFERRABLE,
+ profile_id uuid NOT NULL REFERENCES profile(id) ON DELETE CASCADE DEFERRABLE,
+ direction text NOT NULL,
+ change_key text NOT NULL,
+
+ fingerprint text NOT NULL,
+ created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
+
+ PRIMARY KEY (file_branch_id, profile_id, direction, change_key)
+);
+
+CREATE INDEX file_branch_change_review__profile_id__idx
+ ON file_branch_change_review(profile_id);
diff --git a/backend/src/app/rpc/commands/files_branch.clj b/backend/src/app/rpc/commands/files_branch.clj
index 98fc3384d2..e85e9da959 100644
--- a/backend/src/app/rpc/commands/files_branch.clj
+++ b/backend/src/app/rpc/commands/files_branch.clj
@@ -2071,6 +2071,87 @@
(files/check-read-permissions! cfg profile-id main-id)
(db/exec! conn [sql:get-file-branch-merges main-id])))))
+;; --- COMMANDS: the changes a profile marked as reviewed
+
+(defn- get-readable-branch
+ "The branch `branch-id`, once `profile-id` is known to read its main.
+ Raises when there is no such branch."
+ [{:keys [::db/conn] :as cfg} profile-id branch-id]
+ (let [branch (db/get* conn :file-branch {:id branch-id})]
+ (when (nil? branch)
+ (ex/raise :type :not-found
+ :code :branch-not-found
+ :hint "unable to find branch with the provided id"
+ :branch-id branch-id))
+ (files/check-read-permissions! cfg profile-id (:source-file-id branch))
+ branch))
+
+(def ^:private schema:get-branch-change-reviews
+ [:map {:title "get-branch-change-reviews"}
+ [:branch-id ::sm/uuid]
+ [:direction [:enum :branch->main :main->branch]]])
+
+(def ^:private sql:get-branch-change-reviews
+ "SELECT r.change_key, r.fingerprint
+ FROM file_branch_change_review AS r
+ WHERE r.file_branch_id = ?
+ AND r.profile_id = ?
+ AND r.direction = ?")
+
+(sv/defmethod ::get-branch-change-reviews
+ "The changes of a comparison the profile marked as reviewed, each with
+ the fingerprint of the change when it was marked. The marks are the
+ profile's own: nobody else's are returned. A mark whose fingerprint no
+ longer matches its change is stale, which the reader of the comparison
+ decides: the change may have moved since."
+ {::doc/added "2.16"
+ ::sm/params schema:get-branch-change-reviews}
+ [cfg {:keys [::rpc/profile-id branch-id direction]}]
+ (check-branching-enabled!)
+ (db/run! cfg
+ (fn [{:keys [::db/conn] :as cfg}]
+ (get-readable-branch cfg profile-id branch-id)
+ (db/exec! conn [sql:get-branch-change-reviews
+ branch-id profile-id (name direction)]))))
+
+(def ^:private schema:set-branch-change-review
+ [:map {:title "set-branch-change-review"}
+ [:branch-id ::sm/uuid]
+ [:direction [:enum :branch->main :main->branch]]
+ [:change-key [:string {:max 500}]]
+ [:fingerprint [:string {:max 250}]]
+ [:reviewed ::sm/boolean]])
+
+(def ^:private sql:upsert-branch-change-review
+ "INSERT INTO file_branch_change_review
+ (file_branch_id, profile_id, direction, change_key, fingerprint)
+ VALUES (?, ?, ?, ?, ?)
+ ON CONFLICT (file_branch_id, profile_id, direction, change_key)
+ DO UPDATE SET fingerprint = EXCLUDED.fingerprint,
+ created_at = clock_timestamp()")
+
+(sv/defmethod ::set-branch-change-review
+ "Mark a change of a comparison as reviewed by the profile, with the
+ fingerprint of the change as it stands, or clear the mark. Reading the
+ branch is enough: the mark is the profile's own note and changes
+ nothing of the branch."
+ {::doc/added "2.16"
+ ::sm/params schema:set-branch-change-review
+ ::db/transaction true}
+ [{:keys [::db/conn] :as cfg}
+ {:keys [::rpc/profile-id branch-id direction change-key fingerprint reviewed]}]
+ (check-branching-enabled!)
+ (get-readable-branch cfg profile-id branch-id)
+ (if reviewed
+ (db/exec-one! conn [sql:upsert-branch-change-review
+ branch-id profile-id (name direction) change-key fingerprint])
+ (db/delete! conn :file-branch-change-review
+ {:file-branch-id branch-id
+ :profile-id profile-id
+ :direction (name direction)
+ :change-key change-key}))
+ nil)
+
;; --- COMMAND: update-file-branch (rename / description)
(def ^:private schema:update-file-branch
diff --git a/backend/test/backend_tests/rpc_file_branch_test.clj b/backend/test/backend_tests/rpc_file_branch_test.clj
index 0ff1177d2c..b2a8de9297 100644
--- a/backend/test/backend_tests/rpc_file_branch_test.clj
+++ b/backend/test/backend_tests/rpc_file_branch_test.clj
@@ -3236,3 +3236,83 @@
(= main-1 (:id %))
(= :deleted (:status %)))
(:changes diff))))))))
+
+;;; --- The changes a profile marked as reviewed ---
+
+(t/deftest review-marks-belong-to-a-profile-a-direction-and-a-change
+ (with-redefs [cf/flags (conj cf/flags :branching)]
+ (let [owner (th/create-profile* 1 {:is-active true})
+ mate (th/create-profile* 2 {:is-active true})
+ stranger (th/create-profile* 3 {:is-active true})
+ file (th/create-file* 1 {:profile-id (:id owner)
+ :project-id (:default-project-id owner)
+ :is-shared false})
+ _ (th/create-team-role* {:team-id (:default-team-id owner)
+ :profile-id (:id mate)
+ :role :editor})
+ branch (:result (th/command! {::th/type :create-file-branch
+ ::rpc/profile-id (:id owner)
+ :file-id (:id file)
+ :name "review-marks"}))
+ mark (fn [profile direction change-key fingerprint reviewed]
+ (th/command! {::th/type :set-branch-change-review
+ ::rpc/profile-id (:id profile)
+ :branch-id (:id branch)
+ :direction direction
+ :change-key change-key
+ :fingerprint fingerprint
+ :reviewed reviewed}))
+ marks (fn [profile direction]
+ (let [out (th/command! {::th/type :get-branch-change-reviews
+ ::rpc/profile-id (:id profile)
+ :branch-id (:id branch)
+ :direction direction})]
+ (t/is (nil? (:error out)))
+ (into {} (map (juxt :change-key :fingerprint)) (:result out))))]
+
+ (t/testing "a mark is read back with its fingerprint"
+ (t/is (nil? (:error (mark owner :branch->main "shape/p/1" "a1" true))))
+ (t/is (nil? (:error (mark owner :branch->main "shape/p/2" "b1" true))))
+ (t/is (= {"shape/p/1" "a1" "shape/p/2" "b1"} (marks owner :branch->main))))
+
+ (t/testing "marking again keeps one mark, with the newest fingerprint"
+ (t/is (nil? (:error (mark owner :branch->main "shape/p/1" "a2" true))))
+ (t/is (= {"shape/p/1" "a2" "shape/p/2" "b1"} (marks owner :branch->main))))
+
+ (t/testing "each direction has its own marks"
+ (t/is (= {} (marks owner :main->branch)))
+ (t/is (nil? (:error (mark owner :main->branch "shape/p/1" "m1" true))))
+ (t/is (= {"shape/p/1" "m1"} (marks owner :main->branch)))
+ (t/is (= "a2" (get (marks owner :branch->main) "shape/p/1"))))
+
+ (t/testing "the marks of a profile are not anybody else's"
+ (t/is (= {} (marks mate :branch->main)))
+ (t/is (nil? (:error (mark mate :branch->main "shape/p/2" "theirs" true))))
+ (t/is (= {"shape/p/2" "theirs"} (marks mate :branch->main)))
+ (t/is (= "b1" (get (marks owner :branch->main) "shape/p/2"))))
+
+ (t/testing "clearing a mark removes that one alone"
+ (t/is (nil? (:error (mark owner :branch->main "shape/p/1" "a2" false))))
+ (t/is (= {"shape/p/2" "b1"} (marks owner :branch->main)))
+ (t/is (= {"shape/p/1" "m1"} (marks owner :main->branch)))
+ (t/is (= {"shape/p/2" "theirs"} (marks mate :branch->main))))
+
+ (t/testing "a profile that cannot read the file neither marks nor reads"
+ (let [out (mark stranger :branch->main "shape/p/1" "x" true)]
+ (t/is (th/ex-info? (:error out)))
+ (t/is (= :not-found (th/ex-type (:error out)))))
+ (let [out (th/command! {::th/type :get-branch-change-reviews
+ ::rpc/profile-id (:id stranger)
+ :branch-id (:id branch)
+ :direction :branch->main})]
+ (t/is (= :not-found (th/ex-type (:error out)))))
+ (t/is (= {"shape/p/2" "b1"} (marks owner :branch->main))
+ "the refused mark was not written"))
+
+ (t/testing "a branch that does not exist is not found"
+ (let [out (th/command! {::th/type :get-branch-change-reviews
+ ::rpc/profile-id (:id owner)
+ :branch-id (uuid/next)
+ :direction :branch->main})]
+ (t/is (= :not-found (th/ex-type (:error out))))
+ (t/is (= :branch-not-found (th/ex-code (:error out)))))))))
diff --git a/frontend/playwright/data/compare/get-branch-change-reviews-empty.json b/frontend/playwright/data/compare/get-branch-change-reviews-empty.json
new file mode 100644
index 0000000000..fe51488c70
--- /dev/null
+++ b/frontend/playwright/data/compare/get-branch-change-reviews-empty.json
@@ -0,0 +1 @@
+[]
diff --git a/frontend/playwright/data/compare/get-branch-diff-changes.json b/frontend/playwright/data/compare/get-branch-diff-changes.json
new file mode 100644
index 0000000000..e713e2bcfa
--- /dev/null
+++ b/frontend/playwright/data/compare/get-branch-diff-changes.json
@@ -0,0 +1,34 @@
+{
+ "~:changes": [
+ {
+ "~:kind": "~:color",
+ "~:status": "~:modified",
+ "~:id": "~uc7ce0794-0992-8105-8004-38f2804439a1",
+ "~:key": "color//c7ce0794-0992-8105-8004-38f2804439a1",
+ "~:label": "Brand",
+ "~:changed-attrs": {
+ "~:color": { "~:main": "#000000", "~:branch": "#ff0000" }
+ }
+ },
+ {
+ "~:kind": "~:typography",
+ "~:status": "~:added",
+ "~:id": "~uc7ce0794-0992-8105-8004-38f2804439a2",
+ "~:key": "typography//c7ce0794-0992-8105-8004-38f2804439a2",
+ "~:label": "Heading"
+ }
+ ],
+ "~:conflicts": [],
+ "~:stats": {
+ "~:added": 1,
+ "~:modified": 1,
+ "~:deleted": 0,
+ "~:conflicts": 0
+ },
+ "~:meta": {
+ "~:base-at": "~m1713536343369",
+ "~:main-at": "~m1713873823633",
+ "~:branch-at": "~m1713873823633",
+ "~:main-revn": 11
+ }
+}
diff --git a/frontend/playwright/data/compare/get-branch-diff-conflicts.json b/frontend/playwright/data/compare/get-branch-diff-conflicts.json
new file mode 100644
index 0000000000..667220a328
--- /dev/null
+++ b/frontend/playwright/data/compare/get-branch-diff-conflicts.json
@@ -0,0 +1,96 @@
+{
+ "~:changes": [],
+ "~:conflicts": [
+ {
+ "~:kind": "~:color",
+ "~:status": "~:conflict",
+ "~:reason": "~:modify-modify",
+ "~:id": "~uc7ce0794-0992-8105-8004-38f2804439b1",
+ "~:key": "color//c7ce0794-0992-8105-8004-38f2804439b1",
+ "~:label": "Brand",
+ "~:base": { "~:name": "Brand", "~:color": "#000000", "~:opacity": 1 },
+ "~:main": { "~:name": "Brand", "~:color": "#00ff00", "~:opacity": 1 },
+ "~:branch": { "~:name": "Brand", "~:color": "#ff0000", "~:opacity": 1 },
+ "~:changed-attrs": {
+ "~:color": { "~:main": "#00ff00", "~:branch": "#ff0000" }
+ }
+ },
+ {
+ "~:kind": "~:shape",
+ "~:status": "~:conflict",
+ "~:reason": "~:modify-modify",
+ "~:id": "~uc7ce0794-0992-8105-8004-38f2804439b2",
+ "~:page-id": "~u66697432-c33d-8055-8006-2c62cc084cad",
+ "~:key": "shape/66697432-c33d-8055-8006-2c62cc084cad/c7ce0794-0992-8105-8004-38f2804439b2",
+ "~:label": "Legal footnote",
+ "~:shape-type": "~:text",
+ "~:base": {
+ "~:type": "~:text",
+ "~:content": {
+ "~:type": "root",
+ "~:children": [
+ {
+ "~:type": "paragraph-set",
+ "~:children": [
+ { "~:type": "paragraph", "~:children": [{ "~:text": "Terms apply." }] }
+ ]
+ }
+ ]
+ }
+ },
+ "~:main": {
+ "~:type": "~:text",
+ "~:content": {
+ "~:type": "root",
+ "~:children": [
+ {
+ "~:type": "paragraph-set",
+ "~:children": [
+ { "~:type": "paragraph", "~:children": [{ "~:text": "Our terms apply." }] }
+ ]
+ }
+ ]
+ }
+ },
+ "~:branch": {
+ "~:type": "~:text",
+ "~:content": {
+ "~:type": "root",
+ "~:children": [
+ {
+ "~:type": "paragraph-set",
+ "~:children": [
+ { "~:type": "paragraph", "~:children": [{ "~:text": "The terms of sale apply." }] }
+ ]
+ }
+ ]
+ }
+ },
+ "~:changed-attrs": {
+ "~:content": {}
+ }
+ },
+ {
+ "~:kind": "~:typography",
+ "~:status": "~:conflict",
+ "~:reason": "~:modify-delete",
+ "~:id": "~uc7ce0794-0992-8105-8004-38f2804439b3",
+ "~:key": "typography//c7ce0794-0992-8105-8004-38f2804439b3",
+ "~:label": "Heading",
+ "~:main": null,
+ "~:branch": { "~:name": "Heading", "~:font-size": "32" }
+ }
+ ],
+ "~:stats": {
+ "~:added": 0,
+ "~:modified": 0,
+ "~:deleted": 0,
+ "~:conflicts": 3
+ },
+ "~:meta": {
+ "~:base-at": "~m1713536343369",
+ "~:main-at": "~m1713873823633",
+ "~:branch-at": "~m1713873823633",
+ "~:main-revn": 11
+ }
+}
diff --git a/frontend/playwright/data/compare/set-branch-change-review.json b/frontend/playwright/data/compare/set-branch-change-review.json
new file mode 100644
index 0000000000..19765bd501
--- /dev/null
+++ b/frontend/playwright/data/compare/set-branch-change-review.json
@@ -0,0 +1 @@
+null
diff --git a/frontend/playwright/ui/specs/branch-compare.spec.js b/frontend/playwright/ui/specs/branch-compare.spec.js
new file mode 100644
index 0000000000..bacb9977a5
--- /dev/null
+++ b/frontend/playwright/ui/specs/branch-compare.spec.js
@@ -0,0 +1,186 @@
+import { test, expect } from "@playwright/test";
+import { WorkspacePage } from "../pages/WorkspacePage";
+
+const BRAND_KEY = "color//c7ce0794-0992-8105-8004-38f2804439a1";
+
+test.beforeEach(async ({ page }) => {
+ await WorkspacePage.init(page);
+ await WorkspacePage.mockConfigFlags(page, ["enable-branching"]);
+});
+
+// The open file is the branch "checkout"; `diff` is what comparing it with
+// main lists, in either direction.
+const setupBranch = async (workspacePage, diff) => {
+ await workspacePage.setupEmptyFile();
+ await workspacePage.mockRPCs({
+ "get-file-branch-info?file-id=*":
+ "pull-requests/get-file-branch-info-branch.json",
+ "get-file-branches?file-id=*": "pull-requests/get-file-branches-empty.json",
+ "get-file-pull-requests?file-id=*":
+ "pull-requests/get-file-branches-empty.json",
+ "get-file-tasks?file-id=*": "pull-requests/get-file-branches-empty.json",
+ "get-branch-diff?branch-id=*": `compare/${diff}`,
+ "get-branch-change-reviews?branch-id=*":
+ "compare/get-branch-change-reviews-empty.json",
+ "set-branch-change-review": "compare/set-branch-change-review.json",
+ });
+};
+
+const banner = (page) => page.locator("#branch-banner");
+const changes = (page) => page.getByTestId("left-sidebar");
+const detail = (page) => page.getByTestId("right-sidebar");
+
+const enterCompare = async (page) => {
+ await banner(page).getByRole("button", { name: "Compare" }).click();
+ await expect(banner(page).getByText("Comparing with main")).toBeVisible();
+};
+
+test("comparing takes the canvas, read-only, and Escape leaves it", async ({
+ page,
+}) => {
+ const workspacePage = new WorkspacePage(page);
+ await setupBranch(workspacePage, "get-branch-diff-changes.json");
+ await workspacePage.goToWorkspace();
+ await enterCompare(page);
+
+ // no dialog: the changes take the left sidebar and the drawing tools go
+ await expect(page.getByRole("dialog")).toBeHidden();
+ await expect(changes(page).getByText("View only")).toBeVisible();
+ await expect(
+ changes(page).getByRole("tab", { name: "In this branch (2)" }),
+ ).toBeVisible();
+ await expect(changes(page).getByText("Brand")).toBeVisible();
+ await expect(changes(page).getByText("Heading")).toBeVisible();
+ await expect(
+ page.getByRole("toolbar", { name: "Drawing tools" }),
+ ).toBeHidden();
+ await expect(
+ page.getByRole("toolbar", { name: "Compare tools" }),
+ ).toBeVisible();
+
+ await page.keyboard.press("Escape");
+ await expect(banner(page).getByText("1 change not in main")).toBeVisible();
+ await expect(
+ page.getByRole("toolbar", { name: "Drawing tools" }),
+ ).toBeVisible();
+});
+
+test("a change left out stays out of the merge", async ({ page }) => {
+ const workspacePage = new WorkspacePage(page);
+ await setupBranch(workspacePage, "get-branch-diff-changes.json");
+ await workspacePage.goToWorkspace();
+ await enterCompare(page);
+
+ await expect(
+ banner(page).getByRole("button", { name: "Merge 2 changes" }),
+ ).toBeVisible();
+
+ // the list opens on its first change: its detail says what it did, and
+ // leaves it out
+ await expect(detail(page).getByText("#000000")).toBeVisible();
+ await expect(detail(page).getByText("#ff0000")).toBeVisible();
+ await detail(page)
+ .getByRole("button", { name: "Leave out of merge" })
+ .click();
+ await expect(
+ changes(page).getByText("Left out", { exact: true }),
+ ).toBeVisible();
+ await expect(banner(page).getByText("1 left out")).toBeVisible();
+
+ // merging asks first, and sends what was left out
+ const merge = page.waitForRequest(
+ (req) =>
+ req.url().includes("merge-file-branch") &&
+ (req.postData() ?? "").includes(BRAND_KEY),
+ );
+ await banner(page).getByRole("button", { name: "Merge 1 change" }).click();
+ await expect(page.getByText("1 change is left out.")).toBeVisible();
+ await page.getByRole("button", { name: "Merge", exact: true }).click();
+ await merge;
+});
+
+test("main's changes are listed apart and update the branch", async ({
+ page,
+}) => {
+ const workspacePage = new WorkspacePage(page);
+ await setupBranch(workspacePage, "get-branch-diff-changes.json");
+ await workspacePage.goToWorkspace();
+ await enterCompare(page);
+
+ const incoming = page.waitForRequest(
+ (req) =>
+ req.url().includes("get-branch-diff") &&
+ req.url().includes("main-%3Ebranch"),
+ );
+ await changes(page).getByRole("tab", { name: "In main" }).click();
+ await incoming;
+ await expect(banner(page).getByText("main has 2 new changes")).toBeVisible();
+ await expect(
+ changes(page).getByRole("tab", { name: "In main (2)" }),
+ ).toBeVisible();
+ // the other direction keeps the count it had
+ await expect(
+ changes(page).getByRole("tab", { name: "In this branch (2)" }),
+ ).toBeVisible();
+
+ const update = page.waitForRequest((req) =>
+ req.url().includes("update-branch-from-main"),
+ );
+ await banner(page)
+ .getByRole("button", { name: "Update with 2 changes" })
+ .click();
+ await page.getByRole("button", { name: "Update", exact: true }).click();
+ await update;
+});
+
+test("conflicts are decided in the sidebar before they apply", async ({
+ page,
+}) => {
+ const workspacePage = new WorkspacePage(page);
+ await setupBranch(workspacePage, "get-branch-diff-conflicts.json");
+ await workspacePage.goToWorkspace();
+ await enterCompare(page);
+
+ await banner(page)
+ .getByRole("button", { name: "Resolve 3 decisions" })
+ .click();
+ await expect(banner(page).getByText("3 conflicts with main")).toBeVisible();
+ await expect(banner(page).getByText("0 of 3 decided")).toBeVisible();
+ const apply = banner(page).getByRole("button", { name: "Apply and merge" });
+ await expect(apply).toBeDisabled();
+ await expect(changes(page).getByText("Needs a decision (3)")).toBeVisible();
+
+ // a property: the value of a side keeps that side. The list opens on
+ // its first conflict; a click on its row would let it go
+ await detail(page).getByRole("button", { name: "#ff0000" }).click();
+ await expect(banner(page).getByText("1 of 3 decided")).toBeVisible();
+
+ // a text: one whole text is kept
+ await changes(page).getByText("Legal footnote").click();
+ await expect(detail(page).getByText("¶1 Our terms apply.")).toBeVisible();
+ await detail(page)
+ .getByRole("radio")
+ .filter({ hasText: "The terms of sale apply." })
+ .click();
+ await expect(banner(page).getByText("2 of 3 decided")).toBeVisible();
+ await expect(apply).toBeDisabled();
+
+ // an entity one side deleted: one of the two versions
+ await changes(page).getByText("Heading").click();
+ await expect(detail(page).getByText("This version deletes it")).toBeVisible();
+ await detail(page).getByRole("radio").last().click();
+ await expect(banner(page).getByText("All conflicts decided")).toBeVisible();
+ await expect(changes(page).getByText("Decided (3)")).toBeVisible();
+
+ const merge = page.waitForRequest((req) => {
+ const body = req.postData() ?? "";
+ return (
+ req.url().includes("merge-file-branch") &&
+ body.includes("38f2804439b1") &&
+ body.includes("38f2804439b2") &&
+ body.includes("38f2804439b3")
+ );
+ });
+ await apply.click();
+ await merge;
+});
diff --git a/frontend/playwright/ui/specs/merged-and-archived-branches.spec.js b/frontend/playwright/ui/specs/merged-and-archived-branches.spec.js
index 7acef87809..aeb071f2a0 100644
--- a/frontend/playwright/ui/specs/merged-and-archived-branches.spec.js
+++ b/frontend/playwright/ui/specs/merged-and-archived-branches.spec.js
@@ -145,7 +145,9 @@ test("the branch list offers Restore for archived branches only", async ({
const info = page.getByRole("dialog").filter({ hasText: "Branch info" });
await expect(info.getByRole("button", { name: "Restore" })).toBeVisible();
- await expect(info.getByRole("button", { name: "Compare" })).toBeVisible();
+ // a branch is compared from its own file: from another one it opens first
+ await expect(info.getByRole("button", { name: "Compare" })).toBeHidden();
+ await expect(info.getByRole("button", { name: "Open branch" })).toBeVisible();
await expect(
info.getByRole("button", { name: "Turn into an ordinary file" }),
).toBeVisible();
diff --git a/frontend/playwright/ui/specs/pull-requests.spec.js b/frontend/playwright/ui/specs/pull-requests.spec.js
index 9735caad4d..09986d2e5a 100644
--- a/frontend/playwright/ui/specs/pull-requests.spec.js
+++ b/frontend/playwright/ui/specs/pull-requests.spec.js
@@ -36,9 +36,7 @@ test("opening a file with pr-id enters the design review", async ({ page }) => {
// file name for the title of the review
const bar = reviewBar(page);
await expect(bar).toBeVisible();
- await expect(
- bar.getByText("Reviewing the design review", { exact: true }),
- ).toBeVisible();
+ await expect(bar.getByText("In review", { exact: true })).toBeVisible();
await expect(
bar.getByText("Checkout redesign", { exact: true }),
).toBeVisible();
@@ -60,17 +58,27 @@ test("opening a file with pr-id enters the design review", async ({ page }) => {
await expect(page.getByText("Cancel review")).toBeVisible();
});
-test("the compare dialog shows the proposed changes", async ({ page }) => {
+test("comparing shows the proposed changes on the canvas", async ({ page }) => {
const workspacePage = new WorkspacePage(page);
await setupPullRequestSandbox(workspacePage);
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
// comparing is one of the review bar's options
- await reviewBar(page).getByRole("button", { name: "Options" }).click();
+ const bar = reviewBar(page);
+ await bar.getByRole("button", { name: "Options" }).click();
await page.getByText("Compare", { exact: true }).click();
- // the branching compare dialog is reused to inspect the changes
- await expect(page.getByText("Review changes")).toBeVisible();
+ // the review bar belongs to the comparison, and the changes take the
+ // left sidebar: no dialog opens
+ await expect(bar.getByText("Comparing", { exact: true })).toBeVisible();
+ await expect(page.getByRole("dialog")).toBeHidden();
+ await expect(
+ page.getByTestId("left-sidebar").getByText("View only"),
+ ).toBeVisible();
+
+ // leaving the comparison goes back to the review
+ await bar.getByRole("button", { name: "Exit compare" }).click();
+ await expect(bar.getByText("In review", { exact: true })).toBeVisible();
});
test("accepting the pull request opens the merge dialog", async ({ page }) => {
@@ -139,7 +147,10 @@ test("an assigned reviewer can submit a verdict from the review bar", async ({
dialog.getByRole("heading", { name: "Submit review" }),
).toBeVisible();
- await dialog.getByRole("button", { name: "Request changes" }).click();
+ // the verdicts are a choice of one: radios, each with its hint
+ const requestChanges = dialog.getByRole("radio", { name: /Request changes/ });
+ await requestChanges.click();
+ await expect(requestChanges).toBeChecked();
await dialog.getByRole("button", { name: "Submit review" }).click();
await expect(page.getByText("Review submitted")).toBeVisible();
@@ -200,10 +211,10 @@ test("exiting the review takes the user back to the file", async ({ page }) => {
await setupPullRequestSandbox(workspacePage);
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
+ // the way out is an icon button on the bar, named by its tooltip
const banner = reviewBar(page);
await expect(banner).toBeVisible();
- await banner.getByRole("button", { name: "Options" }).click();
- await page.getByText("Exit review").click();
+ await banner.getByRole("button", { name: "Exit review" }).click();
// exiting drops the review context and the pr-id param; the file (the
// live branch) stays as it was
diff --git a/frontend/scripts/check-translations/words.es.txt b/frontend/scripts/check-translations/words.es.txt
index 5111ebe320..7699ec28f7 100644
--- a/frontend/scripts/check-translations/words.es.txt
+++ b/frontend/scripts/check-translations/words.es.txt
@@ -228,6 +228,7 @@ autoguardado
autoreferencia
ayudarnos
ayudarte
+bloqueo
borradores
borrarlo
bloquearla
@@ -249,6 +250,9 @@ contactarnos
contener
contiene
contexto
+contraer
+convertirla
+convertirse
danos
demás
desactivarlos
@@ -256,6 +260,7 @@ desbloquearla
deseleccionar
desuscripción
durante
+editarla
editores
eje
eliminarla
@@ -263,6 +268,8 @@ eliminarlo
eliminarlos
ella
ellos
+enlazarla
+enviarla
ese
eso
esos
@@ -278,11 +285,17 @@ hubo
importada
iniciarse
instalarla
+intentarlo
invitaciones
+lados
lectores
+leen
letras
+mal
manifiesto
menos
+mesa
+nodos
nosotros
otras
pero
@@ -295,7 +308,10 @@ proveedores
publicarla
publicarlo
puesto
+queda
+quienes
regenerada
+restaurarla
restaurarlo
restaurarlos
sal
@@ -306,6 +322,7 @@ sino
solicitudes
soportada
sufijo
+suya
tanto
temas
tenerte
@@ -319,6 +336,7 @@ unos
usarlas
utilizada
verla
+verlo
versiones
verticales
vincularse
diff --git a/frontend/src/app/main/data/changes.cljs b/frontend/src/app/main/data/changes.cljs
index 6a0d8f6540..aa68604b96 100644
--- a/frontend/src/app/main/data/changes.cljs
+++ b/frontend/src/app/main/data/changes.cljs
@@ -299,7 +299,8 @@
permissions (get state :permissions)]
;; Historical previews must not create edits to the live file, and
- ;; a design review is read-only (the branch is edited outside it).
+ ;; a design review and the comparison of a branch with main are
+ ;; read-only (the branch is edited outside them).
;; Check this when creating commits so previously queued edits can
;; still save. While saves fail, a user edit would queue behind the
;; failed save. Refusals answer with an empty stream (never nil) so
@@ -307,6 +308,7 @@
(if (and (:can-edit permissions)
(not (dm/get-in state [:workspace-global :preview-id]))
(not (contains? state :workspace-pr-preview))
+ (not (contains? state :workspace-compare))
(or ignore-save-lock (not (plk/locked? state))))
(do
(log/trace :hint "commit-changes" :redo-changes redo-changes)
diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs
index 2a6fa5a9cd..e723fa47eb 100644
--- a/frontend/src/app/main/data/workspace.cljs
+++ b/frontend/src/app/main/data/workspace.cljs
@@ -46,6 +46,7 @@
[app.main.data.workspace.colors :as dwcl]
[app.main.data.workspace.comments :as dwcm]
[app.main.data.workspace.common :as dwc]
+ [app.main.data.workspace.compare :as dwcmp]
[app.main.data.workspace.drawing :as dwd]
[app.main.data.workspace.edition :as dwe]
[app.main.data.workspace.fix-deleted-fonts :as fdf]
@@ -528,6 +529,10 @@
;; Keep comment thread positions in sync on undo/redo
(rx/of (dwcm/watch-comment-thread-position-changes stoper-s))
+ ;; The conflicts of a merge or an update are resolved on
+ ;; the canvas, in the compare mode
+ (rx/of (dwcmp/watch-events stoper-s))
+
;; Resize auto-grow text shapes whose selrect does not match
;; the WASM text layout once their fonts finish loading.
(->> stream
@@ -625,6 +630,8 @@
;; FIXME: revisit
(dissoc
:current-file-id
+ :workspace-branch-diff
+ :workspace-compare
:workspace-editor-state
:workspace-wasm-editor-styles
:workspace-media-objects
diff --git a/frontend/src/app/main/data/workspace/branches.cljs b/frontend/src/app/main/data/workspace/branches.cljs
index c0260171ab..25baf1228b 100644
--- a/frontend/src/app/main/data/workspace/branches.cljs
+++ b/frontend/src/app/main/data/workspace/branches.cljs
@@ -5,8 +5,9 @@
;; Copyright (c) KALEIDOS INC Sucursal en España SL
(ns app.main.data.workspace.branches
- "Data layer for file branching (Phase 1: create + list). Mirrors the
- patterns in `app.main.data.workspace.versions`."
+ "Data layer for file branching: the branches of a file, the diff of a
+ branch against main, and merging and updating it. Mirrors the patterns
+ in `app.main.data.workspace.versions`."
(:require
[app.config :as cf]
[app.main.data.common :as dcm]
@@ -416,6 +417,23 @@
;; COMPARE (read-only 3-way diff)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(defn item-key
+ "The key a change or a conflict of a diff is chosen and marked as
+ reviewed by: its change key
+ (`app.common.files.branch-merge/change-key`), or its kind and id for an
+ entry that carries none."
+ [item]
+ (or (:key item) (str (name (:kind item)) ":" (:id item))))
+
+(defn change-fingerprint
+ "A digest of what the diff entry `item` is: what happened to it and the
+ values it moved between. A review mark is kept with it, so a mark made
+ on a change that later became another one no longer counts."
+ [item]
+ (str (hash [(:status item) (:changed-attrs item) (:shape item) (:main item) (:branch item)])))
+
+(declare fetch-diff-reviewed)
+
(defn update-branch-diff
[diff-state]
(ptk/reify ::update-branch-diff
@@ -435,47 +453,46 @@
(ptk/reify ::fetch-branch-diff
ptk/UpdateEvent
(update [_ state]
- (let [prev (:workspace-branch-diff state)]
+ (let [prev (:workspace-branch-diff state)
+ same? (= branch-id (:branch-id prev))
+ same-direction? (and same? (= direction (:direction prev)))]
(assoc state :workspace-branch-diff
{:status :loading
:branch-id branch-id
:direction direction
- :selected nil
- ;; a refetch of the SAME comparison keeps the user's
- ;; per-change selection, review marks and conflict
- ;; choices (they name the same entities); a different
- ;; branch or direction starts over
- :excluded (if (and (= branch-id (:branch-id prev))
- (= direction (:direction prev)))
- (or (:excluded prev) #{})
- #{})
- :reviewed (if (= branch-id (:branch-id prev))
- (or (:reviewed prev) #{})
- #{})
- :resolutions (when (= branch-id (:branch-id prev))
- (:resolutions prev))})))
+ ;; a refetch for the SAME branch keeps the per-change
+ ;; selection of each direction and the conflict choices
+ ;; (they name the same entities), so going from one
+ ;; direction to the other and back loses nothing; a
+ ;; different branch starts over
+ :excluded (if same? (or (:excluded prev) {}) {})
+ ;; the review marks are the ones of the direction: they
+ ;; stay while it reloads, and load again with the diff
+ :reviewed (if same-direction? (or (:reviewed prev) #{}) #{})
+ :resolutions (when same? (:resolutions prev))})))
ptk/WatchEvent
(watch [_ _ stream]
(->> (rp/cmd! :get-branch-diff {:branch-id branch-id :direction direction})
- (rx/map #(update-branch-diff {:status :loaded :diff %}))
+ (rx/mapcat #(rx/of (update-branch-diff {:status :loaded :diff %})
+ (fetch-diff-reviewed)))
(rx/catch (fn [_]
(rx/of (update-branch-diff {:status :error}))))
(rx/take-until (rx/filter (ptk/type? ::fetch-branch-diff) stream)))))))
-(defn select-diff-change
- "Select a change/conflict (by its index in the diff) to show its detail."
- [selected]
- (ptk/reify ::select-diff-change
- ptk/UpdateEvent
- (update [_ state]
- (assoc-in state [:workspace-branch-diff :selected] selected))))
+(defn diff-excluded
+ "The per-change selection of `diff-state` (the `:workspace-branch-diff`
+ entry) for the direction it shows: the change keys left OUT of the
+ merge or update. Each direction keeps its own."
+ [diff-state]
+ (get-in diff-state [:excluded (:direction diff-state :branch->main)] #{}))
(defn toggle-diff-excluded
- "Toggle the per-change selection of the current diff. `change-keys` are
- change keys (`app.common.files.branch-merge/change-key`); a key the
- selection holds is left OUT of the merge or update, and a key it lacks
- travels. `include?` sets them all to that side instead of toggling (the
- group checkbox): nil flips the whole batch, which is what a single row
+ "Toggle the per-change selection of the current diff, in the direction
+ it shows. `change-keys` are change keys
+ (`app.common.files.branch-merge/change-key`); a key the selection holds
+ is left OUT of the merge or update, and a key it lacks travels.
+ `include?` sets them all to that side instead of toggling (the group
+ checkbox): nil flips the whole batch, which is what a single row
checkbox needs too."
([change-keys] (toggle-diff-excluded change-keys nil))
([change-keys include?]
@@ -483,22 +500,73 @@
(ptk/reify ::toggle-diff-excluded
ptk/UpdateEvent
(update [_ state]
- (update-in state [:workspace-branch-diff :excluded]
- (fn [excluded]
- (let [excluded (or excluded #{})
- include? (if (some? include?)
- include?
- (every? excluded change-keys))]
- (if include?
- (apply disj excluded change-keys)
- (into excluded change-keys)))))))))
+ (let [direction (get-in state [:workspace-branch-diff :direction] :branch->main)]
+ (update-in state [:workspace-branch-diff :excluded direction]
+ (fn [excluded]
+ (let [excluded (or excluded #{})
+ include? (if (some? include?)
+ include?
+ (every? excluded change-keys))]
+ (if include?
+ (apply disj excluded change-keys)
+ (into excluded change-keys))))))))))
+
+(defn- diff-items
+ "Every entry of the diff in `diff-state`, by its key (`item-key`)."
+ [diff-state]
+ (into {}
+ (map (juxt item-key identity))
+ (concat (get-in diff-state [:diff :changes])
+ (get-in diff-state [:diff :conflicts]))))
+
+(defn- set-diff-reviewed
+ "Keep `reviewed` as the review marks of the diff of `branch-id` in
+ `direction`, when that is still the one in the store."
+ [branch-id direction reviewed]
+ (ptk/reify ::set-diff-reviewed
+ ptk/UpdateEvent
+ (update [_ state]
+ (let [diff-st (:workspace-branch-diff state)]
+ (if (and (= branch-id (:branch-id diff-st))
+ (= direction (:direction diff-st)))
+ (assoc-in state [:workspace-branch-diff :reviewed] reviewed)
+ state)))))
+
+(defn fetch-diff-reviewed
+ "Load the changes the profile marked as reviewed in the comparison the
+ store holds. A mark counts while its change is still what it was when
+ it was marked (`change-fingerprint`): a layer that changed again asks
+ to be reviewed again. The marks are the profile's own and the same
+ inside and outside a design review. A failure leaves the marks as they
+ are."
+ []
+ (ptk/reify ::fetch-diff-reviewed
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [{:keys [branch-id direction status] :as diff-st} (:workspace-branch-diff state)]
+ (if (= :loaded status)
+ (let [items (diff-items diff-st)]
+ (->> (rp/cmd! :get-branch-change-reviews {:branch-id branch-id :direction direction})
+ (rx/map (fn [marks]
+ (set-diff-reviewed
+ branch-id direction
+ (into #{}
+ (keep (fn [{:keys [change-key fingerprint]}]
+ (when (= fingerprint
+ (some-> (get items change-key) change-fingerprint))
+ change-key)))
+ marks))))
+ (rx/catch (fn [_] (rx/empty)))))
+ (rx/empty))))))
(defn toggle-diff-reviewed
- "Mark the change `change-key` as reviewed in the compare dialog, or clear
- the mark. `reviewed?` forces one side; nil flips it. The marks only
- guide the review: the merge does not read them."
- ([change-key] (toggle-diff-reviewed change-key nil))
- ([change-key reviewed?]
+ "Mark the change `item-key` as reviewed in the compare mode, or clear
+ the mark. `reviewed?` forces one side; nil flips it. The mark shows at
+ once and is kept for the profile, with the fingerprint of the change
+ as it stands; if it cannot be kept, the marks are read again. The
+ marks only guide the review: the merge does not read them."
+ ([item-key] (toggle-diff-reviewed item-key nil))
+ ([item-key reviewed?]
(ptk/reify ::toggle-diff-reviewed
ptk/UpdateEvent
(update [_ state]
@@ -507,19 +575,35 @@
(let [reviewed (or reviewed #{})
reviewed? (if (some? reviewed?)
reviewed?
- (not (contains? reviewed change-key)))]
+ (not (contains? reviewed item-key)))]
(if reviewed?
- (conj reviewed change-key)
- (disj reviewed change-key)))))))))
+ (conj reviewed item-key)
+ (disj reviewed item-key))))))
+
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [{:keys [branch-id direction reviewed] :as diff-st} (:workspace-branch-diff state)
+ item (get (diff-items diff-st) item-key)]
+ ;; only a change of the diff has a mark to keep
+ (if (and (some? item) (uuid? branch-id))
+ (->> (rp/cmd! :set-branch-change-review
+ {:branch-id branch-id
+ :direction direction
+ :change-key item-key
+ :fingerprint (change-fingerprint item)
+ :reviewed (contains? reviewed item-key)})
+ (rx/ignore)
+ (rx/catch (fn [_] (rx/of (fetch-diff-reviewed)))))
+ (rx/empty)))))))
(defn clear-diff-excluded
- "Drop the per-change selection: the compare dialog closes without
- applying it."
+ "Drop the per-change selection of both directions: the compare mode
+ closes without applying it."
[]
(ptk/reify ::clear-diff-excluded
ptk/UpdateEvent
(update [_ state]
- (assoc-in state [:workspace-branch-diff :excluded] #{}))))
+ (assoc-in state [:workspace-branch-diff :excluded] {}))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; BRANCH CONTEXT (banner when the open file is a branch)
@@ -575,43 +659,47 @@
(rx/catch (fn [_] (rx/of (set-branch-context file-id nil)))))))))))
(defn open-conflict-resolutions
- "Open the conflict-resolution modal and seed the store with the conflict set
- the command just returned.
+ "Seed the store with the conflict set a merge or update just returned.
+ The compare mode reacts to this event and takes the user to resolve
+ them (`app.main.data.workspace.compare/watch-events`).
- Those conflicts are authoritative for the whole modal: they are the very
- ones the command's own `resolved?` matches against, while the diff the modal
- can fetch on its own is computed in another id space and may list a
- different set, or none at all. Keeping them in the store also lets the
- bulk actions resolve the same set the modal shows.
+ Those conflicts are authoritative while they are resolved: they are the
+ very ones the command's own `resolved?` matches against, while the diff
+ the compare mode fetches on its own is computed in another id space and
+ may list a different set, or none at all.
`main-revn` is main's revn when the command computed those conflicts. It
- is stored with them because the modal's own diff fetch can still be in
- flight when the user applies; see `conflict-main-revn`."
+ is stored with them because the diff fetch can still be in flight when
+ the user applies; see `conflict-main-revn`. `excluded` is the per-change
+ selection the attempt was made with and `comment` what the user said
+ about the merge: applying the resolutions sends both again."
[{:keys [branch mode conflicts main-revn excluded comment]}]
(ptk/reify ::open-conflict-resolutions
ptk/UpdateEvent
(update [_ state]
(assoc state :workspace-branch-conflicts
{:branch-id (:id branch)
+ :branch branch
:mode mode
:conflicts (vec conflicts)
- :main-revn main-revn}))
- ptk/WatchEvent
- (watch [_ _ _]
- ;; `excluded` is the per-change selection the merge/update attempt
- ;; was made with, and `comment` what the user said about the merge;
- ;; the resolution modal sends both again on retry
- (rx/of (modal/show :branch-conflicts {:branch branch
- :mode mode
- :conflicts conflicts
- :excluded excluded
- :comment comment})))))
+ :main-revn main-revn
+ :excluded excluded
+ :comment comment}))))
+
+(defn close-conflict-resolutions
+ "Forget the conflict set of the last merge or update attempt: the user
+ left it unresolved."
+ []
+ (ptk/reify ::close-conflict-resolutions
+ ptk/UpdateEvent
+ (update [_ state]
+ (dissoc state :workspace-branch-conflicts))))
(defn- conflict-main-revn
"Main's revn when the server computed the conflict set stored for
`branch-id`, or nil when the stored set belongs to another branch.
- The resolution modal fetches its own diff when it opens, and that fetch
+ Resolving fetches the diff in its own direction, and that fetch
replaces the loaded diff with a loading state until it answers. The user
can resolve every conflict and apply inside that window, so merge and
update fall back to this revn: resolutions never leave without the token
@@ -624,8 +712,8 @@
(defn update-branch-from-main
"Bring main's changes into the branch (reverse of merge). `branch` is the
- branch row. With conflicts and no `resolutions`, opens the conflict
- resolution modal in update mode; with resolutions, applies them.
+ branch row. With conflicts and no `resolutions`, hands them over to be
+ resolved (`open-conflict-resolutions`); with resolutions, applies them.
Options (`opts`): `:resolutions` `{entity-id (:main|:branch)}` as below,
and `:excluded`, the per-change selection (change keys,
@@ -666,8 +754,8 @@
(reload-file-window))
;; the returned conflicts are authoritative: they are the very
;; ones the command computes `resolved?` against, and the diff
- ;; the modal could fetch on its own is computed in another id
- ;; space, which can disagree with them
+ ;; fetched to compare is computed in another id space, which
+ ;; can disagree with them
:conflicts (rx/of (open-conflict-resolutions {:branch branch
:mode :update
:conflicts conflicts
@@ -713,36 +801,6 @@
(update [_ state]
(update-in state [:workspace-branch-diff :resolutions] dissoc id))))
-(defn set-conflict-attr-resolution
- "Choose `:main` or `:branch` for a single attribute `attr` of a
- conflicting entity, leaving the other attributes as they were. `attrs`
- is the full set of the conflict's changed-attr keys, used to seed a
- complete resolution map the first time a property is toggled (so the
- conflict counts as resolved, with untouched attrs defaulting to the safe
- `:main` side). Promotes a prior whole-entity keyword to a per-attr map."
- [id attr choice attrs]
- (ptk/reify ::set-conflict-attr-resolution
- ptk/UpdateEvent
- (update [_ state]
- (update-in state [:workspace-branch-diff :resolutions id]
- (fn [cur]
- (let [seed (cond
- (map? cur) cur
- (= cur :branch) (zipmap attrs (repeat :branch))
- :else (zipmap attrs (repeat :main)))]
- (assoc seed attr choice)))))))
-
-(defn set-all-resolutions
- "Bulk-resolve every current conflict to `:main` or `:branch`."
- [choice]
- (ptk/reify ::set-all-resolutions
- ptk/UpdateEvent
- (update [_ state]
- (let [conflicts (or (get-in state [:workspace-branch-conflicts :conflicts])
- (get-in state [:workspace-branch-diff :diff :conflicts]))
- res (into {} (map (fn [c] [(:id c) choice])) conflicts)]
- (assoc-in state [:workspace-branch-diff :resolutions] res)))))
-
(defn merge-branch
"Merge `branch` (a branch row/context map with at least `:id`) into main.
On success the server records the merge and deletes the branch and its
@@ -764,7 +822,8 @@
computed against a stale diff (`:file-modified`); in that case the diff
is re-fetched and the user is asked to review it again. Resolutions sent
before that diff has loaded carry the revn of the conflict answer instead
- (`conflict-main-revn`). Unresolved conflicts open the resolution modal."
+ (`conflict-main-revn`). Unresolved conflicts are handed over to be
+ resolved (`open-conflict-resolutions`)."
([branch] (merge-branch branch nil))
([branch {:keys [resolutions comment excluded notify-assignees]}]
(assert (uuid? (:id branch)) "expected a branch row with a valid `:id`")
diff --git a/frontend/src/app/main/data/workspace/compare.cljs b/frontend/src/app/main/data/workspace/compare.cljs
new file mode 100644
index 0000000000..9cc7e19375
--- /dev/null
+++ b/frontend/src/app/main/data/workspace/compare.cljs
@@ -0,0 +1,664 @@
+;; 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) KALEIDOS SUBSIDIARY SL
+
+(ns app.main.data.workspace.compare
+ "Data layer of the compare mode: the open branch against main, on the
+ canvas. The left sidebar lists the changes, the right one shows the
+ change chosen, and the canvas marks them where they are. The conflicts
+ of a merge or an update are resolved in the same mode.
+
+ `:workspace-compare` is the mode, and its presence makes the workspace
+ read-only (`app.main.data.changes/commit-changes`):
+
+ {:branch the branch row compared (`:id`, `:name`, `:branch-file-id`)
+ :phase :compare | :resolve
+ :view :highlight | :side
+ :side-mode how the side by side view places main (`side-modes`):
+ at the spot of the page the branch shows (`:linked`),
+ or moved so the change chosen sits at the same spot of
+ its half (`:aligned`). The last one picked is kept in
+ the browser and comes back on every comparison
+ :main-extent the rect of the page as main has it, while main is
+ beside the branch: fitting the whole page takes it in
+ (`app.main.data.workspace.zoom/zoom-to-fit-all`)
+ :hidden true while the changes are hidden on the canvas
+ :selected the key of the change or conflict chosen (`item-key`)
+ :hovered the key of the change or conflict under the pointer, and
+ :hovered-from where the pointer is: its row (`:list`) or its layer
+ (`:canvas`)
+ :attr the property in turn while resolving a conflict
+ :preview the side (`:main`, `:branch`) of that property the canvas
+ tries out while the pointer is on its option
+ :peek true while the canvas shows main in place of the branch
+ :filter :all | :layers | :library | :left-out
+ :collapsed the ids of the groups folded in the list
+ :counts how many changes each direction lists, once it loaded
+ :other-changes the changes of the direction the diff does not list,
+ once they loaded (`watch-events`): main is the branch
+ without its own changes and with the ones main made
+ :other-conflicts the conflicts that direction lists, which its tab
+ counts before it is shown}
+
+ The diff itself, its direction, the per-change selection, the review
+ marks and the conflict choices stay in `:workspace-branch-diff`
+ (`app.main.data.workspace.branches`)."
+ (:require
+ [app.common.data :as d]
+ [app.main.data.helpers :as dsh]
+ [app.main.data.modal :as modal]
+ [app.main.data.workspace.branches :as dwb]
+ [app.main.data.workspace.drawing.common :as dwdc]
+ [app.main.data.workspace.review :as dwrv]
+ [app.main.data.workspace.selection :as dws]
+ [app.main.data.workspace.viewport-wasm :as dwvw]
+ [app.main.data.workspace.zoom :as dwz]
+ [app.main.repo :as rp]
+ [app.main.router :as rt]
+ [app.util.storage :as storage]
+ [beicon.v2.core :as rx]
+ [potok.v2.core :as ptk]))
+
+(def views
+ "The ways the canvas shows the changes: marked on the branch
+ (`:highlight`), or with main beside it (`:side`), main on the first
+ half of the canvas and the branch on the second."
+ #{:highlight :side})
+
+(def side-modes
+ "How the side by side view places main: at the spot of the page the
+ branch shows (`:linked`), or moved so the change chosen sits at the
+ same spot of its half as on the branch (`:aligned`)."
+ #{:linked :aligned})
+
+(def filters
+ #{:all :layers :library :left-out})
+
+(def ^:private side-mode-storage-key
+ ::side-mode)
+
+(defn- get-stored-side-mode
+ "The side mode picked last in this browser, `:linked` when none is
+ kept or what is kept is no side mode."
+ []
+ (let [side-mode (get @storage/user side-mode-storage-key)]
+ (if (contains? side-modes side-mode) side-mode :linked)))
+
+(defn comparing?
+ [state]
+ (some? (:workspace-compare state)))
+
+;; --- Entries
+
+(def item-key
+ "The key a change or a conflict is chosen and marked as reviewed by
+ (`dwb/item-key`)."
+ dwb/item-key)
+
+(defn get-conflicts
+ "The conflicts to resolve for the branch `branch-id`. The set a merge or
+ an update returned (`attempt`, the `:workspace-branch-conflicts` entry)
+ wins over the one of the diff: it is the very set the command matches
+ the resolutions against, and the diff can list another one."
+ [attempt diff-state branch-id]
+ (if (and (= branch-id (:branch-id attempt)) (seq (:conflicts attempt)))
+ (:conflicts attempt)
+ (get-in diff-state [:diff :conflicts])))
+
+(defn item-rect
+ "Where the layer of entry `item` is on its page, as a rect: its place in
+ `objects` (the page as the open file has it), or the place the diff
+ gives for a layer the open file lacks. Nil for an entry that is no
+ layer or has no place."
+ [objects item]
+ (when (= :shape (:kind item))
+ (let [shape (or (get objects (:id item))
+ (:shape item)
+ (:branch item)
+ (:main item))
+ {:keys [x y width height]} (or (:selrect shape) shape)]
+ (when (and (number? x) (number? y) (number? width) (number? height))
+ {:x x :y y :width width :height height}))))
+
+(defn- find-item
+ [state item-key']
+ (let [diff-st (:workspace-branch-diff state)
+ attempt (:workspace-branch-conflicts state)]
+ (->> (concat (get-in diff-st [:diff :changes])
+ (get-conflicts attempt diff-st (:branch-id diff-st)))
+ (d/seek #(= item-key' (item-key %))))))
+
+;; --- Viewport
+
+(defn- side-view?
+ [state]
+ (= :side (get-in state [:workspace-compare :view])))
+
+(defn- centered-vbox
+ "`vbox` with `rect` in the middle of the canvas, or of its second half
+ when main takes the first one (`side?`)."
+ [vbox {:keys [x y width height]} side?]
+ (assoc vbox
+ :x (- (+ x (/ width 2)) (* (:width vbox) (if side? 0.75 0.5)))
+ :y (- (+ y (/ height 2)) (/ (:height vbox) 2))))
+
+(defn- center-on-rect
+ "Take the viewport to `rect`, at the zoom it has."
+ [rect]
+ (ptk/reify ::center-on-rect
+ ptk/UpdateEvent
+ (update [_ state]
+ (if (dwvw/render-context-lost? state)
+ state
+ (update-in state [:workspace-local :vbox] centered-vbox rect (side-view? state))))
+
+ ;; the WASM render keeps its own view: without this the canvas stays
+ ;; where it was and the marks, which follow the store, go alone
+ ptk/EffectEvent
+ (effect [_ state _]
+ (dwvw/maybe-sync-workspace-local-viewport! state))))
+
+(defn- go-to-item
+ "Take the canvas to the layer of `item`: to its page first when it is on
+ another one."
+ [item]
+ (ptk/reify ::go-to-item
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [page-id (:page-id item)
+ rect (item-rect (dsh/lookup-page-objects state page-id) item)]
+ (if (nil? rect)
+ (rx/empty)
+ (rx/concat
+ (if (not= page-id (:current-page-id state))
+ (rx/of (rt/nav :workspace (assoc (rt/get-params state) :page-id page-id)
+ {::rt/replace true}))
+ (rx/empty))
+ (->> (rx/of (center-on-rect rect))
+ (rx/observe-on :async))))))))
+
+;; --- Entering and leaving
+
+(defn enter
+ "Compare `branch` with main on the canvas. The mode only opens on the
+ branch itself: with another file open (main included) nothing happens."
+ [branch]
+ (assert (uuid? (:id branch)) "expected a branch row with a valid `:id`")
+ (ptk/reify ::enter
+ ptk/UpdateEvent
+ (update [_ state]
+ (if (= (:branch-file-id branch) (:current-file-id state))
+ (assoc state :workspace-compare
+ {:branch (select-keys branch [:id :name :branch-file-id])
+ :phase :compare
+ :view :highlight
+ :side-mode (get-stored-side-mode)
+ :hidden false
+ :selected nil
+ :attr nil
+ :filter :all
+ :collapsed #{}})
+ state))
+
+ ptk/WatchEvent
+ (watch [_ state _]
+ (if (comparing? state)
+ (rx/of (modal/hide)
+ (dwdc/clear-drawing)
+ (dws/deselect-all true)
+ ;; the changes of a design review give way to these ones
+ (dwrv/hide-changes)
+ (dwb/fetch-branch-diff (:id branch)))
+ (rx/empty)))))
+
+(defn exit
+ "Leave the compare mode. The file was never touched, so there is
+ nothing to restore: the per-change selection and an unresolved merge or
+ update attempt are dropped."
+ []
+ (ptk/reify ::exit
+ ptk/UpdateEvent
+ (update [_ state]
+ (dissoc state :workspace-compare))
+
+ ptk/WatchEvent
+ (watch [_ _ _]
+ (rx/of (dwb/clear-diff-excluded)
+ (dwb/close-conflict-resolutions)
+ (dwdc/clear-drawing)))))
+
+;; --- What the mode shows
+
+(defn set-direction
+ "Show the changes of the branch (`:branch->main`) or the ones main has
+ and the branch lacks (`:main->branch`)."
+ [direction]
+ (assert (contains? #{:branch->main :main->branch} direction) "expected a direction")
+ (ptk/reify ::set-direction
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-when state :workspace-compare assoc
+ :phase :compare
+ :selected nil
+ :attr nil
+ :filter :all))
+
+ ptk/WatchEvent
+ (watch [_ state _]
+ (if-let [branch-id (get-in state [:workspace-compare :branch :id])]
+ (rx/of (dwb/fetch-branch-diff branch-id direction))
+ (rx/empty)))))
+
+(defn set-view
+ [view]
+ (assert (contains? views view) "expected a view")
+ (ptk/reify ::set-view
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-when state :workspace-compare assoc :view view :hidden false))))
+
+(defn set-side-mode
+ "Place main beside the branch as `side-mode` says (one of
+ `side-modes`), and keep it in the browser for the next comparison."
+ [side-mode]
+ (assert (contains? side-modes side-mode) "expected a side mode")
+ (ptk/reify ::set-side-mode
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-when state :workspace-compare assoc :side-mode side-mode))
+
+ ptk/EffectEvent
+ (effect [_ state _]
+ (when (comparing? state)
+ (swap! storage/user assoc side-mode-storage-key side-mode)))))
+
+(defn toggle-side-mode
+ "Take the other side mode, while main is beside the branch."
+ []
+ (ptk/reify ::toggle-side-mode
+ ptk/WatchEvent
+ (watch [_ state _]
+ (if (side-view? state)
+ (rx/of (set-side-mode (if (= :aligned (get-in state [:workspace-compare :side-mode]))
+ :linked
+ :aligned)))
+ (rx/empty)))))
+
+(defn set-main-extent
+ "Remember the rect of the page as main has it (`rect`), or none, for
+ as long as main is beside the branch."
+ [rect]
+ (ptk/reify ::set-main-extent
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-when state :workspace-compare assoc :main-extent rect))))
+
+(defn toggle-hidden
+ "Hide the changes on the canvas, or show them again."
+ []
+ (ptk/reify ::toggle-hidden
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-when state :workspace-compare update :hidden not))))
+
+(defn set-filter
+ "Keep in the list the changes `value` names (one of `filters`)."
+ [value]
+ (assert (contains? filters value) "expected a filter")
+ (ptk/reify ::set-filter
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-when state :workspace-compare assoc :filter value))))
+
+(defn set-count
+ "Remember that `direction` lists `total` changes, so its tab can say so
+ while the other direction is the one shown."
+ [direction total]
+ (ptk/reify ::set-count
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-when state :workspace-compare assoc-in [:counts direction] total))))
+
+(defn toggle-group
+ "Fold the group `id` of the list, or unfold it."
+ [id]
+ (ptk/reify ::toggle-group
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-in-when state [:workspace-compare :collapsed]
+ #(if (contains? % id) (disj % id) (conj % id))))))
+
+(defn select
+ "Choose the change or conflict `item-key`. The canvas goes to its layer,
+ on whatever page it is, unless `travel` is false: a change chosen on
+ the canvas is already in sight."
+ ([item-key] (select item-key nil))
+ ([item-key {:keys [travel] :or {travel true}}]
+ (ptk/reify ::select
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-when state :workspace-compare assoc
+ :selected item-key
+ :attr nil
+ :preview nil))
+
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [item (when travel (find-item state item-key))]
+ ;; the detail of the change takes the right sidebar back from
+ ;; the comments, which a commenting tool had put there
+ (if (some? item)
+ (rx/of (dwdc/clear-drawing)
+ (go-to-item item))
+ (rx/of (dwdc/clear-drawing))))))))
+
+(defn set-hovered
+ "Take the change or conflict `item-key` as the one under the pointer,
+ or none: the canvas marks it beside the one chosen, and the list shows
+ its row. `from` says where the pointer is, on the row (`:list`) or on
+ the layer (`:canvas`): each one only lets go what it took, so the
+ pointer leaving the canvas for the list does not undo the row it
+ reaches."
+ [item-key from]
+ (assert (contains? #{:list :canvas} from) "expected `:list` or `:canvas`")
+ (ptk/reify ::set-hovered
+ ptk/UpdateEvent
+ (update [_ state]
+ (let [mode (:workspace-compare state)]
+ (cond
+ (nil? mode)
+ state
+
+ (some? item-key)
+ (assoc state :workspace-compare
+ (assoc mode :hovered item-key :hovered-from from))
+
+ (= from (:hovered-from mode))
+ (assoc state :workspace-compare (dissoc mode :hovered :hovered-from))
+
+ :else
+ state)))))
+
+(defn- get-hovered-layer
+ "The key of the change or conflict whose layer is under the pointer."
+ [state]
+ (let [mode (:workspace-compare state)]
+ (when (= :canvas (:hovered-from mode))
+ (:hovered mode))))
+
+(defn pick-hovered
+ "Choose the change or conflict whose layer is under the pointer, or
+ none on any other spot of the canvas, where every change is marked
+ again. The canvas stays where it is: the layer is in sight."
+ []
+ (ptk/reify ::pick-hovered
+ ptk/WatchEvent
+ (watch [_ state _]
+ (if (comparing? state)
+ (rx/of (select (get-hovered-layer state) {:travel false}))
+ (rx/empty)))))
+
+(defn toggle-selected
+ "Choose the change or conflict `item-key`, or none when it is the one
+ chosen: with none chosen the canvas marks them all again."
+ [item-key]
+ (ptk/reify ::toggle-selected
+ ptk/WatchEvent
+ (watch [_ state _]
+ (rx/of (select (when (not= item-key (get-in state [:workspace-compare :selected]))
+ item-key))))))
+
+(defn fit-selected
+ "Zoom to the layer of the change or conflict chosen, as the workspace
+ does with the selection: the layer is not selected here, so that
+ shortcut finds nothing. Main beside the branch leaves half the canvas
+ to fit it in."
+ []
+ (ptk/reify ::fit-selected
+ ptk/UpdateEvent
+ (update [_ state]
+ (let [item (find-item state (get-in state [:workspace-compare :selected]))
+ rect (when (= (:page-id item) (:current-page-id state))
+ (item-rect (dsh/lookup-page-objects state) item))
+ side? (side-view? state)]
+ (if (or (nil? rect) (dwvw/render-context-lost? state))
+ state
+ (update state :workspace-local dwz/fit-rect rect 40 side?))))
+
+ ptk/EffectEvent
+ (effect [_ state _]
+ (dwvw/maybe-sync-workspace-local-viewport! state))))
+
+(defn fit-hovered
+ "Choose the change or conflict whose layer is under the pointer and
+ zoom to it."
+ []
+ (ptk/reify ::fit-hovered
+ ptk/WatchEvent
+ (watch [_ state _]
+ (if-let [item-key (get-hovered-layer state)]
+ (rx/of (select item-key {:travel false})
+ (fit-selected))
+ (rx/empty)))))
+
+(defn set-attr
+ "Take the property `attr` of the conflict chosen as the one in turn."
+ [attr]
+ (ptk/reify ::set-attr
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-when state :workspace-compare assoc :attr attr))))
+
+(defn set-preview
+ "Try `side` out on the canvas for the property in turn of the conflict
+ chosen, or stop trying (nil). Nothing is chosen by it."
+ [side]
+ (ptk/reify ::set-preview
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-when state :workspace-compare assoc :preview side))))
+
+(defn set-peek
+ "Show main on the canvas in place of the branch, or the branch again."
+ [peek]
+ (ptk/reify ::set-peek
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-when state :workspace-compare assoc :peek (boolean peek)))))
+
+(defn edit-layer
+ "Leave the compare mode with the layer of `item` selected and in sight."
+ [item]
+ (ptk/reify ::edit-layer
+ ptk/WatchEvent
+ (watch [_ _ _]
+ (rx/concat
+ (rx/of (exit)
+ (go-to-item item))
+ (->> (rx/of (dws/select-shape (:id item)))
+ (rx/observe-on :async))))))
+
+;; --- Resolving conflicts
+
+(defn start-resolve
+ "Resolve the conflicts of the comparison on the canvas. With the set a
+ merge or an update just returned in the store
+ (`dwb/open-conflict-resolutions`), those are the ones resolved, in the
+ direction of that attempt; with the branch file not open yet, it opens
+ first and the mode follows (`watch-events`)."
+ []
+ (ptk/reify ::start-resolve
+ ptk/UpdateEvent
+ (update [_ state]
+ (let [attempt (:workspace-branch-conflicts state)
+ branch (or (get-in state [:workspace-compare :branch])
+ (:branch attempt))]
+ (if (= (:branch-file-id branch) (:current-file-id state))
+ (-> state
+ (d/update-when :workspace-branch-conflicts dissoc :pending)
+ (update :workspace-compare
+ (fn [mode]
+ (merge {:view :highlight
+ :side-mode (get-stored-side-mode)
+ :hidden false
+ :filter :all
+ :collapsed #{}}
+ mode
+ {:branch (select-keys branch [:id :name :branch-file-id])
+ :phase :resolve
+ :selected nil
+ :attr nil}))))
+ ;; the conflicts wait for their branch file to open
+ (d/update-when state :workspace-branch-conflicts assoc :pending true))))
+
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [attempt (:workspace-branch-conflicts state)
+ diff-st (:workspace-branch-diff state)
+ branch (get-in state [:workspace-compare :branch])
+ direction (case (:mode attempt)
+ :update :main->branch
+ :merge :branch->main
+ (:direction diff-st :branch->main))]
+ (cond
+ ;; the conflicts belong to a branch that is not the open file
+ (and (nil? branch) (uuid? (get-in attempt [:branch :branch-file-id])))
+ (rx/of (dwb/open-branch (get-in attempt [:branch :branch-file-id])))
+
+ (nil? branch)
+ (rx/empty)
+
+ ;; the diff backs the sides of each conflict, so it is the one
+ ;; of the direction resolved
+ (or (not= (:id branch) (:branch-id diff-st))
+ (not= direction (:direction diff-st)))
+ (rx/of (modal/hide)
+ (dwdc/clear-drawing)
+ (dws/deselect-all true)
+ (dwb/fetch-branch-diff (:id branch) direction))
+
+ :else
+ (rx/of (modal/hide)))))))
+
+(defn back-to-compare
+ "Leave the conflicts unresolved and go back to the list of changes. The
+ choices made so far are kept; the merge or update attempt is not."
+ []
+ (ptk/reify ::back-to-compare
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-when state :workspace-compare assoc
+ :phase :compare
+ :selected nil
+ :attr nil))
+
+ ptk/WatchEvent
+ (watch [_ _ _]
+ (rx/of (dwb/close-conflict-resolutions)))))
+
+(defn apply-resolutions
+ "Merge or update with the choices made for every conflict. The
+ per-change selection and the comment of the merge travel again: the
+ ones of the attempt that returned the conflicts, or the selection of
+ the comparison when the user came from it."
+ []
+ (ptk/reify ::apply-resolutions
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [diff-st (:workspace-branch-diff state)
+ attempt (:workspace-branch-conflicts state)
+ branch (get-in state [:workspace-compare :branch])
+ attempt (when (= (:id branch) (:branch-id attempt)) attempt)
+ conflicts (get-conflicts attempt diff-st (:id branch))
+ ids (into #{} (map :id) conflicts)
+ res (into {}
+ (filter (fn [[id _]] (contains? ids id)))
+ (:resolutions diff-st))
+ excluded (if (some? attempt)
+ (:excluded attempt)
+ (dwb/diff-excluded diff-st))]
+ (if (= :main->branch (:direction diff-st))
+ (rx/of (dwb/update-branch-from-main branch {:resolutions res
+ :excluded excluded}))
+ (rx/of (dwb/merge-branch branch {:resolutions res
+ :comment (:comment attempt)
+ :excluded excluded})))))))
+
+(defn- resume-resolve
+ "Start resolving the conflicts that waited for the branch file to open."
+ []
+ (ptk/reify ::resume-resolve
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [attempt (:workspace-branch-conflicts state)]
+ (if (and (:pending attempt)
+ (= (get-in attempt [:branch :branch-file-id]) (:current-file-id state)))
+ (rx/of (start-resolve))
+ (rx/empty))))))
+
+(defn- set-other-changes
+ [{:keys [changes conflicts]}]
+ (ptk/reify ::set-other-changes
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-when state :workspace-compare assoc
+ :other-changes changes
+ :other-conflicts conflicts))))
+
+(defn- fetch-other-changes
+ "Load the changes of the direction the diff of the mode does not list.
+ The diff of a direction carries the changes of one side alone, and main
+ takes both to put together: the layers the branch changed as they
+ were, and the ones main changed since as they are now. A failure
+ leaves main without the second ones."
+ []
+ (ptk/reify ::fetch-other-changes
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-when state :workspace-compare dissoc :other-changes :other-conflicts))
+
+ ptk/WatchEvent
+ (watch [_ state stream]
+ (let [branch-id (get-in state [:workspace-compare :branch :id])
+ diff-st (:workspace-branch-diff state)
+ direction (if (= :main->branch (:direction diff-st))
+ :branch->main
+ :main->branch)]
+ (if (and (some? branch-id) (= branch-id (:branch-id diff-st)))
+ (->> (rp/cmd! :get-branch-diff {:branch-id branch-id :direction direction})
+ (rx/map set-other-changes)
+ (rx/catch (fn [_] (rx/empty)))
+ (rx/take-until
+ (rx/filter #(or (ptk/type? ::fetch-other-changes %)
+ (ptk/type? ::exit %))
+ stream)))
+ (rx/empty))))))
+
+(defn watch-events
+ "What the compare mode follows from outside it, until `stopper` emits.
+
+ Every diff asked for brings the changes of its other direction with it
+ (`fetch-other-changes`).
+
+ A merge or an update that returns conflicts takes the user to resolve
+ them. The command can run with main open (from the list of branches),
+ so the conflicts wait in the store while the branch file opens: once
+ its context loads, the mode starts there."
+ [stopper]
+ (ptk/reify ::watch-events
+ ptk/WatchEvent
+ (watch [_ _ stream]
+ (->> (rx/merge
+ (->> stream
+ (rx/filter (ptk/type? ::dwb/fetch-branch-diff))
+ (rx/map (fn [_] (fetch-other-changes))))
+ (->> stream
+ (rx/filter (ptk/type? ::dwb/open-conflict-resolutions))
+ (rx/map (fn [_] (start-resolve))))
+ (->> stream
+ (rx/filter (ptk/type? ::dwb/set-branch-context))
+ (rx/take 1)
+ (rx/map (fn [_] (resume-resolve)))))
+ (rx/take-until stopper)))))
diff --git a/frontend/src/app/main/data/workspace/zoom.cljs b/frontend/src/app/main/data/workspace/zoom.cljs
index bf53b9462f..65cbb62495 100644
--- a/frontend/src/app/main/data/workspace/zoom.cljs
+++ b/frontend/src/app/main/data/workspace/zoom.cljs
@@ -22,11 +22,61 @@
[beicon.v2.core :as rx]
[potok.v2.core :as ptk]))
+(defn- split?
+ "True while the compare mode puts main beside the branch
+ (`app.main.data.workspace.compare`): main takes the first half of the
+ viewport, and the page shows in the second one."
+ [state]
+ (= :side (get-in state [:workspace-compare :view])))
+
+(defn- get-split-extent
+ "The rect of the page as main has it, which main shows beside the
+ branch (`:main-extent` of the compare mode); nil when none is shown."
+ [state]
+ (when (split? state)
+ (get-in state [:workspace-compare :main-extent])))
+
+(defn room-center
+ "The point of the page at the middle of the room the canvas shows it
+ in: the middle of `vbox`, or of its second half while main takes the
+ first one (`split`)."
+ [{:keys [x y width height]} split]
+ (gpt/point (+ x (* width (if split 0.75 0.5)))
+ (+ y (/ height 2))))
+
+(defn fit-rect
+ "`local` (the `:workspace-local` entry) with the zoom and the viewbox
+ that fit `rect`, with `padding` around it, in the room the canvas
+ shows the page in: the whole viewport, or its second half while main
+ takes the first one (`split`)."
+ [{:keys [vport] :as local} rect padding split]
+ (let [room (cond-> vport split (update :width / 2))
+ srect (gal/adjust-to-viewport room rect {:padding padding :min-zoom 0.01})
+ zoom (/ (:width room) (:width srect))
+ vbox (if split
+ ;; `srect` is centred on `rect`, and so is the second half
+ (let [width (/ (:width vport) zoom)
+ height (/ (:height vport) zoom)]
+ (grc/make-rect (- (+ (:x srect) (/ (:width srect) 2)) (* width 0.75))
+ (- (+ (:y srect) (/ (:height srect) 2)) (/ height 2))
+ width
+ height))
+ srect)]
+ (-> local
+ (assoc :zoom zoom)
+ (assoc :zoom-inverse (/ 1 zoom))
+ (update :vbox merge vbox))))
+
(defn impl-update-zoom
- [{:keys [vbox] :as local} center zoom]
+ "`local` at `zoom` (a number, or a fn of the zoom it has), with the
+ point `center` of the page kept where it is on the screen. Without a
+ `center`, the middle of the room the canvas shows the page in stays
+ (`room-center`), which takes the second half of the viewport while
+ main takes the first one (`split`)."
+ [{:keys [vbox] :as local} center zoom & {:keys [split]}]
(let [new-zoom (if (fn? zoom) (zoom (:zoom local)) zoom)
old-zoom (:zoom local)
- center (if center center (grc/rect->center vbox))
+ center (if center center (room-center vbox split))
scale (/ old-zoom new-zoom)
mtx (gmt/scale-matrix (gpt/point scale) center)
vbox' (gsh/transform-rect vbox mtx)]
@@ -48,7 +98,7 @@
state
(let [center (if (= center ::auto) @ms/mouse-position center)]
(update state :workspace-local
- #(impl-update-zoom % center (fn [z] (min (* z 1.3) 200)))))))
+ #(impl-update-zoom % center (fn [z] (min (* z 1.3) 200)) :split (split? state))))))
ptk/EffectEvent
(effect [_ state _]
@@ -67,7 +117,7 @@
state
(let [center (if (= center ::auto) @ms/mouse-position center)]
(update state :workspace-local
- #(impl-update-zoom % center (fn [z] (max (/ z 1.3) 0.01)))))))
+ #(impl-update-zoom % center (fn [z] (max (/ z 1.3) 0.01)) :split (split? state))))))
ptk/EffectEvent
(effect [_ state _]
@@ -84,10 +134,8 @@
(update [_ state]
(if (dwvw/render-context-lost? state)
state
- (let [vp (dm/get-in state [:workspace-local :vbox])
- x (+ (:x vp) (/ (:width vp) 2))
- y (+ (:y vp) (/ (:height vp) 2))
- center (d/nilv center (gpt/point x y))]
+ (let [vp (dm/get-in state [:workspace-local :vbox])
+ center (d/nilv center (room-center vp (split? state)))]
(update state :workspace-local
#(impl-update-zoom % center (fn [z] (-> (* z scale)
(max 0.01)
@@ -104,7 +152,7 @@
(if (dwvw/render-context-lost? state)
state
(update state :workspace-local
- #(impl-update-zoom % nil 1))))
+ #(impl-update-zoom % nil 1 :split (split? state)))))
ptk/EffectEvent
(effect [_ state _]
@@ -119,17 +167,13 @@
(let [page-id (:current-page-id state)
objects (dsh/lookup-page-objects state page-id)
shapes (cfh/get-immediate-children objects)
- srect (gsh/shapes->rect shapes)]
+ srect (gsh/shapes->rect shapes)
+ ;; main beside the branch can reach further than it
+ main (get-split-extent state)
+ srect (if (some? main) (grc/join-rects [srect main]) srect)]
(if (empty? shapes)
state
- (update state :workspace-local
- (fn [{:keys [vport] :as local}]
- (let [srect (gal/adjust-to-viewport vport srect {:padding 160 :min-zoom 0.01})
- zoom (/ (:width vport) (:width srect))]
- (-> local
- (assoc :zoom zoom)
- (assoc :zoom-inverse (/ 1 zoom))
- (update :vbox merge srect)))))))))
+ (update state :workspace-local fit-rect srect 160 (split? state))))))
ptk/EffectEvent
(effect [_ state _]
@@ -175,14 +219,7 @@
srect (->> selected
(map #(get objects %))
(gsh/shapes->rect))]
- (update state :workspace-local
- (fn [{:keys [vport] :as local}]
- (let [srect (gal/adjust-to-viewport vport srect {:padding 40 :min-zoom 0.01})
- zoom (/ (:width vport) (:width srect))]
- (-> local
- (assoc :zoom zoom)
- (assoc :zoom-inverse (/ 1 zoom))
- (update :vbox merge srect))))))))))
+ (update state :workspace-local fit-rect srect 40 (split? state)))))))
ptk/EffectEvent
(effect [_ state _]
@@ -201,17 +238,7 @@
(map #(get objects %))
(gsh/shapes->rect))]
- (update state :workspace-local
- (fn [{:keys [vport] :as local}]
- (let [srect (gal/adjust-to-viewport
- vport srect
- {:padding 40 :min-zoom 0.01})
- zoom (/ (:width vport)
- (:width srect))]
- (-> local
- (assoc :zoom zoom)
- (assoc :zoom-inverse (/ 1 zoom))
- (update :vbox merge srect))))))))
+ (update state :workspace-local fit-rect srect 40 (split? state)))))
ptk/EffectEvent
(effect [_ state _]
diff --git a/frontend/src/app/main/refs.cljs b/frontend/src/app/main/refs.cljs
index 489867fb6c..51d2daef33 100644
--- a/frontend/src/app/main/refs.cljs
+++ b/frontend/src/app/main/refs.cljs
@@ -46,6 +46,20 @@
;; consumers only care about the branch row itself
(l/derived #(get-in % [:workspace-branch-context :info]) st/state))
+(def branch-diff
+ "The diff of a branch against main, its per-change selection, review
+ marks and conflict choices."
+ (l/derived :workspace-branch-diff st/state))
+
+(def branch-conflicts
+ "The conflict set the last merge or update attempt returned."
+ (l/derived :workspace-branch-conflicts st/state))
+
+(def compare-mode
+ "The compare mode: the branch compared and what its panels show. Nil
+ outside it."
+ (l/derived :workspace-compare st/state))
+
(def pull-requests
(l/derived :workspace-pull-requests st/state))
@@ -110,13 +124,20 @@
[state]
(some? (:workspace-pr-preview state)))
+(defn- comparing?
+ "True while the open branch is compared with main: the comparison is
+ read-only, the branch is edited outside it."
+ [state]
+ (some? (:workspace-compare state)))
+
(def permissions
- "The team permissions, without edition on a merged or archived branch
- nor inside a design review."
+ "The team permissions, without edition on a merged or archived branch,
+ inside a design review or while comparing a branch with main."
(l/derived (fn [state]
(cond-> (:permissions (dsh/lookup-team state))
(or (open-closed-branch? state)
- (reviewing? state))
+ (reviewing? state)
+ (comparing? state))
(assoc :can-edit false)))
st/state))
diff --git a/frontend/src/app/main/ui/dashboard/branches_popover.cljs b/frontend/src/app/main/ui/dashboard/branches_popover.cljs
index 93821f4dd6..2fb210525d 100644
--- a/frontend/src/app/main/ui/dashboard/branches_popover.cljs
+++ b/frontend/src/app/main/ui/dashboard/branches_popover.cljs
@@ -13,8 +13,8 @@
[app.common.uuid :as uuid]
[app.main.data.workspace.branches :as dwb]
[app.main.store :as st]
- [app.main.ui.components.dropdown :refer [dropdown]]
[app.main.ui.ds.foundations.assets.icon :as i]
+ [app.main.ui.ds.layout.popover :refer [popover*]]
[app.main.ui.ds.product.branch-row :refer [branch-row*]]
[app.main.ui.ds.product.branch-status :refer [branch-status*]]
[app.util.dom :as dom]
@@ -60,7 +60,7 @@
[:span (dm/str n)]]
;; a switcher only: branches are created from inside the file
- [:& dropdown {:show (deref show?) :on-close on-close}
+ [:> popover* {:is-open (deref show?) :on-close on-close}
[:div {:class (stl/css :branches-popover)
:role "dialog"
:aria-label (tr "dashboard.branches-badge" (dm/str n))}
diff --git a/frontend/src/app/main/ui/ds.cljs b/frontend/src/app/main/ui/ds.cljs
index 640f5c133f..4fb6ae70c4 100644
--- a/frontend/src/app/main/ui/ds.cljs
+++ b/frontend/src/app/main/ui/ds.cljs
@@ -29,6 +29,7 @@
token-status-list]]
[app.main.ui.ds.layout.menu :refer [menu* menu-item* menu-separator* sub-menu* context-menu*]]
[app.main.ui.ds.layout.modal :refer [modal* modal-header* modal-content* modal-footer*]]
+ [app.main.ui.ds.layout.popover :refer [popover*]]
[app.main.ui.ds.layout.tab-switcher :refer [tab-switcher*]]
[app.main.ui.ds.notifications.actionable :refer [actionable*]]
[app.main.ui.ds.notifications.context-notification :refer [context-notification*]]
@@ -51,7 +52,6 @@
[app.main.ui.ds.product.milestone :refer [milestone*]]
[app.main.ui.ds.product.milestone-group :refer [milestone-group*]]
[app.main.ui.ds.product.panel-title :refer [panel-title*]]
- [app.main.ui.ds.product.preview-card :refer [preview-card*]]
[app.main.ui.ds.product.progress-bar :refer [progress-bar*]]
[app.main.ui.ds.product.review-label :refer [review-label*]]
[app.main.ui.ds.product.review-marker :refer [review-marker*]]
@@ -104,7 +104,6 @@
:BranchStatus branch-status*
:ChangeRow change-row*
:FilterChip filter-chip*
- :PreviewCard preview-card*
:Tag tag*
:CommentCard comment-card*
:LayerChip layer-chip*
@@ -128,6 +127,7 @@
:MenuSeparator menu-separator*
:SubMenu sub-menu*
:ContextMenu context-menu*
+ :Popover popover*
:set-default-translations
(fn [data]
diff --git a/frontend/src/app/main/ui/ds/layout/popover.cljs b/frontend/src/app/main/ui/ds/layout/popover.cljs
new file mode 100644
index 0000000000..7dd02e34fc
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/layout/popover.cljs
@@ -0,0 +1,111 @@
+;; 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) KALEIDOS SUBSIDIARY SL
+
+(ns app.main.ui.ds.layout.popover
+ "A panel that floats over the page and closes by itself. It only
+ behaves: the caller places and draws the panel."
+ (:require-macros
+ [app.main.style :as stl])
+ (:require
+ [app.config :as cfg]
+ [app.util.dom :as dom]
+ [app.util.globals :as globals]
+ [app.util.keyboard :as kbd]
+ [app.util.timers :as tm]
+ [beicon.v2.core :as rx]
+ [goog.events :as events]
+ [rumext.v2 :as mf])
+ (:import goog.events.EventType))
+
+(def ^:private schema:popover
+ [:map
+ [:is-open :boolean]
+ [:on-close fn?]
+ [:container {:optional true} [:maybe :any]]])
+
+(defn- inside?
+ "Whether `target` is in the element of the ref `node-ref`."
+ [node-ref target]
+ (let [node (some-> node-ref mf/ref-val)]
+ (and (some? node) (.contains ^js node target))))
+
+(defn- outside-click?
+ "Whether the click `event` closes the popover: one out of the panel
+ (`panel-ref`) and out of `container`, other than the second event of
+ a ctrl+click on macOS, which also sends a context menu one."
+ [event panel-ref container]
+ (let [target (dom/get-target event)]
+ (not (or (and (cfg/check-platform? :macos) (kbd/ctrl? event))
+ (.-data-no-close ^js target)
+ (inside? panel-ref target)
+ (inside? container target)))))
+
+(defn- give-focus-back
+ "Focus `node` again, the element focused before the popover opened,
+ unless the focus went somewhere else since: a dialog the popover
+ opened keeps it."
+ [node panel-ref]
+ (let [active (dom/get-active)]
+ (when (and (some? node)
+ (.-isConnected ^js node)
+ (or (nil? active)
+ (= active (.-body globals/document))
+ (inside? panel-ref active)))
+ (dom/focus! node))))
+
+(mf/defc popover-content*
+ {::mf/private true}
+ [{:keys [on-close container children]}]
+ (let [panel-ref (mf/use-ref nil)
+ ;; read when an event comes: a new handler from a later render
+ ;; must not set the popover up again and move the focus
+ on-close-ref (mf/use-ref on-close)
+ container-ref (mf/use-ref container)]
+ (mf/set-ref-val! on-close-ref on-close)
+ (mf/set-ref-val! container-ref container)
+ (mf/with-effect []
+ (let [opener (dom/get-active)
+ close #((mf/ref-val on-close-ref))
+ listening (volatile! false)
+ ;; the click that opened the popover is still on its way up:
+ ;; it does not count
+ timer (tm/schedule #(vreset! listening true))
+
+ on-click
+ (fn [event]
+ (when (and @listening
+ (outside-click? event panel-ref (mf/ref-val container-ref)))
+ (close)))
+
+ on-key-up
+ (fn [event]
+ (when (kbd/esc? event)
+ (close)))
+
+ keys [(events/listen globals/document EventType.CLICK on-click)
+ (events/listen globals/document EventType.CONTEXTMENU on-click)
+ (events/listen globals/document EventType.KEYUP on-key-up)]]
+ (fn []
+ (rx/dispose! timer)
+ (run! events/unlistenByKey keys)
+ (give-focus-back opener panel-ref))))
+
+ [:div {:class (stl/css :popover) :ref panel-ref}
+ children]))
+
+(mf/defc popover*
+ "A panel that floats over the page while `is-open`, for content a menu
+ cannot hold (rows with a status, sections, a group that folds). A click
+ out of it, and out of `container` (a ref, the element that opened it),
+ or Escape calls `on-close`. On closing, the focus goes back where it
+ was before it opened. It only behaves: it renders `children` in place
+ and the caller places and draws the panel."
+ {::mf/schema schema:popover}
+ [{:keys [is-open on-close container children]}]
+ (when ^boolean is-open
+ [:> popover-content* {:on-close on-close
+ :container container
+ :children children}]))
diff --git a/frontend/src/app/main/ui/ds/layout/popover.mdx b/frontend/src/app/main/ui/ds/layout/popover.mdx
new file mode 100644
index 0000000000..acec611b37
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/layout/popover.mdx
@@ -0,0 +1,43 @@
+{ /* 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) KALEIDOS SUBSIDIARY SL */ }
+import { Canvas, Meta } from "@storybook/addon-docs/blocks";
+import * as Popover from "./popover.stories";
+
+
+
+# Popover
+
+A panel that floats over the page while it is open, for content a
+[Menu](?path=/docs/layout-menu--docs) cannot hold: rows with a status,
+sections, a group that folds. It closes on a click out of it or on
+**Escape**, and gives the focus back to where it was.
+
+## Example
+
+
+
+## Usage
+
+```clj
+[:> popover* {:is-open open?
+ :on-close on-close
+ :container trigger-ref}
+ [:div {:class (stl/css :panel)} ...]]
+```
+
+- `is-open` shows the panel; `on-close` is called when it should close.
+- `container` (optional) is a ref to an element whose clicks do not close
+ it either, such as the bar that holds the trigger.
+- A click on an element with a `data-no-close` property does not close it.
+
+## Technical notes
+
+The popover only behaves: it renders its children in place, with no box
+of its own, and places and draws nothing. The caller positions and
+styles the panel, so moving a panel to it changes nothing on screen.
+
+It starts listening on the next tick, so the click that opened it does
+not close it. On macOS the second event of a ctrl+click is ignored.
diff --git a/frontend/src/app/main/ui/ds/layout/popover.scss b/frontend/src/app/main/ui/ds/layout/popover.scss
new file mode 100644
index 0000000000..e1ae1303d0
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/layout/popover.scss
@@ -0,0 +1,11 @@
+// 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) KALEIDOS SUBSIDIARY SL
+
+// no box of its own: the panel the caller draws is placed as if the
+// popover were not there
+.popover {
+ display: contents;
+}
diff --git a/frontend/src/app/main/ui/ds/layout/popover.stories.jsx b/frontend/src/app/main/ui/ds/layout/popover.stories.jsx
new file mode 100644
index 0000000000..c7469b6794
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/layout/popover.stories.jsx
@@ -0,0 +1,63 @@
+// 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) KALEIDOS SUBSIDIARY SL
+
+import * as React from "react";
+import Components from "@target/components";
+
+const { Popover, Button } = Components;
+
+// The popover only behaves: the story places and draws the panel, as a
+// caller does.
+const panelStyle = {
+ position: "absolute",
+ insetBlockStart: "calc(100% + 4px)",
+ insetInlineStart: 0,
+ inlineSize: "240px",
+ padding: "8px",
+ borderRadius: "8px",
+ border: "1px solid var(--color-background-quaternary)",
+ backgroundColor: "var(--color-background-tertiary)",
+ color: "var(--color-foreground-primary)",
+};
+
+const PopoverWrapper = ({ isOpen: initial = false }) => {
+ const [open, setOpen] = React.useState(initial);
+ const close = React.useCallback(() => setOpen(false), []);
+
+ return (
+
+
setOpen((open) => !open)}>
+ Open panel
+
+
+
+
A click out of this panel, or Escape, closes it.
+
A click here keeps it open
+
+
+
+ );
+};
+
+export default {
+ title: "Layout/Popover",
+ component: PopoverWrapper,
+ args: {
+ isOpen: false,
+ },
+ parameters: {
+ controls: { exclude: ["isOpen"] },
+ },
+ render: (args) => ,
+};
+
+export const Default = {};
+
+export const Open = {
+ args: {
+ isOpen: true,
+ },
+};
diff --git a/frontend/src/app/main/ui/ds/product/preview_card.cljs b/frontend/src/app/main/ui/ds/product/preview_card.cljs
deleted file mode 100644
index 19d82d786f..0000000000
--- a/frontend/src/app/main/ui/ds/product/preview_card.cljs
+++ /dev/null
@@ -1,53 +0,0 @@
-;; 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) KALEIDOS SUBSIDIARY SL
-
-(ns app.main.ui.ds.product.preview-card
- (:require-macros
- [app.main.style :as stl])
- (:require
- [app.common.data :as d]
- [app.main.ui.ds.foundations.typography :as t]
- [app.main.ui.ds.foundations.typography.text :refer [text*]]
- [rumext.v2 :as mf]))
-
-(def ^:private schema:preview-card
- [:map
- [:class {:optional true} [:maybe :string]]
- [:label :string]
- [:side {:optional true} [:maybe [:enum "base" "main" "branch" "result"]]]
- [:detail {:optional true} [:maybe :string]]
- [:caption {:optional true} [:maybe :string]]
- [:is-warning {:optional true} [:maybe :boolean]]
- [:is-large {:optional true} [:maybe :boolean]]])
-
-(mf/defc preview-card*
- "A framed preview of one side of a comparison. The side picks the
- colour of the frame and of the label: base is neutral,
- main purple, the branch the accent and the merged result green.
- `detail` follows the label (who or when); `caption` sits under the
- preview, in the warning colour when `is-warning` says so. `is-large`
- gives the preview a taller stage, for a view that has the room."
- {::mf/schema schema:preview-card}
- [{:keys [class label side detail caption is-warning is-large children] :rest props}]
- (let [side (d/nilv side "base")
- is-warning (d/nilv is-warning false)
- is-large (d/nilv is-large false)
- props (mf/spread-props props
- {:class [class (stl/css-case :preview-card true
- :side-main (= side "main")
- :side-branch (= side "branch")
- :side-result (= side "result"))]})]
- [:> :div props
- [:div {:class (stl/css :head)}
- [:> text* {:as "span" :typography t/headline-small :class (stl/css :label)} label]
- (when detail
- [:> text* {:as "span" :typography t/body-small :class (stl/css :detail)} detail])]
- [:div {:class (stl/css-case :stage true :is-large is-large)} children]
- (when caption
- [:> text* {:as "span"
- :typography t/body-small
- :class (stl/css-case :caption true :is-warning is-warning)}
- caption])]))
diff --git a/frontend/src/app/main/ui/ds/product/preview_card.mdx b/frontend/src/app/main/ui/ds/product/preview_card.mdx
deleted file mode 100644
index c685bfee9e..0000000000
--- a/frontend/src/app/main/ui/ds/product/preview_card.mdx
+++ /dev/null
@@ -1,49 +0,0 @@
-{ /* 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) KALEIDOS SUBSIDIARY SL */ }
-
-import { Canvas, Meta } from '@storybook/addon-docs/blocks';
-import * as PreviewCard from "./preview_card.stories";
-
-
-
-# PreviewCard
-
-A framed preview of one side of a comparison, labelled with the side
-it shows.
-
-
-
-## Variants
-
-The side colours the frame and the label: base neutral, main purple, the
-branch the accent, the merged result green.
-
-
-
-`caption` sits under the preview; `is-warning` draws it in the error
-colour.
-
-
-
-`is-large` gives the preview a taller stage, for a view with room to
-spare (the expanded comparison).
-
-
-
-## Technical notes
-
-The stage is 100 px high, 320 px with `is-large`. A container that
-knows how much room it has can set `--preview-card-stage-block-size`
-and `--preview-card-stage-large-block-size` to change them.
-
-The children fill the dark stage in the middle, centred.
-
-```clj
-[:> preview-card* {:label (tr "workspace.branches.review.side.main")
- :side "main"
- :detail main-ago}
- [:> entity-preview* {:kind :shape :value main}]]
-```
diff --git a/frontend/src/app/main/ui/ds/product/preview_card.scss b/frontend/src/app/main/ui/ds/product/preview_card.scss
deleted file mode 100644
index 509e9d762a..0000000000
--- a/frontend/src/app/main/ui/ds/product/preview_card.scss
+++ /dev/null
@@ -1,78 +0,0 @@
-// 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) KALEIDOS SUBSIDIARY SL
-
-@use "ds/_borders.scss" as *;
-@use "ds/_utils.scss" as *;
-@use "ds/mixins.scss" as *;
-
-.preview-card {
- --card-side-color: var(--color-foreground-secondary);
-
- display: flex;
- flex-direction: column;
- gap: var(--sp-s);
- min-inline-size: 0;
- padding: var(--sp-m);
- border: $b-1 solid var(--card-side-color);
- border-radius: $br-8;
- background-color: var(--color-background-tertiary);
-
- &.side-main {
- --card-side-color: var(--color-accent-secondary);
- }
-
- &.side-branch {
- --card-side-color: var(--color-accent-primary);
- }
-
- &.side-result {
- --card-side-color: var(--color-accent-success);
- }
-}
-
-.head {
- display: flex;
- align-items: center;
- gap: var(--sp-xs);
- min-inline-size: 0;
-}
-
-.label {
- flex-shrink: 0;
- color: var(--card-side-color);
-}
-
-.detail {
- @include text-ellipsis;
-
- color: var(--color-foreground-secondary);
-}
-
-.stage {
- @include transparency-checkerboard;
-
- display: flex;
- align-items: center;
- justify-content: center;
-
- // a container that knows its room sets these two
- block-size: var(--preview-card-stage-block-size, #{px2rem(100)});
- padding: var(--sp-s);
- overflow: hidden;
- border-radius: $br-6;
-
- &.is-large {
- block-size: var(--preview-card-stage-large-block-size, #{px2rem(320)});
- }
-}
-
-.caption {
- color: var(--color-foreground-secondary);
-
- &.is-warning {
- color: var(--color-accent-error);
- }
-}
diff --git a/frontend/src/app/main/ui/ds/product/preview_card.stories.jsx b/frontend/src/app/main/ui/ds/product/preview_card.stories.jsx
deleted file mode 100644
index bddddcb2c6..0000000000
--- a/frontend/src/app/main/ui/ds/product/preview_card.stories.jsx
+++ /dev/null
@@ -1,83 +0,0 @@
-// 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) KALEIDOS SUBSIDIARY SL
-
-import * as React from "react";
-import Components from "@target/components";
-
-const { PreviewCard } = Components;
-
-const Sample = ({ text }) => (
-
- {text}
-
-);
-
-export default {
- title: "Product/Branching/PreviewCard",
- component: PreviewCard,
- argTypes: {
- side: {
- options: ["base", "main", "branch", "result"],
- control: { type: "radio" },
- },
- isWarning: { control: { type: "boolean" } },
- isLarge: { control: { type: "boolean" } },
- },
- args: { label: "Branch", side: "branch", detail: "You", isWarning: false },
- render: ({ ...args }) => (
-
- ),
-};
-
-export const Default = {};
-
-export const Sides = {
- render: () => (
-
- ),
-};
-
-export const Large = {
- args: { isLarge: true },
-};
-
-export const WithCaption = {
- args: {
- label: "Result",
- side: "result",
- detail: "Merged as stored",
- caption: "Card 4 from main lands on card 3.",
- isWarning: true,
- },
-};
diff --git a/frontend/src/app/main/ui/workspace/branch_switcher.cljs b/frontend/src/app/main/ui/workspace/branch_switcher.cljs
index d652af2a57..c4b5b99960 100644
--- a/frontend/src/app/main/ui/workspace/branch_switcher.cljs
+++ b/frontend/src/app/main/ui/workspace/branch_switcher.cljs
@@ -19,11 +19,11 @@
[app.main.data.workspace.pull-requests :as dwpr]
[app.main.refs :as refs]
[app.main.store :as st]
- [app.main.ui.components.dropdown :refer [dropdown]]
[app.main.ui.ds.controls.input :refer [input*]]
[app.main.ui.ds.foundations.assets.icon :as i]
[app.main.ui.ds.foundations.typography :as t]
[app.main.ui.ds.foundations.typography.text :refer [text*]]
+ [app.main.ui.ds.layout.popover :refer [popover*]]
[app.main.ui.ds.product.branch-chip :refer [branch-chip*]]
[app.main.ui.ds.product.branch-row :refer [branch-row*]]
[app.main.ui.ds.product.branch-status :refer [branch-status*]]
@@ -201,7 +201,7 @@
(mf/use-fn
(fn [event]
;; the button unmounts as the listing reloads, so the
- ;; dropdown would take the click for an outside one and close
+ ;; popover would take the click for an outside one and close
(dom/stop-propagation event)
(st/emit! (dwb/init-branches-state))))]
@@ -314,7 +314,7 @@
on-toggle
(mf/use-fn
(fn [event]
- ;; the dropdown closes itself on any outside click: the click
+ ;; the popover closes itself on any outside click: the click
;; that opens it must not reach it
(dom/stop-propagation event)
(st/emit! (dwb/toggle-branch-switcher))))
@@ -401,7 +401,7 @@
:else
[:> row-status* {:row ctx :pr pr}]))
- [:& dropdown {:show open? :on-close on-close :container bar-ref}
+ [:> popover* {:is-open (boolean open?) :on-close on-close :container bar-ref}
[:> switcher-popover* {:current current
:prs-by-branch prs-by-branch
:on-close on-close}]]])))
diff --git a/frontend/src/app/main/ui/workspace/branch_switcher.scss b/frontend/src/app/main/ui/workspace/branch_switcher.scss
index 8a7466fc13..800d0b0ea2 100644
--- a/frontend/src/app/main/ui/workspace/branch_switcher.scss
+++ b/frontend/src/app/main/ui/workspace/branch_switcher.scss
@@ -90,6 +90,8 @@
}
.action {
+ --action-background-color: transparent;
+
@include use-typography("body-small");
display: flex;
@@ -101,14 +103,14 @@
border: none;
border-radius: $br-8;
background: none;
+ background-color: var(--action-background-color);
color: var(--color-foreground-primary);
text-align: start;
cursor: pointer;
&:hover:not(:disabled) {
+ --action-background-color: var(--color-background-quaternary);
--shortcut-foreground-color: var(--color-foreground-primary);
-
- background-color: var(--color-background-quaternary);
}
&:focus-visible {
diff --git a/frontend/src/app/main/ui/workspace/compare/common.cljs b/frontend/src/app/main/ui/workspace/compare/common.cljs
new file mode 100644
index 0000000000..4a3e6087b6
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/compare/common.cljs
@@ -0,0 +1,405 @@
+;; 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) KALEIDOS SUBSIDIARY SL
+
+(ns app.main.ui.workspace.compare.common
+ "What every panel of the compare mode reads and does: the comparison
+ as the store has it, and the actions the list, the navigator, the
+ banner and the popover share."
+ (:require
+ [app.common.files.branch-merge :as bm]
+ [app.common.files.helpers :as cfh]
+ [app.common.geom.shapes :as gsh]
+ [app.main.data.workspace.branches :as dwb]
+ [app.main.data.workspace.compare :as dwcp]
+ [app.main.refs :as refs]
+ [app.main.store :as st]
+ [app.main.ui.ds.foundations.assets.icon :as i]
+ [app.main.ui.workspace.sidebar.branch-review.common :as brc]
+ [app.main.ui.workspace.sidebar.branch-review.sides :as brs]
+ [app.util.dom :as dom]
+ [app.util.i18n :as i18n :refer [tr]]
+ [app.util.webapi :as wapi]
+ [cuerdas.core :as str]
+ [rumext.v2 :as mf]))
+
+(defn use-comparison
+ "The comparison of the compare mode, put together from the store:
+
+ `:mode` the `:workspace-compare` entry, and from it `:branch`,
+ `:phase`, `:selected`, `:hovered` and `:attr`;
+ `:status` of the diff (`:loading`, `:loaded`, `:error`);
+ `:incoming` true when the changes listed are main's;
+ `:excluded`, `:reviewed`, `:resolutions` the marks on the diff;
+ `:diff`, `:data`, `:copies` what the detail and the export read;
+ `:model` the list of changes (`brc/change-model`);
+ `:conflicts` the list of conflicts (`brc/conflict-model`);
+ `:rows` the rows of the phase, in the order of its list;
+ `:item` the change or conflict chosen, and `:res` its
+ resolution when it is a conflict."
+ []
+ (let [mode (mf/deref refs/compare-mode)
+ diff-st (mf/deref refs/branch-diff)
+ attempt (mf/deref refs/branch-conflicts)
+ data (mf/deref refs/workspace-data)
+
+ {:keys [branch phase selected]} mode
+ {:keys [status diff resolutions]} diff-st
+ incoming? (= :main->branch (:direction diff-st))
+ excluded (dwb/diff-excluded diff-st)
+ reviewed (or (:reviewed diff-st) #{})
+ active (:filter mode)
+
+ model (mf/with-memo [diff active excluded data]
+ (brc/change-model diff {:filter active
+ :excluded excluded
+ :pages-index (:pages-index data)
+ :pages (:pages data)}))
+ conflicts (mf/with-memo [attempt diff-st branch resolutions]
+ (brc/conflict-model (dwcp/get-conflicts attempt diff-st (:id branch))
+ (or resolutions {})))
+ rows (if (= phase :resolve) (:rows conflicts) (:rows model))
+ item (mf/with-memo [rows selected]
+ (some #(when (= selected (dwcp/item-key %)) %) rows))]
+ {:mode mode
+ :branch branch
+ :phase phase
+ :selected selected
+ :hovered (:hovered mode)
+ :hovered-from (:hovered-from mode)
+ :attr (:attr mode)
+ :status status
+ :incoming incoming?
+ :excluded excluded
+ :reviewed reviewed
+ :resolutions (or resolutions {})
+ :diff diff
+ :data data
+ :copies (:copies diff)
+ :model model
+ :conflicts conflicts
+ :rows rows
+ :item item
+ :res (get resolutions (:id item))}))
+
+;; --- What the canvas shows
+
+(defn main-objects
+ "The layers of page `page-id` as main has them, from `objects`, the
+ page as the open branch has it. `items` are the entries of the diff
+ listed, main's own when `incoming`, and `other` the changes of its
+ other direction (`:other-changes` of the mode): main lacks what the
+ branch changed and has what main itself changed."
+ [objects page-id items other incoming]
+ (let [on-page (fn [items] (filterv #(= page-id (:page-id %)) items))
+ [own others] (if incoming [:main :branch] [:branch :main])]
+ (-> objects
+ (brs/side-objects (on-page items) :main :branch own)
+ (brs/side-objects (on-page other) :main :branch others))))
+
+(defn main-extent
+ "The rect that holds every layer of `main` (`main-objects`), nil for an
+ empty page."
+ [main]
+ (let [shapes (cfh/get-immediate-children main)]
+ (when (seq shapes)
+ (gsh/shapes->rect shapes))))
+
+(defn- get-center
+ [objects id]
+ (when-let [{:keys [x y width height]} (get-in objects [id :selrect])]
+ {:x (+ x (/ width 2)) :y (+ y (/ height 2))}))
+
+(defn align-offset
+ "How far main is moved, as `{:x :y}` in page units, so the layer of
+ entry `item` sits in main's half where the canvas has it in its own:
+ the centre of the layer in `canvas` (the page as the canvas shows it)
+ less its centre in `main`. Nil when there is nothing to line up: no
+ entry, an entry that is no layer, a layer one side lacks, or the same
+ place on both."
+ [canvas main item]
+ (when (= :shape (:kind item))
+ (let [to (get-center canvas (:id item))
+ from (get-center main (:id item))]
+ (when (and (some? to) (some? from) (not= to from))
+ {:x (- (:x to) (:x from))
+ :y (- (:y to) (:y from))}))))
+
+(defn canvas-objects
+ "The layers of the page `page-id` as the canvas shows them in the
+ compare mode, from `objects`, the page as the open branch has it. The
+ canvas shows what the action on offer leaves:
+
+ - listing main's changes, the branch with the ones kept brought in;
+ - resolving, the choices made so far on top of that, with the side
+ the pointer tries out (`:preview`) as if it were chosen;
+ - while peeking (`:peek`), main in place of the branch.
+
+ Returns `{:kind :objects}` with `:kind` one of `:update`, `:result` or
+ `:main`, or nil when the canvas shows the branch as it is."
+ [{:keys [mode phase incoming model conflicts resolutions excluded item res attr]} objects page-id]
+ (let [on-page? #(= page-id (:page-id %))
+ incoming* (fn [objects]
+ (brs/side-objects objects
+ (filterv #(and (on-page? %)
+ (brc/selectable-item? %)
+ (not (contains? excluded (:key %))))
+ (:items model))
+ :main :branch :main))
+ result
+ (cond
+ (:hidden mode)
+ nil
+
+ (= phase :resolve)
+ (let [side (:preview mode)
+ res* (cond-> resolutions
+ (and (some? side) (some? item))
+ (assoc (:id item)
+ (if-let [attr (brc/pending-attr item res attr)]
+ (brc/choose-attr item res attr side)
+ side)))]
+ {:kind :result
+ :objects (brs/resolved-objects (cond-> objects incoming incoming*)
+ (filterv on-page? (:conflicts conflicts))
+ res*)})
+
+ incoming
+ {:kind :update :objects (incoming* objects)}
+
+ (:peek mode)
+ {:kind :main
+ :objects (main-objects objects page-id (:items model) (:other-changes mode) false)})]
+ (when (and (some? result) (not (identical? objects (:objects result))))
+ result)))
+
+(defn chosen-marks
+ "The marks of `marks` the canvas shows with the entry `selected`
+ chosen: its own, the ones of the layers that use it (`:usage`) and the
+ one of the entry whose row is under the pointer (`hovered`), so the
+ canvas is not crowded. All of them with none chosen."
+ [selected hovered marks]
+ (if (some? selected)
+ (filterv #(or (= selected (:key %))
+ (= hovered (:key %))
+ (= :usage (:status %)))
+ marks)
+ marks))
+
+(defn layer-entry
+ "The key of the entry of `rows` that answers for the layers `ids` (the
+ ones under the pointer) of `objects`: the entry of one of them or of
+ the closest layer that holds it, as a change of a board is the change
+ of what is in it. With several, the one of the deepest layer."
+ [rows objects ids]
+ (let [by-layer (into {}
+ (comp (filter #(= :shape (:kind %)))
+ (map (juxt :id dwcp/item-key)))
+ rows)
+ ;; up to the root of the page, which is its own parent
+ chain (fn [id]
+ (loop [id id found []]
+ (let [parent-id (:parent-id (get objects id))]
+ (if (or (nil? id) (some #(= id %) found))
+ found
+ (recur (when (not= parent-id id) parent-id)
+ (conj found id))))))
+ depth (fn [id] (count (chain id)))
+ holder (fn [id] (some #(when (contains? by-layer %) %) (chain id)))]
+ (when (seq by-layer)
+ (some->> (keep holder ids)
+ (seq)
+ (apply max-key depth)
+ (get by-layer)))))
+
+;; --- Moving through the list
+
+(defn select-step
+ "Choose the row `offset` rows away from the one chosen."
+ [{:keys [rows selected]} offset]
+ (when-let [item-key (brc/step rows selected offset)]
+ (st/emit! (dwcp/select item-key))))
+
+(defn mark-reviewed
+ "Mark the change chosen as reviewed and go to the next one not reviewed
+ yet."
+ [{:keys [rows selected item reviewed]}]
+ (when (some? item)
+ (st/emit! (dwb/toggle-diff-reviewed selected true)))
+ (when-let [item-key (brc/next-pending rows selected
+ #(or (bm/settled? %)
+ (contains? reviewed (dwcp/item-key %))))]
+ (st/emit! (dwcp/select item-key))))
+
+(defn toggle-excluded
+ "Leave the change chosen out of the merge or update, or take it back
+ in, with the layers folded under it."
+ [{:keys [item model]}]
+ (when (and (some? item) (brc/selectable-item? item))
+ (st/emit! (dwb/toggle-diff-excluded
+ (brc/row-keys item (get (:cascades model) (dwcp/item-key item)))))))
+
+(defn export-diff
+ "Download the diff of the comparison as a JSON file named after the
+ branch."
+ [{:keys [branch diff]}]
+ (let [payload (clj->js {:stats (:stats diff)
+ :changes (:changes diff)
+ :conflicts (:conflicts diff)
+ :copies (:copies diff)})
+ text (js/JSON.stringify payload nil 2)]
+ (dom/trigger-download (str (:name branch) "-diff.json")
+ (wapi/create-blob text "application/json"))))
+
+;; --- Deciding a conflict
+
+(defn pick-attr
+ "Keep `side` for the property `attr` of the conflict chosen."
+ [{:keys [item res]} attr side]
+ (when (some? item)
+ (st/emit! (dwb/set-conflict-resolutions
+ {(:id item) (brc/choose-attr item res attr side)}))))
+
+(defn choose-side
+ "Keep `side` for the whole conflict chosen."
+ [{:keys [item]} side]
+ (when (some? item)
+ (st/emit! (dwb/set-conflict-resolution (:id item) side))))
+
+(defn clear-choice
+ "Forget the choice made for the conflict chosen: it asks again, with
+ the edits one side made alone filled in as at the start."
+ [{:keys [item]}]
+ (when (some? item)
+ (st/emit! (dwb/clear-conflict-resolution (:id item))
+ (dwb/set-conflict-resolutions
+ (if (brc/per-attr? item)
+ {(:id item) (brc/prefill-resolution item)}
+ {})))))
+
+(defn keep-all
+ "Keep `side` for every conflict; the edits one side made alone stay
+ with the side that made them."
+ [{:keys [conflicts]} side]
+ (st/emit! (dwb/set-conflict-resolutions
+ (into {}
+ (map (fn [conflict] [(:id conflict) (brc/choose-side conflict side)]))
+ (:conflicts conflicts)))))
+
+(defn next-pending
+ "Go to the next thing to decide: the next property without a choice of
+ the conflict chosen, or the next conflict that waits for one."
+ [{:keys [rows selected item res attr resolutions]}]
+ (let [current (when (some? item) (brc/pending-attr item res attr))
+ another (when (some? item)
+ (->> (brc/conflicting-attrs (brc/conflict-attr-rows item))
+ (remove #{current})
+ (some #(when (nil? (brc/attr-choice res %)) %))))]
+ (if (and (some? another) (brc/per-attr? item))
+ (st/emit! (dwcp/set-attr another))
+ (when-let [item-key (brc/next-pending rows selected
+ #(bm/conflict-resolved? % (get resolutions (:id %))))]
+ (st/emit! (dwcp/select item-key))))))
+
+;; --- The bar at the bottom of the canvas
+
+(defn- on-exit
+ []
+ (st/emit! (dwcp/exit)))
+
+(defn- on-back
+ []
+ (st/emit! (dwcp/back-to-compare)))
+
+(defn- on-resolve
+ []
+ (st/emit! (dwcp/start-resolve)))
+
+(defn- on-apply
+ []
+ (st/emit! (dwcp/apply-resolutions)))
+
+(defn- compare-bar
+ [{:keys [branch status incoming model reviewed excluded]}]
+ (let [{:keys [counted decisions kept left-out]} model
+ loaded? (= status :loaded)
+ total (count counted)
+ reviewed-n (count (filter #(contains? reviewed (dwcp/item-key %)) counted))]
+ {:icon (if incoming i/arrow-down i/git-compare-arrows)
+ :title (if (and incoming loaded?)
+ (tr "workspace.branches.banner.status.behind" (i18n/c total))
+ (tr "workspace.compare.bar.comparing-main"))
+ :detail (cond
+ (= status :error) (tr "workspace.branches.compare.error")
+ (not loaded?) (tr "workspace.branches.compare.loading")
+ :else
+ (str/join " - "
+ (remove nil?
+ [(tr "workspace.branches.compare.footer-changes" (i18n/c total))
+ (when (pos? left-out)
+ (tr "workspace.branches.review.footer.left-out" (i18n/c left-out)))
+ (when (pos? reviewed-n)
+ (tr "workspace.branches.review.footer.reviewed"
+ (str reviewed-n) (str total)))])))
+ :progress (when loaded?
+ (tr "workspace.branches.review.footer.reviewed" (str reviewed-n) (str total)))
+ :exit {:label (tr "workspace.compare.bar.exit") :icon i/close :on-click on-exit}
+ :action (cond
+ (not loaded?)
+ nil
+
+ (pos? decisions)
+ {:label (tr "workspace.branches.review.action.resolve" (i18n/c decisions))
+ :icon i/git-merge-conflict
+ :on-click on-resolve}
+
+ incoming
+ {:label (tr "workspace.branches.review.action.update" (i18n/c kept))
+ :icon i/status-update
+ :disabled (zero? kept)
+ :on-click #(brc/confirm-update! branch excluded)}
+
+ :else
+ {:label (tr "workspace.branches.review.action.merge" (i18n/c kept))
+ :icon i/git-merge
+ :merge true
+ :disabled (zero? kept)
+ :on-click #(brc/confirm-merge! branch excluded)})}))
+
+(defn- resolve-bar
+ [{:keys [incoming conflicts]}]
+ (let [total (count (:conflicts conflicts))
+ decided (count (:decided conflicts))
+ done? (and (pos? total) (= total decided))]
+ {:icon (if done? i/tick i/triangle-alert)
+ :warning (not done?)
+ :title (if done?
+ (tr "workspace.compare.bar.all-decided")
+ (tr "workspace.branches.banner.status.conflicts" (i18n/c total)))
+ :detail (tr "workspace.compare.bar.decided" (str decided) (str total))
+ :progress (tr "workspace.compare.bar.decided" (str decided) (str total))
+ :exit {:label (tr "workspace.compare.bar.back") :icon i/arrow-left :on-click on-back}
+ :action {:label (if incoming
+ (tr "workspace.compare.bar.apply-update")
+ (tr "workspace.branches.conflicts.apply"))
+ :icon i/git-merge
+ :merge (not incoming)
+ ;; nothing is applied until every conflict has a choice
+ :disabled (not done?)
+ :on-click on-apply}}))
+
+(defn bar
+ "What the bar at the bottom of the canvas says and offers in the
+ compare mode, for the banner that draws it: its `:icon` (a `:warning`
+ one while conflicts wait), `:title` and `:detail`, the `:progress` of
+ the review or of the decisions, the way out (`:exit`, drawn as its
+ `:icon` alone, its `:label` in a tooltip) and the main `:action`, each
+ `{:label :on-click}` with `:disabled` and `:icon`. An
+ action that merges into main says so (`:merge`), as not everybody may
+ merge."
+ [comparison]
+ (if (= :resolve (:phase comparison))
+ (resolve-bar comparison)
+ (compare-bar comparison)))
diff --git a/frontend/src/app/main/ui/workspace/compare/detail.cljs b/frontend/src/app/main/ui/workspace/compare/detail.cljs
new file mode 100644
index 0000000000..b3c45041cc
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/compare/detail.cljs
@@ -0,0 +1,160 @@
+;; 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) KALEIDOS SUBSIDIARY SL
+
+(ns app.main.ui.workspace.compare.detail
+ "The right sidebar of the compare mode: the change or the conflict
+ chosen in the list, and under it the comments and the tasks on its
+ layer."
+ (:require-macros [app.main.style :as stl])
+ (:require
+ [app.common.data.macros :as dm]
+ [app.main.data.workspace.compare :as dwcp]
+ [app.main.data.workspace.tasks :as dwtk]
+ [app.main.refs :as refs]
+ [app.main.store :as st]
+ [app.main.ui.ds.foundations.assets.icon :as i]
+ [app.main.ui.ds.foundations.typography :as t]
+ [app.main.ui.ds.foundations.typography.heading :refer [heading*]]
+ [app.main.ui.ds.product.empty-state :refer [empty-state*]]
+ [app.main.ui.workspace.compare.common :as cc]
+ [app.main.ui.workspace.review.panel :refer [thread-card*]]
+ [app.main.ui.workspace.review.tasks :refer [task-list*]]
+ [app.main.ui.workspace.sidebar.branch-review.common :as brc]
+ [app.main.ui.workspace.sidebar.branch-review.detail :as brd]
+ [app.util.i18n :refer [tr]]
+ [rumext.v2 :as mf]))
+
+(defn- on-resolve
+ []
+ (st/emit! (dwcp/start-resolve)))
+
+(defn- on-attr
+ [attr]
+ (st/emit! (dwcp/set-attr attr)))
+
+(mf/defc change*
+ "The change chosen while comparing, with what can be done about it."
+ {::mf/private true}
+ [{:keys [comparison]}]
+ (let [{:keys [item model data copies incoming excluded]} comparison
+ objects (get-in data [:pages-index (:page-id item) :objects])
+ ;; only a layer the open file has can be edited
+ editable? (and (= :shape (:kind item)) (contains? objects (:id item)))
+ selectable? (brc/selectable-item? item)
+ on-edit (mf/use-fn (mf/deps item) #(st/emit! (dwcp/edit-layer item)))
+ on-toggle (mf/use-fn (mf/deps comparison) #(cc/toggle-excluded comparison))]
+ [:> brd/change-detail* {:item item
+ :items (:items model)
+ :inner (get (:cascades model) (dwcp/item-key item))
+ :copies copies
+ :data data
+ ;; the mode only opens on the branch file
+ :open-side :branch
+ :incoming incoming
+ :excluded (and selectable? (contains? excluded (:key item)))
+ :on-edit (when editable? on-edit)
+ :on-toggle (when selectable? on-toggle)
+ :on-resolve (when (brc/conflict? item) on-resolve)}]))
+
+(mf/defc conflict*
+ "The conflict chosen while resolving."
+ {::mf/private true}
+ [{:keys [comparison is-review]}]
+ (let [{:keys [item res attr branch data copies]} comparison
+ on-pick (mf/use-fn (mf/deps comparison) #(cc/pick-attr comparison %1 %2))
+ on-choose (mf/use-fn (mf/deps comparison) #(cc/choose-side comparison %))
+ on-clear (mf/use-fn (mf/deps comparison) #(cc/clear-choice comparison))]
+ [:> brd/conflict-detail* {:conflict item
+ :res res
+ :attr (brc/pending-attr item res attr)
+ :branch-name (:name branch)
+ :is-review is-review
+ :copies copies
+ :data data
+ :on-pick on-pick
+ :on-choose on-choose
+ :on-clear on-clear
+ :on-attr on-attr}]))
+
+(defn layer-threads
+ "The comment threads of `threads` (by id) on the layer `layer-id` that
+ wait for an answer, in the order they were opened."
+ [threads layer-id]
+ (->> (vals threads)
+ (filter #(and (= layer-id (:shape-id %)) (not (:is-resolved %))))
+ (sort-by :seqn)
+ (vec)))
+
+(defn layer-tasks
+ "The tasks of `tasks` (by id) on the layer `layer-id` still to be done
+ or verified."
+ [tasks layer-id]
+ (->> (vals tasks)
+ (filter #(and (= layer-id (:shape-id %)) (not (dwtk/closed? %))))
+ (vec)))
+
+(mf/defc context-head*
+ {::mf/private true}
+ [{:keys [icon label]}]
+ [:> heading* {:level 3 :typography t/body-small :class (stl/css :context-head)}
+ [:> i/icon* {:icon-id icon :size "s" :class (stl/css :context-icon)}]
+ label])
+
+(mf/defc layer-context*
+ "What else the layer of `item` carries: the comments that wait for an
+ answer and the tasks still open on it, for the context of its change.
+ Nothing for an entry that is no layer, or a layer without them."
+ {::mf/private true}
+ [{:keys [item data]}]
+ (let [threads (mf/deref refs/threads)
+ tasks (mf/deref refs/tasks)
+ clocal (mf/deref refs/comments-local)
+ layer-id (when (= :shape (:kind item)) (:id item))
+ on-layer (mf/with-memo [threads layer-id]
+ (if layer-id (layer-threads threads layer-id) []))
+ todo (mf/with-memo [tasks layer-id]
+ (if layer-id (layer-tasks tasks layer-id) []))
+ objects (dm/get-in data [:pages-index (:page-id item) :objects])]
+ (when (or (seq on-layer) (seq todo))
+ [:div {:class (stl/css :context)}
+ (when (seq on-layer)
+ [:section {:class (stl/css :context-group)}
+ [:> context-head* {:icon i/comments
+ :label (tr "workspace.compare.layer.comments" (count on-layer))}]
+ (for [thread on-layer]
+ [:> thread-card* {:key (dm/str (:id thread))
+ :thread thread
+ :objects objects
+ :show-review true
+ :is-open (= (:id thread) (:open clocal))}])])
+ (when (seq todo)
+ [:section {:class (stl/css :context-group)}
+ [:> context-head* {:icon i/view-as-list
+ :label (tr "workspace.compare.layer.tasks" (count todo))}]
+ [:> task-list* {:tasks todo :show-review true}]])])))
+
+(mf/defc compare-detail*
+ []
+ (let [comparison (cc/use-comparison)
+ preview (mf/deref refs/pull-request-preview)
+ review? (some? preview)
+ {:keys [item phase status]} comparison]
+ (cond
+ (nil? item)
+ [:div {:class (stl/css :empty)}
+ (when (or (= status :loaded) (= phase :resolve))
+ [:> empty-state* {:icon i/git-compare-arrows
+ :text (tr "workspace.branches.compare.select-hint")}])]
+
+ (= phase :resolve)
+ [:div {:class (stl/css :compare-detail)}
+ [:> conflict* {:comparison comparison :is-review review?}]
+ [:> layer-context* {:item item :data (:data comparison)}]]
+
+ :else
+ [:div {:class (stl/css :compare-detail)}
+ [:> change* {:comparison comparison}]
+ [:> layer-context* {:item item :data (:data comparison)}]])))
diff --git a/frontend/src/app/main/ui/workspace/compare/detail.scss b/frontend/src/app/main/ui/workspace/compare/detail.scss
new file mode 100644
index 0000000000..d98e3b8250
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/compare/detail.scss
@@ -0,0 +1,50 @@
+// 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) KALEIDOS SUBSIDIARY SL
+
+@use "ds/mixins.scss" as *;
+
+// its blocks over the whole width undo this padding
+// (`branch_review/detail.scss`)
+.compare-detail {
+ @include custom-scrollbar;
+
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-xl);
+ block-size: 100%;
+ min-block-size: 0;
+ padding: var(--sp-m);
+ overflow-y: auto;
+}
+
+// the comments and the tasks on the layer of the change
+.context {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-l);
+}
+
+.context-group {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+}
+
+.context-head {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-xs);
+ margin: 0;
+ color: var(--color-foreground-secondary);
+}
+
+.context-icon {
+ flex-shrink: 0;
+}
+
+.empty {
+ padding: var(--sp-xxl) var(--sp-m);
+}
diff --git a/frontend/src/app/main/ui/workspace/compare/list.cljs b/frontend/src/app/main/ui/workspace/compare/list.cljs
new file mode 100644
index 0000000000..2c5fc7e9d8
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/compare/list.cljs
@@ -0,0 +1,226 @@
+;; 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) KALEIDOS SUBSIDIARY SL
+
+(ns app.main.ui.workspace.compare.list
+ "The left sidebar of the compare mode. Comparing, it lists the changes
+ of the branch or the ones main has, by page and board, with the
+ checkbox that leaves each one out. Resolving, it lists the conflicts
+ with the ones that wait for a choice first."
+ (:require-macros [app.main.style :as stl])
+ (:require
+ [app.common.data.macros :as dm]
+ [app.main.data.workspace.branches :as dwb]
+ [app.main.data.workspace.compare :as dwcp]
+ [app.main.store :as st]
+ [app.main.ui.ds.buttons.button :refer [button*]]
+ [app.main.ui.ds.buttons.icon-button :refer [icon-button*]]
+ [app.main.ui.ds.foundations.assets.icon :as i]
+ [app.main.ui.ds.foundations.typography :as t]
+ [app.main.ui.ds.foundations.typography.heading :refer [heading*]]
+ [app.main.ui.ds.layout.tab-switcher :refer [tab-switcher*]]
+ [app.main.ui.ds.product.empty-state :refer [empty-state*]]
+ [app.main.ui.ds.product.filter-chip :refer [filter-chip*]]
+ [app.main.ui.ds.product.tag :refer [tag*]]
+ [app.main.ui.workspace.compare.common :as cc]
+ [app.main.ui.workspace.sidebar.branch-review.common :as brc]
+ [app.main.ui.workspace.sidebar.branch-review.list :as brli]
+ [app.util.dom :as dom]
+ [app.util.i18n :refer [tr]]
+ [rumext.v2 :as mf]))
+
+(defn- on-select
+ [item-key]
+ (st/emit! (dwcp/toggle-selected item-key)))
+
+(defn- on-hover
+ "The row under the pointer, from wherever in it the pointer is; none
+ between rows."
+ [event]
+ (let [row (.closest ^js (dom/get-target event) "[data-item-key]")]
+ (st/emit! (dwcp/set-hovered (some-> row (dom/get-data "item-key")) :list))))
+
+(defn- on-leave
+ [_]
+ (st/emit! (dwcp/set-hovered nil :list)))
+
+(defn- on-fold
+ [id]
+ (st/emit! (dwcp/toggle-group id)))
+
+(defn- on-toggle
+ [change-keys include?]
+ (st/emit! (dwb/toggle-diff-excluded change-keys include?)))
+
+(defn- on-direction
+ [id]
+ (st/emit! (dwcp/set-direction (keyword id))))
+
+(defn- on-filter
+ [event]
+ (st/emit! (dwcp/set-filter (-> (dom/get-current-target event)
+ (dom/get-data "filter")
+ (keyword)))))
+
+(mf/defc header*
+ "The title of the list, the tag that says the canvas takes no edits
+ here and, with `on-export`, the button that downloads the diff."
+ {::mf/private true}
+ [{:keys [title on-export]}]
+ [:div {:class (stl/css :header)}
+ [:> heading* {:level 2 :typography t/headline-small :class (stl/css :title)} title]
+ (when on-export
+ [:> icon-button* {:variant "ghost"
+ :icon i/download
+ :aria-label (tr "workspace.branches.compare.export")
+ :on-click on-export}])
+ ;; the same badge the pages panel shows on a file that takes no edits
+ [:> tag* {:variant "pill" :icon i/lock}
+ (tr "labels.view-only")]])
+
+(mf/defc filters*
+ {::mf/private true}
+ [{:keys [counts selected]}]
+ [:div {:class (stl/css :filters)}
+ [:> filter-chip* {:label (dm/str (tr "labels.all") " (" (:all counts) ")")
+ :is-selected (= selected :all)
+ :data-filter "all"
+ :on-click on-filter}]
+ (when (pos? (:layers counts))
+ [:> filter-chip* {:label (dm/str (tr "workspace.compare.filter.layers") " (" (:layers counts) ")")
+ :is-selected (= selected :layers)
+ :data-filter "layers"
+ :on-click on-filter}])
+ (when (pos? (:library counts))
+ [:> filter-chip* {:label (dm/str (tr "workspace.branches.review.group.library")
+ " (" (:library counts) ")")
+ :is-selected (= selected :library)
+ :data-filter "library"
+ :on-click on-filter}])
+ (when (pos? (:left-out counts))
+ [:> filter-chip* {:label (dm/str (tr "workspace.branches.review.row.left-out")
+ " (" (:left-out counts) ")")
+ :is-selected (= selected :left-out)
+ :data-filter "left-out"
+ :on-click on-filter}])])
+
+(defn- tab-label
+ "The label of a direction tab, with how many changes it lists once that
+ is known."
+ [label total]
+ (if (some? total)
+ (tr "workspace.compare.tab-count" label total)
+ label))
+
+(mf/defc changes*
+ "The changes of the direction shown, under the tabs that switch it."
+ {::mf/private true}
+ [{:keys [comparison]}]
+ (let [{:keys [mode status incoming model selected excluded reviewed copies]} comparison
+ counts (:counts mode)
+ direction (if incoming :main->branch :branch->main)
+ tabs (mf/with-memo [counts]
+ [{:id "branch->main"
+ :label (tab-label (tr "workspace.compare.direction.branch")
+ (get counts :branch->main))}
+ {:id "main->branch"
+ :label (tab-label (tr "workspace.compare.direction.main")
+ (get counts :main->branch))}])
+ follows (mf/with-memo [copies]
+ (brc/copy-follow-counts copies))]
+ [:> tab-switcher* {:tabs tabs
+ :selected (name direction)
+ :on-change on-direction
+ :scrollable-panel true
+ :class (stl/css :tabs)}
+ (cond
+ (= status :error)
+ [:div {:class (stl/css :empty)}
+ [:> empty-state* {:icon i/triangle-alert :text (tr "workspace.branches.compare.error")}]]
+
+ (not= status :loaded)
+ [:div {:class (stl/css :empty)}
+ [:> empty-state* {:icon i/git-compare-arrows :text (tr "workspace.branches.compare.loading")}]]
+
+ (empty? (:items model))
+ [:div {:class (stl/css :empty)}
+ [:> empty-state* {:icon i/git-branch
+ :text (if incoming
+ (tr "workspace.compare.empty-main")
+ (tr "workspace.branches.compare.empty"))}]]
+
+ :else
+ [:div {:class (stl/css :content)}
+ [:> filters* {:counts (:counts model) :selected (:filter mode)}]
+ [:div {:class (stl/css :rows)}
+ [:> brli/change-list* {:model model
+ :follow-counts follows
+ :selected selected
+ :excluded excluded
+ :reviewed reviewed
+ :collapsed (:collapsed mode)
+ :on-select on-select
+ :on-toggle on-toggle
+ :on-fold on-fold}]]])]))
+
+(mf/defc decisions*
+ "The conflicts to resolve, under the buttons that decide them all at
+ once."
+ {::mf/private true}
+ [{:keys [comparison]}]
+ (let [{:keys [mode conflicts selected resolutions]} comparison
+ total (count (:conflicts conflicts))
+ on-all-main (mf/use-fn (mf/deps comparison) #(cc/keep-all comparison :main))
+ on-all-branch (mf/use-fn (mf/deps comparison) #(cc/keep-all comparison :branch))]
+ (if (zero? total)
+ [:div {:class (stl/css :empty)}
+ [:> empty-state* {:icon i/git-merge :text (tr "workspace.branches.conflicts.empty")}]]
+ [:div {:class (stl/css :content :is-scrollable)}
+ ;; deciding them all at once only means something with more than
+ ;; one decision
+ (when (> total 1)
+ [:div {:class (stl/css :bulk)}
+ [:> button* {:variant "secondary" :on-click on-all-main}
+ (tr "workspace.branches.resolve.keep-all-main")]
+ [:> button* {:variant "secondary" :on-click on-all-branch}
+ (tr "workspace.branches.resolve.keep-all-branch")]])
+ [:div {:class (stl/css :rows)}
+ [:> brli/conflict-list* {:model conflicts
+ :resolutions resolutions
+ :selected selected
+ :collapsed (:collapsed mode)
+ :on-select on-select
+ :on-fold on-fold}]]])))
+
+(mf/defc compare-list*
+ [{:keys [class]}]
+ (let [comparison (cc/use-comparison)
+ resolving? (= :resolve (:phase comparison))
+ on-export (mf/use-fn (mf/deps comparison) #(cc/export-diff comparison))
+ node-ref (mf/use-ref nil)
+ hovered (:hovered comparison)
+ ;; the row of the layer under the pointer, on the canvas
+ pointed (when (= :canvas (:hovered-from comparison)) hovered)]
+
+ ;; that row comes into sight
+ (mf/with-effect [pointed]
+ (when (some? pointed)
+ (some-> (mf/ref-val node-ref)
+ (.querySelector (dm/str "[data-item-key=\"" pointed "\"]"))
+ (.scrollIntoView #js {:block "nearest"}))))
+
+ [:div {:class [class (stl/css :compare-list)]
+ :ref node-ref
+ :on-pointer-over on-hover
+ :on-pointer-leave on-leave}
+ [:> (mf/provider brli/pointed-row) {:value pointed}
+ [:> header* {:title (if resolving?
+ (tr "workspace.compare.decisions"
+ (count (get-in comparison [:conflicts :conflicts])))
+ (tr "workspace.compare.changes"))
+ :on-export (when (= :loaded (:status comparison)) on-export)}]
+ (if resolving?
+ [:> decisions* {:comparison comparison}]
+ [:> changes* {:comparison comparison}])]]))
diff --git a/frontend/src/app/main/ui/workspace/compare/list.scss b/frontend/src/app/main/ui/workspace/compare/list.scss
new file mode 100644
index 0000000000..f7bd503229
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/compare/list.scss
@@ -0,0 +1,75 @@
+// 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) KALEIDOS SUBSIDIARY SL
+
+@use "ds/_sizes.scss" as *;
+@use "ds/mixins.scss" as *;
+
+.compare-list {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+ min-block-size: 0;
+ padding-block-start: var(--sp-s);
+}
+
+.header {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-s);
+ min-block-size: $sz-32;
+ padding-inline: var(--sp-m) var(--sp-s);
+}
+
+.title {
+ flex: 1;
+ margin: 0;
+ color: var(--color-foreground-secondary);
+}
+
+.tabs {
+ --tabs-nav-padding-inline-start: var(--sp-s);
+ --tabs-nav-padding-inline-end: var(--sp-s);
+
+ flex: 1;
+ min-block-size: 0;
+}
+
+.content {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+ padding: var(--sp-s);
+
+ &.is-scrollable {
+ @include custom-scrollbar;
+
+ flex: 1;
+ min-block-size: 0;
+ overflow-y: auto;
+ }
+}
+
+.filters {
+ display: flex;
+ flex-wrap: wrap;
+ gap: var(--sp-xs);
+}
+
+.rows {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-xxs);
+}
+
+.bulk {
+ display: flex;
+ flex-wrap: wrap;
+ gap: var(--sp-xs);
+}
+
+.empty {
+ padding: var(--sp-xxl) var(--sp-m);
+}
diff --git a/frontend/src/app/main/ui/workspace/compare/overlays.cljs b/frontend/src/app/main/ui/workspace/compare/overlays.cljs
new file mode 100644
index 0000000000..4e08b76054
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/compare/overlays.cljs
@@ -0,0 +1,494 @@
+;; 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) KALEIDOS SUBSIDIARY SL
+
+(ns app.main.ui.workspace.compare.overlays
+ "What the compare mode draws over the canvas: a mark on every changed
+ layer of the page, the bar that goes through the changes and, while
+ resolving, the popover that asks for a choice beside the layer in
+ conflict."
+ (:require-macros [app.main.style :as stl])
+ (:require
+ [app.common.data.macros :as dm]
+ [app.common.files.branch-merge :as bm]
+ [app.common.math :as mth]
+ [app.main.data.modal :as modal]
+ [app.main.data.workspace.branches :as dwb]
+ [app.main.data.workspace.compare :as dwcp]
+ [app.main.features :as features]
+ [app.main.refs :as refs]
+ [app.main.store :as st]
+ [app.main.ui.ds.buttons.button :refer [button*]]
+ [app.main.ui.ds.foundations.typography :as t]
+ [app.main.ui.ds.foundations.typography.heading :refer [heading*]]
+ [app.main.ui.ds.foundations.typography.text :refer [text*]]
+ [app.main.ui.workspace.compare.common :as cc]
+ [app.main.ui.workspace.compare.side :refer [side-view*]]
+ [app.main.ui.workspace.review.overlays :as rvo]
+ [app.main.ui.workspace.sidebar.branch-review.common :as brc]
+ [app.main.ui.workspace.sidebar.branch-review.detail :as brd]
+ [app.render-wasm.api :as wasm.api]
+ [app.util.dom :as dom]
+ [app.util.i18n :refer [tr]]
+ [app.util.keyboard :as kbd]
+ [rumext.v2 :as mf]))
+
+;; --- Marks
+
+(defn- status-tone
+ [status]
+ (case status
+ :added "success"
+ :deleted "error"
+ :conflict "warning"
+ :decided "success"
+ nil))
+
+(defn- status-label
+ [status]
+ (case status
+ :added (tr "workspace.branches.status.added")
+ :deleted (tr "workspace.branches.status.deleted")
+ :conflict (tr "workspace.branches.status.conflict")
+ :decided (tr "workspace.branches.resolve.decided")
+ (tr "workspace.branches.status.modified")))
+
+(mf/defc mark*
+ "The mark of one change. Its tag chooses the change, without moving
+ the canvas: it is already in sight."
+ {::mf/private true}
+ [{:keys [mark zoom is-active children]}]
+ (let [{:keys [label status rect]} mark
+ mark-key (:key mark)
+ usage? (= :usage status)
+ on-click (mf/use-fn
+ (mf/deps mark-key)
+ (fn [event]
+ (dom/stop-propagation event)
+ (st/emit! (dwcp/select mark-key {:travel false}))))]
+ [:> rvo/change-box* {:rect rect
+ :zoom zoom
+ :tone (status-tone status)
+ :label (cond
+ usage? label
+ is-active (tr "workspace.review.text-and-detail"
+ label (status-label status))
+ :else (status-label status))
+ :is-active is-active
+ ;; a layer that only uses the change is no row
+ ;; of the list
+ :on-click (when-not usage? on-click)}
+ children]))
+
+;; --- The choice of a conflict
+
+(def ^:private popover-width
+ "The width of the popover in pixels, as its stylesheet sets it: the
+ side it opens on is decided from it."
+ 240)
+
+(mf/defc conflict-popover*
+ "The choice of the conflict chosen, beside its layer: one property at a
+ time for a conflict that splits by property, the two texts for a text
+ conflict, the two versions otherwise. It opens after the layer, or
+ before it when the canvas has no room left there."
+ {::mf/private true}
+ [{:keys [comparison rect vbox vport zoom is-review can-preview]}]
+ (let [{:keys [item res attr branch incoming]} comparison
+ attr (brc/pending-attr item res attr)
+ text? (and (= attr :content) (brc/text-conflict? item))
+ branch-nm (:name branch)
+ room (- (:width vport)
+ (* (- (+ (:x rect) (:width rect)) (:x vbox)) zoom))
+ before? (< room (+ popover-width 16))
+ on-pick (mf/use-fn (mf/deps comparison) #(cc/pick-attr comparison %1 %2))
+ on-choose (mf/use-fn (mf/deps comparison) #(cc/choose-side comparison %))
+ on-preview (mf/use-fn #(st/emit! (dwcp/set-preview %)))]
+ [:div {:class (stl/css-case :popover true :is-before before?)
+ :role "dialog"
+ :aria-label (tr "workspace.branches.status.conflict")
+ ;; the canvas under it must not take its clicks
+ :on-pointer-down dom/stop-propagation
+ :on-click dom/stop-propagation}
+ [:> heading* {:level 3 :typography t/body-small :class (stl/css :popover-title)}
+ (if (some? attr)
+ (brc/attr-label attr)
+ (:label item))]
+ [:> text* {:as "p" :typography t/body-small :class (stl/css :popover-text)}
+ (cond
+ text? (tr "workspace.compare.popover.text")
+ (some? attr) (tr "workspace.compare.popover.attr")
+ :else (tr "workspace.branches.resolve.intro-whole"))]
+ (cond
+ text?
+ [:> brd/text-options* {:conflict item :res res
+ :branch-name branch-nm :is-review is-review
+ :on-pick on-pick
+ :on-preview on-preview}]
+
+ (some? attr)
+ [:> brd/attr-options* {:conflict item :res res :attr attr
+ :branch-name branch-nm :is-review is-review
+ :on-pick on-pick
+ :on-preview on-preview}]
+
+ :else
+ [:> brd/whole-options* {:conflict item :res res
+ :branch-name branch-nm :is-review is-review
+ :on-choose on-choose
+ :on-preview on-preview}])
+ [:> text* {:as "p" :typography t/body-small :class (stl/css :popover-text)}
+ (cond
+ can-preview (tr "workspace.compare.popover.hover")
+ incoming (tr "workspace.compare.popover.applies-update")
+ :else (tr "workspace.compare.popover.applies-merge"))]]))
+
+;; --- The bar that goes through the list
+
+(mf/defc compare-navigator*
+ {::mf/private true}
+ [{:keys [comparison can-peek is-review]}]
+ (let [{:keys [rows selected item phase res attr incoming resolutions]} comparison
+ resolving? (= phase :resolve)
+ index (or (first (keep-indexed (fn [idx row]
+ (when (= selected (dwcp/item-key row)) idx))
+ rows))
+ 0)
+ resolved? (and resolving? (some? item) (bm/conflict-resolved? item res))
+ all-done? (and resolving?
+ (every? #(bm/conflict-resolved? % (get resolutions (:id %))) rows))
+ cur-attr (when (and resolving? (some? item)) (brc/pending-attr item res attr))
+
+ on-previous (mf/use-fn (mf/deps comparison) #(cc/select-step comparison -1))
+ on-next (mf/use-fn (mf/deps comparison) #(cc/select-step comparison 1))
+ on-mark (mf/use-fn (mf/deps comparison) #(cc/mark-reviewed comparison))
+ on-pending (mf/use-fn (mf/deps comparison) #(cc/next-pending comparison))
+ on-clear (mf/use-fn (mf/deps comparison) #(cc/clear-choice comparison))
+
+ ;; the bar of the branch folds down to a strip, and this one
+ ;; goes down with it
+ bottom-bar (mf/deref refs/bottom-bar)
+ folded? (and (some? bottom-bar) (not= :branch bottom-bar))]
+ [:> rvo/navigator* {:class (stl/css :navigator)
+ :index index
+ :is-lowered folded?
+ :total (count rows)
+ ;; blue inside a review alone
+ :tone (cond
+ (and resolving? (not all-done?)) "warning"
+ (not is-review) "neutral")
+ :aria-label (if resolving?
+ (tr "workspace.compare.navigator.decisions")
+ (tr "workspace.compare.navigator.changes"))
+ :on-previous on-previous
+ :on-next on-next}
+ [:> rvo/navigator-text*
+ {:name (:label item)
+ :detail (when (some? item)
+ (cond
+ (and (not resolving?) incoming)
+ (tr "workspace.compare.navigator.in-main" (brc/change-summary item))
+
+ (and (not resolving?) can-peek)
+ (tr "workspace.compare.navigator.peek" (brc/change-summary item))
+
+ (not resolving?)
+ (brc/change-summary item)
+
+ (some? cur-attr)
+ (tr "workspace.branches.resolve.row.both-changed" (brc/attr-label cur-attr))
+
+ :else
+ (brc/conflict-reason-label (:reason item))))}]
+ [:> rvo/navigator-separator* {}]
+ (cond
+ (not resolving?)
+ [:> button* {:variant "ghost" :class (stl/css :navigator-action)
+ :disabled (nil? item) :on-click on-mark}
+ (tr "workspace.compare.navigator.mark-reviewed")]
+
+ (and resolved? all-done?)
+ [:> button* {:variant "ghost" :class (stl/css :navigator-action) :on-click on-clear}
+ (tr "workspace.branches.resolve.change-choice")]
+
+ :else
+ [:> button* {:variant "ghost" :class (stl/css :navigator-action) :on-click on-pending}
+ (tr "workspace.compare.navigator.next-pending")])]))
+
+;; --- The mode on the canvas
+
+(def ^:private next-key? (kbd/is-key-ignore-case? "j"))
+(def ^:private previous-key? (kbd/is-key-ignore-case? "k"))
+(def ^:private reviewed-key? (kbd/is-key-ignore-case? "r"))
+(def ^:private exclude-key? (kbd/is-key-ignore-case? "x"))
+(def ^:private peek-key? (kbd/is-key-ignore-case? "m"))
+(def ^:private align-key? (kbd/is-key-ignore-case? "a"))
+
+(defn- fit-key?
+ "The key 2, whatever character it types with shift held."
+ [event]
+ (contains? #{"Digit2" "Numpad2"} (.-code ^js event)))
+
+(defn- typing?
+ "Whether a key `event` belongs to a field the user writes in."
+ [event]
+ (let [target (dom/get-target event)]
+ (or (contains? #{"INPUT" "TEXTAREA" "SELECT"} (dom/get-tag-name target))
+ (dom/is-content-editable? target))))
+
+(defn- use-shortcuts
+ "The keys of the compare mode: Escape leaves it (or goes back from the
+ conflicts to the changes), J and K go to the next and the previous
+ row, R marks the change as reviewed, X leaves it out or takes it back
+ in, M shows main for as long as it is held, and A lines main up with
+ the change chosen, or links it again, while it is beside the branch.
+ A dialog, a field or a tool in use keeps its own keys."
+ [comparison]
+ (let [comparison* (mf/use-ref comparison)]
+ (mf/set-ref-val! comparison* comparison)
+ (mf/with-effect []
+ (let [on-key
+ (fn [event]
+ (let [comparison (mf/ref-val comparison*)
+ state @st/state
+ resolving? (= :resolve (:phase comparison))]
+ (when-not (or (typing? event)
+ (kbd/mod? event)
+ (kbd/alt? event)
+ (some? (::modal/modal state))
+ (some? (get-in state [:workspace-drawing :tool])))
+ (cond
+ (kbd/esc? event)
+ (st/emit! (if resolving? (dwcp/back-to-compare) (dwcp/exit)))
+
+ ;; the layer chosen is not selected: the key that
+ ;; zooms to the selection zooms to it
+ (and (fit-key? event) (kbd/shift? event))
+ (st/emit! (dwcp/fit-selected))
+
+ (kbd/shift? event)
+ nil
+
+ (next-key? event) (cc/select-step comparison 1)
+ (previous-key? event) (cc/select-step comparison -1)
+
+ (and (reviewed-key? event) (not resolving?))
+ (cc/mark-reviewed comparison)
+
+ (and (exclude-key? event) (not resolving?))
+ (cc/toggle-excluded comparison)
+
+ (and (peek-key? event) (not resolving?) (not (.-repeat ^js event)))
+ (st/emit! (dwcp/set-peek true))
+
+ (and (align-key? event) (not (.-repeat ^js event)))
+ (st/emit! (dwcp/toggle-side-mode))))))
+
+ on-key-up
+ (fn [event]
+ (when (peek-key? event)
+ (st/emit! (dwcp/set-peek false))))]
+ (.addEventListener js/document "keydown" on-key)
+ (.addEventListener js/document "keyup" on-key-up)
+ (fn []
+ (.removeEventListener js/document "keydown" on-key)
+ (.removeEventListener js/document "keyup" on-key-up))))))
+
+(defn- use-canvas-projection
+ "Draw the layers of `projected` that differ from `objects` (the page as
+ the open file has it) on the canvas, and the ones of `objects` again
+ when the projection changes or ends. Only the render hears of it: the
+ file in the store is never touched. A layer the projection lacks goes
+ with the children of its parent, and one only the projection has
+ comes with them."
+ [objects projected]
+ (mf/with-effect [objects projected]
+ (when (and (some? projected) (wasm.api/initialized?))
+ (let [ids (into []
+ (filter #(not (identical? (get objects %) (get projected %))))
+ (distinct (concat (keys projected) (keys objects))))]
+ (wasm.api/process-objects (into [] (keep #(get projected %)) ids))
+ (wasm.api/request-render "compare-projection")
+ (fn []
+ (when (wasm.api/initialized?)
+ (wasm.api/process-objects (into [] (keep #(get objects %)) ids))
+ (wasm.api/request-render "compare-projection")))))))
+
+(mf/defc compare-overlays*
+ [{:keys [vbox vport zoom page-id show-rulers hover-ids]}]
+ (let [comparison (cc/use-comparison)
+ objects (mf/deref refs/workspace-page-objects)
+ review? (some? (mf/deref refs/pull-request-preview))
+
+ {:keys [mode phase status incoming selected hovered item rows model
+ conflicts excluded resolutions data res attr]} comparison
+ resolving? (= phase :resolve)
+ hidden? (:hidden mode)
+ loaded? (= status :loaded)
+ direction (if incoming :main->branch :branch->main)
+ total (get-in model [:counts :all])
+ other-dir (if incoming :branch->main :main->branch)
+ ;; the changes of the other direction come with every diff, so
+ ;; its tab can count them before it is shown
+ other-total (mf/with-memo [(:other-changes mode) (:other-conflicts mode) data]
+ (when (some? (:other-changes mode))
+ (-> (brc/change-model {:changes (:other-changes mode)
+ :conflicts (:other-conflicts mode)}
+ {:filter :all
+ :pages-index (:pages-index data)
+ :pages (:pages data)})
+ (get-in [:counts :all]))))
+ first-key (some-> (first rows) dwcp/item-key)
+ ;; the entry of the layer under the pointer, while the canvas
+ ;; answers for the layers with a change (`hover-ids`)
+ pointed (mf/with-memo [rows objects hover-ids]
+ (cc/layer-entry rows objects hover-ids))
+
+ ;; only the WASM render can draw a page the file does not hold
+ wasm? (features/use-feature "render-wasm/v1")
+ ;; from what it reads alone: the comparison is put together on
+ ;; every render, and each projection is drawn again by the render
+ projection (mf/with-memo [wasm? objects page-id phase incoming model conflicts
+ resolutions excluded item res attr
+ hidden? (:preview mode) (:peek mode) (:other-changes mode)]
+ (when wasm?
+ (cc/canvas-objects comparison objects page-id)))
+ live objects
+ side? (and wasm? (= :side (:view mode)))
+ aligned? (and side? (= :aligned (:side-mode mode)))
+ objects (or (:objects projection) objects)
+ ;; kept the same between renders: the side view takes its pictures
+ ;; of main again when they change
+ page-items (mf/with-memo [model page-id]
+ (filterv #(= page-id (:page-id %)) (:items model)))
+ main (mf/with-memo [side? live page-id page-items (:other-changes mode) incoming]
+ (when side?
+ (cc/main-objects live page-id page-items (:other-changes mode) incoming)))
+ ;; from the page as the canvas shows it: while it shows main
+ ;; (`:peek`) both halves hold the same place and nothing moves
+ extent (mf/with-memo [main]
+ (when (some? main)
+ (cc/main-extent main)))
+ offset (mf/with-memo [aligned? objects main item]
+ (when aligned?
+ (cc/align-offset objects main item)))
+
+ ;; every change is marked until one is chosen; then its mark
+ ;; stands alone, with the layers that use it when it is an asset
+ marks
+ (mf/with-memo [resolving? model conflicts resolutions excluded item objects page-id data selected hovered]
+ (cc/chosen-marks
+ selected
+ hovered
+ (if resolving?
+ (brc/change-marks (:conflicts conflicts)
+ {:page-id page-id
+ :objects objects
+ :status-of #(if (bm/conflict-resolved? % (get resolutions (:id %)))
+ :decided
+ :conflict)})
+ (cond-> (brc/change-marks (:listed model)
+ {:page-id page-id
+ :objects objects
+ :excluded excluded})
+ (and (some? item) (= :library (brc/scope item)))
+ (into (brc/usage-marks data item page-id))))))]
+
+ (use-shortcuts comparison)
+
+ (mf/with-effect [pointed]
+ (st/emit! (dwcp/set-hovered pointed :canvas)))
+ (use-canvas-projection live (:objects projection))
+
+ ;; fitting the whole page takes in main beside the branch
+ (mf/with-effect [extent]
+ (st/emit! (dwcp/set-main-extent extent)))
+
+ ;; each direction remembers how many changes it lists, for its tab
+ (mf/with-effect [loaded? direction total]
+ (when (and loaded? (not resolving?))
+ (st/emit! (dwcp/set-count direction total))))
+
+ (mf/with-effect [other-dir other-total]
+ (when (and (some? other-total) (not resolving?))
+ (st/emit! (dwcp/set-count other-dir other-total))))
+
+ ;; the edits one side made alone are not in doubt: they are filled in
+ ;; from that side, so only the conflicting properties wait
+ (mf/with-effect [resolving? (:conflicts conflicts)]
+ (when resolving?
+ (let [seed (brc/prefill-resolutions (:conflicts conflicts) resolutions)]
+ (when (seq seed)
+ (st/emit! (dwb/set-conflict-resolutions seed))))))
+
+ ;; a list opens on its first row, with the canvas on its layer. Only
+ ;; when the list changes: a row the user lets go stays let go, and
+ ;; the canvas marks every change again
+ (mf/with-effect [resolving? first-key]
+ (when (and (nil? selected) (some? first-key))
+ (st/emit! (dwcp/select first-key))))
+
+ [:div {:class (stl/css :overlays)
+ :style #js {:width (dm/str (:width vport) "px")
+ :height (dm/str (:height vport) "px")}}
+ (when-not hidden?
+ [:div {:class (stl/css :marks)
+ :style (rvo/viewbox-offset vbox zoom)}
+ (for [mark marks
+ :let [active? (or (= selected (:key mark))
+ (= hovered (:key mark)))]]
+ [:> mark* {:key (:key mark)
+ :mark mark
+ :zoom zoom
+ :is-active active?}
+ (when (and active? resolving? (some? item))
+ [:> conflict-popover* {:comparison comparison
+ :rect (:rect mark)
+ :vbox vbox
+ :vport vport
+ :zoom zoom
+ :is-review review?
+ :can-preview wasm?}])])])
+ ;; main beside the branch, over the first half of the canvas
+ (when side?
+ [:> side-view* {:comparison comparison
+ :objects live
+ :canvas objects
+ :main main
+ :offset offset
+ :items page-items
+ :listed (if resolving? (:conflicts conflicts) (:listed model))
+ :page-id page-id
+ :background (get-in data [:pages-index page-id :background])
+ :vbox vbox
+ :vport vport
+ :zoom zoom
+ :show-rulers show-rulers}])
+ [:div {:class (stl/css :notes)}
+ (when (some? projection)
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :note)}
+ (case (:kind projection)
+ :update (tr "workspace.compare.canvas.update" (get-in comparison [:branch :name]))
+ :result (tr "workspace.compare.canvas.result")
+ :main (tr "workspace.compare.canvas.main"))])
+ (when side?
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :note)}
+ (cond
+ (not aligned?)
+ (tr "workspace.compare.side.linked")
+
+ (some? offset)
+ (tr "workspace.compare.side.aligned"
+ (str (mth/round (:x offset)))
+ (str (mth/round (:y offset))))
+
+ :else
+ (tr "workspace.compare.side.aligned-none"))])]
+ ;; the bar goes through the list from the entry chosen: with none
+ ;; chosen the canvas marks them all and the bar has nothing to say
+ (when (some? item)
+ [:> compare-navigator* {:comparison comparison
+ :can-peek wasm?
+ :is-review review?}])]))
diff --git a/frontend/src/app/main/ui/workspace/compare/overlays.scss b/frontend/src/app/main/ui/workspace/compare/overlays.scss
new file mode 100644
index 0000000000..25aad514f7
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/compare/overlays.scss
@@ -0,0 +1,87 @@
+// 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) KALEIDOS SUBSIDIARY SL
+
+@use "ds/_borders.scss" as *;
+@use "ds/_utils.scss" as *;
+
+.overlays {
+ position: absolute;
+ inset-block-start: 0;
+ inset-inline-start: 0;
+ overflow: hidden;
+ pointer-events: none;
+}
+
+.marks {
+ position: absolute;
+}
+
+// beside the layer in conflict, after it; before it (`is-before`) when
+// the canvas has no room left there. Its width is `popover-width`
+.popover {
+ position: absolute;
+ inset-block-start: 0;
+ inset-inline-start: calc(100% + var(--sp-s));
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+ inline-size: px2rem(240);
+ padding: var(--sp-m);
+ border: $b-1 solid var(--color-accent-warning);
+ border-radius: $br-8;
+ background-color: var(--color-background-primary);
+ pointer-events: auto;
+
+ &.is-before {
+ inset-inline: auto calc(100% + var(--sp-s));
+ }
+}
+
+.popover-title {
+ margin: 0;
+ color: var(--color-foreground-primary);
+}
+
+.popover-text {
+ margin: 0;
+ color: var(--color-foreground-secondary);
+}
+
+// what the canvas says of itself, under the toolbar at the top center
+// of the canvas: what it shows when it is not the branch as it is, and
+// how main stands beside the branch
+.notes {
+ position: absolute;
+ inset-block-start: px2rem(96);
+ inset-inline-start: 50%;
+ transform: translateX(-50%);
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: var(--sp-xs);
+}
+
+.note {
+ padding: var(--sp-xxs) var(--sp-s);
+ border-radius: $br-4;
+ background-color: var(--color-background-quaternary);
+ color: var(--color-foreground-primary);
+ white-space: nowrap;
+}
+
+// the bar that goes through the list keeps one width, whatever the entry
+// says: its arrows and its action stay where they are from one entry to
+// the next, and the text is cut short when it does not fit
+.navigator {
+ --navigator-count-size: 7ch;
+
+ inline-size: px2rem(640);
+}
+
+.navigator-action {
+ flex-shrink: 0;
+ white-space: nowrap;
+}
diff --git a/frontend/src/app/main/ui/workspace/compare/side.cljs b/frontend/src/app/main/ui/workspace/compare/side.cljs
new file mode 100644
index 0000000000..c54320ad0d
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/compare/side.cljs
@@ -0,0 +1,174 @@
+;; 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) KALEIDOS SUBSIDIARY SL
+
+(ns app.main.ui.workspace.compare.side
+ "The side by side view of the compare mode: main on the first half of
+ the canvas, the branch on the second one. The branch is the canvas
+ itself; main is a picture of each board with changes, drawn off screen
+ by the same render and placed over the first half so that both halves
+ show the same spot. Both follow the one viewport, so zoom and pan are
+ linked; lined up with the change chosen (`:side-mode :aligned`), main
+ is moved by how far that layer moved."
+ (:require-macros [app.main.style :as stl])
+ (:require
+ [app.common.colors :as clr]
+ [app.common.data.macros :as dm]
+ [app.main.ui.ds.product.branch-pill :refer [branch-pill*]]
+ [app.main.ui.workspace.compare.common :as cc]
+ [app.main.ui.workspace.review.overlays :as rvo]
+ [app.main.ui.workspace.sidebar.branch-review.common :as brc]
+ [app.main.ui.workspace.viewport.rulers :as rulers]
+ [app.render-wasm.api :as wasm.api]
+ [app.util.i18n :refer [tr]]
+ [app.util.timers :as ts]
+ [app.util.webapi :as wapi]
+ [rumext.v2 :as mf]))
+
+(def ^:private max-scale
+ "The most a picture of main is enlarged when it is drawn; past it, the
+ browser scales the picture."
+ 4)
+
+(defn picture-roots
+ "The ids of the layers of main to take a picture of: the top board of
+ each entry of `items` (the layer itself outside any board), as
+ `main` (the page as main has it) holds it, or as `objects` (the open
+ branch) does for a layer main lacks. Only the ones main has."
+ [items main objects]
+ (into []
+ (comp (filter #(= :shape (:kind %)))
+ (keep (fn [{:keys [id]}]
+ (:id (or (brc/top-board main id)
+ (get main id)
+ (brc/top-board objects id)))))
+ (filter #(contains? main %))
+ (distinct))
+ items))
+
+(defn- changed-ids
+ [from to]
+ (into []
+ (filter #(not (identical? (get from %) (get to %))))
+ (distinct (concat (keys from) (keys to)))))
+
+(defn- take-pictures
+ "Draw each layer of `roots` as `main` has it, off screen, and answer
+ `{:id :rect :uri}` for each one that drew. The render holds `canvas`
+ (the page as the canvas shows it): main goes in for as long as the
+ pictures take and `canvas` comes back before anything reaches the
+ screen."
+ [canvas main roots scale]
+ (when (wasm.api/initialized?)
+ (let [ids (changed-ids canvas main)]
+ (wasm.api/process-objects (into [] (keep #(get main %)) ids))
+ (let [pictures
+ (into []
+ (keep (fn [id]
+ (let [rect (or (wasm.api/get-shape-extrect id)
+ (dm/get-in main [id :selrect]))
+ bytes (wasm.api/render-shape-pixels id scale :png false)]
+ (when (and (some? rect) (some? bytes) (pos? (.-length ^js bytes)))
+ {:id id
+ :rect (select-keys rect [:x :y :width :height])
+ :uri (wapi/create-uri (wapi/create-blob bytes "image/png"))}))))
+ roots)]
+ (wasm.api/process-objects (into [] (keep #(get canvas %)) ids))
+ (wasm.api/request-render "compare-side")
+ pictures))))
+
+(defn layer-translate
+ "Where the layer of main goes, in pixels: the spot of the page the
+ second half shows, half a viewport (`half`) back and after the rulers
+ (`edge`)."
+ [vbox zoom half edge]
+ {:x (- (* (- (:x vbox)) zoom) half edge)
+ :y (- (* (- (:y vbox)) zoom) edge)})
+
+(defn- use-settled
+ "`value`, once it has stayed the same for `ms` milliseconds."
+ [value ms]
+ (let [settled* (mf/use-state value)]
+ (mf/with-effect [value]
+ (let [timer (ts/schedule ms #(reset! settled* value))]
+ #(ts/dispose! timer)))
+ (deref settled*)))
+
+(mf/defc side-view*
+ "`objects` is the page as the open branch has it, `canvas` as the
+ canvas shows it and `main` as main has it (`cc/main-objects`); `items`
+ are the entries of the comparison on the page and `listed` the ones
+ its list shows, which are the ones marked. Main is moved by `offset`
+ (`cc/align-offset`, nil for none). The rulers are drawn on the canvas,
+ so main starts after them (`show-rulers`)."
+ [{:keys [comparison objects canvas main offset items listed page-id background vbox vport zoom show-rulers]}]
+ (let [{:keys [excluded selected hovered branch mode]} comparison
+ half (/ (:width vport) 2)
+ edge (if show-rulers rulers/ruler-area-size 0)
+ place (layer-translate vbox zoom half edge)
+ ;; main slides to the change chosen for a moment after it is
+ ;; chosen, and follows pan and zoom at once the rest of the time
+ sliding (not= selected (use-settled selected 250))
+ roots (mf/with-memo [items main objects]
+ (picture-roots items main objects))
+ ;; the pictures are drawn again once the zoom rests, sharp at it
+ scale (use-settled (min max-scale (max 1 (* zoom (or (.-devicePixelRatio js/window) 1)))) 250)
+ pictures* (mf/use-state [])
+ pictures (deref pictures*)
+ ;; a layer main lacks leaves a gap where the branch has it
+ marks (mf/with-memo [listed main excluded page-id selected hovered]
+ (cc/chosen-marks
+ selected
+ hovered
+ (brc/change-marks listed {:page-id page-id
+ :objects main
+ :excluded excluded
+ :status-of #(if (contains? main (:id %))
+ :present
+ :missing)})))]
+
+ (mf/with-effect [canvas main roots scale]
+ (let [taken (take-pictures canvas main roots scale)]
+ (reset! pictures* (or taken []))
+ (fn []
+ (run! #(wapi/revoke-uri (:uri %)) taken))))
+
+ [:*
+ [:div {:class (stl/css :main-half)
+ :style #js {:top (dm/str edge "px")
+ :left (dm/str edge "px")
+ :width (dm/str (- half edge) "px")
+ :backgroundColor (or background clr/canvas)}}
+ [:div {:class (stl/css :layer)
+ :style #js {:transform (dm/fmt "translate(%px, %px)" (:x place) (:y place))}}
+ ;; moved by how far the change chosen moved (`offset`)
+ [:div {:class (stl/css-case :layer true :is-sliding sliding)
+ :style #js {:transform (dm/fmt "translate(%px, %px)"
+ (* (:x offset 0) zoom)
+ (* (:y offset 0) zoom))}}
+ (for [{:keys [id rect uri]} pictures]
+ [:img {:key (str id)
+ :class (stl/css :picture)
+ :alt ""
+ :src uri
+ :style (rvo/screen-rect rect zoom)}])
+ (when-not (:hidden mode)
+ (for [mark marks
+ :let [missing? (= :missing (:status mark))]]
+ [:> rvo/change-box* {:key (:key mark)
+ :rect (:rect mark)
+ :zoom zoom
+ :tone (when missing? "warning")
+ :class (stl/css-case :is-missing missing?)
+ :label (cond
+ missing? (tr "workspace.compare.side.not-in-main")
+ (= selected (:key mark)) (:label mark)
+ :else nil)
+ :is-active (and (not missing?) (= selected (:key mark)))}]))]]
+ [:span {:class (stl/css :label)}
+ [:> branch-pill* {:label (tr "workspace.branches.main") :is-main true}]]]
+ [:span {:class (stl/css :label :is-branch)
+ :style #js {:top (dm/str edge "px")}}
+ [:> branch-pill* {:label (or (:name branch) "")}]]]))
diff --git a/frontend/src/app/main/ui/workspace/compare/side.scss b/frontend/src/app/main/ui/workspace/compare/side.scss
new file mode 100644
index 0000000000..f8c47ab918
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/compare/side.scss
@@ -0,0 +1,66 @@
+// 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) KALEIDOS SUBSIDIARY SL
+
+@use "ds/_borders.scss" as *;
+
+// main covers the first half of the canvas, after the rulers; its edge
+// is the divider
+.main-half {
+ position: absolute;
+ inset-block-end: 0;
+ overflow: hidden;
+ border-inline-end: $b-2 solid var(--color-background-quaternary);
+ border-start-start-radius: $br-12;
+ border-end-start-radius: $br-12;
+
+ // the frame of the canvas (`rulers/viewport-frame*`) is drawn under
+ // this half: it is drawn again on top, with its rounded corners. Over
+ // the pictures, and not as a border, which would move them
+ &::after {
+ content: "";
+ position: absolute;
+ inset: 0;
+ border: $b-2 solid var(--color-background-quaternary);
+ border-inline-end: none;
+ border-start-start-radius: $br-12;
+ border-end-start-radius: $br-12;
+ pointer-events: none;
+ }
+}
+
+.layer {
+ position: absolute;
+
+ // main slides to the change chosen; pan and zoom never wait for it
+ &.is-sliding {
+ @media (prefers-reduced-motion: no-preference) {
+ transition: transform 0.2s ease-out;
+ }
+ }
+}
+
+.picture {
+ position: absolute;
+ max-inline-size: none;
+}
+
+// a layer the branch has and main lacks: the place it would take
+.is-missing {
+ border-style: dashed;
+}
+
+// each half says whose it is at its outer top corner: main at the start
+// of its half, the branch at the end of the canvas
+.label {
+ position: absolute;
+ inset-block-start: 0;
+ inset-inline-start: 0;
+ margin: var(--sp-m);
+
+ &.is-branch {
+ inset-inline: auto 0;
+ }
+}
diff --git a/frontend/src/app/main/ui/workspace/compare/view_menu.cljs b/frontend/src/app/main/ui/workspace/compare/view_menu.cljs
new file mode 100644
index 0000000000..d6f118adf7
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/compare/view_menu.cljs
@@ -0,0 +1,96 @@
+;; 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) KALEIDOS SUBSIDIARY SL
+
+(ns app.main.ui.workspace.compare.view-menu
+ "The control of the compare toolbar that says how the canvas shows the
+ changes, and the menu that picks another way or hides them."
+ (:require-macros [app.main.style :as stl])
+ (:require
+ [app.main.data.workspace.compare :as dwcp]
+ [app.main.features :as features]
+ [app.main.store :as st]
+ [app.main.ui.ds.foundations.assets.icon :as i]
+ [app.main.ui.ds.foundations.typography :as t]
+ [app.main.ui.ds.foundations.typography.text :refer [text*]]
+ [app.main.ui.ds.layout.menu :refer [menu* menu-item* menu-separator* sub-menu*]]
+ [app.util.i18n :refer [tr]]
+ [rumext.v2 :as mf]))
+
+(defn- on-action
+ [action]
+ (case action
+ "highlight" (st/emit! (dwcp/set-view :highlight))
+ "side-linked" (st/emit! (dwcp/set-view :side) (dwcp/set-side-mode :linked))
+ "side-aligned" (st/emit! (dwcp/set-view :side) (dwcp/set-side-mode :aligned))
+ "hide" (st/emit! (dwcp/toggle-hidden))
+ nil))
+
+(mf/defc view-item*
+ "The label of a view in the menu, ticked when it is the one in use."
+ {::mf/private true}
+ [{:keys [label is-selected]}]
+ [:span {:class (stl/css-case :item true :is-selected is-selected)}
+ [:span {:class (stl/css :item-label)} label]
+ (when is-selected
+ [:> i/icon* {:icon-id i/tick :size "s"}])])
+
+(mf/defc view-mode-menu*
+ "`view` is the view in use, `side-mode` how the side by side view
+ places main and `hidden` says the changes are hidden. Inside a design
+ review (`is-review`) the control takes the colour of the review."
+ [{:keys [view side-mode hidden is-review]}]
+ (let [open* (mf/use-state false)
+ open? (deref open*)
+ on-toggle (mf/use-fn #(swap! open* not))
+ on-change (mf/use-fn #(reset! open* %))
+ ;; main beside the branch is drawn by the WASM render alone
+ wasm? (features/use-feature "render-wasm/v1")
+ side? (and wasm? (= view :side) (not hidden))
+ aligned? (= side-mode :aligned)
+ highlight (tr "workspace.compare.view.highlight")
+ side (tr "workspace.branches.review.view.side")
+ linked (tr "workspace.compare.view.side.linked")
+ lined-up (tr "workspace.compare.view.side.aligned")
+ ;; the mode of the side view is told by the note on the canvas
+ current (if (and wasm? (= view :side)) side highlight)]
+ [:> menu* {:is-open open?
+ :on-open-change on-change
+ :on-action on-action
+ :placement "bottom start"
+ :trigger
+ (mf/html
+ [:button {:class (stl/css-case :trigger true
+ :is-hidden hidden
+ :is-review is-review)
+ :aria-label (tr "workspace.compare.view.label")
+ :aria-expanded open?
+ :on-click on-toggle}
+ [:> i/icon* {:icon-id (if hidden i/hide i/shown) :size "s"}]
+ [:> text* {:as "span" :typography t/body-small}
+ (if hidden
+ (tr "workspace.compare.view.hidden")
+ current)]
+ [:> i/icon* {:icon-id i/arrow-down :size "s"}]])}
+ [:> menu-item* {:id "highlight" :text-value highlight}
+ [:> view-item* {:label highlight
+ :is-selected (and (= view :highlight) (not hidden))}]]
+ ;; the two ways main stands beside the branch
+ [:> sub-menu* {:id "side"
+ :text-value side
+ :trigger side
+ :is-disabled (not wasm?)
+ :on-action on-action}
+ [:> menu-item* {:id "side-linked" :text-value linked}
+ [:> view-item* {:label linked
+ :is-selected (and side? (not aligned?))}]]
+ [:> menu-item* {:id "side-aligned" :text-value lined-up}
+ [:> view-item* {:label lined-up
+ :is-selected (and side? aligned?)}]]]
+ [:> menu-separator* {}]
+ [:> menu-item* {:id "hide"}
+ (if hidden
+ (tr "workspace.compare.view.show")
+ (tr "workspace.compare.view.hide"))]]))
diff --git a/frontend/src/app/main/ui/workspace/compare/view_menu.scss b/frontend/src/app/main/ui/workspace/compare/view_menu.scss
new file mode 100644
index 0000000000..5839e9057e
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/compare/view_menu.scss
@@ -0,0 +1,57 @@
+// 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) KALEIDOS SUBSIDIARY SL
+
+@use "ds/_borders.scss" as *;
+@use "ds/_sizes.scss" as *;
+
+// the active element of the toolbar: the accent of the drawing tools on a
+// branch, the blue of the review inside a design review
+.trigger {
+ --trigger-bg-color: var(--color-background-quaternary);
+ --trigger-fg-color: var(--color-accent-primary);
+
+ display: flex;
+ align-items: center;
+ gap: var(--sp-xs);
+ block-size: $sz-32;
+ padding-inline: var(--sp-s);
+ border: none;
+ border-radius: $br-8;
+ background-color: var(--trigger-bg-color);
+ color: var(--trigger-fg-color);
+ white-space: nowrap;
+ cursor: pointer;
+
+ &.is-review {
+ --trigger-bg-color: var(--color-background-info);
+ --trigger-fg-color: var(--color-accent-info);
+ }
+
+ &.is-hidden {
+ --trigger-bg-color: transparent;
+ --trigger-fg-color: var(--color-foreground-secondary);
+ }
+
+ &:focus-visible {
+ outline: $b-1 solid var(--color-accent-primary);
+ }
+}
+
+.item {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--sp-l);
+ inline-size: 100%;
+
+ &.is-selected {
+ color: var(--color-accent-primary);
+ }
+}
+
+.item-label {
+ flex: 1;
+}
diff --git a/frontend/src/app/main/ui/workspace/review/details.cljs b/frontend/src/app/main/ui/workspace/review/details.cljs
index d2902ed878..94637da102 100644
--- a/frontend/src/app/main/ui/workspace/review/details.cljs
+++ b/frontend/src/app/main/ui/workspace/review/details.cljs
@@ -40,10 +40,10 @@
[app.main.ui.ds.product.task-status :refer [task-status*]]
[app.main.ui.hooks :as hooks]
[app.main.ui.workspace.review.common :as rvc]
+ [app.main.ui.workspace.review.shape-preview :refer [shape-preview*]]
[app.main.ui.workspace.review.tasks :as rvt]
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
[app.main.ui.workspace.sidebar.branch-review.layout :as brl]
- [app.main.ui.workspace.sidebar.branch-review.previews :as brp]
[app.main.ui.workspace.sidebar.pull-requests :as prui :refer [pr-state-badge* dialog-header*]]
[app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]]
@@ -331,7 +331,7 @@
[:> tag* {:tone (kind-tone (:kind entry))} (rvc/change-kind-label (:kind entry))]]
[:div {:class (stl/css :change-card-preview)}
(if (and (some? shape) (not= :deleted (:kind entry)))
- [:> brp/shape-preview* {:shape shape :objects objects}]
+ [:> shape-preview* {:shape shape :objects objects}]
[:div {:class (stl/css :deleted-preview)}])]
(when (seq attrs)
[:dl {:class (stl/css :attrs)}
diff --git a/frontend/src/app/main/ui/workspace/review/filter_menu.cljs b/frontend/src/app/main/ui/workspace/review/filter_menu.cljs
index 74f843c7d4..89d16d11dc 100644
--- a/frontend/src/app/main/ui/workspace/review/filter_menu.cljs
+++ b/frontend/src/app/main/ui/workspace/review/filter_menu.cljs
@@ -5,28 +5,29 @@
;; Copyright (c) KALEIDOS SUBSIDIARY SL
(ns app.main.ui.workspace.review.filter-menu
- "The dropdown that picks which comments or tasks a list shows."
+ "The menu that picks which comments or tasks a list shows."
(:require-macros [app.main.style :as stl])
(:require
[app.common.data :as d]
- [app.main.ui.components.dropdown :refer [dropdown]]
[app.main.ui.ds.foundations.assets.icon :refer [icon*] :as i]
[app.main.ui.ds.foundations.typography :as t]
[app.main.ui.ds.foundations.typography.text :refer [text*]]
- [app.util.dom :as dom]
+ [app.main.ui.ds.layout.menu :refer [menu* menu-item* menu-separator*]]
[rumext.v2 :as mf]))
-(mf/defc menu-item*
+(def ^:private toggle-id
+ "The id of the item that turns `toggle-label` on or off; the options
+ use the names of their ids."
+ "__toggle")
+
+(mf/defc item-content*
+ "The label of an item, with a tick when it is in use."
{::mf/private true}
- [{:keys [label id is-selected on-click]}]
- [:li
- [:button {:class (stl/css-case :item true
- :is-selected is-selected)
- :type "button"
- :data-id id
- :on-click on-click}
- [:> text* {:as "span" :typography t/body-small :class (stl/css :item-label)} label]
- [:> icon* {:icon-id i/tick :size "s" :class (stl/css :item-tick)}]]])
+ [{:keys [label is-selected]}]
+ [:span {:class (stl/css-case :item true :is-selected is-selected)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :item-label)} label]
+ (when is-selected
+ [:> icon* {:icon-id i/tick :size "s" :class (stl/css :item-tick)}])])
(mf/defc filter-menu*
"A button naming the view of a list that opens the views to pick from
@@ -37,41 +38,38 @@
open? (deref open*)
current (d/seek #(= selected (:id %)) options)
- on-trigger
- (mf/use-fn
- (fn [event]
- (dom/stop-propagation event)
- (swap! open* not)))
+ on-trigger (mf/use-fn #(swap! open* not))
+ on-change (mf/use-fn #(reset! open* %))
- on-close (mf/use-fn #(reset! open* false))
-
- on-item
+ on-action
(mf/use-fn
- (mf/deps on-select)
- (fn [event]
- (on-select (-> (dom/get-current-target event)
- (dom/get-data "id")
- (keyword)))))]
+ (mf/deps on-select on-toggle)
+ (fn [action]
+ (if (= toggle-id action)
+ (on-toggle)
+ (on-select (keyword action)))))]
[:div {:class (stl/css :filter-menu)}
- [:button {:class (stl/css :trigger)
- :type "button"
- :aria-haspopup "menu"
- :aria-expanded open?
- :on-click on-trigger}
- [:> text* {:as "span" :typography t/body-small :class (stl/css :trigger-label)}
- (:label current)]
- [:> icon* {:icon-id i/arrow-down :size "s" :class (stl/css :trigger-icon)}]]
-
- [:& dropdown {:show open? :on-close on-close}
- [:ul {:class (stl/css :menu)}
- (for [{:keys [id label]} options]
- [:> menu-item* {:key (name id)
- :id (name id)
- :label label
- :is-selected (= selected id)
- :on-click on-item}])
- [:li {:class (stl/css :separator) :role "separator"}]
- [:> menu-item* {:label toggle-label
- :is-selected is-toggled
- :on-click on-toggle}]]]]))
+ [:> menu* {:is-open open?
+ :on-open-change on-change
+ :on-action on-action
+ :placement "bottom start"
+ ;; as wide as the button that opens it (`.menu`)
+ :max-width "none"
+ :class (stl/css :menu)
+ :trigger
+ (mf/html
+ [:button {:class (stl/css :trigger)
+ :type "button"
+ :aria-haspopup "menu"
+ :aria-expanded open?
+ :on-click on-trigger}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :trigger-label)}
+ (:label current)]
+ [:> icon* {:icon-id i/arrow-down :size "s" :class (stl/css :trigger-icon)}]])}
+ (for [{:keys [id label]} options]
+ [:> menu-item* {:key (name id) :id (name id) :text-value label}
+ [:> item-content* {:label label :is-selected (= selected id)}]])
+ [:> menu-separator* {}]
+ [:> menu-item* {:id toggle-id :text-value toggle-label}
+ [:> item-content* {:label toggle-label :is-selected (boolean is-toggled)}]]]]))
diff --git a/frontend/src/app/main/ui/workspace/review/filter_menu.scss b/frontend/src/app/main/ui/workspace/review/filter_menu.scss
index c7d834dd01..58f5a2d34b 100644
--- a/frontend/src/app/main/ui/workspace/review/filter_menu.scss
+++ b/frontend/src/app/main/ui/workspace/review/filter_menu.scss
@@ -6,10 +6,16 @@
@use "ds/_borders.scss" as *;
@use "ds/_sizes.scss" as *;
-@use "ds/_utils.scss" as *;
+// the button spans the list. The DS menu wraps it in a div with no class
+// to reach, and that div sizes to its content: it has to grow
.filter-menu {
- position: relative;
+ display: flex;
+
+ > div {
+ flex-grow: 1;
+ min-inline-size: 0;
+ }
}
.trigger {
@@ -42,51 +48,18 @@
color: var(--color-foreground-secondary);
}
+// the DS menu takes the width of the button that opens it: react-aria
+// sets --trigger-width on its popover
.menu {
- position: absolute;
- inset-block-start: calc($sz-32 + $b-1);
- inset-inline-start: 0;
- z-index: var(--z-index-dropdown);
- inline-size: 100%;
- max-block-size: px2rem(300);
- margin: 0;
- padding: $b-2;
- overflow: hidden auto;
- border: $b-2 solid var(--color-background-quaternary);
- border-radius: $br-8;
- background-color: var(--color-background-tertiary);
- box-shadow: 0 0 px2rem(12) 0 var(--color-shadow-dark);
- list-style: none;
+ inline-size: var(--trigger-width);
}
.item {
- --item-bg-color: transparent;
- --item-fg-color: var(--color-foreground-secondary);
- --item-tick-color: transparent;
-
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--sp-s);
inline-size: 100%;
- block-size: $sz-32;
- padding: 0 var(--sp-s);
- border: none;
- border-radius: $br-6;
- background-color: var(--item-bg-color);
- color: var(--item-fg-color);
- text-align: start;
- cursor: pointer;
-
- &:hover {
- --item-bg-color: var(--color-background-quaternary);
- --item-fg-color: var(--color-foreground-primary);
- }
-
- &.is-selected {
- --item-fg-color: var(--color-foreground-primary);
- --item-tick-color: var(--color-foreground-primary);
- }
}
.item-label {
@@ -95,11 +68,4 @@
.item-tick {
flex-shrink: 0;
- color: var(--item-tick-color);
-}
-
-.separator {
- margin-block: var(--sp-xs);
- margin-inline: calc(-1 * var(--sp-xxs));
- border-block-start: $b-1 solid var(--color-background-quaternary);
}
diff --git a/frontend/src/app/main/ui/workspace/review/overlays.cljs b/frontend/src/app/main/ui/workspace/review/overlays.cljs
index 24f1da1a0e..2ec1212cd7 100644
--- a/frontend/src/app/main/ui/workspace/review/overlays.cljs
+++ b/frontend/src/app/main/ui/workspace/review/overlays.cljs
@@ -29,32 +29,93 @@
[app.util.keyboard :as kbd]
[rumext.v2 :as mf]))
-(defn- screen-rect
- "The box of `shape` on the screen, inside a layer translated by the
- viewbox."
- [shape zoom]
- (let [{:keys [x y width height]} (:selrect shape)]
- #js {:left (dm/str (* x zoom) "px")
- :top (dm/str (* y zoom) "px")
- :width (dm/str (* width zoom) "px")
- :height (dm/str (* height zoom) "px")}))
+(defn screen-rect
+ "The box `rect` (canvas coordinates) on the screen, inside a layer
+ translated by the viewbox."
+ [{:keys [x y width height]} zoom]
+ #js {:left (dm/str (* x zoom) "px")
+ :top (dm/str (* y zoom) "px")
+ :width (dm/str (* width zoom) "px")
+ :height (dm/str (* height zoom) "px")})
+
+(defn viewbox-offset
+ "The style that moves a layer covering the viewport to the origin of
+ the canvas, so what it holds is placed in canvas coordinates."
+ [vbox zoom]
+ #js {:transform (dm/fmt "translate(%px, %px)"
+ (* (- (:x vbox)) zoom)
+ (* (- (:y vbox)) zoom))})
;; --- Changes
(mf/defc change-box*
- {::mf/private true}
- [{:keys [entry shape zoom is-active]}]
- (let [kind (:kind entry)]
- [:div {:class (stl/css-case :change-box true
+ "The mark of a change on the canvas: a dashed box around `rect` with a
+ tag that says what happened, in the `tone` of its status. The active
+ one is drawn solid. With `on-click` the tag is a button; the box itself
+ never takes the pointer, so the canvas under it stays usable."
+ [{:keys [class rect zoom label tone is-active on-click children] :rest props}]
+ (let [tag-class (stl/css-case :change-tag true
:is-active is-active
- :is-added (= kind :added))
- :style (screen-rect shape zoom)}
- [:span {:class (stl/css-case :change-tag true
- :is-active is-active
- :is-added (= kind :added))}
- (if is-active
- (tr "workspace.review.text-and-detail" (:name shape) (rvc/change-kind-label kind))
- (rvc/change-kind-label kind))]]))
+ :is-button (some? on-click))
+ props (mf/spread-props props
+ {:class [class (stl/css-case :change-box true
+ :is-active is-active
+ :tone-success (= tone "success")
+ :tone-error (= tone "error")
+ :tone-warning (= tone "warning"))]
+ :style (screen-rect rect zoom)})]
+ [:> :div props
+ (if (some? on-click)
+ [:button {:class tag-class :on-click on-click} label]
+ [:span {:class tag-class} label])
+ children]))
+
+(mf/defc navigator*
+ "A bar over the canvas that goes through a list one entry at a time:
+ the arrows, the place in the list and, after them, what the entry is
+ and what can be done with it (`children`). It stands over the bar at
+ the bottom of the canvas, in the middle of the canvas the rulers leave
+ as that bar is, and over its strip when that bar is folded
+ (`is-lowered`). Its border is blue, unless a `tone` (\"warning\" or
+ \"neutral\") says otherwise."
+ [{:keys [class index total tone is-lowered on-previous on-next children] :rest props}]
+ (let [rulers? (mf/deref refs/rulers?)
+ props (mf/spread-props props
+ {:class [class (stl/css-case :navigator true
+ :has-rulers rulers?
+ :is-lowered is-lowered
+ :tone-warning (= tone "warning")
+ :tone-neutral (= tone "neutral"))]
+ :role "region"})]
+ [:> :div props
+ ;; the arrows hold the place in the list between them
+ [:div {:class (stl/css :navigator-steps)}
+ [:> icon-button* {:variant "ghost"
+ :icon i/arrow-left
+ :aria-label (tr "workspace.review.changes.previous")
+ :disabled (zero? total)
+ :on-click on-previous}]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :navigator-count)}
+ (tr "workspace.review.changes.position" (if (pos? total) (inc index) 0) total)]
+ [:> icon-button* {:variant "ghost"
+ :icon i/arrow-right
+ :aria-label (tr "workspace.review.changes.next")
+ :disabled (zero? total)
+ :on-click on-next}]]
+ children]))
+
+(mf/defc navigator-text*
+ "What the entry of a `navigator*` is: its `name` and a `detail`."
+ [{:keys [name detail]}]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :navigator-text)}
+ (when name
+ [:strong {:class (stl/css :navigator-name)} name])
+ (when name " ")
+ detail])
+
+(mf/defc navigator-separator*
+ []
+ [:div {:class (stl/css :navigator-separator)}])
(mf/defc changes-navigator*
"The bar that goes through the changes shown on the canvas."
@@ -67,32 +128,19 @@
on-back (mf/use-fn #(st/emit! (dwrv/back-to-details)))
on-close (mf/use-fn #(st/emit! (dwrv/hide-changes)))]
- [:div {:class (stl/css :navigator)
- :role "region"
- :aria-label (tr "workspace.review.changes.label")}
- [:> icon-button* {:variant "ghost"
- :icon i/arrow-left
- :aria-label (tr "workspace.review.changes.previous")
- :disabled (zero? total)
- :on-click on-prev}]
- [:> text* {:as "span" :typography t/body-small :class (stl/css :navigator-count)}
- (tr "workspace.review.changes.position" (if (pos? total) (inc index) 0) total)]
- [:> icon-button* {:variant "ghost"
- :icon i/arrow-right
- :aria-label (tr "workspace.review.changes.next")
- :disabled (zero? total)
- :on-click on-next}]
+ [:> navigator* {:index index
+ :total total
+ :aria-label (tr "workspace.review.changes.label")
+ :on-previous on-prev
+ :on-next on-next}
(if (some? entry)
- [:> text* {:as "span" :typography t/body-small :class (stl/css :navigator-text)}
- [:strong {:class (stl/css :navigator-name)} (:name entry)]
- " "
- (tr "workspace.review.changes.by"
- (rvc/change-kind-label-lower (:kind entry))
- (rvc/profile-name profiles (:profile-id entry))
- (ct/format-inst (:changed-at entry) :localized-time))]
- [:> text* {:as "span" :typography t/body-small :class (stl/css :navigator-text)}
- (tr "workspace.review.changes.none")])
- [:div {:class (stl/css :navigator-separator)}]
+ [:> navigator-text* {:name (:name entry)
+ :detail (tr "workspace.review.changes.by"
+ (rvc/change-kind-label-lower (:kind entry))
+ (rvc/profile-name profiles (:profile-id entry))
+ (ct/format-inst (:changed-at entry) :localized-time))}]
+ [:> navigator-text* {:detail (tr "workspace.review.changes.none")}])
+ [:> navigator-separator* {}]
[:> button* {:variant "ghost" :on-click on-back}
(tr "workspace.review.changes.back")]
[:> icon-button* {:variant "ghost"
@@ -118,15 +166,22 @@
(into [] d/xf:add-index entries))]
[:*
(for [entry entries]
- (let [shape (get objects (:id entry))]
+ (let [shape (get objects (:id entry))
+ kind (:kind entry)
+ active? (= (::d/index entry) index)]
(when (and (= page-id (:page-id entry))
(some? shape)
(not (cfh/root? shape)))
[:> change-box* {:key (dm/str (:id entry))
- :entry entry
- :shape shape
+ :class (stl/css :review-change)
+ :rect (:selrect shape)
:zoom zoom
- :is-active (= (::d/index entry) index)}])))]))
+ :tone (when (= kind :added) "success")
+ :label (if active?
+ (tr "workspace.review.text-and-detail"
+ (:name shape) (rvc/change-kind-label kind))
+ (rvc/change-kind-label kind))
+ :is-active active?}])))]))
;; --- Picking the layer of a task
@@ -178,13 +233,12 @@
:on-click on-click}
(when (some? hover)
[:div {:class (stl/css :threads)
- :style #js {:transform (dm/fmt "translate(%px, %px)"
- (* (- (:x vbox)) zoom)
- (* (- (:y vbox)) zoom))}}
- [:div {:class (stl/css :change-box :is-active)
- :style (screen-rect hover zoom)}
- [:span {:class (stl/css :change-tag :is-active :is-pick)}
- (tr "workspace.tasks.relink.link-to" (:name hover))]]])]
+ :style (viewbox-offset vbox zoom)}
+ [:> change-box* {:rect (:selrect hover)
+ :zoom zoom
+ :class (stl/css :is-pick)
+ :label (tr "workspace.tasks.relink.link-to" (:name hover))
+ :is-active true}]])]
[:div {:class (stl/css :picker-banner)
:role "status"}
[:> icon* {:icon-id i/view-as-list :size "s" :class (stl/css :picker-icon)}]
@@ -212,9 +266,7 @@
(when (some? show-changes)
[:*
[:div {:class (stl/css :threads)
- :style #js {:transform (dm/fmt "translate(%px, %px)"
- (* (- (:x vbox)) zoom)
- (* (- (:y vbox)) zoom))}}
+ :style (viewbox-offset vbox zoom)}
[:> change-boxes* {:entries entries
:zoom zoom
:page-id page-id
diff --git a/frontend/src/app/main/ui/workspace/review/overlays.scss b/frontend/src/app/main/ui/workspace/review/overlays.scss
index 7548f686ad..80166f1042 100644
--- a/frontend/src/app/main/ui/workspace/review/overlays.scss
+++ b/frontend/src/app/main/ui/workspace/review/overlays.scss
@@ -25,13 +25,29 @@
.change-box {
--change-color: var(--color-accent-info);
+ --change-bg-color: var(--color-background-info);
position: absolute;
border: $b-1 dashed var(--change-color);
pointer-events: none;
- &.is-added {
+ &.tone-success {
--change-color: var(--color-accent-success);
+ --change-bg-color: var(--color-background-success);
+ }
+
+ &.tone-error {
+ --change-color: var(--color-accent-error);
+ --change-bg-color: var(--color-background-error);
+ }
+
+ &.tone-warning {
+ --change-color: var(--color-accent-warning);
+ --change-bg-color: var(--color-background-warning);
+ }
+
+ &.is-pick {
+ --change-color: var(--color-accent-primary);
}
&.is-active {
@@ -41,8 +57,8 @@
}
.change-tag {
- --change-tag-bg-color: var(--color-background-info);
- --change-tag-fg-color: var(--color-accent-info);
+ --change-tag-bg-color: var(--change-bg-color);
+ --change-tag-fg-color: var(--change-color);
@include use-typography("body-small");
@@ -51,53 +67,97 @@
inset-inline-end: 0;
margin-block-end: var(--sp-xxs);
padding: 0 var(--sp-xs);
+ border: none;
border-radius: $br-4 $br-4 0 0;
background-color: var(--change-tag-bg-color);
color: var(--change-tag-fg-color);
white-space: nowrap;
- &.is-added {
- --change-tag-bg-color: var(--color-background-success);
- --change-tag-fg-color: var(--color-accent-success);
- }
-
&.is-active {
- --change-tag-bg-color: var(--color-accent-info);
+ --change-tag-bg-color: var(--change-color);
--change-tag-fg-color: var(--color-background-primary);
inset-inline: 0 auto;
}
- &.is-pick {
- --change-tag-bg-color: var(--color-accent-primary);
+ // the tag picks its change; the box around it lets the pointer through
+ &.is-button {
+ pointer-events: auto;
+ cursor: pointer;
}
}
-// right above the review bar (`.pr-banner`): its offset from the bottom,
-// its height (the buttons, its padding and its border) and a small gap
+// the change in front of a design review keeps its tag in the colour of
+// the review, added or not
+.review-change .change-tag.is-active {
+ --change-tag-bg-color: var(--color-accent-info);
+}
+
+// right above the bar at the bottom of the canvas (`.pr-banner`,
+// `.branch-banner`): its offset from the bottom, its height (the buttons,
+// its padding and its border) and a small gap
.navigator {
+ --navigator-border-color: var(--color-accent-info);
+
position: absolute;
inset-block-end: calc(var(--sp-m) + #{$sz-32} + var(--sp-s) * 2 + #{$b-2} * 2 + var(--sp-s));
inset-inline-start: 50%;
transform: translateX(-50%);
+ transition: inset-block-end 0.2s;
display: flex;
align-items: center;
gap: var(--sp-s);
+ max-inline-size: calc(100% - var(--sp-xxl));
padding: var(--sp-xs) var(--sp-s);
- border: $b-1 solid var(--color-accent-info);
+ border: $b-1 solid var(--navigator-border-color);
border-radius: $br-8;
background-color: var(--color-background-primary);
pointer-events: auto;
+
+ &.tone-warning {
+ --navigator-border-color: var(--color-accent-warning);
+ }
+
+ // the grey of the bar at the bottom of the canvas (`.branch-banner`)
+ &.tone-neutral {
+ --navigator-border-color: var(--color-background-quaternary);
+ }
+
+ // half a ruler after the middle (`rulers/ruler-area-size`)
+ &.has-rulers {
+ inset-inline-start: calc(50% + #{px2rem(11)});
+ }
+
+ // over the strip the bar folds down to (`.branch-banner.is-collapsed`),
+ // with the same gap
+ &.is-lowered {
+ inset-block-end: calc(var(--sp-m) + var(--sp-s));
+ }
}
+// the arrows and the place in the list between them, with no gap
+.navigator-steps {
+ display: flex;
+ flex-shrink: 0;
+ align-items: center;
+}
+
+// a bar of a fixed width gives the place in the list a width too
+// (`--navigator-count-size`), so the arrows do not move with its digits
.navigator-count {
+ min-inline-size: var(--navigator-count-size, auto);
color: var(--color-foreground-secondary);
+ text-align: center;
white-space: nowrap;
}
.navigator-text {
+ flex-grow: 1;
+ min-inline-size: 0;
+ overflow: hidden;
color: var(--color-foreground-secondary);
white-space: nowrap;
+ text-overflow: ellipsis;
}
.navigator-name {
diff --git a/frontend/src/app/main/ui/workspace/review/panel.cljs b/frontend/src/app/main/ui/workspace/review/panel.cljs
index 254cf955a5..83fec3c987 100644
--- a/frontend/src/app/main/ui/workspace/review/panel.cljs
+++ b/frontend/src/app/main/ui/workspace/review/panel.cljs
@@ -44,7 +44,6 @@
"A comment thread of the review: its number and board, who wrote it and
when, what it points at, its text and its replies. With `show-review`,
it names the design review it belongs to."
- {::mf/private true}
[{:keys [thread objects is-open show-review]}]
(let [owner (d/without-nils (dcmt/get-owner thread))
replies (dec (or (:count-comments thread) 1))
diff --git a/frontend/src/app/main/ui/workspace/review/shape_preview.cljs b/frontend/src/app/main/ui/workspace/review/shape_preview.cljs
new file mode 100644
index 0000000000..6a91068a00
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/review/shape_preview.cljs
@@ -0,0 +1,43 @@
+;; 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) KALEIDOS SUBSIDIARY SL
+
+(ns app.main.ui.workspace.review.shape-preview
+ "A small drawing of a layer, for the card of a change in the details of
+ a design review."
+ (:require-macros [app.main.style :as stl])
+ (:require
+ [app.common.data.macros :as dm]
+ [app.main.render :as render]
+ [rumext.v2 :as mf]))
+
+(defn- shape-bounds
+ "Axis-aligned bounds framing a shape, taken from its rotated corner
+ `:points` when present, else its `:selrect`."
+ [shape]
+ (let [pts (:points shape)]
+ (if (and (sequential? pts) (seq pts))
+ (let [xs (keep :x pts) ys (keep :y pts)
+ x (apply min xs) y (apply min ys)]
+ {:x x :y y :width (- (apply max xs) x) :height (- (apply max ys) y)})
+ (let [sr (:selrect shape)]
+ {:x (:x sr 0) :y (:y sr 0) :width (:width sr 1) :height (:height sr 1)}))))
+
+(mf/defc shape-preview*
+ "Renders `shape` to a fitted SVG with the real shape renderers. `objects`
+ supplies its children (a board or group draws them)."
+ [{:keys [shape objects]}]
+ (let [{:keys [x y width height]} (shape-bounds shape)
+ width (max 1 width)
+ height (max 1 height)
+ objects (mf/with-memo [shape objects]
+ (assoc (or objects {}) (:id shape) shape))
+ wrapper (mf/with-memo [objects] (render/shape-wrapper-factory objects))]
+ [:svg {:class (stl/css :shape-preview)
+ :viewBox (dm/str x " " y " " width " " height)
+ :preserveAspectRatio "xMidYMid meet"
+ :xmlns "http://www.w3.org/2000/svg"
+ :fill "none"}
+ [:> wrapper {:shape shape}]]))
diff --git a/frontend/src/app/main/ui/workspace/review/shape_preview.scss b/frontend/src/app/main/ui/workspace/review/shape_preview.scss
new file mode 100644
index 0000000000..70e82a4345
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/review/shape_preview.scss
@@ -0,0 +1,10 @@
+// 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) KALEIDOS SUBSIDIARY SL
+
+.shape-preview {
+ inline-size: 100%;
+ block-size: 100%;
+}
diff --git a/frontend/src/app/main/ui/workspace/review/tasks.scss b/frontend/src/app/main/ui/workspace/review/tasks.scss
index b4ccd3fd7d..7a32d1e9cd 100644
--- a/frontend/src/app/main/ui/workspace/review/tasks.scss
+++ b/frontend/src/app/main/ui/workspace/review/tasks.scss
@@ -183,19 +183,22 @@
}
.task-next-step {
+ --task-next-step-background-color: var(--color-background-tertiary);
+
display: flex;
flex-direction: column;
gap: var(--sp-m);
padding: var(--sp-m);
border-radius: $br-8;
- background-color: var(--color-background-tertiary);
+ background-color: var(--task-next-step-background-color);
color: var(--color-foreground-primary);
&.is-inline {
+ --task-next-step-background-color: transparent;
+
flex-direction: row;
justify-content: flex-end;
padding: 0;
- background: none;
}
}
diff --git a/frontend/src/app/main/ui/workspace/sidebar.cljs b/frontend/src/app/main/ui/workspace/sidebar.cljs
index 7d222f0f43..29f52bf3c0 100644
--- a/frontend/src/app/main/ui/workspace/sidebar.cljs
+++ b/frontend/src/app/main/ui/workspace/sidebar.cljs
@@ -30,6 +30,8 @@
[app.main.ui.hooks :as hooks]
[app.main.ui.hooks.resize :refer [use-resize-hook]]
[app.main.ui.workspace.comments :refer [comments-sidebar*]]
+ [app.main.ui.workspace.compare.detail :refer [compare-detail*]]
+ [app.main.ui.workspace.compare.list :refer [compare-list*]]
[app.main.ui.workspace.left-header :refer [left-header*]]
[app.main.ui.workspace.review.panel :refer [review-panel*]]
[app.main.ui.workspace.right-header :refer [right-header*]]
@@ -129,6 +131,8 @@
design-tokens? (features/use-feature "design-tokens/v1")
;; a design review is read-only: it shows the pages and layers alone
reviewing? (some? (mf/deref refs/pull-request-preview))
+ ;; comparing the branch with main, the changes take their place
+ comparing? (some? (mf/deref refs/compare-mode))
mode-inspect? (or reviewing? (= options-mode :inspect))
shortcuts? (contains? layout :shortcuts)
show-debug? (contains? layout :debug-panel)
@@ -206,6 +210,9 @@
(true? show-debug?)
[:> debug-panel* {:class (stl/css :left-sidebar-content)}]
+ ^boolean comparing?
+ [:> compare-list* {:class (stl/css :left-sidebar-content)}]
+
^boolean reviewing?
[:div {:class (stl/css :left-sidebar-content)}
[:> layers-content* {:layout layout
@@ -295,6 +302,10 @@
(mf/defc right-sidebar*
[{:keys [layout section file-id page-id drawing-tool active-tokens] :as props}]
(let [reviewing? (some? (mf/deref refs/pull-request-preview))
+ ;; comparing the branch with main, the panel shows the change
+ ;; chosen; a commenting tool brings the comments and tasks back
+ is-comparing? (and (some? (mf/deref refs/compare-mode))
+ (not= drawing-tool :comments))
is-comments? (and (not reviewing?) (= drawing-tool :comments))
is-history? (contains? layout :document-history)
is-scale? (contains? layout :scale-text)
@@ -362,6 +373,9 @@
[:div {:class (stl/css :right-sidebar-content)}
(cond
+ (and is-comparing? (not is-history?))
+ [:> compare-detail* {}]
+
;; inside a design review the panel shows the inspect of the
;; selection (the same one the workspace has) and the comments and
;; tasks of the review
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branch_review/common.cljs b/frontend/src/app/main/ui/workspace/sidebar/branch_review/common.cljs
index feb2e55444..0757630d08 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+++ b/frontend/src/app/main/ui/workspace/sidebar/branch_review/common.cljs
@@ -5,11 +5,12 @@
;; Copyright (c) KALEIDOS SUBSIDIARY SL
(ns app.main.ui.workspace.sidebar.branch-review.common
- "What the compare and conflict dialogs say about a diff entry, kept free
- of rendering: labels, values, categories, one-line summaries, the
- page/board a change lives on, how a conflict splits into the
- properties in conflict and the ones only one side touched, and what the
- copy rule decides for the copies of a changed component."
+ "What the compare mode says about a diff entry, kept free of rendering:
+ labels, values, one-line summaries, the page/board a change lives on,
+ the list the changes make and the marks they leave on the canvas, how a
+ conflict splits into the properties in conflict and the ones only one
+ side touched, and what the copy rule decides for the copies of a changed
+ component."
(:require
[app.common.data.macros :as dm]
[app.common.files.branch-merge :as bm]
@@ -19,6 +20,7 @@
[app.common.uuid :as uuid]
[app.main.data.modal :as modal]
[app.main.data.workspace.branches :as dwb]
+ [app.main.data.workspace.compare :as dwcp]
[app.main.store :as st]
[app.main.ui.ds.foundations.assets.icon :as i]
[app.util.i18n :as i18n :refer [tr]]
@@ -29,7 +31,7 @@
(defn confirm-merge!
"Open the merge dialog for `branch` (merge into main is irreversible and
deletes the branch; the dialog asks for a comment for the merge's
- record). `excluded` is the compare dialog's per-change selection, if
+ record). `excluded` is the per-change selection of the comparison, if
any."
([branch] (confirm-merge! branch nil))
([branch excluded]
@@ -37,8 +39,8 @@
(defn confirm-update!
"Ask for confirmation before updating `branch` from main (overwrites
- conflicting branch changes). `excluded` is the compare dialog's
- per-change selection, if any."
+ conflicting branch changes). `excluded` is the per-change selection of
+ the comparison, if any."
([branch] (confirm-update! branch nil))
([branch excluded]
(st/emit! (modal/show {:type :confirm
@@ -257,75 +259,20 @@
[changed-attrs]
(into [] (remove (fn [[attr _]] (contains? technical-attrs attr))) changed-attrs))
-;; --- Categories
+;; --- Scope
-(def ^:private copy-attrs #{:content :name})
-(def ^:private colour-attrs #{:fills :strokes :fill-color :stroke-color :color :gradient
- :shadow :opacity :blend-mode})
-(def ^:private layout-attrs #{:layout :layout-flex-dir :layout-gap :layout-padding
- :layout-padding-type :layout-gap-type :layout-wrap-type
- :layout-justify-content :layout-align-items
- :layout-align-content :layout-justify-items
- :layout-grid-rows :layout-grid-columns :layout-grid-cells
- :layout-item-margin :layout-item-h-sizing
- :layout-item-v-sizing :layout-item-align-self
- :x :y :width :height :rotation :constraints-h
- :constraints-v})
+(def ^:private page-kinds
+ #{:page :page-order})
-(def categories
- "Category order, the tone and icon of each one. Colour is
- kept for what happened to an entry (added, modified, deleted, in
- conflict), so the categories are neutral and told apart by their icon;
- decisions alone stay in the conflict colour, as they are conflicts."
- [[:decisions "warning" i/triangle-alert]
- [:copy "neutral" i/text]
- [:colour "neutral" i/swatches]
- [:layout "neutral" i/flex]
- [:components "neutral" i/component]
- [:variants "neutral" i/variant]
- [:tokens "neutral" i/tokens]
- [:other "neutral" i/layers]])
-
-(def category->tone
- (into {} (map (fn [[k tone _]] [k tone])) categories))
-
-(defn category-label
- [cat]
- (case cat
- :decisions (tr "workspace.branches.review.category.decisions")
- :copy (tr "workspace.branches.review.category.copy")
- :colour (tr "workspace.branches.review.category.colour")
- :layout (tr "workspace.branches.review.category.layout")
- :components (tr "workspace.branches.review.category.components")
- :variants (tr "workspace.branches.review.category.variants")
- :tokens (tr "workspace.branches.review.category.tokens")
- :other (tr "workspace.branches.review.category.other")))
-
-(def category->icon
- (into {} (map (fn [[k _ icon]] [k icon])) categories))
-
-(defn category
- "The one category a diff entry falls under, most specific first: a
- conflict is a decision; a variant is a variant change; a component or
- a copy is a component change; a token is a token change; the attrs of a modified
- layer decide between copy, colour and layout."
+(defn scope
+ "Where a diff entry belongs, as the filters of the list tell them
+ apart: `:layers` for what lives on a page (layers, and the pages
+ themselves), `:library` for what the whole file shares (components,
+ colours, typographies, tokens, file options)."
[item]
- (let [kind (:kind item)
- attrs (set (keys (:changed-attrs item)))]
- (cond
- (= :conflict (:status item)) :decisions
- (:variant? item) :variants
- (or (= :component kind) (:component? item) (:component-copy? item))
- :components
- (contains? #{:token :token-set :token-set-rename :token-set-order :token-theme
- :token-active-themes :token-active-sets :tokens-source} kind)
- :tokens
- (contains? #{:color} kind) :colour
- (contains? #{:typography} kind) :copy
- (some copy-attrs attrs) :copy
- (some colour-attrs attrs) :colour
- (some layout-attrs attrs) :layout
- :else :other)))
+ (if (or (some? (:page-id item)) (contains? page-kinds (:kind item)))
+ :layers
+ :library))
(defn status-tone
"The colour of the bar on a change row: what happened to the entry. A
@@ -413,26 +360,26 @@
"The added or deleted layers that only follow a container added or
deleted with them, folded under the outermost one: deleting a group
deletes its layers too, and listing each one apart would repeat the
- same change. Takes `[index item]` pairs and returns a map from the
- index of each outermost entry to the `[index item]` pairs it holds."
- [indexed]
+ same change. Returns a map from the key (`dwcp/item-key`) of each
+ outermost entry to the entries it holds."
+ [items]
(let [by-id (into {}
- (keep (fn [[idx item]]
+ (keep (fn [item]
(when (cascade-entry? item)
- [[(:page-id item) (:id item)] [idx item]])))
- indexed)
+ [[(:page-id item) (:id item)] item])))
+ items)
root-of (fn [item]
(loop [cur item root nil depth 0]
- (let [[pidx parent] (get by-id [(:page-id item) (get-in cur [:shape :parent-id])])]
+ (let [parent (get by-id [(:page-id item) (get-in cur [:shape :parent-id])])]
(if (and parent (= (:status parent) (:status item)) (< depth 64))
- (recur parent pidx (inc depth))
+ (recur parent parent (inc depth))
root))))]
- (reduce (fn [acc [_ item :as row]]
+ (reduce (fn [acc item]
(if-let [root (when (cascade-entry? item) (root-of item))]
- (update acc root (fnil conj []) row)
+ (update acc (dwcp/item-key root) (fnil conj []) item)
acc))
{}
- indexed)))
+ items)))
;; --- What goes with an added or deleted layer
@@ -467,14 +414,14 @@
Penpot makes these changes itself when a layer goes, so the diff lists
them as entries of their own; this ties them to their cause. `objects`
is the page as the side that holds the layer has it, `inner` the
- layers folded under it (`fold-cascades`), and `incoming` says the
+ entries folded under it (`fold-cascades`), and `incoming` says the
changes are main's, going to the branch, rather than the branch's
going to main."
[item items objects inner incoming]
(let [from (if incoming :branch :main)
to (if incoming :main :branch)
deleted? (= :deleted (:status item))
- ids (into #{(:id item)} (map (comp :id second)) inner)
+ ids (into #{(:id item)} (map :id) inner)
page-id (:page-id item)
on-page (filterv #(= page-id (:page-id %)) items)
modified (into {}
@@ -529,32 +476,31 @@
ancestors)}))
(defn group-by-place
- "Group the clean changes (`[index item]` pairs) by page, and inside a
- page by the top-level board that holds them, reading names from the
- open file's `pages-index`. Entries that belong to no page (components,
- colours, typographies, tokens) go to a last `:library` group, after a
- `:pages` group for the pages added, deleted or reordered. Each
- group is `{:id :name :page-id :rows [[idx item]] :boards [{:id :name
- :rows}]}`, with `:rows` holding the entries outside any board. A board
- groups its changes only when it holds two or more of `rows`. `:count`
- leaves out the copies the copy rule settled (`bm/settled?`)."
- [rows pages-index pages]
- (let [by-page (group-by (fn [[_ item]] (:page-id item)) rows)
+ "Group the clean changes `items` by page, and inside a page by the
+ top-level board that holds them, reading names from the open file's
+ `pages-index`. Entries that belong to no page (components, colours,
+ typographies, tokens) go to a last `:library` group, after a `:pages`
+ group for the pages added, deleted or reordered. Each group is
+ `{:id :name :page-id :rows [item] :boards [{:id :name :rows}]}`, with
+ `:rows` holding the entries outside any board. A board groups its
+ changes only when it holds two or more of `items`. `:count` leaves out
+ the copies the copy rule settled (`bm/settled?`)."
+ [items pages-index pages]
+ (let [by-page (group-by :page-id items)
page-group
- (fn [page-id page-rows]
+ (fn [page-id page-items]
(let [page (get pages-index page-id)
objects (:objects page)
- placed (map (fn [[_ item :as row]]
- (let [board (when (= :shape (:kind item))
- (top-board objects (:id item)))]
- [row board]))
- page-rows)
+ placed (map (fn [item]
+ [item (when (= :shape (:kind item))
+ (top-board objects (:id item)))])
+ page-items)
;; a board folds its changes only when it holds two or
;; more of the listed ones: a lone change stays loose, as
;; the fold would only repeat it
sizes (frequencies (keep (comp :id second) placed))
- placed (map (fn [[row board]]
- [row (when (> (get sizes (:id board) 0) 1) board)])
+ placed (map (fn [[item board]]
+ [item (when (> (get sizes (:id board) 0) 1) board)])
placed)
boards (->> placed
(filter second)
@@ -570,14 +516,14 @@
:name (or (:name page) (tr "workspace.branches.review.unknown-page"))
:rows (into [] (comp (remove second) (map first)) placed)
:boards boards
- :count (count (remove (comp bm/settled? second) page-rows))}))
+ :count (count (remove bm/settled? page-items))}))
page-order (into {} (map-indexed (fn [idx id] [id idx])) pages)
loose (get by-page nil)
- page-kind #(contains? #{:page :page-order} (:kind (second %)))
- page-rows (filterv page-kind loose)
- library (filterv (complement page-kind) loose)]
+ page-kind? #(contains? page-kinds (:kind %))
+ page-rows (filterv page-kind? loose)
+ library (filterv (complement page-kind?) loose)]
(cond-> (->> (dissoc by-page nil)
- (map (fn [[page-id page-rows]] (page-group page-id page-rows)))
+ (map (fn [[page-id page-items]] (page-group page-id page-items)))
(sort-by #(get page-order (:page-id %) 9999))
vec)
(seq page-rows)
@@ -594,6 +540,110 @@
:boards []
:count (count library)}))))
+;; --- The list of changes
+
+(defn selectable-item?
+ "An entry the per-change selection covers: a clean change. A conflict
+ keeps its resolution instead, and an `:unsupported` entry is a refusal
+ the merge raises whatever the selection says."
+ [item]
+ (contains? #{:added :modified :deleted} (:status item)))
+
+(defn conflict?
+ [item]
+ (= :conflict (:status item)))
+
+(defn row-keys
+ "The change keys a row stands for: its own and those of the layers
+ folded under it (`fold-cascades`), which travel or stay with it."
+ [item inner]
+ (into #{(:key item)} (map :key) inner))
+
+(defn change-model
+ "What the list of a comparison shows, from its `diff` and the open
+ file (`pages-index`, `pages`), with the filter in use (`:filter`) and
+ the per-change selection `excluded` applied:
+
+ `:items` every change and conflict of the diff;
+ `:cascades` the entries folded under another one (`fold-cascades`);
+ `:listed` the entries the list shows, the folded ones left out;
+ `:counted` the listed ones that count as changes: a copy the copy
+ rule settled is shown, never counted;
+ `:counts` how many each filter keeps (`:all`, `:layers`,
+ `:library`, `:left-out`);
+ `:conflicts` the conflicts the filter keeps;
+ `:groups` the clean changes it keeps, by place (`group-by-place`);
+ `:rows` the entries it keeps, in the order the list shows them;
+ `:decisions` how many conflicts wait for a choice;
+ `:kept` how many clean changes travel, and `:left-out` how many
+ stay: a folded layer goes with its container, so both
+ count the rows the list shows."
+ [diff {:keys [excluded pages-index pages] active-filter :filter}]
+ (let [items (into (vec (:changes diff)) (:conflicts diff))
+ excluded (or excluded #{})
+ cascades (fold-cascades items)
+ folded (into #{} (comp (mapcat val) (map dwcp/item-key)) cascades)
+ listed (filterv #(not (contains? folded (dwcp/item-key %))) items)
+ left-out? #(and (selectable-item? %) (contains? excluded (:key %)))
+ visible (filterv (fn [item]
+ (case active-filter
+ :left-out (left-out? item)
+ :layers (= :layers (scope item))
+ :library (= :library (scope item))
+ true))
+ listed)
+ conflicts (filterv conflict? visible)
+ groups (group-by-place (filterv (complement conflict?) visible) pages-index pages)
+ selectable (filterv selectable-item? listed)
+ left-out (count (filter left-out? selectable))
+ counted (filterv (complement bm/settled?) listed)]
+ {:items items
+ :cascades cascades
+ :listed listed
+ :counted counted
+ :counts {:all (count counted)
+ :layers (count (filter #(= :layers (scope %)) counted))
+ :library (count (filter #(= :library (scope %)) counted))
+ :left-out left-out}
+ :conflicts conflicts
+ :groups groups
+ :rows (into conflicts
+ (mapcat (fn [{:keys [rows boards]}]
+ (concat rows (mapcat :rows boards))))
+ groups)
+ :decisions (count (filter conflict? items))
+ :kept (- (count selectable) left-out)
+ :left-out left-out}))
+
+(defn step
+ "The key of the entry `offset` rows away from `selected` in `rows`,
+ going round at the ends; the first row when nothing is chosen. Nil for
+ an empty list."
+ [rows selected offset]
+ (when (seq rows)
+ (let [pos (first (keep-indexed (fn [idx item]
+ (when (= selected (dwcp/item-key item)) idx))
+ rows))]
+ (dwcp/item-key (if (nil? pos)
+ (first rows)
+ (nth rows (mod (+ pos offset) (count rows))))))))
+
+(defn next-pending
+ "The key of the first row after `selected` (going round) that `done?`
+ does not hold for, or nil when every row is done. `rows` are the
+ entries in the order of the list."
+ [rows selected done?]
+ (let [pos (or (first (keep-indexed (fn [idx item]
+ (when (= selected (dwcp/item-key item)) idx))
+ rows))
+ -1)
+ start (inc pos)
+ ahead (concat (drop start rows) (take start rows))]
+ (some (fn [item]
+ (when (and (not= selected (dwcp/item-key item)) (not (done? item)))
+ (dwcp/item-key item)))
+ ahead)))
+
;; --- Conflicts: which properties conflict and what one side did alone
(defn- attr-sources
@@ -741,6 +791,79 @@
:else nil)})))
mine)))
+;; --- Conflicts: what the user decides, and how far along they are
+
+(defn conflict-reason-label
+ "Why both sides clash on an entity, or nil for any other reason."
+ [reason]
+ (case reason
+ :modify-modify (tr "workspace.branches.conflicts.reason.modify-modify")
+ :add-add (tr "workspace.branches.conflicts.reason.add-add")
+ :delete-modify (tr "workspace.branches.conflicts.reason.delete-modify")
+ :modify-delete (tr "workspace.branches.conflicts.reason.modify-delete")
+ nil))
+
+(defn text-conflict?
+ "A conflict whose text content both sides rewrote."
+ [conflict]
+ (boolean
+ (and (per-attr? conflict)
+ (some #(and (= :content (:attr %)) (= :conflict (:source %)))
+ (conflict-attr-rows conflict)))))
+
+(defn dropped-paragraphs
+ "The paragraph edits keeping `side` drops."
+ [conflict side]
+ (let [other (if (= side :main) :branch :main)]
+ (filterv #(= :kept (:status %)) (paragraph-rows conflict other))))
+
+(defn loses-work?
+ "Whether every choice on a text conflict drops a paragraph edit: both
+ sides edited different paragraphs."
+ [conflict]
+ (boolean
+ (and (text-conflict? conflict)
+ (seq (dropped-paragraphs conflict :main))
+ (seq (dropped-paragraphs conflict :branch)))))
+
+(defn pending-attr
+ "The property of `conflict` in turn under resolution `res`: `attr` when
+ it is one of its conflicting properties, else the first one without a
+ choice, else the first one. Nil for a conflict that cannot be split by
+ property."
+ [conflict res attr]
+ (when (per-attr? conflict)
+ (let [attrs (conflicting-attrs (conflict-attr-rows conflict))]
+ (or (some #{attr} attrs)
+ (some #(when (nil? (attr-choice res %)) %) attrs)
+ (first attrs)))))
+
+(defn conflict-model
+ "How far along the `conflicts` of a merge or an update are under
+ `resolutions`: the ones that still wait for a choice (`:pending`), the
+ ones decided (`:decided`), and both in the order the list shows them
+ (`:rows`)."
+ [conflicts resolutions]
+ (let [resolved? #(bm/conflict-resolved? % (get resolutions (:id %)))
+ pending (filterv (complement resolved?) conflicts)
+ decided (filterv resolved? conflicts)]
+ {:conflicts (vec conflicts)
+ :pending pending
+ :decided decided
+ :rows (into pending decided)}))
+
+(defn prefill-resolutions
+ "The resolutions the `conflicts` without one in `resolutions` start
+ with (`prefill-resolution`), by conflict id: the edits one side made
+ alone are not in doubt, so only the conflicting properties wait."
+ [conflicts resolutions]
+ (into {}
+ (keep (fn [conflict]
+ (when (and (per-attr? conflict)
+ (nil? (get resolutions (:id conflict))))
+ [(:id conflict) (prefill-resolution conflict)])))
+ conflicts))
+
;; --- What a new or deleted entry is, where it lands, what it affects
(defn page-contents
@@ -767,42 +890,75 @@
(recur (:parent-id parent) (conj path (:name parent)) (inc depth))
(vec path)))))
-(defn- all-shapes
- [data]
- (mapcat (comp vals :objects) (vals (:pages-index data))))
+(defn- uses?
+ "Whether `shape` depends on the library entry `item`: it copies the
+ component, fills or strokes with the colour, writes with the
+ typography or applies the token."
+ [shape {:keys [kind id label]}]
+ (case kind
+ :component (and (= id (:component-id shape))
+ (not (:main-instance shape)))
+ :color (or (some #(= id (:fill-color-ref-id %)) (:fills shape))
+ (some #(= id (:stroke-color-ref-id %)) (:strokes shape)))
+ :typography (and (= :text (:type shape))
+ (some #(= id (:typography-ref-id %))
+ (txt/node-seq (:content shape))))
+ :token (some #(= label %) (vals (:applied-tokens shape)))
+ false))
-(defn component-copies
- "How many copies of component `component-id` the file `data` holds."
- [data component-id]
- (count (filter #(and (= component-id (:component-id %))
- (not (:main-instance %)))
- (all-shapes data))))
+(defn usages
+ "The layers of the file `data` that depend on the library entry `item`
+ (a component, colour, typography or token), each as
+ `{:page-id :shape}`; nil for an entry no layer can depend on."
+ [data item]
+ (when (contains? #{:component :color :typography :token} (:kind item))
+ (into []
+ (mapcat (fn [[page-id page]]
+ (eduction (filter #(uses? % item))
+ (map (fn [shape] {:page-id page-id :shape shape}))
+ (vals (:objects page)))))
+ (:pages-index data))))
-(defn color-usages
- "How many layers of `data` fill or stroke with library colour
- `color-id`."
- [data color-id]
- (count (filter (fn [shape]
- (or (some #(= color-id (:fill-color-ref-id %)) (:fills shape))
- (some #(= color-id (:stroke-color-ref-id %)) (:strokes shape))))
- (all-shapes data))))
+;; --- The marks of the changes on the canvas
-(defn typography-usages
- "How many text layers of `data` use library typography
- `typography-id`."
- [data typography-id]
- (count (filter (fn [shape]
- (and (= :text (:type shape))
- (some #(= typography-id (:typography-ref-id %))
- (txt/node-seq (:content shape)))))
- (all-shapes data))))
+(defn- shape-rect
+ [shape]
+ (select-keys (:selrect shape) [:x :y :width :height]))
-(defn token-usages
- "How many layers of `data` apply the token named `token-name`."
- [data token-name]
- (count (filter (fn [shape]
- (some #(= token-name %) (vals (:applied-tokens shape))))
- (all-shapes data))))
+(defn change-marks
+ "The marks the entries `items` leave on the page `page-id`, whose
+ layers are `objects`: `{:key :label :status :rect}` for each one that
+ is a layer of that page with a place (`dwcp/item-rect`). A layer the
+ open file lacks (deleted here, or added on the other side) is marked
+ where the diff says it is. `status-of` gives the status drawn for an
+ entry; the entries `excluded` holds leave no mark, as they stay out."
+ [items {:keys [page-id objects excluded status-of]}]
+ (let [excluded (or excluded #{})
+ status-of (or status-of :status)]
+ (into []
+ (keep (fn [item]
+ (when (and (= page-id (:page-id item))
+ (not (contains? excluded (:key item))))
+ (when-let [rect (dwcp/item-rect objects item)]
+ {:key (dwcp/item-key item)
+ :label (:label item)
+ :status (status-of item)
+ :rect rect}))))
+ items)))
+
+(defn usage-marks
+ "The marks of the layers of page `page-id` that depend on the library
+ entry `item` (`usages`): the change of a token or a colour shows on
+ the layers that use it."
+ [data item page-id]
+ (into []
+ (comp (filter #(= page-id (:page-id %)))
+ (map (fn [{:keys [shape]}]
+ {:key (dm/str (dwcp/item-key item) "/" (:id shape))
+ :label (:name shape)
+ :status :usage
+ :rect (shape-rect shape)})))
+ (usages data item)))
;; --- Component copies: what follows a changed component
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branch_review/compare.cljs b/frontend/src/app/main/ui/workspace/sidebar/branch_review/compare.cljs
deleted file mode 100644
index daf4c5074e..0000000000
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/compare.cljs
+++ /dev/null
@@ -1,922 +0,0 @@
-;; 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) KALEIDOS SUBSIDIARY SL
-
-(ns app.main.ui.workspace.sidebar.branch-review.compare
- "The compare dialog: what a branch changes, in words. It opens on the
- full list of changes, grouped by page and board, each one with its
- before and after."
- (:require-macros [app.main.style :as stl])
- (:require
- [app.common.data.macros :as dm]
- [app.common.files.branch-merge :as bm]
- [app.common.time :as ct]
- [app.main.data.modal :as modal]
- [app.main.data.workspace.branches :as dwb]
- [app.main.refs :as refs]
- [app.main.store :as st]
- [app.main.ui.ds.buttons.button :refer [button*]]
- [app.main.ui.ds.buttons.icon-button :refer [icon-button*]]
- [app.main.ui.ds.controls.checkbox :refer [checkbox*]]
- [app.main.ui.ds.foundations.assets.icon :as i]
- [app.main.ui.ds.foundations.typography :as t]
- [app.main.ui.ds.foundations.typography.heading :refer [heading*]]
- [app.main.ui.ds.foundations.typography.text :refer [text*]]
- [app.main.ui.ds.product.change-row :refer [change-row*]]
- [app.main.ui.ds.product.empty-state :refer [empty-state*]]
- [app.main.ui.ds.product.filter-chip :refer [filter-chip*]]
- [app.main.ui.ds.product.preview-card :refer [preview-card*]]
- [app.main.ui.ds.product.tag :refer [tag*]]
- [app.main.ui.ds.tooltip :refer [tooltip*]]
- [app.main.ui.workspace.sidebar.branch-review.common :as brc]
- [app.main.ui.workspace.sidebar.branch-review.facts :as brf]
- [app.main.ui.workspace.sidebar.branch-review.layout :as brl]
- [app.main.ui.workspace.sidebar.branch-review.previews :as brp]
- [app.util.dom :as dom]
- [app.util.i18n :as i18n :refer [tr]]
- [cuerdas.core :as str]
- [okulary.core :as l]
- [rumext.v2 :as mf]))
-
-(def ^:private branch-diff
- (l/derived :workspace-branch-diff st/state))
-
-(defn- selectable-item?
- "A row the per-change selection covers: a clean change. A conflict keeps
- its resolution UI instead, and an `:unsupported` entry is a refusal the
- merge raises whatever the selection says."
- [item]
- (contains? #{:added :modified :deleted} (:status item)))
-
-(defn- review-key
- "The key a row's review mark is stored under."
- [item]
- (or (:key item) (dm/str (name (:kind item)) ":" (:id item))))
-
-;; --- List rows
-
-(defn- dom-stop
- [event]
- (.stopPropagation event))
-
-(mf/defc row-end*
- {::mf/private true}
- [{:keys [item excluded reviewed]}]
- (let [status (:status item)
- edits (count (brc/visible-attrs (:changed-attrs item)))]
- (cond
- ;; the warning icon alone: the bar and the group already say it
- ;; waits for a decision
- (= :conflict status)
- [:> i/icon* {:icon-id i/triangle-alert
- :size "s"
- :class (stl/css :row-warning)
- :aria-label (tr "workspace.branches.review.row.choose")}]
-
- ;; information, not a change: nothing to choose or leave out
- (= :settled status)
- [:> tag* {:variant "pill"} (tr "workspace.branches.review.copies.settled-tag")]
-
- excluded
- [:> tag* {:variant "pill"} (tr "workspace.branches.review.row.left-out")]
-
- ;; reviewing is the user's progress, not what happened to the
- ;; entry: a quiet eye, seen by a person, never a coloured status
- reviewed
- [:> tooltip* {:content (tr "workspace.branches.review.row.reviewed")
- :placement "top"}
- [:> i/icon* {:icon-id i/shown
- :size "s"
- :class (stl/css :row-reviewed)}]]
-
- (= :added status)
- [:> tag* {:tone "success" :variant "pill"} (tr "workspace.branches.status.added")]
-
- (= :deleted status)
- [:> tag* {:tone "error" :variant "pill"} (tr "workspace.branches.status.deleted")]
-
- (> edits 1)
- [:> tag* {:tone "info" :variant "pill"}
- (tr "workspace.branches.review.row.edits" (i18n/c edits))]
-
- :else nil)))
-
-(defn- row-keys
- "The change keys a row stands for: its own and those of the layers
- folded under it (`brc/fold-cascades`), which travel or stay with it."
- [item inner]
- (into #{(:key item)} (map (comp :key second)) inner))
-
-(defn- remove-folded
- "`rows` (`[index item]` pairs) without the layers folded under another
- row (`brc/fold-cascades`)."
- [rows cascades]
- (let [folded (into #{} (comp (mapcat val) (map first)) cascades)]
- (filterv (fn [[idx _]] (not (contains? folded idx))) rows)))
-
-(defn- follows-of
- "How many copies follow the component `item` is, or the main instance
- of (`brc/copy-follow-counts`), or nil."
- [follow-counts item]
- (when (or (= :component (:kind item)) (:component? item))
- (get follow-counts (:id item))))
-
-(mf/defc item-row*
- "One change. `inner` are the layers added or deleted with it, folded
- under it: the row counts them and its checkbox takes them along.
- `follows` is how many copies follow the component the row changes."
- {::mf/private true}
- [{:keys [index item inner follows selected excluded reviewed on-select on-toggle]}]
- (let [selectable? (selectable-item? item)
- change-key (:key item)
- toggle-keys (row-keys item inner)
- subtitle (cond-> (brc/change-summary item)
- (seq inner)
- (dm/str " - " (tr "workspace.branches.review.facts.layers"
- (i18n/c (count inner))))
-
- (and follows (pos? follows))
- (dm/str " - " (tr "workspace.branches.review.copies.row-follow"
- (i18n/c follows))))
- on-click (mf/use-fn (mf/deps index on-select) #(on-select {:kind :item :index index}))
- on-check (mf/use-fn (mf/deps toggle-keys on-toggle) #(on-toggle toggle-keys))
- start (when selectable?
- (mf/html
- [:span {:class (stl/css :row-check)
- ;; the click must not also select the row
- :on-click dom-stop}
- [:> checkbox* {:id (dm/str "change-" change-key)
- :checked (not excluded)
- :on-change on-check}]]))]
- [:> change-row* {:title (or (:label item) "")
- :subtitle subtitle
- :icon (brc/entry-icon item)
- :tone (if (and excluded selectable?) "neutral" (brc/status-tone (:status item)))
- :is-selected (= selected {:kind :item :index index})
- :is-muted (and excluded selectable?)
- :start start
- :end (mf/html [:> row-end* {:item item :excluded excluded :reviewed reviewed}])
- :on-click on-click}]))
-
-(mf/defc board-row*
- "A top-level board that holds changes; its changes fold under it."
- {::mf/private true}
- [{:keys [group board selected collapsed on-select on-fold children]}]
- (let [sel {:kind :board :page-id (:page-id group) :board-id (:id board)}
- open? (not (contains? collapsed (:id board)))
- on-click (mf/use-fn (mf/deps sel on-select) #(on-select sel))
- on-chevron (mf/use-fn (mf/deps board on-fold)
- (fn [event]
- (.stopPropagation event)
- (on-fold (:id board))))]
- [:*
- [:> change-row* {:title (or (:name board) "")
- :subtitle (tr "workspace.branches.review.board.inside"
- (i18n/c (count (remove (comp bm/settled? second)
- (:rows board)))))
- ;; a fold is not a change: no status colour
- :tone "neutral"
- :is-selected (= selected sel)
- :start (mf/html
- [:button {:class (stl/css :row-fold)
- :aria-expanded open?
- :on-click on-chevron}
- [:> i/icon* {:icon-id (if open? i/arrow-down i/arrow-right)
- :size "s"}]])
- :on-click on-click}]
- (when open? children)]))
-
-(mf/defc decisions-group*
- "The changes both sides made, which wait for a decision."
- {::mf/private true}
- [{:keys [conflicts follow-counts selected reviewed collapsed on-select on-toggle on-fold]}]
- (let [open? (not (contains? collapsed "decisions"))
- on-header (mf/use-fn (mf/deps on-fold) #(on-fold "decisions"))]
- [:div {:class (stl/css :group)}
- [:> brl/group-head* {:label (tr "workspace.branches.review.group.decisions"
- (str (count conflicts)))
- :is-open open?
- :on-toggle on-header}]
- (when open?
- (for [[idx item] conflicts]
- [:> item-row* {:key idx :index idx :item item
- :follows (follows-of follow-counts item)
- :selected selected
- :reviewed (contains? reviewed (review-key item))
- :on-select on-select :on-toggle on-toggle}]))]))
-
-(mf/defc change-group*
- "The changes of one page: the group folds, and its checkbox takes all of
- them."
- {::mf/private true}
- [{:keys [group cascades follow-counts selected excluded reviewed collapsed
- on-select on-toggle on-fold]}]
- (let [{:keys [id name rows boards count]} group
- open? (not (contains? collapsed id))
- toggles (into #{} (comp (filter (fn [[_ it]] (selectable-item? it)))
- (mapcat (fn [[idx it]] (row-keys it (get cascades idx)))))
- (concat rows (mapcat :rows boards)))
- included? (not-any? excluded toggles)
- on-header (mf/use-fn (mf/deps id on-fold) #(on-fold id))
- on-check (mf/use-fn (mf/deps toggles included? on-toggle) #(on-toggle toggles (not included?)))]
- [:div {:class (stl/css :group)}
- [:> brl/group-head*
- {:label (dm/str name " (" count ")")
- :is-open open?
- :on-toggle on-header
- :start (when (seq toggles)
- (mf/html
- [:span {:class (stl/css :row-check)}
- [:> checkbox* {:id (dm/str "group-" id)
- :checked included?
- :on-change on-check}]]))}]
- (when open?
- [:*
- (for [[idx item] rows]
- [:> item-row* {:key idx :index idx :item item
- :inner (get cascades idx)
- :follows (follows-of follow-counts item)
- :selected selected
- :excluded (contains? excluded (:key item))
- :reviewed (contains? reviewed (review-key item))
- :on-select on-select :on-toggle on-toggle}])
- (for [board boards]
- [:> board-row* {:key (str (:id board))
- :group group :board board
- :selected selected :collapsed collapsed
- :on-select on-select :on-fold on-fold}
- (for [[idx item] (:rows board)]
- [:> item-row* {:key idx :index idx :item item
- :inner (get cascades idx)
- :follows (follows-of follow-counts item)
- :selected selected
- :excluded (contains? excluded (:key item))
- :reviewed (contains? reviewed (review-key item))
- :on-select on-select :on-toggle on-toggle}])])])]))
-
-(mf/defc change-list*
- {::mf/private true}
- [{:keys [groups conflicts cascades follow-counts selected excluded reviewed collapsed
- on-select on-toggle on-fold]}]
- [:*
- (when (seq conflicts)
- [:> decisions-group* {:conflicts conflicts
- :follow-counts follow-counts
- :selected selected
- :reviewed reviewed
- :collapsed collapsed
- :on-select on-select
- :on-toggle on-toggle
- :on-fold on-fold}])
-
- (for [group groups]
- [:> change-group* {:key (:id group)
- :group group
- :cascades cascades
- :follow-counts follow-counts
- :selected selected
- :excluded excluded
- :reviewed reviewed
- :collapsed collapsed
- :on-select on-select
- :on-toggle on-toggle
- :on-fold on-fold}])])
-
-;; --- Previews
-
-(def ^:private view-modes
- [[:side i/side-by-side]
- [:overlay i/boolean-intersection]])
-
-(defn- view-mode-label
- [mode]
- (case mode
- :side (tr "workspace.branches.review.view.side")
- :overlay (tr "workspace.branches.review.view.overlay")))
-
-(defn- library-entity
- "A library entry (colour, typography) as the open file holds it."
- [data item]
- (case (:kind item)
- :color (get-in data [:colors (:id item)])
- :typography (get-in data [:typographies (:id item)])
- nil))
-
-(mf/defc side-cards*
- "MAIN and BRANCH, side by side, each with what it holds for the change."
- {::mf/private true}
- [{:keys [kind main-value branch-value main-objects branch-objects
- main-detail branch-detail main-missing branch-missing large highlight]}]
- [:div {:class (stl/css :cards)}
- [:> preview-card* {:label (tr "workspace.branches.review.side.main")
- :side "main"
- :detail main-detail
- :is-large (boolean large)}
- [:> brp/entity-preview* {:kind kind
- :value main-value
- :objects main-objects
- :missing main-missing
- :highlight highlight}]]
- [:> preview-card* {:label (tr "workspace.branches.review.side.branch")
- :side "branch"
- :detail branch-detail
- :is-large (boolean large)}
- [:> brp/entity-preview* {:kind kind
- :value branch-value
- :objects branch-objects
- :missing branch-missing
- :highlight highlight}]]])
-
-(mf/defc overlay-card*
- "MAIN under BRANCH, in one card, so what moved or changed shows."
- {::mf/private true}
- [{:keys [kind main-value branch-value main-objects branch-objects large highlight]}]
- [:> preview-card* {:label (tr "workspace.branches.review.view.overlay")
- :side "base"
- :is-large (boolean large)
- :detail (tr "workspace.branches.review.overlay-detail")}
- [:div {:class (stl/css :overlay-stage)}
- (when main-value
- [:div {:class (stl/css :overlay-layer)}
- [:> brp/entity-preview* {:kind kind :value main-value :objects main-objects
- :highlight highlight}]])
- (when branch-value
- [:div {:class (stl/css :overlay-layer :is-top)}
- [:> brp/entity-preview* {:kind kind :value branch-value :objects branch-objects
- :highlight highlight}]])]])
-
-(mf/defc view-modes*
- "Side by side or overlay for the previews of a change, as icon toggles,
- then the toggle that gives the previews the whole dialog. `show-modes`
- leaves the view toggles out for a change with nothing to overlay."
- {::mf/private true}
- [{:keys [mode on-change show-modes expanded on-expand]}]
- (let [on-mode (mf/use-fn
- (mf/deps on-change)
- (fn [event]
- (on-change (-> (dom/get-current-target event)
- (dom/get-data "mode")
- (keyword)))))]
- [:div {:class (stl/css :view-modes)}
- (when show-modes
- (for [[m icon] view-modes]
- [:> icon-button* {:key (name m)
- :variant "ghost"
- :class (stl/css :view-toggle)
- :icon icon
- :aria-label (view-mode-label m)
- :aria-pressed (= m mode)
- :data-mode (name m)
- :on-click on-mode}]))
- [:> icon-button* {:variant "ghost"
- :icon (if expanded i/collapse i/expand)
- :aria-label (if expanded
- (tr "workspace.branches.review.view.collapse")
- (tr "workspace.branches.review.view.expand"))
- :on-click on-expand}]]))
-
-(mf/defc item-visual*
- "The visual comparison of one change, in the view `mode`."
- {::mf/private true}
- [{:keys [item items open-side incoming data diff-meta mode large]}]
- (let [kind (:kind item)
- page-id (:page-id item)
- objects (when (= :shape kind)
- (get-in data [:pages-index page-id :objects]))
- page-items (mf/with-memo [items page-id]
- (filterv #(= page-id (:page-id %)) items))
- main-objs (mf/with-memo [objects page-items open-side]
- (when objects (brp/side-objects objects page-items :main open-side)))
- branch-objs (mf/with-memo [objects page-items open-side]
- (when objects (brp/side-objects objects page-items :branch open-side)))
- ;; an added or deleted layer inside a board is shown in it: the
- ;; board on both sides, the layer outlined on the side that holds
- ;; it, so the change reads as what the board gains or loses
- stage (when (and (= :shape kind) (contains? #{:added :deleted} (:status item)))
- (let [holder (if (contains? main-objs (:id item)) main-objs branch-objs)
- fid (brp/context-frame-id holder (:id item))]
- (when (and (some? fid) (contains? main-objs fid) (contains? branch-objs fid))
- fid)))
- highlight (when stage {:id (:id item) :status (:status item)})
- main-v (cond
- stage (get main-objs stage)
- (= :shape kind) (or (get main-objs (:id item)) (get item :main))
- :else (brp/side-entity item :main open-side (library-entity data item)))
- branch-v (cond
- stage (get branch-objs stage)
- (= :shape kind) (or (get branch-objs (:id item)) (get item :branch))
- :else (brp/side-entity item :branch open-side (library-entity data item)))
- main-detail (some-> (:main-at diff-meta) ct/inst ct/timeago)
- branch-detail (some-> (:branch-at diff-meta) ct/inst ct/timeago)]
- (when (or main-v branch-v)
- [:div {:class (stl/css :visual)}
- (if (= mode :overlay)
- [:> overlay-card* {:kind kind
- :large large
- :highlight highlight
- :main-value main-v
- :branch-value branch-v
- :main-objects main-objs
- :branch-objects branch-objs}]
- [:> side-cards* {:kind kind
- :large large
- :highlight highlight
- :main-value main-v
- :branch-value branch-v
- :main-objects main-objs
- :branch-objects branch-objs
- :main-detail main-detail
- :branch-detail branch-detail
- :main-missing {:reason (brp/missing-reason item :main incoming)
- :side :main
- :open-side open-side}
- :branch-missing {:reason (brp/missing-reason item :branch incoming)
- :side :branch
- :open-side open-side}}])])))
-
-;; --- Detail panes
-
-(mf/defc item-detail*
- {::mf/private true}
- [{:keys [item items indexed cascades copies excluded excluded-keys reviewed selected open-side
- incoming data diff-meta on-resolve on-select on-toggle expanded on-expand]}]
- (let [type-lbl (brc/type-label item)
- cat (brc/category item)
- attrs (:changed-attrs item)
- visible (brc/visible-attrs attrs)
- conflict? (= :conflict (:status item))
- copies-of (mf/with-memo [copies item data]
- (brc/copies-entry copies item
- (get-in data [:pages-index (:page-id item) :objects])))
- mode* (mf/use-state :side)
- mode (deref mode*)
- on-mode (mf/use-fn #(reset! mode* %))]
- [:*
- [:div {:class (stl/css :detail-head)}
- [:div {:class (stl/css :detail-head-main)}
- [:> heading* {:level 3 :typography t/body-large :class (stl/css :detail-title)}
- (:label item)]
- (when type-lbl
- [:> tag* {} type-lbl])
- ;; a decision already shows as one (the warning row, the notice);
- ;; its category tag would only repeat it
- (when-not conflict?
- [:> tag* {:tone (brc/category->tone cat)
- :icon (brc/category->icon cat)}
- (brc/category-label cat)])
- (when (and excluded (selectable-item? item))
- [:> tag* {} (tr "workspace.branches.review.row.left-out")])]
- [:> view-modes* {:mode mode
- :on-change on-mode
- :show-modes (= :shape (:kind item))
- :expanded expanded
- :on-expand on-expand}]]
-
- [:> item-visual* {:item item
- :items items
- :open-side open-side
- :incoming incoming
- :data data
- :diff-meta diff-meta
- :mode mode
- :large expanded}]
-
- (when conflict?
- [:> brl/notice* {:level :warning}
- (tr "workspace.branches.review.decision.body")])
-
- ;; the summary heads the property table; a decision puts its way in
- ;; on the same line. A copy the copy rule settled changes nothing:
- ;; its section below says what the rule decided instead
- (when-not (bm/settled? item)
- [:*
- [:div {:class (stl/css :detail-summary-row)}
- [:> text* {:as "p" :typography t/body-small :class (stl/css :detail-summary)}
- (brc/change-summary item)]
- (when (and conflict? on-resolve)
- [:> button* {:variant "secondary" :on-click on-resolve}
- (tr "workspace.branches.review.row.choose")])]
-
- (if (seq visible)
- [:> brl/value-steps* {:attrs visible}]
- (when (= :modified (:status item))
- [:> text* {:as "p" :typography t/body-small :class (stl/css :detail-summary)}
- (tr "workspace.branches.compare.no-props")]))])
-
- ;; the copy rule: what it decided on this copy, how many copies a
- ;; choice on a main decides, and which copies follow the component
- (when (:settled item)
- [:> brf/settled-facts* {:settled (:settled item)
- :is-conflict conflict?
- :is-settled (bm/settled? item)}])
- (when (and conflict? (:copies-affected item))
- [:> brf/copies-affected* {:n (:copies-affected item)}])
- (when copies-of
- [:> brf/copies-facts* {:entry copies-of :copies copies :data data}])
-
- ;; an entry without a before and after says what it is, where it
- ;; lands and what it affects instead
- (when-not conflict?
- (case (:kind item)
- :page
- (when (contains? #{:added :deleted} (:status item))
- (let [rows (filterv (fn [[_ it]] (= (:id item) (:page-id it))) indexed)
- rows (remove-folded rows cascades)]
- [:> brf/page-facts* {:item item
- :data data
- :open-side open-side
- :incoming incoming
- :change-count (count (remove (comp bm/settled? second) rows))}
- (for [[idx it] rows]
- [:> item-row* {:key idx :index idx :item it
- :inner (get cascades idx)
- :selected selected
- :excluded (contains? excluded-keys (:key it))
- :reviewed (contains? reviewed (review-key it))
- :on-select on-select :on-toggle on-toggle}])]))
-
- :shape
- (when (contains? #{:added :deleted} (:status item))
- [:> brf/shape-facts* {:item item :items items :data data
- :inner (get cascades (:index selected))
- :open-side open-side :incoming incoming}])
-
- (:component :color :typography :token)
- [:> brf/usage-facts* {:item item :data data}]
-
- nil))]))
-
-(mf/defc board-detail*
- {::mf/private true}
- [{:keys [page-id board-id groups items cascades open-side data diff-meta selected excluded
- reviewed on-select on-toggle expanded on-expand]}]
- (let [mode* (mf/use-state :side)
- mode (deref mode*)
- on-mode (mf/use-fn #(reset! mode* %))
- group (some #(when (= page-id (:page-id %)) %) groups)
- board (some #(when (= board-id (:id %)) %) (:boards group))
- rows (:rows board)
- objects (get-in data [:pages-index page-id :objects])
- page-items (mf/with-memo [items page-id]
- (filterv #(= page-id (:page-id %)) items))
- main-objs (mf/with-memo [objects page-items open-side]
- (when objects (brp/side-objects objects page-items :main open-side)))
- branch-objs (mf/with-memo [objects page-items open-side]
- (when objects (brp/side-objects objects page-items :branch open-side)))]
- (when board
- [:*
- [:div {:class (stl/css :detail-head)}
- [:div {:class (stl/css :detail-head-main)}
- [:> heading* {:level 3 :typography t/body-large :class (stl/css :detail-title)}
- (:name board)]
- [:> tag* {} (tr "workspace.branches.compare.shape.board")]]
- [:> view-modes* {:mode mode
- :on-change on-mode
- :show-modes true
- :expanded expanded
- :on-expand on-expand}]]
- [:> text* {:as "p" :typography t/body-small :class (stl/css :detail-summary)}
- (dm/str (:name group) " › " (:name board) " - "
- (tr "workspace.branches.review.board.inside" (i18n/c (count rows))))]
- (let [main-v (get main-objs board-id)
- branch-v (get branch-objs board-id)]
- [:div {:class (stl/css :visual)}
- (if (= mode :overlay)
- [:> overlay-card* {:kind :shape
- :large expanded
- :main-value main-v
- :branch-value branch-v
- :main-objects main-objs
- :branch-objects branch-objs}]
- [:> side-cards* {:kind :shape
- :large expanded
- :main-value main-v
- :branch-value branch-v
- :main-objects main-objs
- :branch-objects branch-objs
- :main-detail (some-> (:main-at diff-meta) ct/inst ct/timeago)
- :branch-detail (some-> (:branch-at diff-meta) ct/inst ct/timeago)
- :main-missing {:side :main :open-side open-side}
- :branch-missing {:side :branch :open-side open-side}}])])
- [:div {:class (stl/css :inner-list)}
- (for [[idx item] rows]
- [:> item-row* {:key idx :index idx :item item
- :inner (get cascades idx)
- :selected selected
- :excluded (contains? excluded (:key item))
- :reviewed (contains? reviewed (review-key item))
- :on-select on-select :on-toggle on-toggle}])]])))
-
-;; --- The dialog
-
-(defn- display-order
- "Every row index in the order the list shows them: decisions first,
- then each page's loose rows and its boards' rows."
- [conflicts groups]
- (-> []
- (into (map first) conflicts)
- (into (mapcat (fn [{:keys [rows boards]}]
- (concat (map first rows)
- (mapcat (comp (partial map first) :rows) boards))))
- groups)))
-
-(mf/defc branch-compare-dialog*
- {::mf/register modal/components
- ::mf/register-as :branch-compare}
- [{:keys [branch is-review]}]
- (let [{:keys [status diff direction excluded reviewed]} (mf/deref branch-diff)
- file-id (:id (mf/deref refs/file))
- data (mf/deref refs/workspace-data)
- direction (or direction :branch->main)
- incoming? (= direction :main->branch)
- excluded (or excluded #{})
- reviewed (or reviewed #{})
- open-side (brp/open-side branch file-id)
- diff-meta (:meta diff)
-
- items (mf/with-memo [diff]
- (into (vec (:changes diff)) (:conflicts diff)))
- indexed (mf/with-memo [items]
- (into [] (map-indexed vector) items))
- ;; the layers added or deleted with a container fold under it:
- ;; the list, the filters and the counts show the container alone
- cascades (mf/with-memo [indexed]
- (brc/fold-cascades indexed))
- listed (mf/with-memo [indexed cascades]
- (remove-folded indexed cascades))
- listed-items (mf/with-memo [listed]
- (mapv second listed))
- ;; a copy the copy rule settled entirely is shown, never counted
- counted (mf/with-memo [listed-items]
- (filterv (complement bm/settled?) listed-items))
- counts (mf/with-memo [counted]
- (group-by brc/category counted))
- copies (:copies diff)
- follow-counts (mf/with-memo [copies]
- (brc/copy-follow-counts copies))
-
- filter* (mf/use-state :all)
- active-filter (deref filter*)
- selected* (mf/use-state nil)
- selected (deref selected*)
- ;; expanded: the list steps aside and the previews take the
- ;; whole dialog
- expanded* (mf/use-state false)
- expanded (deref expanded*)
- on-expand (mf/use-fn #(swap! expanded* not))
- collapsed* (mf/use-state #{})
- collapsed (deref collapsed*)
-
- visible (mf/with-memo [listed active-filter excluded]
- (filterv (fn [[_ item]]
- (case active-filter
- :all true
- :left-out (contains? excluded (:key item))
- (= active-filter (brc/category item))))
- listed))
- conflicts (mf/with-memo [visible]
- (filterv (fn [[_ it]] (= :conflict (:status it))) visible))
- decisions (count (filter #(= :conflict (:status %)) items))
- groups (mf/with-memo [visible data]
- (brc/group-by-place (filterv (fn [[_ it]] (not= :conflict (:status it))) visible)
- (:pages-index data)
- (:pages data)))
- order (mf/with-memo [conflicts groups]
- (display-order conflicts groups))
-
- ;; a folded layer travels or stays with its container, so the
- ;; counts are of the rows the list shows
- row-keys* (into #{} (comp (filter selectable-item?) (map :key)) listed-items)
- kept-count (count (remove excluded row-keys*))
- left-out (count (filter excluded row-keys*))
- reviewed-n (count (filter #(contains? reviewed (review-key %)) counted))
-
- sel-index (when (= :item (:kind selected)) (:index selected))
- sel-item (when (and (some? sel-index) (< sel-index (count items)))
- (nth items sel-index))
- pos (when sel-index (.indexOf order sel-index))
-
- on-close (mf/use-fn #(st/emit! (dwb/clear-diff-excluded) (modal/hide)))
- on-select (mf/use-fn #(reset! selected* %))
- on-toggle (mf/use-fn (fn [change-keys include?]
- (st/emit! (dwb/toggle-diff-excluded change-keys include?))))
- on-fold (mf/use-fn (fn [id] (swap! collapsed* #(if (contains? % id) (disj % id) (conj % id)))))
- on-filter (mf/use-fn (fn [f]
- (reset! filter* f)
- (reset! selected* nil)))
- on-chip (mf/use-fn
- (mf/deps on-filter)
- (fn [event]
- (on-filter (-> (dom/get-current-target event)
- (dom/get-data "filter")
- (keyword)))))
- on-swap (mf/use-fn (mf/deps branch direction)
- #(st/emit! (dwb/fetch-branch-diff
- (:id branch)
- (if incoming? :branch->main :main->branch))))
- on-merge (mf/use-fn (mf/deps branch excluded)
- #(brc/confirm-merge! branch excluded))
- on-update (mf/use-fn (mf/deps branch excluded)
- #(brc/confirm-update! branch excluded))
- on-resolve (mf/use-fn (mf/deps branch direction excluded)
- #(modal/show! :branch-conflicts
- {:branch branch
- :mode (if incoming? :update :merge)
- :excluded excluded}))
- on-previous (mf/use-fn (mf/deps order pos)
- (fn []
- (when (and pos (pos? pos))
- (reset! selected* {:kind :item :index (nth order (dec pos))}))))
- on-mark-next
- (mf/use-fn
- (mf/deps order pos sel-item items reviewed)
- (fn []
- (when sel-item
- (st/emit! (dwb/toggle-diff-reviewed (review-key sel-item) true)))
- (let [start (if pos (inc pos) 0)
- ahead (concat (drop start order) (take start order))
- next-ix (some (fn [idx]
- (when (and (not= idx (:index selected))
- (not (bm/settled? (nth items idx)))
- (not (contains? reviewed (review-key (nth items idx)))))
- idx))
- ahead)]
- (when next-ix
- (reset! selected* {:kind :item :index next-ix})))))
- on-export (mf/use-fn
- (mf/deps diff branch)
- (fn []
- (let [payload (clj->js {:stats (:stats diff)
- :changes (:changes diff)
- :conflicts (:conflicts diff)
- :copies (:copies diff)})
- text (js/JSON.stringify payload nil 2)
- blob (js/Blob. #js [text] #js {:type "application/json"})
- url (js/URL.createObjectURL blob)
- a (.createElement js/document "a")]
- (set! (.-href a) url)
- (set! (.-download a) (dm/str (:name branch) "-diff.json"))
- (.click a)
- (js/URL.revokeObjectURL url))))
-
- primary
- (mf/html
- (cond
- (pos? decisions)
- [:> button* {:variant "primary" :on-click on-resolve}
- (tr "workspace.branches.review.action.resolve" (i18n/c decisions))]
-
- incoming?
- [:> button* {:variant "primary"
- :disabled (zero? kept-count)
- :on-click on-update}
- (tr "workspace.branches.review.action.update" (i18n/c kept-count))]
-
- :else
- [:> button* {:variant "primary"
- :disabled (zero? kept-count)
- :on-click on-merge}
- (tr "workspace.branches.review.action.merge" (i18n/c kept-count))]))]
-
- (mf/with-effect [(:id branch)]
- (st/emit! (dwb/fetch-branch-diff (:id branch))))
-
- ;; the list opens on its first row
- (mf/with-effect [status order]
- (when (and (= status :loaded) (nil? selected) (seq order))
- (reset! selected* {:kind :item :index (first order)})))
-
- [:> brl/review-modal*
- {:icon i/git-compare-arrows
- :title (tr "workspace.branches.review.title")
- :route (mf/html [:> brl/route* {:branch-name (:name branch)
- :is-review is-review
- :incoming incoming?
- :on-swap on-swap}])
- :filters (when (and (= status :loaded) (seq items) (not expanded))
- (mf/html
- [:*
- [:> filter-chip* {:label (dm/str (tr "labels.all") " (" (count counted) ")")
- :is-selected (= active-filter :all)
- :data-filter "all"
- :on-click on-chip}]
- (for [[cat tone icon] brc/categories
- :let [n (count (get counts cat))]
- :when (pos? n)]
- [:> filter-chip* {:key (name cat)
- :label (dm/str (brc/category-label cat) " (" n ")")
- :icon icon
- :tone tone
- :is-selected (= active-filter cat)
- :data-filter (name cat)
- :on-click on-chip}])
- (when (pos? left-out)
- [:> filter-chip* {:label (dm/str (tr "workspace.branches.review.row.left-out")
- " (" left-out ")")
- :is-selected (= active-filter :left-out)
- :data-filter "left-out"
- :on-click on-chip}])]))
- :list (when (and (= status :loaded) (seq items) (not expanded))
- (mf/html
- [:> change-list* {:groups groups
- :conflicts conflicts
- :cascades cascades
- :follow-counts follow-counts
- :selected selected
- :excluded excluded
- :reviewed reviewed
- :collapsed collapsed
- :on-select on-select
- :on-toggle on-toggle
- :on-fold on-fold}]))
- :detail
- (mf/html
- (cond
- (= status :error)
- [:div {:class (stl/css :empty)}
- [:> empty-state* {:icon i/triangle-alert :text (tr "workspace.branches.compare.error")}]]
-
- (not= status :loaded)
- [:div {:class (stl/css :empty)}
- [:> empty-state* {:icon i/git-compare-arrows :text (tr "workspace.branches.compare.loading")}]]
-
- (empty? items)
- [:div {:class (stl/css :empty)}
- [:> empty-state* {:icon i/git-branch :text (tr "workspace.branches.compare.empty")}]]
-
- (= :board (:kind selected))
- [:> board-detail* {:key (dm/str (:page-id selected) "/" (:board-id selected))
- :page-id (:page-id selected)
- :board-id (:board-id selected)
- :groups groups
- :items items
- :cascades cascades
- :open-side open-side
- :data data
- :diff-meta diff-meta
- :selected selected
- :excluded excluded
- :reviewed reviewed
- :on-select on-select
- :on-toggle on-toggle
- :expanded expanded
- :on-expand on-expand}]
-
- sel-item
- [:> item-detail* {:key (:index selected)
- :item sel-item
- :items items
- :indexed indexed
- :cascades cascades
- :copies copies
- :excluded (contains? excluded (:key sel-item))
- :excluded-keys excluded
- :reviewed reviewed
- :selected selected
- :on-select on-select
- :on-toggle on-toggle
- :expanded expanded
- :on-expand on-expand
- :open-side open-side
- :incoming incoming?
- :data data
- :diff-meta diff-meta
- :on-resolve on-resolve}]
-
- :else
- [:div {:class (stl/css :empty)}
- [:> empty-state* {:icon i/git-compare-arrows :text (tr "workspace.branches.compare.select-hint")}]]))
-
- :footer-start
- (when (= status :loaded)
- (mf/html
- [:div {:class (stl/css :footer-start)}
- [:> icon-button* {:variant "ghost"
- :icon i/download
- :aria-label (tr "workspace.branches.compare.export")
- :on-click on-export}]
- [:> text* {:as "span" :typography t/body-small :class (stl/css :footer-status)}
- (str/join " - "
- (remove nil?
- [(tr "workspace.branches.review.footer.reviewed"
- (str reviewed-n) (str (count counted)))
- (when (pos? decisions)
- (tr "workspace.branches.review.footer.blocked" (i18n/c decisions)))
- (when (pos? left-out)
- (tr "workspace.branches.review.footer.left-out" (i18n/c left-out)))]))]]))
- :footer-end
- (when (and (= status :loaded) (seq items))
- (mf/html
- [:*
- [:> button* {:variant "secondary"
- :disabled (not (and pos (pos? pos)))
- :on-click on-previous}
- (tr "workspace.branches.review.action.previous")]
- [:> button* {:variant "secondary"
- :disabled (nil? sel-item)
- :on-click on-mark-next}
- (tr "workspace.branches.review.action.mark-next")]
- primary]))
- :on-close on-close}]))
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branch_review/compare.scss b/frontend/src/app/main/ui/workspace/sidebar/branch_review/compare.scss
deleted file mode 100644
index 17b06b4bd8..0000000000
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/compare.scss
+++ /dev/null
@@ -1,158 +0,0 @@
-// 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) KALEIDOS SUBSIDIARY SL
-
-@use "ds/_borders.scss" as *;
-@use "ds/_sizes.scss" as *;
-
-// --- List
-
-.group {
- display: flex;
- flex-direction: column;
- gap: var(--sp-xxs);
-}
-
-// the DS checkbox keeps room for a label even without one; the slot
-// holds the box alone, so the next item sits one gap away from it
-.row-check {
- display: flex;
- flex-shrink: 0;
- inline-size: $sz-16;
- overflow: visible;
-}
-
-.row-fold {
- display: flex;
- align-items: center;
- padding: 0;
- border: none;
- background: none;
- color: var(--color-foreground-secondary);
- cursor: pointer;
-}
-
-// --- Detail
-//
-// Every block of the detail pane sets `flex-shrink: 0`: the pane is a
-// column that scrolls, and a block allowed to shrink gets clipped
-// instead (the property table did).
-
-.empty {
- display: flex;
- flex: 1;
- align-items: center;
- justify-content: center;
-}
-
-// title and tags on the left, the view modes on the right of the same
-// line
-.detail-head {
- flex-shrink: 0;
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- justify-content: space-between;
- gap: var(--sp-s);
-}
-
-.detail-head-main {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- gap: var(--sp-s);
- min-inline-size: 0;
-}
-
-.detail-title {
- color: var(--color-foreground-primary);
- overflow-wrap: anywhere;
-}
-
-.detail-summary {
- flex-shrink: 0;
- margin: 0;
- color: var(--color-foreground-secondary);
-}
-
-.detail-summary-row {
- display: flex;
- flex-shrink: 0;
- align-items: center;
- justify-content: space-between;
- gap: var(--sp-s);
- min-block-size: $sz-32;
-}
-
-.visual {
- flex-shrink: 0;
- display: flex;
- flex-direction: column;
- gap: var(--sp-m);
-}
-
-.view-modes {
- display: flex;
- align-items: center;
- gap: var(--sp-xxs);
-}
-
-// the ghost icon button of the DS, as the dialog's close button; the
-// view picked reads in the primary foreground, not in the accent
-.view-toggle[aria-pressed="true"] {
- --button-active-fg-color: var(--color-foreground-primary);
-}
-
-.cards {
- display: grid;
- grid-template-columns: repeat(2, minmax(0, 1fr));
- gap: var(--sp-m);
-}
-
-.overlay-stage {
- display: grid;
- inline-size: 100%;
- block-size: 100%;
-}
-
-.overlay-layer {
- display: flex;
- grid-area: 1 / 1;
- align-items: center;
- justify-content: center;
- min-block-size: 0;
-
- &.is-top {
- opacity: 0.5;
- }
-}
-
-.inner-list {
- flex-shrink: 0;
- display: flex;
- flex-direction: column;
- gap: var(--sp-xxs);
- padding: var(--sp-xs);
- border: $b-1 solid var(--color-background-quaternary);
- border-radius: $br-8;
-}
-
-.footer-status {
- color: var(--color-foreground-secondary);
-}
-
-.footer-start {
- display: flex;
- align-items: center;
- gap: var(--sp-s);
-}
-
-.row-warning {
- color: var(--color-accent-warning);
-}
-
-.row-reviewed {
- color: var(--color-foreground-secondary);
-}
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs b/frontend/src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs
deleted file mode 100644
index 2e09fd157c..0000000000
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs
+++ /dev/null
@@ -1,620 +0,0 @@
-;; 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) KALEIDOS SUBSIDIARY SL
-
-(ns app.main.ui.workspace.sidebar.branch-review.conflicts
- "The decisions dialog: one entity both sides changed at a time. Only the
- properties really in conflict ask for a choice; the ones a single side
- changed are filled in from that side, and the dialog says what each
- choice drops before the merge applies it."
- (:require-macros [app.main.style :as stl])
- (:require
- [app.common.data :as d]
- [app.common.data.macros :as dm]
- [app.common.files.branch-merge :as bm]
- [app.common.time :as ct]
- [app.main.data.modal :as modal]
- [app.main.data.workspace.branches :as dwb]
- [app.main.refs :as refs]
- [app.main.store :as st]
- [app.main.ui.ds.buttons.button :refer [button*]]
- [app.main.ui.ds.foundations.assets.icon :as i]
- [app.main.ui.ds.foundations.typography :as t]
- [app.main.ui.ds.foundations.typography.heading :refer [heading*]]
- [app.main.ui.ds.foundations.typography.text :refer [text*]]
- [app.main.ui.ds.product.change-row :refer [change-row*]]
- [app.main.ui.ds.product.empty-state :refer [empty-state*]]
- [app.main.ui.ds.product.filter-chip :refer [filter-chip*]]
- [app.main.ui.ds.product.preview-card :refer [preview-card*]]
- [app.main.ui.ds.product.tag :refer [tag*]]
- [app.main.ui.workspace.sidebar.branch-review.common :as brc]
- [app.main.ui.workspace.sidebar.branch-review.facts :as brf]
- [app.main.ui.workspace.sidebar.branch-review.layout :as brl]
- [app.main.ui.workspace.sidebar.branch-review.previews :as brp]
- [app.util.clipboard :as clipboard]
- [app.util.i18n :as i18n :refer [tr]]
- [cuerdas.core :as str]
- [okulary.core :as l]
- [rumext.v2 :as mf]))
-
-(def ^:private branch-diff
- (l/derived :workspace-branch-diff st/state))
-
-(defn- reason-label
- "Why both sides clash on an entity, or nil for any other reason."
- [reason]
- (case reason
- :modify-modify (tr "workspace.branches.conflicts.reason.modify-modify")
- :add-add (tr "workspace.branches.conflicts.reason.add-add")
- :delete-modify (tr "workspace.branches.conflicts.reason.delete-modify")
- :modify-delete (tr "workspace.branches.conflicts.reason.modify-delete")
- nil))
-
-(defn- text-conflict?
- "A conflict whose text content both sides rewrote."
- [conflict]
- (and (brc/per-attr? conflict)
- (some #(and (= :content (:attr %)) (= :conflict (:source %)))
- (brc/conflict-attr-rows conflict))))
-
-(defn- loses-work?
- "Whether every choice on a text conflict drops a paragraph edit: both
- sides edited different paragraphs."
- [conflict]
- (and (text-conflict? conflict)
- (some #(= :dropped (:status %)) (brc/paragraph-rows conflict :main))
- (some #(= :dropped (:status %)) (brc/paragraph-rows conflict :branch))))
-
-(defn- row-subtitle
- [conflict res]
- (let [rows (brc/conflict-attr-rows conflict)
- conflicting (brc/conflicting-attrs rows)
- drops (brc/dropped-values conflict res)]
- (cond
- (bm/conflict-resolved? conflict res)
- (cond
- (= res :main) (tr "workspace.branches.resolve.row.kept-main")
- (= res :branch) (tr "workspace.branches.resolve.row.kept-branch")
- (seq drops) (tr "workspace.branches.resolve.row.drops"
- (str/lower (str/join ", " (map (comp brc/attr-label :attr) drops))))
- :else (tr "workspace.branches.resolve.row.kept-both"))
-
- (seq conflicting)
- (tr "workspace.branches.resolve.row.both-changed"
- (str/join ", " (map brc/attr-label conflicting)))
-
- :else
- (reason-label (:reason conflict)))))
-
-(mf/defc conflict-row*
- {::mf/private true}
- [{:keys [conflict index selected res on-select]}]
- (let [resolved? (bm/conflict-resolved? conflict res)
- on-click (mf/use-fn (mf/deps index on-select) #(on-select index))]
- [:> change-row* {:title (or (:label conflict) "")
- :subtitle (row-subtitle conflict res)
- :icon (brc/entry-icon conflict)
- :tone (if resolved? "success" "warning")
- :is-selected (= index selected)
- :end (mf/html
- (cond
- resolved?
- [:> tag* {:tone "success" :variant "pill"}
- (tr "workspace.branches.resolve.decided")]
- (loses-work? conflict)
- [:> tag* {:tone "error" :variant "pill"}
- (tr "workspace.branches.resolve.row.loses-work")]
- :else
- [:> i/icon* {:icon-id i/triangle-alert
- :size "s"
- :class (stl/css :row-warning)
- :aria-label (tr "workspace.branches.review.row.choose")}]))
- :on-click on-click}]))
-
-;; --- Property table
-
-(mf/defc pick-button*
- "The value of one side in the property table: a click keeps it."
- {::mf/private true}
- [{:keys [attr side value choice is-conflicting on-pick]}]
- (let [on-click (mf/use-fn (mf/deps attr side on-pick) #(on-pick attr side))]
- [:button {:class (stl/css-case :td-pick true :is-chosen (and is-conflicting (= choice side)))
- :disabled (not is-conflicting)
- :on-click on-click}
- [:> brl/value-chip* {:value value :is-old (not= choice side)}]]))
-
-(mf/defc attr-table*
- "Property | Main | Branch | Result, with the source of each result."
- {::mf/private true}
- [{:keys [rows res on-pick]}]
- [:div {:class (stl/css :table)}
- [:div {:class (stl/css :table-row :is-head)}
- (for [label [(tr "workspace.branches.resolve.th.property")
- (tr "workspace.branches.resolve.th.main")
- (tr "workspace.branches.resolve.th.branch")
- (tr "workspace.branches.resolve.th.result")]]
- [:> text* {:key label :as "span" :typography t/headline-small :class (stl/css :th)} label])
- [:span]]
- (for [{:keys [attr main branch source]} rows
- :let [choice (brc/attr-choice res attr)
- conflicting? (= source :conflict)
- result (case (or choice (when-not conflicting? source))
- :main main
- :branch branch
- nil)
- decided? (some? (or choice (when-not conflicting? source)))]]
- [:div {:class (stl/css-case :table-row true :is-conflicting (and conflicting? (nil? choice)))
- :key (str attr)}
- [:> text* {:as "span" :typography t/body-small :class (stl/css :td-name)}
- (brc/attr-label attr)]
- (if (= source :branch)
- [:> text* {:as "span" :typography t/body-small :class (stl/css :td-unchanged)}
- (tr "workspace.branches.resolve.unchanged")]
- [:> pick-button* {:attr attr
- :side :main
- :value main
- :choice choice
- :is-conflicting conflicting?
- :on-pick on-pick}])
- (if (= source :main)
- [:> text* {:as "span" :typography t/body-small :class (stl/css :td-unchanged)}
- (tr "workspace.branches.resolve.unchanged")]
- [:> pick-button* {:attr attr
- :side :branch
- :value branch
- :choice choice
- :is-conflicting conflicting?
- :on-pick on-pick}])
- (if decided?
- [:span {:class (stl/css :td-result)}
- [:> brl/value-chip* {:value result}]]
- [:> text* {:as "span" :typography t/body-small :class (stl/css :td-choose)}
- (tr "workspace.branches.resolve.choose-side")])
- [:span {:class (stl/css :td-tag)}
- (cond
- ;; a decided conflict is done (green); an independent edit takes the
- ;; colour of the side it comes from, as the preview cards do
- (and conflicting? choice)
- [:> tag* {:tone "success"} (tr "workspace.branches.resolve.tag.your-choice")]
- conflicting?
- [:> tag* {:tone "warning"} (tr "workspace.branches.resolve.tag.conflict")]
- (= source :main)
- [:> tag* {:tone "purple"} (tr "workspace.branches.resolve.tag.from-main")]
- :else
- [:> tag* {:tone "accent"} (tr "workspace.branches.resolve.tag.from-branch")])]])])
-
-;; --- Whole-version and text choices
-
-(mf/defc option-card*
- "A choice between the two versions, as a radio card."
- {::mf/private true}
- [{:keys [label side detail is-chosen warning on-choose children]}]
- (let [on-click (mf/use-fn (mf/deps side on-choose) #(on-choose side))]
- [:button {:class (stl/css-case :option true :is-chosen is-chosen)
- :role "radio"
- :aria-checked (boolean is-chosen)
- :on-click on-click}
- [:div {:class (stl/css :option-head)}
- [:span {:class (stl/css-case :option-radio true :is-chosen is-chosen) :aria-hidden true}]
- [:> text* {:as "span" :typography t/body-small :class (stl/css :option-label)} label]]
- [:div {:class (stl/css :option-side)}
- [:> text* {:as "span" :typography t/headline-small
- :class (stl/css-case :option-side-label true :is-main (= side :main))}
- (if (= side :main)
- (tr "workspace.branches.review.side.main")
- (tr "workspace.branches.review.side.branch"))]
- (when detail
- [:> text* {:as "span" :typography t/body-small :class (stl/css :option-detail)} detail])]
- children
- (when warning
- [:span {:class (stl/css :option-warning)}
- [:> i/icon* {:icon-id i/triangle-alert :size "s"}]
- warning])]))
-
-(mf/defc paragraph-list*
- {::mf/private true}
- [{:keys [rows]}]
- [:div {:class (stl/css :paragraphs)}
- (for [{:keys [index text status]} rows]
- [:> text* {:key index
- :as "span"
- :typography t/body-small
- :class (stl/css-case :paragraph true
- :is-kept (= status :kept)
- :is-dropped (= status :dropped))}
- (dm/str "¶" (inc index) " " text)])])
-
-(defn- dropped-paragraphs
- "The paragraph edits keeping `side` drops."
- [conflict side]
- (let [other (if (= side :main) :branch :main)]
- (filterv #(= :kept (:status %)) (brc/paragraph-rows conflict other))))
-
-(mf/defc text-choice*
- {::mf/private true}
- [{:keys [conflict res main-detail branch-detail on-pick]}]
- (let [choice (brc/attr-choice res :content)
- on-choose (mf/use-fn (mf/deps on-pick) #(on-pick :content %))
- on-copy (mf/use-fn
- (mf/deps conflict choice)
- (fn []
- (when choice
- (let [lost (dropped-paragraphs conflict choice)]
- (-> (clipboard/to-clipboard (str/join "\n" (map :text lost)))
- (.catch (constantly nil)))))))]
- [:*
- [:div {:class (stl/css :options)}
- (for [side [:main :branch]
- :let [lost (dropped-paragraphs conflict side)]]
- [:> option-card* {:key (name side)
- :label (if (= side :main)
- (tr "workspace.branches.resolve.keep-main-text")
- (tr "workspace.branches.resolve.keep-branch-text"))
- :side side
- :detail (if (= side :main) main-detail branch-detail)
- :is-chosen (= choice side)
- :warning (when (seq lost)
- (tr "workspace.branches.resolve.drops-paragraphs"
- (str/join ", " (map #(dm/str "¶" (inc (:index %))) lost))))
- :on-choose on-choose}
- [:> paragraph-list* {:rows (brc/paragraph-rows conflict side)}]])]
- (when (and choice (seq (dropped-paragraphs conflict choice)))
- [:div {:class (stl/css :inline-actions)}
- [:> text* {:as "span" :typography t/body-small :class (stl/css :muted)}
- (tr "workspace.branches.resolve.keep-safe")]
- [:> button* {:variant "secondary" :on-click on-copy}
- (tr "workspace.branches.resolve.copy-dropped")]])]))
-
-(mf/defc whole-choice*
- "The choice for a conflict that cannot be split by property: one side
- deleted the entity, or both added it differently."
- {::mf/private true}
- [{:keys [conflict res main-detail branch-detail on-choose]}]
- [:div {:class (stl/css :options)}
- (for [side [:main :branch]
- :let [value (get conflict side)]]
- [:> option-card* {:key (name side)
- :label (if (= side :main)
- (tr "workspace.branches.resolve.keep-main-version")
- (tr "workspace.branches.resolve.keep-branch-version"))
- :side side
- :detail (if (= side :main) main-detail branch-detail)
- :is-chosen (= res side)
- :warning (when (nil? value)
- (tr "workspace.branches.resolve.deletes-it"))
- :on-choose on-choose}
- [:div {:class (stl/css :option-stage)}
- [:> brp/entity-preview* {:kind (:kind conflict)
- :value value
- :missing {:reason :deleted :side side}}]]])])
-
-;; --- Detail
-
-(mf/defc attr-actions*
- "The two sides of a property in conflict, as buttons that keep one."
- {::mf/private true}
- [{:keys [attr main branch res on-pick]}]
- (let [choice (brc/attr-choice res attr)
- on-main (mf/use-fn (mf/deps attr on-pick) #(on-pick attr :main))
- on-branch (mf/use-fn (mf/deps attr on-pick) #(on-pick attr :branch))]
- [:div {:class (stl/css :inline-actions)}
- [:> text* {:as "span" :typography t/body-small :class (stl/css :muted)}
- (dm/str (brc/attr-label attr) ":")]
- [:> button* {:variant (if (= choice :main) "primary" "secondary")
- :on-click on-main}
- (tr "workspace.branches.resolve.keep-main" (brc/display-val main))]
- [:> button* {:variant (if (= choice :branch) "primary" "secondary")
- :on-click on-branch}
- (tr "workspace.branches.resolve.keep-branch" (brc/display-val branch))]]))
-
-(mf/defc conflict-detail*
- {::mf/private true}
- [{:keys [conflict res diff-meta copies data on-pick on-choose on-clear]}]
- (let [rows (brc/conflict-attr-rows conflict)
- copies-of (mf/with-memo [copies conflict data]
- (brc/copies-entry copies conflict
- (get-in data [:pages-index (:page-id conflict) :objects])))
- per-attr? (brc/per-attr? conflict)
- text? (text-conflict? conflict)
- table-rows (if text? (filterv #(not= :content (:attr %)) rows) rows)
- conflict-n (count (brc/conflicting-attrs rows))
- indep-n (- (count rows) conflict-n)
- resolved? (bm/conflict-resolved? conflict res)
- drops (when resolved? (brc/dropped-values conflict res))
- main-detail (some-> (:main-at diff-meta) ct/inst ct/timeago)
- branch-detail (some-> (:branch-at diff-meta) ct/inst ct/timeago)
- prefill (brc/prefill-resolution conflict)
- result (when per-attr?
- (reduce (fn [entity attr]
- (let [side (or (brc/attr-choice res attr)
- (get prefill attr)
- :main)
- v (get-in conflict [side attr])]
- (if (nil? v) (dissoc entity attr) (assoc entity attr v))))
- (:main conflict)
- (keys (:changed-attrs conflict))))]
- [:*
- [:div {:class (stl/css :detail-head)}
- [:> heading* {:level 3 :typography t/body-large :class (stl/css :detail-title)}
- (:label conflict)]
- (if resolved?
- [:> tag* {:tone "success"} (tr "workspace.branches.resolve.decided")]
- [:> tag* {:tone "warning"}
- (if per-attr?
- (dm/str (tr "workspace.branches.resolve.tag.conflicts" (i18n/c conflict-n))
- (when (pos? indep-n)
- (dm/str " - " (tr "workspace.branches.resolve.tag.independent" (i18n/c indep-n)))))
- (or (reason-label (:reason conflict))
- (tr "workspace.branches.status.conflict")))])]
-
- ;; what each side looks like comes first: the previews, or the two
- ;; versions to pick from when the entity cannot be split by property
- (cond
- (not per-attr?)
- [:> whole-choice* {:conflict conflict :res res
- :main-detail main-detail :branch-detail branch-detail
- :on-choose on-choose}]
-
- text?
- [:> text-choice* {:conflict conflict :res res
- :main-detail main-detail :branch-detail branch-detail
- :on-pick on-pick}]
-
- :else
- [:div {:class (stl/css :cards)}
- [:> preview-card* {:label (tr "workspace.branches.review.side.main")
- :side "main" :detail main-detail}
- [:> brp/entity-preview* {:kind (:kind conflict)
- :value (:main conflict)
- :missing {:reason :deleted :side :main}}]]
- [:> preview-card* {:label (tr "workspace.branches.review.side.branch")
- :side "branch" :detail branch-detail}
- [:> brp/entity-preview* {:kind (:kind conflict)
- :value (:branch conflict)
- :missing {:reason :deleted :side :branch}}]]
- [:> preview-card* {:label (tr "workspace.branches.review.side.result")
- :side "result"}
- [:> brp/entity-preview* {:kind (:kind conflict) :value result}]]])
-
- (when (and per-attr? (seq table-rows))
- [:> attr-table* {:rows table-rows :res res :on-pick on-pick}])
-
- (when per-attr?
- (for [{:keys [attr main branch source]} rows
- :when (and (= :conflict source) (not= attr :content))]
- [:> attr-actions* {:key (str attr)
- :attr attr
- :main main
- :branch branch
- :res res
- :on-pick on-pick}]))
-
- ;; the copy rule: what it decided on this copy, how many copies a
- ;; choice on a main decides, and which copies follow the component
- (when (:settled conflict)
- [:> brf/settled-facts* {:settled (:settled conflict) :is-conflict true}])
- (when (:copies-affected conflict)
- [:> brf/copies-affected* {:n (:copies-affected conflict)}])
- (when copies-of
- [:> brf/copies-facts* {:entry copies-of :copies copies :data data}])
-
- ;; once decided, one quiet block says what the merge leaves behind,
- ;; with the way back; until then, a note says how the choice works
- (if resolved?
- [:div {:class (stl/css :outcome)}
- [:div {:class (stl/css :outcome-text)}
- [:> text* {:as "span" :typography t/body-small :class (stl/css :outcome-title)}
- (tr "workspace.branches.resolve.drops.title")]
- (if (seq drops)
- (for [{:keys [attr side value]} drops]
- [:> text* {:key (str attr)
- :as "span"
- :typography t/body-small
- :class (stl/css :outcome-line)}
- (if (= side :main)
- (tr "workspace.branches.resolve.drops.main-short" (str/lower (brc/attr-label attr)))
- (tr "workspace.branches.resolve.drops.branch-short" (str/lower (brc/attr-label attr))))
- " "
- [:span {:class (stl/css :outcome-dropped)} (brc/display-val value)]])
- [:> text* {:as "span" :typography t/body-small :class (stl/css :outcome-line)}
- (tr "workspace.branches.resolve.drops.none")])]
- [:> button* {:variant "ghost" :on-click on-clear}
- (tr "workspace.branches.resolve.change-choice")]]
-
- [:div {:class (stl/css :footnote)}
- [:> i/icon* {:icon-id i/info :size "s" :class (stl/css :footnote-icon)}]
- [:> text* {:as "p" :typography t/body-small :class (stl/css :footnote-text)}
- (cond
- text? (tr "workspace.branches.resolve.intro-text")
- per-attr? (tr "workspace.branches.resolve.intro-attrs")
- :else (tr "workspace.branches.resolve.intro-whole"))]])]))
-
-;; --- The dialog
-
-(mf/defc branch-conflicts-dialog*
- {::mf/register modal/components
- ::mf/register-as :branch-conflicts}
- [{:keys [branch mode conflicts excluded comment]}]
- (let [{:keys [diff resolutions status]} (mf/deref branch-diff)
- data (mf/deref refs/workspace-data)
- copies (:copies diff)
-
- loading? (= status :loading)
- selected* (mf/use-state 0)
- selected (deref selected*)
-
- diff-meta (:meta diff)
-
- ;; the command that opened this modal returned its own conflict set,
- ;; computed in the id space it resolves against; the diff this dialog
- ;; can fetch may have been computed in another id space and disagree,
- ;; which left the dialog showing 0 of 0 with an Apply that could never
- ;; enable. Prefer what the command said.
- conflicts (if (seq conflicts) conflicts (:conflicts diff))
-
- ;; the payload's two sides are document-keyed in both directions:
- ;; `:main` holds main's value and `:branch` the branch's
- ;; (`branch-merge.cljc::compute-merge`), which is what every heading,
- ;; chip and button below names. Resolutions use the same vocabulary.
- resolutions (or resolutions {})
- total (count conflicts)
- resolved? (fn [c] (bm/conflict-resolved? c (get resolutions (:id c))))
- resolved (count (filterv resolved? conflicts))
- pending (- total resolved)
- all-done? (and (pos? total) (zero? pending))
-
- sel-idx (min selected (max 0 (dec total)))
- sel (when (seq conflicts) (nth conflicts sel-idx))
- sel-res (when sel (get resolutions (:id sel)))
-
- on-close (mf/use-fn #(st/emit! (modal/hide)))
- on-back (mf/use-fn (mf/deps branch)
- #(modal/show! :branch-compare {:branch branch}))
- on-select (mf/use-fn #(reset! selected* %))
- on-pick (mf/use-fn
- (mf/deps sel sel-res)
- (fn [attr side]
- (when sel
- (st/emit! (dwb/set-conflict-resolutions
- {(:id sel) (brc/choose-attr sel sel-res attr side)})))))
- on-choose (mf/use-fn
- (mf/deps sel)
- (fn [side]
- (when sel
- (st/emit! (dwb/set-conflict-resolution (:id sel) side)))))
- on-clear (mf/use-fn
- (mf/deps sel)
- (fn []
- (when sel
- (st/emit! (dwb/clear-conflict-resolution (:id sel))
- (dwb/set-conflict-resolutions
- (if (brc/per-attr? sel)
- {(:id sel) (brc/prefill-resolution sel)}
- {}))))))
- on-all (mf/use-fn
- (mf/deps conflicts)
- (fn [side]
- (st/emit! (dwb/set-conflict-resolutions
- (into {} (map (fn [c] [(:id c) (brc/choose-side c side)]))
- conflicts)))))
- on-all-main (mf/use-fn (mf/deps on-all) #(on-all :main))
- on-all-branch (mf/use-fn (mf/deps on-all) #(on-all :branch))
- indexed (mf/with-memo [conflicts]
- (into [] d/xf:add-index conflicts))
- on-next (mf/use-fn
- (mf/deps conflicts sel-idx resolutions)
- (fn []
- (let [n (count conflicts)
- order (map #(mod (+ sel-idx 1 %) n) (range n))
- next-ix (some #(when-not (bm/conflict-resolved?
- (nth conflicts %)
- (get resolutions (:id (nth conflicts %))))
- %)
- order)]
- (when next-ix (reset! selected* next-ix)))))
- on-apply (mf/use-fn
- ;; a merge sends again the comment of the merge dialog
- (mf/deps branch resolutions mode excluded comment conflicts)
- (fn []
- (let [ids (into #{} (map :id) conflicts)
- res (into {} (filter (fn [[id _]] (contains? ids id))) resolutions)]
- (st/emit! (if (= mode :update)
- (dwb/update-branch-from-main branch {:resolutions res
- :excluded excluded})
- (dwb/merge-branch branch {:resolutions res
- :comment comment
- :excluded excluded}))))))]
-
- ;; the fetched diff backs both the fallback conflict set and the side
- ;; subtitles, so it must be computed in the direction this modal resolves
- (mf/with-effect [(:id branch) mode]
- (st/emit! (dwb/fetch-branch-diff (:id branch)
- (if (= mode :update) :main->branch :branch->main))))
-
- ;; independent edits are not in doubt: fill them in from the side that
- ;; made them, so only the conflicting properties wait for a choice
- (mf/with-effect [conflicts status]
- (when (and (seq conflicts) (not loading?))
- (let [seed (into {}
- (keep (fn [c]
- (when (and (brc/per-attr? c)
- (nil? (get resolutions (:id c))))
- [(:id c) (brc/prefill-resolution c)])))
- conflicts)]
- (when (seq seed)
- (st/emit! (dwb/set-conflict-resolutions seed))))))
-
- [:> brl/review-modal*
- {:icon i/triangle-alert
- :tone :warning
- :title (tr "workspace.branches.resolve.title")
- :route (mf/html [:> brl/route* {:branch-name (:name branch)
- :incoming (= mode :update)}])
- :filters (mf/html
- [:> filter-chip* {:icon i/triangle-alert
- :label (dm/str (tr "workspace.branches.review.category.decisions")
- " (" total ")")
- :tone "warning"
- :is-selected true}])
- :list (when (and (not loading?) (seq conflicts))
- (mf/html
- [:*
- ;; deciding them all at once only means something with
- ;; more than one decision
- (when (> total 1)
- [:div {:class (stl/css :bulk)}
- [:> button* {:variant "secondary" :on-click on-all-main}
- (tr "workspace.branches.resolve.keep-all-main")]
- [:> button* {:variant "secondary" :on-click on-all-branch}
- (tr "workspace.branches.resolve.keep-all-branch")]])
- [:> brl/group-head* {:label (tr "workspace.branches.review.group.decisions" (str total))
- :is-open true}]
- (for [c indexed]
- [:> conflict-row* {:key (::d/index c)
- :conflict c
- :index (::d/index c)
- :selected sel-idx
- :res (get resolutions (:id c))
- :on-select on-select}])]))
- :detail
- (mf/html
- (cond
- loading?
- [:div {:class (stl/css :empty)}
- [:> empty-state* {:icon i/git-merge :text (tr "workspace.branches.compare.loading")}]]
-
- (empty? conflicts)
- [:div {:class (stl/css :empty)}
- [:> empty-state* {:icon i/git-merge :text (tr "workspace.branches.conflicts.empty")}]]
-
- sel
- [:> conflict-detail* {:key (str (:id sel))
- :conflict sel
- :res sel-res
- :diff-meta diff-meta
- :copies copies
- :data data
- :on-pick on-pick
- :on-choose on-choose
- :on-clear on-clear}]))
- :footer-start
- (mf/html
- (if all-done?
- [:div {:class (stl/css :footer-start)}
- [:> text* {:as "span" :typography t/body-small :class (stl/css :footer-ready)}
- (tr "workspace.branches.conflicts.footer-ready")]]
- [:> text* {:as "span" :typography t/body-small :class (stl/css :footer-blocked)}
- (tr "workspace.branches.resolve.footer.blocked" (i18n/c pending))]))
- :footer-end
- (mf/html
- [:*
- [:> button* {:variant "secondary" :on-click on-back}
- (tr "workspace.branches.resolve.back")]
- (if all-done?
- [:> button* {:variant "primary" :icon i/git-merge :on-click on-apply}
- (tr "workspace.branches.conflicts.apply")]
- [:> button* {:variant "primary" :on-click on-next}
- (tr "workspace.branches.resolve.next")])])
- :on-close on-close}]))
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branch_review/conflicts.scss b/frontend/src/app/main/ui/workspace/sidebar/branch_review/conflicts.scss
deleted file mode 100644
index 7b906cbb49..0000000000
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/conflicts.scss
+++ /dev/null
@@ -1,340 +0,0 @@
-// 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) KALEIDOS SUBSIDIARY SL
-
-@use "ds/_borders.scss" as *;
-@use "ds/_sizes.scss" as *;
-@use "ds/_utils.scss" as *;
-@use "ds/mixins.scss" as *;
-
-.empty {
- display: flex;
- flex: 1;
- align-items: center;
- justify-content: center;
-}
-
-.bulk {
- display: grid;
- grid-template-columns: repeat(2, minmax(0, 1fr));
- gap: var(--sp-xs);
- margin-block-end: var(--sp-xs);
-}
-
-.detail-head {
- flex-shrink: 0;
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- gap: var(--sp-s);
-}
-
-.detail-title {
- color: var(--color-foreground-primary);
- overflow-wrap: anywhere;
-}
-
-.muted {
- color: var(--color-foreground-secondary);
-}
-
-.outcome {
- display: flex;
- flex-shrink: 0;
- align-items: center;
- gap: var(--sp-m);
- padding: var(--sp-s) var(--sp-s) var(--sp-s) var(--sp-m);
- border: $b-1 solid var(--color-background-quaternary);
- border-radius: $br-8;
- background-color: var(--color-background-tertiary);
-}
-
-.outcome-text {
- display: flex;
- flex: 1;
- flex-direction: column;
- gap: var(--sp-xxs);
- min-inline-size: 0;
-}
-
-.outcome-title {
- color: var(--color-foreground-primary);
-}
-
-.outcome-line {
- color: var(--color-foreground-secondary);
-}
-
-// only the value that is lost takes the error colour
-.outcome-dropped {
- color: var(--color-accent-error);
-}
-
-.footnote {
- display: flex;
- flex-shrink: 0;
- align-items: flex-start;
- gap: var(--sp-xs);
- margin-block-start: auto;
- padding-block-start: var(--sp-s);
- color: var(--color-foreground-secondary);
-}
-
-.footnote-icon {
- flex-shrink: 0;
-}
-
-.footnote-text {
- margin: 0;
-}
-
-// --- Property table
-
-.table {
- flex-shrink: 0;
- display: flex;
- flex-direction: column;
- overflow: hidden;
- border: $b-1 solid var(--color-background-quaternary);
- border-radius: $br-8;
- background-color: var(--color-background-tertiary);
-}
-
-.table-row {
- --table-row-bg-color: transparent;
-
- display: grid;
- grid-template-columns: minmax(0, 1.2fr) repeat(3, minmax(0, 1fr)) px2rem(100);
- align-items: center;
- gap: var(--sp-s);
- min-block-size: $sz-40;
- padding: var(--sp-xs) var(--sp-m);
- background-color: var(--table-row-bg-color);
-
- &.is-head {
- --table-row-bg-color: var(--color-background-secondary);
- }
-
- &.is-conflicting {
- --table-row-bg-color: var(--color-background-warning);
- }
-}
-
-.th {
- color: var(--color-foreground-secondary);
-}
-
-.td-name {
- @include text-ellipsis;
-
- color: var(--color-foreground-primary);
-
- // TODO: No exact DS typography match found.
- // Closest match: body-small (weight 500 vs 400).
- font-weight: 500;
-}
-
-.td-unchanged {
- color: var(--color-foreground-secondary);
-}
-
-// the button hugs its value chip, and the selection outline sits right
-// on the chip's own border instead of around the cell
-.td-pick {
- display: inline-flex;
- justify-self: start;
- min-inline-size: 0;
- max-inline-size: 100%;
- padding: 0;
- border: none;
- border-radius: $br-4;
- background: none;
- cursor: pointer;
-
- &:disabled {
- cursor: default;
- }
-
- &:not(:disabled):hover,
- &.is-chosen {
- outline: $b-1 solid var(--color-accent-primary);
- outline-offset: calc(#{$b-1} * -1);
- }
-}
-
-.td-result {
- display: inline-flex;
- justify-self: start;
- min-inline-size: 0;
- max-inline-size: 100%;
-}
-
-.td-choose {
- color: var(--color-accent-warning);
-}
-
-.td-tag {
- display: flex;
- justify-content: flex-end;
-}
-
-.inline-actions {
- flex-shrink: 0;
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- gap: var(--sp-s);
-}
-
-.cards {
- flex-shrink: 0;
- display: grid;
- grid-template-columns: repeat(3, minmax(0, 1fr));
- gap: var(--sp-m);
-}
-
-// --- Version cards
-
-.options {
- flex-shrink: 0;
- display: grid;
- grid-template-columns: repeat(2, minmax(0, 1fr));
- gap: var(--sp-m);
-}
-
-.option {
- --option-border-color: var(--color-background-quaternary);
-
- display: flex;
- flex-direction: column;
- gap: var(--sp-s);
- padding: var(--sp-m);
- border: $b-1 solid var(--option-border-color);
- border-radius: $br-8;
- background-color: var(--color-background-tertiary);
- color: var(--color-foreground-primary);
- text-align: start;
- cursor: pointer;
-
- &:hover {
- --option-border-color: var(--color-foreground-secondary);
- }
-
- &.is-chosen {
- --option-border-color: var(--color-accent-primary);
- }
-
- &:focus-visible {
- outline: $b-1 solid var(--color-accent-primary);
- }
-}
-
-.option-head {
- display: flex;
- align-items: center;
- gap: var(--sp-s);
-}
-
-.option-radio {
- --option-radio-border-color: var(--color-foreground-secondary);
- --option-radio-border-width: #{$b-2};
-
- flex-shrink: 0;
- inline-size: $sz-16;
- block-size: $sz-16;
- border: var(--option-radio-border-width) solid var(--option-radio-border-color);
- border-radius: $br-circle;
-
- &.is-chosen {
- --option-radio-border-color: var(--color-accent-primary);
- --option-radio-border-width: #{px2rem(4)};
- }
-}
-
-.option-label {
- // TODO: 600 is not a weight of the DS typographies.
- font-weight: 600;
-}
-
-.option-side {
- display: flex;
- align-items: center;
- gap: var(--sp-xs);
-}
-
-.option-side-label {
- --option-side-label-color: var(--color-accent-primary);
-
- color: var(--option-side-label-color);
-
- &.is-main {
- --option-side-label-color: var(--color-accent-secondary);
- }
-}
-
-.option-detail {
- color: var(--color-foreground-secondary);
-}
-
-.option-stage {
- @include transparency-checkerboard;
-
- display: flex;
- align-items: center;
- justify-content: center;
- block-size: var(--preview-card-stage-block-size, #{px2rem(100)});
- padding: var(--sp-s);
- border-radius: $br-6;
-}
-
-.option-warning {
- display: flex;
- align-items: center;
- gap: var(--sp-xs);
- color: var(--color-accent-error);
-}
-
-.paragraphs {
- display: flex;
- flex-direction: column;
- gap: var(--sp-xs);
-}
-
-.paragraph {
- --paragraph-bg-color: transparent;
-
- padding: var(--sp-s);
- border-radius: $br-4;
- background-color: var(--paragraph-bg-color);
- color: var(--color-foreground-primary);
-
- &.is-kept {
- --paragraph-bg-color: var(--color-background-success);
- }
-
- &.is-dropped {
- --paragraph-bg-color: var(--color-background-error);
- }
-}
-
-// --- Footer
-
-.footer-start {
- display: flex;
- align-items: center;
- gap: var(--sp-l);
-}
-
-.footer-ready {
- color: var(--color-accent-success);
-}
-
-.footer-blocked {
- color: var(--color-accent-warning);
-}
-
-.row-warning {
- color: var(--color-accent-warning);
-}
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branch_review/detail.cljs b/frontend/src/app/main/ui/workspace/sidebar/branch_review/detail.cljs
new file mode 100644
index 0000000000..9ff5876e9b
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/sidebar/branch_review/detail.cljs
@@ -0,0 +1,427 @@
+;; 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) KALEIDOS SUBSIDIARY SL
+
+(ns app.main.ui.workspace.sidebar.branch-review.detail
+ "The detail of the entry chosen in a comparison. A change says what it
+ did, property by property, as `before → after`, and what else comes
+ with it. A conflict shows the two sides of each property: only the
+ ones really in conflict ask for a choice, the ones a single side
+ changed are filled in from that side, and the detail says what each
+ choice drops before it is applied."
+ (:require-macros [app.main.style :as stl])
+ (:require
+ [app.common.data.macros :as dm]
+ [app.common.files.branch-merge :as bm]
+ [app.main.ui.ds.buttons.button :refer [button*]]
+ [app.main.ui.ds.foundations.assets.icon :as i]
+ [app.main.ui.ds.foundations.typography :as t]
+ [app.main.ui.ds.foundations.typography.heading :refer [heading*]]
+ [app.main.ui.ds.foundations.typography.text :refer [text*]]
+ [app.main.ui.ds.product.branch-pill :refer [branch-pill*]]
+ [app.main.ui.ds.product.tag :refer [tag*]]
+ [app.main.ui.workspace.sidebar.branch-review.common :as brc]
+ [app.main.ui.workspace.sidebar.branch-review.facts :as brf]
+ [app.main.ui.workspace.sidebar.branch-review.layout :as brl]
+ [app.util.clipboard :as clipboard]
+ [app.util.dom :as dom]
+ [app.util.i18n :as i18n :refer [tr]]
+ [cuerdas.core :as str]
+ [rumext.v2 :as mf]))
+
+;; --- Head
+
+(defn- place
+ "Where entry `item` is, in words: its page and top board for a layer,
+ the name of its type for anything else."
+ [item data]
+ (if (= :shape (:kind item))
+ (let [page (get-in data [:pages-index (:page-id item)])
+ board (brc/top-board (:objects page) (:id item))]
+ (str/join " / " (remove nil? [(:name page) (:name board)])))
+ (brc/type-label item)))
+
+(mf/defc detail-head*
+ "The name of the entry with its tags (`children`) and, under them, where
+ it is and what happened to it."
+ {::mf/private true}
+ [{:keys [title place summary children]}]
+ [:div {:class (stl/css :head)}
+ [:div {:class (stl/css :head-row)}
+ [:> heading* {:level 3 :typography t/body-large :class (stl/css :title)} title]
+ children]
+ [:> text* {:as "p" :typography t/body-small :class (stl/css :summary)}
+ (str/join " - " (remove str/blank? [place summary]))]])
+
+(mf/defc status-tag*
+ {::mf/private true}
+ [{:keys [status]}]
+ (case status
+ :added [:> tag* {:tone "success"} (tr "workspace.branches.status.added")]
+ :deleted [:> tag* {:tone "error"} (tr "workspace.branches.status.deleted")]
+ :conflict [:> tag* {:tone "warning"} (tr "workspace.branches.status.conflict")]
+ :settled [:> tag* {} (tr "workspace.branches.review.copies.settled-tag")]
+ [:> tag* {:tone "info"} (tr "workspace.branches.status.modified")]))
+
+;; --- A change
+
+(mf/defc change-detail*
+ "What the change `item` did. `on-edit` leaves the comparison to edit its
+ layer and `on-toggle` leaves the change out of the merge or takes it
+ back in; each button shows only with its handler."
+ [{:keys [item items inner copies data open-side incoming excluded on-edit on-toggle on-resolve]}]
+ (let [visible (brc/visible-attrs (:changed-attrs item))
+ conflict? (brc/conflict? item)
+ copies-of (mf/with-memo [copies item data]
+ (brc/copies-entry copies item
+ (get-in data [:pages-index (:page-id item) :objects])))]
+ [:div {:class (stl/css :detail)}
+ [:> detail-head* {:title (:label item)
+ :place (place item data)
+ :summary (when-not (bm/settled? item) (brc/change-summary item))}
+ [:> status-tag* {:status (:status item)}]
+ (when excluded
+ [:> tag* {:tone "info"} (tr "workspace.branches.review.row.left-out")])]
+
+ (when conflict?
+ [:> brl/notice* {:level :warning}
+ (tr "workspace.branches.review.decision.body")])
+
+ ;; a copy the copy rule settled changes nothing: its section below
+ ;; says what the rule decided instead
+ (when-not (bm/settled? item)
+ (if (seq visible)
+ [:div {:class (stl/css :section)}
+ [:> brl/value-steps* {:attrs visible :incoming incoming}]]
+ (when (= :modified (:status item))
+ [:> text* {:as "p" :typography t/body-small :class (stl/css :summary)}
+ (tr "workspace.branches.compare.no-props")])))
+
+ ;; the copy rule: what it decided on this copy, how many copies a
+ ;; choice on a main decides, and which copies follow the component
+ (when (:settled item)
+ [:> brf/settled-facts* {:settled (:settled item)
+ :is-conflict conflict?
+ :is-settled (bm/settled? item)}])
+ (when (and conflict? (:copies-affected item))
+ [:> brf/copies-affected* {:n (:copies-affected item)}])
+ (when copies-of
+ [:> brf/copies-facts* {:entry copies-of :copies copies :data data}])
+
+ ;; an entry without a before and after says what it is, where it
+ ;; lands and what it affects instead
+ (when-not conflict?
+ (case (:kind item)
+ :page
+ (when (contains? #{:added :deleted} (:status item))
+ [:> brf/page-facts* {:item item :data data :incoming incoming}])
+
+ :shape
+ (when (contains? #{:added :deleted} (:status item))
+ [:> brf/shape-facts* {:item item :items items :data data :inner inner
+ :open-side open-side :incoming incoming}])
+
+ (:component :color :typography :token)
+ [:> brf/usage-facts* {:item item :data data}]
+
+ nil))
+
+ (when (or on-edit on-toggle on-resolve)
+ [:div {:class (stl/css :section :stacked-actions)}
+ (when on-edit
+ [:> button* {:variant "secondary" :class (stl/css :wide-action) :on-click on-edit}
+ (tr "workspace.compare.action.edit-layer")])
+ (when on-toggle
+ [:> button* {:variant "secondary" :class (stl/css :wide-action) :on-click on-toggle}
+ (cond
+ (and excluded incoming) (tr "workspace.compare.action.include-update")
+ excluded (tr "workspace.compare.action.include-merge")
+ incoming (tr "workspace.compare.action.leave-out-update")
+ :else (tr "workspace.compare.action.leave-out-merge"))])
+ (when on-resolve
+ [:> button* {:variant "secondary" :class (stl/css :wide-action) :on-click on-resolve}
+ (tr "workspace.branches.review.row.choose")])])]))
+
+;; --- A choice between the two sides
+
+(mf/defc side-pill*
+ "The name of a side: main, or the branch by its name."
+ [{:keys [side branch-name is-review]}]
+ (if (= side :main)
+ [:> branch-pill* {:label (tr "workspace.branches.main") :is-main true}]
+ [:> branch-pill* {:label (or branch-name (tr "workspace.branches.review.side.branch"))
+ :is-review (boolean is-review)}]))
+
+(mf/defc option-card*
+ "One of the two sides of a choice, as a radio card: the side it keeps,
+ what that side holds (`children`) and what keeping it costs
+ (`warning`). `on-preview` hears when the pointer enters (with the side)
+ and leaves (with nil)."
+ [{:keys [side branch-name is-review is-chosen warning on-choose on-preview children]}]
+ (let [on-click (mf/use-fn (mf/deps side on-choose) #(on-choose side))
+ on-enter (mf/use-fn (mf/deps side on-preview) #(when on-preview (on-preview side)))
+ on-leave (mf/use-fn (mf/deps on-preview) #(when on-preview (on-preview nil)))]
+ [:button {:class (stl/css-case :option true :is-chosen is-chosen)
+ :role "radio"
+ :aria-checked (boolean is-chosen)
+ :on-click on-click
+ :on-pointer-enter on-enter
+ :on-pointer-leave on-leave}
+ [:> side-pill* {:side side :branch-name branch-name :is-review is-review}]
+ children
+ (when warning
+ [:span {:class (stl/css :option-warning)}
+ [:> i/icon* {:icon-id i/triangle-alert :size "s"}]
+ [:> text* {:as "span" :typography t/body-small} warning]])]))
+
+(mf/defc attr-options*
+ "The two values of the property `attr` of a conflict, to keep one."
+ [{:keys [conflict res attr branch-name is-review on-pick on-preview]}]
+ (let [choice (brc/attr-choice res attr)
+ values (get-in conflict [:changed-attrs attr])
+ on-choose (mf/use-fn (mf/deps attr on-pick) #(on-pick attr %))]
+ [:div {:class (stl/css :options) :role "radiogroup"}
+ (for [side [:main :branch]]
+ [:> option-card* {:key (name side)
+ :side side
+ :branch-name branch-name
+ :is-review is-review
+ :is-chosen (= choice side)
+ :on-choose on-choose
+ :on-preview on-preview}
+ [:> brl/value-chip* {:value (get values side)}]])]))
+
+(mf/defc text-options*
+ "The two texts of a text conflict, to keep one whole: Penpot keeps one
+ text, so each card counts its paragraphs and says which edits of the
+ other side it drops. `show-paragraphs` lists them too."
+ [{:keys [conflict res branch-name is-review show-paragraphs on-pick on-preview]}]
+ (let [choice (brc/attr-choice res :content)
+ on-choose (mf/use-fn (mf/deps on-pick) #(on-pick :content %))]
+ [:div {:class (stl/css :options) :role "radiogroup"}
+ (for [side [:main :branch]
+ :let [rows (brc/paragraph-rows conflict side)
+ lost (brc/dropped-paragraphs conflict side)]]
+ [:> option-card* {:key (name side)
+ :side side
+ :branch-name branch-name
+ :is-review is-review
+ :is-chosen (= choice side)
+ :warning (when (seq lost)
+ (tr "workspace.branches.resolve.drops-paragraphs"
+ (str/join ", " (map #(dm/str "¶" (inc (:index %))) lost))))
+ :on-choose on-choose
+ :on-preview on-preview}
+ (if show-paragraphs
+ [:div {:class (stl/css :paragraphs)}
+ (for [{:keys [index text status]} rows]
+ [:> text* {:key index
+ :as "span"
+ :typography t/body-small
+ :class (stl/css-case :paragraph true
+ :is-kept (= status :kept)
+ :is-dropped (= status :dropped))}
+ (dm/str "¶" (inc index) " " text)])]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :muted)}
+ (tr "workspace.branches.resolve.paragraphs" (i18n/c (count rows)))])])]))
+
+(mf/defc whole-options*
+ "The choice for a conflict that cannot be split by property: one side
+ deleted the entity, or both added it differently."
+ [{:keys [conflict res branch-name is-review on-choose on-preview]}]
+ [:div {:class (stl/css :options) :role "radiogroup"}
+ (for [side [:main :branch]]
+ [:> option-card* {:key (name side)
+ :side side
+ :branch-name branch-name
+ :is-review is-review
+ :is-chosen (= res side)
+ :warning (when (nil? (get conflict side))
+ (tr "workspace.branches.resolve.deletes-it"))
+ :on-choose on-choose
+ :on-preview on-preview}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :muted)}
+ (if (= side :main)
+ (tr "workspace.branches.resolve.keep-main-version")
+ (tr "workspace.branches.resolve.keep-branch-version"))]])])
+
+;; --- A conflict
+
+(mf/defc pick-button*
+ "The value of one side of a property: a click keeps it."
+ {::mf/private true}
+ [{:keys [attr side value choice is-conflicting on-pick]}]
+ (let [on-click (mf/use-fn (mf/deps attr side on-pick) #(on-pick attr side))]
+ [:button {:class (stl/css-case :pick true :is-chosen (and is-conflicting (= choice side)))
+ :disabled (not is-conflicting)
+ :on-click on-click}
+ [:> brl/value-chip* {:value value :is-old (not= choice side)}]]))
+
+(mf/defc attr-table*
+ "Each property of a conflict with the value of main and of the branch,
+ and where its result comes from: a conflict, the user's choice, or the
+ only side that changed it."
+ {::mf/private true}
+ [{:keys [rows res branch-name selected on-pick on-select]}]
+ [:div {:class (stl/css :attrs)}
+ (for [{:keys [attr main branch source]} rows
+ :let [choice (brc/attr-choice res attr)
+ conflicting? (= source :conflict)]]
+ [:div {:class (stl/css-case :attr true
+ :is-conflicting (and conflicting? (nil? choice))
+ :is-selected (= attr selected))
+ :key (str attr)
+ :data-attr (name attr)
+ :on-click (when conflicting? on-select)}
+ [:div {:class (stl/css :attr-head)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :attr-name)}
+ (brc/attr-label attr)]
+ (cond
+ ;; a decided conflict is done (green); an independent edit names
+ ;; the side it comes from
+ (and conflicting? choice)
+ [:> tag* {:tone "success"} (tr "workspace.branches.resolve.tag.your-choice")]
+ conflicting?
+ [:> tag* {:tone "warning"} (tr "workspace.branches.resolve.tag.conflict")]
+ (= source :main)
+ [:> tag* {:tone "purple"}
+ (tr "workspace.branches.resolve.tag.from" (tr "workspace.branches.compare.main"))]
+ :else
+ [:> tag* {:tone "accent"}
+ (tr "workspace.branches.resolve.tag.from"
+ (or branch-name (tr "workspace.branches.compare.branch")))])]
+ [:div {:class (stl/css :attr-values)}
+ [:> pick-button* {:attr attr
+ :side :main
+ :value main
+ :choice (or choice (when-not conflicting? source))
+ :is-conflicting conflicting?
+ :on-pick on-pick}]
+ [:> pick-button* {:attr attr
+ :side :branch
+ :value branch
+ :choice (or choice (when-not conflicting? source))
+ :is-conflicting conflicting?
+ :on-pick on-pick}]]])])
+
+(mf/defc outcome*
+ "Once decided, what the merge or update leaves behind, with the way
+ back; until then, how the choice works."
+ {::mf/private true}
+ [{:keys [conflict res on-clear]}]
+ (let [drops (brc/dropped-values conflict res)]
+ (if (bm/conflict-resolved? conflict res)
+ [:div {:class (stl/css :outcome)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :muted)}
+ (tr "workspace.branches.resolve.drops.title")]
+ (if (seq drops)
+ (for [{:keys [attr side value]} drops]
+ [:> text* {:key (str attr)
+ :as "span"
+ :typography t/body-small
+ :class (stl/css :outcome-line)}
+ (if (= side :main)
+ (tr "workspace.branches.resolve.drops.main-short" (str/lower (brc/attr-label attr)))
+ (tr "workspace.branches.resolve.drops.branch-short" (str/lower (brc/attr-label attr))))
+ " "
+ [:span {:class (stl/css :outcome-dropped)} (brc/display-val value)]])
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :outcome-line)}
+ (tr "workspace.branches.resolve.drops.none")])
+ [:> button* {:variant "secondary" :class (stl/css :outcome-action) :on-click on-clear}
+ (tr "workspace.branches.resolve.change-choice")]]
+
+ [:> text* {:as "p" :typography t/body-small :class (stl/css :summary)}
+ (cond
+ (brc/text-conflict? conflict) (tr "workspace.branches.resolve.intro-text")
+ (brc/per-attr? conflict) (tr "workspace.branches.resolve.intro-attrs")
+ :else (tr "workspace.branches.resolve.intro-whole"))])))
+
+(mf/defc conflict-detail*
+ "The conflict `conflict` under resolution `res`. `attr` is the property
+ in turn; `on-pick` keeps a side for a property, `on-choose` for the
+ whole entity, `on-clear` forgets the choice and `on-attr` takes another
+ property in turn."
+ [{:keys [conflict res attr branch-name is-review copies data
+ on-pick on-choose on-clear on-attr]}]
+ (let [rows (brc/conflict-attr-rows conflict)
+ copies-of (mf/with-memo [copies conflict data]
+ (brc/copies-entry copies conflict
+ (get-in data [:pages-index (:page-id conflict) :objects])))
+ per-attr? (brc/per-attr? conflict)
+ text? (brc/text-conflict? conflict)
+ table-rows (if text? (filterv #(not= :content (:attr %)) rows) rows)
+ conflict-n (count (brc/conflicting-attrs rows))
+ indep-n (- (count rows) conflict-n)
+ resolved? (bm/conflict-resolved? conflict res)
+ lost (when text?
+ (some->> (brc/attr-choice res :content)
+ (brc/dropped-paragraphs conflict)))
+ on-select (mf/use-fn
+ (mf/deps on-attr)
+ (fn [event]
+ (on-attr (-> (dom/get-current-target event)
+ (dom/get-data "attr")
+ (keyword)))))
+ on-copy (mf/use-fn
+ (mf/deps lost)
+ (fn []
+ (-> (clipboard/to-clipboard (str/join "\n" (map :text lost)))
+ (.catch (constantly nil)))))]
+ [:div {:class (stl/css :detail)}
+ [:> detail-head*
+ {:title (:label conflict)
+ :place (place conflict data)
+ :summary (if per-attr?
+ (dm/str (tr "workspace.branches.resolve.tag.conflicts" (i18n/c conflict-n))
+ (when (pos? indep-n)
+ (dm/str ", " (tr "workspace.branches.resolve.tag.independent"
+ (i18n/c indep-n)))))
+ (brc/conflict-reason-label (:reason conflict)))}
+ (if resolved?
+ [:> tag* {:tone "success"} (tr "workspace.branches.resolve.decided")]
+ [:> tag* {:tone "warning"} (tr "workspace.branches.status.conflict")])]
+
+ ;; which value is whose: main first, then the branch
+ [:div {:class (stl/css :legend)}
+ [:> side-pill* {:side :main}]
+ [:> side-pill* {:side :branch :branch-name branch-name :is-review is-review}]]
+
+ (cond
+ (not per-attr?)
+ [:> whole-options* {:conflict conflict :res res
+ :branch-name branch-name :is-review is-review
+ :on-choose on-choose}]
+
+ text?
+ [:*
+ [:> text-options* {:conflict conflict :res res
+ :branch-name branch-name :is-review is-review
+ :show-paragraphs true
+ :on-pick on-pick}]
+ (when (seq lost)
+ [:div {:class (stl/css :actions)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :muted)}
+ (tr "workspace.branches.resolve.keep-safe")]
+ [:> button* {:variant "secondary" :on-click on-copy}
+ (tr "workspace.branches.resolve.copy-dropped")]])])
+
+ (when (and per-attr? (seq table-rows))
+ [:> attr-table* {:rows table-rows
+ :res res
+ :branch-name branch-name
+ :selected attr
+ :on-pick on-pick
+ :on-select on-select}])
+
+ ;; the copy rule: what it decided on this copy, how many copies a
+ ;; choice on a main decides, and which copies follow the component
+ (when (:settled conflict)
+ [:> brf/settled-facts* {:settled (:settled conflict) :is-conflict true}])
+ (when (:copies-affected conflict)
+ [:> brf/copies-affected* {:n (:copies-affected conflict)}])
+ (when copies-of
+ [:> brf/copies-facts* {:entry copies-of :copies copies :data data}])
+
+ [:> outcome* {:conflict conflict :res res :on-clear on-clear}]]))
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branch_review/detail.scss b/frontend/src/app/main/ui/workspace/sidebar/branch_review/detail.scss
new file mode 100644
index 0000000000..d3f8f25bb0
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/sidebar/branch_review/detail.scss
@@ -0,0 +1,255 @@
+// 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) KALEIDOS SUBSIDIARY SL
+
+@use "ds/_borders.scss" as *;
+@use "ds/mixins.scss" as *;
+
+.detail {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-l);
+ min-inline-size: 0;
+}
+
+.head {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-xs);
+}
+
+.head-row {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: var(--sp-s);
+}
+
+.title {
+ flex: 1;
+ min-inline-size: 0;
+ margin: 0;
+ color: var(--color-foreground-primary);
+ overflow-wrap: anywhere;
+}
+
+.summary {
+ margin: 0;
+ color: var(--color-foreground-secondary);
+}
+
+.muted {
+ color: var(--color-foreground-secondary);
+}
+
+.actions {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: var(--sp-s);
+}
+
+// a block over the whole width of the sidebar, on the background the
+// inspect tab gives each of its blocks: it undoes the padding of the
+// panel around the detail (`compare/detail.scss`)
+.section {
+ margin-inline: calc(-1 * var(--sp-m));
+ padding: var(--sp-m);
+
+ // TODO: --low-emphasis-background is not a DS token: the inspect tab
+ // defines it per theme (`inspect/styles/style_box.scss`).
+ background-color: var(--low-emphasis-background);
+}
+
+// two blocks in a row read as one: the second one takes away the gap of
+// the detail (`.detail`) and keeps a little of its top padding, so the
+// two groups stay apart on the one background
+.section + .section {
+ margin-block-start: calc(-1 * var(--sp-l));
+ padding-block-start: var(--sp-s);
+}
+
+// what can be done about the change, one button over the other
+.stacked-actions {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+}
+
+// a full-width DS button does not center its label on its own
+.wide-action {
+ inline-size: 100%;
+ justify-content: center;
+}
+
+.legend {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: var(--sp-s);
+}
+
+// --- Property table
+
+.attrs {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-xs);
+}
+
+.attr {
+ --attr-bg-color: transparent;
+ --attr-border-color: transparent;
+
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-xs);
+ padding: var(--sp-s);
+ border: $b-1 solid var(--attr-border-color);
+ border-radius: $br-8;
+ background-color: var(--attr-bg-color);
+
+ &.is-conflicting {
+ --attr-bg-color: var(--color-background-warning);
+ }
+
+ &.is-selected {
+ --attr-border-color: var(--color-accent-warning);
+ }
+}
+
+.attr-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--sp-s);
+}
+
+.attr-name {
+ @include text-ellipsis;
+
+ color: var(--color-foreground-secondary);
+}
+
+.attr-values {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: var(--sp-s);
+}
+
+// the button hugs its value chip, and the selection outline sits right
+// on the chip's own border instead of around the cell
+.pick {
+ display: inline-flex;
+ min-inline-size: 0;
+ max-inline-size: 100%;
+ padding: 0;
+ border: none;
+ border-radius: $br-4;
+ background: none;
+ cursor: pointer;
+
+ &:disabled {
+ cursor: default;
+ }
+
+ &:not(:disabled):hover,
+ &.is-chosen {
+ outline: $b-1 solid var(--color-accent-primary);
+ outline-offset: calc(#{$b-1} * -1);
+ }
+}
+
+// --- Choice cards
+
+.options {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+}
+
+.option {
+ --option-border-color: var(--color-background-quaternary);
+
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: var(--sp-s);
+ min-inline-size: 0;
+ padding: var(--sp-s) var(--sp-m);
+ border: $b-1 solid var(--option-border-color);
+ border-radius: $br-8;
+ background-color: var(--color-background-tertiary);
+ color: var(--color-foreground-primary);
+ text-align: start;
+ cursor: pointer;
+
+ &:hover {
+ --option-border-color: var(--color-foreground-secondary);
+ }
+
+ &.is-chosen {
+ --option-border-color: var(--color-accent-primary);
+ }
+
+ &:focus-visible {
+ outline: $b-1 solid var(--color-accent-primary);
+ }
+}
+
+.option-warning {
+ display: flex;
+ align-items: flex-start;
+ gap: var(--sp-xs);
+ color: var(--color-accent-error);
+}
+
+.paragraphs {
+ display: flex;
+ flex-direction: column;
+ align-self: stretch;
+ gap: var(--sp-xs);
+}
+
+.paragraph {
+ --paragraph-bg-color: transparent;
+
+ padding: var(--sp-xs) var(--sp-s);
+ border-radius: $br-4;
+ background-color: var(--paragraph-bg-color);
+ color: var(--color-foreground-primary);
+ overflow-wrap: anywhere;
+
+ &.is-kept {
+ --paragraph-bg-color: var(--color-background-success);
+ }
+
+ &.is-dropped {
+ --paragraph-bg-color: var(--color-background-error);
+ }
+}
+
+// --- What a choice leaves behind
+
+.outcome {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-xs);
+}
+
+.outcome-line {
+ color: var(--color-foreground-primary);
+}
+
+// only the value that is lost takes the error colour
+.outcome-dropped {
+ color: var(--color-accent-error);
+}
+
+.outcome-action {
+ align-self: flex-start;
+ margin-block-start: var(--sp-xs);
+}
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branch_review/facts.cljs b/frontend/src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
index 479c65af17..e6798a7612 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+++ b/frontend/src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
@@ -5,7 +5,7 @@
;; Copyright (c) KALEIDOS SUBSIDIARY SL
(ns app.main.ui.workspace.sidebar.branch-review.facts
- "What the detail pane says about an entry that has no before and after:
+ "What the detail says about an entry that has no before and after:
a new or deleted page or layer, and the library entries other layers
depend on. It answers what the entry is, where it lands and what it
affects, from the open file and, for a layer it lacks, from the diff.
@@ -17,11 +17,10 @@
[app.main.ui.ds.foundations.assets.icon :as i]
[app.main.ui.ds.foundations.typography :as t]
[app.main.ui.ds.foundations.typography.text :refer [text*]]
- [app.main.ui.ds.product.preview-card :refer [preview-card*]]
[app.main.ui.ds.product.tag :refer [tag*]]
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
[app.main.ui.workspace.sidebar.branch-review.layout :as brl]
- [app.main.ui.workspace.sidebar.branch-review.previews :as brp]
+ [app.main.ui.workspace.sidebar.branch-review.sides :as brs]
[app.util.i18n :as i18n :refer [tr]]
[cuerdas.core :as str]
[rumext.v2 :as mf]))
@@ -58,52 +57,33 @@
;; --- Pages
(mf/defc page-facts*
- "A new or deleted page: what it holds, drawn and counted, and the
- changes listed on it (`children`)."
- [{:keys [item data open-side incoming change-count children]}]
+ "A new or deleted page: what it holds, counted, when the open file has
+ it."
+ [{:keys [item data incoming]}]
(let [page (get-in data [:pages-index (:id item)])
deleted? (= :deleted (:status item))
{:keys [boards layers]} (when page (brc/page-contents page))
names (map :name boards)]
- [:*
- (if page
- [:*
- [:> preview-card* {:label (brc/side-label open-side)
- :side (name open-side)
- :detail (:name page)}
- [:> brp/page-preview* {:objects (:objects page)}]]
- [:> fact-list*
- {:rows [[(tr "workspace.branches.review.facts.contents")
- (if (zero? layers)
- (tr "workspace.branches.review.facts.empty-page")
- (dm/str (tr "workspace.branches.review.facts.boards" (i18n/c (count boards)))
- " - "
- (tr "workspace.branches.review.facts.layers" (i18n/c layers))))]
- (when (seq names)
- [(tr "workspace.branches.review.facts.board-names")
- (names-line names)])]}]
- (when (and deleted? (pos? layers))
- [:> brl/notice* {:level :warning
- :title (tr "workspace.branches.review.facts.page-goes")}
- (let [boards (tr "workspace.branches.review.facts.boards" (i18n/c (count boards)))
- layers (tr "workspace.branches.review.facts.layers" (i18n/c layers))]
- (if incoming
- (tr "workspace.branches.review.facts.page-goes-update" boards layers)
- (tr "workspace.branches.review.facts.page-goes-merge" boards layers)))])]
-
- [:> preview-card* {:label (brc/side-label (if (= open-side :main) :branch :main))
- :side (if (= open-side :main) "branch" "main")}
- [:> brp/entity-preview* {:kind :page
- :value nil
- :missing {:reason :unavailable
- :side (if (= open-side :main) :branch :main)
- :open-side open-side}}]])
-
- (when (pos? change-count)
- [:div {:class (stl/css :section)}
- [:> section-title* {}
- (tr "workspace.branches.review.facts.changes-on-page" (str change-count))]
- [:div {:class (stl/css :inner-list)} children]])]))
+ (when page
+ [:*
+ [:> fact-list*
+ {:rows [[(tr "workspace.branches.review.facts.contents")
+ (if (zero? layers)
+ (tr "workspace.branches.review.facts.empty-page")
+ (dm/str (tr "workspace.branches.review.facts.boards" (i18n/c (count boards)))
+ " - "
+ (tr "workspace.branches.review.facts.layers" (i18n/c layers))))]
+ (when (seq names)
+ [(tr "workspace.branches.review.facts.board-names")
+ (names-line names)])]}]
+ (when (and deleted? (pos? layers))
+ [:> brl/notice* {:level :warning
+ :title (tr "workspace.branches.review.facts.page-goes")}
+ (let [boards (tr "workspace.branches.review.facts.boards" (i18n/c (count boards)))
+ layers (tr "workspace.branches.review.facts.layers" (i18n/c layers))]
+ (if incoming
+ (tr "workspace.branches.review.facts.page-goes-update" boards layers)
+ (tr "workspace.branches.review.facts.page-goes-merge" boards layers)))])])))
;; --- Layers
@@ -164,7 +144,7 @@
(let [{:keys [interactions flows layouts]}
(mf/with-memo [item items objects inner incoming]
(brc/shape-effects item items objects inner incoming))
- names (mapv (comp :label second) inner)
+ names (mapv :label inner)
deleted? (= :deleted (:status item))
rows (cond-> (mapv layout-row layouts)
(seq names)
@@ -197,19 +177,20 @@
(let [open-objs (get-in data [:pages-index (:page-id item) :objects])
;; a layer the open file lacks is read on the other side, where
;; the changes of `items` put it and its deleted parents back
- objects (mf/with-memo [open-objs items item open-side]
+ objects (mf/with-memo [open-objs items item open-side incoming]
(if (or (contains? open-objs (:id item)) (nil? open-objs))
open-objs
- (brp/side-objects open-objs
+ (brs/side-objects open-objs
(filterv #(= (:page-id item) (:page-id %)) items)
(if (= open-side :main) :branch :main)
- open-side)))
+ open-side
+ (if incoming :main :branch))))
shape (get objects (:id item))
page (get-in data [:pages-index (:page-id item) :name])
deleted? (= :deleted (:status item))
type-lbl (brc/type-label item)
copies (when (and deleted? shape (:main-instance shape))
- (brc/component-copies data (:component-id shape)))]
+ (count (brc/usages data {:kind :component :id (:component-id shape)})))]
(when shape
[:*
[:> fact-list*
@@ -229,21 +210,12 @@
;; --- Library entries other layers depend on
-(defn- usages
- [item data]
- (case (:kind item)
- :component (brc/component-copies data (:id item))
- :color (brc/color-usages data (:id item))
- :typography (brc/typography-usages data (:id item))
- :token (brc/token-usages data (:label item))
- nil))
-
(mf/defc usage-facts*
"How many layers of the open file depend on a component, colour,
typography or token, and what a merge does to them when it deletes
it."
[{:keys [item data]}]
- (let [n (usages item data)
+ (let [n (some-> (brc/usages data item) count)
deleted? (= :deleted (:status item))
kind (:kind item)]
(when (some? n)
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branch_review/facts.scss b/frontend/src/app/main/ui/workspace/sidebar/branch_review/facts.scss
index 8e23f0414c..6d6c05440c 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/facts.scss
+++ b/frontend/src/app/main/ui/workspace/sidebar/branch_review/facts.scss
@@ -6,7 +6,6 @@
@use "ds/_borders.scss" as *;
@use "ds/_sizes.scss" as *;
-@use "ds/_utils.scss" as *;
@use "ds/mixins.scss" as *;
@use "ds/typography.scss" as *;
@@ -14,19 +13,15 @@
flex-shrink: 0;
display: flex;
flex-direction: column;
- padding-block: var(--sp-xs);
- border: $b-1 solid var(--color-background-quaternary);
- border-radius: $br-8;
- background-color: var(--color-background-tertiary);
+ gap: var(--sp-m);
}
+// the label over its value: the sidebar is too narrow for two columns
.fact {
- display: grid;
- grid-template-columns: px2rem(180) 1fr;
- align-items: center;
- gap: var(--sp-s);
- min-block-size: $sz-32;
- padding: var(--sp-xs) var(--sp-m);
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-xxs);
+ min-inline-size: 0;
}
.fact-label {
@@ -35,9 +30,9 @@
.fact-value {
@include use-typography("body-small");
- @include text-ellipsis;
color: var(--color-foreground-primary);
+ overflow-wrap: anywhere;
}
.section {
@@ -51,12 +46,6 @@
color: var(--color-foreground-primary);
}
-.inner-list {
- display: flex;
- flex-direction: column;
- gap: var(--sp-xxs);
-}
-
.copy-list {
display: flex;
flex-direction: column;
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branch_review/layout.cljs b/frontend/src/app/main/ui/workspace/sidebar/branch_review/layout.cljs
index 1387a59ff2..ccf6fb092a 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/layout.cljs
+++ b/frontend/src/app/main/ui/workspace/sidebar/branch_review/layout.cljs
@@ -5,91 +5,23 @@
;; Copyright (c) KALEIDOS SUBSIDIARY SL
(ns app.main.ui.workspace.sidebar.branch-review.layout
- "The frame the compare and conflict dialogs share: a header with the
- route between the two branches, a bar of filters, an
- optional banner, a list beside a detail pane (or a single pane), and a
- footer with a status line and the actions."
+ "The small pieces the list and the detail of a comparison share: the
+ heading of a group, a note, and a property value alone or as `before →
+ after`."
(:require-macros [app.main.style :as stl])
(:require
[app.main.ui.ds.foundations.assets.icon :as i]
[app.main.ui.ds.foundations.typography :as t]
- [app.main.ui.ds.foundations.typography.heading :refer [heading*]]
[app.main.ui.ds.foundations.typography.text :refer [text*]]
- [app.main.ui.ds.layout.modal :refer [modal* modal-header* modal-footer*]]
[app.main.ui.ds.notifications.context-notification :refer [context-notification*]]
- [app.main.ui.ds.product.branch-pill :refer [branch-pill*]]
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
- [app.main.ui.workspace.sidebar.pull-requests :as prui]
- [app.util.i18n :refer [tr]]
[rumext.v2 :as mf]))
-(mf/defc route*
- "`from → to` between the branch and main. With `on-swap` the arrow
- turns the comparison around."
- [{:keys [branch-name is-review incoming on-swap]}]
- (let [branch (mf/html [:> branch-pill* {:label branch-name :is-review (boolean is-review)}])
- main (mf/html [:> branch-pill* {:label (tr "workspace.branches.main") :is-main true}])
- arrow (if on-swap
- (mf/html
- [:button {:class (stl/css :route-swap)
- :title (tr "workspace.branches.compare.swap")
- :aria-label (tr "workspace.branches.compare.swap")
- :on-click on-swap}
- [:> i/icon* {:icon-id i/arrow-long-right :size "s"}]])
- (mf/html
- [:span {:class (stl/css :route-arrow) :aria-hidden true}
- [:> i/icon* {:icon-id i/arrow-long-right :size "s"}]]))]
- [:div {:class (stl/css :route)}
- (if incoming
- [:* main arrow branch]
- [:* branch arrow main])]))
-
-(mf/defc review-modal*
- "`list` and `detail` are the two panes; with no `list` the `detail`
- takes the whole width. `filters` go in the bar under the header,
- after the \"This branch:\" label; `banner` sits under that bar."
- [{:keys [icon tone title route filters banner list detail
- footer-start footer-end on-close]}]
- [:> modal* {:is-open true
- :on-open-change (prui/on-dismiss on-close)
- :size "xlarge"
- :show-body false
- :class (stl/css :review-modal)}
- [:> modal-header* {:class (stl/css :review-header)}
- [:div {:class (stl/css-case :header-icon true
- :is-warning (= tone :warning))}
- [:> i/icon* {:icon-id icon}]]
- [:div {:class (stl/css :header-text)}
- [:> heading* {:level 2
- :typography t/body-large
- :class (stl/css :header-title)}
- title]
- route]]
-
- (when filters
- [:div {:class (stl/css :filter-bar)}
- [:> text* {:as "span" :typography t/body-small :class (stl/css :filter-label)}
- (tr "workspace.branches.review.this-branch")]
- filters])
-
- banner
-
- (if list
- [:div {:class (stl/css :review-body)}
- [:div {:class (stl/css :review-list)} list]
- [:div {:class (stl/css :review-detail)} detail]]
- [:div {:class (stl/css :review-body :is-single)}
- [:div {:class (stl/css :review-detail)} detail]])
-
- [:> modal-footer* {:variant "split"
- :class (stl/css :review-footer)
- :start footer-start
- :end footer-end}]])
-
(mf/defc group-head*
- "The heading of a group in the change list: a fold toggle, the group
- name and count, and an optional control before them (a checkbox)."
- [{:keys [label is-open on-toggle start end]}]
+ "The heading of a group in a list: a fold toggle, the group name and
+ count with an optional `icon` before them, and an optional control at
+ each end (a checkbox at the `start`)."
+ [{:keys [label icon is-open on-toggle start end]}]
[:div {:class (stl/css :group-head)}
start
[:button {:class (stl/css :group-toggle)
@@ -98,6 +30,8 @@
[:> i/icon* {:icon-id (if is-open i/arrow-down i/arrow-right)
:size "s"
:class (stl/css :group-chevron)}]
+ (when icon
+ [:> i/icon* {:icon-id icon :size "s" :class (stl/css :group-chevron)}])
[:> text* {:as "span" :typography t/body-small :class (stl/css :group-label)}
label]]
end])
@@ -128,14 +62,16 @@
(brc/display-val value))]))
(mf/defc value-steps*
- "Each property of a change as `before → after`, one row per property."
- [{:keys [attrs]}]
+ "Each property of a change as `before → after`, the name of the
+ property over its two values. `incoming` says the change is main's,
+ going to the branch: its new value is then main's."
+ [{:keys [attrs incoming]}]
[:div {:class (stl/css :steps)}
(for [[attr {:keys [main branch]}] attrs]
[:div {:class (stl/css :steps-row) :key (str attr)}
[:> text* {:as "span" :typography t/body-small :class (stl/css :steps-name)}
(brc/attr-label attr)]
[:div {:class (stl/css :steps-values)}
- [:> value-chip* {:value main :is-old true}]
+ [:> value-chip* {:value (if incoming branch main) :is-old true}]
[:> i/icon* {:icon-id i/arrow-long-right :size "s" :class (stl/css :steps-arrow)}]
- [:> value-chip* {:value branch}]]])])
+ [:> value-chip* {:value (if incoming main branch)}]]])])
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branch_review/layout.scss b/frontend/src/app/main/ui/workspace/sidebar/branch_review/layout.scss
index 18997f9abd..9e8c9a7777 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/layout.scss
+++ b/frontend/src/app/main/ui/workspace/sidebar/branch_review/layout.scss
@@ -10,175 +10,24 @@
@use "ds/mixins.scss" as *;
@use "ds/typography.scss" as *;
-// The dialog draws its own rows edge to edge (header, filter bar, panes,
-// footer), so it opts out of the padded `modal*` body.
-//
-// These dialogs carry more to read than a `modal*` size allows, so they
-// size to the window instead, within bounds:
-// - width: 88% of the window, between 960 and 1440, and never wider than
-// the window less a margin; a 4K screen stops at the upper bound;
-// - panes: all the height the header, filters, footer and margins leave,
-// up to 880. The height stays fixed for a given window, so moving
-// between changes or decisions never resizes the dialog; the panes
-// scroll instead.
-// The previews grow with the panes too.
-// Bounds are in rem, so the dialog follows the interface scale.
-.review-modal {
- --review-modal-inline-size: clamp(#{px2rem(960)}, 88vw, #{px2rem(1440)});
- --review-panes-block-size: min(calc(100dvh - #{px2rem(280)}), #{px2rem(880)});
- --review-list-inline-size: clamp(#{px2rem(320)}, 26%, #{$sz-400});
-
- // the previews grow with the panes: about a third of their height in
- // the detail, about two thirds when expanded, within bounds
- --preview-card-stage-block-size: clamp(
- #{px2rem(100)},
- calc(var(--review-panes-block-size) * 0.3),
- #{px2rem(260)}
- );
- --preview-card-stage-large-block-size: clamp(
- #{px2rem(320)},
- calc(var(--review-panes-block-size) * 0.62),
- #{px2rem(600)}
- );
-
- max-inline-size: min(var(--review-modal-inline-size), calc(100vw - #{$sz-32}));
- overflow: hidden;
-}
-
-.review-header {
- gap: var(--sp-m);
- padding: var(--sp-xl) var(--sp-xxxl) var(--sp-xl) var(--sp-xl);
- border-block-end: $b-1 solid var(--color-background-quaternary);
-}
-
-.header-icon {
- --header-icon-color: var(--color-foreground-secondary);
-
- display: flex;
- flex-shrink: 0;
- align-items: center;
- justify-content: center;
- inline-size: $sz-32;
- block-size: $sz-32;
- border-radius: $br-8;
- color: var(--header-icon-color);
- background-color: var(--color-background-tertiary);
-
- &.is-warning {
- --header-icon-color: var(--color-accent-warning);
- }
-}
-
-.header-text {
- display: flex;
- flex: 1;
- flex-direction: column;
- gap: var(--sp-xs);
- min-inline-size: 0;
-}
-
-.header-title {
- color: var(--color-foreground-primary);
-}
-
-.route {
- display: flex;
- align-items: center;
- gap: var(--sp-xs);
- min-inline-size: 0;
-}
-
-.route-arrow {
- display: flex;
- color: var(--color-foreground-secondary);
-}
-
-.route-swap {
- --route-swap-color: var(--color-foreground-secondary);
-
- display: flex;
- align-items: center;
- padding: var(--sp-xxs);
- border: none;
- border-radius: $br-4;
- background: none;
- color: var(--route-swap-color);
- cursor: pointer;
-
- &:hover {
- --route-swap-color: var(--color-accent-primary);
- }
-}
-
-.filter-bar {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- gap: var(--sp-s);
- padding: var(--sp-s) var(--sp-xl);
- background-color: var(--color-background-secondary);
-}
-
-.filter-label {
- color: var(--color-foreground-secondary);
-}
-
-.review-body {
- display: grid;
- grid-template-columns: var(--review-list-inline-size) 1fr;
- block-size: var(--review-panes-block-size);
- min-block-size: 0;
-
- &.is-single {
- grid-template-columns: 1fr;
- }
-}
-
-.review-list {
- @include custom-scrollbar;
-
- display: flex;
- flex-direction: column;
- gap: var(--sp-xxs);
- padding: var(--sp-m);
- overflow-block: auto;
- border-inline-end: $b-1 solid var(--color-background-quaternary);
-}
-
-.review-detail {
- @include custom-scrollbar;
-
- display: flex;
- flex-direction: column;
- gap: var(--sp-l);
- min-inline-size: 0;
- padding: var(--sp-xl);
- overflow-block: auto;
-}
-
-.review-footer {
- padding: var(--sp-l) var(--sp-xl);
- border-block-start: $b-1 solid var(--color-background-quaternary);
-}
-
.group-head {
display: flex;
align-items: center;
gap: var(--sp-s);
- padding-block: var(--sp-s);
- padding-inline: var(--sp-s) px2rem(10);
+ min-block-size: $sz-32;
+ padding-inline: var(--sp-xs);
}
.group-toggle {
display: flex;
flex: 1;
align-items: center;
- gap: var(--sp-s);
+ gap: var(--sp-xs);
min-inline-size: 0;
padding: 0;
border: none;
background: none;
- color: var(--color-foreground-primary);
+ color: var(--color-foreground-secondary);
cursor: pointer;
}
@@ -208,6 +57,7 @@
display: inline-flex;
align-items: center;
gap: var(--sp-xs);
+ min-inline-size: 0;
max-inline-size: 100%;
padding: var(--sp-xxs) var(--sp-s);
overflow: hidden;
@@ -234,28 +84,20 @@
flex-shrink: 0;
display: flex;
flex-direction: column;
- padding-block: var(--sp-xs);
- border: $b-1 solid var(--color-background-quaternary);
- border-radius: $br-8;
- background-color: var(--color-background-tertiary);
+ gap: var(--sp-m);
}
.steps-row {
- display: grid;
- grid-template-columns: px2rem(180) 1fr;
- align-items: center;
- gap: var(--sp-s);
- padding: var(--sp-s) var(--sp-m);
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-xs);
+ min-inline-size: 0;
}
.steps-name {
@include text-ellipsis;
- color: var(--color-foreground-primary);
-
- // TODO: No exact DS typography match found.
- // Closest match: body-small (weight 500 vs 400).
- font-weight: 500;
+ color: var(--color-foreground-secondary);
}
.steps-values {
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branch_review/list.cljs b/frontend/src/app/main/ui/workspace/sidebar/branch_review/list.cljs
new file mode 100644
index 0000000000..2fdff779b6
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/sidebar/branch_review/list.cljs
@@ -0,0 +1,322 @@
+;; 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) KALEIDOS SUBSIDIARY SL
+
+(ns app.main.ui.workspace.sidebar.branch-review.list
+ "The rows of a comparison: the changes of a branch, grouped by page and
+ board, each with the checkbox that keeps it in or leaves it out; and
+ the conflicts of a merge or an update, with the ones that still wait
+ for a choice first."
+ (:require-macros [app.main.style :as stl])
+ (:require
+ [app.common.data.macros :as dm]
+ [app.common.files.branch-merge :as bm]
+ [app.main.data.workspace.compare :as dwcp]
+ [app.main.ui.ds.controls.checkbox :refer [checkbox*]]
+ [app.main.ui.ds.foundations.assets.icon :as i]
+ [app.main.ui.ds.product.change-row :refer [change-row*]]
+ [app.main.ui.ds.product.tag :refer [tag*]]
+ [app.main.ui.workspace.sidebar.branch-review.common :as brc]
+ [app.main.ui.workspace.sidebar.branch-review.layout :as brl]
+ [app.util.dom :as dom]
+ [app.util.i18n :as i18n :refer [tr]]
+ [cuerdas.core :as str]
+ [rumext.v2 :as mf]))
+
+;; --- Changes
+
+(mf/defc row-end*
+ {::mf/private true}
+ [{:keys [item excluded reviewed]}]
+ (let [status (:status item)
+ edits (count (brc/visible-attrs (:changed-attrs item)))]
+ (cond
+ (= :conflict status)
+ [:> tag* {:tone "warning" :variant "pill"}
+ (tr "workspace.branches.review.row.choose")]
+
+ ;; information, not a change: nothing to choose or leave out
+ (= :settled status)
+ [:> tag* {:variant "pill"} (tr "workspace.branches.review.copies.settled-tag")]
+
+ excluded
+ [:> tag* {:tone "info" :variant "pill"} (tr "workspace.branches.review.row.left-out")]
+
+ ;; reviewing is the user's progress, not what happened to the
+ ;; entry: a quiet tag in the place of the coloured status
+ reviewed
+ [:> tag* {:variant "pill"} (tr "workspace.branches.review.row.reviewed")]
+
+ (= :added status)
+ [:> tag* {:tone "success" :variant "pill"} (tr "workspace.branches.status.added")]
+
+ (= :deleted status)
+ [:> tag* {:tone "error" :variant "pill"} (tr "workspace.branches.status.deleted")]
+
+ (pos? edits)
+ [:> tag* {:tone "info" :variant "pill"}
+ (tr "workspace.branches.review.row.edits" (i18n/c edits))]
+
+ :else nil)))
+
+(defn- follows-of
+ "How many copies follow the component `item` is, or the main instance
+ of (`brc/copy-follow-counts`), or nil."
+ [follow-counts item]
+ (when (or (= :component (:kind item)) (:component? item))
+ (get follow-counts (:id item))))
+
+(def pointed-row
+ "The key of the entry a list shows as pointed at from somewhere else
+ (its layer on the canvas), for its row to say so."
+ (mf/create-context nil))
+
+(mf/defc item-row*
+ "One change. `inner` are the layers added or deleted with it, folded
+ under it: the row counts them and its checkbox takes them along.
+ `follows` is how many copies follow the component the row changes.
+ Without `on-toggle` the row has no checkbox."
+ [{:keys [item inner follows selected excluded reviewed on-select on-toggle]}]
+ (let [item-key (dwcp/item-key item)
+ selectable? (and (some? on-toggle) (brc/selectable-item? item))
+ toggle-keys (brc/row-keys item inner)
+ subtitle (cond-> (brc/change-summary item)
+ (seq inner)
+ (dm/str " - " (tr "workspace.branches.review.facts.layers"
+ (i18n/c (count inner))))
+
+ (and follows (pos? follows))
+ (dm/str " - " (tr "workspace.branches.review.copies.row-follow"
+ (i18n/c follows))))
+ pointed? (= item-key (mf/use-ctx pointed-row))
+ on-click (mf/use-fn (mf/deps item-key on-select) #(on-select item-key))
+ on-check (mf/use-fn (mf/deps toggle-keys on-toggle) #(on-toggle toggle-keys))
+ start (when selectable?
+ (mf/html
+ [:span {:class (stl/css :row-check)
+ ;; the click must not also select the row
+ :on-click dom/stop-propagation}
+ [:> checkbox* {:id (dm/str "change-" item-key)
+ :checked (not excluded)
+ :on-change on-check}]]))]
+ [:> change-row* {:title (or (:label item) "")
+ :subtitle subtitle
+ :icon (brc/entry-icon item)
+ :tone (if (and excluded selectable?) "neutral" (brc/status-tone (:status item)))
+ :is-selected (= selected item-key)
+ :is-muted (boolean (and excluded selectable?))
+ :class (stl/css-case :is-pointed pointed?)
+ ;; for whoever follows the pointer over the list
+ :data-item-key item-key
+ :start start
+ :end (mf/html [:> row-end* {:item item :excluded excluded :reviewed reviewed}])
+ :on-click on-click}]))
+
+(mf/defc rows*
+ "The rows of `items`, each with what the list knows about it."
+ {::mf/private true}
+ [{:keys [items cascades follow-counts selected excluded reviewed on-select on-toggle]}]
+ (for [item items
+ :let [item-key (dwcp/item-key item)]]
+ [:> item-row* {:key item-key
+ :item item
+ :inner (get cascades item-key)
+ :follows (follows-of follow-counts item)
+ :selected selected
+ :excluded (contains? excluded (:key item))
+ :reviewed (contains? reviewed item-key)
+ :on-select on-select
+ :on-toggle on-toggle}]))
+
+(mf/defc board-group*
+ "A top-level board that holds two or more changes: they fold under it."
+ {::mf/private true}
+ [{:keys [group board collapsed on-fold children]}]
+ (let [fold-id (dm/str (:id group) "/" (:id board))
+ open? (not (contains? collapsed fold-id))
+ on-click (mf/use-fn (mf/deps fold-id on-fold) #(on-fold fold-id))]
+ [:div {:class (stl/css :board)}
+ [:> brl/group-head* {:label (dm/str (:name board) " (" (count (remove bm/settled? (:rows board))) ")")
+ :icon i/board
+ :is-open open?
+ :on-toggle on-click}]
+ (when open? children)]))
+
+(mf/defc change-group*
+ "The changes of one page: the group folds, and its checkbox takes all of
+ them."
+ {::mf/private true}
+ [{:keys [group cascades follow-counts selected excluded reviewed collapsed
+ on-select on-toggle on-fold]}]
+ (let [{:keys [id name rows boards count]} group
+ open? (not (contains? collapsed id))
+ toggles (into #{}
+ (comp (filter brc/selectable-item?)
+ (mapcat #(brc/row-keys % (get cascades (dwcp/item-key %)))))
+ (concat rows (mapcat :rows boards)))
+ included? (not-any? excluded toggles)
+ on-header (mf/use-fn (mf/deps id on-fold) #(on-fold id))
+ on-check (mf/use-fn (mf/deps toggles included? on-toggle) #(on-toggle toggles (not included?)))]
+ [:div {:class (stl/css :group)}
+ [:> brl/group-head*
+ {:label (dm/str name " (" count ")")
+ :is-open open?
+ :on-toggle on-header
+ :start (when (seq toggles)
+ (mf/html
+ [:span {:class (stl/css :row-check)}
+ [:> checkbox* {:id (dm/str "group-" id)
+ :checked included?
+ :on-change on-check}]]))}]
+ (when open?
+ [:*
+ [:> rows* {:items rows
+ :cascades cascades
+ :follow-counts follow-counts
+ :selected selected
+ :excluded excluded
+ :reviewed reviewed
+ :on-select on-select
+ :on-toggle on-toggle}]
+ (for [board boards]
+ [:> board-group* {:key (str (:id board))
+ :group group
+ :board board
+ :collapsed collapsed
+ :on-fold on-fold}
+ [:> rows* {:items (:rows board)
+ :cascades cascades
+ :follow-counts follow-counts
+ :selected selected
+ :excluded excluded
+ :reviewed reviewed
+ :on-select on-select
+ :on-toggle on-toggle}]])])]))
+
+(mf/defc change-list*
+ "The list of a comparison (`model`, a `brc/change-model`): the changes
+ both sides made, which wait for a decision, and then the clean ones by
+ page and board."
+ [{:keys [model follow-counts selected excluded reviewed collapsed
+ on-select on-toggle on-fold]}]
+ (let [{:keys [conflicts groups cascades]} model
+ open? (not (contains? collapsed "decisions"))
+ on-header (mf/use-fn (mf/deps on-fold) #(on-fold "decisions"))]
+ [:*
+ (when (seq conflicts)
+ [:div {:class (stl/css :group)}
+ [:> brl/group-head* {:label (tr "workspace.branches.review.group.decisions"
+ (str (count conflicts)))
+ :is-open open?
+ :on-toggle on-header}]
+ (when open?
+ [:> rows* {:items conflicts
+ :follow-counts follow-counts
+ :selected selected
+ :reviewed reviewed
+ :on-select on-select}])])
+
+ (for [group groups]
+ [:> change-group* {:key (:id group)
+ :group group
+ :cascades cascades
+ :follow-counts follow-counts
+ :selected selected
+ :excluded excluded
+ :reviewed reviewed
+ :collapsed collapsed
+ :on-select on-select
+ :on-toggle on-toggle
+ :on-fold on-fold}])]))
+
+;; --- Conflicts
+
+(defn- row-subtitle
+ [conflict res]
+ (let [rows (brc/conflict-attr-rows conflict)
+ conflicting (brc/conflicting-attrs rows)
+ drops (brc/dropped-values conflict res)]
+ (cond
+ (bm/conflict-resolved? conflict res)
+ (cond
+ (= res :main) (tr "workspace.branches.resolve.row.kept-main")
+ (= res :branch) (tr "workspace.branches.resolve.row.kept-branch")
+ (seq drops) (tr "workspace.branches.resolve.row.drops"
+ (str/lower (str/join ", " (map (comp brc/attr-label :attr) drops))))
+ :else (tr "workspace.branches.resolve.row.kept-both"))
+
+ (seq conflicting)
+ (tr "workspace.branches.resolve.row.both-changed"
+ (str/join ", " (map brc/attr-label conflicting)))
+
+ :else
+ (brc/conflict-reason-label (:reason conflict)))))
+
+(mf/defc conflict-row*
+ {::mf/private true}
+ [{:keys [conflict selected res on-select]}]
+ (let [item-key (dwcp/item-key conflict)
+ resolved? (bm/conflict-resolved? conflict res)
+ pointed? (= item-key (mf/use-ctx pointed-row))
+ on-click (mf/use-fn (mf/deps item-key on-select) #(on-select item-key))]
+ [:> change-row* {:title (or (:label conflict) "")
+ :subtitle (row-subtitle conflict res)
+ :icon (brc/entry-icon conflict)
+ :tone (if resolved? "success" "warning")
+ :is-selected (= selected item-key)
+ :class (stl/css-case :is-pointed pointed?)
+ :data-item-key item-key
+ :end (mf/html
+ (cond
+ resolved?
+ [:> tag* {:tone "success" :variant "pill"}
+ (tr "workspace.branches.resolve.decided")]
+ (brc/loses-work? conflict)
+ [:> tag* {:tone "error" :variant "pill"}
+ (tr "workspace.branches.resolve.row.loses-work")]
+ :else
+ [:> tag* {:tone "warning" :variant "pill"}
+ (tr "workspace.branches.review.row.choose")]))
+ :on-click on-click}]))
+
+(mf/defc conflict-group*
+ {::mf/private true}
+ [{:keys [id label conflicts resolutions selected collapsed on-select on-fold]}]
+ (let [open? (not (contains? collapsed id))
+ on-header (mf/use-fn (mf/deps id on-fold) #(on-fold id))]
+ (when (seq conflicts)
+ [:div {:class (stl/css :group)}
+ [:> brl/group-head* {:label label :is-open open? :on-toggle on-header}]
+ (when open?
+ (for [conflict conflicts]
+ [:> conflict-row* {:key (dwcp/item-key conflict)
+ :conflict conflict
+ :selected selected
+ :res (get resolutions (:id conflict))
+ :on-select on-select}]))])))
+
+(mf/defc conflict-list*
+ "The conflicts of a merge or an update (`model`, a
+ `brc/conflict-model`): the ones that wait for a choice, then the ones
+ decided."
+ [{:keys [model resolutions selected collapsed on-select on-fold]}]
+ (let [{:keys [pending decided]} model]
+ [:*
+ [:> conflict-group* {:id "pending"
+ :label (tr "workspace.branches.resolve.group.pending" (str (count pending)))
+ :conflicts pending
+ :resolutions resolutions
+ :selected selected
+ :collapsed collapsed
+ :on-select on-select
+ :on-fold on-fold}]
+ [:> conflict-group* {:id "decided"
+ :label (tr "workspace.branches.resolve.group.decided" (str (count decided)))
+ :conflicts decided
+ :resolutions resolutions
+ :selected selected
+ :collapsed collapsed
+ :on-select on-select
+ :on-fold on-fold}]]))
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branch_review/list.scss b/frontend/src/app/main/ui/workspace/sidebar/branch_review/list.scss
new file mode 100644
index 0000000000..db0a223318
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/sidebar/branch_review/list.scss
@@ -0,0 +1,29 @@
+// 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) KALEIDOS SUBSIDIARY SL
+
+@use "ds/_sizes.scss" as *;
+
+.group,
+.board {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-xxs);
+}
+
+// the DS checkbox keeps room for a label even without one; the slot
+// holds the box alone, so the next item sits one gap away from it
+.row-check {
+ display: flex;
+ flex-shrink: 0;
+ inline-size: $sz-16;
+ overflow: visible;
+}
+
+// the row of the layer under the pointer on the canvas reads as the row
+// under the pointer itself (`change-row*` on hover)
+.is-pointed {
+ --row-bg-color: var(--color-background-quaternary);
+}
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branch_review/previews.cljs b/frontend/src/app/main/ui/workspace/sidebar/branch_review/previews.cljs
deleted file mode 100644
index 94f3e40797..0000000000
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/previews.cljs
+++ /dev/null
@@ -1,272 +0,0 @@
-;; 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) KALEIDOS SUBSIDIARY SL
-
-(ns app.main.ui.workspace.sidebar.branch-review.previews
- "Visual previews of the two sides of a change. The diff carries whole
- entities for conflicts and for added or deleted shapes; for a modified
- entity the open file holds one side and the changed attrs give the
- other, which is enough to draw both the layer and the board it sits in."
- (:require-macros [app.main.style :as stl])
- (:require
- [app.common.data.macros :as dm]
- [app.common.types.shape :as cts]
- [app.common.uuid :as uuid]
- [app.main.render :as render]
- [app.main.ui.ds.foundations.assets.icon :as i]
- [app.main.ui.ds.foundations.typography :as t]
- [app.main.ui.ds.foundations.typography.text :refer [text*]]
- [app.main.ui.workspace.sidebar.branch-review.common :as brc]
- [app.util.color :as uc]
- [app.util.i18n :refer [tr]]
- [rumext.v2 :as mf]))
-
-(def ^:private renderable-shape-types
- "Shape types we can faithfully render to SVG from a shape map. Images /
- svg-raw reference (possibly cross-file) media and fall back to a type
- icon instead."
- #{:rect :circle :frame :path :bool :text :group})
-
-(def ^:private box-shape-types
- "Shape types whose geometry is their position and size; a path or a
- boolean takes it from its content, a group from its children."
- #{:rect :circle :frame :text :image :svg-raw})
-
-(defn open-side
- "Which document the open file is for `branch`: `:branch` when it is the
- branch file, `:main` otherwise."
- [branch file-id]
- (if (and (some? file-id) (= file-id (:branch-file-id branch)))
- :branch
- :main))
-
-(defn side-entity
- "One side (`:main` or `:branch`) of diff entry `item`. A conflict carries
- both; a clean change carries the attrs that differ, so the side the open
- file does not hold is the open entity with those attrs swapped in. An
- entry that does not exist on a side (added on the other one, or
- deleted) has no entity there. An added or deleted shape the open file
- lacks comes whole in the entry's `:shape`."
- [item side open-side open-entity]
- (cond
- (= :conflict (:status item))
- (get item side)
-
- (= side open-side)
- open-entity
-
- (nil? open-entity)
- (:shape item)
-
- (and (= :added (:status item)) (= side :main))
- nil
-
- (and (= :deleted (:status item)) (= side :branch))
- nil
-
- :else
- (let [attrs (:changed-attrs item)
- entity (reduce-kv (fn [entity attr values]
- (let [v (get values side)]
- (if (nil? v)
- (dissoc entity attr)
- (assoc entity attr v))))
- open-entity
- attrs)]
- ;; the diff leaves out `:selrect` and `:points` (they follow from
- ;; position and size), so a box that moved or resized gets them
- ;; again from its own, or it would draw with the open side's
- (if (and (contains? box-shape-types (:type entity))
- (some #(contains? attrs %) [:x :y :width :height]))
- (cts/setup-rect (dissoc entity :selrect :points))
- entity))))
-
-(defn side-objects
- "The page `objects` as they stand on `side`, with every shape change of
- `items` that lives on this page put on that side. A shape missing on
- that side is taken out of its parent, so boards draw without it, and a
- shape only that side holds is put into its parent, so boards draw it."
- [objects items side open-side]
- (reduce
- (fn [objects item]
- (if (not= :shape (:kind item))
- objects
- (let [id (:id item)
- entity (side-entity item side open-side (get objects id))]
- (if (some? entity)
- (let [parent-id (:parent-id entity)]
- (cond-> (assoc objects id entity)
- (and (contains? objects parent-id)
- (not (contains? objects id))
- (not (some #(= id %) (get-in objects [parent-id :shapes]))))
- (update-in [parent-id :shapes] (fnil conj []) id)))
- (let [parent-id (:parent-id (get objects id))]
- (cond-> (dissoc objects id)
- (contains? objects parent-id)
- (update-in [parent-id :shapes] (fn [ids] (filterv #(not= id %) ids)))))))))
- objects
- items))
-
-(defn- shape-bounds
- "Axis-aligned bounds framing a shape, taken from its rotated corner
- `:points` when present, else its `:selrect`."
- [shape]
- (let [pts (:points shape)]
- (if (and (sequential? pts) (seq pts))
- (let [xs (keep :x pts) ys (keep :y pts)
- x (apply min xs) y (apply min ys)]
- {:x x :y y :width (- (apply max xs) x) :height (- (apply max ys) y)})
- (let [sr (:selrect shape)]
- {:x (:x sr 0) :y (:y sr 0) :width (:width sr 1) :height (:height sr 1)}))))
-
-(defn context-frame-id
- "The nearest board that holds shape `id` in `objects`, the page root
- left out: the stage an added or deleted layer is shown on."
- [objects id]
- (loop [parent-id (:parent-id (get objects id))
- depth 0]
- (let [parent (get objects parent-id)]
- (cond
- (or (nil? parent) (= parent-id uuid/zero) (>= depth 64)) nil
- (= :frame (:type parent)) parent-id
- :else (recur (:parent-id parent) (inc depth))))))
-
-(mf/defc shape-preview*
- "Renders `shape` to a fitted SVG with the real shape renderers. `objects`
- supplies its children (a board or group draws them). `highlight`
- (`{:id :status}`) outlines the layer an added or deleted change is
- about, when `objects` holds it."
- [{:keys [shape objects highlight]}]
- (let [{:keys [x y width height]} (shape-bounds shape)
- width (max 1 width)
- height (max 1 height)
- objects (mf/with-memo [shape objects]
- (assoc (or objects {}) (:id shape) shape))
- marked (some->> (:id highlight) (get objects) shape-bounds)
- wrapper (mf/with-memo [objects] (render/shape-wrapper-factory objects))]
- [:svg {:class (stl/css :preview-svg)
- :viewBox (dm/str x " " y " " width " " height)
- :preserveAspectRatio "xMidYMid meet"
- :xmlns "http://www.w3.org/2000/svg"
- :fill "none"}
- [:> wrapper {:shape shape}]
- (when marked
- [:rect {:class (stl/css-case :preview-highlight true
- :is-added (= :added (:status highlight))
- :is-deleted (= :deleted (:status highlight)))
- :x (:x marked)
- :y (:y marked)
- :width (max 1 (:width marked))
- :height (max 1 (:height marked))
- :vector-effect "non-scaling-stroke"}])]))
-
-(mf/defc page-preview*
- "The whole page `objects` drawn to fit: every top-level layer, framed
- together."
- [{:keys [objects]}]
- (let [tops (mf/with-memo [objects]
- (into [] (keep #(get objects %)) (:shapes (get objects uuid/zero))))
- bounds (mf/with-memo [tops]
- (when (seq tops)
- (let [bs (map shape-bounds tops)
- x1 (apply min (map :x bs))
- y1 (apply min (map :y bs))
- x2 (apply max (map #(+ (:x %) (:width %)) bs))
- y2 (apply max (map #(+ (:y %) (:height %)) bs))]
- {:x x1 :y y1 :width (max 1 (- x2 x1)) :height (max 1 (- y2 y1))})))
- wrapper (mf/with-memo [objects] (render/shape-wrapper-factory objects))]
- (if bounds
- (let [{:keys [x y width height]} bounds]
- [:svg {:class (stl/css :preview-svg)
- :viewBox (dm/str x " " y " " width " " height)
- :preserveAspectRatio "xMidYMid meet"
- :xmlns "http://www.w3.org/2000/svg"
- :fill "none"}
- (for [shape tops]
- [:> wrapper {:key (str (:id shape)) :shape shape}])])
- [:div {:class (stl/css :preview-empty)}
- [:> i/icon* {:icon-id i/document :size "s"}]])))
-
-(defn missing-reason
- "Why `side` of diff entry `item` has nothing to draw. `:absent` when the
- entry never existed there (the other side added it), `:deleted` when
- that side deleted it, `:unavailable` when it exists there but the open
- file cannot draw it. `incoming` says the listed changes are main's."
- [item side incoming]
- (let [origin (if incoming :main :branch)]
- (case (:status item)
- :conflict :deleted
- :added (if (= side origin) :unavailable :absent)
- :deleted (if (= side origin) :deleted :unavailable)
- :unavailable)))
-
-(mf/defc missing-preview*
- "The empty stage of a side with nothing to draw, saying why."
- {::mf/private true}
- [{:keys [reason side open-side]}]
- (let [main? (= side :main)
- [icon title hint]
- (case reason
- :absent
- [i/add
- (if main?
- (tr "workspace.branches.review.missing.not-in-main")
- (tr "workspace.branches.review.missing.not-in-branch"))
- (if main?
- (tr "workspace.branches.review.missing.new-in-branch")
- (tr "workspace.branches.review.missing.new-in-main"))]
- :deleted
- [i/delete
- (if main?
- (tr "workspace.branches.review.missing.deleted-in-main")
- (tr "workspace.branches.review.missing.deleted-in-branch"))
- nil]
- [i/eye-off
- (tr "workspace.branches.review.missing.no-preview")
- (when (and open-side (not= side open-side))
- (if main?
- (tr "workspace.branches.review.missing.open-main")
- (tr "workspace.branches.review.missing.open-branch")))])]
- [:div {:class (stl/css :preview-missing)}
- [:> i/icon* {:icon-id icon :size "s" :class (stl/css :preview-missing-icon)}]
- [:> text* {:as "span" :typography t/body-small :class (stl/css :preview-missing-title)} title]
- (when hint
- [:> text* {:as "span" :typography t/body-small :class (stl/css :preview-missing-hint)} hint])]))
-
-(mf/defc entity-preview*
- "Visual preview of one side of a change, dispatching on entity kind:
- shapes render to SVG, library colors to a swatch, typographies to a text
- sample; everything else shows a type icon. A side with nothing to draw
- says why (`missing`: `{:reason :side :open-side}`, see
- `missing-reason`). A shape `highlight` is passed on to `shape-preview*`."
- [{:keys [kind value objects missing highlight]}]
- (cond
- (nil? value)
- [:> missing-preview* {:reason (:reason missing :unavailable)
- :side (:side missing)
- :open-side (:open-side missing)}]
-
- (= kind :shape)
- (if (contains? renderable-shape-types (:type value))
- [:> shape-preview* {:shape value :objects objects :highlight highlight}]
- [:div {:class (stl/css :preview-empty)}
- [:> i/icon* {:icon-id (brc/shape-icon-id {:shape-type (:type value)})}]])
-
- (= kind :color)
- [:div {:class (stl/css :preview-swatch)
- :style {:background (or (uc/color->background value)
- (brc/hex-color value)
- "transparent")}}]
-
- (= kind :typography)
- [:div {:class (stl/css :preview-type-sample)
- :style {:font-family (:font-family value)
- :font-weight (:font-weight value)
- :font-style (:font-style value)}}
- "Ag"]
-
- :else
- [:div {:class (stl/css :preview-empty)}
- [:> i/icon* {:icon-id (get brc/kind->icon kind i/git-branch)}]]))
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branch_review/previews.scss b/frontend/src/app/main/ui/workspace/sidebar/branch_review/previews.scss
deleted file mode 100644
index 4051356ad9..0000000000
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/previews.scss
+++ /dev/null
@@ -1,85 +0,0 @@
-// 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) KALEIDOS SUBSIDIARY SL
-
-@use "ds/_borders.scss" as *;
-@use "ds/typography.scss" as *;
-
-.preview-svg {
- inline-size: 100%;
- block-size: 100%;
-}
-
-// the outline of the layer an added or deleted change is about, drawn
-// over the board that holds it; the stroke keeps its width at any zoom
-.preview-highlight {
- --preview-highlight-color: var(--color-accent-success);
-
- // TODO: no DS token for these tints of the state colors.
- fill: color-mix(in srgb, var(--preview-highlight-color) 12%, transparent);
- stroke: var(--preview-highlight-color);
- stroke-width: 2;
- stroke-dasharray: 4 3;
-
- &.is-deleted {
- --preview-highlight-color: var(--color-accent-error);
- }
-}
-
-.preview-swatch {
- inline-size: 100%;
- block-size: 100%;
- border-radius: $br-4;
-}
-
-.preview-type-sample {
- @include use-typography("headline-medium");
-
- color: var(--color-static-black);
-
- // TODO: No exact DS typography match found.
- // Closest match: headline-medium (line-height 1 vs 1.4).
- line-height: 1;
-}
-
-.preview-empty {
- display: flex;
- align-items: center;
- justify-content: center;
- color: var(--color-static-black);
-}
-
-// the empty stage sits on the light checkerboard of `preview-card*`, the
-// same in both themes, so its text is dark whatever the theme
-.preview-missing {
- // TODO: no DS token for the tints of this color in this block.
- --preview-missing-color: var(--color-static-black);
-
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- gap: var(--sp-xxs);
- inline-size: 100%;
- block-size: 100%;
- padding: var(--sp-s);
- border: $b-1 dashed color-mix(in srgb, var(--preview-missing-color) 30%, transparent);
- border-radius: $br-4;
- background-color: color-mix(in srgb, var(--color-static-white) 50%, transparent);
- text-align: center;
-}
-
-.preview-missing-icon {
- margin-block-end: var(--sp-xxs);
- color: color-mix(in srgb, var(--preview-missing-color) 60%, transparent);
-}
-
-.preview-missing-title {
- color: var(--preview-missing-color);
-}
-
-.preview-missing-hint {
- color: color-mix(in srgb, var(--preview-missing-color) 60%, transparent);
-}
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branch_review/sides.cljs b/frontend/src/app/main/ui/workspace/sidebar/branch_review/sides.cljs
new file mode 100644
index 0000000000..54fb5361a3
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/sidebar/branch_review/sides.cljs
@@ -0,0 +1,132 @@
+;; 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) KALEIDOS SUBSIDIARY SL
+
+(ns app.main.ui.workspace.sidebar.branch-review.sides
+ "The two sides of a change, main and the branch. The diff carries whole
+ entities for conflicts and for added or deleted shapes; for a modified
+ entity the open file holds one side and the changed attrs give the
+ other, which is enough to put a page together as either side has it."
+ (:require
+ [app.common.types.shape :as cts]))
+
+(def ^:private content-shape-types
+ "Shape types whose geometry is their content; the others keep it in
+ their position and size."
+ #{:path :bool})
+
+(defn- with-values
+ "`entity` with each attr of `attrs` (`{attr {:main .. :branch ..}}`)
+ set to the value `side-of` picks a side for; an attr it picks no side
+ for stays as it is."
+ [entity attrs side-of]
+ (let [changed (into [] (filter (comp some? side-of)) (keys attrs))
+ entity (reduce (fn [entity attr]
+ (let [v (get-in attrs [attr (side-of attr)])]
+ (if (nil? v)
+ (dissoc entity attr)
+ (assoc entity attr v))))
+ entity
+ changed)]
+ ;; the diff leaves out `:selrect` and `:points` (they follow from
+ ;; the geometry), so a layer that moved or resized gets them again
+ ;; from its own, or it would be placed with the open side's: a path
+ ;; or a boolean from its content, any other from its position and
+ ;; size
+ (cond
+ (and (contains? content-shape-types (:type entity))
+ (some #{:content} changed))
+ (cts/setup-path (dissoc entity :selrect :points))
+
+ (and (not (contains? content-shape-types (:type entity)))
+ (some #{:x :y :width :height} changed))
+ (cts/setup-rect (dissoc entity :selrect :points))
+
+ :else
+ entity)))
+
+(defn side-entity
+ "One side (`:main` or `:branch`) of diff entry `item`. A conflict carries
+ both; a clean change carries the attrs that differ, so the side the open
+ file does not hold is the open entity with those attrs swapped in. An
+ entry that does not exist on a side has no entity there: `origin` is
+ the side that made the change, so what it added is missing on the
+ other one and what it deleted is missing on its own. An added or
+ deleted shape the open file lacks comes whole in the entry's `:shape`."
+ [item side open-side origin open-entity]
+ (cond
+ (= :conflict (:status item))
+ (get item side)
+
+ (and (= :added (:status item)) (not= side origin))
+ nil
+
+ (and (= :deleted (:status item)) (= side origin))
+ nil
+
+ (= side open-side)
+ open-entity
+
+ (nil? open-entity)
+ (:shape item)
+
+ :else
+ (with-values open-entity (:changed-attrs item) (constantly side))))
+
+(defn- put-entity
+ "`objects` with shape `id` as `entity`. Nil takes the shape out of its
+ parent, so boards draw without it; a shape `objects` lacked is put
+ into its parent, so boards draw it."
+ [objects id entity]
+ (if (some? entity)
+ (let [parent-id (:parent-id entity)]
+ (cond-> (assoc objects id entity)
+ (and (contains? objects parent-id)
+ (not (contains? objects id))
+ (not (some #(= id %) (get-in objects [parent-id :shapes]))))
+ (update-in [parent-id :shapes] (fnil conj []) id)))
+ (let [parent-id (:parent-id (get objects id))]
+ (cond-> (dissoc objects id)
+ (contains? objects parent-id)
+ (update-in [parent-id :shapes] (fn [ids] (filterv #(not= id %) ids)))))))
+
+(defn side-objects
+ "The page `objects` as they stand on `side`, with every shape change of
+ `items` that lives on this page put on that side. `origin` is the side
+ that made the changes: the branch, or main for the changes an update
+ brings (see `side-entity`)."
+ ([objects items side open-side]
+ (side-objects objects items side open-side :branch))
+ ([objects items side open-side origin]
+ (reduce
+ (fn [objects item]
+ (if (not= :shape (:kind item))
+ objects
+ (let [id (:id item)]
+ (put-entity objects id (side-entity item side open-side origin (get objects id))))))
+ objects
+ items)))
+
+(defn resolved-objects
+ "The page `objects` of the open branch with the choices made so far for
+ `conflicts` (`resolutions`, by conflict id): a layer takes main's
+ value for each property main was chosen for, main's whole version when
+ main was chosen for all of it (none when main deleted it), and stays
+ as the branch has it otherwise."
+ [objects conflicts resolutions]
+ (reduce
+ (fn [objects {:keys [id] :as conflict}]
+ (let [res (get resolutions id)
+ open (get objects id)]
+ (cond
+ (not= :shape (:kind conflict)) objects
+ (= :main res) (put-entity objects id (:main conflict))
+ (and (map? res) (some? open))
+ (put-entity objects id
+ (with-values open (:changed-attrs conflict)
+ #(when (= :main (get res %)) :main)))
+ :else objects)))
+ objects
+ conflicts))
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branches.cljs b/frontend/src/app/main/ui/workspace/sidebar/branches.cljs
index 36cf1fc59a..b5051ba896 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/branches.cljs
+++ b/frontend/src/app/main/ui/workspace/sidebar/branches.cljs
@@ -7,12 +7,12 @@
(ns app.main.ui.workspace.sidebar.branches
(:require-macros [app.main.style :as stl])
(:require
- [app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.time :as ct]
[app.config :as cf]
[app.main.data.modal :as modal]
[app.main.data.workspace.branches :as dwb]
+ [app.main.data.workspace.compare :as dwcp]
[app.main.data.workspace.drawing :as dwd]
[app.main.data.workspace.layout :as dwlo]
[app.main.data.workspace.pull-requests :as dwpr]
@@ -21,10 +21,12 @@
[app.main.refs :as refs]
[app.main.repo :as rp]
[app.main.store :as st]
+ [app.main.ui.context :as ctx]
[app.main.ui.ds.buttons.button :refer [button*]]
[app.main.ui.ds.buttons.icon-button :refer [icon-button*]]
[app.main.ui.ds.controls.checkbox :refer [checkbox*]]
[app.main.ui.ds.controls.input :refer [input*]]
+ [app.main.ui.ds.controls.textarea :refer [textarea*]]
[app.main.ui.ds.foundations.assets.icon :as i]
[app.main.ui.ds.layout.menu :refer [menu* menu-item* menu-separator*]]
[app.main.ui.ds.layout.modal :refer [modal* modal-header* modal-content* modal-footer*]]
@@ -33,10 +35,9 @@
[app.main.ui.ds.product.avatar :refer [avatar*]]
[app.main.ui.ds.product.empty-state :refer [empty-state*]]
[app.main.ui.ds.tooltip :refer [tooltip*]]
+ [app.main.ui.workspace.compare.common :as cc]
[app.main.ui.workspace.review.tasks :as rvt]
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
- [app.main.ui.workspace.sidebar.branch-review.compare]
- [app.main.ui.workspace.sidebar.branch-review.conflicts]
[app.main.ui.workspace.sidebar.pull-requests :as prui :refer [pr-state-badge*]]
[app.util.dom :as dom]
[app.util.globals :as globals]
@@ -51,9 +52,6 @@
(def ^:private branches
(l/derived :workspace-branches st/state))
-(def ^:private branch-diff
- (l/derived :workspace-branch-diff st/state))
-
(def ^:private branch-context
;; see refs/branch-context: the state entry wraps the row under :info
(l/derived #(get-in % [:workspace-branch-context :info]) st/state))
@@ -66,6 +64,7 @@
[]
(let [;; a branch only grows from main, so the open file is main
library? (boolean (:is-shared (mf/deref refs/file)))
+ desc-id (mf/use-id)
branch-name* (mf/use-state "")
description* (mf/use-state "")
branch-name (deref branch-name*)
@@ -102,12 +101,13 @@
:on-change on-name-change}]
[:div {:class (stl/css :field)}
- [:label {:class (stl/css :field-label)}
+ [:label {:class (stl/css :field-label) :for desc-id}
(tr "workspace.branches.create.description-label")]
- [:textarea {:class (stl/css :textarea)
- :value description
- :on-change on-description-change
- :rows 2}]]
+ [:> textarea* {:id desc-id
+ :class (stl/css :field-textarea)
+ :value description
+ :on-change on-description-change
+ :rows 2}]]
[:div {:class (stl/css :field)}
[:label {:class (stl/css :field-label)}
@@ -282,23 +282,17 @@
(vec))
on-notify (mf/use-fn #(swap! notify* not))
- ;; what goes in and what stays out, when the compare dialog of this
- ;; branch is the one that asked for the merge
- diff-st (mf/deref branch-diff)
- ;; counted as the compare list shows them: the layers added or
- ;; deleted with a container go with it (`brc/fold-cascades`)
- changes (when (and (= (:id branch) (:branch-id diff-st))
- (= :loaded (:status diff-st)))
- (let [indexed (into [] (map-indexed vector) (get-in diff-st [:diff :changes]))
- folded (into #{} (comp (mapcat val) (map first))
- (brc/fold-cascades indexed))]
- (into []
- (comp (remove (fn [[idx _]] (contains? folded idx)))
- (map second)
- (filter #(contains? #{:added :modified :deleted} (:status %))))
- indexed)))
- left-out (count (filter #(contains? (or excluded #{}) (:key %)) changes))
- going-in (- (count changes) left-out)
+ ;; what goes in and what stays out, when the comparison of this
+ ;; branch is the one that asked for the merge. Counted as its list
+ ;; shows them: the layers added or deleted with a container go
+ ;; with it
+ diff-st (mf/deref refs/branch-diff)
+ model (mf/with-memo [diff-st branch excluded]
+ (when (and (= (:id branch) (:branch-id diff-st))
+ (= :loaded (:status diff-st)))
+ (brc/change-model (:diff diff-st) {:excluded excluded})))
+ left-out (:left-out model 0)
+ going-in (:kept model 0)
;; The branch name and "main" are highlighted (foreground-primary)
;; within the otherwise secondary-colored prompt. We wrap each of
@@ -345,7 +339,7 @@
[:span {:key idx :class (stl/css :modal-message-emphasis)} part]
[:span {:key idx} part]))]
- (when (seq changes)
+ (when (pos? (+ going-in left-out))
[:ul {:class (stl/css :merge-summary)}
[:li (tr "workspace.branches.merge.summary-in" (i18n/c going-in))]
(when (pos? left-out)
@@ -356,12 +350,12 @@
[:label {:class (stl/css :field-label)
:for "merge-branch-comment"}
(tr "workspace.branches.merge.comment-label")]
- [:textarea {:id "merge-branch-comment"
- :class (stl/css :textarea)
- :value comment
- :max-length 4000
- :on-change on-comment-change
- :rows 3}]]
+ [:> textarea* {:id "merge-branch-comment"
+ :class (stl/css :field-textarea)
+ :value comment
+ :max-length 4000
+ :on-change on-comment-change
+ :rows 3}]]
(when (seq open-tasks)
[:div {:class (stl/css :merge-tasks)}
@@ -468,9 +462,13 @@
[{:keys [branch]}]
(let [profile (mf/deref refs/profile)
profiles (mf/deref refs/profiles)
+ file-id (mf/use-ctx ctx/current-file-id)
+ desc-id (mf/use-id)
author (or (get profiles (:created-by branch))
(when (= (:created-by branch) (:id profile)) (avatar-profile profile)))
author? (= (:created-by branch) (:id profile))
+ ;; a branch is compared with main from the branch itself
+ current? (= file-id (:branch-file-id branch))
status (:status branch)
merged? (= "merged" status)
archived? (= "archived" status)
@@ -493,7 +491,9 @@
(st/emit! (dwb/set-branch-description (:id branch) (str/trim desc)))
(reset! editing? false)))
on-compare (mf/use-fn (mf/deps branch)
- #(modal/show! :branch-compare {:branch branch}))
+ #(st/emit! (dwcp/enter branch)))
+ on-open (mf/use-fn (mf/deps branch)
+ #(st/emit! (dwb/open-branch (:branch-file-id branch))))
on-restore (mf/use-fn (mf/deps branch)
#(confirm-archive! branch false))
on-materialize (mf/use-fn (mf/deps branch)
@@ -516,17 +516,19 @@
;; description: shown read-only, editable inline by the author
[:div {:class (stl/css :info-section)}
[:div {:class (stl/css :info-section-head)}
- [:span {:class (stl/css :field-label)} (tr "workspace.branches.info.description")]
+ [:label {:class (stl/css :field-label) :for desc-id}
+ (tr "workspace.branches.info.description")]
(when (and author? (not (deref editing?)))
[:> button* {:variant "ghost" :on-click on-edit} (tr "labels.edit")])]
(if (deref editing?)
[:div {:class (stl/css :info-desc-edit)}
- [:textarea {:class (stl/css :textarea :info-desc-input)
- :value desc
- :on-change on-desc-change
- :rows 3
- :auto-focus true
- :placeholder (tr "workspace.branches.info.description-placeholder")}]
+ [:> textarea* {:id desc-id
+ :class (stl/css :field-textarea :info-desc-input)
+ :value desc
+ :on-change on-desc-change
+ :rows 3
+ :auto-focus true
+ :placeholder (tr "workspace.branches.info.description-placeholder")}]
[:div {:class (stl/css :info-desc-actions)}
[:> button* {:variant "secondary" :on-click on-cancel} (tr "labels.cancel")]
[:> button* {:variant "primary" :on-click on-save} (tr "labels.save")]]]
@@ -587,13 +589,24 @@
;; the dialog closes from its header; the footer only acts on the
;; branch. The work of a merged branch is in main: there is nothing
- ;; to compare
+ ;; to compare. Another branch opens first, as it is compared from
+ ;; its own file
[:> modal-footer* {}
- (when-not merged?
+ (cond
+ merged?
+ nil
+
+ current?
[:> button* {:variant (if archived? "secondary" "primary")
:icon i/git-compare-arrows
:on-click on-compare}
- (tr "workspace.branches.compare")])
+ (tr "workspace.branches.compare")]
+
+ :else
+ [:> button* {:variant (if archived? "secondary" "primary")
+ :icon i/arrow-up-right
+ :on-click on-open}
+ (tr "workspace.branches.open")])
;; an archived branch is read-only: it leaves the branch engine as an
;; ordinary file, or comes back to work restored, its primary action.
;; The buttons follow the bottom bar of an open archived branch
@@ -645,7 +658,7 @@
(fn [event]
(dom/stop-propagation event)
(on-set-menu false)
- (modal/show! :branch-compare {:branch entry})))
+ (st/emit! (dwcp/enter entry))))
on-update
(mf/use-fn
@@ -776,12 +789,13 @@
[:div {:class (stl/css :branch-entry-body)}
(if (deref editing?)
- [:input {:class (stl/css :branch-rename-input)
- :default-value (:name entry)
- :auto-focus true
- :on-click (fn [e] (dom/stop-propagation e))
- :on-blur on-rename-commit
- :on-key-down on-rename-key-down}]
+ [:> input* {:class (stl/css :branch-rename-input)
+ :aria-label (tr "workspace.branches.rename.title")
+ :default-value (:name entry)
+ :auto-focus true
+ :on-click dom/stop-propagation
+ :on-blur on-rename-commit
+ :on-key-down on-rename-key-down}]
[:span {:class (stl/css :branch-entry-name)} (:name entry)])
[:div {:class (stl/css :branch-entry-meta)}
;; Main is the default branch: always show it the same way (no avatar,
@@ -837,9 +851,14 @@
:on-click on-toggle-menu}])}
[:> menu-item* {:id "info" :on-action on-info}
(tr "workspace.branches.menu.info")]
+ ;; a branch is compared with main from the branch itself: any
+ ;; other one opens first
(when-not merged?
- [:> menu-item* {:id "compare" :on-action on-compare}
- (tr "workspace.branches.compare")])
+ (if current
+ [:> menu-item* {:id "compare" :on-action on-compare}
+ (tr "workspace.branches.compare")]
+ [:> menu-item* {:id "open" :on-action on-open}
+ (tr "workspace.branches.open")]))
(when (and (not closed?) (pos? (or behind 0)))
[:> menu-item* {:id "update" :on-action on-update}
(tr "workspace.branches.update")])
@@ -1063,18 +1082,6 @@
;; --- Branch context banner (shown while editing a branch)
-(defn- canvas-center
- "The middle of the canvas, in pixels from the left of the window. The bar of
- the branch centers there and not on the window, or at a usual width it would
- cover the folded palettes, on the left of the canvas."
- [vport rulers?]
- (let [left-sidebar (dom/get-element "left-sidebar-aside")
- left (-> (dom/get-data left-sidebar "width")
- (d/parse-integer)
- (d/nilv 0))
- rulers (if rulers? 22 0)]
- (+ left rulers (/ (- (:width vport) rulers) 2))))
-
(defn- banner-status
"What the bottom banner says about the open branch, most pressing
first and in the order of its primary action: merged, archived,
@@ -1126,9 +1133,39 @@
:icon i/git-branch
:label (tr "workspace.branches.banner.status.up-to-date")})))
+(mf/defc compare-banner-content*
+ "What the banner says and offers while the branch is compared with
+ main, or the conflicts of a merge or an update are resolved: where the
+ comparison stands, the way out and its main action."
+ {::mf/private true}
+ []
+ (let [comparison (cc/use-comparison)
+ {:keys [icon warning title detail exit action]} (cc/bar comparison)]
+ [:div {:class (stl/css :branch-banner-content)}
+ [:div {:class (stl/css-case :branch-banner-icon true
+ :branch-banner-icon-warning warning)}
+ [:> i/icon* {:icon-id icon}]]
+ [:div {:class (stl/css :branch-banner-text)}
+ [:span {:class (stl/css :branch-banner-title)} title]
+ [:span {:class (stl/css :branch-banner-review)} detail]]
+ [:div {:class (stl/css :branch-banner-separator)}]
+ [:div {:class (stl/css :branch-banner-actions)}
+ (when (some? action)
+ [:> button* {:variant "primary"
+ :icon (:icon action)
+ :disabled (boolean (:disabled action))
+ :on-click (:on-click action)}
+ (:label action)])
+ [:> icon-button* {:variant "ghost"
+ :icon (:icon exit)
+ :aria-label (:label exit)
+ :tooltip-placement "top"
+ :on-click (:on-click exit)}]]]))
+
(mf/defc branch-context-banner*
[{:keys [file-id]}]
(let [ctx (mf/deref branch-context)
+ comparing? (some? (mf/deref refs/compare-mode))
merged? (= "merged" (:status ctx))
archived? (= "archived" (:status ctx))
@@ -1180,12 +1217,12 @@
on-toggle-menu (mf/use-fn #(swap! menu-open* not))
on-menu-change (mf/use-fn #(reset! menu-open* %))
- on-compare (mf/use-fn (mf/deps ctx) #(modal/show! :branch-compare {:branch ctx}))
+ on-compare (mf/use-fn (mf/deps ctx) #(st/emit! (dwcp/enter ctx)))
on-update (mf/use-fn (mf/deps ctx) #(brc/confirm-update! ctx))
on-open-main (mf/use-fn (mf/deps ctx) #(st/emit! (dwb/open-branch (:source-file-id ctx))))
on-restore (mf/use-fn (mf/deps ctx) #(confirm-archive! ctx false))
on-materialize (mf/use-fn (mf/deps ctx) #(confirm-materialize! ctx))
- on-resolve (mf/use-fn (mf/deps ctx) #(modal/show! :branch-conflicts {:branch ctx :mode :merge}))
+ on-resolve (mf/use-fn (mf/deps ctx) #(st/emit! (dwcp/enter ctx) (dwcp/start-resolve)))
on-merge
(mf/use-fn
@@ -1276,7 +1313,7 @@
(when ctx
[:div {:id "branch-banner"
:style (when (some? vport)
- #js {"insetInlineStart" (dm/str (canvas-center vport rulers?) "px")})
+ #js {"insetInlineStart" (dm/str (prui/canvas-center vport rulers?) "px")})
:class (stl/css-case :branch-banner true
:branch-banner-merged (or merged? archived?)
:is-collapsed collapsed?)}
@@ -1286,141 +1323,144 @@
:on-click on-toggle}
[:div {:class (stl/css :branch-banner-handle-btn)}]]
;; the header row names the branch; the banner says where it
- ;; stands and offers what to do next
- [:div {:class (stl/css :branch-banner-content)}
- [:div {:class (stl/css-case :branch-banner-icon true
- :branch-banner-icon-warning (contains? #{:conflicts :counts-error} (:id status)))}
- [:> i/icon* {:icon-id (:icon status)}]]
- [:div {:class (stl/css :branch-banner-text)}
- [:span {:class (stl/css :branch-banner-title)} (:label status)]
- (when (some? open-pr)
- [:span {:class (stl/css :branch-banner-review)} (:title open-pr)])]
- [:div {:class (stl/css :branch-banner-separator)}]
-
- (when (pos? (or my-tasks 0))
- [:*
- [:> prui/banner-button* {:class (stl/css :branch-banner-tasks)
- :on-click on-my-tasks}
- [:> i/icon* {:icon-id i/view-as-list :size "s"}]
- (tr "workspace.tasks.for-you-count" (i18n/c my-tasks))]
- [:div {:class (stl/css :branch-banner-separator)}]])
-
- [:div {:class (stl/css :branch-banner-actions)}
- (cond
- merged?
- [:> button* {:variant "secondary"
- :icon i/arrow-up-right
- :on-click on-open-main}
- (tr "workspace.branches.banner.view-main")]
-
- ;; an archived branch was set aside unmerged and is read-only: it
- ;; can be compared with main, brought back to work, or taken out
- ;; as an ordinary file
- archived?
- [:*
- [:> button* {:variant "secondary"
- :icon i/git-compare-arrows
- :on-click on-compare}
- (tr "workspace.branches.compare")]
- [:> button* {:variant "secondary"
- :icon i/git-branch-minus
- :on-click on-materialize}
- (tr "workspace.branches.materialize.action")]
- [:> button* {:variant "primary"
- :icon i/history
- :on-click on-restore}
- (tr "workspace.branches.menu.restore")]]
-
- :else
- [:*
- [:> button* {:variant "secondary"
- :icon i/git-compare-arrows
- :on-click on-compare}
- (tr "workspace.branches.compare")]
-
- ;; with pull requests enabled the primary flow is asking for a
- ;; review (merging moves to the options menu)
- (case primary
- :resolve
- [:> button* {:variant "primary"
- :icon i/git-merge-conflict
- :on-click on-resolve}
- (tr "workspace.branches.conflicts.resolve")]
-
- :update
- [:> button* {:variant "primary"
- :icon i/status-update
- :on-click on-update}
- (tr "workspace.branches.update")]
-
- :open-review
- [:> button* {:variant "primary"
- :icon i/git-pull-request-arrow
- :on-click on-open-review}
- (tr "workspace.pull-requests.actions.open-review")]
-
- :request-review
- [:> button* {:variant "primary"
- :icon i/git-pull-request-create-arrow
- :on-click on-request-review}
- (tr "workspace.pull-requests.menu.request-review")]
-
- :merge
- [:> button* {:variant "primary"
- :icon i/git-merge
- :on-click on-merge}
- (tr "workspace.branches.merge.action")]
-
- nil)])
-
- ;; the branch's options, minus what the banner already offers as
- ;; a button; the banner sits at the bottom of the canvas, so the
- ;; menu opens upwards
- [:div {:class (stl/css :branch-banner-menu)}
- [:> menu* {:is-open menu-open?
- :on-open-change on-menu-change
- :on-action on-menu-action
- :placement "top end"
- :trigger
- (mf/html
- [:> icon-button* {:variant "ghost"
- :icon i/menu
- :aria-label (tr "labels.options")
- :aria-pressed menu-open?
- :on-click on-toggle-menu}])}
- [:> menu-item* {:id "info"}
- (tr "workspace.branches.menu.info")]
- (when (and open? (pos? behind) (not= primary :update))
- [:> menu-item* {:id "update"}
- (tr "workspace.branches.update")])
- (when (and open? prs-enabled? (nil? open-pr) (not= primary :request-review))
- [:> menu-item* {:id "request-review"}
- (tr "workspace.pull-requests.menu.request-review")])
- (when (and (some? open-pr) (not= primary :open-review))
- [:> menu-item* {:id "open-review"}
- (tr "workspace.pull-requests.actions.open-review")])
+ ;; stands and offers what to do next. While it is compared with
+ ;; main, the banner belongs to the comparison
+ (if comparing?
+ [:> compare-banner-content* {}]
+ [:div {:class (stl/css :branch-banner-content)}
+ [:div {:class (stl/css-case :branch-banner-icon true
+ :branch-banner-icon-warning (contains? #{:conflicts :counts-error} (:id status)))}
+ [:> i/icon* {:icon-id (:icon status)}]]
+ [:div {:class (stl/css :branch-banner-text)}
+ [:span {:class (stl/css :branch-banner-title)} (:label status)]
(when (some? open-pr)
- [:> menu-item* {:id "review-details"}
- (tr "workspace.pull-requests.menu.review-details")])
- (when pr-author?
- [:> menu-item* {:id "publish-review"}
- (tr "workspace.pull-requests.menu.publish")])
- (when (and open? prs-enabled? (not= primary :merge)
- (or (nil? open-pr) can-merge?))
- [:> menu-item* {:id "merge"}
- (tr "workspace.pull-requests.actions.merge")])
- (when (and (some? open-pr) (or pr-author? admin?))
- [:> menu-item* {:id "cancel-review"}
- (tr "workspace.pull-requests.actions.close")])
- (when open?
- [:> menu-item* {:id "rename"}
- (tr "labels.rename")])
- (when open?
- [:> menu-item* {:id "archive"}
- (tr "workspace.branches.menu.archive")])
- (when open?
- [:> menu-item* {:id "materialize"}
- (tr "workspace.branches.materialize.action")])
- [:> menu-separator* {}]
- [:> menu-item* {:id "delete"}
- (tr "labels.delete")]]]]]])))
+ [:span {:class (stl/css :branch-banner-review)} (:title open-pr)])]
+ [:div {:class (stl/css :branch-banner-separator)}]
+
+ (when (pos? (or my-tasks 0))
+ [:*
+ [:> prui/banner-button* {:class (stl/css :branch-banner-tasks)
+ :on-click on-my-tasks}
+ [:> i/icon* {:icon-id i/view-as-list :size "s"}]
+ (tr "workspace.tasks.for-you-count" (i18n/c my-tasks))]
+ [:div {:class (stl/css :branch-banner-separator)}]])
+
+ [:div {:class (stl/css :branch-banner-actions)}
+ (cond
+ merged?
+ [:> button* {:variant "secondary"
+ :icon i/arrow-up-right
+ :on-click on-open-main}
+ (tr "workspace.branches.banner.view-main")]
+
+ ;; an archived branch was set aside unmerged and is read-only: it
+ ;; can be compared with main, brought back to work, or taken out
+ ;; as an ordinary file
+ archived?
+ [:*
+ [:> button* {:variant "secondary"
+ :icon i/git-compare-arrows
+ :on-click on-compare}
+ (tr "workspace.branches.compare")]
+ [:> button* {:variant "secondary"
+ :icon i/git-branch-minus
+ :on-click on-materialize}
+ (tr "workspace.branches.materialize.action")]
+ [:> button* {:variant "primary"
+ :icon i/history
+ :on-click on-restore}
+ (tr "workspace.branches.menu.restore")]]
+
+ :else
+ [:*
+ [:> button* {:variant "secondary"
+ :icon i/git-compare-arrows
+ :on-click on-compare}
+ (tr "workspace.branches.compare")]
+
+ ;; with pull requests enabled the primary flow is asking for a
+ ;; review (merging moves to the options menu)
+ (case primary
+ :resolve
+ [:> button* {:variant "primary"
+ :icon i/git-merge-conflict
+ :on-click on-resolve}
+ (tr "workspace.branches.conflicts.resolve")]
+
+ :update
+ [:> button* {:variant "primary"
+ :icon i/status-update
+ :on-click on-update}
+ (tr "workspace.branches.update")]
+
+ :open-review
+ [:> button* {:variant "primary"
+ :icon i/git-pull-request-arrow
+ :on-click on-open-review}
+ (tr "workspace.pull-requests.actions.open-review")]
+
+ :request-review
+ [:> button* {:variant "primary"
+ :icon i/git-pull-request-create-arrow
+ :on-click on-request-review}
+ (tr "workspace.pull-requests.menu.request-review")]
+
+ :merge
+ [:> button* {:variant "primary"
+ :icon i/git-merge
+ :on-click on-merge}
+ (tr "workspace.branches.merge.action")]
+
+ nil)])
+
+ ;; the branch's options, minus what the banner already offers as
+ ;; a button; the banner sits at the bottom of the canvas, so the
+ ;; menu opens upwards
+ [:div {:class (stl/css :branch-banner-menu)}
+ [:> menu* {:is-open menu-open?
+ :on-open-change on-menu-change
+ :on-action on-menu-action
+ :placement "top end"
+ :trigger
+ (mf/html
+ [:> icon-button* {:variant "ghost"
+ :icon i/menu
+ :aria-label (tr "labels.options")
+ :aria-pressed menu-open?
+ :on-click on-toggle-menu}])}
+ [:> menu-item* {:id "info"}
+ (tr "workspace.branches.menu.info")]
+ (when (and open? (pos? behind) (not= primary :update))
+ [:> menu-item* {:id "update"}
+ (tr "workspace.branches.update")])
+ (when (and open? prs-enabled? (nil? open-pr) (not= primary :request-review))
+ [:> menu-item* {:id "request-review"}
+ (tr "workspace.pull-requests.menu.request-review")])
+ (when (and (some? open-pr) (not= primary :open-review))
+ [:> menu-item* {:id "open-review"}
+ (tr "workspace.pull-requests.actions.open-review")])
+ (when (some? open-pr)
+ [:> menu-item* {:id "review-details"}
+ (tr "workspace.pull-requests.menu.review-details")])
+ (when pr-author?
+ [:> menu-item* {:id "publish-review"}
+ (tr "workspace.pull-requests.menu.publish")])
+ (when (and open? prs-enabled? (not= primary :merge)
+ (or (nil? open-pr) can-merge?))
+ [:> menu-item* {:id "merge"}
+ (tr "workspace.pull-requests.actions.merge")])
+ (when (and (some? open-pr) (or pr-author? admin?))
+ [:> menu-item* {:id "cancel-review"}
+ (tr "workspace.pull-requests.actions.close")])
+ (when open?
+ [:> menu-item* {:id "rename"}
+ (tr "labels.rename")])
+ (when open?
+ [:> menu-item* {:id "archive"}
+ (tr "workspace.branches.menu.archive")])
+ (when open?
+ [:> menu-item* {:id "materialize"}
+ (tr "workspace.branches.materialize.action")])
+ [:> menu-separator* {}]
+ [:> menu-item* {:id "delete"}
+ (tr "labels.delete")]]]]])])))
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branches.scss b/frontend/src/app/main/ui/workspace/sidebar/branches.scss
index 9d50c67a37..2a0bb9e13a 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/branches.scss
+++ b/frontend/src/app/main/ui/workspace/sidebar/branches.scss
@@ -123,20 +123,22 @@
// ahead/behind: a side with changes stands out, a zero stays quiet
.count {
+ --count-foreground-color: var(--color-foreground-secondary);
+
@include use-typography("code-font");
display: inline-flex;
align-items: center;
gap: var(--sp-xxs);
- color: var(--color-foreground-secondary);
+ color: var(--count-foreground-color);
&.has-changes {
- color: var(--color-accent-primary);
+ --count-foreground-color: var(--color-accent-primary);
}
// what main has and the branch lacks reads in the error color
&.is-behind.has-changes {
- color: var(--color-foreground-error);
+ --count-foreground-color: var(--color-foreground-error);
}
}
@@ -206,17 +208,9 @@
color: var(--color-foreground-secondary);
}
-.textarea {
- inline-size: 100%;
+// the DS text area (`textarea*`) keeps the height these fields had
+.field-textarea {
min-block-size: $sz-64;
- padding: var(--sp-s);
- border-radius: $br-8;
- border: $b-1 solid var(--color-background-quaternary);
- background-color: var(--color-background-tertiary);
- color: var(--color-foreground-primary);
- resize: vertical;
-
- @include use-typography("body-medium");
}
.derive-from {
@@ -404,10 +398,9 @@
border: $b-2 solid var(--color-background-quaternary);
background-color: var(--color-background-primary);
- // it must beat the viewport controls, which are raised to z-index 1
- // while a drawing tool is active
- // TODO: no DS z-index token for 2.
- z-index: 2;
+ // over the canvas and what is drawn on it (the viewport controls, the
+ // marks, main beside the branch), as the toolbar is
+ z-index: var(--z-index-panels);
transition:
inset-block-end 0.2s,
block-size 0.2s;
@@ -446,6 +439,8 @@
inset-block-start: 0;
block-size: var(--sp-m);
inline-size: 100%;
+
+ // TODO: no DS z-index token for 1.
z-index: 1;
}
@@ -555,15 +550,9 @@
background-color: var(--color-background-tertiary);
}
+// the DS input (`input*`) takes the width of the row
.branch-rename-input {
inline-size: 100%;
- padding: var(--sp-xxs) var(--sp-xs);
- border-radius: $br-8;
- border: $b-1 solid var(--color-accent-primary);
- background-color: var(--color-background-tertiary);
- color: var(--color-foreground-primary);
-
- @include use-typography("body-medium");
}
.limits-section {
diff --git a/frontend/src/app/main/ui/workspace/sidebar/pull_requests.cljs b/frontend/src/app/main/ui/workspace/sidebar/pull_requests.cljs
index 8159ab7fc6..e0bf83e3ec 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/pull_requests.cljs
+++ b/frontend/src/app/main/ui/workspace/sidebar/pull_requests.cljs
@@ -13,11 +13,13 @@
review / details modals and the review-sandbox banner."
(:require-macros [app.main.style :as stl])
(:require
+ [app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.time :as ct]
[app.common.uuid :as uuid]
[app.main.data.modal :as modal]
[app.main.data.team :as dtm]
+ [app.main.data.workspace.compare :as dwcp]
[app.main.data.workspace.pull-requests :as dwpr]
[app.main.data.workspace.review :as dwrv]
[app.main.refs :as refs]
@@ -25,6 +27,7 @@
[app.main.ui.ds.buttons.button :refer [button*]]
[app.main.ui.ds.buttons.icon-button :refer [icon-button*]]
[app.main.ui.ds.controls.input :refer [input*]]
+ [app.main.ui.ds.controls.textarea :refer [textarea*]]
[app.main.ui.ds.foundations.assets.icon :as i]
[app.main.ui.ds.foundations.typography :as t]
[app.main.ui.ds.foundations.typography.heading :refer [heading*]]
@@ -33,8 +36,8 @@
[app.main.ui.ds.layout.modal :refer [modal* modal-header* modal-content* modal-footer*]]
[app.main.ui.ds.notifications.context-notification :refer [context-notification*]]
[app.main.ui.ds.product.avatar :refer [avatar*]]
- [app.main.ui.ds.product.progress-bar :refer [progress-bar*]]
[app.main.ui.ds.tooltip :refer [tooltip*]]
+ [app.main.ui.workspace.compare.common :as cc]
[app.util.dom :as dom]
[app.util.i18n :refer [tr]]
[cuerdas.core :as str]
@@ -98,11 +101,11 @@
:conflicts (:conflicts pr)})
(defn open-compare!
- "Open the branching compare dialog on the pull request's branch, so the
+ "Compare the pull request's branch with main on the canvas, so the
proposed changes can be inspected. Like merging, it diffs the LIVE
- branch against main."
+ branch against main. The branch is the open file inside its review."
[pr]
- (modal/show! :branch-compare {:branch (pr->branch pr) :is-review true}))
+ (st/emit! (dwcp/enter (pr->branch pr))))
(defn confirm-merge!
"Open the branching merge dialog for the pull request's branch:
@@ -129,7 +132,9 @@
(mf/defc banner-button*
"A quiet action inside a banner on the canvas, with what it does as
- `children`."
+ `children`. Not the DS button: its ghost variant is uppercase and
+ turns the accent color on hover, too loud for a bar over the canvas,
+ and the DS has no quieter one yet."
[{:keys [class children] :rest props}]
(let [props (mf/spread-props props {:class [class (stl/css :banner-button)]
:type "button"})]
@@ -177,6 +182,7 @@
[{:keys [branch]}]
(let [profile (mf/deref refs/profile)
team (mf/deref refs/team)
+ desc-id (mf/use-id)
members (->> (get team :members)
(filter :is-active)
(remove #(= (:id %) (:id profile))))
@@ -237,13 +243,14 @@
:on-change on-title-change}]
[:div {:class (stl/css :field)}
- [:label {:class (stl/css :field-label)}
+ [:label {:class (stl/css :field-label) :for desc-id}
(tr "workspace.pull-requests.create.description-label")]
- [:textarea {:class (stl/css :textarea)
- :value description
- :placeholder (tr "workspace.pull-requests.create.description-placeholder")
- :on-change on-description-change
- :rows 3}]]
+ [:> textarea* {:id desc-id
+ :class (stl/css :field-textarea)
+ :value description
+ :placeholder (tr "workspace.pull-requests.create.description-placeholder")
+ :on-change on-description-change
+ :rows 3}]]
[:div {:class (stl/css :field)}
[:label {:class (stl/css :field-label)}
@@ -256,6 +263,10 @@
[:li {:key (dm/str (:id member))}
[:button {:class (stl/css-case :reviewer-option true
:is-selected (contains? selected (:id member)))
+ ;; a box to tick: the row keeps the avatar the DS
+ ;; checkbox has no room for
+ :role "checkbox"
+ :aria-checked (contains? selected (:id member))
:data-reviewer-id (dm/str (:id member))
:on-click on-toggle-reviewer}
[:> avatar* {:profile member :variant "S"}]
@@ -283,7 +294,8 @@
{::mf/register modal/components
::mf/register-as :pull-request-review}
[{:keys [pr]}]
- (let [verdict* (mf/use-state "approved")
+ (let [comment-id (mf/use-id)
+ verdict* (mf/use-state "approved")
verdict (deref verdict*)
comment* (mf/use-state "")
comment (deref comment*)
@@ -317,9 +329,14 @@
:subtitle (:title pr)}]
[:> modal-content* {:class (stl/css :dialog-content)}
- [:div {:class (stl/css :verdict-options)}
+ ;; one of two, each with a hint the DS radio buttons have no room for
+ [:div {:class (stl/css :verdict-options)
+ :role "radiogroup"
+ :aria-label (tr "workspace.pull-requests.review.title")}
[:button {:class (stl/css-case :verdict-option true
:is-selected (= verdict "approved"))
+ :role "radio"
+ :aria-checked (= verdict "approved")
:data-verdict "approved"
:on-click on-select-verdict}
[:> i/icon* {:icon-id i/tick}]
@@ -331,6 +348,8 @@
[:button {:class (stl/css-case :verdict-option true
:is-selected (= verdict "changes-requested"))
+ :role "radio"
+ :aria-checked (= verdict "changes-requested")
:data-verdict "changes-requested"
:on-click on-select-verdict}
[:> i/icon* {:icon-id i/triangle-alert}]
@@ -341,13 +360,14 @@
(tr "workspace.pull-requests.review.request-changes-hint")]]]]
[:div {:class (stl/css :field)}
- [:label {:class (stl/css :field-label)}
+ [:label {:class (stl/css :field-label) :for comment-id}
(tr "workspace.pull-requests.review.comment-label")]
- [:textarea {:class (stl/css :textarea)
- :value comment
- :placeholder (tr "workspace.pull-requests.review.comment-placeholder")
- :on-change on-comment-change
- :rows 3}]]]
+ [:> textarea* {:id comment-id
+ :class (stl/css :field-textarea)
+ :value comment
+ :placeholder (tr "workspace.pull-requests.review.comment-placeholder")
+ :on-change on-comment-change
+ :rows 3}]]]
[:> modal-footer* {:class (stl/css :dialog-footer)}
[:> button* {:class (stl/css :dialog-action)
@@ -525,6 +545,63 @@
;; --- Review bar (replaces the branch banner inside a design review)
+(mf/defc compare-banner-content*
+ "What the review bar says and offers while the branch of the review is
+ compared with main, or its conflicts are resolved: the comparison, how
+ far along it is, its main action and the way back to the review. Only
+ who may merge gets the action that merges."
+ {::mf/private true}
+ [{:keys [pr can-merge]}]
+ (let [comparison (cc/use-comparison)
+ resolving? (= :resolve (:phase comparison))
+ {:keys [icon title progress exit action]} (cc/bar comparison)]
+ [:div {:class (stl/css :pr-banner-content)}
+ [:div {:class (stl/css :pr-banner-icon)}
+ [:> i/icon* {:icon-id icon}]]
+ [:div {:class (stl/css :pr-banner-text)}
+ (if resolving?
+ [:span {:class (stl/css :pr-banner-name)} title]
+ [:*
+ [:span {:class (stl/css :pr-banner-title)}
+ (tr "workspace.compare.bar.comparing")]
+ [:span {:class (stl/css :pr-banner-name)}
+ (if (:incoming comparison)
+ (tr "workspace.review.route" (tr "workspace.branches.main") (:branch-name pr))
+ (tr "workspace.review.route" (:branch-name pr) (tr "workspace.branches.main")))]])]
+
+ (when (some? progress)
+ [:*
+ [:div {:class (stl/css :pr-banner-separator)}]
+ [:span {:class (stl/css :pr-banner-title :pr-banner-progress)} progress]])
+
+ [:div {:class (stl/css :pr-banner-separator)}]
+
+ [:div {:class (stl/css :pr-banner-actions)}
+ (when (and (some? action) (or can-merge (not (:merge action))))
+ [:> button* {:variant "primary"
+ :icon (:icon action)
+ :disabled (boolean (:disabled action))
+ :on-click (:on-click action)}
+ (:label action)])
+ [:> icon-button* {:variant "ghost"
+ :icon (:icon exit)
+ :aria-label (:label exit)
+ :tooltip-placement "top"
+ :on-click (:on-click exit)}]]]))
+
+(defn canvas-center
+ "The middle of the canvas, in pixels from the left of the window. The bar of
+ the branch and the one of the review center there and not on the window, or
+ at a usual width they would cover the folded palettes, on the left of the
+ canvas. The rulers take their side of it."
+ [vport rulers?]
+ (let [left-sidebar (dom/get-element "left-sidebar-aside")
+ left (-> (dom/get-data left-sidebar "width")
+ (d/parse-integer)
+ (d/nilv 0))
+ rulers (if rulers? 22 0)]
+ (+ left rulers (/ (- (:width vport) rulers) 2))))
+
(mf/defc pr-review-banner*
"The bar at the bottom of the canvas inside a design review: the review
being reviewed, the progress of its tasks, its details, the verdict of
@@ -536,7 +613,10 @@
that says the branch has changes they cannot see yet."
[]
(let [preview (mf/deref refs/pull-request-preview)
+ vport (mf/deref refs/workspace-vport)
+ rulers? (mf/deref refs/rulers?)
pr (:info preview)
+ comparing? (some? (mf/deref refs/compare-mode))
profile (mf/deref refs/profile)
team (mf/deref refs/team)
tasks* (mf/deref refs/tasks)
@@ -587,69 +667,75 @@
(when (some? pr)
[:div {:class (stl/css :pr-banner)
+ :style (when (some? vport)
+ #js {"insetInlineStart" (dm/str (canvas-center vport rulers?) "px")})
:role "region"
:aria-label (tr "workspace.review.bar.label")}
- [:div {:class (stl/css :pr-banner-content)}
- [:div {:class (stl/css :pr-banner-icon)}
- [:> i/icon* {:icon-id i/git-pull-request-arrow}]]
- [:div {:class (stl/css :pr-banner-text)}
- [:span {:class (stl/css :pr-banner-title)}
- (tr "workspace.pull-requests.banner.reviewing")]
- [:span {:class (stl/css :pr-banner-name)} (:title pr)]
- ;; the author publishes them with the button instead
- (when (and outdated? (not author?))
- [:> tooltip* {:content (tr "workspace.pull-requests.badge.outdated-hint")
- :placement "top"}
- [:span {:class (stl/css :pr-badge :badge-outdated)}
- (tr "workspace.pull-requests.badge.outdated")]])]
+ ;; while its branch is compared with main, the bar belongs to the
+ ;; comparison
+ (if comparing?
+ [:> compare-banner-content* {:pr pr :can-merge can-merge?}]
+ [:div {:class (stl/css :pr-banner-content)}
+ [:div {:class (stl/css :pr-banner-icon)}
+ [:> i/icon* {:icon-id i/git-pull-request-arrow}]]
+ [:div {:class (stl/css :pr-banner-text)}
+ [:span {:class (stl/css :pr-banner-title)}
+ (tr "workspace.pull-requests.banner.reviewing")]
+ ;; cut short when it is long: the whole of it on hover
+ [:span {:class (stl/css :pr-banner-name) :title (:title pr)} (:title pr)]
+ ;; the author publishes them with the button instead
+ (when (and outdated? (not author?))
+ [:> tooltip* {:content (tr "workspace.pull-requests.badge.outdated-hint")
+ :placement "top"}
+ [:span {:class (stl/css :pr-badge :badge-outdated)}
+ (tr "workspace.pull-requests.badge.outdated")]])]
- [:div {:class (stl/css :pr-banner-separator)}]
+ [:div {:class (stl/css :pr-banner-separator)}]
- ;; the progress of the tasks shows once the review has any
- (when (pos? total)
- [:*
- [:> banner-button* {:on-click on-tasks}
- [:> i/icon* {:icon-id i/view-as-list :size "s"}]
- [:span (tr "workspace.review.bar.tasks" closed total)]
- [:> progress-bar* {:value closed
- :total total
- :class (stl/css :pr-banner-progress)
- :aria-hidden true}]]
+ ;; the progress of the tasks shows once the review has any
+ (when (pos? total)
+ [:*
+ [:> banner-button* {:on-click on-tasks}
+ [:> i/icon* {:icon-id i/view-as-list :size "s"}]
+ [:span (tr "workspace.review.bar.tasks" closed total)]]
- [:div {:class (stl/css :pr-banner-separator)}]])
+ [:div {:class (stl/css :pr-banner-separator)}]])
- [:div {:class (stl/css :pr-banner-actions)}
- [:> button* {:variant "secondary" :on-click on-details}
- (tr "workspace.review.bar.details")]
- (when (and outdated? author?)
- [:> tooltip* {:content (tr "workspace.pull-requests.banner.publish-hint")
- :placement "top"}
- [:> button* {:variant "primary" :on-click on-publish}
- (tr "workspace.pull-requests.banner.publish")]])
- (when reviewer?
- [:> button* {:variant "primary" :on-click on-review}
- (tr "workspace.review.submit")])
- [:> button* {:variant "ghost" :on-click on-exit}
- (tr "workspace.pull-requests.banner.exit")]
+ [:div {:class (stl/css :pr-banner-actions)}
+ [:> button* {:variant "secondary" :on-click on-details}
+ (tr "workspace.review.bar.details")]
+ (when (and outdated? author?)
+ [:> tooltip* {:content (tr "workspace.pull-requests.banner.publish-hint")
+ :placement "top"}
+ [:> button* {:variant "primary" :on-click on-publish}
+ (tr "workspace.pull-requests.banner.publish")]])
+ (when reviewer?
+ [:> button* {:variant "primary" :on-click on-review}
+ (tr "workspace.review.submit")])
+ [:> icon-button* {:variant "ghost"
+ :icon i/exit
+ :aria-label (tr "workspace.pull-requests.banner.exit")
+ :tooltip-placement "top"
+ :on-click on-exit}]
- ;; the bar sits at the bottom of the canvas: its menu opens upwards
- [:div {:class (stl/css :pr-banner-menu)}
- [:> menu* {:is-open menu-open?
- :on-open-change on-menu-change
- :on-action on-menu-action
- :placement "top end"
- :trigger
- (mf/html
- [:> icon-button* {:variant "ghost"
- :icon i/menu
- :aria-label (tr "labels.options")
- :aria-pressed menu-open?
- :on-click on-toggle-menu}])}
- [:> menu-item* {:id "compare"}
- (tr "workspace.branches.compare")]
- (when can-merge?
- [:> menu-item* {:id "merge"}
- (tr "workspace.pull-requests.actions.merge")])
- (when can-cancel?
- [:> menu-item* {:id "cancel"}
- (tr "workspace.pull-requests.banner.cancel")])]]]]])))
+ ;; the bar sits at the bottom of the canvas: its menu opens upwards
+ [:div {:class (stl/css :pr-banner-menu)}
+ [:> menu* {:is-open menu-open?
+ :on-open-change on-menu-change
+ :on-action on-menu-action
+ :placement "top end"
+ :trigger
+ (mf/html
+ [:> icon-button* {:variant "ghost"
+ :icon i/menu
+ :aria-label (tr "labels.options")
+ :aria-pressed menu-open?
+ :on-click on-toggle-menu}])}
+ [:> menu-item* {:id "compare"}
+ (tr "workspace.branches.compare")]
+ (when can-merge?
+ [:> menu-item* {:id "merge"}
+ (tr "workspace.pull-requests.actions.merge")])
+ (when can-cancel?
+ [:> menu-item* {:id "cancel"}
+ (tr "workspace.pull-requests.banner.cancel")])]]]])])))
diff --git a/frontend/src/app/main/ui/workspace/sidebar/pull_requests.scss b/frontend/src/app/main/ui/workspace/sidebar/pull_requests.scss
index a9b193cc3c..6799d9c3b2 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/pull_requests.scss
+++ b/frontend/src/app/main/ui/workspace/sidebar/pull_requests.scss
@@ -7,6 +7,7 @@
@use "ds/_borders.scss" as *;
@use "ds/_sizes.scss" as *;
@use "ds/_utils.scss" as *;
+@use "ds/mixins.scss" as *;
@use "ds/typography.scss" as *;
// --- State badges
@@ -129,17 +130,9 @@
color: var(--color-foreground-secondary);
}
-.textarea {
- inline-size: 100%;
+// the DS text area (`textarea*`) keeps the height these fields had
+.field-textarea {
min-block-size: $sz-64;
- padding: var(--sp-s);
- border-radius: $br-8;
- border: $b-1 solid var(--color-background-quaternary);
- background-color: var(--color-background-tertiary);
- color: var(--color-foreground-primary);
- resize: vertical;
-
- @include use-typography("body-medium");
}
// --- Reviewer picker (create dialog)
@@ -383,10 +376,9 @@
border: $b-2 solid var(--color-accent-info);
background-color: var(--color-background-primary);
- // it must beat the viewport controls, which are raised to z-index 1
- // while a drawing tool is active
- // TODO: no DS z-index token for 2.
- z-index: 2;
+ // over the canvas and what is drawn on it (the viewport controls, the
+ // marks, main beside the branch), as the toolbar is
+ z-index: var(--z-index-panels);
transition:
inset-block-end 0.2s,
block-size 0.2s;
@@ -411,22 +403,36 @@
color: var(--color-accent-info);
}
+// one line: a long name is cut short instead of growing the bar
.pr-banner-text {
display: flex;
align-items: center;
gap: var(--sp-xs);
+ min-inline-size: 0;
+ white-space: nowrap;
@include use-typography("body-small");
}
.pr-banner-title {
+ flex-shrink: 0;
color: var(--color-foreground-secondary);
}
.pr-banner-name {
+ @include text-ellipsis;
+
+ max-inline-size: px2rem(280);
color: var(--color-foreground-primary);
}
+// how far the review of the comparison is, beside its route
+.pr-banner-progress {
+ @include use-typography("body-small");
+
+ white-space: nowrap;
+}
+
.pr-banner-actions {
display: flex;
align-items: center;
@@ -466,7 +472,3 @@
--banner-button-fg-color: var(--color-foreground-primary);
}
}
-
-.pr-banner-progress {
- inline-size: $sz-64;
-}
diff --git a/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs b/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs
index b375763c3f..48b6252f35 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs
+++ b/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs
@@ -21,8 +21,8 @@
[app.main.ui.context :as ctx]
[app.main.ui.ds.buttons.icon-button :refer [icon-button*]]
[app.main.ui.ds.foundations.assets.icon :as i :refer [icon*]]
+ [app.main.ui.ds.product.tag :refer [tag*]]
[app.main.ui.hooks :as hooks]
- [app.main.ui.notifications.badge :refer [badge-notification]]
[app.main.ui.workspace.sidebar.scroll :as sc]
[app.render-wasm.api :as wasm.api]
[app.util.dom :as dom]
@@ -335,9 +335,8 @@
(if ^boolean read-only?
(when (or ^boolean (:can-edit permissions) ^boolean reviewing?)
- [:& badge-notification {:is-focus true
- :size :small
- :content (tr "labels.view-only")}])
+ [:> tag* {:variant "pill" :icon i/lock}
+ (tr "labels.view-only")])
[:> icon-button* {:variant "ghost"
:aria-label (tr "workspace.sidebar.sitemap.add-page")
:on-click on-create
diff --git a/frontend/src/app/main/ui/workspace/top_toolbar.cljs b/frontend/src/app/main/ui/workspace/top_toolbar.cljs
index 1ae9671c18..17eb6016e7 100644
--- a/frontend/src/app/main/ui/workspace/top_toolbar.cljs
+++ b/frontend/src/app/main/ui/workspace/top_toolbar.cljs
@@ -27,6 +27,7 @@
[app.main.ui.context :as ctx]
[app.main.ui.ds.buttons.icon-button :refer [icon-button*]]
[app.main.ui.ds.foundations.assets.icon :as i]
+ [app.main.ui.workspace.compare.view-menu :refer [view-mode-menu*]]
[app.util.dom :as dom]
[app.util.i18n :refer [tr]]
[app.util.keyboard :as kbd]
@@ -294,32 +295,29 @@
:ref ref
:on-selected on-selected}]]))
-(mf/defc review-toolbar*
- "The toolbar of the review mode: the review is read-only, so it offers
- moving around, commenting on a spot or a layer, commenting on an area,
- creating a task and showing the changes of the branch."
+(defn- on-select-review-tool
+ [event]
+ (let [tool (-> (dom/get-current-target event)
+ (dom/get-data "tool")
+ (keyword))]
+ (st/emit! (dwrv/set-tool tool))))
+
+(mf/defc read-only-toolbar*
+ "The toolbar of a read-only mode of the workspace (a design review, the
+ comparison of a branch with main). It offers no drawing: moving
+ around, commenting on a spot or a layer, commenting on an area and
+ creating a task, and then what the mode adds (`children`). Inside a
+ design review (`is-review`) the tool in use takes the review colour;
+ outside it, the accent of the drawing tools."
{::mf/private true}
- [{:keys [rulers-enabled toolbar-hidden on-toggle-toolbar]}]
+ [{:keys [aria-label is-review rulers-enabled toolbar-hidden on-toggle-toolbar children]}]
(let [local (mf/deref refs/review-local)
drawing (mf/deref refs/selected-drawing-tool)
tool (if (= drawing :comments)
(get local :tool :comment)
- :move)
- changes (some? (:show-changes local))
-
- on-select-tool
- (mf/use-fn
- (fn [event]
- (let [tool (-> (dom/get-current-target event)
- (dom/get-data "tool")
- (keyword))]
- (st/emit! (dwrv/set-tool tool)))))
-
- on-toggle-changes
- (mf/use-fn #(st/emit! (dwrv/toggle-changes)))]
-
+ :move)]
[:div {:role "toolbar"
- :aria-label (tr "workspace.review.toolbar.label")
+ :aria-label aria-label
:tab-index "0"
:class (stl/css-case :toolbar true
:no-rulers (not rulers-enabled)
@@ -331,28 +329,61 @@
[:task i/view-as-list (tr "workspace.review.toolbar.task")]]]
[:li {:key (name id) :class (stl/css :toolbar-option)}
[:> icon-button* {:variant "ghost"
- :class (stl/css :review-tool)
+ :class (stl/css-case :review-tool is-review)
:tooltip-placement "bottom"
:aria-pressed (= tool id)
:aria-label label
:icon icon
:data-tool (name id)
- :on-click on-select-tool}]])
+ :on-click on-select-review-tool}]])
[:div {:class (stl/css :toolbar-separator)}]
- [:li {:class (stl/css :toolbar-option)}
- [:> icon-button* {:variant "ghost"
- :class (stl/css :review-tool)
- :tooltip-placement "bottom"
- :aria-pressed changes
- :aria-label (tr "workspace.review.toolbar.show-changes")
- :icon i/shown
- :on-click on-toggle-changes}]]]
+ [:li {:class (stl/css :toolbar-option)} children]]
[:button {:title (tr "workspace.toolbar.toggle-toolbar")
:aria-label (tr "workspace.toolbar.toggle-toolbar")
:class (stl/css :toolbar-handler)
:on-click on-toggle-toolbar}
[:div {:class (stl/css :toolbar-handler-indicator)}]]]))
+(mf/defc review-toolbar*
+ "The toolbar of the review mode, which also shows the changes of the
+ branch since the review opened."
+ {::mf/private true}
+ [{:keys [rulers-enabled toolbar-hidden on-toggle-toolbar]}]
+ (let [local (mf/deref refs/review-local)
+ changes (some? (:show-changes local))
+
+ on-toggle-changes
+ (mf/use-fn #(st/emit! (dwrv/toggle-changes)))]
+
+ [:> read-only-toolbar* {:aria-label (tr "workspace.review.toolbar.label")
+ :is-review true
+ :rulers-enabled rulers-enabled
+ :toolbar-hidden toolbar-hidden
+ :on-toggle-toolbar on-toggle-toolbar}
+ [:> icon-button* {:variant "ghost"
+ :class (stl/css :review-tool)
+ :tooltip-placement "bottom"
+ :aria-pressed changes
+ :aria-label (tr "workspace.review.toolbar.show-changes")
+ :icon i/shown
+ :on-click on-toggle-changes}]]))
+
+(mf/defc compare-toolbar*
+ "The toolbar of the compare mode, with or without a design review
+ around it: the same tools, and the control that says how the canvas
+ shows the changes in place of the one that shows them."
+ {::mf/private true}
+ [{:keys [mode is-review rulers-enabled toolbar-hidden on-toggle-toolbar]}]
+ [:> read-only-toolbar* {:aria-label (tr "workspace.compare.toolbar.label")
+ :is-review is-review
+ :rulers-enabled rulers-enabled
+ :toolbar-hidden toolbar-hidden
+ :on-toggle-toolbar on-toggle-toolbar}
+ [:> view-mode-menu* {:view (:view mode)
+ :side-mode (:side-mode mode)
+ :hidden (boolean (:hidden mode))
+ :is-review is-review}]])
+
(mf/defc top-toolbar*
{::mf/wrap [mf/memo]}
[{:keys [layout]}]
@@ -365,6 +396,7 @@
plugins-enabled? (features/active-feature? @st/state "plugins/runtime")
read-only? (mf/use-ctx ctx/workspace-read-only?)
reviewing? (some? (mf/deref refs/pull-request-preview))
+ compare-mode (mf/deref refs/compare-mode)
mcp-conn-status (get mcp :connection-status)
mcp-valid-token? (get mcp :token-valid)
@@ -419,6 +451,13 @@
(st/emit! (dwc/toggle-toolbar-visibility))))]
(cond
+ (some? compare-mode)
+ [:> compare-toolbar* {:mode compare-mode
+ :is-review reviewing?
+ :rulers-enabled rulers-enabled
+ :toolbar-hidden toolbar-hidden
+ :on-toggle-toolbar on-toggle-toolbar}]
+
^boolean reviewing?
[:> review-toolbar* {:rulers-enabled rulers-enabled
:toolbar-hidden toolbar-hidden
diff --git a/frontend/src/app/main/ui/workspace/viewport.cljs b/frontend/src/app/main/ui/workspace/viewport.cljs
index e3e0aef469..8344529bac 100644
--- a/frontend/src/app/main/ui/workspace/viewport.cljs
+++ b/frontend/src/app/main/ui/workspace/viewport.cljs
@@ -26,6 +26,7 @@
[app.main.ui.hooks :as ui-hooks]
[app.main.ui.measurements :as msr]
[app.main.ui.shapes.export :as use]
+ [app.main.ui.workspace.compare.overlays :refer [compare-overlays*]]
[app.main.ui.workspace.review.overlays :refer [review-overlays*]]
[app.main.ui.workspace.shapes :as shapes]
[app.main.ui.workspace.shapes.path.editor :refer [path-editor*]]
@@ -213,6 +214,13 @@
mode-inspect? (= options-mode :inspect)
+ compare-mode (mf/deref refs/compare-mode)
+ comparing? (some? compare-mode)
+ ;; comparing, the canvas answers for the layers with a change
+ ;; alone: no layer is selected, and a click picks a change. A
+ ;; commenting tool takes the canvas back
+ picking? (and comparing? (nil? drawing-tool))
+
on-click (actions/on-click hover selected edition path-drawing? drawing-tool space? selrect z?)
on-context-menu (actions/on-context-menu hover hover-ids read-only?)
on-double-click (actions/on-double-click hover hover-ids selected hover-top-frame-id path-drawing? base-objects edition drawing-tool z? read-only?)
@@ -223,7 +231,12 @@
on-drag-end (actions/on-drag-over comp-inst-ref)
on-drop (actions/on-drop file comp-inst-ref)
on-pointer-down (actions/on-pointer-down @hover selected edition drawing-tool text-editing? path-editing? grid-editing?
- path-drawing? create-comment? space? panning z? read-only?)
+ path-drawing? create-comment? space? panning z? read-only?
+ picking?)
+ on-pick (actions/on-pick-change space? z?)
+ on-pick-fit (actions/on-pick-change-fit space? z?)
+ on-click (if picking? on-pick on-click)
+ on-double-click (if picking? on-pick-fit on-double-click)
on-pointer-up (actions/on-pointer-up disable-paste-ref)
@@ -365,7 +378,10 @@
:grid-shape editing-shape
:single-select single-select?}]])
- [:div {:class (stl/css :viewport-overlays)}
+ ;; the wheel with ctrl or cmd held zooms the canvas over them too
+ ;; (`actions/on-mouse-wheel`)
+ [:div {:class (stl/css :viewport-overlays)
+ :data-canvas-overlays true}
;; The behaviour inside a foreign object is a bit different that in plain HTML so we wrap
;; inside a foreign object "dummy" so this awkward behaviour is take into account
[:svg {:style {:top 0 :left 0 :position "fixed" :width "100%" :height "100%" :opacity (when-not (dbg/enabled? :html-text) 0)}}
@@ -381,6 +397,26 @@
:modifiers modifiers
:edition edition}])]]]
+
+ ;; the changes of a design review and the layer picker of a task
+ [:> review-overlays* {:vbox vbox
+ :vport vport
+ :zoom zoom
+ :page-id page-id}]
+
+ ;; the changes of the branch against main, in the compare mode
+ (when ^boolean comparing?
+ [:> compare-overlays* {:vbox vbox
+ :vport vport
+ :zoom zoom
+ :page-id page-id
+ :show-rulers show-rulers?
+ :hover-ids (when picking?
+ (cond-> (vec @hover-ids)
+ (some? (:id @hover)) (conj (:id @hover))))}])
+
+ ;; above the marks of the changes: a thread or a task opened from
+ ;; a bubble covers them
(when show-comments?
[:> comments/comments-layer* {:vbox vbox
:page-id page-id
@@ -389,12 +425,6 @@
:zoom zoom
:show-rulers show-rulers?}])
- ;; the changes of a design review and the layer picker of a task
- [:> review-overlays* {:vbox vbox
- :vport vport
- :zoom zoom
- :page-id page-id}]
-
(when picking-color?
[:> pixel-overlay/pixel-overlay* {:vport vport
:viewport-ref viewport-ref}])]
@@ -454,7 +484,10 @@
:view-box (utils/format-viewbox vbox)
:ref on-viewport-ref
:class (dm/str @cursor (when drawing-tool " drawing") " " (stl/css :viewport-controls))
- :style {:touch-action "none"}
+ ;; a layer with a change says it answers to a click
+ :style (if (and picking? (= :canvas (:hovered-from compare-mode)) (some? (:hovered compare-mode)))
+ #js {:touchAction "none" :cursor "pointer"}
+ #js {:touchAction "none"})
:fill "none"
:on-click on-click
@@ -487,7 +520,7 @@
[:& editor-v1/text-editor-svg {:shape editing-shape
:modifiers modifiers}]))
- (when show-frame-outline?
+ (when (and show-frame-outline? (not picking?))
(let [outlined-frame-id
(->> @hover-ids
(filter #(cfh/frame-shape? (get base-objects %)))
@@ -512,7 +545,7 @@
[:> outline/shape-outlines*
{:objects base-objects
:selected selected
- :hover #{(:id @hover) @frame-hover}
+ :hover (when-not picking? #{(:id @hover) @frame-hover})
:highlighted highlighted
:edition edition
:zoom zoom
diff --git a/frontend/src/app/main/ui/workspace/viewport/actions.cljs b/frontend/src/app/main/ui/workspace/viewport/actions.cljs
index 2763174079..033076eafa 100644
--- a/frontend/src/app/main/ui/workspace/viewport/actions.cljs
+++ b/frontend/src/app/main/ui/workspace/viewport/actions.cljs
@@ -14,6 +14,7 @@
[app.common.uuid :as uuid]
[app.config :as cfg]
[app.main.data.workspace :as dw]
+ [app.main.data.workspace.compare :as dwcp]
[app.main.data.workspace.drawing :as dd]
[app.main.data.workspace.libraries :as dwl]
[app.main.data.workspace.media :as dwm]
@@ -40,12 +41,15 @@
(def scale-per-pixel -0.0057)
(defn on-pointer-down
+ "`view-only?` leaves the pointer the view alone (pan and zoom): no
+ selection, no area and no move start from it."
[{:keys [id blocked hidden type]} selected edition drawing-tool text-editing?
- node-editing? grid-editing? drawing-path? create-comment? space? panning z? read-only?]
+ node-editing? grid-editing? drawing-path? create-comment? space? panning z? read-only?
+ view-only?]
(mf/use-callback
(mf/deps id blocked hidden type selected edition drawing-tool text-editing?
node-editing? grid-editing? drawing-path? create-comment? @z? @space?
- panning read-only?)
+ panning read-only? view-only?)
(fn [event]
;; We need to handle editor related stuff here because
;; handling on editor dom node does not works properly.
@@ -97,7 +101,8 @@
(not blocked)
(not hidden)
(not create-comment?)
- (not drawing-path?))
+ (not drawing-path?)
+ (not view-only?))
(cond
node-editing?
;; Handle path node area selection
@@ -195,6 +200,29 @@
(st/emit! (dw/decrease-zoom pt))
(st/emit! (dw/increase-zoom pt)))))))))
+(defn- canvas-target?
+ [event]
+ (dom/class? (dom/get-target event) "viewport-controls"))
+
+(defn on-pick-change
+ "The click of the canvas in the compare mode: it chooses the change of
+ the layer under the pointer, or none on any other spot."
+ [space? z?]
+ (mf/use-fn
+ (fn [event]
+ (when (and (canvas-target? event) (not @space?) (not @z?))
+ (st/emit! (dwcp/pick-hovered))))))
+
+(defn on-pick-change-fit
+ "The double click of the canvas in the compare mode: it zooms to the
+ layer of the change under the pointer."
+ [space? z?]
+ (mf/use-fn
+ (fn [event]
+ (dom/stop-propagation event)
+ (when (and (canvas-target? event) (not @space?) (not @z?))
+ (st/emit! (dwcp/fit-hovered))))))
+
(defn on-double-click
[hover hover-ids selected hover-top-frame-id drawing-path? objects edition drawing-tool z? read-only?]
@@ -444,6 +472,8 @@
picking-color? (= "pixel-overlay" (.-id target))
comments-layer? (dom/is-child? (dom/get-element "comments") target)
+ ;; the marks, tags and bars drawn over the canvas
+ overlays? (some? (dom/get-parent-with-data target "canvas-overlays"))
raw-pt (dom/get-client-position event)
pt (uwvv/point->viewport raw-pt)
@@ -464,7 +494,7 @@
(schedule-zoom! (mf/ref-val scroll-state) scale pt)
(schedule-scroll! (mf/ref-val scroll-state) (mf/ref-val zoom-ref) event delta-x delta-y)))
- (when (and comments-layer? (or ctrl? mod?))
+ (when (and (or comments-layer? overlays?) (or ctrl? mod?))
(dom/prevent-default event)
(dom/stop-propagation event)
(schedule-zoom! (mf/ref-val scroll-state) scale pt)))))))
diff --git a/frontend/src/app/main/ui/workspace/viewport_wasm.cljs b/frontend/src/app/main/ui/workspace/viewport_wasm.cljs
index 75dcfe7c45..28006d044e 100644
--- a/frontend/src/app/main/ui/workspace/viewport_wasm.cljs
+++ b/frontend/src/app/main/ui/workspace/viewport_wasm.cljs
@@ -29,6 +29,7 @@
[app.main.ui.hooks :as ui-hooks]
[app.main.ui.hooks.wasm-effect :refer [with-wasm-effect]]
[app.main.ui.measurements :as msr]
+ [app.main.ui.workspace.compare.overlays :refer [compare-overlays*]]
[app.main.ui.workspace.review.overlays :refer [review-overlays*]]
[app.main.ui.workspace.shapes.path.editor :refer [path-editor*]]
[app.main.ui.workspace.shapes.text.editor :as editor-v1]
@@ -331,6 +332,13 @@
context-loss-overlay? (mf/deref wasm.api/context-loss-overlay?)
transition-reveal-rulers? (mf/deref wasm.api/transition-reveal-rulers?)
+ compare-mode (mf/deref refs/compare-mode)
+ comparing? (some? compare-mode)
+ ;; comparing, the canvas answers for the layers with a change
+ ;; alone: no layer is selected, and a click picks a change. A
+ ;; commenting tool takes the canvas back
+ picking? (and comparing? (nil? drawing-tool))
+
on-click (actions/on-click hover selected edition path-drawing? drawing-tool space? selrect z?)
on-context-menu (actions/on-context-menu hover hover-ids read-only?)
on-double-click (actions/on-double-click hover hover-ids selected hover-top-frame-id path-drawing? base-objects edition drawing-tool z? read-only?)
@@ -341,7 +349,12 @@
on-drag-end (actions/on-drag-over comp-inst-ref)
on-drop (actions/on-drop file comp-inst-ref)
on-pointer-down (actions/on-pointer-down @hover selected edition drawing-tool text-editing? path-editing? grid-editing?
- path-drawing? create-comment? space? panning z? read-only?)
+ path-drawing? create-comment? space? panning z? read-only?
+ picking?)
+ on-pick (actions/on-pick-change space? z?)
+ on-pick-fit (actions/on-pick-change-fit space? z?)
+ on-click (if picking? on-pick on-click)
+ on-double-click (if picking? on-pick-fit on-double-click)
on-pointer-up (actions/on-pointer-up disable-paste-ref)
@@ -681,7 +694,12 @@
(wasm.api/set-shape-hidden false)
(wasm.api/request-render "stop-path-edition")))))
- [:div {:class (dm/str @cursor " " (stl/css :viewport)) :style #js {"--zoom" zoom} :data-testid "viewport"}
+ [:div {:class (dm/str @cursor " " (stl/css :viewport))
+ ;; a layer with a change says it answers to a click
+ :style (if (and picking? (= :canvas (:hovered-from compare-mode)) (some? (:hovered compare-mode)))
+ #js {"--zoom" zoom :cursor "pointer"}
+ #js {"--zoom" zoom})
+ :data-testid "viewport"}
(cond
(some? preview-id)
@@ -704,7 +722,29 @@
:grid-shape editing-shape
:single-select single-select?}]])
- [:div {:class (stl/css :viewport-overlays)}
+ ;; the wheel with ctrl or cmd held zooms the canvas over them too
+ ;; (`actions/on-mouse-wheel`)
+ [:div {:class (stl/css :viewport-overlays)
+ :data-canvas-overlays true}
+ ;; the changes of a design review and the layer picker of a task
+ [:> review-overlays* {:vbox vbox
+ :vport vport
+ :zoom zoom
+ :page-id page-id}]
+
+ ;; the changes of the branch against main, in the compare mode
+ (when ^boolean comparing?
+ [:> compare-overlays* {:vbox vbox
+ :vport vport
+ :zoom zoom
+ :page-id page-id
+ :show-rulers show-rulers?
+ :hover-ids (when picking?
+ (cond-> (vec @hover-ids)
+ (some? (:id @hover)) (conj (:id @hover))))}])
+
+ ;; above the marks of the changes: a thread or a task opened from
+ ;; a bubble covers them
(when show-comments?
[:> comments/comments-layer* {:vbox vbox
:page-id page-id
@@ -713,12 +753,6 @@
:zoom zoom
:show-rulers show-rulers?}])
- ;; the changes of a design review and the layer picker of a task
- [:> review-overlays* {:vbox vbox
- :vport vport
- :zoom zoom
- :page-id page-id}]
-
(when picking-color?
[:> pixel-overlay/pixel-overlay-wasm* {:viewport-ref viewport-ref
:canvas-ref canvas-ref}])]
@@ -801,7 +835,7 @@
:else [:& editor-v1/text-editor-svg {:shape editing-shape
:ref text-editor-ref}]))
- (when show-frame-outline?
+ (when (and show-frame-outline? (not picking?))
(let [outlined-frame-id (->> @hover-ids
(filter #(cfh/frame-shape? (get base-objects %)))
(remove selected)
@@ -826,7 +860,7 @@
[:> outline/shape-outlines*
{:objects objects-for-outlines
:selected (when-not comments-mode? selected)
- :hover (when-not comments-mode? #{(:id @hover) @frame-hover})
+ :hover (when-not (or comments-mode? picking?) #{(:id @hover) @frame-hover})
:highlighted highlighted
:edition edition
:zoom zoom}])
diff --git a/frontend/test/frontend_tests/data/workspace_branches_test.cljs b/frontend/test/frontend_tests/data/workspace_branches_test.cljs
index bd5d712932..41619b1829 100644
--- a/frontend/test/frontend_tests/data/workspace_branches_test.cljs
+++ b/frontend/test/frontend_tests/data/workspace_branches_test.cljs
@@ -50,8 +50,8 @@
(defn- open-conflicts!
"Ask for a `mode` (`:merge` or `:update`) of `branch` and let the conflict
- answer open the modal, which then fetches its own diff in its direction,
- as `branch-conflicts-dialog*` does on mount."
+ answer seed the store, as the compare mode then fetches the diff in the
+ direction it resolves (`app.main.data.workspace.compare/start-resolve`)."
[store mode branch]
(ptk/emit! store (if (= mode :update)
(dwb/update-branch-from-main branch)
@@ -60,9 +60,12 @@
(if (= mode :update) :main->branch :branch->main))))
(defn- apply-resolutions!
- "Resolve every conflict to main and press Apply, as the modal does."
+ "Resolve every conflict to main and apply, as the compare mode does."
[store mode branch]
- (ptk/emit! store (dwb/set-all-resolutions :main))
+ (ptk/emit! store (dwb/set-conflict-resolutions
+ (into {}
+ (map (fn [conflict] [(:id conflict) :main]))
+ (get-in @store [:workspace-branch-conflicts :conflicts]))))
(let [resolutions (get-in @store [:workspace-branch-diff :resolutions])]
(ptk/emit! store (if (= mode :update)
(dwb/update-branch-from-main branch {:resolutions resolutions})
@@ -90,7 +93,7 @@
(reset! calls [])
(open-conflicts! store mode branch)
(t/is (= :loading (get-in @store [:workspace-branch-diff :status]))
- "the modal's diff fetch has not answered")
+ "the diff fetch has not answered")
(apply-resolutions! store mode branch)
(let [params (last-params calls mode)]
(t/is (= {conflict-id :main} (:resolutions params)))
@@ -113,7 +116,7 @@
store (make-store)]
(reset! calls [])
(open-conflicts! store mode branch)
- ;; the modal's diff fetch answers, computed at a newer main
+ ;; the diff fetch answers, computed at a newer main
(ptk/emit! store (dwb/update-branch-diff {:status :loaded
:diff {:meta {:main-revn 9}}}))
(apply-resolutions! store mode branch)
@@ -153,46 +156,60 @@
;;; --- Selective merge: the per-change selection ---
+(defn- excluded
+ "The per-change selection of the direction the diff of `store` shows."
+ [store]
+ (dwb/diff-excluded (:workspace-branch-diff @store)))
+
(t/deftest the-per-change-selection-toggles-and-clears
(let [store (make-store)
k1 "color//aaaaaaaa/1"
k2 "color//aaaaaaaa/2"]
(t/testing "a row flips on its own"
(ptk/emit! store (dwb/toggle-diff-excluded #{k1}))
- (t/is (= #{k1} (get-in @store [:workspace-branch-diff :excluded])))
+ (t/is (= #{k1} (excluded store)))
(ptk/emit! store (dwb/toggle-diff-excluded #{k1}))
- (t/is (= #{} (get-in @store [:workspace-branch-diff :excluded]))))
+ (t/is (= #{} (excluded store))))
(t/testing "a group sets every key of it to one side"
(ptk/emit! store (dwb/toggle-diff-excluded #{k1 k2} false))
- (t/is (= #{k1 k2} (get-in @store [:workspace-branch-diff :excluded])))
+ (t/is (= #{k1 k2} (excluded store)))
(ptk/emit! store (dwb/toggle-diff-excluded #{k1} false))
- (t/is (= #{k1 k2} (get-in @store [:workspace-branch-diff :excluded])))
+ (t/is (= #{k1 k2} (excluded store)))
(ptk/emit! store (dwb/toggle-diff-excluded #{k1 k2} true))
- (t/is (= #{} (get-in @store [:workspace-branch-diff :excluded]))))
+ (t/is (= #{} (excluded store))))
- (t/testing "closing the compare dialog drops the selection"
+ (t/testing "leaving the comparison drops the selection"
(ptk/emit! store (dwb/toggle-diff-excluded #{k1}))
(ptk/emit! store (dwb/clear-diff-excluded))
- (t/is (= #{} (get-in @store [:workspace-branch-diff :excluded]))))))
+ (t/is (= #{} (excluded store))))))
-(t/deftest a-refetch-of-the-same-comparison-keeps-the-selection
+(t/deftest each-direction-keeps-its-own-selection
(t/async done
- (let [calls (atom [])
- branch {:id (uuid/next)}]
+ (let [calls (atom [])
+ branch {:id (uuid/next)}
+ k1 "color//aaaaaaaa/1"
+ k2 "color//aaaaaaaa/2"]
(mock/with-mocks
{rp/cmd! (cmd-stub calls (uuid/next))}
(fn [done']
(let [store (make-store)]
(ptk/emit! store (dwb/fetch-branch-diff (:id branch)))
- (ptk/emit! store (dwb/toggle-diff-excluded #{"color//aaaaaaaa/1"}))
+ (ptk/emit! store (dwb/toggle-diff-excluded #{k1}))
(t/testing "the same branch and direction refetches over the selection"
(ptk/emit! store (dwb/fetch-branch-diff (:id branch)))
- (t/is (= #{"color//aaaaaaaa/1"}
- (get-in @store [:workspace-branch-diff :excluded]))))
- (t/testing "the other direction starts the selection over"
+ (t/is (= #{k1} (excluded store))))
+ (t/testing "the other direction has a selection of its own"
(ptk/emit! store (dwb/fetch-branch-diff (:id branch) :main->branch))
- (t/is (= #{} (get-in @store [:workspace-branch-diff :excluded]))))
+ (t/is (= #{} (excluded store)))
+ (ptk/emit! store (dwb/toggle-diff-excluded #{k2}))
+ (t/is (= #{k2} (excluded store))))
+ (t/testing "going back finds the first one as it was left"
+ (ptk/emit! store (dwb/fetch-branch-diff (:id branch)))
+ (t/is (= #{k1} (excluded store))))
+ (t/testing "another branch starts over"
+ (ptk/emit! store (dwb/fetch-branch-diff (uuid/next)))
+ (t/is (= #{} (excluded store))))
(rx/dispose! store))
(done'))
done))))
@@ -235,10 +252,9 @@
(ptk/emit! store (dwb/merge-branch branch {:comment " Ships the header "}))
(t/is (= "Ships the header" (:comment (last-params calls :merge)))
"the comment is trimmed")
- (t/testing "the conflict answer hands the comment to the modal"
- (t/is (= :branch-conflicts (get-in @store [::modal/modal :type])))
+ (t/testing "the conflict answer keeps the comment for the retry"
(t/is (= " Ships the header "
- (get-in @store [::modal/modal :props :comment]))))
+ (get-in @store [:workspace-branch-conflicts :comment]))))
(t/testing "a blank comment sends no `:comment` at all"
(ptk/emit! store (dwb/merge-branch branch {:comment " "}))
(t/is (not (contains? (last-params calls :merge) :comment))))
@@ -246,6 +262,108 @@
(done'))
done))))
+;;; --- Review marks: kept for the profile, dropped when the change moves ---
+
+(def ^:private title
+ {:kind :shape :status :modified :id (uuid/next) :key "shape/p/title"
+ :changed-attrs {:opacity {:main 1 :branch 0.5}}})
+
+(def ^:private logo
+ {:kind :shape :status :modified :id (uuid/next) :key "shape/p/logo"
+ :changed-attrs {:rx {:main 0 :branch 8}}})
+
+(defn- review-stub
+ "Fake `rp/cmd!` for a comparison that lists `title` and `logo`: the diff
+ answers at once, the marks answer with `marks`, and keeping a mark
+ fails when `fail-set?` holds. Every call is recorded into `calls`."
+ [calls marks fail-set?]
+ (mock/stub (fn [cmd params]
+ (swap! calls conj [cmd params])
+ (case cmd
+ :get-branch-diff (rx/of {:changes [title logo] :conflicts []})
+ :get-branch-change-reviews (rx/of @marks)
+ :set-branch-change-review (if fail-set?
+ (rx/throw (ex-info "refused" {}))
+ (rx/of nil))
+ (rx/empty)))))
+
+(defn- last-call
+ "Params of the last call of `cmd` recorded in `calls`."
+ [calls cmd]
+ (->> @calls (filter #(= cmd (first %))) (last) (second)))
+
+(defn- reviewed
+ [store]
+ (get-in @store [:workspace-branch-diff :reviewed]))
+
+(t/deftest ^:async a-mark-counts-while-its-change-is-what-it-was
+ (let [calls (atom [])
+ branch {:id (uuid/next)}
+ marks (atom [{:change-key (:key title) :fingerprint (dwb/change-fingerprint title)}
+ ;; the logo changed again after it was marked
+ {:change-key (:key logo) :fingerprint "what-it-was-before"}
+ ;; a change the comparison no longer lists
+ {:change-key "shape/p/gone" :fingerprint "x"}])]
+ (await
+ (mock/with-mocks* {rp/cmd! (review-stub calls marks false)}
+ (let [store (make-store)]
+ (ptk/emit! store (dwb/fetch-branch-diff (:id branch)))
+ (await (async/wait-for-store store #(seq (reviewed store)) "the marks load"))
+ (t/is (= #{(:key title)} (reviewed store)))
+ (t/is (= {:branch-id (:id branch) :direction :branch->main}
+ (last-call calls :get-branch-change-reviews))
+ "the marks are the ones of the direction compared")
+ (rx/dispose! store))))))
+
+(t/deftest ^:async marking-a-change-keeps-it-with-its-fingerprint
+ (let [calls (atom [])
+ branch {:id (uuid/next)}
+ marks (atom [])]
+ (await
+ (mock/with-mocks* {rp/cmd! (review-stub calls marks false)}
+ (let [store (make-store)]
+ (ptk/emit! store (dwb/fetch-branch-diff (:id branch)))
+ (await (async/wait-for #(some? (last-call calls :get-branch-change-reviews))
+ "the marks are asked for"))
+ (ptk/emit! store (dwb/toggle-diff-reviewed (:key logo) true))
+ (t/is (= #{(:key logo)} (reviewed store)) "the mark shows at once")
+ (await (async/wait-for #(some? (last-call calls :set-branch-change-review))
+ "the mark is kept"))
+ (t/is (= {:branch-id (:id branch)
+ :direction :branch->main
+ :change-key (:key logo)
+ :fingerprint (dwb/change-fingerprint logo)
+ :reviewed true}
+ (last-call calls :set-branch-change-review)))
+ (ptk/emit! store (dwb/toggle-diff-reviewed (:key logo)))
+ (t/is (= #{} (reviewed store)) "without a side it flips")
+ (await (async/wait-for #(false? (:reviewed (last-call calls :set-branch-change-review)))
+ "the mark is cleared"))
+ (rx/dispose! store))))))
+
+(t/deftest ^:async a-mark-that-cannot-be-kept-does-not-stay
+ (let [calls (atom [])
+ branch {:id (uuid/next)}
+ marks (atom [])]
+ (await
+ (mock/with-mocks* {rp/cmd! (review-stub calls marks true)}
+ (let [store (make-store)]
+ (ptk/emit! store (dwb/fetch-branch-diff (:id branch)))
+ (await (async/wait-for #(some? (last-call calls :get-branch-change-reviews))
+ "the marks are asked for"))
+ (ptk/emit! store (dwb/toggle-diff-reviewed (:key title) true))
+ (await (async/wait-for-store store #(empty? (reviewed store))
+ "the marks are read again"))
+ (t/is (= #{} (reviewed store)))
+ (rx/dispose! store))))))
+
+(t/deftest the-fingerprint-follows-what-the-change-is
+ (t/is (= (dwb/change-fingerprint title) (dwb/change-fingerprint (assoc title :label "Title"))))
+ (t/is (not= (dwb/change-fingerprint title)
+ (dwb/change-fingerprint (assoc-in title [:changed-attrs :opacity :branch] 0.6))))
+ (t/is (not= (dwb/change-fingerprint title)
+ (dwb/change-fingerprint (assoc title :status :deleted)))))
+
;;; --- Branch switcher: the entry point of the menu and the shortcut ---
(defn- make-store-with
diff --git a/frontend/test/frontend_tests/data/workspace_compare_test.cljs b/frontend/test/frontend_tests/data/workspace_compare_test.cljs
new file mode 100644
index 0000000000..2a55d98de8
--- /dev/null
+++ b/frontend/test/frontend_tests/data/workspace_compare_test.cljs
@@ -0,0 +1,607 @@
+;; 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) KALEIDOS SUBSIDIARY SL
+
+(ns frontend-tests.data.workspace-compare-test
+ "The compare mode: it opens on the branch alone, makes the workspace
+ read-only while it lasts, leaves nothing behind, and applies the
+ conflict choices with what the attempt that returned them carried."
+ (:require
+ [app.common.geom.rect :as grc]
+ [app.common.types.shape :as cts]
+ [app.common.uuid :as uuid]
+ [app.main.data.changes :as dch]
+ [app.main.data.workspace.branches :as dwb]
+ [app.main.data.workspace.compare :as dwcp]
+ [app.main.data.workspace.zoom :as dwz]
+ [app.main.repo :as rp]
+ [app.util.storage :as storage]
+ [beicon.v2.core :as rx]
+ [cljs.test :as t :include-macros true]
+ [frontend-tests.helpers.async :as async]
+ [frontend-tests.helpers.mock :as mock]
+ [potok.v2.core :as ptk]))
+
+(def ^:private branch-file-id (uuid/next))
+(def ^:private main-file-id (uuid/next))
+
+(def ^:private branch
+ {:id (uuid/next) :name "feature-login" :branch-file-id branch-file-id
+ :source-file-id main-file-id :ahead 2})
+
+(defn- make-store
+ [state]
+ (ptk/store {:state state
+ :on-error (fn [cause] (t/is false (str cause)))}))
+
+(defn- on-branch
+ []
+ (make-store {:current-file-id branch-file-id}))
+
+(defn- cmd-stub
+ "Fake `rp/cmd!` that records every call into `calls` and never answers,
+ so a diff stays loading and a merge or an update stays in flight."
+ [calls]
+ (mock/stub (fn [cmd params]
+ (swap! calls conj [cmd params])
+ (rx/subject))))
+
+(defn- last-call
+ [calls cmd]
+ (->> @calls (filter #(= cmd (first %))) (last) (second)))
+
+(t/deftest ^:async the-mode-opens-on-the-branch-and-fetches-its-diff
+ (let [calls (atom [])]
+ (await
+ (mock/with-mocks* {rp/cmd! (cmd-stub calls)}
+ (let [store (on-branch)]
+ (ptk/emit! store (dwcp/enter branch))
+ (await (async/wait-for #(some? (last-call calls :get-branch-diff))
+ "the diff is asked for"))
+ (t/is (dwcp/comparing? @store))
+ (t/is (= {:id (:id branch) :name "feature-login" :branch-file-id branch-file-id}
+ (get-in @store [:workspace-compare :branch]))
+ "the mode keeps what names the branch, not its counts")
+ (t/is (= :compare (get-in @store [:workspace-compare :phase])))
+ (t/is (= {:branch-id (:id branch) :direction :branch->main}
+ (last-call calls :get-branch-diff)))
+ (rx/dispose! store))))))
+
+(t/deftest ^:async the-mode-does-not-open-with-main-open
+ (let [calls (atom [])]
+ (await
+ (mock/with-mocks* {rp/cmd! (cmd-stub calls)}
+ (let [store (make-store {:current-file-id main-file-id})]
+ (ptk/emit! store (dwcp/enter branch))
+ (await (async/settle))
+ (t/is (not (dwcp/comparing? @store)))
+ (t/is (empty? @calls) "nothing is compared")
+ (rx/dispose! store))))))
+
+(t/deftest ^:async leaving-the-mode-leaves-nothing-behind
+ (let [calls (atom [])]
+ (await
+ (mock/with-mocks* {rp/cmd! (cmd-stub calls)}
+ (let [store (on-branch)]
+ (ptk/emit! store (dwcp/enter branch))
+ (ptk/emit! store (dwb/toggle-diff-excluded #{"color//a/1"}))
+ (ptk/emit! store (dwb/open-conflict-resolutions {:branch branch
+ :mode :merge
+ :conflicts [{:id (uuid/next)}]}))
+ (ptk/emit! store (dwcp/exit))
+ (await (async/wait-for-store store
+ #(nil? (:workspace-branch-conflicts @store))
+ "the attempt is dropped"))
+ (t/is (not (dwcp/comparing? @store)))
+ (t/is (= #{} (dwb/diff-excluded (:workspace-branch-diff @store)))
+ "the selection is dropped")
+ (rx/dispose! store))))))
+
+(t/deftest ^:async the-direction-refetches-and-starts-the-list-over
+ (let [calls (atom [])]
+ (await
+ (mock/with-mocks* {rp/cmd! (cmd-stub calls)}
+ (let [store (on-branch)]
+ (ptk/emit! store (dwcp/enter branch))
+ (ptk/emit! store (dwcp/set-filter :library))
+ (ptk/emit! store (dwcp/select "color//a/1" {:travel false}))
+ (ptk/emit! store (dwcp/set-direction :main->branch))
+ (await (async/wait-for #(= :main->branch (:direction (last-call calls :get-branch-diff)))
+ "the other direction is asked for"))
+ (t/is (= {:selected nil :filter :all :phase :compare}
+ (select-keys (:workspace-compare @store) [:selected :filter :phase])))
+ (rx/dispose! store))))))
+
+(t/deftest ^:async main-is-known-by-the-changes-of-both-directions
+ (let [calls (atom [])
+ change {:kind :shape :status :modified :id (uuid/next)}
+ clash {:kind :shape :status :conflict :id (uuid/next)}
+ answers (mock/stub (fn [cmd params]
+ (swap! calls conj [cmd params])
+ (if (and (= :get-branch-diff cmd)
+ (= :main->branch (:direction params)))
+ (rx/of {:changes [change] :conflicts [clash]})
+ (rx/subject))))]
+ (await
+ (mock/with-mocks* {rp/cmd! answers}
+ (let [store (on-branch)
+ stopper (rx/subject)]
+ (ptk/emit! store (dwcp/watch-events stopper))
+ (ptk/emit! store (dwcp/enter branch))
+ (await (async/wait-for #(some? (get-in @store [:workspace-compare :other-changes]))
+ "the other direction answers"))
+ (t/is (= [:branch->main :main->branch]
+ (->> @calls
+ (filter #(= :get-branch-diff (first %)))
+ (mapv (comp :direction second))))
+ "the diff listed, then its other direction")
+ (t/is (= [change] (get-in @store [:workspace-compare :other-changes])))
+ (t/is (= [clash] (get-in @store [:workspace-compare :other-conflicts]))
+ "with its conflicts, which its tab counts")
+ (ptk/emit! store (dwcp/set-direction :main->branch))
+ (t/is (nil? (get-in @store [:workspace-compare :other-changes]))
+ "the ones of the direction left do not stay")
+ (t/is (nil? (get-in @store [:workspace-compare :other-conflicts])))
+ (rx/push! stopper :stop)
+ (rx/dispose! store))))))
+
+(t/deftest the-panels-keep-what-the-user-set
+ (let [store (make-store {:current-file-id branch-file-id
+ :workspace-compare {:branch branch :phase :compare
+ :hidden false :collapsed #{}}})]
+ (ptk/emit! store (dwcp/toggle-group "library"))
+ (t/is (= #{"library"} (get-in @store [:workspace-compare :collapsed])))
+ (ptk/emit! store (dwcp/toggle-group "library"))
+ (t/is (= #{} (get-in @store [:workspace-compare :collapsed])))
+ (ptk/emit! store (dwcp/toggle-hidden))
+ (t/is (true? (get-in @store [:workspace-compare :hidden])))
+ (ptk/emit! store (dwcp/set-view :highlight))
+ (t/is (false? (get-in @store [:workspace-compare :hidden]))
+ "picking a view shows the changes again")
+ (ptk/emit! store (dwcp/set-count :main->branch 4))
+ (t/is (= {:main->branch 4} (get-in @store [:workspace-compare :counts])))
+ (rx/dispose! store)))
+
+(t/deftest choosing-the-change-chosen-lets-it-go
+ (let [store (make-store {:current-file-id branch-file-id
+ :workspace-compare {:phase :compare :selected nil}})]
+ (ptk/emit! store (dwcp/toggle-selected "shape/p/a"))
+ (t/is (= "shape/p/a" (get-in @store [:workspace-compare :selected])))
+ (ptk/emit! store (dwcp/toggle-selected "shape/p/b"))
+ (t/is (= "shape/p/b" (get-in @store [:workspace-compare :selected])))
+ (ptk/emit! store (dwcp/toggle-selected "shape/p/b"))
+ (t/is (nil? (get-in @store [:workspace-compare :selected])))
+ (rx/dispose! store)))
+
+(t/deftest the-pointer-is-followed-on-the-list-and-on-the-canvas
+ (let [store (make-store {:workspace-compare {:phase :compare :selected "shape/p/a"}})
+ idle (make-store {})
+ mode #(select-keys (:workspace-compare @store) [:hovered :hovered-from :selected])]
+ (ptk/emit! store (dwcp/set-hovered "shape/p/b" :canvas))
+ (t/is (= {:hovered "shape/p/b" :hovered-from :canvas :selected "shape/p/a"} (mode))
+ "the choice stays")
+ (ptk/emit! store (dwcp/set-hovered "shape/p/c" :list))
+ (ptk/emit! store (dwcp/set-hovered nil :canvas))
+ (t/is (= "shape/p/c" (:hovered (mode)))
+ "the canvas does not let go the row the pointer reached")
+ (ptk/emit! store (dwcp/set-hovered nil :list))
+ (t/is (nil? (:hovered (mode))))
+ (ptk/emit! idle (dwcp/set-hovered "shape/p/b" :list))
+ (t/is (not (contains? @idle :workspace-compare)) "outside the mode nothing is kept")
+ (rx/dispose! store)
+ (rx/dispose! idle)))
+
+(t/deftest a-click-on-the-canvas-chooses-the-change-of-its-layer
+ (let [store (make-store {:workspace-compare {:phase :compare :selected "shape/p/a"}})
+ selected #(get-in @store [:workspace-compare :selected])]
+ (ptk/emit! store (dwcp/set-hovered "shape/p/b" :canvas))
+ (ptk/emit! store (dwcp/pick-hovered))
+ (t/is (= "shape/p/b" (selected)))
+ (ptk/emit! store (dwcp/set-hovered "shape/p/c" :list))
+ (ptk/emit! store (dwcp/pick-hovered))
+ (t/is (nil? (selected)) "a row under the pointer is no layer under it")
+ (ptk/emit! store (dwcp/select "shape/p/a" {:travel false}))
+ (ptk/emit! store (dwcp/set-hovered nil :list))
+ (ptk/emit! store (dwcp/pick-hovered))
+ (t/is (nil? (selected)) "the background lets the choice go")
+ (rx/dispose! store)))
+
+(t/deftest the-layer-chosen-is-fitted-in-the-room-the-view-leaves
+ (let [page-id (uuid/next)
+ shape-id (uuid/next)
+ change {:kind :shape :status :modified :id shape-id :page-id page-id
+ :key "layer"}
+ state (fn [view]
+ {:current-file-id branch-file-id
+ :current-page-id page-id
+ :files {branch-file-id
+ {:data {:pages-index
+ {page-id {:objects {shape-id {:id shape-id
+ :selrect {:x 100 :y 100
+ :width 200 :height 100}}}}}}}}
+ :workspace-local {:vport {:width 1000 :height 500}
+ :vbox {:x 0 :y 0 :width 1000 :height 500}
+ :zoom 1}
+ :workspace-branch-diff {:diff {:changes [change]}}
+ :workspace-compare {:phase :compare :view view
+ :selected (dwcp/item-key change)}})
+ fit (fn [view]
+ (let [store (make-store (state view))]
+ (ptk/emit! store (dwcp/fit-selected))
+ (let [local (:workspace-local @store)]
+ (rx/dispose! store)
+ local)))
+ whole (fit :highlight)
+ half (fit :side)
+ center (fn [{:keys [vbox]} at]
+ (+ (:x vbox) (* at (:width vbox))))]
+ (t/is (> (:zoom whole) 1) "the layer fills the canvas")
+ (t/is (= 200 (center whole 0.5)) "in its middle")
+ (t/is (< (:zoom half) (:zoom whole)) "half the canvas holds less")
+ (t/is (= 200 (center half 0.75)) "in the middle of the half of the branch")
+ (t/is (= (/ 1000 (:zoom half)) (get-in half [:vbox :width])))))
+
+;;; --- The side mode ---
+
+(def ^:private side-mode-key
+ :app.main.data.workspace.compare/side-mode)
+
+(defn- keeping-side-mode
+ "Run `f` with `stored` as the side mode the browser keeps (nil for
+ none), and leave what the browser kept before as it was."
+ [stored f]
+ (let [prev (get @storage/user side-mode-key)]
+ (if (some? stored)
+ (swap! storage/user assoc side-mode-key stored)
+ (swap! storage/user dissoc side-mode-key))
+ (try
+ (f)
+ (finally
+ (if (some? prev)
+ (swap! storage/user assoc side-mode-key prev)
+ (swap! storage/user dissoc side-mode-key))))))
+
+(defn- side-store
+ [view]
+ (make-store {:current-file-id branch-file-id
+ :workspace-compare {:branch branch :phase :compare
+ :view view :side-mode :linked}}))
+
+(defn- side-mode
+ [store]
+ (get-in @store [:workspace-compare :side-mode]))
+
+(t/deftest ^:async the-side-mode-starts-linked-and-comes-back-as-picked
+ (let [calls (atom [])
+ prev (get @storage/user side-mode-key)]
+ (swap! storage/user dissoc side-mode-key)
+ (await
+ (mock/with-mocks* {rp/cmd! (cmd-stub calls)}
+ (let [store (on-branch)]
+ (ptk/emit! store (dwcp/enter branch))
+ (t/is (= :linked (side-mode store)) "linked with nothing kept")
+ (ptk/emit! store (dwcp/set-side-mode :aligned))
+ (ptk/emit! store (dwcp/exit))
+ (ptk/emit! store (dwcp/enter branch))
+ (await (async/wait-for #(some? (last-call calls :get-branch-diff))
+ "the diff is asked for"))
+ (t/is (= :aligned (side-mode store)) "the one picked last")
+ (rx/dispose! store))))
+ (if (some? prev)
+ (swap! storage/user assoc side-mode-key prev)
+ (swap! storage/user dissoc side-mode-key))))
+
+(t/deftest ^:async the-side-mode-kept-must-be-one
+ (let [calls (atom [])
+ prev (get @storage/user side-mode-key)]
+ (swap! storage/user assoc side-mode-key :sideways)
+ (await
+ (mock/with-mocks* {rp/cmd! (cmd-stub calls)}
+ (let [store (on-branch)]
+ (ptk/emit! store (dwcp/enter branch))
+ (await (async/wait-for #(some? (last-call calls :get-branch-diff))
+ "the diff is asked for"))
+ (t/is (= :linked (side-mode store)))
+ (rx/dispose! store))))
+ (if (some? prev)
+ (swap! storage/user assoc side-mode-key prev)
+ (swap! storage/user dissoc side-mode-key))))
+
+(t/deftest ^:async resolving-takes-the-side-mode-kept
+ (let [calls (atom [])
+ prev (get @storage/user side-mode-key)]
+ (swap! storage/user assoc side-mode-key :aligned)
+ (await
+ (mock/with-mocks* {rp/cmd! (cmd-stub calls)}
+ (let [store (on-branch)]
+ (ptk/emit! store (dwb/open-conflict-resolutions {:branch branch
+ :mode :merge
+ :conflicts [{:id (uuid/next)}]}))
+ (ptk/emit! store (dwcp/start-resolve))
+ (await (async/wait-for #(some? (last-call calls :get-branch-diff))
+ "the diff is asked for"))
+ (t/is (= :aligned (side-mode store)))
+ (rx/dispose! store))))
+ (if (some? prev)
+ (swap! storage/user assoc side-mode-key prev)
+ (swap! storage/user dissoc side-mode-key))))
+
+(t/deftest the-side-mode-is-kept-in-the-browser
+ (keeping-side-mode
+ nil
+ (fn []
+ (let [store (side-store :side)]
+ (ptk/emit! store (dwcp/set-side-mode :aligned))
+ (t/is (= :aligned (side-mode store)))
+ (t/is (= :aligned (get @storage/user side-mode-key)))
+ (rx/dispose! store)))))
+
+(t/deftest ^:async the-key-flips-the-side-mode-beside-the-branch-alone
+ (let [prev (get @storage/user side-mode-key)
+ side (side-store :side)
+ flat (side-store :highlight)]
+ (ptk/emit! side (dwcp/toggle-side-mode))
+ (await (async/wait-for-store side #(= :aligned (side-mode side)) "it flips"))
+ (ptk/emit! side (dwcp/toggle-side-mode))
+ (await (async/wait-for-store side #(= :linked (side-mode side)) "and back"))
+ (ptk/emit! flat (dwcp/toggle-side-mode))
+ (await (async/settle))
+ (t/is (= :linked (side-mode flat)) "highlighting, it does nothing")
+ (rx/dispose! side)
+ (rx/dispose! flat)
+ (if (some? prev)
+ (swap! storage/user assoc side-mode-key prev)
+ (swap! storage/user dissoc side-mode-key))))
+
+(t/deftest another-view-keeps-the-side-mode
+ (let [store (make-store {:current-file-id branch-file-id
+ :workspace-compare {:branch branch :phase :compare
+ :view :side :side-mode :aligned}})]
+ (ptk/emit! store (dwcp/set-view :highlight))
+ (ptk/emit! store (dwcp/set-view :side))
+ (t/is (= :aligned (side-mode store)))
+ (rx/dispose! store)))
+
+;;; --- Zoom with main beside the branch ---
+
+(defn- zoom-state
+ "A page with a board at 100,100 (200 by 100) on a viewport of 1000 by
+ 500, with the compare mode in `view` when there is one."
+ [view local]
+ (let [page-id (uuid/next)
+ board-id (uuid/next)]
+ (cond-> {:current-file-id branch-file-id
+ :current-page-id page-id
+ :files {branch-file-id
+ {:data {:pages-index
+ {page-id
+ {:objects
+ {uuid/zero {:id uuid/zero :type :frame :parent-id uuid/zero
+ :shapes [board-id]}
+ board-id (cts/setup-rect {:id board-id :type :frame
+ :parent-id uuid/zero
+ :x 100 :y 100
+ :width 200 :height 100})}}}}}}
+ :workspace-local (merge {:vport {:width 1000 :height 500}
+ :vbox (grc/make-rect 0 0 1000 500)
+ :zoom 1}
+ local)}
+ (some? view)
+ (assoc :workspace-compare {:phase :compare :view view}))))
+
+(defn- zoom-with
+ [state event]
+ (let [store (make-store state)]
+ (ptk/emit! store event)
+ (let [local (:workspace-local @store)]
+ (rx/dispose! store)
+ local)))
+
+(defn- vbox-at
+ "The point of the page at `at` of the width of the viewbox."
+ [{:keys [vbox]} at]
+ (+ (:x vbox) (* at (:width vbox))))
+
+(t/deftest the-whole-page-is-fitted-in-the-room-the-view-leaves
+ (let [whole (zoom-with (zoom-state nil nil) dwz/zoom-to-fit-all)
+ half (zoom-with (zoom-state :side nil) dwz/zoom-to-fit-all)]
+ (t/is (= 200 (vbox-at whole 0.5)) "in the middle of the canvas")
+ (t/is (= 200 (vbox-at half 0.75)) "in the middle of the half of the branch")
+ (t/is (< (:zoom half) (:zoom whole)) "half the canvas holds less")
+ (t/is (= 200 (vbox-at (zoom-with (zoom-state :highlight nil) dwz/zoom-to-fit-all) 0.5))
+ "highlighting, the canvas is not split")))
+
+(t/deftest the-whole-page-takes-in-main-beside-the-branch
+ (let [state (assoc-in (zoom-state :side nil) [:workspace-compare :main-extent]
+ (grc/make-rect 1000 100 200 100))
+ local (zoom-with state dwz/zoom-to-fit-all)]
+ (t/is (= 650 (vbox-at local 0.75)) "the middle of the board on both sides")))
+
+(t/deftest the-zoom-turns-on-the-middle-of-the-room-the-view-leaves
+ (let [local {:zoom 2 :vbox (grc/make-rect 0 0 500 250)}
+ whole (zoom-with (zoom-state nil local) dwz/reset-zoom)
+ half (zoom-with (zoom-state :side local) dwz/reset-zoom)
+ more (zoom-with (zoom-state :side local) (dwz/increase-zoom nil))]
+ (t/is (= 1 (:zoom half)))
+ (t/is (= 250 (vbox-at whole 0.5)) "the middle of the canvas stays")
+ (t/is (= 375 (vbox-at half 0.75)) "the middle of the half of the branch stays")
+ (t/is (= 375 (vbox-at more 0.75)) "zooming in from the menu too")))
+
+(t/deftest the-events-do-nothing-outside-the-mode
+ (let [store (make-store {:current-file-id branch-file-id})]
+ (keeping-side-mode
+ nil
+ (fn []
+ (ptk/emit! store (dwcp/set-side-mode :aligned))
+ (ptk/emit! store (dwcp/toggle-side-mode))
+ (t/is (nil? (get @storage/user side-mode-key)) "nothing is kept")))
+ (ptk/emit! store (dwcp/toggle-hidden))
+ (ptk/emit! store (dwcp/set-filter :library))
+ (ptk/emit! store (dwcp/toggle-group "library"))
+ (ptk/emit! store (dwcp/set-count :main->branch 4))
+ (t/is (not (dwcp/comparing? @store)) "none of them creates the mode")
+ (rx/dispose! store)))
+
+;;; --- Entries ---
+
+(t/deftest an-entry-is-known-by-its-change-key
+ (t/is (= "shape/p/1" (dwcp/item-key {:key "shape/p/1" :kind :shape :id 1})))
+ (t/is (= "token:brand" (dwcp/item-key {:kind :token :id "brand"}))
+ "an entry without a change key falls back to its kind and id"))
+
+(t/deftest a-layer-is-placed-by-the-open-file-or-by-the-diff
+ (let [id (uuid/next)
+ rect {:x 1 :y 2 :width 3 :height 4}
+ objects {id {:id id :selrect rect}}]
+ (t/is (= rect (dwcp/item-rect objects {:kind :shape :id id})))
+ (t/is (= rect (dwcp/item-rect {} {:kind :shape :id id :shape {:selrect rect}}))
+ "a layer the open file lacks comes whole in the diff")
+ (t/is (= rect (dwcp/item-rect {} {:kind :shape :id id :shape rect}))
+ "its own position and size do when it carries no selrect")
+ (t/is (nil? (dwcp/item-rect objects {:kind :color :id id})))
+ (t/is (nil? (dwcp/item-rect {} {:kind :shape :id id})))))
+
+(t/deftest the-conflicts-of-an-attempt-win-over-the-ones-of-the-diff
+ (let [branch-id (uuid/next)
+ diff-st {:diff {:conflicts [{:id :from-diff}]}}]
+ (t/is (= [{:id :from-attempt}]
+ (dwcp/get-conflicts {:branch-id branch-id :conflicts [{:id :from-attempt}]}
+ diff-st branch-id)))
+ (t/is (= [{:id :from-diff}]
+ (dwcp/get-conflicts {:branch-id (uuid/next) :conflicts [{:id :other}]}
+ diff-st branch-id))
+ "the attempt of another branch does not count")
+ (t/is (= [{:id :from-diff}] (dwcp/get-conflicts nil diff-st branch-id)))))
+
+;;; --- Read-only ---
+
+(t/deftest ^:async no-edit-is-committed-while-comparing
+ (let [state {:current-file-id branch-file-id
+ :permissions {:can-edit true}
+ :files {branch-file-id {:id branch-file-id :revn 1 :vern 0}}
+ :workspace-compare {:branch branch :phase :compare}}
+ store (make-store state)
+ commits (atom [])
+ sub (->> (ptk/input-stream store)
+ (rx/filter dch/commit?)
+ (rx/subs! #(swap! commits conj %)))]
+ (ptk/emit! store (dch/commit-changes {:redo-changes [{:type :mod-obj}]
+ :undo-changes []
+ :file-id branch-file-id}))
+ (await (async/settle))
+ (t/is (empty? @commits) "the comparison refuses the edit")
+ (rx/dispose! sub)
+ (rx/dispose! store)))
+
+;;; --- Resolving conflicts ---
+
+(t/deftest ^:async resolving-starts-in-the-direction-of-the-attempt
+ (let [calls (atom [])]
+ (await
+ (mock/with-mocks* {rp/cmd! (cmd-stub calls)}
+ (let [store (on-branch)]
+ (ptk/emit! store (dwb/open-conflict-resolutions {:branch branch
+ :mode :update
+ :conflicts [{:id (uuid/next)}]}))
+ (ptk/emit! store (dwcp/start-resolve))
+ (await (async/wait-for #(some? (last-call calls :get-branch-diff))
+ "the diff is asked for"))
+ (t/is (= :resolve (get-in @store [:workspace-compare :phase])))
+ (t/is (= (:id branch) (get-in @store [:workspace-compare :branch :id])))
+ (t/is (= :main->branch (:direction (last-call calls :get-branch-diff)))
+ "an update resolves main's changes")
+ (rx/dispose! store))))))
+
+(t/deftest ^:async conflicts-of-another-file-wait-for-their-branch
+ (let [calls (atom [])]
+ (await
+ (mock/with-mocks* {rp/cmd! (cmd-stub calls)}
+ (let [store (make-store {:current-file-id main-file-id})]
+ (ptk/emit! store (dwb/open-conflict-resolutions {:branch branch
+ :mode :merge
+ :conflicts [{:id (uuid/next)}]}))
+ (ptk/emit! store (dwcp/start-resolve))
+ (await (async/wait-for-store store
+ #(true? (get-in @store [:workspace-branch-conflicts :pending]))
+ "the conflicts wait"))
+ (t/is (not (dwcp/comparing? @store)) "the mode waits for the branch file")
+ (rx/dispose! store))))))
+
+(t/deftest going-back-keeps-the-choices-and-drops-the-attempt
+ (let [conflict-id (uuid/next)
+ store (make-store {:current-file-id branch-file-id
+ :workspace-compare {:branch branch :phase :resolve :selected "x"}
+ :workspace-branch-diff {:branch-id (:id branch)
+ :resolutions {conflict-id :main}}
+ :workspace-branch-conflicts {:branch-id (:id branch)
+ :conflicts [{:id conflict-id}]}})]
+ (ptk/emit! store (dwcp/back-to-compare))
+ (t/is (= {:phase :compare :selected nil}
+ (select-keys (:workspace-compare @store) [:phase :selected])))
+ (t/is (nil? (:workspace-branch-conflicts @store)))
+ (t/is (= {conflict-id :main} (get-in @store [:workspace-branch-diff :resolutions])))
+ (rx/dispose! store)))
+
+(defn- resolving
+ "A store that resolves one conflict of the branch, with a choice made
+ for it and for a conflict that is no longer there."
+ [conflict-id diff-st attempt]
+ (make-store {:current-file-id branch-file-id
+ :workspace-compare {:branch (select-keys branch [:id :name :branch-file-id])
+ :phase :resolve}
+ :workspace-branch-diff
+ (merge {:branch-id (:id branch)
+ :status :loaded
+ :diff {:conflicts [{:id conflict-id}] :meta {:main-revn 9}}
+ :resolutions {conflict-id :branch (uuid/next) :main}}
+ diff-st)
+ :workspace-branch-conflicts attempt}))
+
+(t/deftest ^:async applying-a-merge-sends-what-the-attempt-carried
+ (let [calls (atom [])
+ conflict-id (uuid/next)]
+ (await
+ (mock/with-mocks* {rp/cmd! (cmd-stub calls)}
+ (let [store (resolving conflict-id
+ {:direction :branch->main
+ :excluded {:branch->main #{"from-the-comparison"}}}
+ {:branch-id (:id branch)
+ :mode :merge
+ :conflicts [{:id conflict-id}]
+ :main-revn 7
+ :excluded #{"from-the-attempt"}
+ :comment "Ships the header"})]
+ (ptk/emit! store (dwcp/apply-resolutions))
+ (await (async/wait-for #(some? (last-call calls :merge-file-branch))
+ "the merge is asked for"))
+ (t/is (= {:branch-id (:id branch)
+ :resolutions {conflict-id :branch}
+ :excluded #{"from-the-attempt"}
+ :comment "Ships the header"
+ :expected-main-revn 9}
+ (last-call calls :merge-file-branch))
+ "only the choices of its conflicts travel, with its selection and comment")
+ (rx/dispose! store))))))
+
+(t/deftest ^:async applying-an-update-from-the-comparison-sends-its-selection
+ (let [calls (atom [])
+ conflict-id (uuid/next)]
+ (await
+ (mock/with-mocks* {rp/cmd! (cmd-stub calls)}
+ (let [store (resolving conflict-id
+ {:direction :main->branch
+ :excluded {:main->branch #{"left-out"}
+ :branch->main #{"other-direction"}}}
+ nil)]
+ (ptk/emit! store (dwcp/apply-resolutions))
+ (await (async/wait-for #(some? (last-call calls :update-branch-from-main))
+ "the update is asked for"))
+ (t/is (= {:branch-id (:id branch)
+ :resolutions {conflict-id :branch}
+ :excluded #{"left-out"}
+ :expected-main-revn 9}
+ (last-call calls :update-branch-from-main)))
+ (t/is (nil? (last-call calls :merge-file-branch)))
+ (rx/dispose! store))))))
diff --git a/frontend/test/frontend_tests/runner.cljs b/frontend/test/frontend_tests/runner.cljs
index 30a0e2c7da..23d2d8dd30 100644
--- a/frontend/test/frontend_tests/runner.cljs
+++ b/frontend/test/frontend_tests/runner.cljs
@@ -41,6 +41,7 @@
[frontend-tests.data.workspace-branches-test]
[frontend-tests.data.workspace-colors-test]
[frontend-tests.data.workspace-comments-test]
+ [frontend-tests.data.workspace-compare-test]
[frontend-tests.data.workspace-context-menu-test]
[frontend-tests.data.workspace-focus-test]
[frontend-tests.data.workspace-interactions-test]
@@ -159,7 +160,7 @@
[frontend-tests.tokens.typography-form-test]
[frontend-tests.tokens.workspace-tokens-remap-test]
[frontend-tests.ui.branch-review-common-test]
- [frontend-tests.ui.branch-review-previews-test]
+ [frontend-tests.ui.branch-review-sides-test]
[frontend-tests.ui.branches-compare-labels-test]
[frontend-tests.ui.check-updates-test]
[frontend-tests.ui.color-token-position-test]
@@ -170,6 +171,7 @@
[frontend-tests.ui.dashboard-import-linking-test]
[frontend-tests.ui.drawarea-test]
[frontend-tests.ui.ds-controls-numeric-input-test]
+ [frontend-tests.ui.ds-popover-test]
[frontend-tests.ui.error-boundary-test]
[frontend-tests.ui.export-preview-test]
[frontend-tests.ui.file-restored-modal-test]
@@ -275,6 +277,7 @@
'frontend-tests.data.uploads-test
'frontend-tests.data.viewer-test
'frontend-tests.data.workspace-branches-test
+ 'frontend-tests.data.workspace-compare-test
'frontend-tests.data.workspace-tasks-test
'frontend-tests.data.workspace-colors-test
'frontend-tests.data.workspace-comments-test
@@ -394,7 +397,7 @@
'frontend-tests.tokens.logic.tokens-status-test
'frontend-tests.tokens.workspace-tokens-remap-test
'frontend-tests.ui.branch-review-common-test
- 'frontend-tests.ui.branch-review-previews-test
+ 'frontend-tests.ui.branch-review-sides-test
'frontend-tests.ui.branches-compare-labels-test
'frontend-tests.ui.check-updates-test
'frontend-tests.ui.color-token-position-test
@@ -406,6 +409,7 @@
'frontend-tests.ui.drawarea-test
'frontend-tests.ui.ds-controls-numeric-input-test
'frontend-tests.ui.error-boundary-test
+ 'frontend-tests.ui.ds-popover-test
'frontend-tests.ui.export-preview-test
'frontend-tests.ui.file-restored-modal-test
'frontend-tests.ui.gradient-handlers-test
diff --git a/frontend/test/frontend_tests/ui/branch_review_common_test.cljs b/frontend/test/frontend_tests/ui/branch_review_common_test.cljs
index 97a48529d5..0e07766b82 100644
--- a/frontend/test/frontend_tests/ui/branch_review_common_test.cljs
+++ b/frontend/test/frontend_tests/ui/branch_review_common_test.cljs
@@ -5,11 +5,14 @@
;; Copyright (c) KALEIDOS SUBSIDIARY SL
(ns frontend-tests.ui.branch-review-common-test
- "How the decisions dialog splits a conflict: the properties both sides
- moved conflict, the ones a single side moved come filled in from it."
+ "What the compare mode says about a diff: how a conflict splits into the
+ properties both sides moved and the ones a single side moved, what an
+ entry is and affects, the list the changes make and the marks they
+ leave on the canvas."
(:require
[app.common.files.branch-merge :as bm]
[app.common.uuid :as uuid]
+ [app.main.data.workspace.compare :as dwcp]
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
[cljs.test :as t :include-macros true]))
@@ -114,22 +117,26 @@
(t/is (= ["Checkout" "Summary"] (brc/shape-path objects rect-id)))
(t/is (= [] (brc/shape-path objects board-id))))
-(t/deftest library-entries-count-the-layers-that-use-them
- (t/is (= 1 (brc/component-copies data comp-id)))
- (t/is (= 1 (brc/color-usages data color-id)))
- (t/is (= 1 (brc/token-usages data "brand.primary")))
- (t/is (= 0 (brc/token-usages data "brand.secondary"))))
+(t/deftest library-entries-name-the-layers-that-use-them
+ (let [ids (fn [item] (mapv (comp :id :shape) (brc/usages data item)))]
+ (t/is (= [copy-id] (ids {:kind :component :id comp-id})))
+ (t/is (= [rect-id] (ids {:kind :color :id color-id})))
+ (t/is (= [rect-id] (ids {:kind :token :label "brand.primary"})))
+ (t/is (= [] (ids {:kind :token :label "brand.secondary"})))
+ (t/is (= page-id (:page-id (first (brc/usages data {:kind :color :id color-id})))))
+ (t/is (nil? (brc/usages data {:kind :shape :id rect-id}))
+ "a layer is no library entry")))
(t/deftest pages-get-their-own-group-before-the-library
- (let [groups (brc/group-by-place [[0 {:kind :page :status :added :label "Page 2"}]
- [1 {:kind :color :status :added :label "Red"}]]
+ (let [groups (brc/group-by-place [{:kind :page :status :added :label "Page 2"}
+ {:kind :color :status :added :label "Red"}]
{} [])]
(t/is (= ["pages" "library"] (map :id groups)))))
(t/deftest a-board-folds-only-two-or-more-changes
(let [pages-index {page-id {:id page-id :name "Page 1" :objects objects}}
- rect [0 {:kind :shape :status :modified :id rect-id :page-id page-id}]
- button [1 {:kind :shape :status :modified :id copy-id :page-id page-id}]
+ rect {:kind :shape :status :modified :id rect-id :page-id page-id}
+ button {:kind :shape :status :modified :id copy-id :page-id page-id}
one (first (brc/group-by-place [rect] pages-index []))
two (first (brc/group-by-place [rect button] pages-index []))]
(t/is (= [] (:boards one)) "a lone change stays loose")
@@ -137,36 +144,33 @@
(t/is (= ["Checkout"] (map :name (:boards two))))
(t/is (= [] (:rows two)))))
-(t/deftest only-decisions-carry-a-colour
- (t/is (= :variants (brc/category {:kind :shape :status :modified :variant? true :component? true})))
- (t/is (= :components (brc/category {:kind :shape :status :modified :component? true})))
- (t/is (= #{"neutral"} (set (vals (dissoc brc/category->tone :decisions)))))
- (t/is (= "warning" (brc/category->tone :decisions))))
-
(defn- deleted
[id parent-id]
{:kind :shape :status :deleted :id id :page-id page-id
:shape {:id id :parent-id parent-id}})
(t/deftest a-deleted-group-takes-its-layers-along
- (let [rows [[0 (deleted :path-a :icon)]
- [1 (deleted :bg :icon)]
- [2 (deleted :path-b :inner)]
- [3 (deleted :inner :icon)]
- [4 (deleted :icon :button)]
- [5 {:kind :shape :status :modified :id :label :page-id page-id}]]
- folds (brc/fold-cascades rows)]
- (t/is (= [4] (keys folds)) "the outermost deleted layer holds them all")
- (t/is (= #{0 1 2 3} (set (map first (get folds 4)))))))
+ (let [icon (deleted :icon :button)
+ items [(deleted :path-a :icon)
+ (deleted :bg :icon)
+ (deleted :path-b :inner)
+ (deleted :inner :icon)
+ icon
+ {:kind :shape :status :modified :id :label :page-id page-id}]
+ folds (brc/fold-cascades items)]
+ (t/is (= [(dwcp/item-key icon)] (keys folds))
+ "the outermost deleted layer holds them all")
+ (t/is (= #{:path-a :bg :path-b :inner}
+ (set (map :id (get folds (dwcp/item-key icon))))))))
(t/deftest only-the-same-change-folds
(let [added {:kind :shape :status :added :id :new :page-id page-id
:shape {:id :new :parent-id :icon}}
- rows [[0 (deleted :icon :button)]
- [1 added]
- [2 (deleted :lone :button)]
- [3 (assoc (deleted :other :icon) :page-id :elsewhere)]]]
- (t/is (= {} (brc/fold-cascades rows))
+ items [(deleted :icon :button)
+ added
+ (deleted :lone :button)
+ (assoc (deleted :other :icon) :page-id :elsewhere)]]
+ (t/is (= {} (brc/fold-cascades items))
"an addition, a layer whose parent stays and one on another page stay apart")))
;; --- What goes with an added or deleted layer
@@ -239,3 +243,136 @@
items [added (edit cta-id {:interactions {:main [] :branch [link]}})]
fx (brc/shape-effects added items proto-objects [] false)]
(t/is (= [] (:interactions fx)))))
+
+;; --- The list of a comparison
+
+(defn- change
+ "A clean change of the layer `id` of the page, with its change key."
+ [id status]
+ {:kind :shape :status status :id id :page-id page-id :label (name id)
+ :key (str "shape/" page-id "/" (name id))})
+
+(def ^:private red
+ {:kind :color :status :modified :id color-id :label "Red"
+ :key (str "color//" color-id)})
+
+(def ^:private clash
+ (assoc (change :clash :conflict) :changed-attrs {:rx {:main 1 :branch 2}}))
+
+(def ^:private diff
+ {:changes [(change :title :modified)
+ (assoc (change :icon :deleted) :shape {:id :icon :parent-id :button})
+ (assoc (change :path :deleted) :shape {:id :path :parent-id :icon})
+ red]
+ :conflicts [clash]})
+
+(defn- model
+ [opts]
+ (brc/change-model diff (merge {:filter :all :pages-index {} :pages []} opts)))
+
+(t/deftest the-list-shows-decisions-first-and-folds-what-follows
+ (let [{:keys [rows cascades decisions counts kept left-out]} (model {})]
+ (t/is (= ["clash" "title" "icon" "Red"] (map :label rows))
+ "the conflict first; the path goes under the icon deleted with it")
+ (t/is (= [:path] (map :id (get cascades (dwcp/item-key (change :icon :deleted))))))
+ (t/is (= 1 decisions))
+ (t/is (= {:all 4 :layers 3 :library 1 :left-out 0} counts))
+ (t/is (= 3 kept) "a conflict is decided, not selected")
+ (t/is (= 0 left-out))))
+
+(t/deftest the-filters-keep-layers-library-or-what-is-left-out
+ (t/is (= ["clash" "title" "icon"] (map :label (:rows (model {:filter :layers})))))
+ (t/is (= ["Red"] (map :label (:rows (model {:filter :library})))))
+ (let [out (model {:filter :left-out :excluded #{(:key red)}})]
+ (t/is (= ["Red"] (map :label (:rows out))))
+ (t/is (= 1 (:left-out out)))
+ (t/is (= 2 (:kept out)))
+ (t/is (= 4 (get-in out [:counts :all])) "a filter changes what shows, not what there is")))
+
+(t/deftest a-row-takes-its-folded-layers-along
+ (let [icon (change :icon :deleted)]
+ (t/is (= #{(:key icon) (:key (change :path :deleted))}
+ (brc/row-keys icon [(change :path :deleted)])))))
+
+(t/deftest the-list-is-walked-round
+ (let [rows (:rows (model {}))
+ k #(dwcp/item-key (nth rows %))]
+ (t/is (= (k 0) (brc/step rows nil 1)) "nothing chosen: the first row")
+ (t/is (= (k 1) (brc/step rows (k 0) 1)))
+ (t/is (= (k 3) (brc/step rows (k 0) -1)) "before the first comes the last")
+ (t/is (= (k 0) (brc/step rows (k 3) 1)))
+ (t/is (nil? (brc/step [] nil 1)))))
+
+(t/deftest the-next-pending-row-skips-the-ones-done
+ (let [rows (:rows (model {}))
+ k #(dwcp/item-key (nth rows %))
+ done #{(k 1) (k 2)}
+ done? #(contains? done (dwcp/item-key %))]
+ (t/is (= (k 3) (brc/next-pending rows (k 0) done?)))
+ (t/is (= (k 0) (brc/next-pending rows (k 3) done?)) "it goes round")
+ (t/is (nil? (brc/next-pending rows (k 0) (constantly true))))))
+
+;; --- The marks on the canvas
+
+(t/deftest a-change-is-marked-where-its-layer-is
+ (let [objects {rect-id {:id rect-id :selrect {:x 10 :y 20 :width 30 :height 40}}}
+ here {:kind :shape :status :modified :id rect-id :page-id page-id
+ :label "Price" :key "here"}
+ gone {:kind :shape :status :deleted :id copy-id :page-id page-id
+ :label "Button" :key "gone"
+ :shape {:id copy-id :selrect {:x 1 :y 2 :width 3 :height 4}}}
+ away (assoc here :page-id (uuid/next) :key "away")
+ marks (brc/change-marks [here gone away red]
+ {:page-id page-id :objects objects})]
+ (t/is (= [{:key "here" :label "Price" :status :modified
+ :rect {:x 10 :y 20 :width 30 :height 40}}
+ {:key "gone" :label "Button" :status :deleted
+ :rect {:x 1 :y 2 :width 3 :height 4}}]
+ marks)
+ "a layer the open file lacks is marked where the diff says it was")
+ (t/is (= ["gone"]
+ (map :key (brc/change-marks [here gone] {:page-id page-id
+ :objects objects
+ :excluded #{"here"}})))
+ "a change left out leaves no mark")
+ (t/is (= [:decided :decided]
+ (map :status (brc/change-marks [here gone] {:page-id page-id
+ :objects objects
+ :status-of (constantly :decided)}))))))
+
+(t/deftest a-library-change-is-marked-on-the-layers-that-use-it
+ (let [objects (assoc-in objects [rect-id :selrect] {:x 1 :y 2 :width 3 :height 4})
+ data (assoc-in data [:pages-index page-id :objects] objects)
+ marks (brc/usage-marks data red page-id)]
+ (t/is (= [{:label "Price" :status :usage :rect {:x 1 :y 2 :width 3 :height 4}}]
+ (map #(dissoc % :key) marks)))
+ (t/is (= [] (brc/usage-marks data red (uuid/next))) "only on the page in sight")))
+
+;; --- Conflicts: how far along they are
+
+(t/deftest conflicts-wait-until-every-property-has-a-choice
+ (let [other (assoc card :id :other)
+ card (assoc card :id :card)
+ res {:card (brc/choose-side card :main)}
+ {:keys [pending decided rows]} (brc/conflict-model [card other] res)]
+ (t/is (= [:other] (map :id pending)))
+ (t/is (= [:card] (map :id decided)))
+ (t/is (= [:other :card] (map :id rows)) "the ones that wait come first")))
+
+(t/deftest only-conflicts-without-a-choice-get-prefilled
+ (let [card (assoc card :id :card)
+ seed (brc/prefill-resolutions [card (assoc card :id :chosen)] {:chosen :main})]
+ (t/is (= {:card {:width :branch :opacity :main}} seed))))
+
+(t/deftest the-property-in-turn-is-the-first-without-a-choice
+ (let [both (assoc card
+ :base {:rx 8 :width 320 :opacity 1 :fills :a}
+ :main (assoc (:main card) :fills :b)
+ :branch (assoc (:branch card) :fills :c)
+ :changed-attrs (assoc (:changed-attrs card) :fills {:main :b :branch :c}))
+ [first-attr second-attr] (brc/conflicting-attrs (brc/conflict-attr-rows both))]
+ (t/is (= first-attr (brc/pending-attr both nil nil)))
+ (t/is (= second-attr (brc/pending-attr both nil second-attr)) "the one the user took")
+ (t/is (= second-attr (brc/pending-attr both {first-attr :main} nil)))
+ (t/is (nil? (brc/pending-attr (assoc card :main nil) nil nil))
+ "a conflict that does not split by property has none")))
diff --git a/frontend/test/frontend_tests/ui/branch_review_previews_test.cljs b/frontend/test/frontend_tests/ui/branch_review_previews_test.cljs
deleted file mode 100644
index 0f99c7f85e..0000000000
--- a/frontend/test/frontend_tests/ui/branch_review_previews_test.cljs
+++ /dev/null
@@ -1,59 +0,0 @@
-;; 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) KALEIDOS SUBSIDIARY SL
-
-(ns frontend-tests.ui.branch-review-previews-test
- "How the compare previews rebuild the side the open file lacks: a
- deleted layer comes back from the diff, inside the board it was in,
- and a resized board draws at its own size."
- (:require
- [app.common.types.shape :as cts]
- [app.common.uuid :as uuid]
- [app.main.ui.workspace.sidebar.branch-review.previews :as brp]
- [cljs.test :as t :include-macros true]))
-
-(def ^:private board-id (uuid/next))
-(def ^:private icon-id (uuid/next))
-(def ^:private path-id (uuid/next))
-
-(def ^:private branch-objects
- "The branch, open: the button lost its icon and shrank."
- {uuid/zero {:id uuid/zero :type :frame :shapes [board-id]}
- board-id (cts/setup-rect {:id board-id :type :frame :name "Button"
- :parent-id uuid/zero :x 0 :y 0 :width 131 :height 48
- :shapes []})})
-
-(def ^:private icon
- {:id icon-id :type :group :name "icon" :parent-id board-id
- :x 119 :y 12 :width 24 :height 24 :shapes [path-id]})
-
-(def ^:private items
- [{:kind :shape :status :deleted :id path-id
- :shape {:id path-id :type :path :name "path" :parent-id icon-id}}
- {:kind :shape :status :deleted :id icon-id :shape icon}
- {:kind :shape :status :modified :id board-id
- :changed-attrs {:width {:main 163 :branch 131}}}])
-
-(t/deftest a-deleted-layer-comes-back-on-the-side-that-has-it
- (let [main (brp/side-objects branch-objects items :main :branch)]
- (t/is (= icon (get main icon-id)))
- (t/is (contains? main path-id))
- (t/is (= [icon-id] (get-in main [board-id :shapes])))))
-
-(t/deftest the-side-that-deleted-it-stays-without-it
- (let [branch (brp/side-objects branch-objects items :branch :branch)]
- (t/is (not (contains? branch icon-id)))
- (t/is (= [] (get-in branch [board-id :shapes])))))
-
-(t/deftest a-resized-board-draws-at-its-own-size
- (let [main (brp/side-objects branch-objects items :main :branch)]
- (t/is (= 163 (get-in main [board-id :selrect :width])))
- (t/is (= 131 (get-in branch-objects [board-id :selrect :width])))))
-
-(t/deftest a-layer-is-staged-in-the-nearest-board
- (let [main (brp/side-objects branch-objects items :main :branch)]
- (t/is (= board-id (brp/context-frame-id main path-id)))
- (t/is (= board-id (brp/context-frame-id main icon-id)))
- (t/is (nil? (brp/context-frame-id main board-id)))))
diff --git a/frontend/test/frontend_tests/ui/branch_review_sides_test.cljs b/frontend/test/frontend_tests/ui/branch_review_sides_test.cljs
new file mode 100644
index 0000000000..4114c99300
--- /dev/null
+++ b/frontend/test/frontend_tests/ui/branch_review_sides_test.cljs
@@ -0,0 +1,342 @@
+;; 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) KALEIDOS SUBSIDIARY SL
+
+(ns frontend-tests.ui.branch-review-sides-test
+ "How the compare mode rebuilds the side the open file lacks: a deleted
+ layer comes back from the diff, inside the board it was in, and a
+ resized board takes its own size."
+ (:require
+ [app.common.types.shape :as cts]
+ [app.common.uuid :as uuid]
+ [app.main.ui.workspace.compare.common :as cc]
+ [app.main.ui.workspace.compare.detail :as detail]
+ [app.main.ui.workspace.compare.side :as side]
+ [app.main.ui.workspace.sidebar.branch-review.sides :as brs]
+ [cljs.test :as t :include-macros true]))
+
+(def ^:private board-id (uuid/next))
+(def ^:private icon-id (uuid/next))
+(def ^:private path-id (uuid/next))
+
+(def ^:private branch-objects
+ "The branch, open: the button lost its icon and shrank."
+ {uuid/zero {:id uuid/zero :type :frame :shapes [board-id]}
+ board-id (cts/setup-rect {:id board-id :type :frame :name "Button"
+ :parent-id uuid/zero :x 0 :y 0 :width 131 :height 48
+ :shapes []})})
+
+(def ^:private icon
+ {:id icon-id :type :group :name "icon" :parent-id board-id
+ :x 119 :y 12 :width 24 :height 24 :shapes [path-id]})
+
+(def ^:private items
+ [{:kind :shape :status :deleted :id path-id
+ :shape {:id path-id :type :path :name "path" :parent-id icon-id}}
+ {:kind :shape :status :deleted :id icon-id :shape icon}
+ {:kind :shape :status :modified :id board-id
+ :changed-attrs {:width {:main 163 :branch 131}}}])
+
+(t/deftest a-deleted-layer-comes-back-on-the-side-that-has-it
+ (let [main (brs/side-objects branch-objects items :main :branch)]
+ (t/is (= icon (get main icon-id)))
+ (t/is (contains? main path-id))
+ (t/is (= [icon-id] (get-in main [board-id :shapes])))))
+
+(t/deftest the-side-that-deleted-it-stays-without-it
+ (let [branch (brs/side-objects branch-objects items :branch :branch)]
+ (t/is (not (contains? branch icon-id)))
+ (t/is (= [] (get-in branch [board-id :shapes])))))
+
+(t/deftest a-resized-board-draws-at-its-own-size
+ (let [main (brs/side-objects branch-objects items :main :branch)]
+ (t/is (= 163 (get-in main [board-id :selrect :width])))
+ (t/is (= 131 (get-in branch-objects [board-id :selrect :width])))))
+
+;; --- Layers whose place is not their x and y alone
+
+(def ^:private group-id (uuid/next))
+(def ^:private line-id (uuid/next))
+
+(defn- line-content
+ "A path from `x`,`y` to 10 to the right and 20 down."
+ [x y]
+ [{:command :move-to :params {:x x :y y}}
+ {:command :line-to :params {:x (+ x 10) :y (+ y 20)}}])
+
+(def ^:private moved-objects
+ "The branch, open: it moved a group and a path."
+ (-> branch-objects
+ (assoc-in [board-id :shapes] [group-id line-id])
+ (assoc group-id (cts/setup-rect {:id group-id :type :group :name "group"
+ :parent-id board-id :x 300 :y 400
+ :width 50 :height 60 :shapes []})
+ line-id (cts/setup-path {:id line-id :type :path :name "line"
+ :parent-id board-id
+ :content (line-content 500 600)}))))
+
+(def ^:private moves
+ [{:kind :shape :status :modified :id group-id
+ :changed-attrs {:x {:main 10 :branch 300} :y {:main 20 :branch 400}}}
+ {:kind :shape :status :modified :id line-id
+ :changed-attrs {:content {:main (line-content 30 40)
+ :branch (line-content 500 600)}}}])
+
+(t/deftest a-moved-group-takes-its-place-on-the-other-side
+ (let [main (brs/side-objects moved-objects moves :main :branch)]
+ (t/is (= {:x 10 :y 20 :width 50 :height 60}
+ (select-keys (get-in main [group-id :selrect]) [:x :y :width :height])))
+ (t/is (= 300 (get-in moved-objects [group-id :selrect :x])) "the branch keeps its own")))
+
+(t/deftest a-moved-path-takes-its-place-on-the-other-side
+ (let [main (brs/side-objects moved-objects moves :main :branch)]
+ (t/is (= {:x 30 :y 40 :width 10 :height 20}
+ (select-keys (get-in main [line-id :selrect]) [:x :y :width :height])))
+ (t/is (= 500 (get-in moved-objects [line-id :selrect :x])) "the branch keeps its own")))
+
+;; --- The changes an update brings
+
+(def ^:private badge-id (uuid/next))
+
+(def ^:private badge
+ {:id badge-id :type :rect :name "badge" :parent-id board-id
+ :x 4 :y 4 :width 8 :height 8})
+
+(def ^:private incoming
+ "What main did since the branch left: it widened the button, added a
+ badge to it and deleted nothing the branch still has."
+ [{:kind :shape :status :modified :id board-id :key "board"
+ :changed-attrs {:width {:main 200 :branch 131}}}
+ {:kind :shape :status :added :id badge-id :key "badge" :shape badge}])
+
+(t/deftest an-update-brings-what-main-added-and-changed
+ (let [after (brs/side-objects branch-objects incoming :main :branch :main)]
+ (t/is (= 200 (get-in after [board-id :selrect :width])))
+ (t/is (= badge (get after badge-id)))
+ (t/is (= [badge-id] (get-in after [board-id :shapes])))))
+
+(t/deftest an-update-takes-away-what-main-deleted
+ (let [with-badge (-> branch-objects
+ (assoc badge-id badge)
+ (assoc-in [board-id :shapes] [badge-id]))
+ after (brs/side-objects with-badge
+ [{:kind :shape :status :deleted :id badge-id}]
+ :main :branch :main)]
+ (t/is (not (contains? after badge-id)))
+ (t/is (= [] (get-in after [board-id :shapes])))))
+
+;; --- The choices made for the conflicts
+
+(def ^:private clash
+ {:kind :shape :status :conflict :id board-id
+ :main {:id board-id :type :frame :name "Main button" :parent-id uuid/zero
+ :x 0 :y 0 :width 163 :height 48 :opacity 0.5 :shapes []}
+ :branch (get branch-objects board-id)
+ :changed-attrs {:width {:main 163 :branch 131}
+ :opacity {:main 0.5 :branch nil}}})
+
+(t/deftest a-conflict-shows-the-side-chosen-for-each-property
+ (let [none (brs/resolved-objects branch-objects [clash] {})
+ mixed (brs/resolved-objects branch-objects [clash] {board-id {:width :branch :opacity :main}})
+ whole (brs/resolved-objects branch-objects [clash] {board-id :main})
+ gone (brs/resolved-objects branch-objects [(assoc clash :main nil)] {board-id :main})]
+ (t/is (identical? branch-objects none) "no choice: the branch as it is")
+ (t/is (= 0.5 (get-in mixed [board-id :opacity])))
+ (t/is (= 131 (get-in mixed [board-id :selrect :width])) "the branch keeps its width")
+ (t/is (= "Main button" (get-in whole [board-id :name])))
+ (t/is (not (contains? gone board-id)) "main deleted it")
+ (t/is (identical? branch-objects
+ (brs/resolved-objects branch-objects [clash] {board-id :branch})))))
+
+;; --- What the canvas shows in the compare mode
+
+(def ^:private page-id (uuid/next))
+
+(defn- comparison
+ [opts]
+ (merge {:mode {:hidden false}
+ :phase :compare
+ :incoming false
+ :model {:items (mapv #(assoc % :page-id page-id) incoming)}
+ :conflicts {:conflicts [(assoc clash :page-id page-id)]}
+ :resolutions {}
+ :excluded #{}}
+ opts))
+
+(t/deftest the-canvas-shows-the-branch-while-its-own-changes-are-listed
+ (t/is (nil? (cc/canvas-objects (comparison {}) branch-objects page-id))))
+
+(t/deftest the-canvas-shows-the-update-without-what-is-left-out
+ (let [all (cc/canvas-objects (comparison {:incoming true}) branch-objects page-id)
+ some (cc/canvas-objects (comparison {:incoming true :excluded #{"badge"}})
+ branch-objects page-id)]
+ (t/is (= :update (:kind all)))
+ (t/is (contains? (:objects all) badge-id))
+ (t/is (= 200 (get-in all [:objects board-id :selrect :width])))
+ (t/is (not (contains? (:objects some) badge-id)) "a change left out is not brought in")
+ (t/is (nil? (cc/canvas-objects (comparison {:incoming true}) branch-objects (uuid/next)))
+ "another page has nothing of it")
+ (t/is (nil? (cc/canvas-objects (comparison {:incoming true :mode {:hidden true}})
+ branch-objects page-id))
+ "hidden changes leave the branch as it is")))
+
+(t/deftest the-canvas-shows-the-choices-and-the-side-tried-out
+ (let [item (assoc clash :page-id page-id)
+ chosen (cc/canvas-objects (comparison {:phase :resolve
+ :resolutions {board-id {:opacity :main}}})
+ branch-objects page-id)
+ tried (cc/canvas-objects (comparison {:phase :resolve
+ :mode {:preview :main}
+ :item (assoc item :main nil)})
+ branch-objects page-id)]
+ (t/is (= :result (:kind chosen)))
+ (t/is (= 0.5 (get-in chosen [:objects board-id :opacity])))
+ (t/is (nil? (cc/canvas-objects (comparison {:phase :resolve}) branch-objects page-id))
+ "nothing chosen yet")
+ (t/is (= :result (:kind tried)) "the side under the pointer counts as chosen")))
+
+(t/deftest the-change-chosen-is-marked-alone
+ (let [marks [{:key "a" :status :modified}
+ {:key "b" :status :added}
+ {:key "c" :status :deleted}
+ {:key "a/1" :status :usage}]]
+ (t/is (= marks (cc/chosen-marks nil nil marks)) "none chosen: every mark")
+ (t/is (= marks (cc/chosen-marks nil "b" marks)) "the pointer takes none away")
+ (t/is (= ["a" "a/1"] (mapv :key (cc/chosen-marks "a" nil marks)))
+ "its own mark and the layers that use it")
+ (t/is (= ["a" "b" "a/1"] (mapv :key (cc/chosen-marks "a" "b" marks)))
+ "and the one of the row under the pointer")
+ (t/is (= ["a/1"] (mapv :key (cc/chosen-marks "z" nil marks)))
+ "a change of another page leaves no mark of the others")))
+
+(t/deftest a-layer-answers-for-the-closest-change-that-holds-it
+ (let [inner (uuid/next)
+ ;; the root of a page is its own parent
+ objects (-> branch-objects
+ (assoc-in [uuid/zero :parent-id] uuid/zero)
+ (assoc icon-id (assoc icon :shapes [inner])
+ inner {:id inner :parent-id icon-id}))
+ board {:kind :shape :id board-id :key "board"}
+ group {:kind :shape :id icon-id :key "icon"}
+ color {:kind :color :id board-id :key "color"}]
+ (t/is (= "board" (cc/layer-entry [board] objects [inner]))
+ "the change of the board is the change of what is in it")
+ (t/is (= "icon" (cc/layer-entry [board group] objects [board-id inner]))
+ "the deepest layer with a change wins")
+ (t/is (nil? (cc/layer-entry [group] objects [board-id])) "a layer with no change")
+ (t/is (nil? (cc/layer-entry [group] objects [uuid/zero])) "the root of the page")
+ (t/is (nil? (cc/layer-entry [color] objects [board-id])) "an asset is no layer")
+ (t/is (nil? (cc/layer-entry [board] objects nil)) "the pointer on nothing")))
+
+;; --- Main beside the branch
+
+(defn- on-page
+ [items]
+ (mapv #(assoc % :page-id page-id) items))
+
+(t/deftest main-is-put-together-from-either-direction
+ (let [from-branch (cc/main-objects branch-objects page-id (on-page items) nil false)
+ from-main (cc/main-objects branch-objects page-id (on-page incoming) nil true)]
+ (t/is (= icon (get from-branch icon-id)) "what the branch deleted is back")
+ (t/is (= 163 (get-in from-branch [board-id :selrect :width])))
+ (t/is (contains? from-main badge-id) "what main added is there")
+ (t/is (= 200 (get-in from-main [board-id :selrect :width])))))
+
+(t/deftest main-takes-the-changes-of-both-directions
+ (let [own (on-page (filterv #(= :deleted (:status %)) items))
+ added (on-page (filterv #(= :added (:status %)) incoming))
+ main (cc/main-objects branch-objects page-id own added false)
+ same (cc/main-objects branch-objects page-id added own true)
+ peek (cc/canvas-objects (comparison {:mode {:peek true :other-changes added}
+ :model {:items own}})
+ branch-objects page-id)]
+ (t/is (= icon (get main icon-id)) "what the branch deleted is back")
+ (t/is (contains? main badge-id) "what main added since is there too")
+ (t/is (and (contains? same icon-id) (contains? same badge-id))
+ "whichever direction is listed")
+ (t/is (= :main (:kind peek)))
+ (t/is (= main (:objects peek)) "the canvas shows that main while peeking")
+ (t/is (not (contains? (cc/main-objects branch-objects page-id own
+ (mapv #(assoc % :page-id (uuid/next)) added)
+ false)
+ badge-id))
+ "a change of another page stays out")))
+
+(t/deftest pictures-are-taken-of-the-boards-that-hold-changes
+ (let [main (cc/main-objects branch-objects page-id (on-page items) nil false)
+ loose {:kind :shape :status :added :id (uuid/next)}]
+ (t/is (= [board-id] (side/picture-roots items main branch-objects))
+ "one picture of the board, whatever changed inside it")
+ (t/is (= [] (side/picture-roots [loose] main branch-objects))
+ "a layer neither side has in a board leaves nothing to draw")
+ (t/is (= [] (side/picture-roots [{:kind :color :status :modified :id (uuid/next)}]
+ main branch-objects)))))
+
+;; --- Main lined up with the change chosen
+
+(defn- box
+ [id x y width height]
+ (cts/setup-rect {:id id :type :rect :name "box" :parent-id board-id
+ :x x :y y :width width :height height}))
+
+(t/deftest main-moves-by-what-the-layer-moved
+ (let [id (uuid/next)
+ item {:kind :shape :id id}
+ canvas {id (box id 400 150 20 10)}]
+ (t/is (= {:x 300 :y 50} (cc/align-offset canvas {id (box id 100 100 20 10)} item)))
+ (t/is (= {:x 5 :y 3} (cc/align-offset canvas {id (box id 400 150 10 4)} item))
+ "a layer that grew lines up by its centre")))
+
+(t/deftest main-stays-put-with-nothing-to-line-up
+ (let [id (uuid/next)
+ item {:kind :shape :id id}
+ canvas {id (box id 400 150 20 10)}]
+ (t/is (nil? (cc/align-offset canvas canvas item)) "the same place on both sides")
+ (t/is (nil? (cc/align-offset canvas {} item)) "a layer main lacks")
+ (t/is (nil? (cc/align-offset {} canvas item)) "a layer the canvas lacks")
+ (t/is (nil? (cc/align-offset canvas canvas {:kind :color :id id})) "an asset")
+ (t/is (nil? (cc/align-offset canvas canvas nil)) "no change chosen")))
+
+(t/deftest main-lines-up-a-moved-group-and-a-moved-path
+ (let [main (cc/main-objects moved-objects page-id (on-page moves) nil false)]
+ (t/is (= {:x 290 :y 380}
+ (cc/align-offset moved-objects main {:kind :shape :id group-id})))
+ (t/is (= {:x 470 :y 560}
+ (cc/align-offset moved-objects main {:kind :shape :id line-id})))))
+
+(t/deftest the-layer-of-main-shows-the-spot-of-the-second-half
+ (let [vbox {:x 100 :y 50}]
+ (t/is (= {:x -700 :y -100} (side/layer-translate vbox 2 500 0))
+ "half a viewport back")
+ (t/is (= {:x -724 :y -124} (side/layer-translate vbox 2 500 24))
+ "after the rulers")))
+
+(t/deftest main-reaches-as-far-as-its-layers
+ (let [main (cc/main-objects branch-objects page-id (on-page items) nil false)]
+ (t/is (= {:x 0 :y 0 :width 163 :height 48}
+ (select-keys (cc/main-extent main) [:x :y :width :height])))
+ (t/is (nil? (cc/main-extent {uuid/zero {:id uuid/zero :type :frame :shapes []}}))
+ "an empty page")))
+
+;; --- What else the layer of the change carries
+
+(t/deftest the-layer-shows-the-comments-that-wait-for-an-answer
+ (let [layer (uuid/next)
+ threads {1 {:id 1 :seqn 2 :shape-id layer}
+ 2 {:id 2 :seqn 1 :shape-id layer}
+ 3 {:id 3 :seqn 3 :shape-id layer :is-resolved true}
+ 4 {:id 4 :seqn 4 :shape-id (uuid/next)}}]
+ (t/is (= [2 1] (mapv :id (detail/layer-threads threads layer)))
+ "its own, in the order they were opened, the resolved ones left out")
+ (t/is (= [] (detail/layer-threads threads (uuid/next))) "a layer without any")))
+
+(t/deftest the-layer-shows-the-tasks-still-open
+ (let [layer (uuid/next)
+ tasks {1 {:id 1 :shape-id layer :status "open"}
+ 2 {:id 2 :shape-id layer :status "done"}
+ 3 {:id 3 :shape-id layer :status "verified"}
+ 4 {:id 4 :shape-id (uuid/next) :status "open"}}]
+ (t/is (= [1 2] (sort (mapv :id (detail/layer-tasks tasks layer))))
+ "one to do and one to verify; a verified one is closed")))
diff --git a/frontend/test/frontend_tests/ui/ds_popover_test.cljs b/frontend/test/frontend_tests/ui/ds_popover_test.cljs
new file mode 100644
index 0000000000..f0c2aeefab
--- /dev/null
+++ b/frontend/test/frontend_tests/ui/ds_popover_test.cljs
@@ -0,0 +1,119 @@
+;; 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) KALEIDOS SUBSIDIARY SL
+
+(ns frontend-tests.ui.ds-popover-test
+ "The DS popover closes on a click out of it and out of its container,
+ and on Escape; it ignores the click that opened it, and renders
+ nothing while closed. The document comes from jsdom, since the runner
+ has none."
+ (:require
+ ["jsdom" :refer [JSDOM]]
+ ["react" :as react]
+ ["react-dom/client" :as rdc]
+ [app.main.ui.ds.layout.popover :refer [popover*]]
+ [app.util.globals :as globals]
+ [cljs.test :as t :include-macros true]
+ [frontend-tests.helpers.mock :as mock]
+ [rumext.v2 :as mf]))
+
+(mf/defc host*
+ "A bar (the container), the popover with a button inside, and a spot
+ out of both."
+ {::mf/private true}
+ [{:keys [is-open on-close]}]
+ (let [bar-ref (mf/use-ref nil)]
+ [:div
+ [:div {:id "bar" :ref bar-ref} "bar"]
+ [:> popover* {:is-open is-open :on-close on-close :container bar-ref}
+ [:button {:id "inside"} "inside"]]
+ [:div {:id "outside"} "outside"]]))
+
+(defn- later
+ "Resolves after the timers queued so far, the one that lets the
+ popover listen among them."
+ []
+ (js/Promise. (fn [resolve] (js/setTimeout resolve 10))))
+
+(defn- ^:async with-host
+ "Mounts `host*` open (`is-open`) in a jsdom document and calls
+ `test-fn` with a fn that finds an element by id, a fn that sends a
+ keyup of `key` to the document, and the number of times the popover
+ asked to close (an atom)."
+ [is-open test-fn]
+ (let [dom (JSDOM. "
")
+ window (.-window dom)
+ document (.-document window)
+ old-window (.-window js/globalThis)
+ old-document (.-document js/globalThis)
+ old-act (.-IS_REACT_ACT_ENVIRONMENT js/globalThis)
+ closes (atom 0)
+ on-close #(swap! closes inc)
+ by-id #(.getElementById document %)
+ key-up (fn [key]
+ (.dispatchEvent document
+ (new (.-KeyboardEvent window) "keyup"
+ #js {:key key :bubbles true})))]
+ (set! (.-window js/globalThis) window)
+ (set! (.-document js/globalThis) document)
+ (set! (.-IS_REACT_ACT_ENVIRONMENT js/globalThis) true)
+ (try
+ (await
+ (mock/with-mocks* {globals/document document globals/window window}
+ (let [root (rdc/createRoot (by-id "root"))]
+ ;; a synchronous act runs the effects before it returns, and
+ ;; nothing waits after it: the popover is set up and its
+ ;; timer has not run yet, as right after the click that
+ ;; opened it
+ (react/act #(.render root (mf/element host* #js {:isOpen is-open
+ :onClose on-close})))
+ (await (test-fn by-id key-up closes))
+ (await (react/act #(.unmount root))))))
+ (finally
+ (set! (.-window js/globalThis) old-window)
+ (set! (.-document js/globalThis) old-document)
+ (set! (.-IS_REACT_ACT_ENVIRONMENT js/globalThis) old-act)))))
+
+(t/deftest ^:async a-closed-popover-renders-nothing
+ (await
+ (with-host false
+ (^:async fn [by-id _ _]
+ (t/is (nil? (by-id "inside")))
+ (t/is (some? (by-id "outside")))))))
+
+(t/deftest ^:async a-click-out-of-it-closes-it
+ (await
+ (with-host true
+ (^:async fn [by-id _ closes]
+ (await (later))
+ (.click (by-id "outside"))
+ (t/is (= 1 @closes))))))
+
+(t/deftest ^:async a-click-in-it-or-in-its-container-keeps-it-open
+ (await
+ (with-host true
+ (^:async fn [by-id _ closes]
+ (await (later))
+ (.click (by-id "inside"))
+ (.click (by-id "bar"))
+ (t/is (= 0 @closes))))))
+
+(t/deftest ^:async escape-closes-it
+ (await
+ (with-host true
+ (^:async fn [_ key-up closes]
+ (await (later))
+ (key-up "Enter")
+ (t/is (= 0 @closes) "another key does nothing")
+ (key-up "Escape")
+ (t/is (= 1 @closes))))))
+
+(t/deftest ^:async the-click-that-opens-it-does-not-close-it
+ (await
+ (with-host true
+ (^:async fn [by-id _ closes]
+ ;; before the popover listens, as the click that opened it
+ (.click (by-id "outside"))
+ (t/is (= 0 @closes))))))
diff --git a/frontend/translations/en.po b/frontend/translations/en.po
index 57da6e76b3..ab5c6620f6 100644
--- a/frontend/translations/en.po
+++ b/frontend/translations/en.po
@@ -6703,18 +6703,10 @@ msgstr "%s conflicts"
msgid "workspace.branches.banner.expand"
msgstr "Expand"
-#, unused
-msgid "workspace.branches.banner.from-main"
-msgstr "from main"
-
#, unused
msgid "workspace.branches.banner.merged"
msgstr "Merged branch"
-#, unused
-msgid "workspace.branches.banner.on-branch"
-msgstr "On branch"
-
#: src/app/main/ui/workspace/sidebar/branches.cljs:1853
msgid "workspace.branches.banner.status.ahead"
msgid_plural "workspace.branches.banner.status.ahead"
@@ -6749,11 +6741,6 @@ msgstr "View in main"
msgid "workspace.branches.compare"
msgstr "Compare"
-#: src/app/main/ui/workspace/sidebar/branches.cljs:463
-#, unused
-msgid "workspace.branches.compare.attr"
-msgstr "Property"
-
#: src/app/main/ui/workspace/sidebar/branches.cljs:99
msgid "workspace.branches.compare.attr.blend-mode"
msgstr "Blend mode"
@@ -6821,50 +6808,6 @@ msgid_plural "workspace.branches.compare.footer-changes"
msgstr[0] "1 change"
msgstr[1] "%s changes"
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1358
-msgid "workspace.branches.compare.footer-conflicts"
-msgid_plural "workspace.branches.compare.footer-conflicts"
-msgstr[0] "1 to resolve before merging"
-msgstr[1] "%s to resolve before merging"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1354
-msgid "workspace.branches.compare.footer-selected"
-msgid_plural "workspace.branches.compare.footer-selected"
-msgstr[0] "%s of 1 selected"
-msgstr[1] "%s of %s selected"
-
-#, unused
-msgid "workspace.branches.compare.group.colors"
-msgstr "Colors"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1098
-msgid "workspace.branches.compare.group.component"
-msgstr "Component"
-
-#, unused
-msgid "workspace.branches.compare.group.components"
-msgstr "Components"
-
-#, unused
-msgid "workspace.branches.compare.group.media"
-msgstr "Media"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1099
-msgid "workspace.branches.compare.group.other"
-msgstr "Other changes"
-
-#, unused
-msgid "workspace.branches.compare.group.pages"
-msgstr "Pages"
-
-#, unused
-msgid "workspace.branches.compare.group.tokens"
-msgstr "Tokens"
-
-#, unused
-msgid "workspace.branches.compare.group.typographies"
-msgstr "Typographies"
-
#: src/app/main/ui/workspace/sidebar/branches.cljs:1054, src/app/main/ui/workspace/sidebar/branches.cljs:1439
msgid "workspace.branches.compare.loading"
msgstr "Computing changes…"
@@ -6890,10 +6833,6 @@ msgstr[1] "%s properties"
msgid "workspace.branches.compare.no-props"
msgstr "No property-level changes"
-#: src/app/main/ui/workspace/sidebar/branches.cljs:924
-msgid "workspace.branches.compare.prop-changes"
-msgstr "Property changes"
-
#: src/app/main/ui/workspace/sidebar/branches.cljs:912
msgid "workspace.branches.compare.select-hint"
msgstr "Select a change to see its details"
@@ -6953,48 +6892,10 @@ msgstr "Text"
msgid "workspace.branches.compare.shape.variant"
msgstr "Variant"
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1262
-msgid "workspace.branches.compare.stats.added"
-msgid_plural "workspace.branches.compare.stats.added"
-msgstr[0] "1 added"
-msgstr[1] "%s added"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1269
-msgid "workspace.branches.compare.stats.conflicts"
-msgid_plural "workspace.branches.compare.stats.conflicts"
-msgstr[0] "1 conflict"
-msgstr[1] "%s conflicts"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1266
-msgid "workspace.branches.compare.stats.deleted"
-msgid_plural "workspace.branches.compare.stats.deleted"
-msgstr[0] "1 deleted"
-msgstr[1] "%s deleted"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1264
-msgid "workspace.branches.compare.stats.modified"
-msgid_plural "workspace.branches.compare.stats.modified"
-msgstr[0] "1 modified"
-msgstr[1] "%s modified"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1089
-msgid "workspace.branches.compare.subtitle-mods"
-msgid_plural "workspace.branches.compare.subtitle-mods"
-msgstr[0] "1 property change"
-msgstr[1] "%s property changes"
-
#: src/app/main/ui/workspace/sidebar/branches.cljs:876
msgid "workspace.branches.compare.subtitle-new"
msgstr "New %s"
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1013, src/app/main/ui/workspace/sidebar/branches.cljs:1014, src/app/main/ui/workspace/sidebar/branches.cljs:1025, src/app/main/ui/workspace/sidebar/branches.cljs:1026
-msgid "workspace.branches.compare.swap"
-msgstr "Swap direction (branch ↔ main)"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1005
-msgid "workspace.branches.compare.title"
-msgstr "Compare changes"
-
#, unused
msgid "workspace.branches.compare.type.color"
msgstr "Color"
@@ -7027,89 +6928,14 @@ msgstr "false"
msgid "workspace.branches.compare.value-true"
msgstr "true"
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1430
-msgid "workspace.branches.conflicts.all-branch"
-msgstr "Use branch for all"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1428
-msgid "workspace.branches.conflicts.all-main"
-msgstr "Use main for all"
-
#: src/app/main/ui/workspace/sidebar/branches.cljs:1534
msgid "workspace.branches.conflicts.apply"
msgstr "Apply and merge"
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1426
-msgid "workspace.branches.conflicts.bulk-label"
-msgstr "Bulk actions:"
-
-#, unused
-msgid "workspace.branches.conflicts.card.base"
-msgstr "Base (ancestor)"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1369
-msgid "workspace.branches.conflicts.card.base-meta"
-msgstr "at branch creation"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1497
-msgid "workspace.branches.conflicts.card.branch"
-msgstr "Your branch"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1495
-msgid "workspace.branches.conflicts.card.main"
-msgstr "Main"
-
-#, unused
-msgid "workspace.branches.conflicts.card.result"
-msgstr "Result"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1372
-msgid "workspace.branches.conflicts.card.you"
-msgstr "You"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:992
-#, unused
-msgid "workspace.branches.conflicts.chosen"
-msgstr "Chosen"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:777
-#, unused
-msgid "workspace.branches.conflicts.chosen-branch"
-msgstr "branch"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:775
-#, unused
-msgid "workspace.branches.conflicts.chosen-main"
-msgstr "main"
-
#: src/app/main/ui/workspace/sidebar/branches.cljs:1444
msgid "workspace.branches.conflicts.empty"
msgstr "No conflicts to resolve"
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1520
-msgid "workspace.branches.conflicts.footer-pending"
-msgstr "%s conflict(s) pending. Resolve all to merge"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1515
-msgid "workspace.branches.conflicts.footer-ready"
-msgstr "All conflicts resolved"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1450
-msgid "workspace.branches.conflicts.list-head"
-msgstr "%s conflicts"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1433
-msgid "workspace.branches.conflicts.pending"
-msgstr "%s pending"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1419
-msgid "workspace.branches.conflicts.progress"
-msgstr "%s of %s resolved"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1493
-msgid "workspace.branches.conflicts.prop-header"
-msgstr "Property"
-
#, unused
msgid "workspace.branches.conflicts.reason.add-add"
msgstr "added in both with different values"
@@ -7130,63 +6956,18 @@ msgstr "edited in main and in the branch since the base"
msgid "workspace.branches.conflicts.resolve"
msgstr "Resolve conflicts"
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1198
-msgid "workspace.branches.conflicts.side-branch"
-msgstr "branch"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1194
-msgid "workspace.branches.conflicts.side-main"
-msgstr "main"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1190
-msgid "workspace.branches.conflicts.side-mixed"
-msgstr "mixed"
-
-#, unused
-msgid "workspace.branches.conflicts.state-pending"
-msgstr "unresolved"
-
-#, unused
-msgid "workspace.branches.conflicts.state-resolved"
-msgstr "resolved"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1417
-msgid "workspace.branches.conflicts.subtitle"
-msgstr "Merge %s into main"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1415
-msgid "workspace.branches.conflicts.title"
-msgstr "Resolve conflicts"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1477
-msgid "workspace.branches.conflicts.use-branch"
-msgstr "Use branch"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1474
-msgid "workspace.branches.conflicts.use-main"
-msgstr "Use main"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:994
-#, unused
-msgid "workspace.branches.conflicts.use-this"
-msgstr "Use this"
-
-#: src/app/main/ui/workspace/sidebar/branches.cljs:1508
-msgid "workspace.branches.conflicts.whole-hint"
-msgstr "This element was added or removed on one side. Choose which version to keep."
-
#: src/app/main/ui/workspace/sidebar/branches.cljs:593, src/app/main/ui/workspace/sidebar/branches.cljs:824, src/app/main/ui/workspace/sidebar/branches.cljs:1933
msgid "workspace.branches.counts.ahead"
msgstr ""
"Changes this branch has and main does not. Counts entity-level changes "
-"(shapes, pages, components, colours, typographies, media, and tokens), not "
+"(shapes, pages, components, colors, typographies, media, and tokens), not "
"saves."
#: src/app/main/ui/workspace/sidebar/branches.cljs:596, src/app/main/ui/workspace/sidebar/branches.cljs:828, src/app/main/ui/workspace/sidebar/branches.cljs:1936
msgid "workspace.branches.counts.behind"
msgstr ""
"Changes main has and this branch does not. Counts entity-level changes "
-"(shapes, pages, components, colours, typographies, media, and tokens), not "
+"(shapes, pages, components, colors, typographies, media, and tokens), not "
"saves."
#: src/app/main/ui/workspace/sidebar/branches.cljs:606, src/app/main/ui/workspace/sidebar/branches.cljs:842, src/app/main/ui/workspace/sidebar/branches.cljs:1956, src/app/main/ui/dashboard/branches_popover.cljs:85
@@ -7253,11 +7034,6 @@ msgstr "Delete branch \"%s\"? This cannot be undone."
msgid "workspace.branches.delete.title"
msgstr "Delete branch"
-#: src/app/main/ui/workspace/sidebar/branches.cljs:356
-#, unused
-msgid "workspace.branches.empty"
-msgstr "No branches yet"
-
#: src/app/main/ui/workspace/left_header.cljs:169
msgid "workspace.branches.header-badge-tooltip"
msgstr "On branch %s from main"
@@ -7565,11 +7341,6 @@ msgstr ""
msgid "workspace.branches.merge.confirm-title"
msgstr "Merge into main"
-#: src/app/main/data/workspace/branches.cljs:415
-#, unused
-msgid "workspace.branches.merge.conflicts"
-msgstr "This branch has conflicts that must be resolved before merging"
-
#: src/app/main/ui/workspace/sidebar/branches.cljs:378
msgid "workspace.branches.merge.delete-info"
msgstr "After merging, this branch and its file will be deleted to free up storage."
@@ -7598,10 +7369,6 @@ msgstr ""
"This branch changes elements that can't be merged automatically yet "
"(components, pages or tokens)"
-#, unused
-msgid "workspace.branches.new"
-msgstr "New"
-
msgid "workspace.branches.rename.title"
msgstr "Rename branch"
@@ -7705,10 +7472,6 @@ msgstr "Reviews"
msgid "workspace.branches.switcher.tooltip"
msgstr "Switch branch"
-#, unused
-msgid "workspace.branches.tab"
-msgstr "Branches"
-
#: src/app/main/ui/workspace/sidebar/branches.cljs:688, src/app/main/ui/workspace/sidebar/branches.cljs:1141, src/app/main/ui/workspace/sidebar/branches.cljs:1632
msgid "workspace.branches.update"
msgstr "Update from main"
@@ -7727,10 +7490,6 @@ msgstr ""
msgid "workspace.branches.update.confirm-title"
msgstr "Update from main"
-#, unused
-msgid "workspace.branches.update.conflicts"
-msgstr "main has conflicting changes; resolve them when merging"
-
#: src/app/main/data/workspace/branches.cljs:362, src/app/main/data/workspace/branches.cljs:364
msgid "workspace.branches.update.error"
msgstr "Could not update the branch"
@@ -7745,11 +7504,6 @@ msgstr ""
"main changed elements that can't be brought in automatically yet "
"(components, pages or token structure)"
-#: src/app/main/ui/workspace/sidebar/branches.cljs:439
-#, unused
-msgid "workspace.branches.you-editing"
-msgstr "%s - editing now"
-
#: src/app/main/data/workspace/clipboard.cljs:1242
msgid "workspace.clipboard.copying"
msgstr "Copying image…"
@@ -9928,13 +9682,9 @@ msgstr ""
"Reviewers will see the latest changes of the branch. Approvals given so far "
"will have to be renewed."
-#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:748
-msgid "workspace.pull-requests.banner.review"
-msgstr "Review"
-
#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:710
msgid "workspace.pull-requests.banner.reviewing"
-msgstr "Reviewing the design review"
+msgstr "In review"
#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:504
msgid "workspace.pull-requests.close.message"
@@ -10053,10 +9803,6 @@ msgstr "An error occurred while updating the design review"
msgid "workspace.pull-requests.lifecycle.reopened"
msgstr "Design review reopened"
-#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:555, src/app/main/ui/workspace/sidebar/pull_requests.cljs:731
-msgid "workspace.pull-requests.menu.info"
-msgstr "Details"
-
#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:558
msgid "workspace.pull-requests.menu.publish"
msgstr "Publish latest changes"
@@ -10069,10 +9815,6 @@ msgstr "Request review"
msgid "workspace.pull-requests.menu.review-details"
msgstr "Review details"
-#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:618
-msgid "workspace.pull-requests.new"
-msgstr "New"
-
#: src/app/main/data/workspace/pull_requests.cljs:396
msgid "workspace.pull-requests.preview.unavailable"
msgstr "The review sandbox is not available (the design review may be closed)"
@@ -10141,18 +9883,6 @@ msgstr "Review submitted"
msgid "workspace.pull-requests.review.title"
msgstr "Submit review"
-#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:632
-msgid "workspace.pull-requests.section.empty"
-msgstr "No design reviews yet. Create one from a branch to request a review."
-
-#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:639
-msgid "workspace.pull-requests.section.history"
-msgstr "Finished"
-
-#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:611
-msgid "workspace.pull-requests.section.title"
-msgstr "Design reviews"
-
#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:100
#, unused
msgid "workspace.pull-requests.state.approved"
@@ -11542,18 +11272,10 @@ msgstr ""
msgid "workspace.versions.warning.text"
msgstr "Autosaved versions will be kept for %s days."
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:540
-msgid "workspace.branches.resolve.back"
-msgstr "Back to review"
-
#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:361
msgid "workspace.branches.resolve.change-choice"
msgstr "Change choice"
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:150
-msgid "workspace.branches.resolve.choose-side"
-msgstr "Choose a side"
-
#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:241
msgid "workspace.branches.resolve.copy-dropped"
msgstr "Copy dropped text"
@@ -11592,32 +11314,16 @@ msgstr "This cannot be split by property. Keep one of the two versions."
#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:503
msgid "workspace.branches.resolve.keep-all-branch"
-msgstr "Keep branch for all"
+msgstr "Keep all branch"
#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:501
msgid "workspace.branches.resolve.keep-all-main"
-msgstr "Keep main for all"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:328
-msgid "workspace.branches.resolve.keep-branch"
-msgstr "Keep branch - %s"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:227
-msgid "workspace.branches.resolve.keep-branch-text"
-msgstr "Keep your text"
+msgstr "Keep all main"
#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:254
msgid "workspace.branches.resolve.keep-branch-version"
msgstr "Keep your version"
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:325
-msgid "workspace.branches.resolve.keep-main"
-msgstr "Keep main - %s"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:226
-msgid "workspace.branches.resolve.keep-main-text"
-msgstr "Keep main's text"
-
#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:253
msgid "workspace.branches.resolve.keep-main-version"
msgstr "Keep main's version"
@@ -11626,10 +11332,6 @@ msgstr "Keep main's version"
msgid "workspace.branches.resolve.keep-safe"
msgstr "Keep the dropped edit safe:"
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:545
-msgid "workspace.branches.resolve.next"
-msgstr "Next decision"
-
#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:79
msgid "workspace.branches.resolve.row.both-changed"
msgstr "%s - both changed"
@@ -11658,50 +11360,10 @@ msgstr "Loses work"
msgid "workspace.branches.resolve.tag.conflict"
msgstr "Conflict"
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:160
-msgid "workspace.branches.resolve.tag.from-branch"
-msgstr "From branch"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:158
-msgid "workspace.branches.resolve.tag.from-main"
-msgstr "From main"
-
#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:154
msgid "workspace.branches.resolve.tag.your-choice"
msgstr "Your choice"
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:118
-msgid "workspace.branches.resolve.th.branch"
-msgstr "Branch"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:117
-msgid "workspace.branches.resolve.th.main"
-msgstr "Main"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:116
-msgid "workspace.branches.resolve.th.property"
-msgstr "Property"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:119
-msgid "workspace.branches.resolve.th.result"
-msgstr "Result"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:476
-msgid "workspace.branches.resolve.title"
-msgstr "Resolve decisions"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:135
-msgid "workspace.branches.resolve.unchanged"
-msgstr "unchanged"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:772
-msgid "workspace.branches.review.action.mark-next"
-msgstr "Mark reviewed - next"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:768
-msgid "workspace.branches.review.action.previous"
-msgstr "Previous"
-
#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:141
msgid "workspace.branches.review.attr.fill"
msgstr "Fill"
@@ -11722,34 +11384,10 @@ msgstr "Stroke"
msgid "workspace.branches.review.attr.text"
msgstr "Text"
-#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:258
-msgid "workspace.branches.review.category.colour"
-msgstr "Color"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:260
-msgid "workspace.branches.review.category.components"
-msgstr "Components"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:257
-msgid "workspace.branches.review.category.copy"
-msgstr "Copy"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:256
-msgid "workspace.branches.review.category.decisions"
-msgstr "Decisions"
-
#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:259
msgid "workspace.branches.review.category.layout"
msgstr "Layout"
-#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:262
-msgid "workspace.branches.review.category.other"
-msgstr "Other"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:261
-msgid "workspace.branches.review.category.tokens"
-msgstr "Tokens"
-
#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:342
msgid "workspace.branches.review.decision.body"
msgstr "Main and this branch both edited it. Choose which version to keep before merging."
@@ -11766,10 +11404,6 @@ msgstr "Needs your decision (%s)"
msgid "workspace.branches.review.group.library"
msgstr "Library"
-#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:279
-msgid "workspace.branches.review.overlay-detail"
-msgstr "Branch over main"
-
#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:72
msgid "workspace.branches.review.row.choose"
msgstr "Choose"
@@ -11790,10 +11424,6 @@ msgstr "Branch"
msgid "workspace.branches.review.side.main"
msgstr "Main"
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:337
-msgid "workspace.branches.review.side.result"
-msgstr "Result"
-
#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:321
msgid "workspace.branches.review.summary.changed"
msgstr "Changed"
@@ -11802,32 +11432,14 @@ msgstr "Changed"
msgid "workspace.branches.review.summary.deleted"
msgstr "Deleted %s"
-#: src/app/main/ui/workspace/sidebar/branch_review/layout.cljs:72
-msgid "workspace.branches.review.this-branch"
-msgstr "Changes:"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:643
-msgid "workspace.branches.review.title"
-msgstr "Review changes"
-
#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:381
msgid "workspace.branches.review.unknown-page"
msgstr "Unknown page"
-#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:202
-msgid "workspace.branches.review.view.overlay"
-msgstr "Overlay"
-
#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:201
msgid "workspace.branches.review.view.side"
msgstr "Side by side"
-#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:535
-msgid "workspace.branches.resolve.footer.blocked"
-msgid_plural "workspace.branches.resolve.footer.blocked"
-msgstr[0] "Merge blocked: 1 decision left"
-msgstr[1] "Merge blocked: %s decisions left"
-
#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:297
msgid "workspace.branches.resolve.tag.conflicts"
msgid_plural "workspace.branches.resolve.tag.conflicts"
@@ -11858,18 +11470,6 @@ msgid_plural "workspace.branches.review.action.update"
msgstr[0] "Update with 1 change"
msgstr[1] "Update with %s changes"
-#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:130
-msgid "workspace.branches.review.board.inside"
-msgid_plural "workspace.branches.review.board.inside"
-msgstr[0] "Board - 1 change inside"
-msgstr[1] "Board - %s changes inside"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:753
-msgid "workspace.branches.review.footer.blocked"
-msgid_plural "workspace.branches.review.footer.blocked"
-msgstr[0] "merge blocked by 1 decision"
-msgstr[1] "merge blocked by %s decisions"
-
#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:755
msgid "workspace.branches.review.footer.left-out"
msgid_plural "workspace.branches.review.footer.left-out"
@@ -11882,42 +11482,6 @@ msgid_plural "workspace.branches.review.row.edits"
msgstr[0] "1 edit"
msgstr[1] "%s edits"
-#: src/app/main/ui/workspace/sidebar/branch_review/previews.cljs
-msgid "workspace.branches.review.missing.not-in-main"
-msgstr "Not in main"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/previews.cljs
-msgid "workspace.branches.review.missing.not-in-branch"
-msgstr "Not in this branch"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/previews.cljs
-msgid "workspace.branches.review.missing.new-in-branch"
-msgstr "New in this branch"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/previews.cljs
-msgid "workspace.branches.review.missing.new-in-main"
-msgstr "New in main"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/previews.cljs
-msgid "workspace.branches.review.missing.deleted-in-main"
-msgstr "Deleted in main"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/previews.cljs
-msgid "workspace.branches.review.missing.deleted-in-branch"
-msgstr "Deleted in this branch"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/previews.cljs
-msgid "workspace.branches.review.missing.no-preview"
-msgstr "No preview"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/previews.cljs
-msgid "workspace.branches.review.missing.open-main"
-msgstr "Open main to see it"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/previews.cljs
-msgid "workspace.branches.review.missing.open-branch"
-msgstr "Open the branch to see it"
-
#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
msgid "workspace.branches.review.summary.text"
msgstr "Text rewritten"
@@ -12040,10 +11604,6 @@ msgstr "Merging deletes this page and everything on it: %s and %s."
msgid "workspace.branches.review.facts.page-goes-update"
msgstr "Updating deletes this page and everything on it: %s and %s."
-#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
-msgid "workspace.branches.review.facts.changes-on-page"
-msgstr "Changes on this page (%s)"
-
#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
msgid "workspace.branches.review.facts.type"
msgstr "Type"
@@ -12166,10 +11726,6 @@ msgstr "Pages"
msgid "workspace.branches.review.facts.empty-page"
msgstr "Empty page"
-#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
-msgid "workspace.branches.review.category.variants"
-msgstr "Variants"
-
#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs
msgid "workspace.branches.resolve.drops.main-short"
msgstr "Main's %s:"
@@ -12196,14 +11752,6 @@ msgid_plural "workspace.branches.merge.left-out-lost"
msgstr[0] "The change you left out is lost when the branch is deleted."
msgstr[1] "The %s changes you left out are lost when the branch is deleted."
-#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs
-msgid "workspace.branches.review.view.expand"
-msgstr "Expand preview"
-
-#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs
-msgid "workspace.branches.review.view.collapse"
-msgstr "Collapse preview"
-
#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
msgid "workspace.branches.review.copies.settled-row"
msgstr "Decided by the copy rule"
@@ -12901,10 +12449,6 @@ msgstr "Verified"
msgid "workspace.tasks.status.wont-do"
msgstr "Won't do"
-#: src/app/main/ui/workspace/review/tasks.cljs
-msgid "workspace.tasks.task"
-msgstr "Task"
-
#: src/app/main/ui/workspace/review/tasks.cljs
msgid "workspace.tasks.title"
msgstr "Task title"
@@ -13044,3 +12588,163 @@ msgid "workspace.sidebar.layers.comments"
msgid_plural "workspace.sidebar.layers.comments"
msgstr[0] "1 open comment"
msgstr[1] "%s open comments"
+
+msgid "workspace.branches.open"
+msgstr "Open branch"
+
+msgid "workspace.branches.resolve.group.decided"
+msgstr "Decided (%s)"
+
+msgid "workspace.branches.resolve.group.pending"
+msgstr "Needs a decision (%s)"
+
+msgid "workspace.branches.resolve.paragraphs"
+msgid_plural "workspace.branches.resolve.paragraphs"
+msgstr[0] "1 paragraph"
+msgstr[1] "%s paragraphs"
+
+msgid "workspace.branches.resolve.tag.from"
+msgstr "From %s"
+
+msgid "workspace.compare.action.edit-layer"
+msgstr "Edit layer"
+
+msgid "workspace.compare.action.include-merge"
+msgstr "Include in merge"
+
+msgid "workspace.compare.action.include-update"
+msgstr "Include in update"
+
+msgid "workspace.compare.action.leave-out-merge"
+msgstr "Leave out of merge"
+
+msgid "workspace.compare.action.leave-out-update"
+msgstr "Leave out of update"
+
+msgid "workspace.compare.bar.all-decided"
+msgstr "All conflicts decided"
+
+msgid "workspace.compare.bar.apply-update"
+msgstr "Apply and update"
+
+msgid "workspace.compare.bar.back"
+msgstr "Back to compare"
+
+msgid "workspace.compare.bar.comparing"
+msgstr "Comparing"
+
+msgid "workspace.compare.bar.comparing-main"
+msgstr "Comparing with main"
+
+msgid "workspace.compare.bar.decided"
+msgstr "%s of %s decided"
+
+msgid "workspace.compare.bar.exit"
+msgstr "Exit compare"
+
+msgid "workspace.compare.changes"
+msgstr "Changes"
+
+msgid "workspace.compare.decisions"
+msgstr "Decisions (%s)"
+
+msgid "workspace.compare.direction.branch"
+msgstr "In this branch"
+
+msgid "workspace.compare.direction.main"
+msgstr "In main"
+
+msgid "workspace.compare.empty-main"
+msgstr "main has no changes this branch is missing"
+
+msgid "workspace.compare.filter.layers"
+msgstr "Layers"
+
+#: src/app/main/ui/workspace/compare/detail.cljs
+msgid "workspace.compare.layer.comments"
+msgstr "Comments on this layer (%s)"
+
+#: src/app/main/ui/workspace/compare/detail.cljs
+msgid "workspace.compare.layer.tasks"
+msgstr "Tasks on this layer (%s)"
+
+msgid "workspace.compare.navigator.changes"
+msgstr "Changes of the comparison"
+
+msgid "workspace.compare.navigator.decisions"
+msgstr "Conflicts to resolve"
+
+msgid "workspace.compare.navigator.in-main"
+msgstr "%s in main"
+
+msgid "workspace.compare.navigator.mark-reviewed"
+msgstr "Mark as reviewed"
+
+msgid "workspace.compare.navigator.next-pending"
+msgstr "Next pending"
+
+msgid "workspace.compare.popover.applies-merge"
+msgstr "Nothing changes until you apply and merge."
+
+msgid "workspace.compare.popover.applies-update"
+msgstr "Nothing changes until you apply and update."
+
+msgid "workspace.compare.popover.attr"
+msgstr "Both sides changed it. Pick the one to keep."
+
+msgid "workspace.compare.popover.text"
+msgstr "Both sides changed this text. Pick the one to keep."
+
+msgid "workspace.compare.tab-count"
+msgstr "%s (%s)"
+
+msgid "workspace.compare.toolbar.label"
+msgstr "Compare tools"
+
+msgid "workspace.compare.view.side.aligned"
+msgstr "Aligned to the change"
+
+msgid "workspace.compare.view.side.linked"
+msgstr "Linked"
+
+msgid "workspace.compare.view.hidden"
+msgstr "Changes hidden"
+
+msgid "workspace.compare.view.hide"
+msgstr "Hide changes"
+
+msgid "workspace.compare.view.highlight"
+msgstr "Highlight"
+
+msgid "workspace.compare.view.label"
+msgstr "How the canvas shows the changes"
+
+msgid "workspace.compare.view.show"
+msgstr "Show changes"
+
+msgid "workspace.compare.canvas.main"
+msgstr "main as it is now"
+
+msgid "workspace.compare.canvas.result"
+msgstr "Preview - the result of your choices"
+
+msgid "workspace.compare.canvas.update"
+msgstr "Preview - %s after the update"
+
+msgid "workspace.compare.navigator.peek"
+msgstr "%s - hold M to see main"
+
+msgid "workspace.compare.popover.hover"
+msgstr "Hovering an option previews it on the canvas."
+
+msgid "workspace.compare.side.aligned"
+msgstr "Main is shifted %s, %s to line up the change"
+
+msgid "workspace.compare.side.aligned-none"
+msgstr "Nothing to line up for this change"
+
+msgid "workspace.compare.side.linked"
+msgstr "Zoom and pan are linked"
+
+msgid "workspace.compare.side.not-in-main"
+msgstr "Not in main"
diff --git a/frontend/translations/es.po b/frontend/translations/es.po
index 70dd2cd4b3..702ae039d0 100644
--- a/frontend/translations/es.po
+++ b/frontend/translations/es.po
@@ -282,6 +282,10 @@ msgstr "Añadir archivo"
msgid "dashboard.add-shared"
msgstr "Añadir como Biblioteca Compartida"
+#: src/app/main/ui/dashboard/branches_popover.cljs:65
+msgid "dashboard.branches-badge"
+msgstr "%s ramas"
+
#: src/app/main/ui/settings/profile.cljs:79
msgid "dashboard.change-email"
msgstr "Cambiar correo"
@@ -1058,6 +1062,10 @@ msgstr "Otros equipos"
msgid "dashboard.password-change"
msgstr "Cambiar contraseña"
+#: src/app/main/ui/dashboard/comments.cljs:131
+msgid "dashboard.pending-reviews.title"
+msgstr "Revisiones pendientes"
+
#: src/app/main/data/common.cljs:194
msgid "dashboard.permissions-change.admin"
msgstr "Ahora eres administrador del equipo."
@@ -1913,6 +1921,18 @@ msgstr ""
"servidor. Se conservan y Penpot seguirá intentando guardarlos. Mantén esta "
"pestaña abierta hasta que se guarden."
+#: src/app/main/errors.cljs:542
+msgid "errors.save-refused-archived-branch"
+msgstr ""
+"Esta rama está archivada y es de solo lectura. Restáurala o conviértela en un "
+"archivo normal para seguir editando."
+
+#: src/app/main/errors.cljs:539
+msgid "errors.save-refused-merged-branch"
+msgstr ""
+"Esta rama ya está fusionada en main y es de solo lectura. Haz tus cambios en "
+"main."
+
#: src/app/main/errors.cljs:696
msgid "errors.save-still-retrying-busy"
msgstr ""
@@ -3892,10 +3912,38 @@ msgstr ""
"Este cliente puede leer y modificar diseños mediante conexiones MCP "
"establecidas desde Penpot."
+#: src/app/main/ui/mcp_authorize.cljs:153
+msgid "mcp.oauth.account"
+msgstr "Has iniciado sesión como %s."
+
+#: src/app/main/ui/mcp_authorize.cljs:162
+msgid "mcp.oauth.approve"
+msgstr "Permitir el acceso"
+
#: src/app/main/ui/mcp_authorize.cljs:133
msgid "mcp.oauth.cancelled"
msgstr "Conexión cancelada"
+#: src/app/main/ui/mcp_authorize.cljs:157
+msgid "mcp.oauth.enable"
+msgstr ""
+"Permitir el acceso activa la integración MCP y crea tu token MCP si hace "
+"falta."
+
+#: src/app/main/ui/mcp_authorize.cljs:137
+msgid "mcp.oauth.failed"
+msgstr ""
+"Esta solicitud ha caducado, ya se usó o no se pudo completar. Vuelve a "
+"iniciar la conexión desde tu cliente MCP."
+
+#: src/app/main/ui/mcp_authorize.cljs:149
+msgid "mcp.oauth.request"
+msgstr "%s quiere conectarse a Penpot."
+
+#: src/app/main/ui/mcp_authorize.cljs:129
+msgid "mcp.oauth.title"
+msgstr "Conectar con el MCP de Penpot"
+
#: src/app/main/ui/workspace/colorpicker.cljs:494
msgid "media.choose-image"
msgstr "Elegir imagen"
@@ -4899,6 +4947,11 @@ msgstr "Introduce el nombre del equipo"
msgid "onboarding.choice.team-up.create-team-name"
msgstr "Nombre del equipo"
+#: src/app/main/ui/onboarding/team_choice.cljs:188
+#, unused
+msgid "onboarding.choice.team-up.create-team-placeholder"
+msgstr "Escribe el nombre del equipo"
+
#: src/app/main/ui/onboarding/team_choice.cljs:237
msgid "onboarding.choice.team-up.create-team-without-invite"
msgstr "Crear equipo"
@@ -5517,6 +5570,10 @@ msgstr "Abrir selector de color"
msgid "shortcuts.open-comments"
msgstr "Comentarios"
+#: src/app/main/data/workspace/shortcuts.cljs:661
+msgid "shortcuts.open-branches"
+msgstr "Ramas"
+
#: src/app/main/data/workspace/shortcuts.cljs:765
msgid "shortcuts.open-dashboard"
msgstr "Ir al dashboard"
@@ -6719,6 +6776,38 @@ msgstr "Transformar texto"
msgid "workspace.assets.ungroup"
msgstr "Desagrupar"
+msgid "workspace.branches.archive.message"
+msgstr ""
+"¿Archivar la rama \"%s\"? Pasará a ser de solo lectura y saldrá de la lista "
+"de activas. Podrás restaurarla más adelante."
+
+msgid "workspace.branches.archive.title"
+msgstr "Archivar rama"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:836
+msgid "workspace.branches.archived"
+msgstr "Archivada"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:1840
+msgid "workspace.branches.banner.archived"
+msgstr "Rama archivada"
+
+#, unused
+msgid "workspace.branches.banner.collapse"
+msgstr "Contraer"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:518, src/app/main/ui/workspace/sidebar/branches.cljs:1614
+msgid "workspace.branches.banner.conflicts"
+msgstr "%s conflictos"
+
+#, unused
+msgid "workspace.branches.banner.expand"
+msgstr "Expandir"
+
+#, unused
+msgid "workspace.branches.banner.merged"
+msgstr "Rama fusionada"
+
#: src/app/main/ui/workspace/sidebar/branches.cljs:1853
msgid "workspace.branches.banner.status.ahead"
msgid_plural "workspace.branches.banner.status.ahead"
@@ -6745,10 +6834,525 @@ msgstr "En revisión - %s de %s aprobaciones"
msgid "workspace.branches.banner.status.up-to-date"
msgstr "Al día con main"
+#: src/app/main/ui/workspace/sidebar/branches.cljs:1602
+msgid "workspace.branches.banner.view-main"
+msgstr "Ver en main"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:529, src/app/main/ui/workspace/sidebar/branches.cljs:685, src/app/main/ui/workspace/sidebar/branches.cljs:1619
+msgid "workspace.branches.compare"
+msgstr "Comparar"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:99
+msgid "workspace.branches.compare.attr.blend-mode"
+msgstr "Modo de fusión"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:101
+msgid "workspace.branches.compare.attr.component"
+msgstr "Componente"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:102
+msgid "workspace.branches.compare.attr.component-library"
+msgstr "Biblioteca del componente"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:100
+msgid "workspace.branches.compare.attr.component-reference"
+msgstr "Referencia del componente"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:107
+msgid "workspace.branches.compare.attr.container"
+msgstr "Contenedor"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:97
+msgid "workspace.branches.compare.attr.corner-radius"
+msgstr "Radio de las esquinas"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:105
+msgid "workspace.branches.compare.attr.lock-proportions"
+msgstr "Bloquear proporciones"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:104
+msgid "workspace.branches.compare.attr.locked"
+msgstr "Bloqueada"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:106
+msgid "workspace.branches.compare.attr.parent"
+msgstr "Capa padre"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:98
+msgid "workspace.branches.compare.attr.text-auto-grow"
+msgstr "Crecimiento automático del texto"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:103
+msgid "workspace.branches.compare.attr.visibility"
+msgstr "Visibilidad"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:465
+#, unused
+msgid "workspace.branches.compare.branch"
+msgstr "rama"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:1064
+msgid "workspace.branches.compare.empty"
+msgstr "No hay cambios entre esta rama y main"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:1059
+msgid "workspace.branches.compare.error"
+msgstr "No se han podido cargar los cambios de esta rama"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:1126
+msgid "workspace.branches.compare.export"
+msgstr "Exportar las diferencias"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:1351
+msgid "workspace.branches.compare.footer-changes"
+msgid_plural "workspace.branches.compare.footer-changes"
+msgstr[0] "1 cambio"
+msgstr[1] "%s cambios"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:1054, src/app/main/ui/workspace/sidebar/branches.cljs:1439
+msgid "workspace.branches.compare.loading"
+msgstr "Calculando los cambios…"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:464
+#, unused
+msgid "workspace.branches.compare.main"
+msgstr "main"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:209
+msgid "workspace.branches.compare.n-items"
+msgid_plural "workspace.branches.compare.n-items"
+msgstr[0] "1 elemento"
+msgstr[1] "%s elementos"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:210
+msgid "workspace.branches.compare.n-props"
+msgid_plural "workspace.branches.compare.n-props"
+msgstr[0] "1 propiedad"
+msgstr[1] "%s propiedades"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:934
+msgid "workspace.branches.compare.no-props"
+msgstr "No hay cambios de propiedades"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:912
+msgid "workspace.branches.compare.select-hint"
+msgstr "Elige un cambio para ver sus detalles"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:140
+#, unused
+msgid "workspace.branches.compare.shape.board"
+msgstr "Tablero"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:147
+#, unused
+msgid "workspace.branches.compare.shape.bool"
+msgstr "Booleana"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:148
+#, unused
+msgid "workspace.branches.compare.shape.component"
+msgstr "Componente"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:149
+#, unused
+msgid "workspace.branches.compare.shape.component-copy"
+msgstr "Copia de componente"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:142
+#, unused
+msgid "workspace.branches.compare.shape.ellipse"
+msgstr "Elipse"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:146
+#, unused
+msgid "workspace.branches.compare.shape.group"
+msgstr "Grupo"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:145
+#, unused
+msgid "workspace.branches.compare.shape.image"
+msgstr "Imagen"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:143
+#, unused
+msgid "workspace.branches.compare.shape.path"
+msgstr "Trazado"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:141
+#, unused
+msgid "workspace.branches.compare.shape.rect"
+msgstr "Rectángulo"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:144
+#, unused
+msgid "workspace.branches.compare.shape.text"
+msgstr "Texto"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:150
+#, unused
+msgid "workspace.branches.compare.shape.variant"
+msgstr "Variante"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:876
+msgid "workspace.branches.compare.subtitle-new"
+msgstr "Nuevo: %s"
+
+#, unused
+msgid "workspace.branches.compare.type.color"
+msgstr "Color"
+
+#, unused
+msgid "workspace.branches.compare.type.component"
+msgstr "Componente"
+
+#, unused
+msgid "workspace.branches.compare.type.media"
+msgstr "Imagen"
+
+#, unused
+msgid "workspace.branches.compare.type.shape"
+msgstr "Forma"
+
+#, unused
+msgid "workspace.branches.compare.type.token"
+msgstr "Token"
+
+#, unused
+msgid "workspace.branches.compare.type.typography"
+msgstr "Tipografía"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:205
+msgid "workspace.branches.compare.value-false"
+msgstr "no"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:204
+msgid "workspace.branches.compare.value-true"
+msgstr "sí"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:1534
+msgid "workspace.branches.conflicts.apply"
+msgstr "Aplicar y fusionar"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:1444
+msgid "workspace.branches.conflicts.empty"
+msgstr "No hay conflictos que resolver"
+
+#, unused
+msgid "workspace.branches.conflicts.reason.add-add"
+msgstr "añadido en los dos lados con valores distintos"
+
+#, unused
+msgid "workspace.branches.conflicts.reason.delete-modify"
+msgstr "eliminado en la rama, editado en main"
+
+#, unused
+msgid "workspace.branches.conflicts.reason.modify-delete"
+msgstr "editado en la rama, eliminado en main"
+
+#, unused
+msgid "workspace.branches.conflicts.reason.modify-modify"
+msgstr "editado en main y en la rama desde la base"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:1134, src/app/main/ui/workspace/sidebar/branches.cljs:1626
+msgid "workspace.branches.conflicts.resolve"
+msgstr "Resolver conflictos"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:593, src/app/main/ui/workspace/sidebar/branches.cljs:824, src/app/main/ui/workspace/sidebar/branches.cljs:1933
+msgid "workspace.branches.counts.ahead"
+msgstr ""
+"Cambios que tiene esta rama y no tiene main. Cuenta cambios de elementos "
+"(formas, páginas, componentes, colores, tipografías, imágenes y tokens), no "
+"guardados."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:596, src/app/main/ui/workspace/sidebar/branches.cljs:828, src/app/main/ui/workspace/sidebar/branches.cljs:1936
+msgid "workspace.branches.counts.behind"
+msgstr ""
+"Cambios que tiene main y no tiene esta rama. Cuenta cambios de elementos "
+"(formas, páginas, componentes, colores, tipografías, imágenes y tokens), no "
+"guardados."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:606, src/app/main/ui/workspace/sidebar/branches.cljs:842, src/app/main/ui/workspace/sidebar/branches.cljs:1956, src/app/main/ui/dashboard/branches_popover.cljs:85
+msgid "workspace.branches.counts.error"
+msgstr "No se ha podido comparar esta rama con main"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:299
+msgid "workspace.branches.create.derive-from"
+msgstr "Crear desde"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:305
+msgid "workspace.branches.create.derive-from-latest"
+msgstr "la última versión"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:303
+msgid "workspace.branches.create.derive-from-main"
+msgstr "main"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:291
+msgid "workspace.branches.create.description-label"
+msgstr "Descripción (opcional)"
+
+#: src/app/main/data/workspace/branches.cljs:208
+msgid "workspace.branches.create.error"
+msgstr "No se ha podido crear la rama"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:308
+msgid "workspace.branches.create.info"
+msgstr ""
+"Tu rama es una copia completa y aislada. Nada de lo que hagas afecta a main "
+"hasta que la fusiones."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:283
+msgid "workspace.branches.create.info-library"
+msgstr ""
+"Tu rama es una copia completa. Nada de lo que hagas afecta a main hasta que "
+"la fusiones, y los archivos que usan esta biblioteca solo pueden adoptar "
+"cambios de main."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:283
+msgid "workspace.branches.create.name-label"
+msgstr "Nombre de la rama"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:285
+msgid "workspace.branches.create.name-placeholder"
+msgstr "p. ej. nuevo-checkout"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:317
+msgid "workspace.branches.create.submit"
+msgstr "Crear rama"
+
+#: src/app/main/data/workspace/branches.cljs:201
+msgid "workspace.branches.create.success"
+msgstr "Rama \"%s\" creada"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:274
+msgid "workspace.branches.create.title"
+msgstr "Crear rama"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:629
+msgid "workspace.branches.delete.message"
+msgstr "¿Eliminar la rama \"%s\"? No se puede deshacer."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:628
+msgid "workspace.branches.delete.title"
+msgstr "Eliminar rama"
+
+#: src/app/main/ui/workspace/left_header.cljs:169
+msgid "workspace.branches.header-badge-tooltip"
+msgstr "En la rama %s, creada desde main"
+
+#: src/app/main/ui/workspace/branch_switcher.cljs:98, src/app/main/ui/workspace/branch_switcher.cljs:315
+msgid "workspace.branches.header.archived"
+msgstr "Archivada, solo lectura"
+
+#: src/app/main/ui/workspace/branch_switcher.cljs:97, src/app/main/ui/workspace/branch_switcher.cljs:309
+msgid "workspace.branches.header.merged"
+msgstr "Fusionada en main, solo lectura"
+
+#: src/app/main/ui/workspace/branch_switcher.cljs:295
+msgid "workspace.branches.header-badge-tooltip-library"
+msgstr ""
+"En la rama %s, creada desde main. Quien usa la biblioteca solo puede adoptar "
+"cambios de main."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:485
+msgid "workspace.branches.info.author"
+msgstr "Creada por"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:510
+msgid "workspace.branches.info.changes"
+msgstr "Cambios"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:498
+msgid "workspace.branches.info.created"
+msgstr "Creada"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:491
+msgid "workspace.branches.info.derived-from"
+msgstr "Creada desde"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:464
+msgid "workspace.branches.info.description"
+msgstr "Descripción"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:479
+msgid "workspace.branches.info.description-empty"
+msgstr "Sin descripción"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:474
+msgid "workspace.branches.info.description-placeholder"
+msgstr "Describe para qué es esta rama"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:522
+msgid "workspace.branches.info.merged"
+msgstr "Fusionada"
+
+#, unused
+msgid "workspace.branches.info.status.archived"
+msgstr "Archivada"
+
+#, unused
+msgid "workspace.branches.info.status.merged"
+msgstr "Fusionada"
+
+#, unused
+msgid "workspace.branches.info.status.open"
+msgstr "Abierta"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:445
+msgid "workspace.branches.info.title"
+msgstr "Información de la rama"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:504
+msgid "workspace.branches.info.updated"
+msgstr "Última actualización"
+
+#: src/app/main/data/workspace/branches.cljs:158
+msgid "workspace.branches.lifecycle.deleted"
+msgstr "Rama eliminada"
+
+#: src/app/main/data/workspace/branches.cljs:126, src/app/main/data/workspace/branches.cljs:138, src/app/main/data/workspace/branches.cljs:149, src/app/main/data/workspace/branches.cljs:160
+msgid "workspace.branches.lifecycle.error"
+msgstr "No se ha podido completar la operación sobre la rama"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.link"
+msgstr "Lo que las ramas pueden y no pueden hacer todavía"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.title"
+msgstr "Límites de las ramas"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.subtitle"
+msgstr "Lo que rechaza esta versión preliminar y qué hacer en su lugar"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.size.title"
+msgstr "Tamaño"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.size.shapes"
+msgstr ""
+"No se puede crear una rama de un archivo con más de %s formas. Divide el "
+"archivo o sigue trabajando en él sin ramas."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.size.pages"
+msgstr "No se puede crear una rama de un archivo con más de %s páginas."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.size.changes"
+msgstr ""
+"Una rama que ha acumulado más de %s cambios no se puede comparar, fusionar ni "
+"actualizar desde main. Conviértela en un archivo normal para conservar su "
+"contenido."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.size.loading"
+msgstr "Cargando los límites de esta instancia…"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.scope.title"
+msgstr "Fuera del alcance de esta versión preliminar"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.scope.nested"
+msgstr "No se puede crear una rama de otra rama."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.scope.libraries"
+msgstr ""
+"Una rama abarca un solo archivo. Los cambios que una biblioteca compartida "
+"haga en otro sitio no entran en la rama."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.scope.comments"
+msgstr ""
+"Los comentarios y sus hilos se quedan en el archivo en el que se escribieron."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.scope.page-attrs"
+msgstr ""
+"Algunos ajustes de página aparecen como cambiados pero no se fusionan. La "
+"comparación los nombra para que no se pierda nada sin avisar."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.merge.title"
+msgstr "Lo que una fusión no decide por ti"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.merge.whole-entities"
+msgstr ""
+"Un conflicto se resuelve elemento a elemento: eliges la versión de esta rama "
+"o la de main."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.merge.no-partial"
+msgstr "Una fusión se lleva la rama entera. Todavía no hay fusiones parciales."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.merge.main-moved"
+msgstr ""
+"Si main cambia mientras resuelves, la comparación se vuelve a cargar y la "
+"revisas de nuevo."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.merge.base-missing"
+msgstr ""
+"Si el punto del que partió esta rama ya no está disponible, la rama aún puede "
+"convertirse en un archivo normal, pero no se puede fusionar."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.limits.exit"
+msgstr ""
+"Cualquier rama puede convertirse en un archivo normal y conservar su "
+"contenido. Nada de lo que hagas aquí depende de que las ramas sigan activadas."
+
+#: src/app/main/data/workspace/branches.cljs
+msgid "workspace.branches.limits.refuse-shapes"
+msgstr ""
+"Este archivo tiene más formas de las que admiten las ramas (%s). Divide el "
+"archivo o sigue trabajando en él sin ramas."
+
+#: src/app/main/data/workspace/branches.cljs
+msgid "workspace.branches.limits.refuse-pages"
+msgstr "Este archivo tiene más páginas de las que admiten las ramas (%s)."
+
+#: src/app/main/data/workspace/branches.cljs
+msgid "workspace.branches.limits.refuse-changes"
+msgstr ""
+"Esta rama ha acumulado más cambios de los que admiten las ramas (%s). No se "
+"puede comparar, fusionar ni actualizar desde main. Conviértela en un archivo "
+"normal para conservar su contenido, o elimínala."
+
+#: src/app/main/data/workspace/branches.cljs
+msgid "workspace.branches.limits.refuse-nested"
+msgstr "No se puede crear una rama de otra rama. Créala desde main."
+
+#: src/app/main/data/workspace/branches.cljs
+msgid "workspace.branches.limits.refuse-base-missing"
+msgstr ""
+"El punto del que partió esta rama ya no está disponible, así que no se puede "
+"comparar ni fusionar. Aún puede convertirse en un archivo normal."
+
+#: src/app/main/data/workspace/branches.cljs
+msgid "workspace.branches.limits.refuse-stale"
+msgstr ""
+"Esta rama ya no está como la mostraba el panel. Vuelve a abrir el panel de "
+"ramas para ver su estado actual."
+
+#: src/app/main/data/workspace/branches.cljs
+msgid "workspace.branches.limits.refuse-name"
+msgstr "El nombre de una rama no puede estar vacío."
+
#: src/app/main/ui/workspace/sidebar/branches.cljs:1000
msgid "workspace.branches.list.empty"
msgstr "No hay ramas aquí"
+#: src/app/main/ui/workspace/branch_switcher.cljs:207, src/app/main/ui/workspace/branch_switcher.cljs:334, src/app/main/ui/workspace/sidebar/branches.cljs:987
+msgid "workspace.branches.list.error"
+msgstr "No se han podido cargar las ramas"
+
#: src/app/main/ui/workspace/sidebar/branches.cljs:945
msgid "workspace.branches.list.tab.active"
msgstr "Activas"
@@ -6761,10 +7365,201 @@ msgstr "Mías"
msgid "workspace.branches.list.title"
msgstr "Ramas - %s"
+#: src/app/main/ui/workspace/branch_switcher.cljs:199, src/app/main/ui/workspace/sidebar/branches.cljs:982
+msgid "workspace.branches.loading"
+msgstr "Cargando ramas…"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:337, src/app/main/ui/workspace/sidebar/branches.cljs:494, src/app/main/ui/workspace/sidebar/branches.cljs:723, src/app/main/ui/workspace/sidebar/branches.cljs:760, src/app/main/ui/workspace/sidebar/branches.cljs:1011, src/app/main/ui/workspace/sidebar/branches.cljs:1031
+msgid "workspace.branches.main"
+msgstr "Main"
+
+#: src/app/main/data/workspace/branches.cljs:336
+msgid "workspace.branches.main-advanced"
+msgstr "Main tiene cambios nuevos. Puedes actualizar esta rama"
+
+msgid "workspace.branches.main-library-note"
+msgstr "La leen quienes usan la biblioteca"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:659
+msgid "workspace.branches.main-subtitle"
+msgstr "Rama principal"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:779
+msgid "workspace.branches.materialize.accept"
+msgstr "Convertirla en archivo"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:609, src/app/main/ui/workspace/sidebar/branches.cljs:895, src/app/main/ui/workspace/sidebar/branches.cljs:2026
+msgid "workspace.branches.materialize.action"
+msgstr "Convertir en un archivo normal"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:778
+msgid "workspace.branches.materialize.message"
+msgstr ""
+"La rama \"%s\" conserva su contenido. El archivo deja de ser una rama, así "
+"que ya no se podrá comparar con main ni fusionar en main."
+
+#: src/app/main/data/workspace/branches.cljs:232
+msgid "workspace.branches.materialize.success"
+msgstr "La rama ahora es un archivo normal"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:777
+msgid "workspace.branches.materialize.title"
+msgstr "Convertir esta rama en un archivo normal"
+
+#: src/app/main/ui/workspace/main_menu.cljs:736
+msgid "workspace.branches.menu"
+msgstr "Ramas"
+
+#, unused
+msgid "workspace.branches.menu.archive"
+msgstr "Archivar"
+
#: src/app/main/ui/workspace/main_menu.cljs:1152
msgid "workspace.branches.menu.create"
msgstr "Crear rama"
+#: src/app/main/ui/workspace/sidebar/branches.cljs:682
+msgid "workspace.branches.menu.info"
+msgstr "Información de la rama"
+
+#, unused
+msgid "workspace.branches.menu.restore"
+msgstr "Restaurar"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:1148, src/app/main/ui/workspace/sidebar/branches.cljs:1638
+msgid "workspace.branches.merge.action"
+msgstr "Fusionar en main"
+
+msgid "workspace.branches.merge.comment-label"
+msgstr "Comentario de la fusión"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:386
+msgid "workspace.branches.merge.confirm-accept"
+msgstr "Fusionar"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:335
+msgid "workspace.branches.merge.confirm-message"
+msgstr ""
+"¿Fusionar %s en %s? Los cambios de la rama se aplican a main y no se puede "
+"deshacer."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:356
+msgid "workspace.branches.merge.confirm-title"
+msgstr "Fusionar en main"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:378
+msgid "workspace.branches.merge.delete-info"
+msgstr ""
+"Tras la fusión, esta rama y su archivo se eliminan para liberar espacio."
+
+#: src/app/main/data/workspace/branches.cljs:451, src/app/main/data/workspace/branches.cljs:459
+msgid "workspace.branches.merge.error"
+msgstr "No se ha podido fusionar la rama"
+
+#: src/app/main/data/workspace/branches.cljs:457
+msgid "workspace.branches.merge.main-moved"
+msgstr ""
+"Main cambió mientras revisabas; la comparación se ha vuelto a cargar. "
+"Revísala y vuelve a intentarlo"
+
+#: src/app/main/data/workspace/branches.cljs:149
+msgid "workspace.branches.merge.nothing-selected"
+msgstr "Elige al menos un cambio para fusionar"
+
+#: src/app/main/data/workspace/branches.cljs:447
+msgid "workspace.branches.merge.success"
+msgstr "Rama fusionada en main"
+
+#: src/app/main/data/workspace/branches.cljs:450
+msgid "workspace.branches.merge.unsupported"
+msgstr ""
+"Esta rama cambia elementos que todavía no se pueden fusionar de forma "
+"automática (componentes, páginas o tokens)"
+
+msgid "workspace.branches.rename.title"
+msgstr "Renombrar rama"
+
+msgid "workspace.branches.restore.message"
+msgstr ""
+"¿Restaurar la rama \"%s\"? Vuelve a la lista de activas y podrás editarla de "
+"nuevo."
+
+msgid "workspace.branches.restore.title"
+msgstr "Restaurar rama"
+
+msgid "workspace.branches.reviews.design.empty"
+msgstr "Todavía no hay revisiones de diseño"
+
+msgid "workspace.branches.reviews.error"
+msgstr "No se han podido cargar las fusiones"
+
+msgid "workspace.branches.reviews.from-review"
+msgstr "De la revisión de diseño \"%s\""
+
+msgid "workspace.branches.reviews.loading"
+msgstr "Cargando revisiones…"
+
+msgid "workspace.branches.reviews.merged"
+msgstr "Fusionada"
+
+msgid "workspace.branches.reviews.merges.empty"
+msgstr "Todavía no se ha fusionado ninguna rama en main"
+
+msgid "workspace.branches.reviews.no-comment"
+msgstr "Sin comentario"
+
+msgid "workspace.branches.reviews.no-results"
+msgstr "Ninguna revisión coincide con tu búsqueda"
+
+msgid "workspace.branches.reviews.search"
+msgstr "Buscar revisión…"
+
+msgid "workspace.branches.reviews.see-less"
+msgstr "Ver menos"
+
+msgid "workspace.branches.reviews.see-more"
+msgstr "Ver más"
+
+msgid "workspace.branches.reviews.tab.design"
+msgstr "Revisiones de diseño"
+
+msgid "workspace.branches.reviews.tab.merges"
+msgstr "Revisiones de fusión"
+
+msgid "workspace.branches.reviews.title"
+msgstr "Revisiones"
+
+msgid "workspace.branches.reviews.unknown-author"
+msgstr "Usuario desconocido"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:787
+msgid "workspace.branches.search.placeholder"
+msgstr "Buscar rama…"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:805
+msgid "workspace.branches.section.current"
+msgstr "Rama actual"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:816
+msgid "workspace.branches.section.others"
+msgstr "Otras ramas"
+
+#, unused
+msgid "workspace.branches.status.added"
+msgstr "Añadido"
+
+#, unused
+msgid "workspace.branches.status.conflict"
+msgstr "Conflicto"
+
+#, unused
+msgid "workspace.branches.status.deleted"
+msgstr "Eliminado"
+
+#, unused
+msgid "workspace.branches.status.modified"
+msgstr "Modificado"
+
#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
msgid "workspace.branches.review.copies.affected"
msgid_plural "workspace.branches.review.copies.affected"
@@ -6939,6 +7734,371 @@ msgstr "Token de %s"
msgid "workspace.branches.review.copies.via"
msgstr "%s sigue el cambio a través de su copia de %s"
+#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:750
+msgid "workspace.branches.review.footer.reviewed"
+msgstr "%s de %s revisados"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:151
+msgid "workspace.branches.review.group.decisions"
+msgstr "Necesita tu decisión (%s)"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:392
+msgid "workspace.branches.review.group.library"
+msgstr "Biblioteca"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:72
+msgid "workspace.branches.review.row.choose"
+msgstr "Elegir"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:75
+msgid "workspace.branches.review.row.left-out"
+msgstr "Fuera"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:78
+msgid "workspace.branches.review.row.reviewed"
+msgstr "Revisado"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:228
+msgid "workspace.branches.review.side.branch"
+msgstr "Rama"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:221
+msgid "workspace.branches.review.side.main"
+msgstr "Main"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:321
+msgid "workspace.branches.review.summary.changed"
+msgstr "Cambiado"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:318
+msgid "workspace.branches.review.summary.deleted"
+msgstr "%s eliminado"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:381
+msgid "workspace.branches.review.unknown-page"
+msgstr "Página desconocida"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:201
+msgid "workspace.branches.review.view.side"
+msgstr "Lado a lado"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:297
+msgid "workspace.branches.resolve.tag.conflicts"
+msgid_plural "workspace.branches.resolve.tag.conflicts"
+msgstr[0] "1 conflicto"
+msgstr[1] "%s conflictos"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:299
+msgid "workspace.branches.resolve.tag.independent"
+msgid_plural "workspace.branches.resolve.tag.independent"
+msgstr[0] "1 edición independiente"
+msgstr[1] "%s ediciones independientes"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:631
+msgid "workspace.branches.review.action.merge"
+msgid_plural "workspace.branches.review.action.merge"
+msgstr[0] "Fusionar 1 cambio"
+msgstr[1] "Fusionar %s cambios"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:618
+msgid "workspace.branches.review.action.resolve"
+msgid_plural "workspace.branches.review.action.resolve"
+msgstr[0] "Resolver 1 decisión"
+msgstr[1] "Resolver %s decisiones"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:625
+msgid "workspace.branches.review.action.update"
+msgid_plural "workspace.branches.review.action.update"
+msgstr[0] "Actualizar con 1 cambio"
+msgstr[1] "Actualizar con %s cambios"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:755
+msgid "workspace.branches.review.footer.left-out"
+msgid_plural "workspace.branches.review.footer.left-out"
+msgstr[0] "1 fuera"
+msgstr[1] "%s fuera"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:88
+msgid "workspace.branches.review.row.edits"
+msgid_plural "workspace.branches.review.row.edits"
+msgstr[0] "1 edición"
+msgstr[1] "%s ediciones"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.summary.text"
+msgstr "Texto reescrito"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.summary.renamed"
+msgstr "Renombrado"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.summary.moved"
+msgstr "Movido"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.summary.resized"
+msgstr "Redimensionado"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.summary.rotated"
+msgstr "Rotado"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.summary.reparented"
+msgstr "Movido a otro contenedor"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.summary.visibility"
+msgstr "Mostrado u ocultado"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.summary.spacing"
+msgstr "Espaciado cambiado"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.summary.layout"
+msgstr "Layout cambiado"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.summary.attr"
+msgstr "%s cambiado"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.summary.more"
+msgid_plural "workspace.branches.review.summary.more"
+msgstr[0] "+1 más"
+msgstr[1] "+%s más"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.type.page"
+msgstr "Página"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.type.page-settings"
+msgstr "Ajustes de la página"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.type.page-order"
+msgstr "Orden de las páginas"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.type.guides"
+msgstr "Guías"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.type.flows"
+msgstr "Flujos"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.type.grids"
+msgstr "Rejillas"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.type.plugin-data"
+msgstr "Datos de plugins"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.type.file-options"
+msgstr "Opciones del archivo"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.type.token-set"
+msgstr "Set de tokens"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.type.token-set-order"
+msgstr "Orden de los sets de tokens"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.type.theme"
+msgstr "Tema"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.type.active-themes"
+msgstr "Temas activos"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.type.active-sets"
+msgstr "Sets de tokens activos"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.type.tokens-source"
+msgstr "Origen de los tokens"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.contents"
+msgstr "Contenido"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.board-names"
+msgstr "Tableros"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.page-goes"
+msgstr "Esta página desaparece"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.page-goes-merge"
+msgstr "La fusión elimina esta página y todo lo que contiene: %s y %s."
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.page-goes-update"
+msgstr "La actualización elimina esta página y todo lo que contiene: %s y %s."
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.type"
+msgstr "Tipo"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.size"
+msgstr "Tamaño"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.position"
+msgstr "Posición"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.where-was"
+msgstr "Dónde estaba"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.where-lands"
+msgstr "Dónde queda"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.copies-orphaned-title"
+msgstr "Hay copias que pierden su componente principal"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.unused-title"
+msgstr "No se usa en este archivo"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.deleted-unused"
+msgstr "Ninguna capa de este archivo lo usa, así que eliminarlo no rompe nada."
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.used-by"
+msgstr "Se usa en este archivo"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.boards"
+msgid_plural "workspace.branches.review.facts.boards"
+msgstr[0] "1 tablero"
+msgstr[1] "%s tableros"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.layers"
+msgid_plural "workspace.branches.review.facts.layers"
+msgstr[0] "1 capa"
+msgstr[1] "%s capas"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.copies"
+msgid_plural "workspace.branches.review.facts.copies"
+msgstr[0] "1 copia"
+msgstr[1] "%s copias"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.copies-orphaned-merge"
+msgid_plural "workspace.branches.review.facts.copies-orphaned-merge"
+msgstr[0] ""
+"1 copia de este archivo apunta a un componente que la fusión elimina."
+msgstr[1] ""
+"%s copias de este archivo apuntan a un componente que la fusión elimina."
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.copies-orphaned-update"
+msgid_plural "workspace.branches.review.facts.copies-orphaned-update"
+msgstr[0] ""
+"1 copia de este archivo apunta a un componente que la actualización elimina."
+msgstr[1] ""
+"%s copias de este archivo apuntan a un componente que la actualización "
+"elimina."
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.used-title"
+msgid_plural "workspace.branches.review.facts.used-title"
+msgstr[0] "Lo usa 1 capa"
+msgstr[1] "Lo usan %s capas"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.deleted-component-used"
+msgid_plural "workspace.branches.review.facts.deleted-component-used"
+msgstr[0] "1 copia de este archivo pierde su componente principal."
+msgstr[1] "%s copias de este archivo pierden su componente principal."
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.deleted-used"
+msgid_plural "workspace.branches.review.facts.deleted-used"
+msgstr[0] "1 capa de este archivo pierde su enlace con él."
+msgstr[1] "%s capas de este archivo pierden su enlace con él."
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.effects.title-deleted"
+msgstr "Lo que se va con él"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.effects.title-added"
+msgstr "Lo que llega con él"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.effects.interactions"
+msgid_plural "workspace.branches.review.effects.interactions"
+msgstr[0] "1 interacción del prototipo lleva aquí y también se va"
+msgstr[1] "%s interacciones del prototipo llevan aquí y también se van"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.effects.interactions-from"
+msgstr "En %s"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.effects.flows"
+msgid_plural "workspace.branches.review.effects.flows"
+msgstr[0] "1 flujo del prototipo empieza aquí y también se va"
+msgstr[1] "%s flujos del prototipo empiezan aquí y también se van"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.effects.moved"
+msgid_plural "workspace.branches.review.effects.moved"
+msgstr[0] "Se mueve 1 capa más"
+msgstr[1] "Se mueven %s capas más"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs
+msgid "workspace.branches.review.group.pages"
+msgstr "Páginas"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
+msgid "workspace.branches.review.facts.empty-page"
+msgstr "Página vacía"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs
+msgid "workspace.branches.resolve.drops.main-short"
+msgstr "%s de main:"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs
+msgid "workspace.branches.resolve.drops.branch-short"
+msgstr "%s de la rama:"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.merge.summary-in"
+msgid_plural "workspace.branches.merge.summary-in"
+msgstr[0] "1 cambio pasa a main."
+msgstr[1] "%s cambios pasan a main."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.merge.summary-out"
+msgid_plural "workspace.branches.merge.summary-out"
+msgstr[0] "1 cambio se queda fuera."
+msgstr[1] "%s cambios se quedan fuera."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.merge.left-out-lost"
+msgid_plural "workspace.branches.merge.left-out-lost"
+msgstr[0] "El cambio que dejaste fuera se pierde al eliminar la rama."
+msgstr[1] "Los %s cambios que dejaste fuera se pierden al eliminar la rama."
+
#: src/app/main/ui/workspace/branch_switcher.cljs:242
msgid "workspace.branches.switcher.all"
msgstr "Todas las ramas"
@@ -6951,10 +8111,45 @@ msgstr "Nueva rama"
msgid "workspace.branches.switcher.new-from-main"
msgstr "Las ramas se crean desde main"
+msgid "workspace.branches.switcher.reviews"
+msgstr "Revisiones"
+
#: src/app/main/ui/workspace/branch_switcher.cljs:309
msgid "workspace.branches.switcher.tooltip"
msgstr "Cambiar de rama"
+#: src/app/main/ui/workspace/sidebar/branches.cljs:688, src/app/main/ui/workspace/sidebar/branches.cljs:1141, src/app/main/ui/workspace/sidebar/branches.cljs:1632
+msgid "workspace.branches.update"
+msgstr "Actualizar desde main"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:403
+msgid "workspace.branches.update.confirm-accept"
+msgstr "Actualizar"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:402
+msgid "workspace.branches.update.confirm-message"
+msgstr ""
+"¿Actualizar \"%s\" con los últimos cambios de main? Puede sobrescribir los "
+"cambios de la rama que entren en conflicto."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:401
+msgid "workspace.branches.update.confirm-title"
+msgstr "Actualizar desde main"
+
+#: src/app/main/data/workspace/branches.cljs:362, src/app/main/data/workspace/branches.cljs:364
+msgid "workspace.branches.update.error"
+msgstr "No se ha podido actualizar la rama"
+
+#: src/app/main/data/workspace/branches.cljs:358
+msgid "workspace.branches.update.success"
+msgstr "Rama actualizada desde main"
+
+#: src/app/main/data/workspace/branches.cljs:361
+msgid "workspace.branches.update.unsupported"
+msgstr ""
+"main cambió elementos que todavía no se pueden traer de forma automática "
+"(componentes, páginas o estructura de tokens)"
+
#: src/app/main/data/workspace/clipboard.cljs:1242
msgid "workspace.clipboard.copying"
msgstr "Copiando imagen…"
@@ -9101,6 +10296,26 @@ msgstr "¡LA EXTENSIÓN '%s' HA SIDO INSTALADA PARA TU USUARIO!"
msgid "workspace.plugins.try-out.try"
msgstr "PROBAR PLUGIN"
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:426, src/app/main/ui/workspace/sidebar/pull_requests.cljs:505, src/app/main/ui/workspace/sidebar/pull_requests.cljs:564
+msgid "workspace.pull-requests.actions.close"
+msgstr "Cancelar revisión de diseño"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:440, src/app/main/ui/workspace/sidebar/pull_requests.cljs:561, src/app/main/ui/workspace/sidebar/pull_requests.cljs:754
+msgid "workspace.pull-requests.actions.merge"
+msgstr "Fusionar en main"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:435
+msgid "workspace.pull-requests.actions.open-review"
+msgstr "Abrir revisión"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:430, src/app/main/ui/workspace/sidebar/pull_requests.cljs:567
+msgid "workspace.pull-requests.actions.reopen"
+msgstr "Reabrir revisión de diseño"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:359, src/app/main/ui/workspace/sidebar/pull_requests.cljs:537, src/app/main/ui/workspace/sidebar/pull_requests.cljs:722
+msgid "workspace.pull-requests.badge.conflicts"
+msgstr "%s conflictos"
+
#: src/app/main/ui/workspace/viewport/top_bar.cljs:46
#, markdown
msgid "workspace.save-failure.retrying"
@@ -10474,10 +11689,295 @@ msgstr "Si quieres aumentar este límite, contáctanos en [support@penpot.app](%
msgid "workspace.versions.warning.text"
msgstr "Los autoguardados duran %s días."
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:361
+msgid "workspace.branches.resolve.change-choice"
+msgstr "Cambiar la elección"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:241
+msgid "workspace.branches.resolve.copy-dropped"
+msgstr "Copiar el texto descartado"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:99
+msgid "workspace.branches.resolve.decided"
+msgstr "Decidido"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:259
+msgid "workspace.branches.resolve.deletes-it"
+msgstr "Esta versión lo elimina"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:358
+msgid "workspace.branches.resolve.drops.none"
+msgstr "No se descarta nada: se conservan todas las ediciones."
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:232
+msgid "workspace.branches.resolve.drops-paragraphs"
+msgstr "Descarta %s del otro lado"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:349
+msgid "workspace.branches.resolve.drops.title"
+msgstr "Lo que descarta esta elección"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:305
+msgid "workspace.branches.resolve.intro-attrs"
+msgstr ""
+"Main y esta rama editaron esto. Solo las propiedades marcadas como Conflicto "
+"necesitan una elección; las demás cambiaron en un solo lado, así que ya están "
+"rellenas."
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:304
+msgid "workspace.branches.resolve.intro-text"
+msgstr ""
+"Main y esta rama editaron este texto. Penpot conserva un texto entero, así "
+"que si cada lado cambió un párrafo distinto, cualquier elección descarta una "
+"de esas ediciones."
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:306
+msgid "workspace.branches.resolve.intro-whole"
+msgstr ""
+"Esto no se puede dividir por propiedades. Quédate con una de las dos "
+"versiones."
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:503
+msgid "workspace.branches.resolve.keep-all-branch"
+msgstr "Mantener todo de la rama"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:501
+msgid "workspace.branches.resolve.keep-all-main"
+msgstr "Mantener todo de main"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:254
+msgid "workspace.branches.resolve.keep-branch-version"
+msgstr "Mantener tu versión"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:253
+msgid "workspace.branches.resolve.keep-main-version"
+msgstr "Mantener la versión de main"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:239
+msgid "workspace.branches.resolve.keep-safe"
+msgstr "Guarda a salvo la edición descartada:"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:79
+msgid "workspace.branches.resolve.row.both-changed"
+msgstr "%s - cambiado en los dos lados"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:74
+msgid "workspace.branches.resolve.row.drops"
+msgstr "Descarta %s del otro lado"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:76
+msgid "workspace.branches.resolve.row.kept-both"
+msgstr "Se conservan las ediciones de los dos lados"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:73
+msgid "workspace.branches.resolve.row.kept-branch"
+msgstr "Se mantiene tu versión"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:72
+msgid "workspace.branches.resolve.row.kept-main"
+msgstr "Se mantiene la versión de main"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:102
+msgid "workspace.branches.resolve.row.loses-work"
+msgstr "Se pierde trabajo"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:156
+msgid "workspace.branches.resolve.tag.conflict"
+msgstr "Conflicto"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs:154
+msgid "workspace.branches.resolve.tag.your-choice"
+msgstr "Tu elección"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:141
+msgid "workspace.branches.review.attr.fill"
+msgstr "Relleno"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:143
+msgid "workspace.branches.review.attr.gap"
+msgstr "Separación entre elementos"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:144
+msgid "workspace.branches.review.attr.padding"
+msgstr "Padding"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:142
+msgid "workspace.branches.review.attr.stroke"
+msgstr "Borde"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:140
+msgid "workspace.branches.review.attr.text"
+msgstr "Texto"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/common.cljs:259
+msgid "workspace.branches.review.category.layout"
+msgstr "Layout"
+
+#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs:342
+msgid "workspace.branches.review.decision.body"
+msgstr ""
+"Main y esta rama lo editaron. Elige qué versión mantener antes de fusionar."
+
#: src/app/main/ui/workspace/left_header.cljs:177
msgid "workspace.pull-requests.header-label"
msgstr "Revisión:"
+#: src/app/main/ui/workspace/left_header.cljs:54
+msgid "workspace.pull-requests.header-title"
+msgstr "Revisión: %s"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:385, src/app/main/ui/workspace/sidebar/pull_requests.cljs:542
+msgid "workspace.pull-requests.info.approvals"
+msgstr "Aprobaciones"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:369
+msgid "workspace.pull-requests.info.author"
+msgstr "Autor"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:375
+msgid "workspace.pull-requests.info.created-at"
+msgstr "Creada"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:364
+msgid "workspace.pull-requests.info.description"
+msgstr "Descripción"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:392
+msgid "workspace.pull-requests.info.reviewers"
+msgstr "Revisores"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:380
+msgid "workspace.pull-requests.info.updated-at"
+msgstr "Revisión actualizada"
+
+#: src/app/main/data/workspace/pull_requests.cljs:252
+msgid "workspace.pull-requests.lifecycle.branch-gone"
+msgstr "La rama de la revisión de diseño ya no está abierta"
+
+#: src/app/main/data/workspace/pull_requests.cljs:230
+msgid "workspace.pull-requests.lifecycle.closed"
+msgstr "Revisión de diseño cerrada"
+
+#: src/app/main/data/workspace/pull_requests.cljs:160, src/app/main/data/workspace/pull_requests.cljs:187, src/app/main/data/workspace/pull_requests.cljs:213, src/app/main/data/workspace/pull_requests.cljs:237, src/app/main/data/workspace/pull_requests.cljs:257
+msgid "workspace.pull-requests.lifecycle.error"
+msgstr "Se ha producido un error al actualizar la revisión de diseño"
+
+#: src/app/main/data/workspace/pull_requests.cljs:246
+msgid "workspace.pull-requests.lifecycle.reopened"
+msgstr "Revisión de diseño reabierta"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:558
+msgid "workspace.pull-requests.menu.publish"
+msgstr "Publicar los últimos cambios"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:691
+msgid "workspace.pull-requests.menu.request-review"
+msgstr "Pedir revisión"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs:700
+msgid "workspace.pull-requests.menu.review-details"
+msgstr "Detalles de la revisión"
+
+#: src/app/main/data/workspace/pull_requests.cljs:396
+msgid "workspace.pull-requests.preview.unavailable"
+msgstr ""
+"El entorno de revisión no está disponible (puede que la revisión de diseño "
+"esté cerrada)"
+
+#: src/app/main/data/workspace/pull_requests.cljs:182
+msgid "workspace.pull-requests.publish.success"
+msgstr "Quienes revisan ya ven los últimos cambios de la rama"
+
+#: src/app/main/data/workspace/pull_requests.cljs:183
+msgid "workspace.pull-requests.publish.up-to-date"
+msgstr "La revisión ya está al día con la rama"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:412
+msgid "workspace.pull-requests.review-state.approved"
+msgstr "Aprobada"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:415
+msgid "workspace.pull-requests.review-state.changes-requested"
+msgstr "Pidió cambios"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:418
+msgid "workspace.pull-requests.review-state.pending"
+msgstr "Pendiente"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:409
+msgid "workspace.pull-requests.review-state.stale"
+msgstr "Revisó una versión anterior"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:258
+msgid "workspace.pull-requests.review.approve"
+msgstr "Aprobar"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:260
+msgid "workspace.pull-requests.review.approve-hint"
+msgstr "Los cambios te parecen bien"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:275
+msgid "workspace.pull-requests.review.comment-label"
+msgstr "Comentario (opcional)"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:278
+msgid "workspace.pull-requests.review.comment-placeholder"
+msgstr "Comparte tu opinión con quien hizo los cambios"
+
+#: src/app/main/data/workspace/pull_requests.cljs:212
+msgid "workspace.pull-requests.review.not-a-reviewer"
+msgstr "Solo quienes tienen asignada la revisión pueden enviarla"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:269
+msgid "workspace.pull-requests.review.request-changes"
+msgstr "Pedir cambios"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:271
+msgid "workspace.pull-requests.review.request-changes-hint"
+msgstr "Hay algo que corregir antes de fusionar"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:287
+msgid "workspace.pull-requests.review.submit"
+msgstr "Enviar revisión"
+
+#: src/app/main/data/workspace/pull_requests.cljs:206
+msgid "workspace.pull-requests.review.submitted"
+msgstr "Revisión enviada"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:242
+msgid "workspace.pull-requests.review.title"
+msgstr "Enviar revisión"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:100
+#, unused
+msgid "workspace.pull-requests.state.approved"
+msgstr "Aprobada"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:100
+#, unused
+msgid "workspace.pull-requests.state.changes-requested"
+msgstr "Con cambios pedidos"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:100
+#, unused
+msgid "workspace.pull-requests.state.closed"
+msgstr "Cerrada"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:100
+#, unused
+msgid "workspace.pull-requests.state.in-review"
+msgstr "En revisión"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:100
+#, unused
+msgid "workspace.pull-requests.state.merged"
+msgstr "Fusionada"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:100
+#, unused
+msgid "workspace.pull-requests.state.open"
+msgstr "Abierta"
+
#: src/app/main/ui/workspace/sidebar/pull_requests.cljs
msgid "workspace.pull-requests.badge.outdated"
msgstr "Cambios sin publicar"
@@ -10491,6 +11991,10 @@ msgstr ""
msgid "workspace.pull-requests.banner.cancel"
msgstr "Cancelar revisión"
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:759
+msgid "workspace.pull-requests.banner.exit"
+msgstr "Salir de la revisión"
+
#: src/app/main/ui/workspace/sidebar/pull_requests.cljs
msgid "workspace.pull-requests.banner.publish"
msgstr "Publicar últimos cambios"
@@ -10501,6 +12005,79 @@ msgstr ""
"Los reviewers verán los últimos cambios de la rama. Las aprobaciones dadas "
"hasta ahora se tendrán que renovar."
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:710
+msgid "workspace.pull-requests.banner.reviewing"
+msgstr "En revisión"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:504
+msgid "workspace.pull-requests.close.message"
+msgstr ""
+"Se cancelará la revisión de \"%s\". La rama no se elimina: vuelve a ser una "
+"rama normal."
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:503
+msgid "workspace.pull-requests.close.title"
+msgstr "Cancelar revisión de diseño"
+
+#: src/app/main/data/workspace/pull_requests.cljs:142, src/app/main/data/workspace/pull_requests.cljs:255
+msgid "workspace.pull-requests.create.already-exists"
+msgstr "Esta rama ya tiene una revisión de diseño abierta"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:167
+msgid "workspace.pull-requests.create.description-label"
+msgstr "Descripción"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:170
+msgid "workspace.pull-requests.create.description-placeholder"
+msgstr "¿Qué ha cambiado y qué hay que revisar o validar?"
+
+#: src/app/main/data/workspace/pull_requests.cljs:143
+msgid "workspace.pull-requests.create.error"
+msgstr "Se ha producido un error al crear la revisión de diseño"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:193
+msgid "workspace.pull-requests.create.info"
+msgstr ""
+"Quienes revisan abren la propia rama, así que cualquier edición suya cambia "
+"la rama, y el modo Ver reproduce la rama tal como está ahora. Puedes seguir "
+"trabajando en la rama y publicar cambios más recientes cuando quieras."
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:159
+msgid "workspace.pull-requests.create.name-label"
+msgstr "Título"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:161
+msgid "workspace.pull-requests.create.name-placeholder"
+msgstr "¿De qué trata esta revisión?"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:179
+msgid "workspace.pull-requests.create.no-members"
+msgstr "No hay más miembros del equipo a quienes pedir una revisión"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:176
+msgid "workspace.pull-requests.create.reviewers-label"
+msgstr "Revisores"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:202
+msgid "workspace.pull-requests.create.submit"
+msgstr "Crear revisión de diseño"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:152
+msgid "workspace.pull-requests.create.subtitle"
+msgstr "Pide una revisión de los cambios de \"%s\""
+
+#: src/app/main/data/workspace/pull_requests.cljs:137
+msgid "workspace.pull-requests.create.success"
+msgstr "Revisión de diseño \"%s\" creada"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:150
+msgid "workspace.pull-requests.create.title"
+msgstr "Crear revisión de diseño"
+
+#: src/app/main/ui/workspace/left_header.cljs:163
+msgid "workspace.pull-requests.header-badge-tooltip"
+msgstr "Revisando la revisión de diseño: %s"
+
#: src/app/main/ui/workspace/sidebar/branches.cljs
msgid "workspace.branches.merge.confirm-anyway"
msgstr "Fusionar igualmente"
@@ -11026,10 +12603,6 @@ msgstr "Verificada"
msgid "workspace.tasks.status.wont-do"
msgstr "No se hará"
-#: src/app/main/ui/workspace/review/tasks.cljs
-msgid "workspace.tasks.task"
-msgstr "Tarea"
-
#: src/app/main/ui/workspace/review/tasks.cljs
msgid "workspace.tasks.title"
msgstr "Título de la tarea"
@@ -11169,3 +12742,163 @@ msgid "workspace.sidebar.layers.comments"
msgid_plural "workspace.sidebar.layers.comments"
msgstr[0] "1 comentario abierto"
msgstr[1] "%s comentarios abiertos"
+
+msgid "workspace.branches.open"
+msgstr "Abrir rama"
+
+msgid "workspace.branches.resolve.group.decided"
+msgstr "Decididos (%s)"
+
+msgid "workspace.branches.resolve.group.pending"
+msgstr "Necesitan una decisión (%s)"
+
+msgid "workspace.branches.resolve.paragraphs"
+msgid_plural "workspace.branches.resolve.paragraphs"
+msgstr[0] "1 párrafo"
+msgstr[1] "%s párrafos"
+
+msgid "workspace.branches.resolve.tag.from"
+msgstr "De %s"
+
+msgid "workspace.compare.action.edit-layer"
+msgstr "Editar capa"
+
+msgid "workspace.compare.action.include-merge"
+msgstr "Incluir en la fusión"
+
+msgid "workspace.compare.action.include-update"
+msgstr "Incluir en la actualización"
+
+msgid "workspace.compare.action.leave-out-merge"
+msgstr "Dejar fuera de la fusión"
+
+msgid "workspace.compare.action.leave-out-update"
+msgstr "Dejar fuera de la actualización"
+
+msgid "workspace.compare.bar.all-decided"
+msgstr "Todos los conflictos decididos"
+
+msgid "workspace.compare.bar.apply-update"
+msgstr "Aplicar y actualizar"
+
+msgid "workspace.compare.bar.back"
+msgstr "Volver a comparar"
+
+msgid "workspace.compare.bar.comparing"
+msgstr "Comparando"
+
+msgid "workspace.compare.bar.comparing-main"
+msgstr "Comparando con main"
+
+msgid "workspace.compare.bar.decided"
+msgstr "%s de %s decididos"
+
+msgid "workspace.compare.bar.exit"
+msgstr "Salir de comparar"
+
+msgid "workspace.compare.changes"
+msgstr "Cambios"
+
+msgid "workspace.compare.decisions"
+msgstr "Decisiones (%s)"
+
+msgid "workspace.compare.direction.branch"
+msgstr "En esta rama"
+
+msgid "workspace.compare.direction.main"
+msgstr "En main"
+
+msgid "workspace.compare.empty-main"
+msgstr "main no tiene cambios que le falten a esta rama"
+
+msgid "workspace.compare.filter.layers"
+msgstr "Capas"
+
+#: src/app/main/ui/workspace/compare/detail.cljs
+msgid "workspace.compare.layer.comments"
+msgstr "Comentarios en esta capa (%s)"
+
+#: src/app/main/ui/workspace/compare/detail.cljs
+msgid "workspace.compare.layer.tasks"
+msgstr "Tareas en esta capa (%s)"
+
+msgid "workspace.compare.navigator.changes"
+msgstr "Cambios de la comparación"
+
+msgid "workspace.compare.navigator.decisions"
+msgstr "Conflictos por resolver"
+
+msgid "workspace.compare.navigator.in-main"
+msgstr "%s en main"
+
+msgid "workspace.compare.navigator.mark-reviewed"
+msgstr "Marcar como revisado"
+
+msgid "workspace.compare.navigator.next-pending"
+msgstr "Siguiente pendiente"
+
+msgid "workspace.compare.popover.applies-merge"
+msgstr "Nada cambia hasta que apliques y fusiones."
+
+msgid "workspace.compare.popover.applies-update"
+msgstr "Nada cambia hasta que apliques y actualices."
+
+msgid "workspace.compare.popover.attr"
+msgstr "Main y la rama lo cambiaron. Elige cuál conservar."
+
+msgid "workspace.compare.popover.text"
+msgstr "Main y la rama cambiaron este texto. Elige cuál conservar."
+
+msgid "workspace.compare.tab-count"
+msgstr "%s (%s)"
+
+msgid "workspace.compare.toolbar.label"
+msgstr "Herramientas de comparación"
+
+msgid "workspace.compare.view.side.aligned"
+msgstr "Alineado al cambio"
+
+msgid "workspace.compare.view.side.linked"
+msgstr "Vinculado"
+
+msgid "workspace.compare.view.hidden"
+msgstr "Cambios ocultos"
+
+msgid "workspace.compare.view.hide"
+msgstr "Ocultar cambios"
+
+msgid "workspace.compare.view.highlight"
+msgstr "Resaltar"
+
+msgid "workspace.compare.view.label"
+msgstr "Cómo muestra el lienzo los cambios"
+
+msgid "workspace.compare.view.show"
+msgstr "Mostrar cambios"
+
+msgid "workspace.compare.canvas.main"
+msgstr "main tal como está ahora"
+
+msgid "workspace.compare.canvas.result"
+msgstr "Vista previa - el resultado de tus elecciones"
+
+msgid "workspace.compare.canvas.update"
+msgstr "Vista previa - %s tras la actualización"
+
+msgid "workspace.compare.navigator.peek"
+msgstr "%s - mantén M para ver main"
+
+msgid "workspace.compare.popover.hover"
+msgstr "Al pasar por una opción se previsualiza en el lienzo."
+
+msgid "workspace.compare.side.aligned"
+msgstr "Main está desplazado %s, %s para alinear el cambio"
+
+msgid "workspace.compare.side.aligned-none"
+msgstr "No hay nada que alinear en este cambio"
+
+msgid "workspace.compare.side.linked"
+msgstr "El zoom y el desplazamiento van vinculados"
+
+msgid "workspace.compare.side.not-in-main"
+msgstr "No está en main"
diff --git a/render-wasm/src/render/debug.rs b/render-wasm/src/render/debug.rs
index d661fd2bd1..50c16ce46c 100644
--- a/render-wasm/src/render/debug.rs
+++ b/render-wasm/src/render/debug.rs
@@ -53,7 +53,9 @@ pub fn render_wasm_label(render_state: &mut RenderState) {
}
let canvas = render_state.surfaces.canvas(SurfaceId::Target);
- let canvas_width = canvas.base_layer_size().width as f32;
+ let canvas_size = canvas.base_layer_size();
+ let canvas_width = canvas_size.width as f32;
+ let canvas_height = canvas_size.height as f32;
let mut paint = skia::Paint::default();
paint.set_color(skia::Color::GRAY);
@@ -64,7 +66,12 @@ pub fn render_wasm_label(render_state: &mut RenderState) {
};
let dpr = render_state.options.dpr;
let (scalar, _) = get_resources().fonts.debug_font().measure_str(str, None);
- let mut p = skia::Point::new(canvas_width - (20.0 * dpr) - scalar, 50.0 * dpr);
+ // at the bottom right corner of the canvas: the top ones hold labels
+ // of the workspace
+ let mut p = skia::Point::new(
+ canvas_width - (20.0 * dpr) - scalar,
+ canvas_height - (20.0 * dpr),
+ );
let debug_font = get_resources().fonts.debug_font();
canvas.draw_str(str, p, debug_font, &paint);
@@ -74,7 +81,7 @@ pub fn render_wasm_label(render_state: &mut RenderState) {
let (scalar, _) = get_resources().fonts.debug_font().measure_str(str, None);
p.x = canvas_width - (20.0 * dpr) - scalar;
- p.y += 15.0 * dpr;
+ p.y -= 15.0 * dpr;
canvas.draw_str(str, p, debug_font, &paint);
}
}