+
+ {% include "app/email/includes/footer.html" %}
+
+
+
+
+
diff --git a/backend/resources/app/email/tasks-moved/en.subj b/backend/resources/app/email/tasks-moved/en.subj
new file mode 100644
index 0000000000..1c1f080367
--- /dev/null
+++ b/backend/resources/app/email/tasks-moved/en.subj
@@ -0,0 +1 @@
+Your tasks moved to main
diff --git a/backend/resources/app/email/tasks-moved/en.txt b/backend/resources/app/email/tasks-moved/en.txt
new file mode 100644
index 0000000000..bacdadd883
--- /dev/null
+++ b/backend/resources/app/email/tasks-moved/en.txt
@@ -0,0 +1,9 @@
+Hello {{name|abbreviate:25}}!
+
+{{ source-user }} merged the branch "{{ branch-name }}" into "{{ file-name }}". Your open tasks moved to main as they were:
+
+{{ task-titles }}
+
+{{ file-url }}
+
+The Penpot team.
diff --git a/backend/src/app/email.clj b/backend/src/app/email.clj
index 3cc78ec02b..c19bda23be 100644
--- a/backend/src/app/email.clj
+++ b/backend/src/app/email.clj
@@ -577,6 +577,35 @@
:id ::review-request
:schema schema:review-request))
+(def ^:private schema:task-assigned
+ [:map
+ [:name ::sm/text]
+ [:source-user ::sm/text]
+ [:task-title ::sm/text]
+ [:task-url ::sm/text]])
+
+(def task-assigned
+ "Email sent to the person a task is assigned to."
+ (template-factory
+ :id ::task-assigned
+ :schema schema:task-assigned))
+
+(def ^:private schema:tasks-moved
+ [:map
+ [:name ::sm/text]
+ [:source-user ::sm/text]
+ [:branch-name ::sm/text]
+ [:file-name ::sm/text]
+ [:task-titles ::sm/text]
+ [:file-url ::sm/text]])
+
+(def tasks-moved
+ "Email sent to the assignees of the open tasks of a branch when the
+ merge of the branch moves them into main."
+ (template-factory
+ :id ::tasks-moved
+ :schema schema:tasks-moved))
+
(def ^:private schema:comment-mention
[:map
[:name ::sm/text]
@@ -656,7 +685,9 @@
"comment-mention" (template-entry comment-mention schema:comment-mention)
"comment-thread" (template-entry comment-thread schema:comment-thread)
"comment-notification" (template-entry comment-notification schema:comment-notification)
- "review-request" (template-entry review-request schema:review-request)})
+ "review-request" (template-entry review-request schema:review-request)
+ "task-assigned" (template-entry task-assigned schema:task-assigned)
+ "tasks-moved" (template-entry tasks-moved schema:tasks-moved)})
(defn render-template
"Render the templated email `template-id` from its JSON-decoded data,
diff --git a/backend/src/app/migrations.clj b/backend/src/app/migrations.clj
index dfe36c2503..0f68a807f9 100644
--- a/backend/src/app/migrations.clj
+++ b/backend/src/app/migrations.clj
@@ -566,7 +566,25 @@
:fn (mg/resource "app/migrations/sql/0807-del-file-branch-profile-rels.sql")}
{:name "0808-mod-file-branch-project"
- :fn (mg/resource "app/migrations/sql/0808-mod-file-branch-project.sql")}])
+ :fn (mg/resource "app/migrations/sql/0808-mod-file-branch-project.sql")}
+
+ {:name "0809-mod-comment-thread-add-review-fields"
+ :fn (mg/resource "app/migrations/sql/0809-mod-comment-thread-add-review-fields.sql")}
+
+ {:name "0810-add-file-task-tables"
+ :fn (mg/resource "app/migrations/sql/0810-add-file-task-tables.sql")}
+
+ {:name "0811-add-file-pull-request-activity-table"
+ :fn (mg/resource "app/migrations/sql/0811-add-file-pull-request-activity-table.sql")}
+
+ {:name "0812-mod-file-task-add-position"
+ :fn (mg/resource "app/migrations/sql/0812-mod-file-task-add-position.sql")}
+
+ {:name "0813-mod-file-task-add-comment"
+ :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")}])
(defn apply-migrations!
[pool name migrations]
diff --git a/backend/src/app/migrations/sql/0809-mod-comment-thread-add-review-fields.sql b/backend/src/app/migrations/sql/0809-mod-comment-thread-add-review-fields.sql
new file mode 100644
index 0000000000..554409f812
--- /dev/null
+++ b/backend/src/app/migrations/sql/0809-mod-comment-thread-add-review-fields.sql
@@ -0,0 +1,27 @@
+-- A comment thread can belong to a design review (a pull request) and can
+-- point at more than a spot of the canvas.
+--
+-- `pull_request_id` names the design review the thread was written in.
+-- It carries no foreign key: the merge of a branch moves the threads of
+-- its tasks into main (`files_task.clj::move-branch-tasks!`) and the
+-- objects GC later deletes the branch file, which takes the pull request
+-- row with it. The thread keeps saying it came from a review.
+--
+-- `anchor_type` says what the thread points at:
+-- * `canvas`: a spot of a board, as every thread did before (`position`
+-- and `frame_id`);
+-- * `layer`: a layer, named by `shape_id`; `position` is where it was,
+-- the fallback when the layer goes away;
+-- * `area`: a rectangle of a board, `area` holds its `x`, `y`, `width`
+-- and `height` in canvas coordinates.
+
+ALTER TABLE comment_thread
+ ADD COLUMN pull_request_id uuid NULL,
+ ADD COLUMN anchor_type text NOT NULL DEFAULT 'canvas'
+ CHECK (anchor_type IN ('canvas', 'layer', 'area')),
+ ADD COLUMN shape_id uuid NULL,
+ ADD COLUMN area jsonb NULL;
+
+CREATE INDEX comment_thread__pull_request_id__idx
+ ON comment_thread(pull_request_id)
+ WHERE pull_request_id IS NOT NULL;
diff --git a/backend/src/app/migrations/sql/0810-add-file-task-tables.sql b/backend/src/app/migrations/sql/0810-add-file-task-tables.sql
new file mode 100644
index 0000000000..ff4be42c8e
--- /dev/null
+++ b/backend/src/app/migrations/sql/0810-add-file-task-tables.sql
@@ -0,0 +1,104 @@
+-- Tasks: a piece of work on a file, assigned to someone and tied to a
+-- layer. A task is born open, its assignee marks it done, someone
+-- verifies it (or reopens it), and it may be dropped as "won't do":
+--
+-- open -> done -> verified
+-- done | verified | wont-do -> reopened -> done
+-- open | reopened -> wont-do
+--
+-- Anyone who can read the file may move a task between states; every
+-- move is recorded in `file_task_event` with who made it.
+--
+-- A task may come from a comment thread (`thread_id`, the thread stays
+-- attached to it) and from a design review (`pull_request_id`). Neither
+-- column has a foreign key to the pull request: the merge of a branch
+-- moves its tasks into main and the objects GC later deletes the branch
+-- file and its pull request rows. The task keeps the names it shows
+-- (`review_title`, `branch_name`) and the merge that moved it
+-- (`merge_id`, a `file_branch_merge` row), so the tasks of a merged
+-- branch remain as its history.
+--
+-- `shape_id` is the layer the task points at, inside `frame_id` on
+-- `page_id`. When that layer is deleted the task moves to the board
+-- that held it and keeps the name of the lost layer in
+-- `lost_shape_name`, until it is linked to another layer.
+
+CREATE TABLE file_task (
+ id uuid PRIMARY KEY,
+
+ file_id uuid NOT NULL REFERENCES file(id) ON DELETE CASCADE DEFERRABLE,
+
+ pull_request_id uuid NULL,
+ review_title text NULL,
+ thread_id uuid NULL REFERENCES comment_thread(id) ON DELETE SET NULL DEFERRABLE,
+
+ title text NOT NULL,
+ status text NOT NULL DEFAULT 'open'
+ CHECK (status IN ('open', 'done', 'reopened', 'verified', 'wont-do')),
+
+ assignee_id uuid NULL REFERENCES profile(id) ON DELETE SET NULL DEFERRABLE,
+ created_by uuid NULL REFERENCES profile(id) ON DELETE SET NULL DEFERRABLE,
+
+ page_id uuid NOT NULL,
+ frame_id uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'::uuid,
+ shape_id uuid NULL,
+ lost_shape_name text NULL,
+
+ merge_id uuid NULL,
+ branch_name text NULL,
+
+ status_changed_at timestamptz NULL,
+ status_changed_by uuid NULL REFERENCES profile(id) ON DELETE SET NULL DEFERRABLE,
+
+ created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
+ updated_at timestamptz NOT NULL DEFAULT clock_timestamp(),
+ deleted_at timestamptz NULL
+);
+
+CREATE INDEX file_task__file_id__idx
+ ON file_task(file_id) WHERE deleted_at IS NULL;
+
+CREATE INDEX file_task__pull_request_id__idx
+ ON file_task(pull_request_id) WHERE pull_request_id IS NOT NULL;
+
+CREATE INDEX file_task__thread_id__idx
+ ON file_task(thread_id) WHERE thread_id IS NOT NULL;
+
+CREATE INDEX file_task__assignee_id__idx
+ ON file_task(assignee_id);
+
+CREATE INDEX file_task__created_by__idx
+ ON file_task(created_by);
+
+CREATE INDEX file_task__status_changed_by__idx
+ ON file_task(status_changed_by);
+
+CREATE INDEX file_task__merge_id__idx
+ ON file_task(merge_id) WHERE merge_id IS NOT NULL;
+
+-- What happened to a task, in order: the lines a thread shows between its
+-- comments ("Ana made this a task for you", "Marc marked it as done").
+--
+-- created {}
+-- assigned {:assignee-id}
+-- status {:from :to}
+-- renamed {:title}
+-- relinked {:shape-id :shape-name}
+-- layer-deleted {:shape-id :shape-name :frame-id :frame-name :objects}
+-- layer-restored {:shape-id :shape-name}
+-- moved-to-main {:merge-id :branch-name}
+
+CREATE TABLE file_task_event (
+ id uuid PRIMARY KEY,
+ task_id uuid NOT NULL REFERENCES file_task(id) ON DELETE CASCADE DEFERRABLE,
+ profile_id uuid NULL REFERENCES profile(id) ON DELETE SET NULL DEFERRABLE,
+ type text NOT NULL,
+ payload jsonb NULL,
+ created_at timestamptz NOT NULL DEFAULT clock_timestamp()
+);
+
+CREATE INDEX file_task_event__task_id__idx
+ ON file_task_event(task_id, created_at);
+
+CREATE INDEX file_task_event__profile_id__idx
+ ON file_task_event(profile_id);
diff --git a/backend/src/app/migrations/sql/0811-add-file-pull-request-activity-table.sql b/backend/src/app/migrations/sql/0811-add-file-pull-request-activity-table.sql
new file mode 100644
index 0000000000..eb78b62b79
--- /dev/null
+++ b/backend/src/app/migrations/sql/0811-add-file-pull-request-activity-table.sql
@@ -0,0 +1,39 @@
+-- The activity of a design review: one row per save of its branch while
+-- the review is open, with who saved and what the save did to each
+-- layer it touched.
+--
+-- The branch op log (`file_branch_change`) cannot answer that: it keeps
+-- no author and an update from main squashes it into one row. This table
+-- is written by the branch save alone (`files_update.clj`), so the work
+-- an update brings in from main never counts as anybody's change.
+--
+-- `entries` is a blob-encoded vector, one map per touched layer
+-- (`app.common.files.review-activity/entries`): its id, page, board,
+-- name and type, the kind of change (`:added`, `:modified`,
+-- `:deleted`) and, for a modified layer, the value before and after of
+-- each property a person reads.
+
+CREATE TABLE file_pull_request_activity (
+ id uuid PRIMARY KEY,
+
+ pull_request_id uuid NOT NULL REFERENCES file_pull_request(id) ON DELETE CASCADE DEFERRABLE,
+ profile_id uuid NULL REFERENCES profile(id) ON DELETE SET NULL DEFERRABLE,
+
+ -- the branch file's revn the save produced
+ revn bigint NOT NULL,
+ entries bytea NOT NULL,
+
+ created_at timestamptz NOT NULL DEFAULT clock_timestamp()
+);
+
+CREATE INDEX file_pull_request_activity__pull_request_id__idx
+ ON file_pull_request_activity(pull_request_id, created_at);
+
+CREATE INDEX file_pull_request_activity__profile_id__idx
+ ON file_pull_request_activity(profile_id);
+
+-- A branch save asks whether its branch is under review: find the open
+-- pull request by its source (the branch file).
+CREATE INDEX file_pull_request__source_file_id__open__idx
+ ON file_pull_request(source_file_id)
+ WHERE status = 'open' AND deleted_at IS NULL;
diff --git a/backend/src/app/migrations/sql/0812-mod-file-task-add-position.sql b/backend/src/app/migrations/sql/0812-mod-file-task-add-position.sql
new file mode 100644
index 0000000000..3a263d2929
--- /dev/null
+++ b/backend/src/app/migrations/sql/0812-mod-file-task-add-position.sql
@@ -0,0 +1,7 @@
+-- Where the mark of a task goes when it points at no layer: a task on the
+-- canvas itself, or one made from a comment thread on the canvas. A task
+-- on a layer keeps the spot too, as the fallback when the layer and its
+-- board are gone.
+
+ALTER TABLE file_task
+ ADD COLUMN position point NULL;
diff --git a/backend/src/app/migrations/sql/0813-mod-file-task-add-comment.sql b/backend/src/app/migrations/sql/0813-mod-file-task-add-comment.sql
new file mode 100644
index 0000000000..66b1e60802
--- /dev/null
+++ b/backend/src/app/migrations/sql/0813-mod-file-task-add-comment.sql
@@ -0,0 +1,20 @@
+-- The message of a comment thread a task comes from: each message may be
+-- a task, so a thread may hold several. A task has no message when it
+-- comes from no thread or when its message was deleted; it then keeps its
+-- thread.
+
+ALTER TABLE file_task
+ ADD COLUMN comment_id uuid NULL REFERENCES comment(id) ON DELETE SET NULL DEFERRABLE;
+
+CREATE INDEX file_task__comment_id__idx
+ ON file_task(comment_id) WHERE comment_id IS NOT NULL;
+
+-- Until now a task came from a whole thread, with the title of its first
+-- message.
+UPDATE file_task AS t
+ SET comment_id = (SELECT c.id
+ FROM comment AS c
+ WHERE c.thread_id = t.thread_id
+ ORDER BY c.created_at ASC
+ LIMIT 1)
+ WHERE t.thread_id IS NOT NULL;
diff --git a/backend/src/app/migrations/sql/0814-mod-file-task-give-thread.sql b/backend/src/app/migrations/sql/0814-mod-file-task-give-thread.sql
new file mode 100644
index 0000000000..fdfd492dbb
--- /dev/null
+++ b/backend/src/app/migrations/sql/0814-mod-file-task-give-thread.sql
@@ -0,0 +1,63 @@
+-- Every task lives in a message of a comment thread, so its thread can go
+-- on: a task created on the canvas gets a thread whose first message is
+-- its title, as if it had been a comment turned into a task.
+--
+-- Until now such a task had no thread. Give one to each of them: the
+-- thread points at the layer of the task (at its spot of the canvas when
+-- it has none), belongs to its design review and takes the next number of
+-- its file. A task whose author is gone keeps no thread: a thread needs an
+-- owner. The spot of a task on a layer was optional; the thread falls back
+-- to the origin of the canvas, and its mark follows the layer anyway.
+
+CREATE TEMPORARY TABLE task_thread ON COMMIT DROP AS
+SELECT t.id AS task_id,
+ gen_random_uuid() AS thread_id,
+ gen_random_uuid() AS comment_id,
+ t.file_id,
+ t.created_by,
+ t.page_id,
+ t.frame_id,
+ t.shape_id,
+ t.pull_request_id,
+ t.title,
+ t.created_at,
+ coalesce(t.position, point(0, 0)) AS position,
+ f.comment_thread_seqn
+ + row_number() OVER (PARTITION BY t.file_id ORDER BY t.created_at) AS seqn
+ FROM file_task AS t
+ JOIN file AS f ON (f.id = t.file_id)
+ WHERE t.thread_id IS NULL
+ AND t.created_by IS NOT NULL
+ AND t.deleted_at IS NULL;
+
+INSERT INTO comment_thread
+ (id, file_id, owner_id, created_at, modified_at, page_id, participants,
+ seqn, position, frame_id, pull_request_id, anchor_type, shape_id)
+SELECT thread_id, file_id, created_by, created_at, created_at, page_id,
+ jsonb_build_object('~#set', jsonb_build_array('~u' || created_by::text)),
+ seqn, position, frame_id, pull_request_id,
+ CASE WHEN shape_id IS NULL THEN 'canvas' ELSE 'layer' END,
+ shape_id
+ FROM task_thread;
+
+INSERT INTO comment (id, thread_id, owner_id, created_at, modified_at, content)
+SELECT comment_id, thread_id, created_by, created_at, created_at, title
+ FROM task_thread;
+
+-- the author has read the thread they wrote
+INSERT INTO comment_thread_status (thread_id, profile_id, created_at, modified_at)
+SELECT thread_id, created_by, created_at, created_at
+ FROM task_thread;
+
+UPDATE file AS f
+ SET comment_thread_seqn = tt.seqn
+ FROM (SELECT file_id, max(seqn) AS seqn
+ FROM task_thread
+ GROUP BY file_id) AS tt
+ WHERE f.id = tt.file_id;
+
+UPDATE file_task AS t
+ SET thread_id = tt.thread_id,
+ comment_id = tt.comment_id
+ FROM task_thread AS tt
+ WHERE t.id = tt.task_id;
diff --git a/backend/src/app/rpc.clj b/backend/src/app/rpc.clj
index 86585c2edf..a08538d41c 100644
--- a/backend/src/app/rpc.clj
+++ b/backend/src/app/rpc.clj
@@ -434,6 +434,7 @@
'app.rpc.commands.files-snapshot
'app.rpc.commands.files-branch
'app.rpc.commands.files-pull-request
+ 'app.rpc.commands.files-task
'app.rpc.commands.files-thumbnails
'app.rpc.commands.jobs
'app.rpc.commands.ldap
diff --git a/backend/src/app/rpc/commands/comments.clj b/backend/src/app/rpc/commands/comments.clj
index a61e1cb3c1..a0103086e5 100644
--- a/backend/src/app/rpc/commands/comments.clj
+++ b/backend/src/app/rpc/commands/comments.clj
@@ -22,6 +22,7 @@
[app.features.fdata :as feat.fdata]
[app.loggers.audit :as-alias audit]
[app.loggers.webhooks :as-alias webhooks]
+ [app.msgbus :as mbus]
[app.rpc :as-alias rpc]
[app.rpc.commands.files :as files]
[app.rpc.commands.profile :as profile]
@@ -174,10 +175,12 @@
:comment-url comment-url}))))))
(defn- decode-row
- [{:keys [participants position mentions] :as row}]
+ [{:keys [participants position mentions area anchor-type] :as row}]
(cond-> row
(db/pgpoint? position) (assoc :position (db/decode-pgpoint position))
(db/pgobject? participants) (assoc :participants (db/decode-transit-pgobject participants))
+ (db/pgobject? area) (assoc :area (db/decode-transit-pgobject area))
+ (string? anchor-type) (assoc :anchor-type (keyword anchor-type))
(db/pgarray? mentions) (assoc :mentions (db/decode-pgarray mentions #{}))))
(def xf-decode-row
@@ -267,6 +270,8 @@
p.team_id AS team_id,
f.name AS file_name,
f.project_id AS project_id,
+ fpr.title AS pull_request_title,
+ fpr.status AS pull_request_status,
first_value(c.content) OVER w AS content,
(SELECT count(1)
FROM comment AS c
@@ -281,6 +286,7 @@
INNER JOIN project AS p ON (p.id = f.project_id)
LEFT JOIN comment_thread_status AS cts ON (cts.thread_id = ct.id AND cts.profile_id = ?)
LEFT JOIN profile AS pf ON (ct.owner_id = pf.id)
+ LEFT JOIN file_pull_request AS fpr ON (fpr.id = ct.pull_request_id)
WHERE f.deleted_at IS NULL
AND p.deleted_at IS NULL
%1
@@ -468,10 +474,30 @@
;; MUTATION COMMANDS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(declare ^:private create-comment-thread)
+(declare ^:private insert-comment-thread)
;; --- COMMAND: Create Comment Thread
+(def schema:area
+ "A rectangle of the canvas a thread points at, in canvas coordinates."
+ [:map {:title "CommentThreadArea"}
+ [:x ::sm/safe-number]
+ [:y ::sm/safe-number]
+ [:width ::sm/safe-number]
+ [:height ::sm/safe-number]])
+
+(def ^:private schema:anchor
+ "What a thread points at: a spot of a board (`:canvas`, the default),
+ a layer or a rectangle."
+ [:multi {:dispatch :type :title "CommentThreadAnchor"}
+ [:canvas [:map [:type [:= :canvas]]]]
+ [:layer [:map
+ [:type [:= :layer]]
+ [:shape-id ::sm/uuid]]]
+ [:area [:map
+ [:type [:= :area]]
+ [:area schema:area]]]])
+
(def ^:private
schema:create-comment-thread
[:map {:title "create-comment-thread"}
@@ -481,7 +507,28 @@
[:page-id ::sm/uuid]
[:frame-id ::sm/uuid]
[:share-id {:optional true} [:maybe ::sm/uuid]]
- [:mentions {:optional true} [::sm/set ::sm/uuid]]])
+ [:mentions {:optional true} [::sm/set ::sm/uuid]]
+ ;; the design review the thread is written in: an open pull request
+ ;; of this file (the branch file it reviews)
+ [:pull-request-id {:optional true} ::sm/uuid]
+ [:anchor {:optional true} schema:anchor]])
+
+(def ^:private sql:get-open-pull-request-of-file
+ "SELECT id FROM file_pull_request
+ WHERE id = ?
+ AND source_file_id = ?
+ AND status = 'open'
+ AND deleted_at IS NULL")
+
+(defn- check-review-of-file
+ "Refuse a thread for a design review that is not an open review of the
+ file the thread is written on."
+ [conn pull-request-id file-id]
+ (when-not (db/exec-one! conn [sql:get-open-pull-request-of-file pull-request-id file-id])
+ (ex/raise :type :validation
+ :code :pull-request-not-open
+ :hint "the thread names a design review that is not open on this file"
+ :pull-request-id pull-request-id)))
(defn- update-thread-seqn
[conn file-id seqn]
@@ -497,6 +544,26 @@
(assoc :owner-email (:email profile))
(assoc :owner-photo-id (:photo-id profile))))
+(defn create-comment-thread
+ "Create a thread with its first message on the page `page-id` of
+ `file-id`, once the quotes of threads and comments allow it. It joins
+ the transaction of `cfg` when there is one: a task created on the canvas
+ gets its thread this way (`app.rpc.commands.files-task`). The caller
+ checks the permissions. Returns the thread with the id of its first
+ message (`:comment-id`)."
+ [cfg {:keys [::rpc/profile-id file-id page-id] :as params}]
+ (let [{:keys [team-id project-id] :as file} (get-file cfg file-id page-id)]
+ (-> cfg
+ (assoc ::quotes/profile-id profile-id)
+ (assoc ::quotes/team-id team-id)
+ (assoc ::quotes/project-id project-id)
+ (assoc ::quotes/file-id file-id)
+ (quotes/check! {::quotes/id ::quotes/comment-threads-per-file}
+ {::quotes/id ::quotes/comments-per-file}))
+
+ (let [thread (db/tx-run! cfg insert-comment-thread (assoc params ::file file))]
+ (vary-meta thread assoc ::audit/props (assoc thread :team-id team-id)))))
+
(sv/defmethod ::create-comment-thread
{::doc/added "1.15"
::webhooks/event? true
@@ -506,24 +573,12 @@
[cfg {:keys [::rpc/profile-id file-id page-id share-id] :as params}]
(let [perms (files/check-comment-permissions! cfg profile-id file-id share-id)]
(check-page-scope perms page-id)
+ (create-comment-thread cfg params)))
- (let [{:keys [team-id project-id] :as file} (get-file cfg file-id page-id)]
- (-> cfg
- (assoc ::quotes/profile-id profile-id)
- (assoc ::quotes/team-id team-id)
- (assoc ::quotes/project-id project-id)
- (assoc ::quotes/file-id file-id)
- (quotes/check! {::quotes/id ::quotes/comment-threads-per-file}
- {::quotes/id ::quotes/comments-per-file}))
-
- (let [params (assoc params ::file file)
- thread (db/tx-run! cfg create-comment-thread params)]
-
- (vary-meta thread assoc ::audit/props (assoc thread :team-id team-id))))))
-
-(defn- create-comment-thread
+(defn- insert-comment-thread
[{:keys [::db/conn] :as cfg}
- {:keys [::rpc/profile-id ::rpc/request-at ::file position content mentions frame-id] :as params}]
+ {:keys [::rpc/profile-id ::rpc/request-at ::file position content mentions frame-id
+ pull-request-id anchor]}]
(let [;; NOTE: we take the next seq number from a separate query
;; because we need to lock the file for avoid race conditions
@@ -534,6 +589,9 @@
;; different storage (example: redis) for alivate the update
;; pression on the file table
+ _ (when pull-request-id
+ (check-review-of-file conn pull-request-id (:id file)))
+
profile (profile/get-profile conn profile-id)
seqn (get-next-seqn conn (:id file))
@@ -552,7 +610,11 @@
:seqn seqn
:frame-id frame-id
:position (db/pgpoint position)
- :mentions (db/encode-pgarray mentions conn "uuid")})
+ :mentions (db/encode-pgarray mentions conn "uuid")
+ :pull-request-id pull-request-id
+ :anchor-type (d/name (get anchor :type :canvas))
+ :shape-id (:shape-id anchor)
+ :area (some-> (:area anchor) db/tjson)})
(decode-row))
comment (-> (db/insert! conn :comment
{:id (uuid/next)
@@ -747,7 +809,37 @@
[:id ::sm/uuid]
[:share-id {:optional true} [:maybe ::sm/uuid]]])
+;; The thread delete that follows clears `thread_id` and `comment_id` of
+;; the task rows through two ON DELETE SET NULL actions, whose order
+;; Postgres picks by trigger name. A row this statement already updated
+;; gets its FK rechecked by the first of them, and when that is the
+;; `thread_id` one, `comment_id` still names a message the cascade has
+;; deleted. Clearing both here leaves the delete no referencing row.
+(def ^:private sql:delete-thread-tasks
+ "UPDATE file_task
+ SET deleted_at = ?,
+ updated_at = ?,
+ thread_id = NULL,
+ comment_id = NULL
+ WHERE thread_id = ?
+ AND deleted_at IS NULL")
+
+(defn- delete-thread-tasks
+ "Delete the tasks of the thread `thread-id`, which live in its messages,
+ and tell the open clients of `file-id` once the transaction commits."
+ [{:keys [::db/conn ::mbus/msgbus]} profile-id file-id thread-id]
+ (let [ts (ct/now)
+ result (db/exec-one! conn [sql:delete-thread-tasks ts ts thread-id])]
+ (when (pos? (db/get-update-count result))
+ (db/after-commit
+ #(mbus/pub! msgbus
+ :topic file-id
+ :message {:type :file-tasks-change
+ :file-id file-id
+ :profile-id profile-id})))))
+
(sv/defmethod ::delete-comment-thread
+ "Delete a thread with its messages and the tasks they hold."
{::doc/added "1.15"
::sm/params schema:delete-comment-thread
::db/transaction true}
@@ -763,6 +855,7 @@
(ex/raise :type :validation
:code :not-allowed))
+ (delete-thread-tasks cfg profile-id file-id id)
(db/delete! conn :comment-thread {:id id}
{::db/return-keys false})
nil))
diff --git a/backend/src/app/rpc/commands/files_branch.clj b/backend/src/app/rpc/commands/files_branch.clj
index 1348e8445c..7af39af58b 100644
--- a/backend/src/app/rpc/commands/files_branch.clj
+++ b/backend/src/app/rpc/commands/files_branch.clj
@@ -43,6 +43,7 @@
[app.rpc.commands.files :as files]
[app.rpc.commands.files-branch-policies :as bp]
[app.rpc.commands.files-create :as fcreate]
+ [app.rpc.commands.files-task :as ftask]
[app.rpc.commands.files-update :as fupd]
[app.rpc.commands.teams :as teams]
[app.rpc.doc :as-alias doc]
@@ -499,12 +500,13 @@
`file_branch_merge` migration). The open pull request of the branch is
the design review the merge accepts, so it is read here, before the
merge closes it. A blank comment is stored as no comment. Must run
- inside the merge transaction."
+ inside the merge transaction. Returns the id of the record."
[conn {:keys [id source-file-id name]} {:keys [profile-id comment created-at]}]
- (let [pr (db/exec-one! conn [sql:get-open-branch-pull-request id])
- comment (when-not (str/blank? comment) (str/trim comment))]
+ (let [pr (db/exec-one! conn [sql:get-open-branch-pull-request id])
+ comment (when-not (str/blank? comment) (str/trim comment))
+ merge-id (uuid/next)]
(db/insert! conn :file-branch-merge
- {:id (uuid/next)
+ {:id merge-id
:created-at created-at
:file-id source-file-id
:file-branch-id id
@@ -513,7 +515,8 @@
:comment comment
:pull-request-id (:id pr)
:pull-request-title (:title pr)}
- {::db/return-keys false})))
+ {::db/return-keys false})
+ merge-id))
;; --- COMMAND: create-file-branch
@@ -1092,7 +1095,10 @@
[:expected-main-revn {:optional true} ::sm/int]
;; what the user says about the merge; kept in its record
;; (`file_branch_merge`), shown in the list of merges of main
- [:comment {:optional true} [:string {:max 4000}]]])
+ [:comment {:optional true} [:string {:max 4000}]]
+ ;; tell the assignees of the open tasks of the branch, by email, that
+ ;; the merge moved their tasks into main
+ [:notify-assignees {:optional true} ::sm/boolean]])
(sv/defmethod ::merge-file-branch
"Merge a branch into its source file (main).
@@ -1120,7 +1126,8 @@
::climit/id [[:merge-file-branch/by-profile ::rpc/profile-id]
[:merge-file-branch/global]]}
[{:keys [::mbus/msgbus] :as cfg}
- {:keys [::rpc/profile-id ::rpc/session-id branch-id resolutions expected-main-revn comment excluded]}]
+ {:keys [::rpc/profile-id ::rpc/session-id branch-id resolutions expected-main-revn comment excluded
+ notify-assignees]}]
(bp/with-policies
(check-branching-enabled!)
(let [branch (db/get* cfg :file-branch {:id branch-id})]
@@ -1219,9 +1226,17 @@
;; releases the pinned base snapshot. The record is
;; written first: it reads the open pull request the
;; lines below close.
- (record-merge! conn branch {:profile-id profile-id
- :comment comment
- :created-at ts})
+ (let [merge-id (record-merge! conn branch {:profile-id profile-id
+ :comment comment
+ :created-at ts})]
+ ;; the tasks of the branch outlive it: the open ones
+ ;; keep going on main, the closed ones are its history
+ (ftask/move-branch-tasks cfg {:branch-file-id branch-file-id
+ :main-id main-id
+ :merge-id merge-id
+ :branch-name (:name branch)
+ :profile-id profile-id
+ :notify-assignees notify-assignees}))
(db/update! conn :file-branch
{:status "merged"
:merged-at ts
diff --git a/backend/src/app/rpc/commands/files_pull_request.clj b/backend/src/app/rpc/commands/files_pull_request.clj
index ab1d8e449b..7f54e004dd 100644
--- a/backend/src/app/rpc/commands/files_pull_request.clj
+++ b/backend/src/app/rpc/commands/files_pull_request.clj
@@ -36,11 +36,13 @@
[app.rpc.climit :as-alias climit]
[app.rpc.commands.files :as files]
[app.rpc.commands.files-branch :as fbranch]
+ [app.rpc.commands.files-task :as ftask]
[app.rpc.commands.profile :as profile]
[app.rpc.commands.teams :as teams]
[app.rpc.doc :as-alias doc]
[app.rpc.permissions :as perms]
[app.rpc.quotes :as quotes]
+ [app.util.blob :as blob]
[app.util.services :as sv]
[clojure.string :as str]))
@@ -169,9 +171,9 @@
the branches listing uses, so ten open pull requests on one file cost
one computation per branch and nothing at all once that panel has been
opened."
- [cfg main-data reviews-map {:keys [id status file-branch-id source-file-id target-file-id
- review-revn branch-revn]
- :as row}]
+ [cfg main-data reviews-map counts-map {:keys [id status file-branch-id source-file-id target-file-id
+ review-revn branch-revn]
+ :as row}]
(let [reviews (get reviews-map id [])
open? (= "open" status)
[ahead behind conflicts]
@@ -187,6 +189,8 @@
(assoc :review-state (review-state reviews))
(assoc :outdated (and open? (> branch-revn review-revn)))
(assoc :ahead ahead :behind behind :conflicts conflicts)
+ ;; the comments and tasks of the review, for its overview
+ (assoc :counts (get counts-map id {:tasks {} :comments-open 0 :comments-resolved 0}))
(dissoc :branch-revn :source-revn :base-snapshot-id
:base-revn :base-branch-revn :review-snapshot-id))))
@@ -454,8 +458,9 @@
(let [[a b] (fbranch/revn-deltas r)]
(or (pos? a) (pos? b)))))
rows)
- main-data (when need? (:data (bfc/get-file cfg target-id :realize? true)))]
- (mapv (partial decorate-pull-request cfg main-data reviews-map) rows))))))
+ main-data (when need? (:data (bfc/get-file cfg target-id :realize? true)))
+ counts-map (ftask/get-review-counts conn (mapv :id rows))]
+ (mapv (partial decorate-pull-request cfg main-data reviews-map counts-map) rows))))))
;; --- COMMAND QUERY: get-pull-request
@@ -508,7 +513,45 @@
:code :pull-request-not-found
:pull-request-id id))
(files/check-read-permissions! cfg profile-id (:target-file-id row))
- (decorate-pull-request cfg nil (get-reviews-map cfg [row]) row)))))
+ (decorate-pull-request cfg nil
+ (get-reviews-map cfg [row])
+ (ftask/get-review-counts conn [id])
+ row)))))
+
+;; --- COMMAND QUERY: get-pull-request-activity
+
+(def ^:private schema:get-pull-request-activity
+ [:map {:title "get-pull-request-activity"}
+ [:id ::sm/uuid]])
+
+(def ^:private max-activity-rows
+ "The newest saves the activity of a review reads. A review that runs
+ for months keeps its history; the list shows the recent part of it."
+ 2000)
+
+(def ^:private sql:get-pull-request-activity
+ "SELECT a.id, a.profile_id, a.revn, a.entries, a.created_at
+ FROM file_pull_request_activity AS a
+ WHERE a.pull_request_id = ?
+ ORDER BY a.created_at DESC
+ LIMIT ?")
+
+(sv/defmethod ::get-pull-request-activity
+ "What the saves of the branch did to its layers since the design review
+ opened: one row per save, newest first, each with who saved and its
+ entries (`app.common.files.review-activity/entries`). The client folds
+ them into the activity list."
+ {::doc/added "2.16"
+ ::sm/params schema:get-pull-request-activity}
+ [cfg {:keys [::rpc/profile-id id]}]
+ (check-pull-requests-enabled!)
+ (db/run! cfg
+ (fn [{:keys [::db/conn] :as cfg}]
+ (let [pr (get-pull-request* conn id)]
+ (files/check-read-permissions! cfg profile-id (:target-file-id pr))
+ (into []
+ (map (fn [row] (update row :entries blob/decode)))
+ (db/exec! conn [sql:get-pull-request-activity id max-activity-rows]))))))
;; --- COMMAND QUERY: get-pull-request-bundle
diff --git a/backend/src/app/rpc/commands/files_task.clj b/backend/src/app/rpc/commands/files_task.clj
new file mode 100644
index 0000000000..62b274c83a
--- /dev/null
+++ b/backend/src/app/rpc/commands/files_task.clj
@@ -0,0 +1,735 @@
+;; 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 INC Sucursal en España SL
+
+(ns app.rpc.commands.files-task
+ "RPC commands for tasks: a piece of work on a file, assigned to someone
+ and tied to a layer (see the `file_task` migration).
+
+ Every task lives in a message of a comment thread, so its thread can
+ go on: a task made from a message keeps that thread, and a task
+ created on the canvas gets a thread whose first message is its title.
+ A task may also belong to a design review. Everybody who can read the
+ file may create a task and move it between states; every move is
+ recorded as an event of the task with who made it, which is what the
+ thread of the task shows between its comments.
+
+ The merge of a branch moves its tasks into main (`move-branch-tasks`,
+ called from `app.rpc.commands.files-branch`): the open ones keep going
+ on main and the closed ones stay as the history of the branch."
+ (:require
+ [app.common.data :as d]
+ [app.common.exceptions :as ex]
+ [app.common.geom.point :as gpt]
+ [app.common.schema :as sm]
+ [app.common.time :as ct]
+ [app.common.uri :as uri]
+ [app.common.uuid :as uuid]
+ [app.config :as cf]
+ [app.db :as db]
+ [app.db.sql :as-alias sql]
+ [app.email :as eml]
+ [app.loggers.webhooks :as-alias webhooks]
+ [app.msgbus :as mbus]
+ [app.rpc :as-alias rpc]
+ [app.rpc.commands.comments :as comments]
+ [app.rpc.commands.files :as files]
+ [app.rpc.commands.profile :as profile]
+ [app.rpc.commands.teams :as teams]
+ [app.rpc.doc :as-alias doc]
+ [app.rpc.permissions :as perms]
+ [app.util.services :as sv]
+ [clojure.string :as str]))
+
+(def statuses
+ #{"open" "done" "reopened" "verified" "wont-do"})
+
+(def closed-statuses
+ "A closed task is finished: verified, or dropped as won't do."
+ #{"verified" "wont-do"})
+
+(def ^:private transitions
+ "The moves a task can make, from each state."
+ {"open" #{"done" "wont-do"}
+ "reopened" #{"done" "wont-do"}
+ "done" #{"verified" "reopened"}
+ "verified" #{"reopened"}
+ "wont-do" #{"reopened"}})
+
+(def ^:private title-max-length 250)
+
+;; --- Helpers
+
+(defn- check-tasks-enabled
+ "Tasks ride on the branching feature, like design reviews."
+ []
+ (when-not (contains? cf/flags :branching)
+ (ex/raise :type :restriction
+ :code :branching-disabled
+ :hint "the branching feature is not enabled on this instance")))
+
+(defn- decode-row
+ [{:keys [payload position] :as row}]
+ (cond-> row
+ (db/pgobject? payload) (assoc :payload (db/decode-transit-pgobject payload))
+ (db/pgpoint? position) (assoc :position (db/decode-pgpoint position))))
+
+(defn- get-task
+ "Fetch a task row or raise :not-found."
+ [conn id & {:as opts}]
+ (let [task (db/get* conn :file-task {:id id} opts)]
+ (when (or (nil? task) (some? (:deleted-at task)))
+ (ex/raise :type :not-found
+ :code :task-not-found
+ :hint "unable to find a task with the provided id"
+ :task-id id))
+ (decode-row task)))
+
+(defn- insert-event
+ [conn task-id profile-id type payload]
+ (db/insert! conn :file-task-event
+ {:id (uuid/next)
+ :task-id task-id
+ :profile-id profile-id
+ :type type
+ :payload (some-> payload db/tjson)
+ :created-at (ct/now)}
+ {::db/return-keys false}))
+
+(defn- check-assignee
+ "Refuse an assignee who is not a member of the team of the file."
+ [conn team-id assignee-id]
+ (when (some? assignee-id)
+ (let [members (into #{} (map :id) (teams/get-team-members conn team-id))]
+ (when-not (contains? members assignee-id)
+ (ex/raise :type :validation
+ :code :assignee-not-team-member
+ :hint "the assignee must be a member of the team"
+ :profile-id assignee-id)))))
+
+(defn- run-and-notify
+ "Run `f` in a transaction, then tell the open clients of `file-id` that
+ its tasks changed: the message leaves once the transaction committed,
+ so a client that reloads on it reads the committed state."
+ [{:keys [::mbus/msgbus] :as cfg} file-id profile-id f]
+ (let [result (db/tx-run! cfg f)]
+ (mbus/pub! msgbus
+ :topic file-id
+ :message {:type :file-tasks-change
+ :file-id file-id
+ :profile-id profile-id})
+ result))
+
+;; --- Helpers: emails
+
+(defn- format-task-url
+ [{:keys [id file-id page-id]} team-id]
+ (str/join [(cf/get :public-uri)
+ "/#/workspace?"
+ (uri/map->query-string {:file-id file-id
+ :page-id page-id
+ :team-id team-id
+ :task-id id})]))
+
+(defn- send-task-assigned-email
+ "Tell `assignee-id` that `actor-id` assigned the task to them. Nobody is
+ told about the tasks they assign to themselves."
+ [{:keys [::db/conn] :as cfg} team-id actor-id {:keys [assignee-id title] :as task}]
+ (when (and (some? assignee-id) (not= assignee-id actor-id))
+ (let [users (->> (teams/get-users+props conn team-id)
+ (map profile/decode-row)
+ (d/index-by :id))]
+ (when-let [{:keys [fullname email]} (get users assignee-id)]
+ (eml/send-template
+ cfg
+ {::eml/reuse-conn true
+ ::eml/template "task-assigned"
+ :public-uri (cf/get :public-uri)
+ :to email
+ :name fullname
+ :source-user (get-in users [actor-id :fullname] "")
+ :task-title title
+ :task-url (format-task-url task team-id)})))))
+
+;; --- COMMAND QUERY: get-file-tasks
+
+(def ^:private schema:get-file-tasks
+ [:map {:title "get-file-tasks"}
+ [:file-id ::sm/uuid]])
+
+(def ^:private sql:get-file-tasks
+ "SELECT t.id,
+ t.file_id,
+ t.pull_request_id,
+ coalesce(fpr.title, t.review_title) AS review_title,
+ fpr.status AS review_status,
+ t.thread_id,
+ t.comment_id,
+ ct.seqn AS thread_seqn,
+ t.title,
+ t.status,
+ t.assignee_id,
+ t.created_by,
+ t.page_id,
+ t.frame_id,
+ t.shape_id,
+ t.lost_shape_name,
+ t.position,
+ t.merge_id,
+ t.branch_name,
+ t.status_changed_at,
+ t.status_changed_by,
+ t.created_at,
+ t.updated_at
+ FROM file_task AS t
+ LEFT JOIN file_pull_request AS fpr ON (fpr.id = t.pull_request_id)
+ LEFT JOIN comment_thread AS ct ON (ct.id = t.thread_id)
+ WHERE t.file_id = ?
+ AND t.deleted_at IS NULL
+ ORDER BY t.created_at ASC")
+
+(defn get-file-tasks
+ [conn file-id]
+ (into [] (map decode-row) (db/exec! conn [sql:get-file-tasks file-id])))
+
+(sv/defmethod ::get-file-tasks
+ "List the tasks of a file, oldest first: the open ones and the history
+ of the closed ones, the tasks of the branches merged into it included
+ (those carry the merge that moved them, `merge-id`)."
+ {::doc/added "2.16"
+ ::sm/params schema:get-file-tasks}
+ [cfg {:keys [::rpc/profile-id file-id]}]
+ (check-tasks-enabled)
+ (db/run! cfg (fn [{:keys [::db/conn] :as cfg}]
+ (files/check-read-permissions! cfg profile-id file-id)
+ (get-file-tasks conn file-id))))
+
+;; --- COMMAND QUERY: get-task-events
+
+(def ^:private schema:get-task-events
+ [:map {:title "get-task-events"}
+ [:id ::sm/uuid]])
+
+(def ^:private sql:get-task-events
+ "SELECT e.id, e.task_id, e.profile_id, e.type, e.payload, e.created_at
+ FROM file_task_event AS e
+ WHERE e.task_id = ?
+ ORDER BY e.created_at ASC")
+
+(sv/defmethod ::get-task-events
+ "What happened to a task, oldest first."
+ {::doc/added "2.16"
+ ::sm/params schema:get-task-events}
+ [cfg {:keys [::rpc/profile-id id]}]
+ (check-tasks-enabled)
+ (db/run! cfg (fn [{:keys [::db/conn] :as cfg}]
+ (let [task (get-task conn id)]
+ (files/check-read-permissions! cfg profile-id (:file-id task))
+ (into [] (map decode-row) (db/exec! conn [sql:get-task-events id]))))))
+
+;; --- COMMAND: create-task
+
+(def ^:private schema:create-task
+ [:map {:title "create-task" :closed true}
+ [:file-id ::sm/uuid]
+ [:title [:string {:max title-max-length}]]
+ [:page-id ::sm/uuid]
+ [:frame-id ::sm/uuid]
+ [:shape-id {:optional true} [:maybe ::sm/uuid]]
+ ;; where its mark goes when it points at no layer, and where its
+ ;; thread sits
+ [:position ::gpt/point]
+ [:assignee-id {:optional true} [:maybe ::sm/uuid]]
+ ;; the design review the task is created in: an open pull request
+ ;; of this file (the branch file it reviews)
+ [:pull-request-id {:optional true} [:maybe ::sm/uuid]]
+ ;; the comment thread the task comes from, which stays attached, and
+ ;; the message of that thread it was made from; without them the
+ ;; task gets a thread of its own
+ [:thread-id {:optional true} [:maybe ::sm/uuid]]
+ [:comment-id {:optional true} [:maybe ::sm/uuid]]])
+
+(def ^:private sql:get-open-review-of-file
+ "SELECT id, title FROM file_pull_request
+ WHERE id = ?
+ AND source_file_id = ?
+ AND status = 'open'
+ AND deleted_at IS NULL")
+
+(def ^:private sql:get-task-of-comment
+ "SELECT id FROM file_task
+ WHERE comment_id = ?
+ AND deleted_at IS NULL")
+
+(defn- check-thread
+ "Refuse a thread of another file."
+ [conn thread-id file-id]
+ (let [thread (db/get* conn :comment-thread {:id thread-id})]
+ (when (or (nil? thread) (not= file-id (:file-id thread)))
+ (ex/raise :type :validation
+ :code :thread-not-in-file
+ :hint "the comment thread does not belong to the file"
+ :thread-id thread-id))))
+
+(defn- check-comment
+ "Refuse a message of another thread, and a message that already has a
+ task: each message of a thread may be one task."
+ [conn comment-id thread-id]
+ (let [comment (db/get* conn :comment {:id comment-id})]
+ (when (or (nil? comment) (not= thread-id (:thread-id comment)))
+ (ex/raise :type :validation
+ :code :comment-not-in-thread
+ :hint "the comment does not belong to the thread"
+ :comment-id comment-id))
+ (when (db/exec-one! conn [sql:get-task-of-comment comment-id])
+ (ex/raise :type :validation
+ :code :comment-already-has-task
+ :hint "the comment already has a task"
+ :comment-id comment-id))))
+
+(defn- create-task-thread
+ "The thread of a task created on the canvas: its first message is the
+ title, it points at the layer of the task (at the spot of the canvas
+ when there is none) and belongs to the design review of the task."
+ [cfg profile-id {:keys [file-id title page-id frame-id shape-id position pull-request-id]}]
+ (comments/create-comment-thread
+ cfg
+ (cond-> {::rpc/profile-id profile-id
+ ::rpc/request-at (ct/now)
+ :file-id file-id
+ :page-id page-id
+ :frame-id frame-id
+ :position position
+ :content title
+ :anchor (if (some? shape-id)
+ {:type :layer :shape-id shape-id}
+ {:type :canvas})}
+ (some? pull-request-id) (assoc :pull-request-id pull-request-id))))
+
+(sv/defmethod ::create-task
+ "Create an open task on a file, in a message of a comment thread: the
+ message it was made from (`thread-id` and `comment-id`), or the first
+ message of a new thread that carries its title. A task created in a
+ design review belongs to it. The assignee, when there is one, must be
+ a member of the team and is told by email."
+ {::doc/added "2.16"
+ ::webhooks/event? true
+ ::sm/params schema:create-task}
+ [cfg {:keys [::rpc/profile-id file-id title page-id frame-id shape-id position assignee-id
+ pull-request-id thread-id comment-id] :as params}]
+ (check-tasks-enabled)
+ (when (str/blank? title)
+ (ex/raise :type :validation
+ :code :invalid-task-title
+ :hint "task title cannot be blank"))
+ (files/check-read-permissions! cfg profile-id file-id)
+ (run-and-notify
+ cfg file-id profile-id
+ (fn [{:keys [::db/conn] :as cfg}]
+ (let [team-id (perms/get-team-id-for-file conn file-id)
+ review (when pull-request-id
+ (or (db/exec-one! conn [sql:get-open-review-of-file pull-request-id file-id])
+ (ex/raise :type :validation
+ :code :pull-request-not-open
+ :hint "the task names a design review that is not open on this file"
+ :pull-request-id pull-request-id)))
+ _ (when thread-id
+ (check-thread conn thread-id file-id))
+ _ (when comment-id
+ (check-comment conn comment-id thread-id))
+ _ (check-assignee conn team-id assignee-id)
+ thread (when (nil? thread-id)
+ (create-task-thread cfg profile-id (update params :title str/trim)))
+ ts (ct/now)
+ task {:id (uuid/next)
+ :position position
+ :file-id file-id
+ :pull-request-id pull-request-id
+ :review-title (:title review)
+ :thread-id (or thread-id (:id thread))
+ :comment-id (or comment-id (:comment-id thread))
+ :title (str/trim title)
+ :status "open"
+ :assignee-id assignee-id
+ :created-by profile-id
+ :page-id page-id
+ :frame-id frame-id
+ :shape-id shape-id
+ :created-at ts
+ :updated-at ts}]
+ (db/insert! conn :file-task
+ (assoc task :position (db/pgpoint position))
+ {::db/return-keys false})
+ (insert-event conn (:id task) profile-id "created" nil)
+ (when (some? assignee-id)
+ (insert-event conn (:id task) profile-id "assigned" {:assignee-id assignee-id}))
+ (send-task-assigned-email cfg team-id profile-id task)
+ task))))
+
+;; --- COMMAND: update-task
+
+(def ^:private schema:update-task
+ [:map {:title "update-task" :closed true}
+ [:id ::sm/uuid]
+ [:title {:optional true} [:string {:max title-max-length}]]
+ ;; nil leaves the task without an assignee
+ [:assignee-id {:optional true} [:maybe ::sm/uuid]]])
+
+(sv/defmethod ::update-task
+ "Rename a task or change its assignee. Each change is an event of the
+ task; a new assignee is told by email."
+ {::doc/added "2.16"
+ ::sm/params schema:update-task}
+ [cfg {:keys [::rpc/profile-id id title] :as params}]
+ (check-tasks-enabled)
+ (when (and (some? title) (str/blank? title))
+ (ex/raise :type :validation
+ :code :invalid-task-title
+ :hint "task title cannot be blank"))
+ (let [task (db/run! cfg (fn [{:keys [::db/conn]}] (get-task conn id)))]
+ (files/check-read-permissions! cfg profile-id (:file-id task))
+ (run-and-notify
+ cfg (:file-id task) profile-id
+ (fn [{:keys [::db/conn] :as cfg}]
+ (let [task (get-task conn id {::sql/for-update true})
+ team-id (perms/get-team-id-for-file conn (:file-id task))
+ reassign? (and (contains? params :assignee-id)
+ (not= (:assignee-id params) (:assignee-id task)))
+ rename? (and (some? title) (not= (str/trim title) (:title task)))
+ changes (cond-> {:updated-at (ct/now)}
+ rename? (assoc :title (str/trim title))
+ reassign? (assoc :assignee-id (:assignee-id params)))
+ task (merge task changes)]
+ (when reassign?
+ (check-assignee conn team-id (:assignee-id params)))
+ (db/update! conn :file-task changes {:id id} {::db/return-keys false})
+ (when rename?
+ (insert-event conn id profile-id "renamed" {:title (:title task)}))
+ (when reassign?
+ (insert-event conn id profile-id "assigned" {:assignee-id (:assignee-id task)})
+ (send-task-assigned-email cfg team-id profile-id task))
+ task)))))
+
+;; --- COMMAND: set-task-status
+
+(def ^:private schema:set-task-status
+ [:map {:title "set-task-status" :closed true}
+ [:id ::sm/uuid]
+ [:status (into [:enum] statuses)]])
+
+(sv/defmethod ::set-task-status
+ "Move a task to another state (see `transitions`). Anybody who can read
+ the file may do it; the event records who did."
+ {::doc/added "2.16"
+ ::webhooks/event? true
+ ::sm/params schema:set-task-status}
+ [cfg {:keys [::rpc/profile-id id status]}]
+ (check-tasks-enabled)
+ (let [task (db/run! cfg (fn [{:keys [::db/conn]}] (get-task conn id)))]
+ (files/check-read-permissions! cfg profile-id (:file-id task))
+ (run-and-notify
+ cfg (:file-id task) profile-id
+ (fn [{:keys [::db/conn]}]
+ (let [task (get-task conn id {::sql/for-update true})
+ from (:status task)
+ ts (ct/now)]
+ (when-not (contains? (get transitions from) status)
+ (ex/raise :type :validation
+ :code :invalid-task-transition
+ :hint "the task cannot move to that state from the one it is in"
+ :from from
+ :to status))
+ (db/update! conn :file-task
+ {:status status
+ :status-changed-at ts
+ :status-changed-by profile-id
+ :updated-at ts}
+ {:id id}
+ {::db/return-keys false})
+ (insert-event conn id profile-id "status" {:from from :to status})
+ (assoc task
+ :status status
+ :status-changed-at ts
+ :status-changed-by profile-id))))))
+
+;; --- COMMAND: relink-task
+
+(def ^:private schema:relink-task
+ [:map {:title "relink-task" :closed true}
+ [:id ::sm/uuid]
+ [:page-id ::sm/uuid]
+ [:frame-id ::sm/uuid]
+ [:shape-id ::sm/uuid]
+ ;; the name the layer has now, kept in the event
+ [:shape-name [:string {:max 250}]]])
+
+(sv/defmethod ::relink-task
+ "Point a task at another layer. A task whose layer was deleted stops
+ being lost."
+ {::doc/added "2.16"
+ ::sm/params schema:relink-task}
+ [cfg {:keys [::rpc/profile-id id page-id frame-id shape-id shape-name]}]
+ (check-tasks-enabled)
+ (let [task (db/run! cfg (fn [{:keys [::db/conn]}] (get-task conn id)))]
+ (files/check-read-permissions! cfg profile-id (:file-id task))
+ (run-and-notify
+ cfg (:file-id task) profile-id
+ (fn [{:keys [::db/conn]}]
+ (let [changes {:page-id page-id
+ :frame-id frame-id
+ :shape-id shape-id
+ :lost-shape-name nil
+ :updated-at (ct/now)}]
+ (db/update! conn :file-task changes {:id id} {::db/return-keys false})
+ (insert-event conn id profile-id "relinked" {:shape-id shape-id :shape-name shape-name})
+ (merge (get-task conn id) changes))))))
+
+;; --- COMMAND: mark-tasks-layer-deleted
+
+(def ^:private schema:deleted-layer
+ [:map {:title "DeletedTaskLayer"}
+ [:shape-id ::sm/uuid]
+ [:shape-name [:string {:max 250}]]
+ ;; the board the task moves to, and its name for the event
+ [:frame-id ::sm/uuid]
+ [:frame-name {:optional true} [:maybe [:string {:max 250}]]]
+ ;; the layer as it was (the shape and its children), what "restore
+ ;; layer" puts back
+ [:objects {:optional true} [:vector {:max 500} :map]]])
+
+(def ^:private schema:mark-tasks-layer-deleted
+ [:map {:title "mark-tasks-layer-deleted" :closed true}
+ [:file-id ::sm/uuid]
+ [:layers [:vector {:min 1 :max 200} schema:deleted-layer]]])
+
+(def ^:private sql:get-tasks-of-layers
+ "SELECT * FROM file_task
+ WHERE file_id = ?
+ AND shape_id = ANY(?)
+ AND lost_shape_name IS NULL
+ AND status NOT IN ('verified', 'wont-do')
+ AND deleted_at IS NULL
+ FOR UPDATE")
+
+(sv/defmethod ::mark-tasks-layer-deleted
+ "Tell the server that layers with open tasks were deleted: each task
+ moves to the board that held its layer and keeps the name of the lost
+ layer until it is linked to another one. The event of each task keeps
+ the deleted layer, so it can be restored later. Returns the tasks it
+ moved."
+ {::doc/added "2.16"
+ ::sm/params schema:mark-tasks-layer-deleted}
+ [cfg {:keys [::rpc/profile-id file-id layers]}]
+ (check-tasks-enabled)
+ (files/check-read-permissions! cfg profile-id file-id)
+ (run-and-notify
+ cfg file-id profile-id
+ (fn [{:keys [::db/conn]}]
+ (let [by-shape (d/index-by :shape-id layers)
+ ids (db/create-array conn "uuid" (vec (keys by-shape)))
+ tasks (into [] (map decode-row) (db/exec! conn [sql:get-tasks-of-layers file-id ids]))
+ ts (ct/now)]
+ (into []
+ (map (fn [{:keys [id shape-id] :as task}]
+ (let [{:keys [shape-name frame-id frame-name objects]} (get by-shape shape-id)
+ changes {:lost-shape-name shape-name
+ :frame-id frame-id
+ :updated-at ts}]
+ (db/update! conn :file-task changes {:id id} {::db/return-keys false})
+ (insert-event conn id profile-id "layer-deleted"
+ {:shape-id shape-id
+ :shape-name shape-name
+ :frame-id frame-id
+ :frame-name frame-name
+ :objects objects})
+ (merge task changes))))
+ tasks)))))
+
+;; --- COMMAND: mark-task-layer-restored
+
+(def ^:private schema:mark-task-layer-restored
+ [:map {:title "mark-task-layer-restored" :closed true}
+ [:id ::sm/uuid]
+ [:frame-id ::sm/uuid]])
+
+(sv/defmethod ::mark-task-layer-restored
+ "The deleted layer of a task is back (undone, or restored from the
+ task): the task points at it again."
+ {::doc/added "2.16"
+ ::sm/params schema:mark-task-layer-restored}
+ [cfg {:keys [::rpc/profile-id id frame-id]}]
+ (check-tasks-enabled)
+ (let [task (db/run! cfg (fn [{:keys [::db/conn]}] (get-task conn id)))]
+ (files/check-read-permissions! cfg profile-id (:file-id task))
+ (run-and-notify
+ cfg (:file-id task) profile-id
+ (fn [{:keys [::db/conn]}]
+ (let [changes {:lost-shape-name nil
+ :frame-id frame-id
+ :updated-at (ct/now)}]
+ (db/update! conn :file-task changes {:id id} {::db/return-keys false})
+ (insert-event conn id profile-id "layer-restored"
+ {:shape-id (:shape-id task)
+ :shape-name (:lost-shape-name task)})
+ (merge task changes))))))
+
+;; --- COMMAND: delete-task
+
+(def ^:private schema:delete-task
+ [:map {:title "delete-task" :closed true}
+ [:id ::sm/uuid]])
+
+(sv/defmethod ::delete-task
+ "Delete a task. Its thread stays: the message the task lived in goes
+ on as a plain comment."
+ {::doc/added "2.16"
+ ::sm/params schema:delete-task}
+ [cfg {:keys [::rpc/profile-id id]}]
+ (check-tasks-enabled)
+ (let [task (db/run! cfg (fn [{:keys [::db/conn]}] (get-task conn id)))]
+ (files/check-read-permissions! cfg profile-id (:file-id task))
+ (run-and-notify
+ cfg (:file-id task) profile-id
+ (fn [{:keys [::db/conn]}]
+ (db/update! conn :file-task
+ {:deleted-at (ct/now) :updated-at (ct/now)}
+ {:id id}
+ {::db/return-keys false})
+ nil))))
+
+;; --- Review counts
+
+(def ^:private sql:get-review-task-counts
+ "SELECT pull_request_id, status, count(*) AS total
+ FROM file_task
+ WHERE pull_request_id = ANY(?)
+ AND deleted_at IS NULL
+ GROUP BY pull_request_id, status")
+
+(def ^:private sql:get-review-comment-counts
+ "SELECT pull_request_id, is_resolved, count(*) AS total
+ FROM comment_thread
+ WHERE pull_request_id = ANY(?)
+ GROUP BY pull_request_id, is_resolved")
+
+(defn get-review-counts
+ "{pull-request-id {:tasks {status count} :comments-open n
+ :comments-resolved n}} for the given design reviews."
+ [conn pull-request-ids]
+ (if (empty? pull-request-ids)
+ {}
+ (let [ids (db/create-array conn "uuid" (vec pull-request-ids))
+ empty {:tasks {} :comments-open 0 :comments-resolved 0}
+ by-tasks (reduce (fn [acc {:keys [pull-request-id status total]}]
+ (assoc-in acc [pull-request-id :tasks status] total))
+ {}
+ (db/exec! conn [sql:get-review-task-counts ids]))]
+ (reduce (fn [acc {:keys [pull-request-id is-resolved total]}]
+ (update acc pull-request-id
+ (fn [counts]
+ (assoc (merge empty counts)
+ (if is-resolved :comments-resolved :comments-open)
+ total))))
+ (update-vals by-tasks #(merge empty %))
+ (db/exec! conn [sql:get-review-comment-counts ids])))))
+
+;; --- Merge: move the tasks of a branch into main
+
+(def ^:private sql:get-branch-tasks
+ "SELECT * FROM file_task
+ WHERE file_id = ?
+ AND deleted_at IS NULL
+ ORDER BY created_at ASC
+ FOR UPDATE")
+
+(def ^:private sql:lock-thread-seqn
+ "SELECT comment_thread_seqn FROM file WHERE id = ? FOR UPDATE")
+
+(defn- move-threads
+ "Move the comment threads `thread-ids` of the branch into main. The
+ number of a thread is unique in its file, so each one takes the next
+ number of main."
+ [conn main-id thread-ids]
+ (when (seq thread-ids)
+ (let [seqn (-> (db/exec-one! conn [sql:lock-thread-seqn main-id])
+ (:comment-thread-seqn 0))]
+ (doseq [[index thread-id] (d/enumerate thread-ids)]
+ (db/update! conn :comment-thread
+ {:file-id main-id
+ :seqn (+ seqn index 1)}
+ {:id thread-id}
+ {::db/return-keys false}))
+ (db/update! conn :file
+ {:comment-thread-seqn (+ seqn (count thread-ids))}
+ {:id main-id}
+ {::db/return-keys false}))))
+
+(defn- send-tasks-moved-emails
+ [{:keys [::db/conn] :as cfg} {:keys [team-id main-id actor-id branch-name file-name]} tasks]
+ (let [users (->> (teams/get-users+props conn team-id)
+ (map profile/decode-row)
+ (d/index-by :id))
+ actor (get-in users [actor-id :fullname] "")]
+ (doseq [[assignee-id tasks] (group-by :assignee-id tasks)]
+ (when-let [{:keys [fullname email]} (and (some? assignee-id)
+ (not= assignee-id actor-id)
+ (get users assignee-id))]
+ (eml/send-template
+ cfg
+ {::eml/reuse-conn true
+ ::eml/template "tasks-moved"
+ :public-uri (cf/get :public-uri)
+ :to email
+ :name fullname
+ :source-user actor
+ :branch-name branch-name
+ :file-name file-name
+ :task-titles (str/join "\n" (map #(str "- " (:title %)) tasks))
+ :file-url (str/join [(cf/get :public-uri)
+ "/#/workspace?"
+ (uri/map->query-string {:file-id main-id
+ :team-id team-id})])})))))
+
+(defn move-branch-tasks
+ "Move every task of the branch file into main, inside the merge
+ transaction: the open ones keep going on main, the closed ones stay as
+ the history of the branch. Each task keeps the names it shows (the
+ review title is refreshed from its pull request, which goes away with
+ the branch), records the merge and gets a `moved-to-main` event. The
+ threads of the tasks move with them. When `notify-assignees` is set,
+ the assignees of the open tasks are told by email. Returns the moved
+ tasks."
+ [{:keys [::db/conn] :as cfg}
+ {:keys [branch-file-id main-id merge-id branch-name profile-id notify-assignees]}]
+ (let [tasks (db/exec! conn [sql:get-branch-tasks branch-file-id])]
+ (when (seq tasks)
+ (let [reviews (->> (keep :pull-request-id tasks)
+ (distinct)
+ (map #(db/get* conn :file-pull-request {:id %}))
+ (remove nil?)
+ (d/index-by :id))
+ ts (ct/now)]
+ (move-threads conn main-id (into [] (comp (keep :thread-id) (distinct)) tasks))
+ (doseq [{:keys [id pull-request-id review-title] :as task} tasks]
+ (db/update! conn :file-task
+ {:file-id main-id
+ :merge-id merge-id
+ :branch-name branch-name
+ :review-title (or (get-in reviews [pull-request-id :title]) review-title)
+ :updated-at ts}
+ {:id id}
+ {::db/return-keys false})
+ (insert-event conn (:id task) profile-id "moved-to-main"
+ {:merge-id merge-id :branch-name branch-name}))
+ (when notify-assignees
+ (let [main (db/get conn :file {:id main-id} {::sql/columns [:name]})]
+ (send-tasks-moved-emails cfg
+ {:team-id (perms/get-team-id-for-file conn main-id)
+ :main-id main-id
+ :actor-id profile-id
+ :branch-name branch-name
+ :file-name (:name main)}
+ (remove #(contains? closed-statuses (:status %)) tasks))))
+ tasks))))
diff --git a/backend/src/app/rpc/commands/files_update.clj b/backend/src/app/rpc/commands/files_update.clj
index 9b5d00b9eb..f73670bac2 100644
--- a/backend/src/app/rpc/commands/files_update.clj
+++ b/backend/src/app/rpc/commands/files_update.clj
@@ -14,6 +14,7 @@
[app.common.files.changes :as cpc]
[app.common.files.migrations :as fmg]
[app.common.files.repair :as cfr]
+ [app.common.files.review-activity :as ra]
[app.common.files.validate :as val]
[app.common.logging :as l]
[app.common.schema :as sm]
@@ -329,6 +330,47 @@
:reprocess-changes-ms (get timings :reprocess-changes-ms)))
(throw cause))))))
+;; --- Design review activity
+
+(def ^:private sql:get-open-review-of-branch-file
+ "SELECT id FROM file_pull_request
+ WHERE source_file_id = ?
+ AND status = 'open'
+ AND deleted_at IS NULL")
+
+(defn- get-open-review-id
+ "The open design review of a branch file, if it has one."
+ [conn file-id]
+ (:id (db/exec-one! conn [sql:get-open-review-of-branch-file file-id])))
+
+(defn- track-review-activity
+ "Wrap the changes application of a save so it also works out what the
+ save did to each layer it touched, into the volatile `activity`: the
+ touched layers are read before the changes apply and again after (see
+ `app.common.files.review-activity`). Only the changes the save
+ accepted (`::changes`) count: a rejected commit touched nothing."
+ [update-fn activity]
+ (fn [cfg file changes commits skip-validate]
+ (let [before (ra/collect-before (:data file) (ra/touched changes))
+ result (update-fn cfg file changes commits skip-validate)]
+ (vreset! activity (ra/entries before (:data result) (ra/touched (::changes result))))
+ result)))
+
+(defn- record-review-activity
+ "Record the activity of a save of a branch under design review: who
+ saved, the revn the save produced and what it did to each layer. A save
+ that changed no layer records nothing."
+ [conn review-id profile-id {:keys [revn]} entries timestamp]
+ (when (seq entries)
+ (db/insert! conn :file-pull-request-activity
+ {:id (uuid/next)
+ :pull-request-id review-id
+ :profile-id profile-id
+ :revn revn
+ :entries (blob/encode entries)
+ :created-at timestamp}
+ {::db/return-keys false})))
+
(defn- update-file*
"Internal function, part of the update-file process, that encapsulates
the changes application offload to a separated thread and emit all
@@ -358,11 +400,22 @@
revn
(get file :revn)
+ ;; A save of a branch under design review records what it did
+ ;; to each layer, for the activity of the review.
+ review-id
+ (when (:is-branch file)
+ (get-open-review-id conn (:id file)))
+
+ activity
+ (volatile! nil)
+
file
(binding [cfeat/*current* features
cfeat/*previous* (:features file)]
(update-file-data! cfg file
- process-changes-and-validate
+ (if review-id
+ (track-review-activity process-changes-and-validate activity)
+ process-changes-and-validate)
changes commits skip-validate))
;; Only the accepted changes are stored and broadcast. The xlog
@@ -469,6 +522,10 @@
(when (contains? cf/flags :redis-cache)
(invalidate-caches! cfg file))
+ (when review-id
+ (record-review-activity conn review-id profile-id file @activity
+ (or timestamp (ct/now))))
+
;; Send asynchronous notifications
(when repair
(send-repair-notifications cfg params file repair))
diff --git a/backend/test/backend_tests/climit_test.clj b/backend/test/backend_tests/climit_test.clj
index 090ae4d6b8..9a40857d55 100644
--- a/backend/test/backend_tests/climit_test.clj
+++ b/backend/test/backend_tests/climit_test.clj
@@ -22,21 +22,28 @@
(def ^:private calls (atom []))
(defn- record-metrics
- "Run `f` recording every metrics call it makes."
+ "Run `f` recording every metrics call made while it runs, with the thread
+ that made it: `with-redefs` is global, so other threads of the test JVM
+ record into the same atom."
[f]
(reset! calls [])
(with-redefs [mtx/run!
(fn [_ & {:keys [id labels val]}]
- (swap! calls conj {:id id :labels (vec labels) :val val}))]
+ (swap! calls conj {:id id :labels (vec labels) :val val
+ :thread (Thread/currentThread)}))]
(f)))
(defn- acquired-in-order
- "Limiter names acquired so far, in acquisition order."
+ "Limiter names the calling thread acquired so far, in acquisition order. A
+ call of another thread, such as an RPC left running by an earlier test, can
+ take a root limiter inside the window and must not count."
[]
- (->> @calls
- (filter #(= :rpc-climit-timing (:id %)))
- (mapcat :labels)
- (vec)))
+ (let [thread (Thread/currentThread)]
+ (->> @calls
+ (filter #(= :rpc-climit-timing (:id %)))
+ (filter #(identical? thread (:thread %)))
+ (mapcat :labels)
+ (vec))))
(defn- invoke!
"Run `f` under the limits the cfg declares, the way a command does: the key
diff --git a/backend/test/backend_tests/email_sending_test.clj b/backend/test/backend_tests/email_sending_test.clj
index 36b602441f..8f54bb023a 100644
--- a/backend/test/backend_tests/email_sending_test.clj
+++ b/backend/test/backend_tests/email_sending_test.clj
@@ -174,7 +174,7 @@
"request-file-access" "request-file-access-yourpenpot"
"request-file-access-yourpenpot-view" "request-team-access"
"comment-mention" "comment-thread" "comment-notification"
- "review-request"}
+ "review-request" "task-assigned" "tasks-moved"}
(set (keys emails/templates)))))
(t/deftest send-template-validation
diff --git a/backend/test/backend_tests/rpc_file_task_test.clj b/backend/test/backend_tests/rpc_file_task_test.clj
new file mode 100644
index 0000000000..fefe1de104
--- /dev/null
+++ b/backend/test/backend_tests/rpc_file_task_test.clj
@@ -0,0 +1,426 @@
+;; 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 INC Sucursal en España SL
+
+(ns backend-tests.rpc-file-task-test
+ (:require
+ [app.common.features :as cfeat]
+ [app.common.geom.point :as gpt]
+ [app.common.types.shape :as cts]
+ [app.common.uuid :as uuid]
+ [app.config :as cf]
+ [app.db :as db]
+ [app.email :as eml]
+ [app.rpc :as-alias rpc]
+ [backend-tests.helpers :as th]
+ [clojure.test :as t]))
+
+(t/use-fixtures :once th/state-init)
+(t/use-fixtures :each th/database-reset)
+
+(defn- task-flags
+ "The test flags plus `:branching`. Read at run time, inside the
+ `th/state-init` fixture, so the flags it turns off (the admin
+ console among them) stay off: a value captured when the namespace
+ loads would carry the production defaults instead."
+ []
+ (conj cf/flags :branching))
+
+(defn- page-id-of
+ [profile file-id]
+ (-> (th/command! {::th/type :get-file
+ ::rpc/profile-id (:id profile)
+ :id file-id})
+ :result :data :pages first))
+
+(defn- update-file*
+ [profile file-id changes]
+ (let [f (th/db-get :file {:id file-id})]
+ (th/command! {::th/type :update-file
+ ::rpc/profile-id (:id profile)
+ :id file-id
+ :session-id (uuid/random)
+ :revn (:revn f)
+ :vern (:vern f)
+ :features cfeat/supported-features
+ :changes changes})))
+
+(defn- add-rect*
+ [profile file-id page-id rect-id name]
+ (update-file* profile file-id
+ [{:type :add-obj
+ :page-id page-id
+ :id rect-id
+ :parent-id uuid/zero
+ :frame-id uuid/zero
+ :obj (cts/setup-shape
+ {:id rect-id :name name :type :rect
+ :parent-id uuid/zero :frame-id uuid/zero})}]))
+
+(defn- setup-review
+ "A file with a rect on main, a branch of it and an open design review of
+ the branch. Returns the ids the tests need."
+ []
+ (let [author (th/create-profile* 1 {:is-active true})
+ reviewer (th/create-profile* 2 {:is-active true})
+ file (th/create-file* 1 {:profile-id (:id author)
+ :project-id (:default-project-id author)})
+ page-id (page-id-of author (:id file))
+ rect-id (uuid/random)]
+ (th/create-team-role* {:team-id (:default-team-id author)
+ :profile-id (:id reviewer)
+ :role :editor})
+ (add-rect* author (:id file) page-id rect-id "Pay button")
+ (let [branch (:result (th/command! {::th/type :create-file-branch
+ ::rpc/profile-id (:id author)
+ :file-id (:id file)
+ :name "feature-login"}))
+ review (:result (th/command! {::th/type :create-pull-request
+ ::rpc/profile-id (:id author)
+ :branch-id (:id branch)
+ :title "Checkout redesign"
+ :reviewers [(:id reviewer)]}))]
+ {:author author
+ :reviewer reviewer
+ :file file
+ :page-id page-id
+ :rect-id rect-id
+ :branch branch
+ :branch-file-id (:branch-file-id branch)
+ :review review})))
+
+(defn- create-task*
+ [profile params]
+ (th/command! (merge {::th/type :create-task
+ ::rpc/profile-id (:id profile)
+ :frame-id uuid/zero
+ :position (gpt/point 0)
+ :title "Use the secondary token on the pay button"}
+ params)))
+
+(defn- set-status*
+ [profile task-id status]
+ (th/command! {::th/type :set-task-status
+ ::rpc/profile-id (:id profile)
+ :id task-id
+ :status status}))
+
+(t/deftest task-lifecycle-records-who-made-each-move
+ (with-redefs [cf/flags (task-flags)
+ eml/send-template (fn [_ _] nil)]
+ (let [{:keys [author reviewer page-id rect-id branch-file-id review]} (setup-review)
+ out (create-task* reviewer {:file-id branch-file-id
+ :page-id page-id
+ :shape-id rect-id
+ :assignee-id (:id author)
+ :pull-request-id (:id review)})
+ task (:result out)]
+ (t/is (nil? (:error out)))
+ (t/is (= "open" (:status task)))
+ (t/is (= "Checkout redesign" (:review-title task)))
+
+ (t/testing "the assignee marks it done and the reviewer verifies it"
+ (t/is (nil? (:error (set-status* author (:id task) "done"))))
+ (t/is (nil? (:error (set-status* reviewer (:id task) "verified")))))
+
+ (t/testing "every move is an event with who made it"
+ (let [events (:result (th/command! {::th/type :get-task-events
+ ::rpc/profile-id (:id author)
+ :id (:id task)}))]
+ (t/is (= ["created" "assigned" "status" "status"] (mapv :type events)))
+ (t/is (= [(:id reviewer) (:id reviewer) (:id author) (:id reviewer)]
+ (mapv :profile-id events)))
+ (t/is (= {:from "done" :to "verified"} (:payload (last events))))))
+
+ (t/testing "the review counts its tasks"
+ (let [row (:result (th/command! {::th/type :get-pull-request
+ ::rpc/profile-id (:id author)
+ :id (:id review)}))]
+ (t/is (= {"verified" 1} (-> row :counts :tasks))))))))
+
+(t/deftest task-refuses-a-move-its-state-does-not-allow
+ (with-redefs [cf/flags (task-flags)]
+ (let [{:keys [author page-id branch-file-id]} (setup-review)
+ task (:result (create-task* author {:file-id branch-file-id :page-id page-id}))
+ out (set-status* author (:id task) "verified")]
+ (t/is (= :invalid-task-transition (-> out :error ex-data :code))))))
+
+(t/deftest task-assignee-must-be-a-team-member
+ (with-redefs [cf/flags (task-flags)]
+ (let [{:keys [author page-id branch-file-id]} (setup-review)
+ stranger (th/create-profile* 3 {:is-active true})
+ out (create-task* author {:file-id branch-file-id
+ :page-id page-id
+ :assignee-id (:id stranger)})]
+ (t/is (= :assignee-not-team-member (-> out :error ex-data :code))))))
+
+(t/deftest deleted-layer-moves-its-task-to-the-board
+ (with-redefs [cf/flags (task-flags)]
+ (let [{:keys [author page-id rect-id branch-file-id]} (setup-review)
+ board-id (uuid/random)
+ task (:result (create-task* author {:file-id branch-file-id
+ :page-id page-id
+ :shape-id rect-id}))
+ out (th/command! {::th/type :mark-tasks-layer-deleted
+ ::rpc/profile-id (:id author)
+ :file-id branch-file-id
+ :layers [{:shape-id rect-id
+ :shape-name "Pay button"
+ :frame-id board-id
+ :frame-name "Checkout / Mobile"
+ :objects [{:id rect-id :name "Pay button" :type :rect}]}]})]
+ (t/is (nil? (:error out)))
+ (t/is (= 1 (count (:result out))))
+ (let [row (th/db-get :file-task {:id (:id task)})]
+ (t/is (= "Pay button" (:lost-shape-name row)))
+ (t/is (= board-id (:frame-id row))))
+
+ (t/testing "restoring the layer clears the loss"
+ (th/command! {::th/type :mark-task-layer-restored
+ ::rpc/profile-id (:id author)
+ :id (:id task)
+ :frame-id uuid/zero})
+ (t/is (nil? (:lost-shape-name (th/db-get :file-task {:id (:id task)}))))))))
+
+(t/deftest review-thread-points-at-a-layer
+ (with-redefs [cf/flags (task-flags)]
+ (let [{:keys [reviewer page-id rect-id branch-file-id review]} (setup-review)
+ out (th/command! {::th/type :create-comment-thread
+ ::rpc/profile-id (:id reviewer)
+ :file-id branch-file-id
+ :page-id page-id
+ :frame-id uuid/zero
+ :position (gpt/point 10 20)
+ :content "The pay button loses contrast"
+ :pull-request-id (:id review)
+ :anchor {:type :layer :shape-id rect-id}})]
+ (t/is (nil? (:error out)))
+ (let [[thread] (:result (th/command! {::th/type :get-comment-threads
+ ::rpc/profile-id (:id reviewer)
+ :file-id branch-file-id}))]
+ (t/is (= (:id review) (:pull-request-id thread)))
+ (t/is (= "Checkout redesign" (:pull-request-title thread)))
+ (t/is (= :layer (:anchor-type thread)))
+ (t/is (= rect-id (:shape-id thread)))))))
+
+(t/deftest review-thread-refuses-a-review-of-another-file
+ (with-redefs [cf/flags (task-flags)]
+ (let [{:keys [reviewer page-id file review]} (setup-review)
+ out (th/command! {::th/type :create-comment-thread
+ ::rpc/profile-id (:id reviewer)
+ :file-id (:id file)
+ :page-id page-id
+ :frame-id uuid/zero
+ :position (gpt/point 0)
+ :content "on main"
+ :pull-request-id (:id review)})]
+ (t/is (= :pull-request-not-open (-> out :error ex-data :code))))))
+
+(t/deftest branch-save-under-review-records-its-activity
+ (with-redefs [cf/flags (task-flags)]
+ (let [{:keys [author page-id rect-id branch-file-id review]} (setup-review)]
+ (update-file* author branch-file-id
+ [{:type :mod-obj :page-id page-id :id rect-id
+ :operations [{:type :set :attr :name :val "Pay"}]}])
+ (let [[row :as rows] (:result (th/command! {::th/type :get-pull-request-activity
+ ::rpc/profile-id (:id author)
+ :id (:id review)}))]
+ (t/is (= 1 (count rows)))
+ (t/is (= (:id author) (:profile-id row)))
+ (t/is (= [{:id rect-id :kind :modified :attrs {:name ["Pay button" "Pay"]}}]
+ (mapv #(select-keys % [:id :kind :attrs]) (:entries row))))))))
+
+(t/deftest merge-moves-the-tasks-and-their-threads-into-main
+ (with-redefs [cf/flags (task-flags)
+ eml/send-template (fn [_ _] nil)]
+ (let [{:keys [author page-id rect-id file branch branch-file-id review]} (setup-review)
+ ;; main has a thread of its own already: the moved one must not
+ ;; take its number
+ _ (th/command! {::th/type :create-comment-thread
+ ::rpc/profile-id (:id author)
+ :file-id (:id file)
+ :page-id page-id
+ :frame-id uuid/zero
+ :position (gpt/point 0)
+ :content "on main"})
+ thread (:result (th/command! {::th/type :create-comment-thread
+ ::rpc/profile-id (:id author)
+ :file-id branch-file-id
+ :page-id page-id
+ :frame-id uuid/zero
+ :position (gpt/point 0)
+ :content "fix the radius"
+ :pull-request-id (:id review)}))
+ open (:result (create-task* author {:file-id branch-file-id
+ :page-id page-id
+ :shape-id rect-id
+ :thread-id (:id thread)
+ :pull-request-id (:id review)}))
+ closed (:result (create-task* author {:file-id branch-file-id
+ :page-id page-id
+ :title "Drop the promo"}))]
+ (set-status* author (:id closed) "wont-do")
+ (update-file* author branch-file-id
+ [{:type :mod-obj :page-id page-id :id rect-id
+ :operations [{:type :set :attr :name :val "Pay"}]}])
+
+ (let [out (th/command! {::th/type :merge-file-branch
+ ::rpc/profile-id (:id author)
+ :branch-id (:id branch)
+ :notify-assignees true})]
+ (t/is (nil? (:error out))))
+
+ (let [tasks (:result (th/command! {::th/type :get-file-tasks
+ ::rpc/profile-id (:id author)
+ :file-id (:id file)}))
+ [merge-row] (th/db-query :file-branch-merge {:file-id (:id file)})]
+ (t/is (= #{(:id open) (:id closed)} (into #{} (map :id) tasks)))
+ (t/is (every? #(= (:id merge-row) (:merge-id %)) tasks))
+ (t/is (every? #(= "feature-login" (:branch-name %)) tasks))
+ (t/is (= "Checkout redesign"
+ (:review-title (th/db-get :file-task {:id (:id open)})))))
+
+ (t/testing "the threads move with their tasks and take the next numbers of main"
+ (let [moved (th/db-get :comment-thread {:id (:id thread)})
+ closed (th/db-get :comment-thread {:id (:thread-id closed)})]
+ (t/is (= (:id file) (:file-id moved)))
+ (t/is (= (:id file) (:file-id closed)))
+ (t/is (= [2 3] [(:seqn moved) (:seqn closed)]))
+ (t/is (= 3 (:comment-thread-seqn (th/db-get :file {:id (:id file)}
+ {::db/remove-deleted false})))))))))
+
+(t/deftest each-message-of-a-thread-may-be-a-task
+ (with-redefs [cf/flags (task-flags)]
+ (let [{:keys [author page-id branch-file-id]} (setup-review)
+ thread (:result (th/command! {::th/type :create-comment-thread
+ ::rpc/profile-id (:id author)
+ :file-id branch-file-id
+ :page-id page-id
+ :frame-id uuid/zero
+ :position (gpt/point 0)
+ :content "fix the radius"}))
+ reply (:result (th/command! {::th/type :create-comment
+ ::rpc/profile-id (:id author)
+ :thread-id (:id thread)
+ :content "and the shadow"}))
+ messages (:result (th/command! {::th/type :get-comments
+ ::rpc/profile-id (:id author)
+ :thread-id (:id thread)}))
+ first-id (:id (first (sort-by :created-at messages)))
+ from (fn [comment-id]
+ (create-task* author {:file-id branch-file-id
+ :page-id page-id
+ :thread-id (:id thread)
+ :comment-id comment-id}))]
+
+ (t/testing "a thread holds a task per message"
+ (t/is (nil? (:error (from first-id))))
+ (t/is (nil? (:error (from (:id reply)))))
+ (let [tasks (:result (th/command! {::th/type :get-file-tasks
+ ::rpc/profile-id (:id author)
+ :file-id branch-file-id}))]
+ (t/is (= #{first-id (:id reply)} (into #{} (map :comment-id) tasks)))))
+
+ (t/testing "a message holds one task"
+ (t/is (= :comment-already-has-task (-> (from first-id) :error ex-data :code))))
+
+ (t/testing "a message of another thread is refused"
+ (let [other (:result (th/command! {::th/type :create-comment-thread
+ ::rpc/profile-id (:id author)
+ :file-id branch-file-id
+ :page-id page-id
+ :frame-id uuid/zero
+ :position (gpt/point 0)
+ :content "another one"}))
+ out (create-task* author {:file-id branch-file-id
+ :page-id page-id
+ :thread-id (:id other)
+ :comment-id (:id reply)})]
+ (t/is (= :comment-not-in-thread (-> out :error ex-data :code))))))))
+
+(t/deftest task-on-the-canvas-keeps-its-position
+ (with-redefs [cf/flags (task-flags)]
+ (let [{:keys [author page-id branch-file-id]} (setup-review)
+ out (create-task* author {:file-id branch-file-id
+ :page-id page-id
+ :position (gpt/point 120 340)})
+ task (:result out)]
+ (t/is (nil? (:error out)))
+ (t/is (nil? (:shape-id task)))
+ (let [[row] (:result (th/command! {::th/type :get-file-tasks
+ ::rpc/profile-id (:id author)
+ :file-id branch-file-id}))]
+ (t/is (= {:x 120.0 :y 340.0} (into {} (:position row)))))
+ (t/testing "a move of its state answers with the task"
+ (t/is (nil? (:error (set-status* author (:id task) "done"))))))))
+
+(t/deftest task-created-on-the-canvas-gets-a-thread
+ (with-redefs [cf/flags (task-flags)
+ eml/send-template (fn [_ _] nil)]
+ (let [{:keys [author reviewer page-id rect-id branch-file-id review]} (setup-review)
+ out (create-task* reviewer {:file-id branch-file-id
+ :page-id page-id
+ :shape-id rect-id
+ :position (gpt/point 30 40)
+ :title " Use the secondary token "
+ :pull-request-id (:id review)})
+ task (:result out)]
+ (t/is (nil? (:error out)))
+ (t/is (some? (:thread-id task)))
+ (t/is (some? (:comment-id task)))
+
+ (t/testing "the thread points at the layer of the task, in its review"
+ (let [thread (th/db-get :comment-thread {:id (:thread-id task)})]
+ (t/is (= branch-file-id (:file-id thread)))
+ (t/is (= (:id reviewer) (:owner-id thread)))
+ (t/is (= (:id review) (:pull-request-id thread)))
+ (t/is (= "layer" (:anchor-type thread)))
+ (t/is (= rect-id (:shape-id thread)))))
+
+ (t/testing "its first message is the title and holds the task"
+ (let [[message] (:result (th/command! {::th/type :get-comments
+ ::rpc/profile-id (:id author)
+ :thread-id (:thread-id task)}))]
+ (t/is (= (:comment-id task) (:id message)))
+ (t/is (= "Use the secondary token" (:content message)))))
+
+ (t/testing "anybody can go on commenting in it"
+ (let [out (th/command! {::th/type :create-comment
+ ::rpc/profile-id (:id author)
+ :thread-id (:thread-id task)
+ :content "On it"})]
+ (t/is (nil? (:error out)))
+ (t/is (= 2 (count (th/db-query :comment {:thread-id (:thread-id task)})))))))))
+
+(t/deftest task-on-the-empty-canvas-gets-a-thread-on-its-spot
+ (with-redefs [cf/flags (task-flags)]
+ (let [{:keys [author page-id branch-file-id]} (setup-review)
+ task (:result (create-task* author {:file-id branch-file-id
+ :page-id page-id
+ :position (gpt/point 120 340)}))
+ thread (th/db-get :comment-thread {:id (:thread-id task)})]
+ (t/is (= "canvas" (:anchor-type thread)))
+ (t/is (nil? (:shape-id thread)))
+ (t/is (nil? (:pull-request-id thread)))
+ (t/is (= {:x 120.0 :y 340.0} (into {} (db/decode-pgpoint (:position thread))))))))
+
+(t/deftest deleting-a-thread-deletes-its-tasks
+ (with-redefs [cf/flags (task-flags)]
+ (let [{:keys [author page-id branch-file-id]} (setup-review)
+ task (:result (create-task* author {:file-id branch-file-id :page-id page-id}))
+ other (:result (create-task* author {:file-id branch-file-id
+ :page-id page-id
+ :title "Another one"}))
+ out (th/command! {::th/type :delete-comment-thread
+ ::rpc/profile-id (:id author)
+ :id (:thread-id task)})]
+ (t/is (nil? (:error out)))
+ (t/is (nil? (th/db-get :comment-thread {:id (:thread-id task)})))
+ (t/is (some? (:deleted-at (th/db-get :file-task {:id (:id task)}
+ {::db/remove-deleted false}))))
+ (t/is (= [(:id other)]
+ (mapv :id (:result (th/command! {::th/type :get-file-tasks
+ ::rpc/profile-id (:id author)
+ :file-id branch-file-id}))))))))
diff --git a/common/src/app/common/files/review_activity.cljc b/common/src/app/common/files/review_activity.cljc
new file mode 100644
index 0000000000..4a1791a688
--- /dev/null
+++ b/common/src/app/common/files/review_activity.cljc
@@ -0,0 +1,290 @@
+;; 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 INC Sucursal en España SL
+
+(ns app.common.files.review-activity
+ "What the saves of a branch under design review did to its layers.
+
+ The backend records one row per branch save while a review is open
+ (`file_pull_request_activity`). `entries` builds that row from the
+ change vector of the save and the file data before and after it: one
+ entry per touched layer, with the kind of change and, for a modified
+ layer, the value before and after of each property a person reads.
+
+ The reading side folds those rows: `net-entries` gives what each layer
+ ends up as since the review opened (a layer added and then deleted is
+ no change at all), and `sessions` cuts the rows into the runs of saves
+ one person made in one sitting, the groups the activity list shows."
+ (:require
+ [app.common.data :as d]
+ [app.common.uuid :as uuid]))
+
+(def tracked-attrs
+ "The properties whose value before and after a modified entry keeps:
+ the ones a person reads in the review, plus the applied tokens, which
+ tell that a value now comes from a token."
+ #{:name :fills :strokes :r1 :r2 :r3 :r4 :x :y :width :height :rotation
+ :opacity :hidden :blocked :blend-mode :content :shadow :blur
+ :layout-gap :layout-padding :layout-flex-dir :layout-item-h-sizing
+ :layout-item-v-sizing :constraints-h :constraints-v :grow-type
+ :applied-tokens :parent-id})
+
+(def ^:private derived-attrs
+ "The properties the editor recomputes from others. A save that touches
+ only these (the text position data recomputed after an edit, the
+ geometry kept in sync) is not a change a person made."
+ #{:position-data :selrect :points :transform :transform-inverse :touched})
+
+;; --- Building a row
+
+(defn- add-touch
+ "Fold one more touch of a layer into what the save did to it so far."
+ [prev kind attrs]
+ (case [(:kind prev) kind]
+ [nil :added] {:kind :added}
+ [nil :deleted] {:kind :deleted}
+ [nil :modified] {:kind :modified :attrs attrs}
+ [:added :modified] prev
+ [:added :deleted] {:kind :dropped}
+ [:added :added] prev
+ [:modified :modified] (update prev :attrs into attrs)
+ [:modified :deleted] {:kind :deleted}
+ [:modified :added] prev
+ [:deleted :added] {:kind :modified :attrs #{}}
+ [:deleted :modified] {:kind :modified :attrs attrs}
+ [:deleted :deleted] prev
+ [:dropped :added] {:kind :added}
+ prev))
+
+(defn- set-attrs
+ [operations]
+ (into #{}
+ (keep (fn [{:keys [type attr]}]
+ (when (= :set type) attr)))
+ operations))
+
+(defn touched
+ "What `changes` did to each layer of a page: `{[page-id id] {:kind
+ :attrs}}`, `:kind` one of `:added`, `:modified`, `:deleted` and
+ `:attrs` the properties a modification set. Changes to component
+ definitions and to file-level assets are not layers of a page and are
+ left out."
+ [changes]
+ (->> changes
+ (reduce
+ (fn [acc {:keys [type page-id id] :as change}]
+ (if (nil? page-id)
+ acc
+ (case type
+ :add-obj
+ (update acc [page-id id] add-touch :added nil)
+
+ :del-obj
+ (update acc [page-id id] add-touch :deleted nil)
+
+ :mod-obj
+ (update acc [page-id id] add-touch :modified (set-attrs (:operations change)))
+
+ :mov-objects
+ (reduce (fn [acc shape-id]
+ (update acc [page-id shape-id] add-touch :modified #{:parent-id}))
+ acc
+ (:shapes change))
+
+ acc)))
+ {})
+ (into {} (remove (fn [[_ {:keys [kind]}]] (= :dropped kind))))))
+
+(defn- get-object
+ [data page-id id]
+ (-> data
+ (get :pages-index)
+ (get page-id)
+ (get :objects)
+ (get id)))
+
+(defn- frame-name
+ [data page-id frame-id]
+ (when (and (some? frame-id) (not= uuid/zero frame-id))
+ (:name (get-object data page-id frame-id))))
+
+(defn collect-before
+ "The state before the save of every layer the save touches: the part
+ of each object `entries` needs, read from the file data the save
+ starts from. Only the touched layers are read, so a page the save does
+ not touch is never loaded."
+ [data touched]
+ (reduce-kv
+ (fn [acc [page-id id :as key] _]
+ (if-let [obj (get-object data page-id id)]
+ (assoc acc key (-> (select-keys obj tracked-attrs)
+ (assoc :type (:type obj))
+ (assoc :frame-id (:frame-id obj))
+ (assoc :frame-name (frame-name data page-id (:frame-id obj)))))
+ acc))
+ {}
+ touched))
+
+(defn- summary
+ [obj page-id id frame-name]
+ {:id id
+ :page-id page-id
+ :name (:name obj)
+ :type (:type obj)
+ :frame-id (:frame-id obj)
+ :frame-name frame-name})
+
+(defn- attr-diff
+ [before after attrs]
+ (into {}
+ (keep (fn [attr]
+ (let [b (get before attr)
+ a (get after attr)]
+ (when (not= b a)
+ [attr [b a]]))))
+ (filter tracked-attrs attrs)))
+
+(defn- root-of-kind?
+ "Whether the layer is the top of what the save added (or deleted): a
+ layer whose parent was added in the same save comes with it, and the
+ entry of its parent stands for both."
+ [touched kind page-id parent-id]
+ (not= kind (get-in touched [[page-id parent-id] :kind])))
+
+(defn entries
+ "The activity entries of one save, from the state `before` it
+ (`collect-before`), the file data `after` it and what it `touched`.
+
+ Every layer gets one entry, except the root layer, the children of a
+ layer the same save added or deleted, and a layer whose only change is
+ one the editor derives (`derived-attrs`)."
+ [before after touched]
+ (into []
+ (keep
+ (fn [[[page-id id :as key] {:keys [kind attrs]}]]
+ (when (not= uuid/zero id)
+ (let [prev (get before key)
+ obj (get-object after page-id id)]
+ (case kind
+ :added
+ (when (and (some? obj)
+ (root-of-kind? touched :added page-id (:parent-id obj)))
+ (-> (summary obj page-id id (frame-name after page-id (:frame-id obj)))
+ (assoc :kind :added)))
+
+ :deleted
+ (when (and (some? prev)
+ (root-of-kind? touched :deleted page-id (:parent-id prev)))
+ (-> (summary prev page-id id (:frame-name prev))
+ (assoc :kind :deleted)))
+
+ :modified
+ (when (and (some? obj) (some? prev))
+ (let [diff (attr-diff prev obj attrs)]
+ (when (or (seq diff)
+ (seq (remove derived-attrs attrs)))
+ (-> (summary obj page-id id (frame-name after page-id (:frame-id obj)))
+ (assoc :kind :modified)
+ (assoc :attrs diff)))))
+
+ nil)))))
+ touched))
+
+;; --- Reading the rows
+
+(defn- fold-entry
+ "Fold a later `entry` of a layer into what the layer is so far."
+ [prev {:keys [kind] :as entry}]
+ (case [(:kind prev) kind]
+ [nil :added] entry
+ [nil :deleted] entry
+ [nil :modified] entry
+ [:added :modified] (merge entry {:kind :added :attrs nil})
+ [:added :deleted] nil
+ [:modified :modified] (assoc entry :attrs
+ (merge-with (fn [[b _] [_ a]] [b a])
+ (:attrs prev)
+ (:attrs entry)))
+ [:modified :deleted] entry
+ [:deleted :added] (assoc entry :kind :modified :attrs {})
+ [:deleted :modified] entry
+ entry))
+
+(defn- drop-unchanged
+ "A modification undone later (the value is back where it was) is no
+ change: drop those attrs, and the entry when nothing else is left of
+ it and it never had a visible attr."
+ [{:keys [kind attrs] :as entry}]
+ (if (= :modified kind)
+ (let [attrs' (into {} (remove (fn [[_ [b a]]] (= b a))) attrs)]
+ (when (or (seq attrs') (empty? attrs))
+ (assoc entry :attrs attrs')))
+ entry))
+
+(defn net-entries
+ "What each layer ends up as across `rows` (activity rows, each with
+ `:profile-id`, `:created-at` and `:entries`), oldest first: one entry
+ per layer, carrying who made its last change and when (`:profile-id`,
+ `:changed-at`). A layer added and then deleted is gone; a modified
+ property keeps its first value before and its last value after."
+ [rows]
+ (->> rows
+ (sort-by :created-at)
+ (reduce
+ (fn [acc {:keys [profile-id created-at entries]}]
+ (reduce
+ (fn [acc {:keys [page-id id] :as entry}]
+ (let [key [page-id id]
+ entry (assoc entry
+ :profile-id profile-id
+ :changed-at created-at)
+ next (fold-entry (get acc key) entry)]
+ (if (nil? next)
+ (dissoc acc key)
+ (assoc acc key next))))
+ acc
+ entries))
+ (d/ordered-map))
+ (vals)
+ (keep drop-unchanged)
+ (sort-by :changed-at #(compare %2 %1))
+ (vec)))
+
+(def default-session-gap-ms
+ "Two saves of the same person further apart than this, in
+ milliseconds, belong to different sittings."
+ (* 30 60 1000))
+
+(defn sessions
+ "Cut `rows` into sittings: runs of saves of one person with no gap
+ longer than `gap-ms` milliseconds between two of them, newest first.
+ Each sitting has the person (`:profile-id`), when it started and ended
+ and its own `net-entries`."
+ ([rows] (sessions rows default-session-gap-ms))
+ ([rows gap-ms]
+ (->> rows
+ (sort-by :created-at)
+ (reduce
+ (fn [acc {:keys [profile-id created-at] :as row}]
+ (let [last-session (peek acc)]
+ (if (and (some? last-session)
+ (= profile-id (:profile-id last-session))
+ (<= (- (inst-ms created-at) (inst-ms (:end last-session))) gap-ms))
+ (conj (pop acc) (-> last-session
+ (assoc :end created-at)
+ (update :rows conj row)))
+ (conj acc {:profile-id profile-id
+ :start created-at
+ :end created-at
+ :rows [row]}))))
+ [])
+ (keep (fn [{:keys [rows] :as session}]
+ (let [entries (net-entries rows)]
+ (when (seq entries)
+ (-> session
+ (dissoc :rows)
+ (assoc :entries entries))))))
+ (reverse)
+ (vec))))
diff --git a/common/test/common_tests/files/review_activity_test.cljc b/common/test/common_tests/files/review_activity_test.cljc
new file mode 100644
index 0000000000..540d644bca
--- /dev/null
+++ b/common/test/common_tests/files/review_activity_test.cljc
@@ -0,0 +1,142 @@
+;; 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 INC Sucursal en España SL
+
+(ns common-tests.files.review-activity-test
+ (:require
+ [app.common.files.review-activity :as ra]
+ [app.common.uuid :as uuid]
+ [clojure.test :as t]))
+
+(def ^:private page-id (uuid/custom 1 1))
+(def ^:private board-id (uuid/custom 2 1))
+(def ^:private button-id (uuid/custom 2 2))
+(def ^:private label-id (uuid/custom 2 3))
+
+(defn- data
+ [& objects]
+ {:pages-index
+ {page-id
+ {:objects (into {uuid/zero {:id uuid/zero :type :frame :name "Root"}}
+ (map (juxt :id identity))
+ objects)}}})
+
+(def ^:private board
+ {:id board-id :type :frame :name "Checkout / Mobile"
+ :parent-id uuid/zero :frame-id uuid/zero})
+
+(def ^:private button
+ {:id button-id :type :rect :name "Pay button" :r1 8 :height 48
+ :parent-id board-id :frame-id board-id})
+
+(def ^:private label
+ {:id label-id :type :text :name "Label"
+ :parent-id button-id :frame-id board-id})
+
+(defn- save-entries
+ "The entries of a save that turns `before` into `after` with `changes`."
+ [before after changes]
+ (let [touched (ra/touched changes)]
+ (ra/entries (ra/collect-before before touched) after touched)))
+
+(t/deftest modified-layer-keeps-the-values-before-and-after
+ (let [after (assoc button :r1 12 :height 52)
+ entries (save-entries (data board button)
+ (data board after)
+ [{:type :mod-obj :page-id page-id :id button-id
+ :operations [{:type :set :attr :r1 :val 12}
+ {:type :set :attr :height :val 52}]}])]
+ (t/is (= [{:id button-id
+ :page-id page-id
+ :name "Pay button"
+ :type :rect
+ :frame-id board-id
+ :frame-name "Checkout / Mobile"
+ :kind :modified
+ :attrs {:r1 [8 12] :height [48 52]}}]
+ entries))))
+
+(t/deftest added-group-gives-one-entry-for-its-top-layer
+ (let [entries (save-entries (data board)
+ (data board button label)
+ [{:type :add-obj :page-id page-id :id button-id
+ :frame-id board-id :obj button}
+ {:type :add-obj :page-id page-id :id label-id
+ :frame-id board-id :obj label}])]
+ (t/is (= [[button-id :added]]
+ (mapv (juxt :id :kind) entries)))))
+
+(t/deftest deleted-layer-keeps-its-name-and-board
+ (let [entries (save-entries (data board button)
+ (data board)
+ [{:type :del-obj :page-id page-id :id button-id}])]
+ (t/is (= [{:id button-id
+ :page-id page-id
+ :name "Pay button"
+ :type :rect
+ :frame-id board-id
+ :frame-name "Checkout / Mobile"
+ :kind :deleted}]
+ entries))))
+
+(t/deftest layer-added-and-deleted-in-one-save-is-no-change
+ (let [entries (save-entries (data board)
+ (data board)
+ [{:type :add-obj :page-id page-id :id button-id
+ :frame-id board-id :obj button}
+ {:type :del-obj :page-id page-id :id button-id}])]
+ (t/is (empty? entries))))
+
+(t/deftest derived-only-change-is-not-an-entry
+ (let [entries (save-entries (data board button)
+ (data board button)
+ [{:type :mod-obj :page-id page-id :id button-id
+ :operations [{:type :set :attr :position-data :val []}]}])]
+ (t/is (empty? entries))))
+
+(t/deftest component-changes-are-left-out
+ (t/is (empty? (ra/touched [{:type :mod-obj :component-id (uuid/next) :id button-id
+ :operations [{:type :set :attr :r1 :val 4}]}]))))
+
+(defn- row
+ [profile-id ms entries]
+ {:profile-id profile-id
+ :created-at #?(:clj (java.time.Instant/ofEpochMilli ms)
+ :cljs (js/Date. ms))
+ :entries entries})
+
+(def ^:private ana (uuid/custom 9 1))
+(def ^:private marc (uuid/custom 9 2))
+
+(def ^:private modified-entry
+ {:id button-id :page-id page-id :name "Pay button" :kind :modified})
+
+(t/deftest net-entries-fold-the-values-across-saves
+ (let [rows [(row ana 1000 [(assoc modified-entry :attrs {:r1 [8 10]})])
+ (row marc 2000 [(assoc modified-entry :attrs {:r1 [10 12]})])]
+ [entry & others] (ra/net-entries rows)]
+ (t/is (empty? others))
+ (t/is (= {:r1 [8 12]} (:attrs entry)))
+ (t/is (= marc (:profile-id entry)))))
+
+(t/deftest net-entries-drop-a-layer-added-and-later-deleted
+ (let [rows [(row ana 1000 [{:id button-id :page-id page-id :kind :added}])
+ (row ana 2000 [{:id button-id :page-id page-id :kind :deleted}])]]
+ (t/is (empty? (ra/net-entries rows)))))
+
+(t/deftest net-entries-drop-a-change-undone-later
+ (let [rows [(row ana 1000 [(assoc modified-entry :attrs {:r1 [8 12]})])
+ (row ana 2000 [(assoc modified-entry :attrs {:r1 [12 8]})])]]
+ (t/is (empty? (ra/net-entries rows)))))
+
+(t/deftest sessions-cut-by-person-and-by-gap
+ (let [minute (* 60 1000)
+ rows [(row ana 0 [(assoc modified-entry :attrs {:r1 [8 10]})])
+ (row ana (* 10 minute) [(assoc modified-entry :attrs {:r1 [10 12]})])
+ (row marc (* 20 minute) [(assoc modified-entry :attrs {:r1 [12 14]})])
+ (row marc (* 90 minute) [(assoc modified-entry :attrs {:r1 [14 16]})])]
+ result (ra/sessions rows)]
+ (t/is (= [marc marc ana] (mapv :profile-id result)))
+ (t/is (= {:r1 [8 12]} (-> result last :entries first :attrs)))))
diff --git a/common/test/common_tests/runner.cljc b/common/test/common_tests/runner.cljc
index 3f95ecaa54..c293cffe1b 100644
--- a/common/test/common_tests/runner.cljc
+++ b/common/test/common_tests/runner.cljc
@@ -31,6 +31,7 @@
[common-tests.files.helpers-test]
[common-tests.files.page-diff-test]
[common-tests.files.repair-test]
+ [common-tests.files.review-activity-test]
[common-tests.files.shapes-builder-test]
[common-tests.files.tokens-test]
[common-tests.files.validate-test]
@@ -147,6 +148,7 @@
'common-tests.files.helpers-test
'common-tests.files.page-diff-test
'common-tests.files.repair-test
+ 'common-tests.files.review-activity-test
'common-tests.files.shapes-builder-test
'common-tests.files.tokens-test
'common-tests.files.validate-test
diff --git a/frontend/playwright/ui/specs/pull-requests.spec.js b/frontend/playwright/ui/specs/pull-requests.spec.js
index 14d484457a..9735caad4d 100644
--- a/frontend/playwright/ui/specs/pull-requests.spec.js
+++ b/frontend/playwright/ui/specs/pull-requests.spec.js
@@ -3,8 +3,9 @@ import { WorkspacePage } from "../pages/WorkspacePage";
const PR_ID = "c7ce0794-0992-8105-8004-38f280443999";
-const reviewTitle = (page) =>
- page.getByText("Reviewing the design review", { exact: true });
+// The review bar at the bottom of the canvas: the review's own chrome,
+// which replaces the branch bar while a design review is open.
+const reviewBar = (page) => page.getByRole("region", { name: "Design review" });
test.beforeEach(async ({ page }) => {
await WorkspacePage.init(page);
@@ -26,31 +27,37 @@ const setupPullRequestSandbox = async (workspacePage) => {
});
};
-test("opening a file with pr-id shows the review sandbox banner", async ({
- page,
-}) => {
+test("opening a file with pr-id enters the design review", async ({ page }) => {
const workspacePage = new WorkspacePage(page);
await setupPullRequestSandbox(workspacePage);
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
- await expect(reviewTitle(page)).toBeVisible();
- await expect(page.getByText("Checkout redesign").first()).toBeVisible();
+ // the review bar names the review being read, and the header trades the
+ // 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("Checkout redesign", { exact: true }),
+ ).toBeVisible();
+ await expect(page.getByTitle("Review: Checkout redesign")).toBeVisible();
- // the route reads as two pills: the branch under review, then main
- const banner = reviewTitle(page).locator("../../..");
- await expect(banner.getByText("checkout", { exact: true })).toBeVisible();
- await expect(banner.getByText("Main", { exact: true })).toBeVisible();
+ // the essentials are visible buttons: the details, the verdict of an
+ // assigned reviewer, and the way out
+ await expect(bar.getByRole("button", { name: "Details" })).toBeVisible();
+ await expect(
+ bar.getByRole("button", { name: "Submit review" }),
+ ).toBeVisible();
+ await expect(bar.getByRole("button", { name: "Exit review" })).toBeVisible();
- // only the essential actions are visible buttons...
- await expect(page.getByRole("button", { name: "Compare" })).toBeVisible();
- await expect(page.getByRole("button", { name: "Details" })).toBeHidden();
-
- // ...the rest live behind the kebab menu
- await banner.getByRole("button", { name: "Options" }).click();
- await expect(page.getByText("Details")).toBeVisible();
+ // comparing, merging and cancelling live behind the kebab menu
+ await expect(bar.getByRole("button", { name: "Compare" })).toBeHidden();
+ await bar.getByRole("button", { name: "Options" }).click();
+ await expect(page.getByText("Compare", { exact: true })).toBeVisible();
await expect(page.getByText("Merge to main")).toBeVisible();
- await expect(page.getByText("Exit review")).toBeVisible();
- await expect(page.getByText("Try interactions")).toBeHidden();
+ await expect(page.getByText("Cancel review")).toBeVisible();
});
test("the compare dialog shows the proposed changes", async ({ page }) => {
@@ -58,7 +65,9 @@ test("the compare dialog shows the proposed changes", async ({ page }) => {
await setupPullRequestSandbox(workspacePage);
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
- await page.getByRole("button", { name: "Compare" }).click();
+ // comparing is one of the review bar's options
+ await reviewBar(page).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();
@@ -69,7 +78,7 @@ test("accepting the pull request opens the merge dialog", async ({ page }) => {
await setupPullRequestSandbox(workspacePage);
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
- const banner = reviewTitle(page).locator("../../..");
+ const banner = reviewBar(page);
await banner.getByRole("button", { name: "Options" }).click();
await page.getByText("Merge to main").click();
@@ -78,33 +87,60 @@ test("accepting the pull request opens the merge dialog", async ({ page }) => {
await expect(page.getByText("checkout").first()).toBeVisible();
});
-test("the review behaves like a normal, editable file", async ({ page }) => {
+test("the review is read-only", async ({ page }) => {
const workspacePage = new WorkspacePage(page);
await setupPullRequestSandbox(workspacePage);
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
- await expect(reviewTitle(page)).toBeVisible();
- // the file is the live branch, opened normally: the design toolbar is
- // available so reviewers can try and validate anything...
- await expect(workspacePage.rectShapeButton).toBeVisible();
- // ...and none of the read-only / inspect affordances kick in
- await expect(page.getByText("Inspecting code")).toBeHidden();
- await expect(page.getByText("View only")).toBeHidden();
+ await expect(reviewBar(page)).toBeVisible();
+
+ // the review toolbar replaces the design tools: moving around,
+ // commenting and tasks only, so the canvas offers no way to draw
+ const toolbar = page.getByRole("toolbar", { name: "Review tools" });
+ await expect(toolbar).toBeVisible();
+ for (const tool of [
+ "Move",
+ "Comment",
+ "Comment an area",
+ "Create a task",
+ "Show changes",
+ ]) {
+ await expect(
+ toolbar.getByRole("button", { name: tool, exact: true }),
+ ).toBeVisible();
+ }
+ await expect(workspacePage.rectShapeButton).toBeHidden();
+
+ // and the sidebar flags the file as view only
+ await expect(page.getByText("View only")).toBeVisible();
+
+ // the right panel is the review's: the inspect of the selection, the
+ // comments and the tasks of the review
+ await expect(page.getByRole("tab", { name: "Inspect" })).toBeVisible();
+ await expect(page.getByRole("tab", { name: "Comments (0)" })).toBeVisible();
+ await expect(page.getByRole("tab", { name: "Tasks (0)" })).toBeVisible();
});
-test("an assigned reviewer can submit a verdict from the banner", async ({
+test("an assigned reviewer can submit a verdict from the review bar", async ({
page,
}) => {
const workspacePage = new WorkspacePage(page);
await setupPullRequestSandbox(workspacePage);
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
- // the logged-in profile is an assigned reviewer in the fixture
- await page.getByRole("button", { name: "Review", exact: true }).click();
+ // the logged-in profile is an assigned reviewer in the fixture, so the
+ // bar offers the verdict
+ const bar = reviewBar(page);
+ await bar.getByRole("button", { name: "Submit review" }).click();
- await expect(page.getByText("Submit review").first()).toBeVisible();
- await page.getByText("Request changes", { exact: true }).click();
- await page.getByRole("button", { name: "Submit review" }).click();
+ const dialog = page.getByRole("dialog");
+ await expect(dialog).toBeVisible();
+ await expect(
+ dialog.getByRole("heading", { name: "Submit review" }),
+ ).toBeVisible();
+
+ await dialog.getByRole("button", { name: "Request changes" }).click();
+ await dialog.getByRole("button", { name: "Submit review" }).click();
await expect(page.getByText("Review submitted")).toBeVisible();
});
@@ -118,7 +154,7 @@ test("closing the pull request asks for confirmation", async ({ page }) => {
);
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
- const banner = reviewTitle(page).locator("../../..");
+ const banner = reviewBar(page);
await banner.getByRole("button", { name: "Options" }).click();
await page.getByText("Cancel review").click();
@@ -164,15 +200,15 @@ test("exiting the review takes the user back to the file", async ({ page }) => {
await setupPullRequestSandbox(workspacePage);
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
- await expect(reviewTitle(page)).toBeVisible();
- const banner = reviewTitle(page).locator("../../..");
+ const banner = reviewBar(page);
+ await expect(banner).toBeVisible();
await banner.getByRole("button", { name: "Options" }).click();
await page.getByText("Exit review").click();
// exiting drops the review context and the pr-id param; the file (the
// live branch) stays as it was
await expect(page).not.toHaveURL(/pr-id/);
- await expect(reviewTitle(page)).toBeHidden();
+ await expect(reviewBar(page)).toBeHidden();
});
test("during a review the header names the branch under review", async ({
@@ -187,9 +223,9 @@ test("during a review the header names the branch under review", async ({
);
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
- // the review banner replaces the branch banner, so the header loads the
+ // the review bar replaces the branch bar, so the header loads the
// branch context itself
- await expect(reviewTitle(page)).toBeVisible();
+ await expect(reviewBar(page)).toBeVisible();
await expect(page.getByTitle("On branch checkout from main")).toBeVisible();
});
diff --git a/frontend/resources/images/cursors/create-task.svg b/frontend/resources/images/cursors/create-task.svg
new file mode 100644
index 0000000000..113a7ca3de
--- /dev/null
+++ b/frontend/resources/images/cursors/create-task.svg
@@ -0,0 +1,12 @@
+
diff --git a/frontend/resources/images/icons/comment-area.svg b/frontend/resources/images/icons/comment-area.svg
new file mode 100644
index 0000000000..2132801c5a
--- /dev/null
+++ b/frontend/resources/images/icons/comment-area.svg
@@ -0,0 +1,3 @@
+
diff --git a/frontend/src/app/main/data/changes.cljs b/frontend/src/app/main/data/changes.cljs
index e114ed26b7..6a0d8f6540 100644
--- a/frontend/src/app/main/data/changes.cljs
+++ b/frontend/src/app/main/data/changes.cljs
@@ -298,13 +298,15 @@
features (get state :features)
permissions (get state :permissions)]
- ;; Historical previews must not create edits to the live file. 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 callers can
- ;; uniformly subscribe and observe termination.
+ ;; Historical previews must not create edits to the live file, and
+ ;; a design review is read-only (the branch is edited outside it).
+ ;; 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
+ ;; callers can uniformly subscribe and observe termination.
(if (and (:can-edit permissions)
(not (dm/get-in state [:workspace-global :preview-id]))
+ (not (contains? state :workspace-pr-preview))
(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 6764e3e86e..659a46be9b 100644
--- a/frontend/src/app/main/data/workspace.cljs
+++ b/frontend/src/app/main/data/workspace.cljs
@@ -689,6 +689,8 @@
;; --- Layout Flags
(dm/export layout/toggle-layout-flag)
+(dm/export layout/open-bottom-bar)
+(dm/export layout/toggle-bottom-bar)
(dm/export layout/remove-layout-flag)
;; --- Profile
diff --git a/frontend/src/app/main/data/workspace/branches.cljs b/frontend/src/app/main/data/workspace/branches.cljs
index 725a388849..c0260171ab 100644
--- a/frontend/src/app/main/data/workspace/branches.cljs
+++ b/frontend/src/app/main/data/workspace/branches.cljs
@@ -753,6 +753,8 @@
resolve conflicts before integrating.
- `:comment` — what the user says about the merge, kept with its
record and shown in the reviews dialog.
+ - `:notify-assignees` — tell the assignees of the open tasks of the
+ branch, by email, that the merge moved their tasks into main.
- `:excluded` — the per-change selection (change keys,
`app.common.files.branch-merge/change-key`) naming the changes the
user deselected, which main keeps its own value for.
@@ -764,7 +766,7 @@
before that diff has loaded carry the revn of the conflict answer instead
(`conflict-main-revn`). Unresolved conflicts open the resolution modal."
([branch] (merge-branch branch nil))
- ([branch {:keys [resolutions comment excluded]}]
+ ([branch {:keys [resolutions comment excluded notify-assignees]}]
(assert (uuid? (:id branch)) "expected a branch row with a valid `:id`")
(ptk/reify ::merge-branch
ptk/WatchEvent
@@ -781,6 +783,7 @@
(cond-> {:branch-id branch-id}
(seq resolutions) (assoc :resolutions resolutions)
(seq excluded) (assoc :excluded excluded)
+ notify-assignees (assoc :notify-assignees true)
(not (str/blank? comment)) (assoc :comment (str/trim comment))
(some? main-revn) (assoc :expected-main-revn main-revn)))
(rx/mapcat
diff --git a/frontend/src/app/main/data/workspace/comments.cljs b/frontend/src/app/main/data/workspace/comments.cljs
index 656fdaa651..3bfb1b2711 100644
--- a/frontend/src/app/main/data/workspace/comments.cljs
+++ b/frontend/src/app/main/data/workspace/comments.cljs
@@ -25,6 +25,8 @@
[app.main.data.workspace.drawing :as dwd]
[app.main.data.workspace.edition :as dwe]
[app.main.data.workspace.layout :as dwlo]
+ [app.main.data.workspace.review :as dwrv]
+ [app.main.data.workspace.tasks :as dwtk]
[app.main.data.workspace.viewport-wasm :as dwvw]
[app.main.data.workspace.zoom :as dwz]
[app.main.repo :as rp]
@@ -82,6 +84,10 @@
(cond
(:draft local) (rx/of (dcmt/close-thread))
(:open local) (rx/of (dcmt/close-thread))
+ (some? (get-in state [:workspace-tasks-local :new]))
+ (rx/of (dwtk/cancel-new-task))
+ (some? (get-in state [:workspace-tasks-local :open]))
+ (rx/of (dwtk/close-task))
(:expanded local) (rx/of (dcmt/collapse-comment-group))
;; Only clear edition / deselect on interrupt while the comments
;; tool is active. When comments are merely visible during design,
@@ -114,6 +120,23 @@
(some? (:open local))
(rx/of (dcmt/close-thread))
+ (some? (get-in state [:workspace-tasks-local :new]))
+ (rx/of (dwtk/cancel-new-task))
+
+ (some? (get-in state [:workspace-tasks-local :open]))
+ (rx/of (dwtk/close-task))
+
+ ;; inside a design review the review tool says what a click does;
+ ;; the area tool draws with the pointer instead
+ (dwrv/reviewing? state)
+ (if (= :comment-area (dwrv/get-tool state))
+ (rx/empty)
+ (rx/of (dwrv/handle-canvas-click position)))
+
+ ;; outside a review, "New task" arms the task tool for one click
+ (= :task (dwrv/get-tool state))
+ (rx/of (dwrv/handle-canvas-click position))
+
:else
(let [page-id (:current-page-id state)
file-id (:current-file-id state)
diff --git a/frontend/src/app/main/data/workspace/layout.cljs b/frontend/src/app/main/data/workspace/layout.cljs
index c0f1a125c2..2199750ebc 100644
--- a/frontend/src/app/main/data/workspace/layout.cljs
+++ b/frontend/src/app/main/data/workspace/layout.cljs
@@ -122,6 +122,45 @@
(let [flags (:workspace-layout state)]
(persist-layout-flags! flags)))))
+;; --- The bars at the bottom of the canvas of a branch
+
+;; A branch has two bars at the same level, the one of the branch and the
+;; palettes, and only one of them is open at a time. `:bottom-bar` says which:
+;; `:branch`, `:palette` or `:none`. It only exists while the bar of the branch
+;; is there: without it the palettes follow their own layout flags.
+
+(defn mount-bottom-bars
+ "The bar of the branch is there, and comes open."
+ []
+ (ptk/reify ::mount-bottom-bars
+ ptk/UpdateEvent
+ (update [_ state]
+ (assoc-in state [:workspace-global :bottom-bar] :branch))))
+
+(defn unmount-bottom-bars
+ []
+ (ptk/reify ::unmount-bottom-bars
+ ptk/UpdateEvent
+ (update [_ state]
+ (update state :workspace-global dissoc :bottom-bar))))
+
+(defn open-bottom-bar
+ "Open `bar`, which folds the other one."
+ [bar]
+ (ptk/reify ::open-bottom-bar
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-in-when state [:workspace-global :bottom-bar] (constantly bar)))))
+
+(defn toggle-bottom-bar
+ "Open `bar`, or fold it when it is open and leave both folded."
+ [bar]
+ (ptk/reify ::toggle-bottom-bar
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-in-when state [:workspace-global :bottom-bar]
+ #(if (= bar %) :none bar)))))
+
(defn set-options-mode
[mode]
(dm/assert!
diff --git a/frontend/src/app/main/data/workspace/notifications.cljs b/frontend/src/app/main/data/workspace/notifications.cljs
index 2c07fb1962..5abddee2d4 100644
--- a/frontend/src/app/main/data/workspace/notifications.cljs
+++ b/frontend/src/app/main/data/workspace/notifications.cljs
@@ -25,6 +25,7 @@
[app.main.data.workspace.layout :as dwly]
[app.main.data.workspace.libraries :as dwl]
[app.main.data.workspace.pull-requests :as dwpr]
+ [app.main.data.workspace.tasks :as dwtk]
[app.main.data.workspace.texts :as dwt]
[app.main.router :as rt]
[app.util.globals :refer [global]]
@@ -169,6 +170,7 @@
:pull-request-updated (handle-pull-request-change msg)
:pull-request-review-submitted (handle-pull-request-change msg)
:pull-request-closed (handle-pull-request-change msg)
+ :file-tasks-change (dwtk/handle-tasks-change msg)
:notification (dc/handle-notification msg)
:team-role-change (handle-change-team-role msg)
:team-membership-change (dc/team-membership-change msg)
diff --git a/frontend/src/app/main/data/workspace/pull_requests.cljs b/frontend/src/app/main/data/workspace/pull_requests.cljs
index 5bd2bd6d19..04e38d9be4 100644
--- a/frontend/src/app/main/data/workspace/pull_requests.cljs
+++ b/frontend/src/app/main/data/workspace/pull_requests.cljs
@@ -15,9 +15,12 @@
`app.main.data.workspace.branches`."
(:require
[app.config :as cf]
+ [app.main.data.comments :as dcmt]
[app.main.data.event :as ev]
[app.main.data.notifications :as ntf]
[app.main.data.persistence :as dwp]
+ [app.main.data.workspace.drawing.common :as dwdc]
+ [app.main.data.workspace.layout :as dwl]
[app.main.repo :as rp]
[app.main.router :as rt]
[app.util.i18n :refer [tr]]
@@ -159,7 +162,8 @@
(defn update-pull-request-snapshot
"Publish the branch's current state to the reviewers (repositions the
review snapshot). When the branch is the currently open file, pending
- local changes are force-persisted first."
+ local changes are force-persisted first. Once published, the review
+ open in the workspace learns it is up to date."
[id]
(assert (uuid? id) "expected valid uuid for `id`")
(ptk/reify ::update-pull-request-snapshot
@@ -178,7 +182,8 @@
(rx/of (if updated
(ntf/success (tr "workspace.pull-requests.publish.success"))
(ntf/info (tr "workspace.pull-requests.publish.up-to-date")))
- (fetch-pull-requests))))
+ (fetch-pull-requests)
+ (refresh-pull-request-preview-info id))))
(rx/catch
(fn [_]
(rx/of (ntf/error (tr "workspace.pull-requests.lifecycle.error")))))))))))
@@ -311,13 +316,15 @@
(ptk/reify ::exit-pull-request-preview
ptk/UpdateEvent
(update [_ state]
- (dissoc state :workspace-pr-preview))
+ (dissoc state :workspace-pr-preview :workspace-review-local :workspace-review-activity))
ptk/WatchEvent
(watch [_ state _]
(let [params (-> (rt/get-params state)
(dissoc :pr-id))]
- (rx/of (rt/nav :workspace params))))))
+ (rx/of (dwdc/clear-drawing)
+ (dcmt/close-thread)
+ (rt/nav :workspace params))))))
(defn- enter-pull-request-preview
"Worker for `initialize-pull-request-preview`: load the pull request
@@ -353,7 +360,12 @@
(rx/of (exit-pull-request-preview))
:else
- (rx/of (set-pull-request-preview {:status :loaded :info info})))))
+ (rx/of (set-pull-request-preview {:status :loaded :info info})
+ ;; the review opens on the inspect of the selection:
+ ;; the move tool picks layers, and the comments and
+ ;; tasks show on the canvas
+ (dwdc/clear-drawing)
+ (dwl/toggle-layout-flag :display-comments :force? true)))))
(rx/catch
(fn [_]
(rx/of (ntf/warn (tr "workspace.pull-requests.preview.unavailable"))
diff --git a/frontend/src/app/main/data/workspace/review.cljs b/frontend/src/app/main/data/workspace/review.cljs
new file mode 100644
index 0000000000..d83410d16f
--- /dev/null
+++ b/frontend/src/app/main/data/workspace/review.cljs
@@ -0,0 +1,341 @@
+;; 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 INC Sucursal en España SL
+
+(ns app.main.data.workspace.review
+ "Data layer of the review mode: what the reviewer does inside a design
+ review. The review is read-only (the branch is edited outside it), so
+ the toolbar offers only the review tools: move around, comment on a
+ spot or a layer, comment on an area, create a task, and show the
+ changes of the branch on the canvas.
+
+ `:workspace-review-local` keeps the tool in use, the tab and filters of
+ the review panel and the change shown on the canvas;
+ `:workspace-review-activity` the activity of the review, one row per
+ save of the branch since the review opened."
+ (:require
+ [app.common.files.review-activity :as ra]
+ [app.common.geom.point :as gpt]
+ [app.common.uuid :as uuid]
+ [app.main.data.comments :as dcmt]
+ [app.main.data.helpers :as dsh]
+ [app.main.data.modal :as modal]
+ [app.main.data.workspace.common :as dwc]
+ [app.main.data.workspace.drawing :as dwd]
+ [app.main.data.workspace.drawing.common :as dwdc]
+ [app.main.data.workspace.layout :as dwl]
+ [app.main.data.workspace.tasks :as dwtk]
+ [app.main.repo :as rp]
+ [app.main.router :as rt]
+ [beicon.v2.core :as rx]
+ [potok.v2.core :as ptk]))
+
+(def tools
+ #{:move :comment :comment-area :task})
+
+(defn reviewing?
+ [state]
+ (some? (:workspace-pr-preview state)))
+
+(defn review-id
+ "The id of the design review open now."
+ [state]
+ (get-in state [:workspace-pr-preview :pr-id]))
+
+;; --- Tools
+
+(defn- forget-task-tool
+ []
+ (ptk/reify ::forget-task-tool
+ ptk/UpdateEvent
+ (update [_ state]
+ (update state :workspace-review-local dissoc :tool))))
+
+(defn set-tool
+ "Use one of the review `tools`. The commenting tools and the task tool
+ take the clicks of the canvas, so they all ride on the comments drawing
+ tool; the review tool says what a click does."
+ [tool]
+ (assert (contains? tools tool) "expected a review tool")
+ (ptk/reify ::set-tool
+ ptk/UpdateEvent
+ (update [_ state]
+ (-> state
+ (update :workspace-review-local assoc :tool tool)
+ (update :comments-local dissoc :draft)))
+
+ ptk/WatchEvent
+ (watch [_ state stream]
+ (if (= tool :move)
+ (rx/of (dwdc/clear-drawing))
+ ;; what the tool makes must be seen: comments and tasks show
+ (rx/merge
+ (rx/of (dwd/select-for-drawing :comments)
+ (dwl/toggle-layout-flag :display-comments :force? true))
+ ;; outside a review the task tool is for one task: leaving it
+ ;; gives the clicks back to the comments
+ (when (and (= tool :task) (not (reviewing? state)))
+ (->> stream
+ (rx/filter #(or (dwc/interrupt? %)
+ (ptk/type? ::dwdc/clear-drawing %)))
+ (rx/take 1)
+ (rx/map (fn [_] (forget-task-tool))))))))))
+
+(defn get-tool
+ [state]
+ (if (= :comments (get-in state [:workspace-drawing :tool]))
+ (get-in state [:workspace-review-local :tool] :comment)
+ :move))
+
+;; --- Panel
+
+(defn set-panel-tab
+ [tab]
+ (assert (contains? #{:inspect :comments :tasks} tab) "expected a panel tab")
+ (ptk/reify ::set-panel-tab
+ ptk/UpdateEvent
+ (update [_ state]
+ (update state :workspace-review-local assoc :panel-tab tab))))
+
+(defn set-task-filter
+ [filter]
+ (assert (contains? #{:all :open :mine :to-verify} filter) "expected a task filter")
+ (ptk/reify ::set-task-filter
+ ptk/UpdateEvent
+ (update [_ state]
+ (update state :workspace-review-local assoc :task-filter filter))))
+
+(def task-statuses
+ "The states a task can be in, in the order the filters show them."
+ ["open" "done" "reopened" "verified" "wont-do"])
+
+(defn set-task-status-filter
+ "Show the tasks of the details of a review in one state (`:all` for
+ every one)."
+ [status]
+ (assert (or (= :all status) (contains? (set task-statuses) status))
+ "expected a task status or :all")
+ (ptk/reify ::set-task-status-filter
+ ptk/UpdateEvent
+ (update [_ state]
+ (update state :workspace-review-local assoc :task-status-filter status))))
+
+(defn toggle-hide-closed-tasks
+ []
+ (ptk/reify ::toggle-hide-closed-tasks
+ ptk/UpdateEvent
+ (update [_ state]
+ (update-in state [:workspace-review-local :hide-closed-tasks] not))))
+
+;; --- Creating from the canvas
+
+(defn- draft-params
+ [state position]
+ {:position position
+ :page-id (:current-page-id state)
+ :file-id (:current-file-id state)})
+
+(defn handle-canvas-click
+ "A click on the canvas with a review tool: the comment tool starts a
+ thread on the layer under the pointer (on the spot of the board when
+ there is no layer), the task tool starts a task on that layer. The
+ area tool draws with the pointer instead (`start-area-comment`).
+ Outside a review the task tool is also in use for one click."
+ [position]
+ (ptk/reify ::handle-canvas-click
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [page-id (:current-page-id state)
+ objects (dsh/lookup-page-objects state page-id)
+ shape (dwtk/shape-at-position objects position)
+ pr-id (review-id state)]
+ (case (get-tool state)
+ :comment
+ (rx/of (dcmt/create-draft
+ (cond-> (assoc (draft-params state position) :pull-request-id pr-id)
+ (and (some? shape) (not= :frame (:type shape)))
+ (assoc :anchor {:type :layer :shape-id (:id shape)})
+
+ (or (nil? shape) (= :frame (:type shape)))
+ (assoc :anchor {:type :canvas}))))
+
+ ;; on the empty canvas the task points at the canvas itself
+ :task
+ (rx/concat
+ (rx/of (dwtk/start-new-task
+ {:page-id page-id
+ :frame-id (cond
+ (nil? shape) uuid/zero
+ (= :frame (:type shape)) (:id shape)
+ :else (:frame-id shape))
+ :shape-id (:id shape)
+ :position position
+ :pull-request-id pr-id}))
+ (if (nil? pr-id)
+ (rx/of (forget-task-tool))
+ (rx/empty)))
+
+ (rx/empty))))))
+
+(defn create-area-draft
+ "The pointer drew `area` (canvas coordinates) with the area tool: start
+ a thread on it. The thread sits at the top right corner of the area,
+ just inside it so it belongs to the board the area is on."
+ [{:keys [x y width] :as area}]
+ (ptk/reify ::create-area-draft
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [position {:x (- (+ x width) 1) :y (+ y 1)}]
+ (rx/of (dcmt/create-draft
+ (-> (draft-params state (gpt/point position))
+ (assoc :pull-request-id (review-id state))
+ (assoc :anchor {:type :area :area area}))))))))
+
+;; --- Activity
+
+(defn- activity-fetched
+ [pr-id rows]
+ (ptk/reify ::activity-fetched
+ ptk/UpdateEvent
+ (update [_ state]
+ (assoc state :workspace-review-activity
+ {:pr-id pr-id
+ :status :loaded
+ :rows rows
+ :entries (ra/net-entries rows)
+ :sessions (ra/sessions rows)}))))
+
+(defn fetch-activity
+ "Load what the saves of the branch did since the review `pr-id` opened."
+ [pr-id]
+ (assert (uuid? pr-id) "expected a valid uuid for `pr-id`")
+ (ptk/reify ::fetch-activity
+ ptk/UpdateEvent
+ (update [_ state]
+ (if (= pr-id (get-in state [:workspace-review-activity :pr-id]))
+ state
+ (assoc state :workspace-review-activity {:pr-id pr-id :status :loading})))
+
+ ptk/WatchEvent
+ (watch [_ _ _]
+ (->> (rp/cmd! :get-pull-request-activity {:id pr-id})
+ (rx/map (partial activity-fetched pr-id))
+ (rx/catch (fn [_]
+ (rx/of (fn [state]
+ (assoc state :workspace-review-activity
+ {:pr-id pr-id :status :error})))))))))
+
+;; --- Details
+
+(defn open-details
+ "Open the details of the review on `tab` (\"overview\", \"activity\" or
+ \"tasks\")."
+ ([] (open-details "overview"))
+ ([tab]
+ (ptk/reify ::open-details
+ ptk/WatchEvent
+ (watch [_ state _]
+ (if-let [pr (get-in state [:workspace-pr-preview :info])]
+ (rx/of (modal/show :review-details {:pr pr :tab tab}))
+ (rx/empty))))))
+
+;; --- Changes on the canvas
+
+(defn- change-entries
+ [state]
+ (let [filter (get-in state [:workspace-review-local :change-filter] :all)]
+ (cond->> (get-in state [:workspace-review-activity :entries])
+ (not= :all filter) (filterv #(= filter (:kind %))))))
+
+(defn set-change-filter
+ [filter]
+ (assert (contains? #{:all :added :modified :deleted} filter) "expected a change filter")
+ (ptk/reify ::set-change-filter
+ ptk/UpdateEvent
+ (update [_ state]
+ (update state :workspace-review-local assoc :change-filter filter))))
+
+(defn- center-on-entry
+ [{:keys [page-id id] :as entry}]
+ (ptk/reify ::center-on-entry
+ ptk/WatchEvent
+ (watch [_ state _]
+ (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 (dwtk/center-to-task {:page-id page-id
+ :shape-id id
+ :frame-id (:frame-id entry)}))
+ (rx/observe-on :async))))))
+
+(defn show-change
+ "Show the changes of the branch on the canvas, with the one at `index`
+ (of the filtered activity) in front, and take the viewport to it."
+ [index]
+ (ptk/reify ::show-change
+ ptk/UpdateEvent
+ (update [_ state]
+ (let [total (count (change-entries state))
+ index (if (pos? total) (mod index total) 0)]
+ (update state :workspace-review-local assoc :show-changes {:index index})))
+
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [index (get-in state [:workspace-review-local :show-changes :index])]
+ (if-let [entry (get (change-entries state) index)]
+ (rx/of (modal/hide)
+ (center-on-entry entry))
+ (rx/of (modal/hide)))))))
+
+(defn show-change-of
+ "Show on the canvas the change of the layer `id`."
+ [id]
+ (ptk/reify ::show-change-of
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [entries (change-entries state)
+ index (or (first (keep-indexed (fn [i e] (when (= id (:id e)) i)) entries)) 0)]
+ (rx/of (show-change index))))))
+
+(declare hide-changes)
+
+(defn toggle-changes
+ "The show changes tool: show the changes on the canvas, or stop."
+ []
+ (ptk/reify ::toggle-changes
+ ptk/WatchEvent
+ (watch [_ state _]
+ (if (some? (get-in state [:workspace-review-local :show-changes]))
+ (rx/of (hide-changes))
+ (let [pr-id (review-id state)]
+ (rx/concat
+ (if (some? pr-id) (rx/of (fetch-activity pr-id)) (rx/empty))
+ (rx/of (fn [state]
+ (update state :workspace-review-local assoc :show-changes {:index 0})))))))))
+
+(defn hide-changes
+ []
+ (ptk/reify ::hide-changes
+ ptk/UpdateEvent
+ (update [_ state]
+ (update state :workspace-review-local dissoc :show-changes))))
+
+(defn back-to-details
+ "Leave the changes on the canvas and go back to the activity."
+ []
+ (ptk/reify ::back-to-details
+ ptk/WatchEvent
+ (watch [_ _ _]
+ (rx/of (hide-changes)
+ (open-details "activity")))))
+
+(defn reset-review-local
+ []
+ (ptk/reify ::reset-review-local
+ ptk/UpdateEvent
+ (update [_ state]
+ (dissoc state :workspace-review-local :workspace-review-activity))))
diff --git a/frontend/src/app/main/data/workspace/shapes.cljs b/frontend/src/app/main/data/workspace/shapes.cljs
index 82691dfad9..c87d779a5e 100644
--- a/frontend/src/app/main/data/workspace/shapes.cljs
+++ b/frontend/src/app/main/data/workspace/shapes.cljs
@@ -26,6 +26,7 @@
[app.main.data.workspace.reflow :as wrf]
[app.main.data.workspace.reflow.signals :as wrfs]
[app.main.data.workspace.selection :as dws]
+ [app.main.data.workspace.tasks :as dwtk]
[app.main.data.workspace.undo :as dwu]
[beicon.v2.core :as rx]
[potok.v2.core :as ptk]))
@@ -401,6 +402,8 @@
(wrf/cancel-shapes! deleted-ids)
(rx/of (dwu/start-undo-transaction undo-id)
(dc/detach-comment-thread ids)
+ ;; the open tasks of the deleted layers move to their board
+ (dwtk/handle-deleted-shapes objects ids)
(dch/commit-changes changes)
(ptk/data-event :layout/update {:ids all-parents :undo-group (:undo-group options)})
(dwu/commit-undo-transaction undo-id)))))))
diff --git a/frontend/src/app/main/data/workspace/shortcuts.cljs b/frontend/src/app/main/data/workspace/shortcuts.cljs
index 0adf37788b..b322ae01a0 100644
--- a/frontend/src/app/main/data/workspace/shortcuts.cljs
+++ b/frontend/src/app/main/data/workspace/shortcuts.cljs
@@ -674,6 +674,7 @@
:section [:workspace]
:fn #(do (r/set-resize-type! :bottom)
(emit-when-no-readonly (dw/remove-layout-flag :hide-palettes)
+ (dw/open-bottom-bar :palette)
(dw/remove-layout-flag :textpalette)
(toggle-layout-flag :colorpalette)))}
@@ -684,6 +685,7 @@
:section [:workspace]
:fn #(do (r/set-resize-type! :bottom)
(emit-when-no-readonly (dw/remove-layout-flag :hide-palettes)
+ (dw/open-bottom-bar :palette)
(dw/remove-layout-flag :colorpalette)
(toggle-layout-flag :textpalette)))}
diff --git a/frontend/src/app/main/data/workspace/tasks.cljs b/frontend/src/app/main/data/workspace/tasks.cljs
new file mode 100644
index 0000000000..e35d96277c
--- /dev/null
+++ b/frontend/src/app/main/data/workspace/tasks.cljs
@@ -0,0 +1,652 @@
+;; 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 INC Sucursal en España SL
+
+(ns app.main.data.workspace.tasks
+ "Data layer for tasks: a piece of work on a file, assigned to someone
+ and tied to a layer. Every task lives in a message of a comment thread,
+ so its thread can go on (a thread may hold several tasks): a task made
+ from a message keeps that thread, and a task created on the canvas gets
+ a thread whose first message is its title. A task may also belong to a
+ design review.
+
+ The tasks of the open file live in `:workspace-tasks`, the events of a
+ task (what the thread of the task shows between its comments) in
+ `:workspace-task-events`, and what the user is doing with them (the
+ task open on the canvas, the new task being written, the task being
+ linked to another layer) in `:workspace-tasks-local`."
+ (:require
+ [app.common.data :as d]
+ [app.common.data.macros :as dm]
+ [app.common.files.changes-builder :as pcb]
+ [app.common.files.helpers :as cfh]
+ [app.common.geom.point :as gpt]
+ [app.common.geom.shapes :as gsh]
+ [app.common.types.shape-tree :as ctst]
+ [app.common.uuid :as uuid]
+ [app.config :as cf]
+ [app.main.data.changes :as dch]
+ [app.main.data.comments :as dcmt]
+ [app.main.data.event :as ev]
+ [app.main.data.helpers :as dsh]
+ [app.main.data.notifications :as ntf]
+ [app.main.data.workspace.undo :as dwu]
+ [app.main.data.workspace.viewport-wasm :as dwvw]
+ [app.main.repo :as rp]
+ [app.main.router :as rt]
+ [app.util.i18n :refer [tr]]
+ [beicon.v2.core :as rx]
+ [cuerdas.core :as str]
+ [potok.v2.core :as ptk]))
+
+(defn enabled?
+ "Tasks ride on the branching feature, like design reviews."
+ []
+ (contains? cf/flags :branching))
+
+;; --- Task predicates
+
+(def closed-statuses
+ "A closed task is finished: verified, or dropped as won't do."
+ #{"verified" "wont-do"})
+
+(defn closed?
+ [task]
+ (contains? closed-statuses (:status task)))
+
+(defn to-do?
+ "The task needs work: open or reopened."
+ [task]
+ (contains? #{"open" "reopened"} (:status task)))
+
+(defn to-verify?
+ "The task is done and waits for someone to verify it."
+ [task]
+ (= "done" (:status task)))
+
+(defn lost?
+ "The layer of the task was deleted."
+ [task]
+ (some? (:lost-shape-name task)))
+
+(defn history?
+ "The task came with a merged branch and is already closed: it is part
+ of the history of that branch, not of the work on this file."
+ [task]
+ (and (some? (:merge-id task)) (closed? task)))
+
+(defn get-tasks-of-thread
+ "The tasks a comment thread is attached to, oldest first."
+ [tasks thread-id]
+ (->> (vals tasks)
+ (filter #(= thread-id (:thread-id %)))
+ (sort-by :created-at)))
+
+(defn get-task-of-comment
+ "The task a message of a comment thread became, if any."
+ [tasks comment-id]
+ (d/seek #(= comment-id (:comment-id %)) (vals tasks)))
+
+;; --- Locating a task on the canvas
+
+(defn shape-at-position
+ "The topmost visible layer under `position` that is not a board, or
+ the innermost board when no other layer is there; nil on the empty
+ canvas."
+ [objects position]
+ (let [hits (->> (vals objects)
+ (remove cfh/root?)
+ (remove :hidden)
+ (filter #(gsh/has-point? % position)))]
+ (when (seq hits)
+ (let [sorted (ctst/sort-z-index-objects objects hits {:bottom-frames? true})
+ shapes (remove cfh/frame-shape? sorted)]
+ (or (last shapes) (last sorted))))))
+
+(defn anchor-shape
+ "The layer a task points at, or its board when the layer is gone. None
+ when it points at the canvas itself."
+ [objects {:keys [shape-id frame-id]}]
+ (->> [(get objects shape-id) (get objects frame-id)]
+ (remove nil?)
+ (remove cfh/root?)
+ (first)))
+
+(defn anchor-position
+ "Where the mark of a task goes on the canvas, as a point: the top right
+ corner of its layer, or of its board when the layer is gone, or the
+ spot it was made on when it points at the canvas itself (`position`).
+ The thread of a layer opens there too, and a thread keeps its position
+ as a point."
+ [objects {:keys [position] :as task}]
+ (let [shape (anchor-shape objects task)]
+ (if (some? shape)
+ (let [{:keys [x y width]} (:selrect shape)]
+ (gpt/point (+ x width) y))
+ (some-> position (gpt/point)))))
+
+;; --- Fetching
+
+(defn- tasks-fetched
+ [tasks]
+ (ptk/reify ::tasks-fetched
+ ptk/UpdateEvent
+ (update [_ state]
+ (assoc state :workspace-tasks {:status :loaded
+ :data (d/index-by :id tasks)}))))
+
+(defn fetch-tasks
+ "Load the tasks of the open file."
+ []
+ (ptk/reify ::fetch-tasks
+ ptk/WatchEvent
+ (watch [_ state _]
+ (if-let [file-id (and (enabled?) (:current-file-id state))]
+ (->> (rp/cmd! :get-file-tasks {:file-id file-id})
+ (rx/map tasks-fetched)
+ (rx/catch (fn [_] (rx/of (tasks-fetched [])))))
+ (rx/empty)))))
+
+(defn- task-events-fetched
+ [task-id events]
+ (ptk/reify ::task-events-fetched
+ ptk/UpdateEvent
+ (update [_ state]
+ (assoc-in state [:workspace-task-events task-id] events))))
+
+(defn fetch-task-events
+ [task-id]
+ (assert (uuid? task-id) "expected a valid uuid for `task-id`")
+ (ptk/reify ::fetch-task-events
+ ptk/WatchEvent
+ (watch [_ _ _]
+ (->> (rp/cmd! :get-task-events {:id task-id})
+ (rx/map (partial task-events-fetched task-id))
+ (rx/catch (fn [_] (rx/empty)))))))
+
+(defn- refresh
+ "Reload the tasks and the events of the task open now, after a change
+ made here or by somebody else."
+ []
+ (ptk/reify ::refresh
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [open-id (get-in state [:workspace-tasks-local :open])]
+ (rx/concat
+ (rx/of (fetch-tasks))
+ (if (some? open-id)
+ (rx/of (fetch-task-events open-id))
+ (rx/empty)))))))
+
+(defn handle-tasks-change
+ "Another session changed the tasks of the open file."
+ [{:keys [file-id]}]
+ (ptk/reify ::handle-tasks-change
+ ptk/WatchEvent
+ (watch [_ state _]
+ (if (= file-id (:current-file-id state))
+ (rx/of (refresh))
+ (rx/empty)))))
+
+;; --- Opening a task
+
+(defn open-task
+ "Open the task `task-id` on the canvas, as the thread it lives in."
+ [task-id]
+ (ptk/reify ::open-task
+ ptk/UpdateEvent
+ (update [_ state]
+ (-> state
+ (update :workspace-tasks-local assoc :open task-id)
+ (update :workspace-tasks-local dissoc :new)
+ (update :comments-local dissoc :open :draft :expanded)))
+
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [task (get-in state [:workspace-tasks :data task-id])
+ thread (some->> (:thread-id task) (get (:comment-threads state)))]
+ (rx/concat
+ (rx/of (fetch-task-events task-id))
+ (if (some? thread)
+ (rx/of (dcmt/open-thread thread))
+ (rx/empty)))))))
+
+(defn close-task
+ []
+ (ptk/reify ::close-task
+ ptk/UpdateEvent
+ (update [_ state]
+ (update state :workspace-tasks-local dissoc :open))))
+
+(declare center-to-task)
+
+(defn navigate-to-task
+ "Take the viewport to the layer of `task` and open it."
+ [task]
+ (ptk/reify ::navigate-to-task
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [page-id (:page-id task)]
+ (rx/concat
+ (if (not= page-id (:current-page-id state))
+ (rx/of (rt/nav :workspace
+ (-> (rt/get-params state)
+ (assoc :page-id page-id))
+ {::rt/replace true}))
+ (rx/empty))
+ (->> (rx/of (center-to-task task)
+ (open-task (:id task)))
+ (rx/observe-on :async)))))))
+
+(defn open-task-link
+ "Open the task of a link (`task-id` query param): load the tasks, take
+ the viewport to it, open it and drop the param."
+ [task-id]
+ (ptk/reify ::open-task-link
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [file-id (:current-file-id state)]
+ (->> (rp/cmd! :get-file-tasks {:file-id file-id})
+ (rx/mapcat
+ (fn [tasks]
+ (let [task (d/seek #(= task-id (:id %)) tasks)]
+ (rx/concat
+ (rx/of (tasks-fetched tasks)
+ (rt/nav :workspace (dissoc (rt/get-params state) :task-id)
+ {::rt/replace true}))
+ (if (some? task)
+ (rx/of (navigate-to-task task))
+ (rx/empty))))))
+ (rx/catch (fn [_] (rx/empty))))))))
+
+;; --- Writing a new task
+
+(defn start-new-task
+ "Open the form of a new task linked to a layer: `params` carries the
+ page, board and layer (`page-id`, `frame-id`, `shape-id`) and,
+ optionally, the message of a comment thread the task comes from
+ (`thread-id` and `comment-id`, with its text as the first `title`) and
+ the design review it belongs to."
+ [params]
+ (ptk/reify ::start-new-task
+ ptk/UpdateEvent
+ (update [_ state]
+ (-> state
+ (update :workspace-tasks-local assoc :new params)
+ (update :workspace-tasks-local dissoc :open)))))
+
+(defn cancel-new-task
+ []
+ (ptk/reify ::cancel-new-task
+ ptk/UpdateEvent
+ (update [_ state]
+ (update state :workspace-tasks-local dissoc :new))))
+
+(defn- task-created
+ "Keep a new task right away: opening it needs to know its thread, before
+ the tasks of the file are fetched again."
+ [task]
+ (ptk/reify ::task-created
+ ptk/UpdateEvent
+ (update [_ state]
+ (assoc-in state [:workspace-tasks :data (:id task)] task))))
+
+(defn- fetch-task-thread
+ "The thread a new task created on the canvas got: keep it before the
+ task opens as that thread."
+ [{:keys [file-id thread-id]}]
+ (->> (rp/cmd! :get-comment-thread {:file-id file-id :id thread-id})
+ (rx/map #(dcmt/created-thread-on-workspace % false))))
+
+(defn create-task
+ "Create a task from the form. A task made from a message lives in it;
+ any other gets a thread of its own, whose first message is its title,
+ on the spot of its mark. It opens once created."
+ [{:keys [title] :as params}]
+ (assert (string? title) "expected a string `title`")
+ (ptk/reify ::create-task
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [file-id (:current-file-id state)
+ objects (dsh/lookup-page-objects state (:page-id params))
+ params (-> params
+ (select-keys [:title :page-id :frame-id :shape-id :assignee-id
+ :pull-request-id :thread-id :comment-id :position])
+ ;; the root of the page is the canvas: no layer
+ (update :shape-id #(when (not= uuid/zero %) %))
+ (update :frame-id #(or % uuid/zero))
+ (assoc :file-id file-id))
+ ;; a task on a selected layer comes with no spot: its thread
+ ;; sits where its mark goes
+ params (-> params
+ (assoc :position (some-> (or (:position params)
+ (anchor-position objects params))
+ (gpt/point)))
+ (d/without-nils))
+ thread? (some? (:thread-id params))]
+ (rx/concat
+ (rx/of (ev/event {::ev/name "create-task"
+ :from-thread thread?
+ :in-review (some? (:pull-request-id params))}))
+ (->> (rp/cmd! :create-task params)
+ (rx/mapcat (fn [task]
+ (rx/concat
+ (if thread?
+ (rx/empty)
+ (fetch-task-thread task))
+ (rx/of (task-created task)
+ (cancel-new-task)
+ (ntf/success (tr "workspace.tasks.created"))
+ (fetch-tasks)
+ (open-task (:id task))))))
+ (rx/catch (fn [cause]
+ (if (= :comment-already-has-task (:code (ex-data cause)))
+ (rx/of (ntf/warn (tr "workspace.tasks.error.comment-has-task")))
+ (rx/of (ntf/error (tr "workspace.tasks.error.generic"))))))))))))
+
+;; --- Changing a task
+
+(defn update-task
+ "Rename a task or change its assignee (`nil` leaves it without one)."
+ [task-id params]
+ (assert (uuid? task-id) "expected a valid uuid for `task-id`")
+ (ptk/reify ::update-task
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-in-when state [:workspace-tasks :data task-id]
+ merge (select-keys params [:title :assignee-id])))
+
+ ptk/WatchEvent
+ (watch [_ _ _]
+ (->> (rp/cmd! :update-task (-> (select-keys params [:title :assignee-id])
+ (assoc :id task-id)))
+ ;; a thread may show the task without having opened it
+ (rx/mapcat (fn [_] (rx/of (refresh) (fetch-task-events task-id))))
+ (rx/catch (fn [_] (rx/of (ntf/error (tr "workspace.tasks.error.generic"))
+ (refresh))))))))
+
+(defn- status-toast
+ [state {:keys [created-by]} status]
+ (let [profile-id (:profile-id state)
+ creator (get-in state [:profiles created-by :fullname])]
+ (case status
+ "done" (if (and (some? creator) (not= created-by profile-id))
+ (tr "workspace.tasks.toast.done-verify" creator)
+ (tr "workspace.tasks.toast.done"))
+ "verified" (tr "workspace.tasks.toast.verified")
+ "reopened" (tr "workspace.tasks.toast.reopened")
+ "wont-do" (tr "workspace.tasks.toast.wont-do")
+ nil)))
+
+(defn set-task-status
+ "Move a task to another state; the server records who did it."
+ [task status]
+ (assert (uuid? (:id task)) "expected a task with a valid `:id`")
+ (ptk/reify ::set-task-status
+ ptk/UpdateEvent
+ (update [_ state]
+ (d/update-in-when state [:workspace-tasks :data (:id task)] assoc :status status))
+
+ ptk/WatchEvent
+ (watch [_ state _]
+ (rx/concat
+ (rx/of (ev/event {::ev/name "set-task-status" :status status}))
+ (->> (rp/cmd! :set-task-status {:id (:id task) :status status})
+ (rx/mapcat (fn [_]
+ (let [message (status-toast state task status)]
+ (rx/concat
+ (if message
+ (rx/of (ntf/success message))
+ (rx/empty))
+ (rx/of (refresh))))))
+ (rx/catch (fn [_]
+ (rx/of (ntf/error (tr "workspace.tasks.error.generic"))
+ (refresh)))))))))
+
+(defn delete-task
+ [task-id]
+ (assert (uuid? task-id) "expected a valid uuid for `task-id`")
+ (ptk/reify ::delete-task
+ ptk/UpdateEvent
+ (update [_ state]
+ (-> state
+ (d/update-in-when [:workspace-tasks :data] dissoc task-id)
+ (update :workspace-tasks-local
+ (fn [local]
+ (cond-> local
+ (= task-id (:open local)) (dissoc :open))))))
+
+ ptk/WatchEvent
+ (watch [_ _ _]
+ (->> (rp/cmd! :delete-task {:id task-id})
+ (rx/map (fn [_] (fetch-tasks)))
+ (rx/catch (fn [_] (rx/of (ntf/error (tr "workspace.tasks.error.generic"))
+ (fetch-tasks))))))))
+
+;; --- Linking a task to another layer
+
+(defn start-relink
+ "Wait for the user to pick the layer the task points at from now on."
+ [task-id]
+ (ptk/reify ::start-relink
+ ptk/UpdateEvent
+ (update [_ state]
+ (-> state
+ (update :workspace-tasks-local assoc :relink task-id)
+ (update :workspace-tasks-local dissoc :open)))))
+
+(defn cancel-relink
+ []
+ (ptk/reify ::cancel-relink
+ ptk/UpdateEvent
+ (update [_ state]
+ (update state :workspace-tasks-local dissoc :relink))))
+
+(defn relink-task
+ "Point the task being linked (`:relink`) at `shape`."
+ [shape]
+ (ptk/reify ::relink-task
+ ptk/WatchEvent
+ (watch [_ state _]
+ (if-let [task-id (get-in state [:workspace-tasks-local :relink])]
+ (let [page-id (:current-page-id state)]
+ (rx/concat
+ (rx/of (cancel-relink))
+ (->> (rp/cmd! :relink-task {:id task-id
+ :page-id page-id
+ :frame-id (if (cfh/frame-shape? shape)
+ (:id shape)
+ (:frame-id shape))
+ :shape-id (:id shape)
+ :shape-name (:name shape)})
+ (rx/mapcat (fn [_]
+ (rx/of (ntf/success (tr "workspace.tasks.toast.relinked" (:name shape)))
+ (refresh))))
+ (rx/catch (fn [_] (rx/of (ntf/error (tr "workspace.tasks.error.generic"))))))))
+ (rx/empty)))))
+
+;; --- Deleted layers
+
+(defn- surviving-frame
+ "The board that keeps a task whose layer `shape-id` is deleted with
+ `deleted-ids`: the nearest board above the layer that stays."
+ [objects deleted-ids shape-id]
+ (let [frame (->> (cfh/get-parent-ids objects shape-id)
+ (map #(get objects %))
+ (filter cfh/frame-shape?)
+ (d/seek #(not (contains? deleted-ids (:id %)))))]
+ (or frame (get objects uuid/zero))))
+
+(defn- subtree-objects
+ "The layer and its children, parents before children, as they are now:
+ what restoring the layer puts back."
+ [objects shape-id]
+ (into []
+ (comp (map #(get objects %))
+ (remove nil?)
+ (map #(dissoc % :shapes)))
+ (cfh/get-children-ids-with-self objects shape-id)))
+
+(declare mark-layer-restored)
+(declare layer-deleted-dialog)
+
+(defn handle-deleted-shapes
+ "Some layers are about to be deleted (`ids`, with their children) from
+ `objects`: move their open tasks to the board that held them, and
+ offer to undo the deletion or to mark the tasks as done, in case the
+ deletion was the fix."
+ [objects ids]
+ (ptk/reify ::handle-deleted-shapes
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [tasks (vals (get-in state [:workspace-tasks :data]))
+ deleted-ids (into #{} (mapcat #(cfh/get-children-ids-with-self objects %)) ids)
+ affected (->> tasks
+ (remove closed?)
+ (remove lost?)
+ (filter #(contains? deleted-ids (:shape-id %))))]
+ (if (or (not (enabled?)) (empty? affected))
+ (rx/empty)
+ (let [file-id (:current-file-id state)
+ layers (->> affected
+ (map :shape-id)
+ (distinct)
+ (mapv (fn [shape-id]
+ (let [shape (get objects shape-id)
+ frame (surviving-frame objects deleted-ids shape-id)]
+ {:shape-id shape-id
+ :shape-name (:name shape)
+ :frame-id (:id frame)
+ :frame-name (when-not (cfh/root? frame) (:name frame))
+ :objects (subtree-objects objects shape-id)}))))
+ first-layer (first layers)
+ message (if (= 1 (count affected))
+ (tr "workspace.tasks.layer-deleted.one"
+ (:shape-name first-layer)
+ (or (:frame-name first-layer) (tr "workspace.tasks.canvas")))
+ (tr "workspace.tasks.layer-deleted.many" (count affected)))]
+ (->> (rp/cmd! :mark-tasks-layer-deleted {:file-id file-id :layers layers})
+ (rx/mapcat
+ (fn [moved]
+ (rx/of (refresh)
+ (layer-deleted-dialog moved message))))
+ (rx/catch (fn [_] (rx/empty))))))))))
+
+(defn- layer-deleted-dialog
+ "The dialog that follows the deletion of layers with open tasks: undo
+ the deletion, or mark the tasks as done."
+ [moved message]
+ (ptk/reify ::layer-deleted-dialog
+ ptk/WatchEvent
+ (watch [_ _ _]
+ (let [output-s (rx/subject)
+ close (fn [& events]
+ (rx/push! output-s (ntf/hide :tag :task-layer-deleted))
+ (run! #(rx/push! output-s %) events)
+ (rx/end! output-s))]
+ (rx/merge
+ output-s
+ (rx/of (ntf/dialog
+ :content message
+ :controls :inline-actions
+ :tag :task-layer-deleted
+ :cancel {:label (tr "workspace.tasks.layer-deleted.undo")
+ :callback #(apply close dwu/undo (map mark-layer-restored moved))}
+ :accept {:label (tr "workspace.tasks.actions.mark-done")
+ :callback #(apply close (map (fn [task] (set-task-status task "done")) moved))})))))))
+
+(defn- mark-layer-restored
+ "The layer of the task is back: the task points at it again."
+ [task]
+ (ptk/reify ::mark-layer-restored
+ ptk/WatchEvent
+ (watch [_ state _]
+ (let [objects (dsh/lookup-page-objects state (:page-id task))
+ shape (get objects (:shape-id task))]
+ (->> (rp/cmd! :mark-task-layer-restored
+ {:id (:id task)
+ :frame-id (or (some-> shape :frame-id) uuid/zero)})
+ (rx/map (fn [_] (refresh)))
+ (rx/catch (fn [_] (rx/empty))))))))
+
+(defn restore-task-layer
+ "Put back the deleted layer of `task`, as it was when it was deleted
+ (the event of the deletion keeps it), and point the task at it again.
+ The layer goes back into its parent when the parent is still there,
+ into the board that keeps the task otherwise."
+ [task]
+ (ptk/reify ::restore-task-layer
+ ptk/WatchEvent
+ (watch [it state _]
+ (let [page-id (:page-id task)
+ objects (dsh/lookup-page-objects state page-id)
+ events (get-in state [:workspace-task-events (:id task)])
+ deleted (->> events
+ (filter #(= "layer-deleted" (:type %)))
+ (last))
+ [root & children :as shapes] (get-in deleted [:payload :objects])]
+ (if (or (empty? shapes) (contains? objects (:id root)))
+ (rx/of (mark-layer-restored task))
+ (let [parent-id (if (contains? objects (:parent-id root))
+ (:parent-id root)
+ (:frame-id task))
+ parent (get objects parent-id)
+ frame-id (if (cfh/frame-shape? parent) parent-id (:frame-id parent))
+ root (assoc root :parent-id parent-id :frame-id frame-id)
+ changes (-> (pcb/empty-changes it page-id)
+ (pcb/with-objects objects)
+ (pcb/add-objects (into [root] children)))]
+ (rx/of (dch/commit-changes changes)
+ (mark-layer-restored task)
+ (ntf/success (tr "workspace.tasks.toast.layer-restored" (:name root))))))))))
+
+;; --- Viewport
+
+(defn center-to-task
+ "Center the viewport on the mark of `task`."
+ [task]
+ (ptk/reify ::center-to-task
+ ptk/UpdateEvent
+ (update [_ state]
+ (let [objects (dsh/lookup-page-objects state (:page-id task))
+ position (anchor-position objects task)]
+ (if (nil? position)
+ state
+ (update state :workspace-local
+ (fn [{:keys [vbox] :as local}]
+ (update local :vbox assoc
+ :x (- (:x position) (/ (:width vbox) 2))
+ :y (- (:y position) (/ (:height vbox) 2))))))))
+
+ ptk/EffectEvent
+ (effect [_ state _]
+ (dwvw/maybe-sync-workspace-local-viewport! state))))
+
+;; --- Counting
+
+(defn tasks-for
+ "The tasks that still need work from `profile-id`."
+ [tasks profile-id]
+ (filter #(and (to-do? %) (= profile-id (:assignee-id %))) tasks))
+
+(defn review-tasks
+ "The tasks of the design review `pull-request-id`."
+ [tasks pull-request-id]
+ (filter #(= pull-request-id (:pull-request-id %)) tasks))
+
+(defn sort-tasks
+ "Open work first (oldest first), then the tasks to verify, then the
+ closed ones."
+ [tasks]
+ (sort-by (juxt #(cond (to-do? %) 0 (to-verify? %) 1 :else 2)
+ #(dm/get-prop % :created-at))
+ tasks))
+
+(defn search
+ [tasks text]
+ (if (str/blank? text)
+ tasks
+ (let [text (str/lower text)]
+ (filter #(str/includes? (str/lower (:title %)) text) tasks))))
diff --git a/frontend/src/app/main/refs.cljs b/frontend/src/app/main/refs.cljs
index 877cb65b83..489867fb6c 100644
--- a/frontend/src/app/main/refs.cljs
+++ b/frontend/src/app/main/refs.cljs
@@ -55,6 +55,27 @@
;; the review banner/actions. nil when no review is active.
(l/derived #(get % :workspace-pr-preview) st/state))
+(def tasks
+ "The tasks of the open file, by id."
+ (l/derived #(get-in % [:workspace-tasks :data]) st/state))
+
+(def task-events
+ "The events of the tasks opened so far, by task id."
+ (l/derived :workspace-task-events st/state))
+
+(def tasks-local
+ "What the user is doing with the tasks: the one open (`:open`), the
+ new one being written (`:new`), the one being linked to another layer
+ (`:relink`)."
+ (l/derived :workspace-tasks-local st/state))
+
+(def review-local
+ "The tool, panel tab, filters and shown change of the review mode."
+ (l/derived :workspace-review-local st/state))
+
+(def review-activity
+ (l/derived :workspace-review-activity st/state))
+
(def pending-reviews
;; dashboard: open pull requests awaiting the current profile's review
(l/derived #(get % :dashboard-pending-reviews) st/state))
@@ -83,11 +104,19 @@
(and (contains? #{"merged" "archived"} (get-in ctx [:info :status]))
(= (:file-id ctx) (:current-file-id state)))))
+(defn- reviewing?
+ "True while the open file is shown inside a design review: the review
+ is read-only, the branch is edited outside it."
+ [state]
+ (some? (:workspace-pr-preview state)))
+
(def permissions
- "The team permissions, without edition on a merged or archived branch."
+ "The team permissions, without edition on a merged or archived branch
+ nor inside a design review."
(l/derived (fn [state]
(cond-> (:permissions (dsh/lookup-team state))
- (open-closed-branch? state)
+ (or (open-closed-branch? state)
+ (reviewing? state))
(assoc :can-edit false)))
st/state))
@@ -100,6 +129,18 @@
(def threads
(l/derived :comment-threads st/state))
+(def layer-comment-counts
+ "How many open comment threads point at each layer, by layer id: the
+ count the layers panel shows next to a layer."
+ (l/derived (fn [threads]
+ (reduce (fn [acc {:keys [anchor-type shape-id is-resolved]}]
+ (if (and (= :layer anchor-type) (some? shape-id) (not is-resolved))
+ (update acc shape-id (fnil inc 0))
+ acc))
+ {}
+ (vals threads)))
+ threads))
+
(def share-links
(l/derived :share-links st/state))
@@ -197,6 +238,11 @@
(def workspace-global
(l/derived :workspace-global st/state))
+(def bottom-bar
+ "Which bar at the bottom of the canvas of a branch is open, without a branch
+ nil (see `app.main.data.workspace.layout`)."
+ (l/derived :bottom-bar workspace-global))
+
(def mcp
(l/derived :mcp st/state))
diff --git a/frontend/src/app/main/ui.cljs b/frontend/src/app/main/ui.cljs
index 9c1c581668..7e0e98c168 100644
--- a/frontend/src/app/main/ui.cljs
+++ b/frontend/src/app/main/ui.cljs
@@ -197,12 +197,14 @@
file-id (some-> params :file-id uuid/parse*)
page-id (some-> params :page-id uuid/parse*)
pr-id (some-> params :pr-id uuid/parse*)
+ task-id (some-> params :task-id uuid/parse*)
layout (some-> params :layout keyword)]
[:> team-container* {:team-id team-id}
[:> workspace-page* {:team-id team-id
:file-id file-id
:page-id page-id
:pr-id pr-id
+ :task-id task-id
:layout-name layout
:key file-id}]])
diff --git a/frontend/src/app/main/ui/comments.cljs b/frontend/src/app/main/ui/comments.cljs
index 706e41c72e..fa524a6c74 100644
--- a/frontend/src/app/main/ui/comments.cljs
+++ b/frontend/src/app/main/ui/comments.cljs
@@ -18,6 +18,7 @@
[app.main.data.comments :as dcm]
[app.main.data.modal :as modal]
[app.main.data.workspace.comments :as dwcm]
+ [app.main.data.workspace.tasks :as dwtk]
[app.main.refs :as refs]
[app.main.store :as st]
[app.main.ui.components.dropdown :refer [dropdown]]
@@ -25,6 +26,8 @@
[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 :refer [icon*] :as i]
+ [app.main.ui.ds.product.review-label :refer [review-label*]]
+ [app.main.ui.ds.tooltip :refer [tooltip*]]
[app.main.ui.hooks :as h]
[app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]]
@@ -206,7 +209,6 @@
;; Component that renders the component content
(mf/defc comment-content*
- {::mf/private true}
[{:keys [content]}]
(let [comment-elements (mf/use-memo (mf/deps content) #(parse-comment content))]
(for [[idx {:keys [type content]}] (d/enumerate comment-elements)]
@@ -657,7 +659,6 @@
:avatar-darken (= variant "solved"))}]]))
(mf/defc comment-info*
- {::mf/private true}
[{:keys [item profile]}]
[:*
[:div {:class (stl/css :author)}
@@ -921,23 +922,39 @@
(dom/stop-propagation event)
(st/emit! (dcm/toggle-comment-options uuid/zero))))
+ ;; the tasks of the thread live in its messages and go with it
+ tasks (mf/deref refs/tasks)
+ tasks? (mf/with-memo [tasks thread]
+ (boolean (seq (dwtk/get-tasks-of-thread tasks (:id thread)))))
+
delete-thread
(mf/use-fn
+ (mf/deps thread origin tasks?)
(fn []
(st/emit! (dcm/close-thread)
- (if (= origin :viewer)
+ (cond
+ (= origin :viewer)
(dcm/delete-comment-thread-on-viewer thread)
+
+ tasks?
+ (dcm/delete-comment-thread-on-workspace
+ thread #(st/emit! (dwtk/fetch-tasks)))
+
+ :else
(dcm/delete-comment-thread-on-workspace thread)))))
on-delete-thread
(mf/use-fn
+ (mf/deps delete-thread tasks?)
(fn [event]
(dom/stop-propagation event)
(st/emit! (dcm/hide-comment-options))
(st/emit! (modal/show
{:type :confirm
:title (tr "modals.delete-comment-thread.title")
- :message (tr "modals.delete-comment-thread.message")
+ :message (if tasks?
+ (tr "modals.delete-comment-thread.message-tasks")
+ (tr "modals.delete-comment-thread.message"))
:accept-label (tr "modals.delete-comment-thread.accept")
:on-accept delete-thread}))))
@@ -953,9 +970,14 @@
(tr "labels.comment") " " [:span {:class (stl/css :grayed-text)} "#" (:seqn thread)]]
[:div {:class (stl/css :floating-thread-header-right)}
(when (some? thread)
- [:> checkbox* {:class (stl/css :checkbox-wrapper)
- :checked (:is-resolved thread)
- :on-change toggle-resolved}])
+ (let [label (if (:is-resolved thread)
+ (tr "labels.mark-as-unresolved")
+ (tr "labels.mark-as-resolved"))]
+ [:> tooltip* {:content label :placement "top"}
+ [:div {:class (stl/css :checkbox-wrapper)}
+ [:> checkbox* {:checked (:is-resolved thread)
+ :aria-label label
+ :on-change toggle-resolved}]]]))
(when (= (:id profile) (:id owner))
[:> icon-button* {:variant "ghost"
:aria-label (tr "labels.options")
@@ -969,8 +991,12 @@
(tr "labels.delete-comment-thread")]]]]))
(mf/defc comment-floating-thread-item*
+ "A message of a thread. `thread` comes only with its first message, the
+ one that cannot be deleted on its own; `parent` is the thread of any
+ message. Each message may become a task, which `task-section` shows
+ under it."
{::mf/private true}
- [{:keys [comment thread]}]
+ [{:keys [comment thread parent origin task task-section]}]
(let [owner (dcm/get-owner comment)
profile (mf/deref refs/profile)
options (mf/deref ref:comments-local-options)
@@ -1000,7 +1026,15 @@
on-delete-comment
(mf/use-fn
(mf/deps comment)
- #(st/emit! (dcm/delete-comment comment)))
+ (fn [event]
+ (dom/stop-propagation event)
+ (st/emit! (dcm/hide-comment-options)
+ (modal/show
+ {:type :confirm
+ :title (tr "modals.delete-comment.title")
+ :message (tr "modals.delete-comment.message")
+ :accept-label (tr "modals.delete-comment.accept")
+ :on-accept #(st/emit! (dcm/delete-comment comment))}))))
on-submit
(mf/use-fn
@@ -1010,7 +1044,33 @@
(st/emit! (dcm/update-comment (assoc comment :content content)))))
on-cancel
- (mf/use-fn #(reset! edition? false))]
+ (mf/use-fn #(reset! edition? false))
+
+ can-task? (and (dwtk/enabled?)
+ (not= origin :viewer)
+ (nil? task))
+
+ ;; "Make it a task": the title comes from the message, the layer is
+ ;; the one the thread points at (its board otherwise)
+ on-make-task
+ (mf/use-fn
+ (mf/deps comment parent)
+ (fn [event]
+ (dom/stop-propagation event)
+ (let [text (str/trim (str/replace (or (:content comment) "")
+ #"@\[([^\]]*)\]\([^\)]*\)" "@$1"))]
+ (st/emit! (dwtk/start-new-task
+ {:page-id (:page-id parent)
+ :frame-id (:frame-id parent)
+ :shape-id (if (= :layer (:anchor-type parent))
+ (:shape-id parent)
+ (:frame-id parent))
+ :position (:position parent)
+ :thread-id (:id parent)
+ :comment-id (:id comment)
+ :pull-request-id (when (= "open" (:pull-request-status parent))
+ (:pull-request-id parent))
+ :title (subs text 0 (min 250 (count text)))})))))]
[:div {:class (stl/css :floating-thread-item-wrapper)}
[:div {:class (stl/css :floating-thread-item)}
@@ -1021,19 +1081,29 @@
[:div {:class (stl/css :author-timeago)}
(ct/timeago (:modified-at comment))]]
+ (when ^boolean can-task?
+ [:> icon-button* {:variant "ghost"
+ :aria-label (tr "workspace.tasks.make-task")
+ :on-click on-make-task
+ :icon i/view-as-list}])
+
(when (= (:id profile) (:id owner))
[:> icon-button* {:variant "ghost"
:aria-label (tr "labels.options")
:on-click on-toggle-options
:icon i/menu}])]
- [:div {:class (stl/css :item)}
+ [:div {:class (stl/css-case :item true
+ :message (not @edition?))}
(if @edition?
[:> comment-edit-form* {:content (:content comment)
:on-submit on-submit
:on-cancel on-cancel}]
[:span {:class (stl/css :text)}
- [:> comment-content* {:content (:content comment)}]])]]
+ [:> comment-content* {:content (:content comment)}]])]
+
+ (when (and (some? task) (some? task-section))
+ [:> task-section {:task task}])]
[:& dropdown {:show (= options (:id comment))
:on-close on-hide-options}
@@ -1052,7 +1122,7 @@
(mf/defc comment-floating-thread*
{::mf/wrap [mf/memo]}
- [{:keys [thread zoom origin position-modifier viewport]}]
+ [{:keys [thread zoom origin position-modifier viewport task-section]}]
(let [ref (mf/use-ref)
mentions-s (mf/use-memo #(rx/subject))
thread-id (:id thread)
@@ -1077,12 +1147,19 @@
(make-comments-ref thread-id))
comments-map (mf/deref comments-ref)
+ tasks (mf/deref refs/tasks)
+
comments (mf/with-memo [comments-map]
(->> (vals comments-map)
(sort-by :created-at)))
first-comment (first comments)
+ ;; the tasks whose message is gone stay at the end of their thread
+ loose-tasks (mf/with-memo [tasks thread-id comments-map]
+ (->> (dwtk/get-tasks-of-thread tasks thread-id)
+ (remove #(contains? comments-map (:comment-id %)))))
+
on-submit
(mf/use-fn
(mf/deps thread)
@@ -1129,12 +1206,29 @@
[:> comment-floating-thread-header* {:thread thread
:origin origin}]]
+ (when (some? (:pull-request-id thread))
+ [:> review-label* {:label (or (:pull-request-title thread)
+ (tr "workspace.review.design-review"))}])
+
+ ;; the workspace passes what a message shows about its task
[:div {:class (stl/css :floating-thread-main)}
[:> comment-floating-thread-item* {:comment first-comment
- :thread thread}]
+ :thread thread
+ :parent thread
+ :origin origin
+ :task (dwtk/get-task-of-comment tasks (:id first-comment))
+ :task-section task-section}]
(for [item (rest comments)]
[:* {:key (dm/str (:id item))}
- [:> comment-floating-thread-item* {:comment item}]])]
+ [:> comment-floating-thread-item* {:comment item
+ :parent thread
+ :origin origin
+ :task (dwtk/get-task-of-comment tasks (:id item))
+ :task-section task-section}]])
+
+ (when (some? task-section)
+ (for [task loose-tasks]
+ [:> task-section {:key (dm/str (:id task)) :task task}]))]
[:> comment-reply-form* {:on-submit on-submit
:on-cancel (when (= origin :viewer) on-cancel)}]
@@ -1259,6 +1353,23 @@
:variant "read"}
num-threads]]))
+(mf/defc preview-card*
+ "The small card that hovering a mark on the canvas shows."
+ [{:keys [children]}]
+ [:div {:class (stl/css :floating-thread-wrapper
+ :floating-preview-displacement
+ :floating-preview-hover-card)}
+ [:div {:class (stl/css :floating-thread-item-wrapper)}
+ [:div {:class (stl/css :floating-thread-item)}
+ children]]])
+
+(mf/defc thread-preview*
+ "The small card of a comment thread."
+ [{:keys [thread owner]}]
+ [:> preview-card* {}
+ [:> comment-info* {:item thread
+ :profile owner}]])
+
(mf/defc comment-floating-bubble*
{::mf/wrap [mf/memo]}
[{:keys [thread zoom is-open on-click origin position-modifier offset ring]}]
@@ -1427,13 +1538,7 @@
:else "read")}]]
(when (:is-hover @state)
- [:div {:class (stl/css :floating-thread-wrapper
- :floating-preview-displacement
- :floating-preview-hover-card)}
- [:div {:class (stl/css :floating-thread-item-wrapper)}
- [:div {:class (stl/css :floating-thread-item)}
- [:> comment-info* {:item thread
- :profile owner}]]]])]))
+ [:> thread-preview* {:thread thread :owner owner}])]))
(mf/defc comment-sidebar-thread-item*
{::mf/private true}
diff --git a/frontend/src/app/main/ui/comments.scss b/frontend/src/app/main/ui/comments.scss
index 547d6e95ef..67c8555e1c 100644
--- a/frontend/src/app/main/ui/comments.scss
+++ b/frontend/src/app/main/ui/comments.scss
@@ -57,6 +57,7 @@
.author-identity {
flex-grow: 1;
+ min-inline-size: 0;
}
.author-fullname {
@@ -144,6 +145,14 @@
white-space: pre-wrap;
}
+// a message of a thread sits in a box, apart from its author and what comes
+// after it
+.message {
+ padding: var(--sp-s) var(--sp-m);
+ border-radius: $br-8;
+ background-color: var(--color-background-tertiary);
+}
+
.replies {
@include use-typography("body-small");
@@ -160,6 +169,7 @@
}
.floating-preview-wrapper {
+ // TODO: no DS z-index token for 1.
z-index: 1;
position: absolute;
user-select: none;
@@ -179,6 +189,7 @@
}
.floating-preview-expanded {
+ // TODO: no DS z-index token for 2.
z-index: 2;
animation: comment-bubble-fan-out 0.18s ease-out;
}
@@ -196,10 +207,12 @@
}
.floating-preview-hovered {
+ // TODO: no DS z-index token for 10.
z-index: 10;
}
.floating-preview-ghost {
+ // TODO: no DS z-index token for 1.
z-index: 1;
opacity: 0.6;
pointer-events: none;
@@ -297,12 +310,19 @@
.floating-thread-header-left {
@include use-typography("body-small");
+ display: flex;
+ align-items: center;
+ gap: var(--sp-xs);
+ min-inline-size: 0;
color: var(--color-foreground-primary);
}
+// the same gap as the author of a message, so the checkbox and the menu
+// line up with its buttons
.floating-thread-header-right {
display: flex;
align-items: center;
+ gap: var(--sp-s);
}
.floating-thread-main {
@@ -325,9 +345,17 @@
gap: var(--sp-s);
}
-// .checkbox-wrapper {
-// margin-inline-end: var(--sp-s);
-// }
+// the resolve checkbox takes the box of an icon button, so it lines up
+// with the buttons of the messages under it. The DS checkbox keeps an
+// empty column for its label after the box: centering the whole would move
+// the box to the left, so the box sits at the middle from the start.
+.checkbox-wrapper {
+ display: flex;
+ align-items: center;
+ inline-size: $sz-32;
+ block-size: $sz-32;
+ padding-inline-start: calc(($sz-32 - $sz-16) / 2);
+}
.dropdown-menu {
position: absolute;
@@ -338,8 +366,8 @@
border-radius: $br-8;
z-index: var(--z-index-dropdown);
overflow: hidden auto;
- background-color: var(--menu-background-color);
- color: var(--menu-foreground-color);
+ background-color: var(--color-background-tertiary);
+ color: var(--color-foreground-primary);
border: $b-2 solid var(--color-background-quaternary);
box-shadow: 0 0 var(--sp-m) 0 var(--color-shadow-dark);
max-inline-size: $sz-200;
@@ -350,6 +378,10 @@
}
.dropdown-menu-option {
+ --dropdown-menu-option-bg-color: transparent;
+ --dropdown-menu-option-fg-color: var(--color-foreground-secondary);
+ --dropdown-menu-option-icon-color: var(--color-foreground-secondary);
+
@include use-typography("body-small");
display: flex;
@@ -358,9 +390,11 @@
block-size: $sz-32;
padding: 0 var(--sp-s);
border-radius: $br-6;
+ background-color: var(--dropdown-menu-option-bg-color);
cursor: pointer;
- color: var(--menu-foreground-color-rest);
+ color: var(--dropdown-menu-option-fg-color);
+ // span: the text of an option has no class in comments.cljs
span {
justify-content: center;
align-items: center;
@@ -370,24 +404,22 @@
text-overflow: ellipsis;
white-space: nowrap;
+ // svg: the icon of an option has no class in comments.cljs
svg {
display: flex;
justify-content: center;
align-items: center;
block-size: $sz-12;
inline-size: $sz-12;
- stroke-width: 1.33px;
- stroke: var(--icon-foreground);
+ stroke-width: px2rem(1.33);
+ stroke: var(--dropdown-menu-option-icon-color);
}
}
&:hover {
- background-color: var(--menu-background-color-hover);
- color: var(--menu-foreground-color);
-
- svg {
- stroke: var(--menu-foreground-color-hover);
- }
+ --dropdown-menu-option-bg-color: var(--color-background-quaternary);
+ --dropdown-menu-option-fg-color: var(--color-foreground-primary);
+ --dropdown-menu-option-icon-color: var(--color-foreground-primary);
}
}
@@ -465,7 +497,7 @@
}
.comments-mentions-entry.is-selected {
- border: 1px solid var(--color-accent-primary-muted);
+ border: $b-1 solid var(--color-accent-primary-muted);
background: var(--color-background-quaternary);
}
diff --git a/frontend/src/app/main/ui/css_cursors.cljs b/frontend/src/app/main/ui/css_cursors.cljs
index 8541d7bedf..471d92cf3d 100644
--- a/frontend/src/app/main/ui/css_cursors.cljs
+++ b/frontend/src/app/main/ui/css_cursors.cljs
@@ -40,6 +40,7 @@
(init-static-cursor-style style "create-polygon" cur/create-polygon)
(init-static-cursor-style style "create-rectangle" cur/create-rectangle)
(init-static-cursor-style style "create-shape" cur/create-shape)
+ (init-static-cursor-style style "create-task" cur/create-task)
(init-static-cursor-style style "draw" cur/draw)
(init-static-cursor-style style "draw-add" cur/draw-add)
(init-static-cursor-style style "draw-node" cur/draw-node)
diff --git a/frontend/src/app/main/ui/cursors.cljs b/frontend/src/app/main/ui/cursors.cljs
index 9453f285d5..76b59a5102 100644
--- a/frontend/src/app/main/ui/cursors.cljs
+++ b/frontend/src/app/main/ui/cursors.cljs
@@ -14,6 +14,7 @@
(def ^:cursor create-polygon (cursor-ref :create-polygon))
(def ^:cursor create-rectangle (cursor-ref :create-rectangle))
(def ^:cursor create-shape (cursor-ref :create-shape))
+(def ^:cursor create-task (cursor-ref :create-task 0 2 20))
(def ^:cursor draw (cursor-ref :draw 0 0 0))
(def ^:cursor draw-add (cursor-ref :draw-add 0 0 0 25 25))
(def ^:cursor draw-node (cursor-ref :draw-node 0 0 0 25 25))
diff --git a/frontend/src/app/main/ui/ds.cljs b/frontend/src/app/main/ui/ds.cljs
index 162d2877a5..640f5c133f 100644
--- a/frontend/src/app/main/ui/ds.cljs
+++ b/frontend/src/app/main/ui/ds.cljs
@@ -8,6 +8,7 @@
(:require
[app.main.ui.ds.buttons.button :refer [button*]]
[app.main.ui.ds.buttons.icon-button :refer [icon-button*]]
+ [app.main.ui.ds.buttons.link-button :refer [link-button*]]
[app.main.ui.ds.controls.checkbox :refer [checkbox*]]
[app.main.ui.ds.controls.combobox :refer [combobox*]]
[app.main.ui.ds.controls.input :refer [input*]]
@@ -15,6 +16,7 @@
[app.main.ui.ds.controls.radio-buttons :refer [radio-buttons*]]
[app.main.ui.ds.controls.select :refer [select*]]
[app.main.ui.ds.controls.switch :refer [switch*]]
+ [app.main.ui.ds.controls.textarea :refer [textarea*]]
[app.main.ui.ds.controls.utilities.hint-message :refer [hint-message*]]
[app.main.ui.ds.controls.utilities.input-field :refer [input-field*]]
[app.main.ui.ds.controls.utilities.label :refer [label*]]
@@ -38,17 +40,24 @@
[app.main.ui.ds.product.branch-row :refer [branch-row*]]
[app.main.ui.ds.product.branch-status :refer [branch-status*]]
[app.main.ui.ds.product.change-row :refer [change-row*]]
+ [app.main.ui.ds.product.comment-card :refer [comment-card*]]
[app.main.ui.ds.product.cta :refer [cta*]]
[app.main.ui.ds.product.empty-placeholder :refer [empty-placeholder*]]
[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.input-with-meta :refer [input-with-meta*]]
+ [app.main.ui.ds.product.layer-chip :refer [layer-chip*]]
[app.main.ui.ds.product.loader :refer [loader*]]
[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*]]
[app.main.ui.ds.product.tag :refer [tag*]]
+ [app.main.ui.ds.product.task-row :refer [task-row*]]
+ [app.main.ui.ds.product.task-status :refer [task-status*]]
[app.main.ui.ds.storybook :as sb]
[app.main.ui.ds.tooltip.tooltip :refer [tooltip*]]
[app.main.ui.ds.utilities.date :refer [date*]]
@@ -97,6 +106,15 @@
:FilterChip filter-chip*
:PreviewCard preview-card*
:Tag tag*
+ :CommentCard comment-card*
+ :LayerChip layer-chip*
+ :LinkButton link-button*
+ :ProgressBar progress-bar*
+ :ReviewLabel review-label*
+ :ReviewMarker review-marker*
+ :Textarea textarea*
+ :TaskRow task-row*
+ :TaskStatus task-status*
:Milestone milestone*
:MilestoneGroup milestone-group*
:Date date*
diff --git a/frontend/src/app/main/ui/ds/buttons/link_button.cljs b/frontend/src/app/main/ui/ds/buttons/link_button.cljs
new file mode 100644
index 0000000000..a641a2fad7
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/buttons/link_button.cljs
@@ -0,0 +1,35 @@
+;; 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.buttons.link-button
+ (:require-macros
+ [app.main.style :as stl])
+ (:require
+ [app.common.data :as d]
+ [app.main.ui.ds.foundations.assets.icon :refer [icon*] :as i]
+ [rumext.v2 :as mf]))
+
+(def ^:private schema:link-button
+ [:map
+ [:class {:optional true} [:maybe :string]]
+ [:icon {:optional true} [:maybe [:and :string [:fn #(contains? i/icon-list %)]]]]
+ [:tone {:optional true} [:maybe [:enum "accent" "info" "neutral"]]]])
+
+(mf/defc link-button*
+ "An action that reads as a link inside a line of text: no box, underlined
+ on hover. `icon` goes before the text."
+ {::mf/schema schema:link-button}
+ [{:keys [class icon tone children] :rest props}]
+ (let [tone (d/nilv tone "accent")
+ props (mf/spread-props props
+ {:class [class (stl/css-case :link-button true
+ :tone-info (= tone "info")
+ :tone-neutral (= tone "neutral"))]
+ :type "button"})]
+ [:> :button props
+ (when icon
+ [:> icon* {:icon-id icon :size "s"}])
+ children]))
diff --git a/frontend/src/app/main/ui/ds/buttons/link_button.mdx b/frontend/src/app/main/ui/ds/buttons/link_button.mdx
new file mode 100644
index 0000000000..83f30df077
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/buttons/link_button.mdx
@@ -0,0 +1,30 @@
+{ /* 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 LinkButton from "./link_button.stories";
+
+
+
+# LinkButton
+
+An action that reads as a link inside a line of text.
+
+
+
+## Variants
+
+`tone` is `accent` (default), `info` or `neutral`.
+
+## Technical notes
+
+It renders a `button`, so use it for actions; a link that navigates is an
+`a`. `icon` goes before the text.
+
+```clj
+[:> link-button* {:icon i/add :on-click on-add}
+ (tr "workspace.tasks.new-task")]
+```
diff --git a/frontend/src/app/main/ui/ds/buttons/link_button.scss b/frontend/src/app/main/ui/ds/buttons/link_button.scss
new file mode 100644
index 0000000000..02ad53690c
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/buttons/link_button.scss
@@ -0,0 +1,34 @@
+// 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/typography.scss" as *;
+
+.link-button {
+ --link-button-fg-color: var(--color-accent-primary);
+
+ @include use-typography("body-small");
+
+ display: inline-flex;
+ align-items: center;
+ gap: var(--sp-xs);
+ padding: 0;
+ border: none;
+ background: none;
+ color: var(--link-button-fg-color);
+ cursor: pointer;
+
+ &:hover {
+ text-decoration: underline;
+ }
+
+ &.tone-info {
+ --link-button-fg-color: var(--color-accent-info);
+ }
+
+ &.tone-neutral {
+ --link-button-fg-color: var(--color-foreground-secondary);
+ }
+}
diff --git a/frontend/src/app/main/ui/ds/buttons/link_button.stories.jsx b/frontend/src/app/main/ui/ds/buttons/link_button.stories.jsx
new file mode 100644
index 0000000000..918edf6fa1
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/buttons/link_button.stories.jsx
@@ -0,0 +1,38 @@
+// 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 { LinkButton } = Components;
+
+export default {
+ title: "Buttons/LinkButton",
+ component: LinkButton,
+ argTypes: {
+ tone: {
+ options: ["accent", "info", "neutral"],
+ control: { type: "select" },
+ },
+ },
+ args: {
+ tone: "accent",
+ children: "See more",
+ },
+ render: ({ ...args }) => ,
+};
+
+export const Default = {};
+
+export const AllTones = {
+ render: () => (
+
+ Accent
+ Info
+ Neutral
+
+ ),
+};
diff --git a/frontend/src/app/main/ui/ds/controls/select.cljs b/frontend/src/app/main/ui/ds/controls/select.cljs
index 3d7a65b9a3..23869811a2 100644
--- a/frontend/src/app/main/ui/ds/controls/select.cljs
+++ b/frontend/src/app/main/ui/ds/controls/select.cljs
@@ -312,7 +312,9 @@
:empty-to-end empty-to-end
:ref set-option-ref
:wrapper-ref dropdown-wrapper-ref}])
- container)
+ ;; a modal makes everything outside it inert: its dropdown stays inside
+ (or (some-> (mf/ref-val select-ref) (.closest "[role='dialog']"))
+ container))
[:> options-dropdown* {:on-click on-option-click
:id listbox-id
:options options
diff --git a/frontend/src/app/main/ui/ds/controls/textarea.cljs b/frontend/src/app/main/ui/ds/controls/textarea.cljs
new file mode 100644
index 0000000000..8955b677fb
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/controls/textarea.cljs
@@ -0,0 +1,23 @@
+;; 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.controls.textarea
+ (:require-macros
+ [app.main.style :as stl])
+ (:require
+ [rumext.v2 :as mf]))
+
+(def ^:private schema:textarea
+ [:map
+ [:class {:optional true} [:maybe :string]]])
+
+(mf/defc textarea*
+ "A text area of several lines. It takes the props of a `textarea`; name
+ it with `aria-label` or a `label`."
+ {::mf/schema schema:textarea}
+ [{:keys [class] :rest props}]
+ (let [props (mf/spread-props props {:class [class (stl/css :textarea)]})]
+ [:> :textarea props]))
diff --git a/frontend/src/app/main/ui/ds/controls/textarea.mdx b/frontend/src/app/main/ui/ds/controls/textarea.mdx
new file mode 100644
index 0000000000..68bc72a625
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/controls/textarea.mdx
@@ -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 */ }
+
+import { Canvas, Meta } from '@storybook/addon-docs/blocks';
+import * as Textarea from "./textarea.stories";
+
+
+
+# Textarea
+
+A text area of several lines.
+
+
+
+## Technical notes
+
+It takes the props of a `textarea` (`value`, `rows`, `max-length`,
+`placeholder`, `on-change`...). Name it with `aria-label` or a `label`.
+Set `--textarea-resize` through `class` to change how it resizes.
+
+```clj
+[:> textarea* {:value value
+ :rows 3
+ :aria-label (tr "workspace.tasks.title")
+ :on-change on-change}]
+```
diff --git a/frontend/src/app/main/ui/ds/controls/textarea.scss b/frontend/src/app/main/ui/ds/controls/textarea.scss
new file mode 100644
index 0000000000..8602dd0937
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/controls/textarea.scss
@@ -0,0 +1,30 @@
+// 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 *;
+
+.textarea {
+ --textarea-border-color: var(--color-background-quaternary);
+
+ @include use-typography("body-small");
+
+ inline-size: 100%;
+ padding: var(--sp-s);
+ border: $b-1 solid var(--textarea-border-color);
+ border-radius: $br-8;
+ background-color: var(--color-background-tertiary);
+ color: var(--color-foreground-primary);
+
+ // a caller may fix its height
+ resize: var(--textarea-resize, vertical);
+
+ &:focus {
+ --textarea-border-color: var(--color-accent-primary);
+
+ outline: none;
+ }
+}
diff --git a/frontend/src/app/main/ui/ds/controls/textarea.stories.jsx b/frontend/src/app/main/ui/ds/controls/textarea.stories.jsx
new file mode 100644
index 0000000000..faf29d2a1b
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/controls/textarea.stories.jsx
@@ -0,0 +1,27 @@
+// 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 { Textarea } = Components;
+
+export default {
+ title: "Controls/Textarea",
+ component: Textarea,
+ args: {
+ rows: 3,
+ placeholder: "What needs to be done?",
+ "aria-label": "Title",
+ },
+ render: ({ ...args }) => (
+
+
+
+ ),
+};
+
+export const Default = {};
diff --git a/frontend/src/app/main/ui/ds/foundations/assets/icon.cljs b/frontend/src/app/main/ui/ds/foundations/assets/icon.cljs
index 11512ae6c5..4c7743a20a 100644
--- a/frontend/src/app/main/ui/ds/foundations/assets/icon.cljs
+++ b/frontend/src/app/main/ui/ds/foundations/assets/icon.cljs
@@ -103,6 +103,7 @@
(def ^:icon-id collapse "collapse")
(def ^:icon-id column "column")
(def ^:icon-id column-reverse "column-reverse")
+(def ^:icon-id comment-area "comment-area")
(def ^:icon-id comments "comments")
(def ^:icon-id component "component")
(def ^:icon-id component-copy "component-copy")
diff --git a/frontend/src/app/main/ui/ds/mixins.scss b/frontend/src/app/main/ui/ds/mixins.scss
index c285bd6295..43f4b6426a 100644
--- a/frontend/src/app/main/ui/ds/mixins.scss
+++ b/frontend/src/app/main/ui/ds/mixins.scss
@@ -7,6 +7,7 @@
@use "ds/typography.scss" as t;
@use "ds/_borders.scss" as *;
@use "ds/_sizes.scss" as *;
+@use "ds/_utils.scss" as *;
@mixin text-ellipsis {
display: block;
@@ -25,6 +26,17 @@
-webkit-box-orient: vertical;
}
+// The checkerboard of a transparent background, the same in both themes, so
+// white, black and grey shapes all stand out from it.
+@mixin transparency-checkerboard {
+ background-color: var(--color-static-white);
+ background-image: repeating-conic-gradient(
+ color-mix(in srgb, var(--color-canvas) 70%, var(--color-static-white)) 0% 25%,
+ transparent 0% 50%
+ );
+ background-size: px2rem(20) px2rem(20);
+}
+
/// Custom Scrollbar Mixin
/// @param {Color} $thumb-color - Base thumb color
/// @param {Color} $thumb-hover-color - Thumb color on hover
diff --git a/frontend/src/app/main/ui/ds/product/change_row.cljs b/frontend/src/app/main/ui/ds/product/change_row.cljs
index c3e0c4de65..c634e51feb 100644
--- a/frontend/src/app/main/ui/ds/product/change_row.cljs
+++ b/frontend/src/app/main/ui/ds/product/change_row.cljs
@@ -25,6 +25,8 @@
[:tone {:optional true} [:maybe (into [:enum] tag/tones)]]
[:is-selected {:optional true} [:maybe :boolean]]
[:is-muted {:optional true} [:maybe :boolean]]
+ [:start {:optional true} [:maybe :any]]
+ [:end {:optional true} [:maybe :any]]
[:on-click {:optional true} [:maybe fn?]]])
(mf/defc change-row*
diff --git a/frontend/src/app/main/ui/ds/product/change_row.scss b/frontend/src/app/main/ui/ds/product/change_row.scss
index ecb868c1ff..1b867cf61a 100644
--- a/frontend/src/app/main/ui/ds/product/change_row.scss
+++ b/frontend/src/app/main/ui/ds/product/change_row.scss
@@ -24,11 +24,9 @@
}
&:focus-visible {
- outline: none;
- }
+ --row-card-outline: #{$b-1} solid var(--color-accent-primary);
- &:focus-visible .card {
- outline: $b-1 solid var(--color-accent-primary);
+ outline: none;
}
&.is-muted {
@@ -69,6 +67,7 @@
}
.card {
+ outline: var(--row-card-outline, none);
display: flex;
flex: 1;
align-items: center;
diff --git a/frontend/src/app/main/ui/ds/product/comment_card.cljs b/frontend/src/app/main/ui/ds/product/comment_card.cljs
new file mode 100644
index 0000000000..295f8606e2
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/comment_card.cljs
@@ -0,0 +1,72 @@
+;; 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.comment-card
+ (:require-macros
+ [app.main.style :as stl])
+ (:require
+ [app.main.ui.ds.foundations.typography :as t]
+ [app.main.ui.ds.foundations.typography.text :refer [text*]]
+ [app.main.ui.ds.product.review-label :refer [review-label*]]
+ [app.util.dom :as dom]
+ [app.util.keyboard :as kbd]
+ [rumext.v2 :as mf]))
+
+(def ^:private schema:comment-card
+ [:map
+ [:class {:optional true} [:maybe :string]]
+ [:location :string]
+ [:author :string]
+ [:time :string]
+ [:replies :string]
+ [:avatar {:optional true} [:maybe :any]]
+ [:anchor {:optional true} [:maybe :any]]
+ [:review {:optional true} [:maybe :string]]
+ [:is-review {:optional true} [:maybe :boolean]]
+ [:is-open {:optional true} [:maybe :boolean]]
+ [:is-resolved {:optional true} [:maybe :boolean]]
+ [:on-click {:optional true} [:maybe fn?]]])
+
+(mf/defc comment-card*
+ "One comment of a list: where it is, who wrote it and when (`avatar`, an
+ avatar), its text (`children`), and its replies beside what it points at
+ (`anchor`, a chip). The whole card opens it. `review` names the design review
+ it belongs to, and `is-review` outlines it open in the review colour."
+ {::mf/schema schema:comment-card}
+ [{:keys [class location author time replies avatar anchor review is-review is-open is-resolved
+ on-click children]
+ :rest props}]
+ (let [on-key-down (mf/use-fn
+ (mf/deps on-click)
+ (fn [event]
+ ;; the text may hold links: the keys on them are theirs
+ (when (and on-click
+ (identical? (dom/get-target event) (dom/get-current-target event))
+ (or (kbd/enter? event) (kbd/space? event)))
+ (dom/prevent-default event)
+ (on-click event))))
+ props (mf/spread-props props
+ {:class [class (stl/css-case :comment-card true
+ :is-open is-open
+ :is-review is-review
+ :is-resolved is-resolved)]
+ :role "button"
+ :tab-index 0
+ :on-click on-click
+ :on-key-down on-key-down})]
+ [:> :div props
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :location)} location]
+ (when review
+ [:> review-label* {:label review}])
+ [:div {:class (stl/css :author)}
+ avatar
+ [:div {:class (stl/css :identity)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :name)} author]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :muted)} time]]]
+ [:div {:class (stl/css :content)} children]
+ [:div {:class (stl/css :footer)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :replies)} replies]
+ anchor]]))
diff --git a/frontend/src/app/main/ui/ds/product/comment_card.mdx b/frontend/src/app/main/ui/ds/product/comment_card.mdx
new file mode 100644
index 0000000000..e2cf358a7b
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/comment_card.mdx
@@ -0,0 +1,45 @@
+{ /* 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 CommentCard from "./comment_card.stories";
+
+
+
+# CommentCard
+
+One comment of a list: where it is, who wrote it and when, its text and
+its replies.
+
+
+
+## Variants
+
+`is-open` outlines the comment open on the canvas, in the review colour
+with `is-review`; `is-resolved` fades a settled one. `review` shows the name
+of the design review it belongs to.
+
+
+
+
+
+## Technical notes
+
+The card is a `role="button"` that reacts to Enter and Space. Two slots
+take elements: `avatar` and `anchor` (a chip with what the comment points
+at). The text of the comment goes in `children`. The caller translates
+`location`, `time` and `replies`.
+
+```clj
+[:> comment-card* {:location "#1 - Board"
+ :author (:fullname owner)
+ :time (ct/timeago (:modified-at thread))
+ :replies (tr "workspace.review.comments.no-replies")
+ :avatar (mf/html [:> avatar* {:profile owner :variant "M"}])
+ :anchor (mf/html [:> layer-chip* {:label "Card form"}])
+ :on-click on-open}
+ (:content thread)]
+```
diff --git a/frontend/src/app/main/ui/ds/product/comment_card.scss b/frontend/src/app/main/ui/ds/product/comment_card.scss
new file mode 100644
index 0000000000..d65c2bcc01
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/comment_card.scss
@@ -0,0 +1,89 @@
+// 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 *;
+
+.comment-card {
+ --comment-card-bg-color: var(--color-background-tertiary);
+ --comment-card-border-color: transparent;
+
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: var(--sp-s);
+ inline-size: 100%;
+ padding: var(--sp-m);
+ border: $b-1 solid var(--comment-card-border-color);
+ border-radius: $br-8;
+ background-color: var(--comment-card-bg-color);
+ color: var(--color-foreground-primary);
+ text-align: start;
+ cursor: pointer;
+
+ &:hover {
+ --comment-card-bg-color: var(--color-background-quaternary);
+ }
+
+ &:focus-visible {
+ outline: $b-1 solid var(--color-accent-primary);
+ }
+
+ &.is-open {
+ --comment-card-border-color: var(--color-accent-primary);
+ }
+
+ &.is-open.is-review {
+ --comment-card-border-color: var(--color-accent-info);
+ }
+
+ &.is-resolved {
+ opacity: 0.7;
+ }
+}
+
+.location {
+ color: var(--color-foreground-secondary);
+}
+
+.author {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-s);
+}
+
+.identity {
+ display: flex;
+ flex-direction: column;
+}
+
+.name {
+ color: var(--color-foreground-primary);
+}
+
+.muted {
+ color: var(--color-foreground-secondary);
+}
+
+.footer {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--sp-s);
+ inline-size: 100%;
+}
+
+.replies {
+ flex-shrink: 0;
+ color: var(--color-foreground-secondary);
+}
+
+.content {
+ @include use-typography("body-small");
+
+ color: var(--color-foreground-primary);
+ overflow-wrap: anywhere;
+}
diff --git a/frontend/src/app/main/ui/ds/product/comment_card.stories.jsx b/frontend/src/app/main/ui/ds/product/comment_card.stories.jsx
new file mode 100644
index 0000000000..c8d2a2e50b
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/comment_card.stories.jsx
@@ -0,0 +1,55 @@
+// 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 { CommentCard } = Components;
+
+export default {
+ title: "Product/Review/CommentCard",
+ component: CommentCard,
+ argTypes: {
+ isOpen: { control: { type: "boolean" } },
+ isResolved: { control: { type: "boolean" } },
+ },
+ args: {
+ location: "#1 - Board",
+ author: "Ana Pérez",
+ time: "1 hour ago",
+ replies: "No replies",
+ children: "The summary should sit closer to the form.",
+ isOpen: false,
+ isResolved: false,
+ },
+ render: ({ ...args }) => (
+
+
+
+ ),
+};
+
+export const Default = {};
+
+export const Open = {
+ args: {
+ isOpen: true,
+ },
+};
+
+export const InAReview = {
+ args: {
+ review: "Checkout redesign",
+ isReview: true,
+ isOpen: true,
+ },
+};
+
+export const Resolved = {
+ args: {
+ isResolved: true,
+ },
+};
diff --git a/frontend/src/app/main/ui/ds/product/layer_chip.cljs b/frontend/src/app/main/ui/ds/product/layer_chip.cljs
new file mode 100644
index 0000000000..4e3f2fe594
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/layer_chip.cljs
@@ -0,0 +1,34 @@
+;; 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.layer-chip
+ (:require-macros
+ [app.main.style :as stl])
+ (:require
+ [app.main.ui.ds.foundations.assets.icon :refer [icon*] :as i]
+ [rumext.v2 :as mf]))
+
+(def ^:private schema:layer-chip
+ [:map
+ [:class {:optional true} [:maybe :string]]
+ [:label :string]
+ [:icon {:optional true} [:maybe [:and :string [:fn #(contains? i/icon-list %)]]]]
+ [:is-lost {:optional true} [:maybe :boolean]]
+ [:is-struck {:optional true} [:maybe :boolean]]])
+
+(mf/defc layer-chip*
+ "A chip naming a layer, or what a comment points at. A lost layer reads
+ in the warning tone, struck through when `is-struck`."
+ {::mf/schema schema:layer-chip}
+ [{:keys [class label icon is-lost is-struck] :rest props}]
+ (let [props (mf/spread-props props
+ {:class [class (stl/css-case :layer-chip true
+ :is-lost is-lost)]})]
+ [:> :span props
+ [:> icon* {:icon-id (if ^boolean is-lost i/triangle-alert (or icon i/board)) :size "s"}]
+ [:span {:class (stl/css-case :label true
+ :is-struck is-struck)}
+ label]]))
diff --git a/frontend/src/app/main/ui/ds/product/layer_chip.mdx b/frontend/src/app/main/ui/ds/product/layer_chip.mdx
new file mode 100644
index 0000000000..3fa63892e0
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/layer_chip.mdx
@@ -0,0 +1,31 @@
+{ /* 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 LayerChip from "./layer_chip.stories";
+
+
+
+# LayerChip
+
+A chip naming a layer, or what a comment points at.
+
+
+
+## Variants
+
+`is-lost` marks a layer that was deleted: the chip turns orange and shows
+a warning. `is-struck` also strikes its name through.
+
+## Technical notes
+
+`icon` replaces the board icon, except on a lost layer.
+
+```clj
+[:> layer-chip* {:label "Card form"
+ :icon i/pin
+ :is-lost (dwtk/lost? task)}]
+```
diff --git a/frontend/src/app/main/ui/ds/product/layer_chip.scss b/frontend/src/app/main/ui/ds/product/layer_chip.scss
new file mode 100644
index 0000000000..45ee2a46b1
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/layer_chip.scss
@@ -0,0 +1,40 @@
+// 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 *;
+
+.layer-chip {
+ --layer-chip-bg-color: var(--color-background-quaternary);
+ --layer-chip-fg-color: var(--color-foreground-secondary);
+
+ @include use-typography("body-small");
+
+ 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);
+ border-radius: $br-4;
+ background-color: var(--layer-chip-bg-color);
+ color: var(--layer-chip-fg-color);
+
+ &.is-lost {
+ --layer-chip-bg-color: var(--color-background-warning);
+ --layer-chip-fg-color: var(--color-accent-warning);
+ }
+}
+
+.label {
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+}
+
+.is-struck {
+ text-decoration: line-through;
+}
diff --git a/frontend/src/app/main/ui/ds/product/layer_chip.stories.jsx b/frontend/src/app/main/ui/ds/product/layer_chip.stories.jsx
new file mode 100644
index 0000000000..2ddcc19bbc
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/layer_chip.stories.jsx
@@ -0,0 +1,37 @@
+// 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 { LayerChip } = Components;
+
+export default {
+ title: "Product/Review/LayerChip",
+ component: LayerChip,
+ argTypes: {
+ isLost: { control: { type: "boolean" } },
+ isStruck: { control: { type: "boolean" } },
+ },
+ args: {
+ label: "Card form",
+ isLost: false,
+ isStruck: false,
+ },
+ render: ({ ...args }) => ,
+};
+
+export const Default = {};
+
+export const AllChips = {
+ render: () => (
+
+
+
+
+
+ ),
+};
diff --git a/frontend/src/app/main/ui/ds/product/preview_card.scss b/frontend/src/app/main/ui/ds/product/preview_card.scss
index 8e9c86836a..509e9d762a 100644
--- a/frontend/src/app/main/ui/ds/product/preview_card.scss
+++ b/frontend/src/app/main/ui/ds/product/preview_card.scss
@@ -5,7 +5,6 @@
// 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 *;
@@ -53,10 +52,7 @@
}
.stage {
- // the checkerboard of a transparent background, the same in both
- // themes (the DS swatch draws its transparency the same way), so
- // white, black and grey shapes all stand out from it
- --stage-check-color: color-mix(in srgb, var(--color-canvas) 70%, var(--color-static-white));
+ @include transparency-checkerboard;
display: flex;
align-items: center;
@@ -67,9 +63,6 @@
padding: var(--sp-s);
overflow: hidden;
border-radius: $br-6;
- background-color: var(--color-static-white);
- background-image: repeating-conic-gradient(var(--stage-check-color) 0% 25%, transparent 0% 50%);
- background-size: px2rem(20) px2rem(20);
&.is-large {
block-size: var(--preview-card-stage-large-block-size, #{px2rem(320)});
diff --git a/frontend/src/app/main/ui/ds/product/progress_bar.cljs b/frontend/src/app/main/ui/ds/product/progress_bar.cljs
new file mode 100644
index 0000000000..2fa9eaed0d
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/progress_bar.cljs
@@ -0,0 +1,34 @@
+;; 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.progress-bar
+ (:require-macros
+ [app.main.style :as stl])
+ (:require
+ [app.common.data.macros :as dm]
+ [rumext.v2 :as mf]))
+
+(def ^:private schema:progress-bar
+ [:map
+ [:class {:optional true} [:maybe :string]]
+ [:value :int]
+ [:total :int]])
+
+(mf/defc progress-bar*
+ "A thin bar filled by how much of `total` is done (`value`). The caller
+ sizes it through `class`."
+ {::mf/schema schema:progress-bar}
+ [{:keys [class value total] :rest props}]
+ (let [percent (if (pos? total) (* 100 (/ value total)) 0)
+ props (mf/spread-props props
+ {:class [class (stl/css :progress-bar)]
+ :role "progressbar"
+ :aria-valuemin 0
+ :aria-valuemax total
+ :aria-valuenow value})]
+ [:> :span props
+ [:span {:class (stl/css :fill)
+ :style #js {:width (dm/str percent "%")}}]]))
diff --git a/frontend/src/app/main/ui/ds/product/progress_bar.mdx b/frontend/src/app/main/ui/ds/product/progress_bar.mdx
new file mode 100644
index 0000000000..4de1d6f3e7
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/progress_bar.mdx
@@ -0,0 +1,28 @@
+{ /* 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 ProgressBar from "./progress_bar.stories";
+
+
+
+# ProgressBar
+
+A thin bar filled by how much of a total is done.
+
+
+
+## Technical notes
+
+It takes the width of its container: size it with `class`. Set
+`--progress-bar-fill-radius` there to round the end of the fill. Add
+`aria-hidden` when text next to it already says the same.
+
+```clj
+[:> progress-bar* {:value closed
+ :total total
+ :class (stl/css :tasks-progress)}]
+```
diff --git a/frontend/src/app/main/ui/ds/product/progress_bar.scss b/frontend/src/app/main/ui/ds/product/progress_bar.scss
new file mode 100644
index 0000000000..24a2fe0943
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/progress_bar.scss
@@ -0,0 +1,25 @@
+// 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 *;
+
+.progress-bar {
+ display: block;
+ block-size: px2rem(4);
+ border-radius: $br-4;
+ background-color: var(--color-background-quaternary);
+ overflow: hidden;
+}
+
+.fill {
+ display: block;
+ block-size: 100%;
+
+ // a caller may round the end of the fill
+ border-radius: var(--progress-bar-fill-radius, 0);
+ background-color: var(--color-accent-info);
+}
diff --git a/frontend/src/app/main/ui/ds/product/progress_bar.stories.jsx b/frontend/src/app/main/ui/ds/product/progress_bar.stories.jsx
new file mode 100644
index 0000000000..e7753fcfe3
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/progress_bar.stories.jsx
@@ -0,0 +1,30 @@
+// 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 { ProgressBar } = Components;
+
+export default {
+ title: "Product/Review/ProgressBar",
+ component: ProgressBar,
+ argTypes: {
+ value: { control: { type: "number" } },
+ total: { control: { type: "number" } },
+ },
+ args: {
+ value: 2,
+ total: 7,
+ },
+ render: ({ ...args }) => (
+
+
+
+ ),
+};
+
+export const Default = {};
diff --git a/frontend/src/app/main/ui/ds/product/review_label.cljs b/frontend/src/app/main/ui/ds/product/review_label.cljs
new file mode 100644
index 0000000000..ccf3aed4a3
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/review_label.cljs
@@ -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
+
+(ns app.main.ui.ds.product.review-label
+ (:require-macros
+ [app.main.style :as stl])
+ (:require
+ [app.main.ui.ds.foundations.assets.icon :refer [icon*] :as i]
+ [rumext.v2 :as mf]))
+
+(def ^:private schema:review-label
+ [:map
+ [:class {:optional true} [:maybe :string]]
+ [:label :string]])
+
+(mf/defc review-label*
+ "Says that a comment or a task belongs to a design review, with the name
+ of the review."
+ {::mf/schema schema:review-label}
+ [{:keys [class label] :rest props}]
+ (let [props (mf/spread-props props
+ {:class [class (stl/css :review-label)]
+ :title label})]
+ [:> :span props
+ [:> icon* {:icon-id i/git-pull-request-arrow :size "s"}]
+ [:span {:class (stl/css :text)} label]]))
diff --git a/frontend/src/app/main/ui/ds/product/review_label.mdx b/frontend/src/app/main/ui/ds/product/review_label.mdx
new file mode 100644
index 0000000000..0a5a9d9e08
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/review_label.mdx
@@ -0,0 +1,26 @@
+{ /* 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 ReviewLabel from "./review_label.stories";
+
+
+
+# ReviewLabel
+
+Says that a comment or a task belongs to a design review, with the name of
+the review.
+
+
+
+## Technical notes
+
+A long name is cut with an ellipsis, and the whole name shows as its
+`title`.
+
+```clj
+[:> review-label* {:label (:review-title task)}]
+```
diff --git a/frontend/src/app/main/ui/ds/product/review_label.scss b/frontend/src/app/main/ui/ds/product/review_label.scss
new file mode 100644
index 0000000000..4a8f661625
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/review_label.scss
@@ -0,0 +1,28 @@
+// 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 *;
+@use "ds/typography.scss" as *;
+
+.review-label {
+ @include use-typography("body-small");
+
+ display: inline-flex;
+ flex-shrink: 0;
+ align-self: flex-start;
+ align-items: center;
+ gap: var(--sp-xxs);
+ max-inline-size: 100%;
+ padding: 0 var(--sp-xs);
+ border-radius: $br-4;
+ background-color: var(--color-background-info);
+ color: var(--color-accent-info);
+}
+
+.text {
+ @include text-ellipsis;
+}
diff --git a/frontend/src/app/main/ui/ds/product/review_label.stories.jsx b/frontend/src/app/main/ui/ds/product/review_label.stories.jsx
new file mode 100644
index 0000000000..49ff093b1f
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/review_label.stories.jsx
@@ -0,0 +1,25 @@
+// 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 { ReviewLabel } = Components;
+
+export default {
+ title: "Product/Review/ReviewLabel",
+ component: ReviewLabel,
+ args: {
+ label: "Checkout redesign",
+ },
+ render: ({ ...args }) => (
+
+
+
+ ),
+};
+
+export const Default = {};
diff --git a/frontend/src/app/main/ui/ds/product/review_marker.cljs b/frontend/src/app/main/ui/ds/product/review_marker.cljs
new file mode 100644
index 0000000000..de19c84288
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/review_marker.cljs
@@ -0,0 +1,59 @@
+;; 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.review-marker
+ (:require-macros
+ [app.main.style :as stl])
+ (:require
+ [app.common.data :as d]
+ [app.main.ui.ds.foundations.assets.icon :refer [icon*] :as i]
+ [rumext.v2 :as mf]))
+
+(def ^:private schema:review-marker
+ [:map
+ [:class {:optional true} [:maybe :string]]
+ [:type {:optional true} [:maybe [:enum "comment" "task"]]]
+ [:state {:optional true} [:maybe [:enum "default" "active" "resolved" "lost" "ghost"]]]
+ [:label {:optional true} [:maybe :string]]
+ [:counter {:optional true} [:maybe :int]]
+ [:aria-label :string]])
+
+(mf/defc review-marker*
+ "The mark a design review leaves on the canvas. A comment is a round
+ mark with its number; a task, a square one with the task icon. Active
+ is the one open now, resolved a comment already settled (it shows a
+ tick instead of its number), lost a mark whose layer was deleted and
+ ghost what stays where a group of marks fanned out from. `counter` is
+ the number of items a mark holds; a comment mark that holds several has
+ no number, so it shows the comments icon. It renders a button: the caller names
+ it (`aria-label`) and handles the click."
+ {::mf/schema schema:review-marker}
+ [{:keys [class type state label counter] :rest props}]
+ (let [type (d/nilv type "comment")
+ state (d/nilv state "default")
+ props (mf/spread-props props
+ {:class [class (stl/css-case :review-marker true
+ :is-task (= type "task")
+ :is-active (= state "active")
+ :is-resolved (= state "resolved")
+ :is-lost (= state "lost")
+ :is-ghost (= state "ghost"))]
+ :type "button"})]
+ [:> :button props
+ (cond
+ (= type "task")
+ [:> icon* {:icon-id i/view-as-list :size "s"}]
+
+ (= state "resolved")
+ [:> icon* {:icon-id i/tick :size "s"}]
+
+ (nil? label)
+ [:> icon* {:icon-id i/comments :size "s"}]
+
+ :else
+ label)
+ (when (some? counter)
+ [:span {:class (stl/css :counter)} counter])]))
diff --git a/frontend/src/app/main/ui/ds/product/review_marker.mdx b/frontend/src/app/main/ui/ds/product/review_marker.mdx
new file mode 100644
index 0000000000..3b3e5a050a
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/review_marker.mdx
@@ -0,0 +1,40 @@
+{ /* 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 ReviewMarker from "./review_marker.stories";
+
+
+
+# ReviewMarker
+
+The mark a design review leaves on the canvas: a round mark with the
+number of a comment, or a square one with the task icon.
+
+
+
+## Variants
+
+- `type`: `comment` (default) or `task`.
+- `state`: `default`, `active` (the one open now), `resolved` (a settled
+ comment: a tick replaces its number) and `lost` (its layer was deleted:
+ a dashed orange outline) and `ghost` (what stays where a group of marks
+ fanned out from).
+- `counter`: the number of items a mark holds, in a white bubble on its
+ top right corner. A comment mark with several comments has no `label`,
+ so it shows the comments icon.
+
+## Technical notes
+
+It renders a `button`. The caller names it with `aria-label` and handles
+`on-click`; `label` is the number of a comment.
+
+```clj
+[:> review-marker* {:label (str (:seqn thread))
+ :state (if open? "active" "default")
+ :aria-label (tr "workspace.review.marker.comment" (:seqn thread))
+ :on-click on-open}]
+```
diff --git a/frontend/src/app/main/ui/ds/product/review_marker.scss b/frontend/src/app/main/ui/ds/product/review_marker.scss
new file mode 100644
index 0000000000..7cd0e4025a
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/review_marker.scss
@@ -0,0 +1,92 @@
+// 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/typography.scss" as *;
+
+.review-marker {
+ --marker-fg-color: var(--color-foreground-primary);
+ --marker-bg-color: var(--color-background-info);
+ --marker-border-color: var(--color-accent-info);
+ --marker-border-style: solid;
+
+ @include use-typography("body-small");
+
+ position: relative;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ inline-size: $sz-32;
+ block-size: $sz-32;
+ padding: 0;
+ border: $b-2 var(--marker-border-style) var(--marker-border-color);
+ border-radius: $br-circle;
+ background-color: var(--marker-bg-color);
+ color: var(--marker-fg-color);
+
+ // TODO: No exact DS typography match found.
+ // Closest match: body-small (weight 700 vs 400).
+ font-weight: 700;
+ cursor: pointer;
+
+ &:focus-visible {
+ outline: $b-1 solid var(--color-accent-primary);
+ outline-offset: $b-2;
+ }
+
+ &.is-task {
+ border-radius: $br-6;
+ }
+
+ &.is-active {
+ --marker-fg-color: var(--color-background-primary);
+ --marker-bg-color: var(--color-accent-info);
+ }
+
+ &.is-resolved {
+ --marker-fg-color: var(--color-foreground-secondary);
+ --marker-bg-color: var(--color-background-primary);
+ --marker-border-color: var(--color-foreground-secondary);
+ }
+
+ &.is-lost {
+ --marker-fg-color: var(--color-accent-warning);
+ --marker-bg-color: var(--color-background-warning);
+ --marker-border-color: var(--color-accent-warning);
+ --marker-border-style: dashed;
+ }
+
+ &.is-ghost {
+ --marker-bg-color: var(--color-background-primary);
+ --marker-border-style: dashed;
+ }
+
+ // after the states, which set the same color with the same specificity
+ &:hover {
+ --marker-border-color: var(--color-foreground-primary);
+ }
+}
+
+.counter {
+ @include use-typography("body-small");
+
+ position: absolute;
+ inset-block-start: px2rem(-8);
+ inset-inline-end: px2rem(-8);
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ min-inline-size: $sz-16;
+ block-size: $sz-16;
+ padding-inline: var(--sp-xxs);
+ border: $b-1 solid var(--marker-border-color);
+ border-radius: $sz-16;
+ background-color: var(--color-static-white);
+ color: var(--color-static-black);
+ font-weight: 700;
+}
diff --git a/frontend/src/app/main/ui/ds/product/review_marker.stories.jsx b/frontend/src/app/main/ui/ds/product/review_marker.stories.jsx
new file mode 100644
index 0000000000..8126ffd28d
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/review_marker.stories.jsx
@@ -0,0 +1,61 @@
+// 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 { ReviewMarker } = Components;
+
+export default {
+ title: "Product/Review/ReviewMarker",
+ component: ReviewMarker,
+ argTypes: {
+ type: {
+ options: ["comment", "task"],
+ control: { type: "select" },
+ },
+ state: {
+ options: ["default", "active", "resolved", "lost", "ghost"],
+ control: { type: "select" },
+ },
+ label: {
+ control: { type: "text" },
+ },
+ counter: {
+ control: { type: "number" },
+ },
+ },
+ args: {
+ type: "comment",
+ state: "default",
+ label: "1",
+ "aria-label": "Comment 1",
+ },
+ render: ({ ...args }) => ,
+};
+
+export const Default = {};
+
+export const AllMarkers = {
+ render: () => (
+
+
+
+
+
+
+
+
+
+
+
+ ),
+};
diff --git a/frontend/src/app/main/ui/ds/product/tag.scss b/frontend/src/app/main/ui/ds/product/tag.scss
index 3be7be8190..8071f9e6bb 100644
--- a/frontend/src/app/main/ui/ds/product/tag.scss
+++ b/frontend/src/app/main/ui/ds/product/tag.scss
@@ -27,6 +27,8 @@
border-radius: $br-4;
background-color: var(--tag-bg-color);
color: var(--tag-fg-color);
+
+ // TODO: 10px is not a size of the DS typographies.
font-size: px2rem(10);
white-space: nowrap;
diff --git a/frontend/src/app/main/ui/ds/product/task_row.cljs b/frontend/src/app/main/ui/ds/product/task_row.cljs
new file mode 100644
index 0000000000..827b5ce412
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/task_row.cljs
@@ -0,0 +1,78 @@
+;; 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.task-row
+ (: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*]]
+ [app.main.ui.ds.product.layer-chip :refer [layer-chip*]]
+ [app.main.ui.ds.product.review-label :refer [review-label*]]
+ [app.main.ui.ds.product.task-status :as ts :refer [task-status*]]
+ [app.util.dom :as dom]
+ [app.util.keyboard :as kbd]
+ [rumext.v2 :as mf]))
+
+(def ^:private schema:task-row
+ [:map
+ [:class {:optional true} [:maybe :string]]
+ [:title :string]
+ [:status (into [:enum] ts/statuses)]
+ [:status-label :string]
+ [:layer {:optional true} [:maybe :string]]
+ [:is-layer-lost {:optional true} [:maybe :boolean]]
+ [:is-selected {:optional true} [:maybe :boolean]]
+ [:review {:optional true} [:maybe :string]]
+ [:is-review {:optional true} [:maybe :boolean]]
+ [:assignee {:optional true} [:maybe :any]]
+ [:actions {:optional true} [:maybe :any]]
+ [:on-click {:optional true} [:maybe fn?]]])
+
+(mf/defc task-row*
+ "One task of a list: its title over its state and the layer it points
+ at, with the assignee (`assignee`, an avatar) and the actions of the
+ task (`actions`, a menu) at the end. A task whose layer was deleted
+ shows the layer it lost in the warning tone. `review` names the design
+ review it belongs to, and `is-review` outlines it selected in the review
+ colour."
+ {::mf/schema schema:task-row}
+ [{:keys [class title status status-label layer is-layer-lost is-selected review is-review
+ assignee actions on-click] :rest props}]
+ (let [is-selected (d/nilv is-selected false)
+ is-layer-lost (d/nilv is-layer-lost false)
+ on-key-down (mf/use-fn
+ (mf/deps on-click)
+ (fn [event]
+ ;; the keys on the actions of the row are theirs
+ (when (and on-click
+ (identical? (dom/get-target event) (dom/get-current-target event))
+ (or (kbd/enter? event) (kbd/space? event)))
+ (dom/prevent-default event)
+ (on-click event))))
+ props (mf/spread-props props
+ {:class [class (stl/css-case :task-row true
+ :is-selected is-selected
+ :is-review is-review)]
+ :role "button"
+ :tab-index 0
+ :aria-pressed is-selected
+ :on-click on-click
+ :on-key-down on-key-down})]
+ [:> :div props
+ [:div {:class (stl/css :header)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :title)} title]
+ (when actions
+ [:div {:class (stl/css :actions)} actions])]
+ (when review
+ [:> review-label* {:label review}])
+ [:div {:class (stl/css :footer)}
+ [:> task-status* {:status status :label status-label}]
+ (when layer
+ [:> layer-chip* {:label layer :is-lost is-layer-lost}])
+ (when assignee
+ [:div {:class (stl/css :assignee)} assignee])]]))
diff --git a/frontend/src/app/main/ui/ds/product/task_row.mdx b/frontend/src/app/main/ui/ds/product/task_row.mdx
new file mode 100644
index 0000000000..c222559811
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/task_row.mdx
@@ -0,0 +1,46 @@
+{ /* 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 TaskRow from "./task_row.stories";
+
+
+
+# TaskRow
+
+One task of a list: its title over its state and the layer it points at.
+
+
+
+## Variants
+
+`is-selected` outlines the task open on the canvas, in the review colour
+with `is-review`. `review` shows the name of the design review it belongs to.
+
+
+
+
+`is-layer-lost` marks a task whose layer was deleted: the chip of the
+layer turns orange and shows a warning.
+
+
+
+## Technical notes
+
+The row is a `role="button"` that reacts to Enter and Space while the focus
+is on the row itself. Two slots
+take elements: `assignee` (an avatar, at the end of the second line)
+and `actions` (a menu trigger, at the end of the title). A click inside
+a slot must stop its propagation when it should not open the task.
+
+```clj
+[:> task-row* {:title (:title task)
+ :status (:status task)
+ :status-label (tr "workspace.tasks.status.open")
+ :layer "Card form"
+ :assignee (mf/html [:> avatar* {:profile assignee :variant "S"}])
+ :on-click on-open}]
+```
diff --git a/frontend/src/app/main/ui/ds/product/task_row.scss b/frontend/src/app/main/ui/ds/product/task_row.scss
new file mode 100644
index 0000000000..501e3b73b8
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/task_row.scss
@@ -0,0 +1,68 @@
+// 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 *;
+
+.task-row {
+ --task-row-bg-color: var(--color-background-tertiary);
+ --task-row-border-color: transparent;
+
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+ padding: var(--sp-m);
+ border: $b-1 solid var(--task-row-border-color);
+ border-radius: $br-8;
+ background-color: var(--task-row-bg-color);
+ color: var(--color-foreground-primary);
+ cursor: pointer;
+
+ &:hover {
+ --task-row-bg-color: var(--color-background-quaternary);
+ }
+
+ &:focus-visible {
+ outline: $b-1 solid var(--color-accent-primary);
+ }
+
+ &.is-selected {
+ --task-row-border-color: var(--color-accent-primary);
+ }
+
+ &.is-selected.is-review {
+ --task-row-border-color: var(--color-accent-info);
+ }
+}
+
+.header {
+ display: flex;
+ align-items: flex-start;
+ gap: var(--sp-s);
+}
+
+.title {
+ flex: 1;
+ min-inline-size: 0;
+ color: var(--color-foreground-primary);
+}
+
+.actions {
+ flex-shrink: 0;
+ margin-block: calc(var(--sp-xs) * -1);
+}
+
+.footer {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-s);
+ min-inline-size: 0;
+}
+
+.assignee {
+ display: flex;
+ flex-shrink: 0;
+ margin-inline-start: auto;
+}
diff --git a/frontend/src/app/main/ui/ds/product/task_row.stories.jsx b/frontend/src/app/main/ui/ds/product/task_row.stories.jsx
new file mode 100644
index 0000000000..9905dc206b
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/task_row.stories.jsx
@@ -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
+
+import * as React from "react";
+import Components from "@target/components";
+
+const { TaskRow } = Components;
+
+export default {
+ title: "Product/Review/TaskRow",
+ component: TaskRow,
+ argTypes: {
+ status: {
+ options: ["open", "done", "reopened", "verified", "wont-do"],
+ control: { type: "select" },
+ },
+ isSelected: {
+ control: { type: "boolean" },
+ },
+ isLayerLost: {
+ control: { type: "boolean" },
+ },
+ },
+ args: {
+ title: "Add 24 px between the card fields and the summary",
+ status: "open",
+ statusLabel: "Open",
+ layer: "Card form",
+ isSelected: false,
+ isLayerLost: false,
+ },
+ render: ({ ...args }) => (
+
+
+
+ ),
+};
+
+export const Default = {};
+
+export const Selected = {
+ args: {
+ isSelected: true,
+ },
+};
+
+export const InAReview = {
+ args: {
+ isSelected: true,
+ isReview: true,
+ review: "Checkout redesign",
+ },
+};
+
+export const LostLayer = {
+ args: {
+ title: "Replace the promo copy (waiting for marketing)",
+ status: "reopened",
+ statusLabel: "Reopened",
+ layer: "Promo banner",
+ isLayerLost: true,
+ },
+};
diff --git a/frontend/src/app/main/ui/ds/product/task_status.cljs b/frontend/src/app/main/ui/ds/product/task_status.cljs
new file mode 100644
index 0000000000..dd84084d93
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/task_status.cljs
@@ -0,0 +1,34 @@
+;; 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.task-status
+ (:require-macros
+ [app.main.style :as stl])
+ (:require
+ [rumext.v2 :as mf]))
+
+(def statuses
+ #{"open" "done" "reopened" "verified" "wont-do"})
+
+(def ^:private schema:task-status
+ [:map
+ [:class {:optional true} [:maybe :string]]
+ [:status (into [:enum] statuses)]
+ [:label :string]])
+
+(mf/defc task-status*
+ "The state of a task, a word in the colour of the state: open is blue,
+ done green, reopened orange, verified purple and won't do red."
+ {::mf/schema schema:task-status}
+ [{:keys [class status label] :rest props}]
+ (let [props (mf/spread-props props
+ {:class [class (stl/css-case :task-status true
+ :is-open (= status "open")
+ :is-done (= status "done")
+ :is-reopened (= status "reopened")
+ :is-verified (= status "verified")
+ :is-wont-do (= status "wont-do"))]})]
+ [:> :span props label]))
diff --git a/frontend/src/app/main/ui/ds/product/task_status.mdx b/frontend/src/app/main/ui/ds/product/task_status.mdx
new file mode 100644
index 0000000000..601ae6eb80
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/task_status.mdx
@@ -0,0 +1,32 @@
+{ /* 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 TaskStatus from "./task_status.stories";
+
+
+
+# TaskStatus
+
+The state of a task: a word in the colour of the state.
+
+
+
+## Technical notes
+
+`status` is one of `open`, `done`, `reopened`, `verified` and `wont-do`;
+`label` is the translated name the caller shows.
+
+```clj
+[:> task-status* {:status (:status task)
+ :label (tr "workspace.tasks.status.open")}]
+```
+
+## Usage guidelines (design)
+
+Open is blue: the task needs work. Done is green: it waits for someone to
+verify it. Reopened is orange: it needs work again. Verified is purple and
+closes the task. Won't do is red and drops it.
diff --git a/frontend/src/app/main/ui/ds/product/task_status.scss b/frontend/src/app/main/ui/ds/product/task_status.scss
new file mode 100644
index 0000000000..3fff79114f
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/task_status.scss
@@ -0,0 +1,51 @@
+// 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 *;
+
+.task-status {
+ --task-status-fg-color: var(--color-foreground-secondary);
+ --task-status-bg-color: var(--color-background-quaternary);
+
+ @include use-typography("body-small");
+
+ display: inline-flex;
+ flex-shrink: 0;
+ align-items: center;
+ padding: var(--sp-xxs) var(--sp-s);
+ border-radius: $br-4;
+ background-color: var(--task-status-bg-color);
+ color: var(--task-status-fg-color);
+ white-space: nowrap;
+
+ &.is-open {
+ --task-status-fg-color: var(--color-accent-info);
+ --task-status-bg-color: var(--color-background-info);
+ }
+
+ &.is-done {
+ --task-status-fg-color: var(--color-accent-success);
+ --task-status-bg-color: var(--color-background-success);
+ }
+
+ &.is-reopened {
+ --task-status-fg-color: var(--color-accent-warning);
+ --task-status-bg-color: var(--color-background-warning);
+ }
+
+ &.is-verified {
+ --task-status-fg-color: var(--color-accent-secondary);
+
+ // TODO: no DS background token pairs with the secondary accent
+ --task-status-bg-color: color-mix(in srgb, var(--color-accent-secondary) 18%, transparent);
+ }
+
+ &.is-wont-do {
+ --task-status-fg-color: var(--color-accent-error);
+ --task-status-bg-color: var(--color-background-error);
+ }
+}
diff --git a/frontend/src/app/main/ui/ds/product/task_status.stories.jsx b/frontend/src/app/main/ui/ds/product/task_status.stories.jsx
new file mode 100644
index 0000000000..d4bc216177
--- /dev/null
+++ b/frontend/src/app/main/ui/ds/product/task_status.stories.jsx
@@ -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 * as React from "react";
+import Components from "@target/components";
+
+const { TaskStatus } = Components;
+
+export default {
+ title: "Product/Review/TaskStatus",
+ component: TaskStatus,
+ argTypes: {
+ status: {
+ options: ["open", "done", "reopened", "verified", "wont-do"],
+ control: { type: "select" },
+ },
+ label: {
+ control: { type: "text" },
+ },
+ },
+ args: {
+ status: "open",
+ label: "Open",
+ },
+ render: ({ ...args }) => ,
+};
+
+export const Default = {};
+
+export const AllStatuses = {
+ render: () => (
+
+
+
+
+
+
+
+ ),
+};
diff --git a/frontend/src/app/main/ui/inspect/code.scss b/frontend/src/app/main/ui/inspect/code.scss
index 01367318d6..524efdeb66 100644
--- a/frontend/src/app/main/ui/inspect/code.scss
+++ b/frontend/src/app/main/ui/inspect/code.scss
@@ -15,7 +15,7 @@
.element-options {
display: flex;
flex-direction: column;
- block-size: calc(100vh - #{$sz-160}); // TODO: Fix this hardcoded value
+ block-size: var(--inspect-tab-block-size, calc(100vh - #{$sz-160})); // TODO: Fix this hardcoded value
overflow: hidden;
padding-block-end: var(--sp-l);
overflow-y: auto;
diff --git a/frontend/src/app/main/ui/inspect/right_sidebar.scss b/frontend/src/app/main/ui/inspect/right_sidebar.scss
index 6d1ea82b4b..a91928b7eb 100644
--- a/frontend/src/app/main/ui/inspect/right_sidebar.scss
+++ b/frontend/src/app/main/ui/inspect/right_sidebar.scss
@@ -12,7 +12,11 @@
.settings-bar-right {
min-inline-size: px2rem(252);
inline-size: 100%;
- block-size: 100vh;
+
+ // a panel that holds the inspect below its own header sets these four
+ // (`--inspect-block-size`, `--inspect-content-display`,
+ // `--inspect-tab-block-size` and `--options-available-height`)
+ block-size: var(--inspect-block-size, 100vh);
position: relative;
inset-inline-start: unset;
inset-inline-end: unset;
@@ -127,6 +131,8 @@
}
.inspect-content {
+ display: var(--inspect-content-display, block);
+ flex-direction: column;
overflow: hidden;
}
diff --git a/frontend/src/app/main/ui/inspect/styles.scss b/frontend/src/app/main/ui/inspect/styles.scss
index 865542c3f2..7a631e646d 100644
--- a/frontend/src/app/main/ui/inspect/styles.scss
+++ b/frontend/src/app/main/ui/inspect/styles.scss
@@ -11,7 +11,7 @@
}
.styles-tab-workspace {
- block-size: calc(100vh - px2rem(180)); // TODO: Fix this hardcoded value
+ block-size: var(--inspect-tab-block-size, calc(100vh - px2rem(180))); // TODO: Fix this hardcoded value
}
.exports-wrapper {
diff --git a/frontend/src/app/main/ui/workspace.cljs b/frontend/src/app/main/ui/workspace.cljs
index 61c82f71f2..6d761be5f6 100644
--- a/frontend/src/app/main/ui/workspace.cljs
+++ b/frontend/src/app/main/ui/workspace.cljs
@@ -13,7 +13,9 @@
[app.main.data.persistence :as dps]
[app.main.data.plugins :as dpl]
[app.main.data.workspace :as dw]
+ [app.main.data.workspace.drawing :as dwd]
[app.main.data.workspace.pull-requests :as dwpr]
+ [app.main.data.workspace.tasks :as dwtk]
[app.main.features :as features]
[app.main.fonts :as fonts]
[app.main.refs :as refs]
@@ -33,6 +35,7 @@
[app.main.ui.workspace.nudge]
[app.main.ui.workspace.palette :refer [palette*]]
[app.main.ui.workspace.plugins]
+ [app.main.ui.workspace.review.details]
[app.main.ui.workspace.sidebar :refer [sidebar*]]
[app.main.ui.workspace.sidebar.branches :refer [branch-context-banner*]]
[app.main.ui.workspace.sidebar.history :refer [history-toolbox*]]
@@ -76,6 +79,7 @@
colorpalette? (:colorpalette layout)
textpalette? (:textpalette layout)
hide-ui? (:hide-ui layout)
+ bottom-bar (mf/deref refs/bottom-bar)
on-resize
(mf/use-fn
@@ -127,8 +131,12 @@
:selected selected
:layout layout
:palete-size
- (when (and (or colorpalette? textpalette?) (not hide-ui?))
- @palete-size)}]]]
+ (when (and (or colorpalette? textpalette?)
+ (not hide-ui?)
+ (contains? #{nil :palette} bottom-bar))
+ ;; on a branch the palettes sit higher, at the level of its bar
+ (cond-> @palete-size
+ (some? bottom-bar) (+ 8)))}]]]
(when-not hide-ui?
[:> sidebar* {:layout layout
@@ -202,7 +210,7 @@
(mf/defc workspace*
{::mf/wrap [mf/memo]}
- [{:keys [team-id project-id file-id page-id pr-id layout-name]}]
+ [{:keys [team-id project-id file-id page-id pr-id task-id layout-name]}]
(let [layout (mf/deref refs/workspace-layout)
wglobal (mf/deref refs/workspace-global)
@@ -264,6 +272,12 @@
(when (and file-loaded? page-id pr-id)
(st/emit! (dwpr/initialize-pull-request-preview pr-id))))
+ ;; a link to a task (the email that assigns it) opens the task
+ (mf/with-effect [file-id task-id file-loaded?]
+ (when (and file-loaded? task-id)
+ (st/emit! (dwd/select-for-drawing :comments)
+ (dwtk/open-task-link task-id))))
+
(mf/with-effect [file-id page-id]
(reset! first-frame-rendered? false))
diff --git a/frontend/src/app/main/ui/workspace/comments.cljs b/frontend/src/app/main/ui/workspace/comments.cljs
index 7ab6ca7dda..3b843bc41e 100644
--- a/frontend/src/app/main/ui/workspace/comments.cljs
+++ b/frontend/src/app/main/ui/workspace/comments.cljs
@@ -12,14 +12,20 @@
[app.main.data.workspace :as dw]
[app.main.data.workspace.comments :as dwcm]
[app.main.data.workspace.drawing.common :as dwdc]
+ [app.main.data.workspace.review :as dwrv]
+ [app.main.data.workspace.tasks :as dwtk]
[app.main.refs :as refs]
[app.main.store :as st]
[app.main.ui.comments :as cmt]
[app.main.ui.components.dropdown :refer [dropdown]]
[app.main.ui.context :as ctx]
+ [app.main.ui.ds.buttons.icon-button :refer [icon-button*]]
[app.main.ui.ds.foundations.assets.icon :refer [icon*] :as i]
+ [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.panel-title :refer [panel-title*]]
+ [app.main.ui.workspace.review.panel :refer [comments-tab* tasks-tab*]]
+ [app.main.ui.workspace.review.tasks :as rvt]
[app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]]
[rumext.v2 :as mf]))
@@ -79,6 +85,8 @@
[:span {:class (stl/css :icon)}
[:> icon* {:icon-id i/tick :size "s" :class (stl/css :tick-icon)}]]]]))
+(declare comments-tasks-tabs* comments-list*)
+
(mf/defc comments-sidebar*
[{:keys [profiles threads page-id from-viewer]}]
(let [threads-map (mf/deref refs/threads)
@@ -126,46 +134,103 @@
(st/emit! (with-meta (dcmt/open-thread thread) {::ev/origin "viewer"}))
(st/emit! (dwcm/navigate-to-comment thread)))))]
- [:div {:class (stl/css-case :comments-section true
- :from-viewer from-viewer)}
+ (if (and (not from-viewer) (dwtk/enabled?))
+ [:> comments-tasks-tabs* {:threads (vals threads-map)
+ :on-close close-section}]
- [:> panel-title* {:class (stl/css :comments-title)
- :text (tr "labels.comments")
- :on-close close-section}]
+ [:div {:class (stl/css-case :comments-section true
+ :from-viewer from-viewer)}
- [:button {:class (stl/css :mode-dropdown-wrapper)
- :type "button"
- :aria-haspopup "menu"
- :aria-expanded options?
- :on-click toggle-mode-selector}
+ [:> panel-title* {:class (stl/css :comments-title)
+ :text (tr "labels.comments")
+ :on-close close-section}]
+ [:> comments-list* {:local local
+ :options? options?
+ :state* state*
+ :from-viewer from-viewer
+ :toggle-mode-selector toggle-mode-selector
+ :tgroups tgroups
+ :on-thread-click on-thread-click
+ :profiles profiles}]])))
- [:span {:class (stl/css :mode-label)}
- (case (:mode local)
- (nil :all) (tr "labels.show-all-comments")
- :yours (tr "labels.show-your-comments")
- :mentions (tr "labels.show-mentions"))]
- [:div {:class (stl/css :arrow-icon)}
- [:> icon* {:icon-id i/arrow-down :size "s" :class (stl/css :arrow-svg)}]]]
+(mf/defc comments-tasks-tabs*
+ "The comments panel of a file with tasks: a tab for its comments and one
+ for its tasks, beside the button that closes the panel."
+ {::mf/private true}
+ [{:keys [threads on-close]}]
+ (let [local (mf/deref refs/review-local)
+ tasks* (mf/deref refs/tasks)
+ tab (get local :panel-tab :comments)
+ tasks (mf/with-memo [tasks*]
+ (vec (rvt/visible-tasks tasks*)))
+ tabs (mf/with-memo [threads tasks]
+ [{:id "comments"
+ :label (tr "workspace.review.tab.comments" (count threads))}
+ {:id "tasks"
+ :label (tr "workspace.review.tab.tasks" (count tasks))}])
+ on-tab (mf/use-fn #(st/emit! (dwrv/set-panel-tab (keyword %))))
+ button (mf/with-memo [on-close]
+ (mf/html
+ [:> icon-button* {:variant "ghost"
+ :aria-label (tr "labels.close")
+ :on-click on-close
+ :icon i/close}]))]
- [:& dropdown {:show options?
- :on-close #(reset! state* false)}
- [:& sidebar-options {:local local :from-viewer from-viewer}]]
+ (mf/with-effect []
+ (st/emit! (dwtk/fetch-tasks)))
- [:div {:class (stl/css :comments-section-content)}
+ [:div {:class (stl/css :comments-panel)}
+ [:> tab-switcher* {:tabs tabs
+ :selected (name tab)
+ :on-change on-tab
+ :scrollable-panel true
+ :action-button-position "end"
+ :action-button button
+ :class (stl/css :comments-tabs)}
+ [:div {:class (stl/css :comments-tab-content)}
+ (if (= tab :tasks)
+ [:> tasks-tab* {:tasks tasks :grouped true :show-review true}]
+ [:> comments-tab* {:threads threads :show-page true :show-review true}])]]]))
- (if (seq tgroups)
- [:div {:class (stl/css :thread-groups)}
+(mf/defc comments-list*
+ "The comment threads of the file, grouped by page, with the selector of
+ which ones to show."
+ {::mf/private true}
+ [{:keys [local options? state* from-viewer toggle-mode-selector tgroups on-thread-click profiles]}]
+ [:*
+ [:button {:class (stl/css :mode-dropdown-wrapper)
+ :type "button"
+ :aria-haspopup "menu"
+ :aria-expanded options?
+ :on-click toggle-mode-selector}
+
+ [:span {:class (stl/css :mode-label)}
+ (case (:mode local)
+ (nil :all) (tr "labels.show-all-comments")
+ :yours (tr "labels.show-your-comments")
+ :mentions (tr "labels.show-mentions"))]
+ [:div {:class (stl/css :arrow-icon)}
+ [:> icon* {:icon-id i/arrow-down :size "s" :class (stl/css :arrow-svg)}]]]
+
+ [:& dropdown {:show options?
+ :on-close #(reset! state* false)}
+ [:& sidebar-options {:local local :from-viewer from-viewer}]]
+
+ [:div {:class (stl/css :comments-section-content)}
+
+ (if (seq tgroups)
+ [:div {:class (stl/css :thread-groups)}
+ [:> cmt/comment-sidebar-thread-group*
+ {:group (first tgroups)
+ :on-thread-click on-thread-click
+ :profiles profiles}]
+ (for [tgroup (rest tgroups)]
[:> cmt/comment-sidebar-thread-group*
- {:group (first tgroups)
+ {:group tgroup
:on-thread-click on-thread-click
- :profiles profiles}]
- (for [tgroup (rest tgroups)]
- [:> cmt/comment-sidebar-thread-group*
- {:group tgroup
- :on-thread-click on-thread-click
- :profiles profiles
- :key (:page-id tgroup)}])]
+ :profiles profiles
+ :key (:page-id tgroup)}])]
- [:div {:class (stl/css :thread-group-placeholder)}
- [:> empty-state* {:icon i/comments
- :text (tr "labels.no-comments-available")}]])]]))
+ [:div {:class (stl/css :thread-group-placeholder)}
+ [:> empty-state* {:icon i/comments
+ :text (tr "labels.no-comments-available")}]])]])
diff --git a/frontend/src/app/main/ui/workspace/comments.scss b/frontend/src/app/main/ui/workspace/comments.scss
index ea18d51a42..d4298629d3 100644
--- a/frontend/src/app/main/ui/workspace/comments.scss
+++ b/frontend/src/app/main/ui/workspace/comments.scss
@@ -24,6 +24,28 @@
padding: 0 var(--sp-s);
}
+// with tasks the panel has a tab for its comments and one for its tasks,
+// beside the button that closes it, like the history panel
+.comments-panel {
+ display: flex;
+ flex-direction: column;
+ block-size: 100%;
+ min-block-size: 0;
+ background-color: var(--color-background-primary);
+}
+
+.comments-tabs {
+ --tabs-nav-padding-inline-start: var(--sp-m);
+ --tabs-nav-padding-inline-end: var(--sp-m);
+
+ block-size: 100%;
+ min-block-size: 0;
+}
+
+.comments-tab-content {
+ padding-inline: var(--sp-m);
+}
+
.comments-title {
margin: var(--sp-s) var(--sp-s) 0 var(--sp-s);
}
diff --git a/frontend/src/app/main/ui/workspace/palette.cljs b/frontend/src/app/main/ui/workspace/palette.cljs
index 2f27304d97..5f335e8551 100644
--- a/frontend/src/app/main/ui/workspace/palette.cljs
+++ b/frontend/src/app/main/ui/workspace/palette.cljs
@@ -54,7 +54,13 @@
[{:keys [layout on-change-size]}]
(let [color-palette? (:colorpalette layout)
text-palette? (:textpalette layout)
- hide-palettes? (:hide-palettes layout)
+ bottom-bar (mf/deref refs/bottom-bar)
+ on-branch? (some? bottom-bar)
+ ;; on a branch it shares its level with the bar of the branch, and is
+ ;; open only when that one is not (see `layout/open-bottom-bar`)
+ hide-palettes? (if on-branch?
+ (not= :palette bottom-bar)
+ (:hide-palettes layout))
custom-shortcuts (mf/deref refs/custom-shortcuts)
get-tt #(sc/get-effective-tooltip % custom-shortcuts)
@@ -121,11 +127,14 @@
toggle-palettes
(mf/use-fn
+ (mf/deps on-branch?)
(fn [_]
(r/set-resize-type! :top)
(dom/add-class! (dom/get-element-by-class "color-palette") "fade-out-down")
- (st/emit! (-> (dw/toggle-layout-flag :hide-palettes)
- (vary-meta assoc ::ev/origin "workspace-left-toolbar")))))
+ (if on-branch?
+ (st/emit! (dw/toggle-bottom-bar :palette))
+ (st/emit! (-> (dw/toggle-layout-flag :hide-palettes)
+ (vary-meta assoc ::ev/origin "workspace-left-toolbar"))))))
on-select-color-palette
(mf/use-fn
@@ -169,7 +178,8 @@
width (obj/get dom "clientWidth")]
(swap! state* assoc :width width)))
- [:section {:class (stl/css :palette-wrapper)
+ [:section {:class (stl/css-case :palette-wrapper true
+ :on-branch on-branch?)
:id "palette-wrapper"
:style (calculate-palette-style rulers?)
:aria-label (tr "workspace.toolbar.palette-bar")
@@ -177,7 +187,7 @@
(when-not ^boolean read-only?
[:div {:ref parent-ref
:class (dm/str size-classname " " (stl/css-case :palettes true
- :wide any-palette?
+ :wide (and any-palette? (not hide-palettes?))
:hidden-bts hide-palettes?))
:style #js {"--height" (dm/str size "px")}}
@@ -204,7 +214,7 @@
:on-click on-select-text-palette}]]]
- (if any-palette?
+ (if (and any-palette? (not hide-palettes?))
[:*
[:> icon-button* {:variant "ghost"
:class (stl/css :palette-actions)
diff --git a/frontend/src/app/main/ui/workspace/palette.scss b/frontend/src/app/main/ui/workspace/palette.scss
index 29b1e7e106..f198d0f0fd 100644
--- a/frontend/src/app/main/ui/workspace/palette.scss
+++ b/frontend/src/app/main/ui/workspace/palette.scss
@@ -12,12 +12,7 @@
position: absolute;
inline-size: 100vw;
inset-inline-start: 0;
-
- // The branch banner hangs from this same bottom edge and publishes the room
- // it takes from it (`branches.cljs::publish-banner-clearance!`), so the bar
- // sits above the banner instead of over its controls. With no banner the
- // property is unset and the bar keeps its plain bottom anchor.
- inset-block-end: var(--branch-banner-clearance, 0);
+ inset-block-end: 0;
padding-block-end: var(--sp-xs);
/** Aligns AI Chat button **/
@@ -25,6 +20,11 @@
align-items: center;
justify-content: space-between;
gap: var(--sp-s);
+
+ // the level of the bar of the branch, clear of the scroll of the canvas
+ &.on-branch {
+ padding-block-end: var(--sp-m);
+ }
}
// `right` and `width` stay physical: they are the transitioned properties.
diff --git a/frontend/src/app/main/ui/workspace/review/common.cljs b/frontend/src/app/main/ui/workspace/review/common.cljs
new file mode 100644
index 0000000000..ab4076500f
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/review/common.cljs
@@ -0,0 +1,103 @@
+;; 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.common
+ "Pieces shared by the review mode and the tasks: who someone is, what a
+ task points at, and what a change did."
+ (:require
+ [app.common.files.helpers :as cfh]
+ [app.common.math :as mth]
+ [app.main.ui.ds.foundations.assets.icon :as i]
+ [app.util.dom :as dom]
+ [app.util.i18n :refer [tr]]))
+
+(defn profile-name
+ "The name of the person `profile-id`, or a dash when nobody knows it."
+ [profiles profile-id]
+ (or (get-in profiles [profile-id :fullname])
+ (tr "workspace.review.unknown-name")))
+
+(defn status-tone
+ "The tone a task in `status` is drawn in, the colour of its state."
+ [status]
+ (case status
+ "done" "success"
+ "reopened" "warning"
+ "verified" "purple"
+ "wont-do" "error"
+ "info"))
+
+(defn status-label
+ [status]
+ (case status
+ "done" (tr "workspace.tasks.status.done")
+ "reopened" (tr "workspace.tasks.status.reopened")
+ "verified" (tr "workspace.tasks.status.verified")
+ "wont-do" (tr "workspace.tasks.status.wont-do")
+ (tr "workspace.tasks.status.open")))
+
+(defn board-name
+ "The name of the board `frame-id`: what the header of a thread or a
+ task says it is on."
+ [objects frame-id]
+ (let [frame (get objects frame-id)]
+ (if (or (nil? frame) (cfh/root? frame))
+ (tr "workspace.tasks.canvas")
+ (:name frame))))
+
+(defn layer-name
+ "The name of the layer a task points at: the lost one when it was
+ deleted, its board when it points at none."
+ [objects {:keys [shape-id frame-id lost-shape-name]}]
+ (let [shape (get objects shape-id)]
+ (or lost-shape-name
+ (when (and (some? shape) (not (cfh/root? shape)))
+ (:name shape))
+ (board-name objects frame-id))))
+
+(defn thread-anchor-label
+ "What a comment thread points at, as its chip says it: the layer, the
+ size of the area, or the board of the spot."
+ [objects {:keys [anchor-type shape-id area frame-id]}]
+ (case anchor-type
+ :layer (or (some-> (get objects shape-id) :name)
+ (tr "workspace.review.anchor.deleted-layer"))
+ :area (tr "workspace.review.anchor.area"
+ (mth/round (:width area))
+ (mth/round (:height area)))
+ (board-name objects frame-id)))
+
+(defn thread-anchor-icon
+ [{:keys [anchor-type]}]
+ (case anchor-type
+ :layer i/board
+ :area i/comment-area
+ i/pin))
+
+(defn change-kind-label
+ "What a change did to its layer."
+ [kind]
+ (case kind
+ :added (tr "workspace.review.change.added")
+ :deleted (tr "workspace.review.change.deleted")
+ (tr "workspace.review.change.modified")))
+
+(defn change-kind-label-lower
+ "What a change did to its layer, in the middle of a sentence."
+ [kind]
+ (case kind
+ :added (tr "workspace.review.change.added-lower")
+ :deleted (tr "workspace.review.change.deleted-lower")
+ (tr "workspace.review.change.modified-lower")))
+
+(defn event->canvas
+ "The canvas point under a pointer `event` on a layer that covers the
+ viewport."
+ [event vbox zoom]
+ (let [rect (dom/get-bounding-rect (dom/get-current-target event))
+ pt (dom/get-client-position event)]
+ {:x (+ (:x vbox) (/ (- (:x pt) (:left rect)) zoom))
+ :y (+ (:y vbox) (/ (- (:y pt) (:top rect)) zoom))}))
diff --git a/frontend/src/app/main/ui/workspace/review/details.cljs b/frontend/src/app/main/ui/workspace/review/details.cljs
new file mode 100644
index 0000000000..d2902ed878
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/review/details.cljs
@@ -0,0 +1,684 @@
+;; 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.details
+ "The details of a design review: an overview (who opened it, where it
+ stands, its description and reviewers), its activity (what the saves
+ of the branch did since it opened) and its tasks."
+ (: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.workspace.pull-requests :as dwpr]
+ [app.main.data.workspace.review :as dwrv]
+ [app.main.data.workspace.tasks :as dwtk]
+ [app.main.refs :as refs]
+ [app.main.store :as st]
+ [app.main.ui.ds.buttons.button :refer [button*]]
+ [app.main.ui.ds.buttons.link-button :refer [link-button*]]
+ [app.main.ui.ds.controls.select :refer [select*]]
+ [app.main.ui.ds.controls.textarea :refer [textarea*]]
+ [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.heading :refer [heading*]]
+ [app.main.ui.ds.foundations.typography.text :refer [text*]]
+ [app.main.ui.ds.layout.modal :refer [modal* modal-content* modal-footer*]]
+ [app.main.ui.ds.layout.tab-switcher :refer [tab-switcher*]]
+ [app.main.ui.ds.notifications.context-notification :refer [context-notification*]]
+ [app.main.ui.ds.product.avatar :refer [avatar*]]
+ [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.progress-bar :refer [progress-bar*]]
+ [app.main.ui.ds.product.tag :refer [tag*]]
+ [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.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]]
+ [cuerdas.core :as str]
+ [rumext.v2 :as mf]))
+
+(defn- review-tasks
+ [tasks pr-id]
+ (vec (dwtk/sort-tasks (dwtk/review-tasks (vals tasks) pr-id))))
+
+;; --- Overview
+
+(mf/defc stat-card*
+ {::mf/private true}
+ [{:keys [label children]}]
+ [:div {:class (stl/css :stat-card)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :muted)} label]
+ [:div {:class (stl/css :stat-value)} children]])
+
+(mf/defc description-block*
+ "The description of the review; its author and the admins edit it."
+ {::mf/private true}
+ [{:keys [pr can-edit]}]
+ (let [editing* (mf/use-state false)
+ editing? (deref editing*)
+ value* (mf/use-state (or (:description pr) ""))
+ value (deref value*)
+
+ on-edit (mf/use-fn #(reset! editing* true))
+ on-change (mf/use-fn #(reset! value* (dom/get-target-val %)))
+ on-cancel (mf/use-fn (mf/deps pr)
+ (fn [_]
+ (reset! value* (or (:description pr) ""))
+ (reset! editing* false)))
+ on-save (mf/use-fn
+ (mf/deps pr value)
+ (fn [_]
+ (reset! editing* false)
+ (st/emit! (dwpr/update-pull-request (:id pr) {:description (str/trim value)}))))]
+
+ [:section {:class (stl/css :section)}
+ [:div {:class (stl/css :section-head)}
+ [:> heading* {:level 3 :typography t/body-small :class (stl/css :section-title)}
+ (tr "workspace.pull-requests.info.description")]
+ (when (and can-edit (not editing?))
+ [:> button* {:variant "ghost" :on-click on-edit}
+ (tr "labels.edit")])]
+ ;; the same look as the description of a branch (its info dialog)
+ (cond
+ editing?
+ [:div {:class (stl/css :edit-block)}
+ [:> textarea* {:class (stl/css :description-input)
+ :value value
+ :rows 3
+ :max-length 4000
+ :auto-focus true
+ :aria-label (tr "workspace.pull-requests.info.description")
+ :on-change on-change}]
+ [:div {:class (stl/css :edit-actions)}
+ [:> button* {:variant "secondary" :on-click on-cancel} (tr "labels.cancel")]
+ [:> button* {:variant "primary" :on-click on-save} (tr "labels.save")]]]
+
+ (str/blank? (:description pr))
+ [:> text* {:as "p" :typography t/body-medium :class (stl/css :description-empty)}
+ (tr "workspace.review.details.no-description")]
+
+ :else
+ [:> text* {:as "p" :typography t/body-medium :class (stl/css :description)}
+ (:description pr)])]))
+
+(defn- verdict-label
+ [{:keys [state stale]}]
+ (cond
+ stale (tr "workspace.pull-requests.review-state.stale")
+ (= "approved" state) (tr "workspace.pull-requests.review-state.approved")
+ (= "changes-requested" state) (tr "workspace.pull-requests.review-state.changes-requested")
+ :else (tr "workspace.pull-requests.review-state.pending")))
+
+(defn- verdict-tone
+ [{:keys [state stale]}]
+ (cond
+ stale "neutral"
+ (= "approved" state) "success"
+ (= "changes-requested" state) "warning"
+ :else "neutral"))
+
+(mf/defc reviewers-block*
+ "The reviewers of the review and their verdicts; its author and the
+ admins add reviewers."
+ {::mf/private true}
+ [{:keys [pr can-edit]}]
+ (let [profiles (mf/deref refs/profiles)
+ team (mf/deref refs/team)
+ adding* (mf/use-state false)
+ adding? (deref adding*)
+
+ current (into #{} (map :profile-id) (:reviews pr))
+ options (mf/with-memo [team current pr]
+ (->> (:members team)
+ (remove #(contains? current (:id %)))
+ (remove #(= (:created-by pr) (:id %)))
+ (sort-by :fullname)
+ (mapv (fn [{:keys [id fullname]}] {:id (str id) :label fullname}))))
+
+ on-add (mf/use-fn #(reset! adding* true))
+ on-select (mf/use-fn
+ (mf/deps pr current)
+ (fn [id]
+ (reset! adding* false)
+ (st/emit! (dwpr/update-pull-request
+ (:id pr)
+ {:reviewers (conj (vec current) (uuid/parse id))}))))]
+
+ [:section {:class (stl/css :section)}
+ [:div {:class (stl/css :section-head)}
+ [:> heading* {:level 3 :typography t/body-small :class (stl/css :section-title)}
+ (tr "workspace.pull-requests.info.reviewers")]
+ (when (and can-edit (seq options) (not adding?))
+ [:> link-button* {:icon i/add :on-click on-add}
+ (tr "workspace.review.details.add-reviewer")])]
+ (when adding?
+ [:> select* {:options (into [{:id "" :label (tr "workspace.review.details.pick-reviewer")}] options)
+ :default-selected ""
+ :on-change on-select
+ :has-portal true
+ :wrapper-class (stl/css :reviewer-picker)}])
+ (if (empty? (:reviews pr))
+ [:> text* {:as "p" :typography t/body-small :class (stl/css :muted)}
+ (tr "workspace.review.details.no-reviewers")]
+ [:ul {:class (stl/css :reviewers)}
+ (for [review (:reviews pr)]
+ (let [reviewer (get profiles (:profile-id review))]
+ [:li {:key (dm/str (:profile-id review)) :class (stl/css :reviewer)}
+ [:div {:class (stl/css :reviewer-head)}
+ (when reviewer [:> avatar* {:profile reviewer :variant "S"}])
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :strong)}
+ (rvc/profile-name profiles (:profile-id review))]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :muted)}
+ (ct/format-inst (:updated-at review) :localized-date-time)]
+ [:> tag* {:variant "pill"
+ :tone (verdict-tone review)
+ :class (stl/css :push-end)}
+ (verdict-label review)]]
+ (when-not (str/blank? (:comment review))
+ [:> text* {:as "p" :typography t/body-small :class (stl/css :reviewer-comment)}
+ (tr "workspace.review.details.quoted-comment" (:comment review))])]))])]))
+
+(mf/defc overview-tab*
+ {::mf/private true}
+ [{:keys [pr tasks activity]}]
+ (let [profiles (mf/deref refs/profiles)
+ profile (mf/deref refs/profile)
+ team (mf/deref refs/team)
+ author (get profiles (:created-by pr))
+ can-edit (or (= (:created-by pr) (:id profile))
+ (boolean (get-in team [:permissions :is-admin])))
+
+ [approvals total] (prui/current-approvals pr)
+ missing (- total approvals)
+ open (count (remove dwtk/closed? tasks))
+ closed (count (filter dwtk/closed? tasks))
+ counts (:counts pr)
+ last-row (first (:rows activity))]
+
+ [:div {:class (stl/css :tab-body)}
+ [:div {:class (stl/css :facts)}
+ [:div {:class (stl/css :fact)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :muted)}
+ (tr "workspace.pull-requests.info.author")]
+ [:div {:class (stl/css :fact-value)}
+ (when author [:> avatar* {:profile author :variant "S"}])
+ [:> text* {:as "span" :typography t/body-small} (rvc/profile-name profiles (:created-by pr))]]]
+ [:div {:class (stl/css :fact)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :muted)}
+ (tr "workspace.review.details.opened")]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :fact-value)}
+ (ct/format-inst (:created-at pr) :localized-date-time)]]
+ [:div {:class (stl/css :fact)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :muted)}
+ (tr "workspace.review.details.last-change")]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :fact-value)}
+ (if (some? last-row)
+ (tr "workspace.review.details.last-change-by"
+ (ct/timeago (:created-at last-row))
+ (rvc/profile-name profiles (:profile-id last-row)))
+ (ct/timeago (:review-updated-at pr)))]]]
+
+ (when (and (pos? missing) (= "open" (:status pr)))
+ [:> context-notification* {:level :warning :appearance :ghost}
+ (dm/str (tr "workspace.review.details.needs-approvals" (i18n/c missing))
+ (when (pos? open)
+ (dm/str " " (tr "workspace.review.details.open-tasks-dont-block" (i18n/c open)))))])
+
+ [:div {:class (stl/css :stats)}
+ [:> stat-card* {:label (tr "workspace.pull-requests.info.approvals")}
+ [:span (tr "workspace.review.details.x-of-y" approvals total)]
+ [:span {:class (stl/css :avatars)}
+ (for [review (:reviews pr)]
+ (when-let [reviewer (get profiles (:profile-id review))]
+ [:> avatar* {:key (dm/str (:profile-id review)) :profile reviewer :variant "S"}]))]]
+ [:> stat-card* {:label (tr "workspace.review.details.comments")}
+ [:span (tr "workspace.review.details.comments-open" (:comments-open counts 0))]
+ [:span {:class (stl/css :muted)}
+ (tr "workspace.review.details.comments-resolved" (:comments-resolved counts 0))]]
+ [:> stat-card* {:label (tr "workspace.review.tab.tasks-plain")}
+ [:span (tr "workspace.review.details.x-of-y" closed (count tasks))]
+ [:> progress-bar* {:value closed :total (count tasks) :class (stl/css :mini-bar)}]]
+ [:> stat-card* {:label (tr "workspace.review.details.branch")}
+ (cond
+ (pos? (or (:conflicts pr) 0))
+ [:span {:class (stl/css :warning)} (tr "workspace.pull-requests.badge.conflicts" (dm/str (:conflicts pr)))]
+
+ (pos? (or (:behind pr) 0))
+ [:span {:class (stl/css :warning)} (tr "workspace.review.details.behind" (i18n/c (:behind pr)))]
+
+ :else
+ [:span {:class (stl/css :ok)}
+ [:span {:class (stl/css :dot)}]
+ (tr "workspace.review.details.up-to-date")])]]
+
+ [:> description-block* {:pr pr :can-edit can-edit}]
+ [:> reviewers-block* {:pr pr :can-edit can-edit}]]))
+
+;; --- Activity
+
+(defn- day-label
+ "Today, yesterday, or the date of `inst`: the heading of the changes
+ made that day."
+ [inst]
+ (let [day (fn [ms] (.toDateString (js/Date. ms)))
+ now (js/Date.now)
+ this-day (day (inst-ms inst))]
+ (cond
+ (= this-day (day now)) (tr "workspace.review.activity.today")
+ (= this-day (day (- now 86400000))) (tr "workspace.review.activity.yesterday")
+ :else (ct/format-inst inst :localized-date))))
+
+(defn- kind-tone
+ [kind]
+ (case kind :added "success" :deleted "error" "info"))
+
+(defn- display-attr
+ "A property of a change as the hover card shows it: its label and its
+ values before and after, the token behind a value when there is one."
+ [attr [before after] [tokens-before tokens-after]]
+ (let [token-key (case attr :fills :fill :strokes :stroke-color nil)]
+ [(brc/attr-label attr)
+ (or (get tokens-before token-key) before)
+ (or (get tokens-after token-key) after)]))
+
+(def ^:private card-width
+ "The width of the card of a change, as its style sets it."
+ 320)
+
+(defn- card-style
+ "Put the card beside the row box `rect` (viewport coordinates), on its
+ right when it fits there and on its left otherwise, inside the window."
+ [{:keys [left right top]}]
+ (let [gap 8
+ win-w (.-innerWidth js/window)
+ win-h (.-innerHeight js/window)
+ x (if (< (+ right gap card-width) win-w)
+ (+ right gap)
+ (max gap (- left gap card-width)))
+ y (min top (- win-h 360))]
+ #js {:left (dm/str x "px")
+ :top (dm/str (max gap y) "px")}))
+
+(mf/defc change-card*
+ "What a change did, beside its row. It goes in a portal so the scroll of
+ the dialog never cuts it."
+ {::mf/private true}
+ [{:keys [entry tasks rect]}]
+ (let [profiles (mf/deref refs/profiles)
+ data (mf/deref refs/workspace-data)
+ objects (dm/get-in data [:pages-index (:page-id entry) :objects])
+ shape (get objects (:id entry))
+ attrs (:attrs entry)
+ tokens (:applied-tokens attrs)
+ linked (filterv #(= (:id entry) (:shape-id %)) tasks)]
+
+ [:div {:class (stl/css :change-card) :role "tooltip" :style (card-style rect)}
+ [:div {:class (stl/css :change-card-head)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :strong)} (:name entry)]
+ [:> 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}]
+ [:div {:class (stl/css :deleted-preview)}])]
+ (when (seq attrs)
+ [:dl {:class (stl/css :attrs)}
+ (for [[attr diff] (dissoc attrs :applied-tokens :parent-id)]
+ (let [[label before after] (display-attr attr diff tokens)]
+ [:* {:key (name attr)}
+ [:dt {:class (stl/css :muted)} label]
+ [:dd {:class (stl/css :attr-value)}
+ [:> brl/value-chip* {:value before :is-old true}]
+ [:> icon* {:icon-id i/arrow-long-right :size "s" :class (stl/css :attr-arrow)}]
+ [:> brl/value-chip* {:value after}]]]))])
+ (when (seq linked)
+ [:div {:class (stl/css :linked)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :section-title)}
+ (tr "workspace.review.activity.linked-tasks" (i18n/c (count linked)))]
+ (for [task linked]
+ [:div {:key (dm/str (:id task)) :class (stl/css :linked-task)}
+ [:> text* {:as "span" :typography t/body-small} (:title task)]
+ [:> task-status* {:status (:status task) :label (rvc/status-label (:status task))}]
+ (when (dwtk/lost? task)
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :warning)}
+ (tr "workspace.review.activity.now-points-to"
+ (rvc/board-name objects (:frame-id task)))])])])
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :muted)}
+ (tr "workspace.review.text-and-detail"
+ (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 :muted)}
+ (if (seq linked)
+ (tr "workspace.review.activity.open-task-to-relink")
+ (tr "workspace.review.activity.click-to-show"))]]))
+
+(def ^:private rows-shown
+ "The changes a group lists before it folds the rest."
+ 4)
+
+(mf/defc change-item*
+ "One change of a group: a click shows it on the canvas, and hovering it
+ shows what it did."
+ {::mf/private true}
+ [{:keys [entry tasks portal]}]
+ (let [id (:id entry)
+ tone (kind-tone (:kind entry))
+ rect* (mf/use-state nil)
+ rect (deref rect*)
+
+ on-enter (mf/use-fn #(reset! rect* (dom/get-bounding-rect (dom/get-current-target %))))
+ on-leave (mf/use-fn #(reset! rect* nil))
+ on-show (mf/use-fn (mf/deps id) #(st/emit! (dwrv/show-change-of id)))]
+
+ [:li {:class (stl/css :change-item)
+ :on-pointer-enter on-enter
+ :on-pointer-leave on-leave}
+ [:> change-row* {:title (or (:name entry) (tr "workspace.review.unknown-name"))
+ :subtitle (:frame-name entry)
+ :tone tone
+ :is-muted (= :deleted (:kind entry))
+ :end (mf/html [:> tag* {:tone tone}
+ (rvc/change-kind-label (:kind entry))])
+ :on-click on-show}]
+ (when (some? rect)
+ (mf/portal
+ (mf/html [:> change-card* {:entry entry :tasks tasks :rect rect}])
+ portal))]))
+
+(mf/defc change-group*
+ {::mf/private true}
+ [{:keys [session tasks is-open]}]
+ (let [profiles (mf/deref refs/profiles)
+ open* (mf/use-state is-open)
+ open? (deref open*)
+ all* (mf/use-state false)
+ all? (deref all*)
+ portal (hooks/use-portal-container :tooltip)
+ entries (:entries session)
+ shown (if all? entries (take rows-shown entries))
+ person (get profiles (:profile-id session))
+
+ on-toggle (mf/use-fn #(swap! open* not))
+ on-all (mf/use-fn #(reset! all* true))]
+
+ [:div {:class (stl/css :change-group)}
+ [:button {:class (stl/css :change-group-head)
+ :type "button"
+ :aria-expanded open?
+ :on-click on-toggle}
+ [:> icon* {:icon-id (if open? i/arrow-down i/arrow-right) :size "s"}]
+ (when person [:> avatar* {:profile person :variant "S"}])
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :strong)}
+ (rvc/profile-name profiles (:profile-id session))]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :muted)}
+ (tr "workspace.review.activity.changed" (i18n/c (count entries)))]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :muted :push-end)}
+ (ct/format-inst (:end session) :localized-time)]]
+ (when open?
+ [:ul {:class (stl/css :change-rows)}
+ (for [entry shown]
+ [:> change-item* {:key (dm/str (:id entry))
+ :entry entry
+ :tasks tasks
+ :portal portal}])
+ (when (and (not all?) (> (count entries) rows-shown))
+ [:li
+ [:> link-button* {:on-click on-all}
+ (tr "workspace.review.activity.more" (i18n/c (- (count entries) rows-shown)))]])])]))
+
+(mf/defc day-group*
+ "The changes of one day: only the group of its last session opens."
+ {::mf/private true}
+ [{:keys [sessions tasks]}]
+ (let [sessions (mf/with-memo [sessions]
+ (into [] d/xf:add-index sessions))]
+ [:section {:class (stl/css :section)}
+ [:> heading* {:level 3 :typography t/body-small :class (stl/css :section-title)}
+ (day-label (:end (first sessions)))]
+ (for [session sessions]
+ [:> change-group* {:key (dm/str (inst-ms (:start session)) (:profile-id session))
+ :session session
+ :tasks tasks
+ :is-open (zero? (::d/index session))}])]))
+
+(mf/defc activity-tab*
+ {::mf/private true}
+ [{:keys [pr activity tasks]}]
+ (let [profiles (mf/deref refs/profiles)
+ local (mf/deref refs/review-local)
+ kind (get local :change-filter :all)
+ entries (:entries activity)
+ people (count (into #{} (map :profile-id) (:rows activity)))
+ counts (frequencies (map :kind entries))
+ sessions (mf/with-memo [activity kind]
+ (->> (:sessions activity)
+ (keep (fn [s]
+ (let [es (cond->> (:entries s)
+ (not= :all kind) (filterv #(= kind (:kind %))))]
+ (when (seq es) (assoc s :entries es)))))))
+ by-day (mf/with-memo [sessions]
+ (partition-by #(day-label (:end %)) sessions))
+
+ on-filter
+ (mf/use-fn
+ (fn [event]
+ (let [kind (-> (dom/get-current-target event) (dom/get-data "filter") keyword)]
+ (st/emit! (dwrv/set-change-filter kind)))))
+
+ on-show (mf/use-fn #(st/emit! (dwrv/show-change 0)))]
+
+ (case (:status activity)
+ :loaded
+ [:div {:class (stl/css :tab-body)}
+ [:> text* {:as "p" :typography t/body-small :class (stl/css :muted)}
+ (tr "workspace.review.activity.summary" (count entries) people)]
+ [:div {:class (stl/css :activity-bar)}
+ [:div {:class (stl/css :filters)}
+ (for [[id label n] [[:all (tr "workspace.review.activity.all") (count entries)]
+ [:added (tr "workspace.review.change.added") (:added counts 0)]
+ [:modified (tr "workspace.review.change.modified") (:modified counts 0)]
+ [:deleted (tr "workspace.review.change.deleted") (:deleted counts 0)]]]
+ [:> filter-chip* {:key (name id)
+ :label (tr "workspace.review.label-count" label n)
+ :tone (case id :added "success" :deleted "error" :modified "info" "neutral")
+ :is-selected (= kind id)
+ :data-filter (name id)
+ :on-click on-filter}])]
+ [:> button* {:variant "ghost" :icon i/shown :on-click on-show
+ :disabled (empty? entries)}
+ (tr "workspace.review.activity.show-on-canvas")]]
+
+ (if (empty? sessions)
+ [:> empty-state* {:icon i/history
+ :text (tr "workspace.review.activity.empty")}]
+ (for [day by-day]
+ [:> day-group* {:key (day-label (:end (first day)))
+ :sessions day
+ :tasks tasks}]))
+
+ [:div {:class (stl/css :opened-line)}
+ [:> icon* {:icon-id i/git-pull-request-arrow :size "s"}]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :muted)}
+ (tr "workspace.review.activity.opened"
+ (rvc/profile-name profiles (:created-by pr))
+ (ct/format-inst (:created-at pr) :localized-date-time))]]]
+
+ :error
+ [:> empty-state* {:icon i/triangle-alert
+ :text (tr "workspace.review.activity.error")}]
+
+ [:div {:class (stl/css :tab-body)}
+ [:> text* {:as "p" :typography t/body-small :class (stl/css :muted)}
+ (tr "labels.loading")]])))
+
+;; --- Tasks
+
+(mf/defc tasks-tab*
+ "The tasks of the review: filters by state, as the activity has by kind
+ of change, how many are closed and the list. With every state shown,
+ the closed tasks fold under the open ones."
+ {::mf/private true}
+ [{:keys [tasks]}]
+ (let [local (mf/deref refs/review-local)
+ status (get local :task-status-filter :all)
+ closed-open* (mf/use-state false)
+ closed-open? (deref closed-open*)
+ counts (frequencies (map :status tasks))
+ open-tasks (remove dwtk/closed? tasks)
+ closed-tasks (filter dwtk/closed? tasks)
+ shown (mf/with-memo [tasks status]
+ (filterv #(= status (:status %)) tasks))
+
+ on-filter
+ (mf/use-fn
+ (fn [event]
+ (let [value (-> (dom/get-current-target event) (dom/get-data "filter"))]
+ (st/emit! (dwrv/set-task-status-filter
+ (if (= "all" value) :all value))))))
+
+ on-toggle (mf/use-fn #(swap! closed-open* not))]
+
+ [:div {:class (stl/css :tab-body)}
+ [:div {:class (stl/css :tasks-head)}
+ [:div {:class (stl/css :filters)}
+ [:> filter-chip* {:label (tr "workspace.review.label-count"
+ (tr "workspace.review.activity.all")
+ (count tasks))
+ :is-selected (= :all status)
+ :data-filter "all"
+ :on-click on-filter}]
+ (for [id dwrv/task-statuses]
+ [:> filter-chip* {:key id
+ :label (tr "workspace.review.label-count"
+ (rvc/status-label id)
+ (get counts id 0))
+ :tone (rvc/status-tone id)
+ :is-selected (= status id)
+ :data-filter id
+ :on-click on-filter}])]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :strong)}
+ (tr "workspace.tasks.closed-of" (count closed-tasks) (count tasks))]]
+ [:> progress-bar* {:value (count closed-tasks) :total (count tasks) :class (stl/css :wide-bar)}]
+
+ (cond
+ (empty? tasks)
+ [:> empty-state* {:icon i/view-as-list :text (tr "workspace.tasks.empty")}]
+
+ (not= :all status)
+ (if (empty? shown)
+ [:> empty-state* {:icon i/view-as-list :text (tr "workspace.tasks.empty")}]
+ [:> rvt/task-list* {:tasks shown}])
+
+ :else
+ [:*
+ [:> rvt/task-list* {:tasks (vec open-tasks)}]
+ (when (seq closed-tasks)
+ [:section {:class (stl/css :section)}
+ [:> link-button* {:icon (if closed-open? i/arrow-down i/arrow-right)
+ :tone "neutral"
+ :class (stl/css :closed-toggle)
+ :aria-expanded closed-open?
+ :on-click on-toggle}
+ (tr "workspace.review.details.closed" (count closed-tasks))]
+ (when closed-open?
+ [:> rvt/task-list* {:tasks (vec closed-tasks)}])])])]))
+
+;; --- Dialog
+
+(mf/defc review-details-dialog*
+ {::mf/register modal/components
+ ::mf/register-as :review-details}
+ [{:keys [pr tab]}]
+ (let [preview (mf/deref refs/pull-request-preview)
+ ;; the review open now is fresher than the row the dialog got
+ pr (if (= (:id pr) (:pr-id preview)) (or (:info preview) pr) pr)
+ profile (mf/deref refs/profile)
+ team (mf/deref refs/team)
+ tasks* (mf/deref refs/tasks)
+ activity (mf/deref refs/review-activity)
+ tasks (mf/with-memo [tasks* pr] (review-tasks tasks* (:id pr)))
+ tab* (mf/use-state (or tab "overview"))
+ tab (deref tab*)
+ profiles (mf/deref refs/profiles)
+ author (get profiles (:created-by pr))
+
+ reviewer? (some #(= (:profile-id %) (:id profile)) (:reviews pr))
+ can-close? (and (or (= (:created-by pr) (:id profile))
+ (boolean (get-in team [:permissions :is-admin])))
+ (= "open" (:status pr)))
+ entries (:entries activity)
+
+ tabs (mf/with-memo [entries tasks]
+ [{:id "overview" :label (tr "workspace.review.details.overview")}
+ {:id "activity" :label (tr "workspace.review.details.activity" (count entries))}
+ {:id "tasks" :label (tr "workspace.review.tab.tasks" (count tasks))}])
+
+ ;; kept in the props too: a confirmation takes the place of the dialog
+ ;; and brings it back with its props
+ on-tab (mf/use-fn
+ (fn [id]
+ (reset! tab* id)
+ (st/emit! (modal/update-props :review-details {:tab id}))))
+ on-close (mf/use-fn #(st/emit! (modal/hide)))
+ on-open-change (mf/use-fn (fn [open?] (when-not open? (st/emit! (modal/hide)))))
+ on-compare (mf/use-fn (mf/deps pr) #(prui/open-compare! pr))
+ on-review (mf/use-fn (mf/deps pr) #(modal/show! :pull-request-review {:pr pr}))
+ on-close-review (mf/use-fn (mf/deps pr) #(prui/confirm-close! pr))]
+
+ (mf/with-effect [pr]
+ (st/emit! (dwrv/fetch-activity (:id pr))
+ (dwtk/fetch-tasks)))
+
+ [:> modal* {:is-open true
+ :on-open-change on-open-change
+ :size "large"}
+ [:> dialog-header*
+ {:icon i/git-pull-request-arrow
+ :title (:title pr)
+ :subtitle
+ (mf/html
+ [:div {:class (stl/css :subtitle)}
+ [:> pr-state-badge* {:pr pr}]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :muted)}
+ (tr "workspace.review.text-and-detail"
+ (tr "workspace.review.route" (:branch-name pr) (tr "workspace.branches.main"))
+ (tr "workspace.review.details.opened-by"
+ (ct/format-inst (:created-at pr) :localized-date)
+ (or (:fullname author) (tr "workspace.review.unknown-name"))))]])}]
+
+ [:> modal-content* {:class (stl/css :content)}
+ [:> tab-switcher* {:tabs tabs
+ :selected tab
+ :on-change on-tab
+ :scrollable-panel true
+ :class (stl/css :tabs)}
+ (case tab
+ "activity" [:> activity-tab* {:pr pr :activity activity :tasks tasks}]
+ "tasks" [:> tasks-tab* {:tasks tasks}]
+ [:> overview-tab* {:pr pr :tasks tasks :activity activity}])]]
+
+ [:> modal-footer* {:class (stl/css :footer)}
+ (when can-close?
+ [:> button* {:variant "ghost"
+ :class (stl/css :push-start)
+ :on-click on-close-review}
+ (tr "workspace.review.details.close-review")])
+ [:> button* {:variant "secondary" :icon i/git-compare-arrows :on-click on-compare}
+ (tr "workspace.branches.compare")]
+ (if reviewer?
+ [:> button* {:variant "primary" :on-click on-review}
+ (tr "workspace.review.submit")]
+ [:> button* {:variant "primary" :on-click on-close}
+ (tr "labels.close")])]]))
diff --git a/frontend/src/app/main/ui/workspace/review/details.scss b/frontend/src/app/main/ui/workspace/review/details.scss
new file mode 100644
index 0000000000..cc75371535
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/review/details.scss
@@ -0,0 +1,395 @@
+// 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/typography.scss" as *;
+
+.subtitle {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: var(--sp-s);
+}
+
+.content {
+ display: flex;
+ flex-direction: column;
+ min-block-size: px2rem(420);
+ max-block-size: 70vh;
+}
+
+.tabs {
+ flex: 1;
+ min-block-size: 0;
+}
+
+.tab-body {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-l);
+ padding-block: var(--sp-m);
+}
+
+.footer {
+ display: flex;
+ gap: var(--sp-s);
+}
+
+.push-start {
+ margin-inline-end: auto;
+}
+
+.push-end {
+ margin-inline-start: auto;
+}
+
+.muted {
+ color: var(--color-foreground-secondary);
+}
+
+.strong {
+ color: var(--color-foreground-primary);
+}
+
+.warning {
+ color: var(--color-accent-warning);
+}
+
+.ok {
+ display: inline-flex;
+ align-items: center;
+ gap: var(--sp-xs);
+ color: var(--color-foreground-primary);
+}
+
+.dot {
+ inline-size: $sz-6;
+ block-size: $sz-6;
+ border-radius: $br-circle;
+ background-color: var(--color-accent-success);
+}
+
+// TODO: No exact DS typography match found.
+// Closest match: headline-small (weight 400 vs 500, line-height 1.3 vs 1.2).
+.closed-toggle {
+ text-transform: uppercase;
+}
+
+// --- Overview
+
+.facts {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ padding: var(--sp-m);
+ border-radius: $br-8;
+ background-color: var(--color-background-tertiary);
+}
+
+.fact {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-xs);
+ padding-inline: var(--sp-m);
+
+ & + & {
+ border-inline-start: $b-1 solid var(--color-background-quaternary);
+ }
+}
+
+.fact-value {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-s);
+ color: var(--color-foreground-primary);
+}
+
+.stats {
+ display: grid;
+ grid-template-columns: repeat(4, 1fr);
+ gap: var(--sp-s);
+}
+
+.stat-card {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+ padding: var(--sp-m);
+ border-radius: $br-8;
+ background-color: var(--color-background-tertiary);
+}
+
+.stat-value {
+ @include use-typography("body-medium");
+
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: var(--sp-s);
+ color: var(--color-foreground-primary);
+}
+
+.avatars {
+ display: inline-flex;
+ gap: var(--sp-xxs);
+}
+
+.mini-bar {
+ flex: 1;
+ min-inline-size: $sz-32;
+}
+
+.wide-bar {
+ inline-size: 100%;
+}
+
+.section {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+}
+
+.section-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+}
+
+.section-title {
+ margin: 0;
+ color: var(--color-foreground-secondary);
+
+ // TODO: No exact DS typography match found.
+ // Closest match: headline-small (weight 400 vs 500, line-height 1.3 vs 1.2).
+ text-transform: uppercase;
+}
+
+// a description reads as the one of a branch (its info dialog): a filled
+// box as high as 400px, which scrolls inside past it, or a dashed one while
+// there is none
+.description {
+ max-block-size: px2rem(400);
+ overflow-y: auto;
+ margin: 0;
+ padding: var(--sp-s);
+ border-radius: $br-8;
+ background-color: var(--color-background-tertiary);
+ color: var(--color-foreground-primary);
+ white-space: pre-wrap;
+ overflow-wrap: break-word;
+}
+
+.description-empty {
+ margin: 0;
+ padding: var(--sp-s);
+ border-radius: $br-8;
+ border: $b-1 dashed var(--color-background-quaternary);
+ color: var(--color-foreground-secondary);
+ font-style: italic;
+}
+
+.edit-block {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+
+ // the text of the textarea of a branch description, and room to write:
+ // as high as the description may grow while read. Two classes, so it
+ // wins over the DS textarea whatever the order of the styles
+ .description-input {
+ @include use-typography("body-medium");
+
+ min-block-size: px2rem(400);
+ }
+}
+
+.edit-actions {
+ display: flex;
+ justify-content: flex-end;
+ gap: var(--sp-s);
+}
+
+// the tab scrolls and would cut the focus outline of a select that fills it
+.reviewer-picker {
+ padding-inline: $b-1;
+}
+
+.reviewers {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+
+.reviewer {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+ padding: var(--sp-m);
+ border-radius: $br-8;
+ background-color: var(--color-background-tertiary);
+}
+
+.reviewer-head {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-s);
+}
+
+.reviewer-comment {
+ margin: 0;
+ color: var(--color-foreground-primary);
+}
+
+// --- Activity
+
+.activity-bar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--sp-s);
+}
+
+.filters {
+ display: flex;
+ flex-wrap: wrap;
+ gap: var(--sp-xs);
+}
+
+.change-group {
+ display: flex;
+ flex-direction: column;
+ border-radius: $br-8;
+ background-color: var(--color-background-tertiary);
+}
+
+.change-group-head {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-s);
+ padding: var(--sp-m);
+ border: none;
+ background: none;
+ color: var(--color-foreground-secondary);
+ text-align: start;
+ cursor: pointer;
+}
+
+.change-rows {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-xs);
+ margin: 0;
+ padding: 0 var(--sp-m) var(--sp-m);
+ list-style: none;
+}
+
+.change-item {
+ position: relative;
+}
+
+.change-card {
+ position: fixed;
+ z-index: var(--z-index-dropdown);
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+ inline-size: px2rem(320);
+ padding: var(--sp-m);
+ border: $b-1 solid var(--color-accent-info);
+ border-radius: $br-8;
+ background-color: var(--color-background-primary);
+ box-shadow: 0 0 px2rem(12) 0 var(--color-shadow-dark);
+
+ // it goes in a portal: nothing above it sets the color of its text
+ color: var(--color-foreground-primary);
+ pointer-events: none;
+}
+
+.change-card-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--sp-s);
+}
+
+.change-card-preview {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ block-size: $sz-96;
+ padding: var(--sp-s);
+ border-radius: $br-4;
+ background-color: var(--color-background-quaternary);
+}
+
+.deleted-preview {
+ inline-size: 70%;
+ block-size: 40%;
+ border: $b-1 dashed var(--color-accent-error);
+ border-radius: $br-8;
+}
+
+.attrs {
+ @include use-typography("body-small");
+
+ display: grid;
+ grid-template-columns: auto 1fr;
+ gap: var(--sp-xs) var(--sp-s);
+ margin: 0;
+}
+
+.attr-value {
+ display: flex;
+ align-items: center;
+ justify-content: flex-end;
+ gap: var(--sp-s);
+ min-inline-size: 0;
+ margin: 0;
+ overflow: hidden;
+ white-space: nowrap;
+}
+
+.attr-arrow {
+ flex-shrink: 0;
+ color: var(--color-foreground-secondary);
+}
+
+.linked {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-xs);
+}
+
+.linked-task {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: var(--sp-xs);
+ padding: var(--sp-s);
+ border-radius: $br-4;
+ background-color: var(--color-background-tertiary);
+}
+
+.opened-line {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-s);
+ color: var(--color-accent-info);
+}
+
+// --- Tasks
+
+.tasks-head {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--sp-s);
+}
diff --git a/frontend/src/app/main/ui/workspace/review/filter_menu.cljs b/frontend/src/app/main/ui/workspace/review/filter_menu.cljs
new file mode 100644
index 0000000000..74f843c7d4
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/review/filter_menu.cljs
@@ -0,0 +1,77 @@
+;; 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.filter-menu
+ "The dropdown 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]
+ [rumext.v2 :as mf]))
+
+(mf/defc menu-item*
+ {::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)}]]])
+
+(mf/defc filter-menu*
+ "A button naming the view of a list that opens the views to pick from
+ (`options`, a vector of maps with `:id` and `:label`; `selected` is the
+ id of the one in use), and below them what `toggle-label` turns on or off."
+ [{:keys [options selected toggle-label is-toggled on-select on-toggle]}]
+ (let [open* (mf/use-state false)
+ open? (deref open*)
+ current (d/seek #(= selected (:id %)) options)
+
+ on-trigger
+ (mf/use-fn
+ (fn [event]
+ (dom/stop-propagation event)
+ (swap! open* not)))
+
+ on-close (mf/use-fn #(reset! open* false))
+
+ on-item
+ (mf/use-fn
+ (mf/deps on-select)
+ (fn [event]
+ (on-select (-> (dom/get-current-target event)
+ (dom/get-data "id")
+ (keyword)))))]
+
+ [: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}]]]]))
diff --git a/frontend/src/app/main/ui/workspace/review/filter_menu.scss b/frontend/src/app/main/ui/workspace/review/filter_menu.scss
new file mode 100644
index 0000000000..c7d834dd01
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/review/filter_menu.scss
@@ -0,0 +1,105 @@
+// 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 *;
+
+.filter-menu {
+ position: relative;
+}
+
+.trigger {
+ --trigger-bg-color: var(--color-background-tertiary);
+
+ display: flex;
+ align-items: center;
+ gap: var(--sp-s);
+ inline-size: 100%;
+ block-size: $sz-32;
+ padding: var(--sp-s);
+ border: none;
+ border-radius: $br-8;
+ background-color: var(--trigger-bg-color);
+ color: var(--color-foreground-primary);
+ cursor: pointer;
+
+ &:hover {
+ --trigger-bg-color: var(--color-background-quaternary);
+ }
+}
+
+.trigger-label {
+ flex-grow: 1;
+ text-align: start;
+}
+
+.trigger-icon {
+ flex-shrink: 0;
+ color: var(--color-foreground-secondary);
+}
+
+.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;
+}
+
+.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 {
+ min-inline-size: 0;
+}
+
+.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/markers.cljs b/frontend/src/app/main/ui/workspace/review/markers.cljs
new file mode 100644
index 0000000000..58e3b39657
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/review/markers.cljs
@@ -0,0 +1,450 @@
+;; 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.markers
+ "The marks of the design reviews and the tasks on the canvas. They live
+ in the comments layer, inside its box translated by the viewbox, so a
+ canvas point `p` sits at `p * zoom`.
+
+ A thread written in a design review shows as a numbered review mark
+ (in the review colour, wherever the file is open), the tasks of a
+ thread show as a task mark that opens it, and a thread on an area
+ draws its area while it is open. Marks that would overlap show as one,
+ with a counter, and fan out on a click. Hovering a mark outlines its
+ layer."
+ (:require-macros [app.main.style :as stl])
+ (:require
+ [app.common.data.macros :as dm]
+ [app.common.geom.point :as gpt]
+ [app.common.math :as mth]
+ [app.main.data.comments :as dcmt]
+ [app.main.data.workspace.comments :as dwcm]
+ [app.main.data.workspace.highlight :as dwh]
+ [app.main.data.workspace.review :as dwrv]
+ [app.main.data.workspace.tasks :as dwtk]
+ [app.main.refs :as refs]
+ [app.main.store :as st]
+ [app.main.ui.comments :as cmt]
+ [app.main.ui.ds.product.review-marker :refer [review-marker*]]
+ [app.main.ui.workspace.review.common :as rvc]
+ [app.main.ui.workspace.review.tasks :as rvt]
+ [app.util.dom :as dom]
+ [app.util.i18n :refer [tr]]
+ [rumext.v2 :as mf]))
+
+(def ^:private panel-gap
+ "Screen distance between a mark and the panel it opens."
+ 20)
+
+(defn thread-position
+ "Where the mark of `thread` goes: the top right corner of its layer
+ while the layer is there, the spot it was written on otherwise."
+ [objects {:keys [anchor-type shape-id position]}]
+ (or (when (= :layer anchor-type)
+ (dwtk/anchor-position objects {:shape-id shape-id}))
+ position))
+
+(defn review-thread?
+ "Whether the review layer draws `thread` instead of the plain comment
+ bubbles: a thread of a design review, or one attached to a task."
+ [task-thread-ids thread]
+ (or (some? (:pull-request-id thread))
+ (contains? task-thread-ids (:id thread))))
+
+(defn- screen-style
+ "The style that puts a mark at canvas `position`, `offset` screen pixels
+ away from it. `ring` is where it starts to fan out from."
+ [{:keys [x y]} zoom offset ring]
+ #js {:left (dm/str (+ (* x zoom) (or (:x offset) 0)) "px")
+ :top (dm/str (+ (* y zoom) (or (:y offset) 0)) "px")
+ "--marker-ring-x" (some-> (:x ring) - (dm/str "px"))
+ "--marker-ring-y" (some-> (:y ring) - (dm/str "px"))})
+
+(def ^:private thread-width
+ "The width of an open comment thread: a task made from a thread opens
+ beside it."
+ 300)
+
+(defn panel-style
+ "The style that puts a panel beside the mark at canvas `position`,
+ `offset` screen pixels further right."
+ ([position zoom] (panel-style position zoom 0))
+ ([position zoom offset]
+ #js {:left (dm/str (+ (* (:x position) zoom) panel-gap offset) "px")
+ :top (dm/str (- (* (:y position) zoom) panel-gap) "px")}))
+
+(mf/defc area-box*
+ "The area a thread points at."
+ {::mf/private true}
+ [{:keys [area zoom]}]
+ (let [{:keys [x y width height]} area]
+ [:div {:class (stl/css :area-box)
+ :style #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")}}]))
+
+(mf/defc marker-slot*
+ "A mark on the canvas, centered on its point. Hovering it outlines the
+ layers `shape-ids` and shows `preview` unless it is open, like the bubbles
+ of the comments."
+ {::mf/private true}
+ [{:keys [position zoom offset ring is-open preview shape-ids children]}]
+ (let [hover* (mf/use-state false)
+ hover? (deref hover*)
+ on-enter (mf/use-fn #(reset! hover* true))
+ on-leave (mf/use-fn #(reset! hover* false))
+ shown? (and hover? (not is-open))]
+
+ ;; an effect, because a mark that fans out goes away under the pointer
+ ;; and never hears it leave
+ (mf/with-effect [hover? shape-ids]
+ (when hover?
+ (apply st/emit! (map dwh/highlight-shape shape-ids))
+ (fn []
+ (apply st/emit! (map dwh/dehighlight-shape shape-ids)))))
+
+ [:div {:class (stl/css-case :marker true
+ :is-expanded (some? ring)
+ :is-hovered shown?)
+ :style (screen-style position zoom offset ring)
+ :on-pointer-enter on-enter
+ :on-pointer-leave on-leave}
+ children
+ (when shown? preview)]))
+
+(def ^:private preview-limit
+ "How many items the card of a mark lists: a big group at a low zoom would
+ not fit the screen."
+ 5)
+
+(mf/defc thread-preview-item*
+ {::mf/private true}
+ [{:keys [thread]}]
+ (let [owner (mf/with-memo [thread]
+ (dcmt/get-owner thread))]
+ [:> cmt/comment-info* {:item thread :profile owner}]))
+
+(mf/defc marks-preview*
+ "The small card of `marks`: their comments and tasks, oldest first."
+ {::mf/private true}
+ [{:keys [marks]}]
+ (let [items (mf/with-memo [marks]
+ (->> (sort-by :seqn marks)
+ (mapcat (fn [{:keys [thread tasks]}]
+ (if (some? thread)
+ [{:thread thread}]
+ (map (fn [task] {:task task}) tasks))))
+ (vec)))
+ hidden (- (count items) preview-limit)]
+ [:> cmt/preview-card* {}
+ (for [{:keys [thread task]} (take preview-limit items)]
+ (if (some? thread)
+ [:> thread-preview-item* {:key (dm/str (:id thread)) :thread thread}]
+ [:> rvt/task-preview* {:key (dm/str (:id task)) :task task}]))
+ (when (pos? hidden)
+ [:span {:class (stl/css :preview-more)}
+ (tr "workspace.review.marker.more" hidden)])]))
+
+(mf/defc thread-marker*
+ "The mark of a thread. `offset` and `ring` place it when it is fanned out."
+ {::mf/private true}
+ [{:keys [mark zoom offset ring is-open]}]
+ (let [thread (:thread mark)
+ marks (mf/with-memo [mark] [mark])
+ on-click
+ (mf/use-fn
+ (mf/deps thread)
+ (fn [event]
+ (dom/stop-propagation event)
+ (st/emit! (dwtk/close-task)
+ (dcmt/open-thread thread))))]
+ [:> marker-slot* {:position (:position mark)
+ :zoom zoom
+ :offset offset
+ :ring ring
+ :is-open is-open
+ :shape-ids (:shape-ids mark)
+ :preview (mf/html [:> marks-preview* {:marks marks}])}
+ [:> review-marker* {:label (str (:seqn thread))
+ :state (cond is-open "active"
+ (:is-resolved thread) "resolved"
+ :else "default")
+ :aria-label (tr "workspace.review.marker.comment" (:seqn thread))
+ :on-click on-click}]]))
+
+(mf/defc task-marker*
+ "The mark of its `tasks`: the tasks of a thread on the same layer, which
+ open as that thread. `offset` and `ring` place it when it is fanned
+ out."
+ {::mf/private true}
+ [{:keys [mark zoom offset ring is-open]}]
+ (let [tasks (:tasks mark)
+ task (first tasks)
+ many? (some? (next tasks))
+ marks (mf/with-memo [mark] [mark])
+ on-click
+ (mf/use-fn
+ (mf/deps task)
+ (fn [event]
+ (dom/stop-propagation event)
+ (st/emit! (dwtk/open-task (:id task)))))]
+ [:> marker-slot* {:position (:position mark)
+ :zoom zoom
+ :offset offset
+ :ring ring
+ :is-open is-open
+ :shape-ids (:shape-ids mark)
+ :preview (mf/html [:> marks-preview* {:marks marks}])}
+ [:> review-marker* {:type "task"
+ :state (cond is-open "active"
+ (some dwtk/lost? tasks) "lost"
+ :else "default")
+ :counter (when many? (count tasks))
+ :aria-label (if many?
+ (tr "workspace.review.marker.tasks" (count tasks))
+ (tr "workspace.review.marker.task" (:title task)))
+ :on-click on-click}]]))
+
+(mf/defc mark-marker*
+ {::mf/private true}
+ [{:keys [mark zoom offset ring is-open]}]
+ [:> (if (some? (:thread mark)) thread-marker* task-marker*)
+ {:mark mark :zoom zoom :offset offset :ring ring :is-open is-open}])
+
+(defn- cluster-look
+ "What the one mark of `marks` shows: the square of the tasks when it holds
+ any, as they ask for work, and how many items it holds."
+ [marks]
+ (let [tasks (into [] (mapcat :tasks) marks)
+ threads (into [] (keep :thread) marks)
+ total (+ (count tasks) (count threads))]
+ {:type (if (seq tasks) "task" "comment")
+ :state (cond (some dwtk/lost? tasks) "lost"
+ (and (empty? tasks) (every? :is-resolved threads)) "resolved"
+ :else "default")
+ :counter total
+ :aria-label (cond (empty? threads) (tr "workspace.review.marker.tasks" total)
+ (empty? tasks) (tr "workspace.review.marker.comments" total)
+ :else (tr "workspace.review.marker.items" total))}))
+
+(mf/defc mark-cluster*
+ "The one mark of `marks`, which overlap: a click fans them out so the
+ user picks one."
+ {::mf/private true}
+ [{:keys [marks zoom is-open]}]
+ (let [look (mf/with-memo [marks] (cluster-look marks))
+ mark-ids (mf/with-memo [marks] (into #{} (map :id) marks))
+ shape-ids (mf/with-memo [marks] (into #{} (mapcat :shape-ids) marks))
+ on-click
+ (mf/use-fn
+ (mf/deps mark-ids)
+ (fn [event]
+ (dom/stop-propagation event)
+ (st/emit! (dwtk/close-task)
+ (dwtk/cancel-new-task)
+ (dcmt/expand-comment-group mark-ids))))]
+ [:> marker-slot* {:position (cmt/expanded-group-center marks)
+ :zoom zoom
+ :is-open is-open
+ :shape-ids shape-ids
+ :preview (mf/html [:> marks-preview* {:marks marks}])}
+ [:> review-marker* {:type (:type look)
+ :state (if is-open "active" (:state look))
+ :counter (:counter look)
+ :aria-label (:aria-label look)
+ :on-click on-click}]]))
+
+(mf/defc cluster-ghost*
+ "What stays at the center of `marks` while they are fanned out."
+ {::mf/private true}
+ [{:keys [marks zoom]}]
+ (let [look (mf/with-memo [marks] (cluster-look marks))]
+ [:div {:class (stl/css :marker :is-ghost)
+ :style (screen-style (cmt/expanded-group-center marks) zoom nil nil)}
+ [:> review-marker* {:type (:type look)
+ :state "ghost"
+ :counter (:counter look)
+ :aria-hidden true
+ :aria-label (:aria-label look)
+ :tab-index -1}]]))
+
+(defn- group-task-marks
+ "The tasks of a page by mark: one per thread and layer, as the tasks of
+ a thread all open it."
+ [tasks]
+ (->> (group-by (juxt :thread-id :shape-id) tasks)
+ (vals)
+ (mapv #(vec (sort-by :created-at %)))))
+
+(defn- thread-mark
+ [objects {:keys [id created-at anchor-type shape-id] :as thread}]
+ (when-let [position (thread-position objects thread)]
+ {:id id
+ :created-at created-at
+ :position (gpt/point position)
+ :thread thread
+ :shape-ids (when (= :layer anchor-type)
+ (some-> (dwtk/anchor-shape objects {:shape-id shape-id}) :id vector))}))
+
+(defn- task-mark
+ [objects tasks]
+ (let [{:keys [id created-at] :as task} (first tasks)]
+ (when-let [position (dwtk/anchor-position objects task)]
+ {:id id
+ :created-at created-at
+ :position (gpt/point position)
+ :tasks tasks
+ :shape-ids (some-> (dwtk/anchor-shape objects task) :id vector)})))
+
+(defn mark-clusters
+ "The marks of `threads` and `tasks` at `zoom`, grouped when they would
+ overlap: a vector of marks for each spot of the canvas. `:seqn` keeps them
+ oldest first, whatever their kind."
+ [objects zoom threads tasks]
+ (->> (concat (keep #(thread-mark objects %) threads)
+ (keep #(task-mark objects %) (group-task-marks tasks)))
+ (sort-by :created-at)
+ (map-indexed (fn [index mark] (assoc mark :seqn index)))
+ (dwcm/group-bubbles zoom)))
+
+(defn- mark-open?
+ "Whether `mark` is open now: its thread, a task of it, or the thread of one."
+ [{:keys [thread tasks]} open-task open-id]
+ (or (and (some? thread) (= open-id (:id thread)))
+ (boolean
+ (some (fn [{:keys [id thread-id]}]
+ (or (= id (:id open-task))
+ (= open-id thread-id)))
+ tasks))))
+
+(mf/defc review-markers*
+ "The marks of the page `page-id`: the threads the review layer draws
+ (`threads`) and the open tasks, the area of the open thread or draft,
+ and the form of the new task. An open task shows as its thread."
+ [{:keys [threads page-id zoom open-id draft expanded]}]
+ (let [objects (mf/deref refs/workspace-page-objects)
+ tasks (mf/deref refs/tasks)
+ tasks-local (mf/deref refs/tasks-local)
+ open-task (some->> (:open tasks-local) (get tasks))
+ new-task (:new tasks-local)
+
+ task-thread-ids
+ (mf/with-memo [tasks]
+ (into #{} (keep :thread-id) (vals tasks)))
+
+ clusters
+ (mf/with-memo [objects threads tasks task-thread-ids page-id zoom]
+ (mark-clusters objects zoom
+ (remove #(contains? task-thread-ids (:id %)) threads)
+ (->> (vals tasks)
+ (remove dwtk/history?)
+ (remove dwtk/closed?)
+ (filter #(= page-id (:page-id %))))))
+
+ open-thread (some #(when (= open-id (:id %)) %) threads)]
+
+ [:*
+ ;; the area of the thread open now, or of the draft being written
+ (when (= :area (:anchor-type open-thread))
+ [:> area-box* {:area (:area open-thread) :zoom zoom}])
+ (when (= :area (get-in draft [:anchor :type]))
+ [:> area-box* {:area (get-in draft [:anchor :area]) :zoom zoom}])
+
+ (for [marks clusters]
+ (let [mark (first marks)
+ cluster? (some? (next marks))
+ expanded? (and cluster?
+ (= expanded (into #{} (map :id) marks)))]
+ (cond
+ expanded?
+ [:* {:key (dm/str (:id mark))}
+ [:> cluster-ghost* {:marks marks :zoom zoom}]
+ (for [[mark offset ring] (cmt/expanded-group-offsets zoom marks)]
+ [:> mark-marker* {:key (dm/str (:id mark))
+ :mark mark
+ :zoom zoom
+ :offset offset
+ :ring ring
+ :is-open false}])]
+
+ cluster?
+ [:> mark-cluster* {:key (dm/str (:id mark))
+ :marks marks
+ :zoom zoom
+ :is-open (some #(mark-open? % open-task open-id) marks)}]
+
+ :else
+ [:> mark-marker* {:key (dm/str (:id mark))
+ :mark mark
+ :zoom zoom
+ :is-open (mark-open? mark open-task open-id)}])))
+
+ (when (and (some? new-task) (= page-id (:page-id new-task)))
+ (when-let [position (or (dwtk/anchor-position objects new-task)
+ (:position new-task))]
+ [:> rvt/new-task-form* {:key (dm/str (:shape-id new-task) (:comment-id new-task))
+ :params new-task
+ :style (panel-style position zoom
+ (if (some? (:thread-id new-task))
+ thread-width
+ 0))}]))]))
+
+(mf/defc area-layer*
+ "The area tool of the review mode, over the whole comments layer: drag on
+ the canvas to comment on a rectangle."
+ [{:keys [vbox zoom]}]
+ (let [start* (mf/use-state nil)
+ start (deref start*)
+ current* (mf/use-state nil)
+ current (deref current*)
+
+ on-down
+ (mf/use-fn
+ (mf/deps vbox zoom)
+ (fn [event]
+ (dom/stop-propagation event)
+ (dom/capture-pointer event)
+ (let [pt (rvc/event->canvas event vbox zoom)]
+ (reset! start* pt)
+ (reset! current* pt))))
+
+ on-move
+ (mf/use-fn
+ (mf/deps vbox zoom start)
+ (fn [event]
+ (when (some? start)
+ (reset! current* (rvc/event->canvas event vbox zoom)))))
+
+ on-up
+ (mf/use-fn
+ (mf/deps start current)
+ (fn [event]
+ (dom/release-pointer event)
+ (when (and (some? start) (some? current))
+ (let [x (min (:x start) (:x current))
+ y (min (:y start) (:y current))
+ w (mth/abs (- (:x current) (:x start)))
+ h (mth/abs (- (:y current) (:y start)))]
+ ;; a click, not a drag, draws nothing
+ (when (and (> (* w zoom) 4) (> (* h zoom) 4))
+ (st/emit! (dwrv/create-area-draft {:x x :y y :width w :height h})))))
+ (reset! start* nil)
+ (reset! current* nil)))]
+
+ [:div {:class (stl/css :area-drawer)
+ :on-pointer-down on-down
+ :on-pointer-move on-move
+ :on-pointer-up on-up
+ :on-click dom/stop-propagation}
+ (when (and (some? start) (some? current))
+ (let [x (min (:x start) (:x current))
+ y (min (:y start) (:y current))]
+ [:div {:class (stl/css :area-box)
+ :style #js {:left (dm/str (* (- x (:x vbox)) zoom) "px")
+ :top (dm/str (* (- y (:y vbox)) zoom) "px")
+ :width (dm/str (* (mth/abs (- (:x current) (:x start))) zoom) "px")
+ :height (dm/str (* (mth/abs (- (:y current) (:y start))) zoom) "px")}}]))]))
diff --git a/frontend/src/app/main/ui/workspace/review/markers.scss b/frontend/src/app/main/ui/workspace/review/markers.scss
new file mode 100644
index 0000000000..8b4d4da146
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/review/markers.scss
@@ -0,0 +1,89 @@
+// 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 *;
+
+.marker {
+ position: absolute;
+
+ // the mark is centered on its point
+ transform: translate(-50%, -50%);
+ pointer-events: auto;
+
+ // the card of a hovered mark goes over the other marks
+ &.is-hovered {
+ z-index: var(--z-index-panels);
+ }
+
+ // what stays under marks that fan out
+ &.is-ghost {
+ opacity: 0.6;
+ pointer-events: none;
+ animation: marker-ghost-appear 0.18s ease-out;
+ }
+
+ &.is-expanded {
+ // TODO: no DS z-index token for 2.
+ z-index: 2;
+ animation: marker-fan-out 0.18s ease-out;
+ }
+
+ &.is-expanded.is-hovered {
+ z-index: var(--z-index-panels);
+ }
+}
+
+// the marks start under the pointer that fanned them out: they ignore it until
+// they arrive, or the first one would take the hover and show its card
+@keyframes marker-fan-out {
+ 0% {
+ translate: var(--marker-ring-x, 0) var(--marker-ring-y, 0);
+ opacity: 0;
+ pointer-events: none;
+ }
+
+ 99% {
+ pointer-events: none;
+ }
+
+ 100% {
+ translate: 0 0;
+ opacity: 1;
+ }
+}
+
+@keyframes marker-ghost-appear {
+ from {
+ opacity: 0;
+ }
+
+ to {
+ opacity: 0.6;
+ }
+}
+
+.preview-more {
+ color: var(--color-foreground-secondary);
+}
+
+// the area a thread points at: the review blue at a tenth of its strength,
+// with a dashed outline
+.area-box {
+ position: absolute;
+ border: $b-1 dashed var(--color-accent-info);
+ border-radius: $br-4;
+
+ // TODO: no DS token for this tint of the review blue.
+ background-color: color-mix(in srgb, var(--color-accent-info) 10%, transparent);
+ pointer-events: none;
+}
+
+.area-drawer {
+ position: absolute;
+ inset: 0;
+ cursor: crosshair;
+ pointer-events: auto;
+}
diff --git a/frontend/src/app/main/ui/workspace/review/overlays.cljs b/frontend/src/app/main/ui/workspace/review/overlays.cljs
new file mode 100644
index 0000000000..24f1da1a0e
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/review/overlays.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.review.overlays
+ "What the review mode and the tasks draw over the canvas: the changes of
+ the branch since the review opened, with a bar to go through them, and
+ the layer picker that links a task to another layer."
+ (:require-macros [app.main.style :as stl])
+ (:require
+ [app.common.data :as d]
+ [app.common.data.macros :as dm]
+ [app.common.files.helpers :as cfh]
+ [app.common.time :as ct]
+ [app.main.data.workspace.review :as dwrv]
+ [app.main.data.workspace.tasks :as dwtk]
+ [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.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.main.ui.workspace.review.common :as rvc]
+ [app.util.dom :as dom]
+ [app.util.i18n :refer [tr]]
+ [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")}))
+
+;; --- 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
+ :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))]]))
+
+(mf/defc changes-navigator*
+ "The bar that goes through the changes shown on the canvas."
+ {::mf/private true}
+ [{:keys [entry index total]}]
+ (let [profiles (mf/deref refs/profiles)
+
+ on-prev (mf/use-fn (mf/deps index) #(st/emit! (dwrv/show-change (dec index))))
+ on-next (mf/use-fn (mf/deps index) #(st/emit! (dwrv/show-change (inc index))))
+ 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}]
+ (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)}]
+ [:> button* {:variant "ghost" :on-click on-back}
+ (tr "workspace.review.changes.back")]
+ [:> icon-button* {:variant "ghost"
+ :icon i/close
+ :aria-label (tr "labels.close")
+ :on-click on-close}]]))
+
+(defn- use-change-entries
+ "The changes of the activity the change filter keeps."
+ []
+ (let [activity (mf/deref refs/review-activity)
+ local (mf/deref refs/review-local)
+ kind (get local :change-filter :all)]
+ (mf/with-memo [activity kind]
+ (cond->> (:entries activity)
+ (not= :all kind) (filterv #(= kind (:kind %)))))))
+
+(mf/defc change-boxes*
+ {::mf/private true}
+ [{:keys [entries zoom page-id index]}]
+ (let [objects (mf/deref refs/workspace-page-objects)
+ entries (mf/with-memo [entries]
+ (into [] d/xf:add-index entries))]
+ [:*
+ (for [entry entries]
+ (let [shape (get objects (:id entry))]
+ (when (and (= page-id (:page-id entry))
+ (some? shape)
+ (not (cfh/root? shape)))
+ [:> change-box* {:key (dm/str (:id entry))
+ :entry entry
+ :shape shape
+ :zoom zoom
+ :is-active (= (::d/index entry) index)}])))]))
+
+;; --- Picking the layer of a task
+
+(mf/defc relink-overlay*
+ "Pick the layer a task points at from now on, on the canvas or in the
+ layers panel. Escape or Cancel leaves the task as it is."
+ {::mf/private true}
+ [{:keys [task vbox zoom]}]
+ (let [objects (mf/deref refs/workspace-page-objects)
+ selected (mf/deref refs/selected-shapes)
+ hover* (mf/use-state nil)
+ hover (deref hover*)
+ start (mf/use-ref selected)
+
+ on-move
+ (mf/use-fn
+ (mf/deps objects vbox zoom)
+ (fn [event]
+ (reset! hover* (dwtk/shape-at-position objects (rvc/event->canvas event vbox zoom)))))
+
+ on-click
+ (mf/use-fn
+ (mf/deps objects vbox zoom)
+ (fn [event]
+ (dom/stop-propagation event)
+ (when-let [shape (dwtk/shape-at-position objects (rvc/event->canvas event vbox zoom))]
+ (st/emit! (dwtk/relink-task shape)))))
+
+ on-cancel
+ (mf/use-fn #(st/emit! (dwtk/cancel-relink)))]
+
+ ;; a layer picked in the layers panel links the task too
+ (mf/with-effect [selected]
+ (when (and (not= selected (mf/ref-val start))
+ (= 1 (count selected)))
+ (when-let [shape (get objects (first selected))]
+ (st/emit! (dwtk/relink-task shape)))))
+
+ (mf/with-effect []
+ (let [on-key (fn [event]
+ (when (kbd/esc? event)
+ (st/emit! (dwtk/cancel-relink))))]
+ (.addEventListener js/document "keydown" on-key)
+ #(.removeEventListener js/document "keydown" on-key)))
+
+ [:*
+ [:div {:class (stl/css :picker)
+ :on-pointer-move on-move
+ :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))]]])]
+ [:div {:class (stl/css :picker-banner)
+ :role "status"}
+ [:> icon* {:icon-id i/view-as-list :size "s" :class (stl/css :picker-icon)}]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :picker-label)}
+ (tr "workspace.tasks.relink.pick")]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :picker-title)}
+ (:title task)]
+ [:> button* {:variant "secondary" :on-click on-cancel}
+ (tr "labels.cancel")]]]))
+
+(mf/defc review-overlays*
+ [{:keys [vbox vport zoom page-id]}]
+ (let [local (mf/deref refs/review-local)
+ tasks-local (mf/deref refs/tasks-local)
+ tasks (mf/deref refs/tasks)
+ show-changes (:show-changes local)
+ index (:index show-changes 0)
+ entries (use-change-entries)
+ relink (some->> (:relink tasks-local) (get tasks))]
+
+ (when (or (some? show-changes) (some? relink))
+ [:div {:class (stl/css :overlays)
+ :style #js {:width (dm/str (:width vport) "px")
+ :height (dm/str (:height vport) "px")}}
+ (when (some? show-changes)
+ [:*
+ [:div {:class (stl/css :threads)
+ :style #js {:transform (dm/fmt "translate(%px, %px)"
+ (* (- (:x vbox)) zoom)
+ (* (- (:y vbox)) zoom))}}
+ [:> change-boxes* {:entries entries
+ :zoom zoom
+ :page-id page-id
+ :index index}]]
+ [:> changes-navigator* {:entry (get entries index)
+ :index index
+ :total (count entries)}]])
+ (when (some? relink)
+ [:> relink-overlay* {:task relink :vbox vbox :zoom zoom}])])))
diff --git a/frontend/src/app/main/ui/workspace/review/overlays.scss b/frontend/src/app/main/ui/workspace/review/overlays.scss
new file mode 100644
index 0000000000..7548f686ad
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/review/overlays.scss
@@ -0,0 +1,150 @@
+// 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/typography.scss" as *;
+
+.overlays {
+ position: absolute;
+ inset-block-start: 0;
+ inset-inline-start: 0;
+ overflow: hidden;
+ pointer-events: none;
+}
+
+.threads {
+ position: absolute;
+}
+
+// --- Changes
+
+.change-box {
+ --change-color: var(--color-accent-info);
+
+ position: absolute;
+ border: $b-1 dashed var(--change-color);
+ pointer-events: none;
+
+ &.is-added {
+ --change-color: var(--color-accent-success);
+ }
+
+ &.is-active {
+ border: $b-2 solid var(--change-color);
+ border-radius: $br-4;
+ }
+}
+
+.change-tag {
+ --change-tag-bg-color: var(--color-background-info);
+ --change-tag-fg-color: var(--color-accent-info);
+
+ @include use-typography("body-small");
+
+ position: absolute;
+ inset-block-end: 100%;
+ inset-inline-end: 0;
+ margin-block-end: var(--sp-xxs);
+ padding: 0 var(--sp-xs);
+ 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-fg-color: var(--color-background-primary);
+
+ inset-inline: 0 auto;
+ }
+
+ &.is-pick {
+ --change-tag-bg-color: var(--color-accent-primary);
+ }
+}
+
+// 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
+.navigator {
+ 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%);
+ display: flex;
+ align-items: center;
+ gap: var(--sp-s);
+ padding: var(--sp-xs) var(--sp-s);
+ border: $b-1 solid var(--color-accent-info);
+ border-radius: $br-8;
+ background-color: var(--color-background-primary);
+ pointer-events: auto;
+}
+
+.navigator-count {
+ color: var(--color-foreground-secondary);
+ white-space: nowrap;
+}
+
+.navigator-text {
+ color: var(--color-foreground-secondary);
+ white-space: nowrap;
+}
+
+.navigator-name {
+ color: var(--color-foreground-primary);
+}
+
+.navigator-separator {
+ align-self: stretch;
+ border-inline-start: $b-1 solid var(--color-background-quaternary);
+}
+
+// --- Picking the layer of a task
+
+.picker {
+ position: absolute;
+ inset: 0;
+ cursor: crosshair;
+ pointer-events: auto;
+}
+
+.picker-banner {
+ position: absolute;
+
+ // below the toolbar, which sits at the top center of the canvas
+ inset-block-start: px2rem(120);
+ inset-inline-start: 50%;
+ transform: translateX(-50%);
+ display: flex;
+ align-items: center;
+ gap: var(--sp-s);
+ padding: var(--sp-xs) var(--sp-xs) var(--sp-xs) var(--sp-m);
+ border: $b-1 solid var(--color-accent-primary);
+ border-radius: $br-8;
+ background-color: var(--color-background-primary);
+ pointer-events: auto;
+}
+
+.picker-icon {
+ color: var(--color-foreground-secondary);
+}
+
+.picker-label {
+ color: var(--color-foreground-secondary);
+ white-space: nowrap;
+}
+
+.picker-title {
+ color: var(--color-foreground-primary);
+ white-space: nowrap;
+}
diff --git a/frontend/src/app/main/ui/workspace/review/panel.cljs b/frontend/src/app/main/ui/workspace/review/panel.cljs
new file mode 100644
index 0000000000..254cf955a5
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/review/panel.cljs
@@ -0,0 +1,295 @@
+;; 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.panel
+ "The right panel of the review mode and the tasks tab of the comments
+ panel: the comments of the review, grouped by board, and its tasks."
+ (:require-macros [app.main.style :as stl])
+ (:require
+ [app.common.data :as d]
+ [app.common.data.macros :as dm]
+ [app.common.files.helpers :as cfh]
+ [app.common.time :as ct]
+ [app.main.data.comments :as dcmt]
+ [app.main.data.workspace.comments :as dwcm]
+ [app.main.data.workspace.review :as dwrv]
+ [app.main.data.workspace.tasks :as dwtk]
+ [app.main.refs :as refs]
+ [app.main.store :as st]
+ [app.main.ui.comments :as cmt]
+ [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.layout.tab-switcher :refer [tab-switcher*]]
+ [app.main.ui.ds.product.avatar :refer [avatar*]]
+ [app.main.ui.ds.product.comment-card :refer [comment-card*]]
+ [app.main.ui.ds.product.empty-state :refer [empty-state*]]
+ [app.main.ui.ds.product.layer-chip :refer [layer-chip*]]
+ [app.main.ui.workspace.review.common :as rvc]
+ [app.main.ui.workspace.review.filter-menu :refer [filter-menu*]]
+ [app.main.ui.workspace.review.tasks :as rvt]
+ [app.main.ui.workspace.sidebar.pull-requests :as prui :refer [pr-state-badge*]]
+ [app.util.dom :as dom]
+ [app.util.i18n :refer [tr]]
+ [rumext.v2 :as mf]))
+
+;; --- Comments
+
+(mf/defc thread-card*
+ "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))
+ review? (some? (:pull-request-id thread))
+
+ on-click
+ (mf/use-fn
+ (mf/deps thread)
+ (fn [event]
+ (dom/stop-propagation event)
+ (st/emit! (dwcm/navigate-to-comment thread))))]
+
+ [:> comment-card* {:location (tr "workspace.review.text-and-detail"
+ (tr "workspace.review.comment-number" (:seqn thread))
+ (rvc/board-name objects (:frame-id thread)))
+ :author (:fullname owner)
+ :time (ct/timeago (:modified-at thread))
+ :replies (case replies
+ 0 (tr "workspace.review.comments.no-replies")
+ 1 (tr "workspace.review.comments.one-reply")
+ (tr "workspace.review.comments.replies" replies))
+ :avatar (mf/html [:> avatar* {:profile owner :variant "M"}])
+ :anchor (mf/html
+ [:> layer-chip* {:label (rvc/thread-anchor-label objects thread)
+ :icon (rvc/thread-anchor-icon thread)}])
+ :review (when (and show-review review?)
+ (or (:pull-request-title thread)
+ (tr "workspace.review.design-review")))
+ :is-review review?
+ :is-open is-open
+ :is-resolved (:is-resolved thread)
+ :on-click on-click}
+ [:> cmt/comment-content* {:content (:content thread)}]]))
+
+(mf/defc comments-tab*
+ "The comment threads `threads`: filters and the cards grouped by board
+ (by page and board with `show-page`). With `show-review`, each card names
+ the design review it belongs to."
+ [{:keys [threads show-page show-review]}]
+ (let [profile (mf/deref refs/profile)
+ clocal (mf/deref refs/comments-local)
+ data (mf/deref refs/workspace-data)
+ mode (get clocal :mode :all)
+
+ ;; the same filters as the marks on the canvas
+ shown (mf/with-memo [threads clocal profile]
+ (->> (dcmt/apply-filters clocal profile threads)
+ (sort-by :seqn)))
+
+ groups (mf/with-memo [shown]
+ (->> shown
+ (group-by (juxt :page-id :frame-id))
+ (sort-by (fn [[_ items]] (:seqn (first items))))))
+
+ options [{:id :all :label (tr "labels.show-all-comments")}
+ {:id :yours :label (tr "labels.show-your-comments")}
+ {:id :mentions :label (tr "labels.show-mentions")}]
+
+ on-select
+ (mf/use-fn #(st/emit! (dcmt/update-filters {:mode %})))
+
+ on-toggle
+ (mf/use-fn
+ (mf/deps clocal)
+ (fn [_]
+ (st/emit! (dcmt/update-filters {:show (if (= :pending (:show clocal)) :all :pending)}))))]
+
+ [:div {:class (stl/css :tab-content)}
+ [:> filter-menu* {:options options
+ :selected mode
+ :toggle-label (tr "labels.hide-resolved-comments")
+ :is-toggled (= :pending (:show clocal))
+ :on-select on-select
+ :on-toggle on-toggle}]
+
+ (if (empty? groups)
+ [:div {:class (stl/css :empty)}
+ [:> empty-state* {:icon i/comments
+ :text (tr "workspace.review.comments.empty")}]]
+ [:div {:class (stl/css :groups)}
+ (for [[[page-id frame-id] items] groups]
+ (let [objects (dm/get-in data [:pages-index page-id :objects])]
+ [:section {:key (dm/str page-id frame-id) :class (stl/css :group)}
+ [:> heading* {:level 3 :typography t/body-small :class (stl/css :group-title)}
+ (if show-page
+ (tr "workspace.review.text-and-detail"
+ (:page-name (first items))
+ (rvc/board-name objects frame-id))
+ (rvc/board-name objects frame-id))]
+ (for [thread items]
+ [:> thread-card* {:key (dm/str (:id thread))
+ :thread thread
+ :objects objects
+ :show-review show-review
+ :is-open (= (:id thread) (:open clocal))}])]))])]))
+
+;; --- Tasks
+
+(mf/defc tasks-tab*
+ "The tasks of the review (`pull-request-id`), or of the file when there
+ is none: its progress, filters and list. With `show-review`, each task
+ names the design review it belongs to."
+ [{:keys [tasks pull-request-id grouped show-review]}]
+ (let [profile (mf/deref refs/profile)
+ local (mf/deref refs/review-local)
+ selected (mf/deref refs/selected-shapes)
+ objects (mf/deref refs/workspace-page-objects)
+ page-id (mf/deref refs/current-page-id)
+ kind (get local :task-filter :all)
+ hide? (true? (:hide-closed-tasks local))
+
+ shown (mf/with-memo [tasks kind hide? profile]
+ (cond->> (rvt/filter-tasks tasks kind (:id profile))
+ hide? (remove dwtk/closed?)))
+
+ options [{:id :all :label (tr "workspace.tasks.view.all")}
+ {:id :mine :label (tr "workspace.tasks.view.mine")}
+ {:id :open :label (tr "workspace.tasks.view.open")}
+ {:id :to-verify :label (tr "workspace.tasks.view.to-verify")}]
+
+ on-select
+ (mf/use-fn #(st/emit! (dwrv/set-task-filter %)))
+
+ on-toggle
+ (mf/use-fn #(st/emit! (dwrv/toggle-hide-closed-tasks)))
+
+ on-to-verify
+ (mf/use-fn #(st/emit! (dwrv/set-task-filter :to-verify)))
+
+ on-new-task
+ (mf/use-fn
+ (mf/deps selected objects page-id pull-request-id)
+ (fn [_]
+ (let [shape (some->> (first selected) (get objects))]
+ (if (some? shape)
+ (st/emit! (dwtk/start-new-task
+ {:page-id page-id
+ :frame-id (if (cfh/frame-shape? shape) (:id shape) (:frame-id shape))
+ :shape-id (:id shape)
+ :pull-request-id pull-request-id}))
+ ;; no layer chosen yet: the task tool picks it on the canvas
+ (st/emit! (dwrv/set-tool :task))))))]
+
+ [:div {:class (stl/css :tab-content)}
+ [:> rvt/progress* {:tasks tasks :on-to-verify on-to-verify}]
+
+ [:> filter-menu* {:options options
+ :selected kind
+ :toggle-label (tr "workspace.tasks.view.hide-closed")
+ :is-toggled hide?
+ :on-select on-select
+ :on-toggle on-toggle}]
+
+ (cond
+ (empty? shown)
+ [:div {:class (stl/css :empty)}
+ [:> empty-state* {:icon i/view-as-list
+ :text (tr "workspace.tasks.empty")}]]
+
+ grouped
+ [:div {:class (stl/css :groups)}
+ (for [{:keys [id title tasks]} (rvt/group-tasks shown)]
+ [:section {:key (dm/str id) :class (stl/css :group)}
+ [:> heading* {:level 3 :typography t/body-small :class (stl/css :group-title)}
+ (if (= :other id)
+ (tr "workspace.tasks.group.other")
+ (tr "workspace.tasks.group.review" title))]
+ [:> rvt/task-list* {:tasks tasks :show-review show-review}]])]
+
+ :else
+ [:> rvt/task-list* {:tasks shown :show-review show-review}])
+
+ [:> button* {:variant "secondary"
+ :icon i/add
+ :class (stl/css :new-task)
+ :on-click on-new-task}
+ (tr "workspace.tasks.new-task")]]))
+
+;; --- The review panel
+
+(mf/defc review-header*
+ {::mf/private true}
+ [{:keys [pr]}]
+ (let [[approvals total] (prui/current-approvals pr)
+ route (tr "workspace.review.route" (:branch-name pr) (tr "workspace.branches.main"))]
+ [:div {:class (stl/css :review-header)}
+ [:div {:class (stl/css :review-title-row)}
+ [:> heading* {:level 2 :typography t/body-large :class (stl/css :review-title)}
+ (:title pr)]
+ [:> pr-state-badge* {:pr pr}]]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :review-route)}
+ (if (pos? total)
+ (tr "workspace.review.text-and-detail" route (tr "workspace.review.approved-of" approvals total))
+ route)]]))
+
+(mf/defc review-panel*
+ "The right panel of the review mode: the inspect of the selection
+ (`inspect`, the element the workspace renders for it), and the
+ comments and tasks of the review."
+ [{:keys [inspect]}]
+ (let [preview (mf/deref refs/pull-request-preview)
+ pr (:info preview)
+ pr-id (:pr-id preview)
+ threads* (mf/deref refs/threads)
+ tasks* (mf/deref refs/tasks)
+ local (mf/deref refs/review-local)
+ ;; the review opens on the inspect of the selection
+ tab (get local :panel-tab :inspect)
+
+ threads (mf/with-memo [threads* pr-id]
+ (filterv #(= pr-id (:pull-request-id %)) (vals threads*)))
+ tasks (mf/with-memo [tasks* pr-id]
+ (vec (dwtk/sort-tasks (dwtk/review-tasks (vals tasks*) pr-id))))
+
+ tabs (mf/with-memo [threads tasks]
+ [{:id "inspect"
+ :label (tr "workspace.options.inspect")}
+ {:id "comments"
+ :label (tr "workspace.review.tab.comments" (count threads))}
+ {:id "tasks"
+ :label (tr "workspace.review.tab.tasks" (count tasks))}])
+
+ ;; inspecting means picking layers: the move tool takes the clicks
+ on-tab (mf/use-fn
+ (fn [id]
+ (let [tab (keyword id)]
+ (st/emit! (dwrv/set-panel-tab tab))
+ (when (= tab :inspect)
+ (st/emit! (dwrv/set-tool :move))))))]
+
+ (mf/with-effect [pr-id]
+ (st/emit! (dwtk/fetch-tasks)))
+
+ (when (some? pr)
+ [:div {:class (stl/css :review-panel)}
+ [:> review-header* {:pr pr}]
+ ;; the inspect scrolls on its own: its tab only gives it the space
+ [:> tab-switcher* {:tabs tabs
+ :selected (name tab)
+ :on-change on-tab
+ :scrollable-panel (not= tab :inspect)
+ :class (stl/css :review-tabs)}
+ (if (= tab :inspect)
+ [:div {:class (stl/css :inspect-tab)} inspect]
+ [:div {:class (stl/css :review-tab-content)}
+ (if (= tab :tasks)
+ [:> tasks-tab* {:tasks tasks :pull-request-id pr-id}]
+ [:> comments-tab* {:threads threads}])])]])))
diff --git a/frontend/src/app/main/ui/workspace/review/panel.scss b/frontend/src/app/main/ui/workspace/review/panel.scss
new file mode 100644
index 0000000000..36e4acc157
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/review/panel.scss
@@ -0,0 +1,104 @@
+// 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
+
+.review-panel {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-m);
+ block-size: 100%;
+ min-block-size: 0;
+ padding-block-start: var(--sp-m);
+}
+
+.review-header {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-xs);
+ padding-inline: var(--sp-m);
+}
+
+.review-title-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--sp-s);
+}
+
+.review-title {
+ min-inline-size: 0;
+ margin: 0;
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ color: var(--color-foreground-primary);
+}
+
+.review-route {
+ color: var(--color-foreground-secondary);
+}
+
+.review-tabs {
+ --tabs-nav-padding-inline-start: var(--sp-m);
+ --tabs-nav-padding-inline-end: var(--sp-m);
+
+ flex: 1;
+ min-block-size: 0;
+}
+
+// the inspect of the workspace, sized to the room the tab leaves it and with
+// the margins it has there: a review is read-only, but it is no narrower
+.inspect-tab {
+ --options-available-height: 100%;
+ --inspect-block-size: 100%;
+ --inspect-content-display: flex;
+ --inspect-tab-block-size: auto;
+ --options-read-only-padding: var(--sp-s) 0 0;
+
+ block-size: 100%;
+ min-block-size: 0;
+}
+
+.review-tab-content {
+ padding-inline: var(--sp-m);
+}
+
+.tab-content {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-m);
+ padding-block: var(--sp-m);
+}
+
+.groups {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-l);
+}
+
+.group {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+}
+
+.group-title {
+ margin: 0;
+ color: var(--color-foreground-secondary);
+
+ // TODO: No exact DS typography match found.
+ // Closest match: headline-small (weight 400 vs 500, line-height 1.3 vs 1.2).
+ text-transform: uppercase;
+}
+
+.empty {
+ padding-block: var(--sp-xxl);
+}
+
+// a full-width DS button does not center its label on its own
+.new-task {
+ justify-content: center;
+ inline-size: 100%;
+}
diff --git a/frontend/src/app/main/ui/workspace/review/tasks.cljs b/frontend/src/app/main/ui/workspace/review/tasks.cljs
new file mode 100644
index 0000000000..b2af6fbafc
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/review/tasks.cljs
@@ -0,0 +1,678 @@
+;; 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.tasks
+ "Tasks in the workspace: the list of tasks, the menu of a task, what a
+ task shows inside its thread (its state, what happened to it and what
+ to do next) and the form of a new task."
+ (:require-macros [app.main.style :as stl])
+ (:require
+ [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.workspace.pull-requests :as dwpr]
+ [app.main.data.workspace.review :as dwrv]
+ [app.main.data.workspace.tasks :as dwtk]
+ [app.main.refs :as refs]
+ [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.buttons.link-button :refer [link-button*]]
+ [app.main.ui.ds.controls.select :refer [select*]]
+ [app.main.ui.ds.controls.textarea :refer [textarea*]]
+ [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.main.ui.ds.layout.menu :refer [menu* menu-item* sub-menu*]]
+ [app.main.ui.ds.product.avatar :refer [avatar*]]
+ [app.main.ui.ds.product.layer-chip :refer [layer-chip*]]
+ [app.main.ui.ds.product.progress-bar :refer [progress-bar*]]
+ [app.main.ui.ds.product.task-row :refer [task-row*]]
+ [app.main.ui.ds.product.task-status :refer [task-status*]]
+ [app.main.ui.workspace.review.common :as rvc]
+ [app.util.dom :as dom]
+ [app.util.i18n :refer [tr]]
+ [app.util.keyboard :as kbd]
+ [cuerdas.core :as str]
+ [rumext.v2 :as mf]))
+
+(defn page-objects
+ [data page-id]
+ (dm/get-in data [:pages-index page-id :objects]))
+
+;; --- Who a task is for
+
+(def ^:private no-assignee
+ "The option of a task without an assignee."
+ "none")
+
+(defn- option->assignee-id
+ [option-id]
+ (when (not= no-assignee option-id)
+ (uuid/parse option-id)))
+
+(defn- use-assignee-options
+ "Who a task may be for: nobody, or a member of the team."
+ []
+ (let [team (mf/deref refs/team)
+ profile (mf/deref refs/profile)
+ members (:members team)]
+ (mf/with-memo [members profile]
+ (into [{:id no-assignee :label (tr "workspace.tasks.unassigned")}]
+ (map (fn [{:keys [id fullname] :as member}]
+ {:id (str id)
+ :member member
+ :label (if (= id (:id profile))
+ (tr "workspace.tasks.assignee-me" fullname)
+ fullname)}))
+ (sort-by :fullname members)))))
+
+(defn- assign-task
+ "Make `task` the work of the option `option-id`."
+ [task option-id]
+ (let [assignee-id (option->assignee-id option-id)]
+ (when (not= assignee-id (:assignee-id task))
+ (st/emit! (dwtk/update-task (:id task) {:assignee-id assignee-id})))))
+
+(defn- assignee-items
+ "The items of a menu that changes who `task` is for."
+ [task options]
+ (for [{:keys [id label member]} options]
+ (mf/html
+ [:> menu-item* {:key id :id id :text-value label}
+ [:div {:class (stl/css :assignee-item)}
+ (when (some? member)
+ [:> avatar* {:profile member :variant "S"}])
+ [:span {:class (stl/css :assignee-name)} label]
+ (when (= (option->assignee-id id) (:assignee-id task))
+ [:> icon* {:icon-id i/tick :size "s" :class (stl/css :assignee-tick)}])]])))
+
+(defn- keep-enter
+ "The shortcuts of the workspace take Enter on any element and cancel its
+ default: kept from them, Enter clicks the trigger of a menu."
+ [event]
+ (when (kbd/enter? event)
+ (dom/stop-propagation event)))
+
+;; --- Menu of a task
+
+(defn- confirm-delete-task
+ "Ask before deleting `task`. The confirmation takes the place of the dialog
+ the task may be listed in, which comes back afterwards."
+ [task]
+ (let [previous (::modal/modal @st/state)
+ restore (fn [_]
+ (when (some? previous)
+ (st/emit! (modal/show (:type previous) (:props previous)))))]
+ (st/emit! (modal/show {:type :confirm
+ :title (tr "modals.delete-task.title")
+ :message (tr "modals.delete-task.message")
+ :accept-label (tr "modals.delete-task.accept")
+ :on-accept (fn [props]
+ (st/emit! (dwtk/delete-task (:id task)))
+ (restore props))
+ :on-cancel restore}))))
+
+(def ^:private menu-navigation
+ "The items of the menu of a task that lead to other items."
+ #{"assign" "__menu-back"})
+
+(mf/defc task-menu*
+ "The actions of a task, behind a menu trigger: the moves its state
+ allows, who it is for, linking it to another layer and deleting it."
+ {::mf/private true}
+ [{:keys [task]}]
+ (let [open* (mf/use-state false)
+ open? (deref open*)
+ status (:status task)
+ options (use-assignee-options)
+
+ on-toggle
+ (mf/use-fn
+ (fn [event]
+ (dom/stop-propagation event)
+ (swap! open* not)))
+
+ on-open-change (mf/use-fn #(reset! open* %))
+
+ ;; the assignees sit in this same menu (see `sub-menu*`): an action
+ ;; that only walks into or out of them leaves it open
+ on-action
+ (mf/use-fn
+ (mf/deps task)
+ (fn [action]
+ (when-not (contains? menu-navigation action)
+ (reset! open* false)
+ (case action
+ "done" (st/emit! (dwtk/set-task-status task "done"))
+ "verify" (st/emit! (dwtk/set-task-status task "verified"))
+ "reopen" (st/emit! (dwtk/set-task-status task "reopened"))
+ "wont-do" (st/emit! (dwtk/set-task-status task "wont-do"))
+ "relink" (st/emit! (dwtk/start-relink (:id task)))
+ "delete" (confirm-delete-task task)
+ (assign-task task action)))))]
+
+ [:div {:on-click dom/stop-propagation
+ :on-key-down keep-enter}
+ [:> menu* {:class (stl/css :task-menu)
+ :is-open open?
+ :on-open-change on-open-change
+ :on-action on-action
+ :placement "bottom end"
+ :trigger (mf/html
+ [:> icon-button* {:variant "ghost"
+ :icon i/menu
+ :aria-label (tr "labels.options")
+ :aria-haspopup "menu"
+ :aria-expanded open?
+ ;; the DS button draws its pressed look from this
+ :aria-pressed open?
+ :on-click on-toggle}])}
+ (when (dwtk/to-do? task)
+ [:> menu-item* {:id "done"}
+ (tr "workspace.tasks.actions.mark-done")])
+ (when (= "done" status)
+ [:> menu-item* {:id "verify"}
+ (tr "workspace.tasks.actions.verify")])
+ (when (or (= "done" status) (dwtk/closed? task))
+ [:> menu-item* {:id "reopen"}
+ (tr "workspace.tasks.actions.reopen")])
+ (when (dwtk/to-do? task)
+ [:> menu-item* {:id "wont-do"}
+ (tr "workspace.tasks.actions.wont-do")])
+ (when-not (dwtk/closed? task)
+ [:> sub-menu* {:id "assign"
+ :variant "drilldown"
+ :trigger (tr "workspace.tasks.actions.assign")
+ :text-value (tr "workspace.tasks.actions.assign")}
+ (assignee-items task options)])
+ (when-not (dwtk/closed? task)
+ [:> menu-item* {:id "relink"}
+ (tr "workspace.tasks.actions.relink")])
+ [:> menu-item* {:id "delete"}
+ (tr "workspace.tasks.actions.delete")]]]))
+
+;; --- List of tasks
+
+(mf/defc task-list-item*
+ {::mf/private true}
+ [{:keys [task data profiles is-selected show-review on-open]}]
+ (let [objects (page-objects data (:page-id task))
+ assignee (get profiles (:assignee-id task))
+ review? (some? (:pull-request-id task))
+
+ on-click
+ (mf/use-fn
+ (mf/deps task on-open)
+ (fn [_] (on-open task)))]
+
+ [:> task-row* {:title (:title task)
+ :status (:status task)
+ :status-label (rvc/status-label (:status task))
+ :layer (rvc/layer-name objects task)
+ :is-layer-lost (dwtk/lost? task)
+ :is-selected is-selected
+ :is-review review?
+ :review (when (and show-review review?)
+ (or (:review-title task) (tr "workspace.review.design-review")))
+ :on-click on-click
+ :assignee (when assignee
+ (mf/html [:> avatar* {:profile assignee :variant "S"}]))
+ :actions (mf/html [:> task-menu* {:task task}])}]))
+
+(mf/defc task-list*
+ "The tasks `tasks`, each one opening on the canvas when clicked. With
+ `show-review`, each one names the design review it belongs to."
+ [{:keys [tasks show-review]}]
+ (let [data (mf/deref refs/workspace-data)
+ profiles (mf/deref refs/profiles)
+ local (mf/deref refs/tasks-local)
+
+ ;; a task opened from a dialog (the details of a review) shows on
+ ;; the canvas: the dialog gets out of the way
+ on-open
+ (mf/use-fn
+ (fn [task]
+ (st/emit! (modal/hide)
+ (dwtk/navigate-to-task task))))]
+ [:ul {:class (stl/css :task-list)}
+ (for [task tasks]
+ [:li {:key (dm/str (:id task))}
+ [:> task-list-item* {:task task
+ :data data
+ :profiles profiles
+ :is-selected (= (:id task) (:open local))
+ :show-review show-review
+ :on-open on-open}]])]))
+
+;; --- What happened to a task
+
+(defn- actor-name
+ [profiles profile-id me]
+ (if (= profile-id me)
+ (tr "workspace.tasks.you")
+ (rvc/profile-name profiles profile-id)))
+
+(defn- event-text
+ "What an event says. That a task was created says nothing the task itself
+ does not show."
+ [{:keys [type profile-id payload]} profiles me]
+ (let [actor (actor-name profiles profile-id me)]
+ (case type
+ "assigned" (let [assignee-id (:assignee-id payload)]
+ (cond
+ (nil? assignee-id)
+ (tr "workspace.tasks.event.unassigned" actor)
+
+ (= assignee-id me)
+ (tr "workspace.tasks.event.assigned-to-you" actor)
+
+ :else
+ (tr "workspace.tasks.event.assigned" actor
+ (rvc/profile-name profiles assignee-id))))
+ "status" (case (:to payload)
+ "done" (tr "workspace.tasks.event.done" actor)
+ "verified" (tr "workspace.tasks.event.verified" actor)
+ "reopened" (tr "workspace.tasks.event.reopened" actor)
+ "wont-do" (tr "workspace.tasks.event.wont-do" actor)
+ (tr "workspace.tasks.event.status" actor))
+ "renamed" (tr "workspace.tasks.event.renamed" actor)
+ "relinked" (tr "workspace.tasks.event.relinked" actor (:shape-name payload))
+ "layer-deleted" (tr "workspace.tasks.event.layer-deleted" actor (:shape-name payload))
+ "layer-restored" (tr "workspace.tasks.event.layer-restored" actor (:shape-name payload))
+ "moved-to-main" (tr "workspace.tasks.event.moved-to-main" (:branch-name payload))
+ nil)))
+
+(defn- event-icon
+ [{:keys [type payload]}]
+ (case type
+ "layer-deleted" i/triangle-alert
+ "status" (if (= "done" (:to payload)) i/tick i/view-as-list)
+ "moved-to-main" i/git-merge
+ i/view-as-list))
+
+(mf/defc task-event*
+ "One line of what happened to a task."
+ {::mf/private true}
+ [{:keys [event]}]
+ (let [profiles (mf/deref refs/profiles)
+ profile (mf/deref refs/profile)
+ text (event-text event profiles (:id profile))]
+ (when text
+ [:div {:class (stl/css-case :task-event true
+ :is-warning (= "layer-deleted" (:type event)))}
+ [:> icon* {:icon-id (event-icon event) :size "s" :class (stl/css :task-event-icon)}]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :task-event-text)}
+ text
+ [:span {:class (stl/css :task-event-time)}
+ " - " (ct/timeago (:created-at event))]]])))
+
+;; --- State of a task and what to do next
+
+(mf/defc assignee-menu*
+ "Who a task is for, as the trigger of the menu that changes it."
+ {::mf/private true}
+ [{:keys [task label]}]
+ (let [open* (mf/use-state false)
+ open? (deref open*)
+ options (use-assignee-options)
+
+ on-toggle
+ (mf/use-fn
+ (fn [event]
+ (dom/stop-propagation event)
+ (swap! open* not)))
+
+ on-open-change (mf/use-fn #(reset! open* %))
+
+ on-action
+ (mf/use-fn
+ (mf/deps task)
+ (fn [option-id]
+ (reset! open* false)
+ (assign-task task option-id)))]
+
+ [:div {:class (stl/css :assignee-menu)
+ :on-click dom/stop-propagation
+ :on-key-down keep-enter}
+ [:> menu* {:is-open open?
+ :on-open-change on-open-change
+ :on-action on-action
+ :placement "bottom start"
+ :trigger (mf/html
+ [:button {:type "button"
+ :class (stl/css :assignee-trigger)
+ :aria-label (tr "workspace.tasks.change-assignee" label)
+ :aria-haspopup "menu"
+ :aria-expanded open?
+ :on-click on-toggle}
+ [:> text* {:as "span"
+ :typography t/body-small
+ :class (stl/css :assignee-label)}
+ label]
+ [:> icon* {:icon-id i/arrow-down
+ :size "s"
+ :class (stl/css :assignee-icon)}]])}
+ (assignee-items task options)]]))
+
+(mf/defc task-state-line*
+ "The state of a task and the layer it points at, over who it is for and,
+ out of a review, the review it comes from."
+ {::mf/private true}
+ [{:keys [task]}]
+ (let [profiles (mf/deref refs/profiles)
+ profile (mf/deref refs/profile)
+ data (mf/deref refs/workspace-data)
+ preview (mf/deref refs/pull-request-preview)
+ objects (page-objects data (:page-id task))
+ for-me? (= (:assignee-id task) (:id profile))
+ lost? (dwtk/lost? task)
+ file-id (mf/use-ctx ctx/current-file-id)
+ assignee (cond
+ for-me? (tr "workspace.tasks.for-you")
+ (some? (:assignee-id task)) (rvc/profile-name profiles (:assignee-id task))
+ :else (tr "workspace.tasks.unassigned"))
+
+ on-open-review
+ (mf/use-fn
+ (mf/deps task file-id)
+ (fn [_]
+ (st/emit! (dwpr/open-pull-request {:id (:pull-request-id task)
+ :source-file-id file-id}))))]
+
+ [:div {:class (stl/css :task-state)}
+ [:div {:class (stl/css :task-state-row)}
+ [:> task-status* {:status (:status task)
+ :label (rvc/status-label (:status task))
+ :class (stl/css :task-state-status)}]
+ [:> layer-chip* {:label (rvc/layer-name objects task)
+ :is-lost lost?
+ :is-struck lost?}]]
+ [:div {:class (stl/css :task-state-row)}
+ ;; a closed task is settled: who it was for stays as it was
+ (if (dwtk/closed? task)
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :task-state-text)}
+ assignee]
+ [:> assignee-menu* {:task task :label assignee}])
+ (when (and (some? (:pull-request-id task))
+ (= "open" (:review-status task))
+ (nil? preview))
+ [:div {:class (stl/css :task-state-origin)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :task-state-text)}
+ (tr "workspace.tasks.from")]
+ [:> link-button* {:icon i/git-pull-request-arrow
+ :class (stl/css :task-state-review)
+ :title (:review-title task)
+ :on-click on-open-review}
+ [:span {:class (stl/css :task-state-review-title)}
+ (:review-title task)]]])]]))
+
+(mf/defc task-next-step*
+ "What to do next with a task: verify a done task (or reopen it), and
+ decide about a task whose layer was deleted."
+ {::mf/private true}
+ [{:keys [task]}]
+ (let [profiles (mf/deref refs/profiles)
+ data (mf/deref refs/workspace-data)
+ preview (mf/deref refs/pull-request-preview)
+ objects (page-objects data (:page-id task))
+ status (:status task)
+
+ set-status
+ (mf/use-fn
+ (mf/deps task)
+ (fn [event]
+ (let [status (-> (dom/get-current-target event)
+ (dom/get-data "status"))]
+ (st/emit! (dwtk/set-task-status task status)))))
+
+ on-show-change
+ (mf/use-fn
+ (mf/deps task)
+ (fn [_]
+ (st/emit! (dwtk/close-task)
+ (dwrv/show-change-of (:shape-id task)))))
+
+ on-restore
+ (mf/use-fn
+ (mf/deps task)
+ (fn [_]
+ (st/emit! (dwtk/restore-task-layer task))))
+
+ on-relink
+ (mf/use-fn
+ (mf/deps task)
+ (fn [_]
+ (st/emit! (dwtk/start-relink (:id task)))))]
+
+ (cond
+ (and (dwtk/lost? task) (not (dwtk/closed? task)))
+ [:div {:class (stl/css :task-next-step)}
+ [:> text* {:as "p" :typography t/body-small}
+ (tr "workspace.tasks.lost.message" (rvc/board-name objects (:frame-id task)))]
+ [:div {:class (stl/css :task-next-step-actions)}
+ ;; restoring and relinking edit the branch: not inside a review
+ (when (nil? preview)
+ [:> button* {:variant "ghost" :icon i/history :on-click on-restore}
+ (tr "workspace.tasks.actions.restore-layer")])
+ (when (nil? preview)
+ [:> button* {:variant "secondary" :on-click on-relink}
+ (tr "workspace.tasks.actions.relink-short")])
+ [:> button* {:variant "primary" :data-status "done" :on-click set-status}
+ (tr "workspace.tasks.actions.mark-done")]]]
+
+ (= "done" status)
+ [:div {:class (stl/css :task-next-step)}
+ [:> text* {:as "p" :typography t/body-small}
+ (if (some? (:assignee-id task))
+ (tr "workspace.tasks.verify.message"
+ (rvc/profile-name profiles (:assignee-id task)))
+ (tr "workspace.tasks.verify.message-unassigned"))]
+ [:div {:class (stl/css :task-next-step-actions)}
+ (when (and (some? preview) (some? (:shape-id task)))
+ [:> button* {:variant "ghost" :icon i/shown :on-click on-show-change}
+ (tr "workspace.tasks.actions.show-change")])
+ [:> button* {:variant "secondary" :data-status "reopened" :on-click set-status}
+ (tr "workspace.tasks.actions.reopen")]
+ [:> button* {:variant "primary" :data-status "verified" :on-click set-status}
+ (tr "workspace.tasks.actions.verify")]]]
+
+ (dwtk/to-do? task)
+ [:div {:class (stl/css :task-next-step :is-inline)}
+ [:> button* {:variant "primary" :data-status "done" :on-click set-status}
+ (tr "workspace.tasks.actions.mark-done")]]
+
+ :else nil)))
+
+(defn- use-task-events
+ "The events of `task`, loaded once the task is shown."
+ [task-id]
+ (let [events (mf/deref refs/task-events)]
+ (mf/with-effect [task-id]
+ (when task-id
+ (st/emit! (dwtk/fetch-task-events task-id))))
+ (get events task-id)))
+
+;; --- The task a comment thread is attached to
+
+(mf/defc thread-task-section*
+ "The task a thread is attached to, inside the thread: its state, what
+ happened to it and what to do next."
+ [{:keys [task]}]
+ (let [events (use-task-events (:id task))]
+ [:div {:class (stl/css :thread-task)}
+ [:> task-state-line* {:task task}]
+ (for [event events]
+ [:> task-event* {:key (dm/str (:id event)) :event event}])
+ [:> task-next-step* {:task task}]]))
+
+;; --- The card of a mark on the canvas
+
+(mf/defc task-preview*
+ "A task in the small card of a mark: its state, title and assignee."
+ [{:keys [task]}]
+ (let [profiles (mf/deref refs/profiles)]
+ [:div {:class (stl/css :task-preview)}
+ [:> task-status* {:status (:status task)
+ :label (rvc/status-label (:status task))}]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :task-preview-title)}
+ (:title task)]
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :task-preview-assignee)}
+ (if (some? (:assignee-id task))
+ (tr "workspace.tasks.assigned-to" (rvc/profile-name profiles (:assignee-id task)))
+ (tr "workspace.tasks.unassigned"))]]))
+
+;; --- A new task
+
+(mf/defc new-task-form*
+ "The form of a new task, next to the layer it is linked to. From a
+ message of a thread it is \"Make it a task\": the title comes from the
+ message, which the task lives in. Any other task gets a thread whose
+ first message is its title."
+ [{:keys [params style class]}]
+ (let [data (mf/deref refs/workspace-data)
+ objects (page-objects data (:page-id params))
+ thread? (some? (:thread-id params))
+
+ title* (mf/use-state (or (:title params) ""))
+ title (deref title*)
+ assignee* (mf/use-state (or (some-> (:assignee-id params) str) no-assignee))
+ assignee (deref assignee*)
+ options (use-assignee-options)
+
+ valid? (not (str/blank? title))
+ heading (if thread?
+ (tr "workspace.tasks.make-task")
+ (tr "workspace.tasks.new-task"))
+
+ on-title-change (mf/use-fn #(reset! title* (dom/get-target-val %)))
+ on-assignee (mf/use-fn #(reset! assignee* %))
+
+ on-cancel
+ (mf/use-fn #(st/emit! (dwtk/cancel-new-task)))
+
+ on-submit
+ (mf/use-fn
+ (mf/deps params title assignee valid?)
+ (fn [event]
+ (dom/prevent-default event)
+ (when valid?
+ (st/emit! (dwtk/create-task
+ (-> params
+ (assoc :title (str/trim title))
+ (assoc :assignee-id (option->assignee-id assignee))))))))
+
+ on-key-down
+ (mf/use-fn
+ (mf/deps on-submit)
+ (fn [event]
+ (cond
+ (kbd/esc? event)
+ (do (dom/stop-propagation event)
+ (st/emit! (dwtk/cancel-new-task)))
+
+ (and (kbd/enter? event) (kbd/mod? event))
+ (on-submit event))))]
+
+ [:form {:class [class (stl/css :floating-panel)]
+ :style style
+ :aria-label heading
+ :on-submit on-submit
+ :on-key-down on-key-down
+ :on-click dom/stop-propagation}
+ [:div {:class (stl/css :floating-header)}
+ [:> icon* {:icon-id i/view-as-list :size "s" :class (stl/css :floating-header-icon)}]
+ [:> text* {:as "span" :typography t/body-medium :class (stl/css :floating-title :is-strong)}
+ heading]
+ [:> icon-button* {:variant "ghost"
+ :type "button"
+ :icon i/close
+ :aria-label (tr "labels.close")
+ :on-click on-cancel}]]
+ [:div {:class (stl/css :floating-body)}
+ [:> textarea* {:class (stl/css :task-title-input)
+ :value title
+ :auto-focus true
+ :rows 3
+ :max-length 250
+ :aria-label (tr "workspace.tasks.title")
+ :placeholder (tr "workspace.tasks.title-placeholder")
+ :on-change on-title-change}]
+ [:> text* {:as "p" :typography t/body-small :class (stl/css :form-hint)}
+ (if thread?
+ (tr "workspace.tasks.make-task.hint")
+ (tr "workspace.tasks.new-task.hint"))]
+ [:div {:class (stl/css :form-row)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :form-label)}
+ (tr "workspace.tasks.assignee")]
+ [:> select* {:options options
+ :default-selected assignee
+ :on-change on-assignee
+ :has-portal true
+ :wrapper-class (stl/css :form-select)}]]
+ [:div {:class (stl/css :form-row)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :form-label)}
+ (tr "workspace.tasks.linked-to")]
+ [:> layer-chip* {:label (rvc/layer-name objects params)}]]
+ [:div {:class (stl/css :form-actions)}
+ [:> button* {:variant "ghost" :type "button" :on-click on-cancel}
+ (tr "labels.cancel")]
+ [:> button* {:variant "primary" :type "submit" :disabled (not valid?)}
+ (tr "workspace.tasks.create")]]]]))
+
+(defn filter-tasks
+ "The tasks a filter of the task list keeps."
+ [tasks kind profile-id]
+ (case kind
+ :open (filter dwtk/to-do? tasks)
+ :mine (filter #(= profile-id (:assignee-id %)) tasks)
+ :to-verify (filter dwtk/to-verify? tasks)
+ tasks))
+
+(defn closed-count
+ [tasks]
+ (count (filter dwtk/closed? tasks)))
+
+(mf/defc progress*
+ "\"2 of 7 closed\" over a bar, and the tasks waiting to be verified."
+ [{:keys [tasks on-to-verify]}]
+ (let [total (count tasks)
+ closed (closed-count tasks)
+ to-verify (count (filter dwtk/to-verify? tasks))]
+ [:div {:class (stl/css :progress)}
+ [:div {:class (stl/css :progress-head)}
+ [:> text* {:as "span" :typography t/body-small :class (stl/css :progress-label)}
+ (tr "workspace.tasks.closed-of" closed total)]
+ (when (pos? to-verify)
+ [:> link-button* {:tone "info" :on-click on-to-verify}
+ (tr "workspace.tasks.to-verify" to-verify)])]
+ [:> progress-bar* {:value closed :total total :class (stl/css :progress-bar)}]]))
+
+(defn count-by
+ [f tasks]
+ (count (filter f tasks)))
+
+(defn group-tasks
+ "The tasks of the branch workspace list: those of each design review
+ first (the open review first), then the others."
+ [tasks]
+ (let [[review other] ((juxt filter remove) (comp some? :pull-request-id) tasks)]
+ (concat
+ (->> (group-by :pull-request-id review)
+ (sort-by (fn [[_ items]] (if (= "open" (:review-status (first items))) 0 1)))
+ (map (fn [[id items]] {:id id :title (:review-title (first items)) :tasks items})))
+ (when (seq other)
+ [{:id :other :tasks other}]))))
+
+(defn visible-tasks
+ "The tasks of the file that are still work of this file: the history of
+ merged branches stays out."
+ [tasks]
+ (->> (vals tasks)
+ (remove dwtk/history?)
+ (dwtk/sort-tasks)))
diff --git a/frontend/src/app/main/ui/workspace/review/tasks.scss b/frontend/src/app/main/ui/workspace/review/tasks.scss
new file mode 100644
index 0000000000..b4ccd3fd7d
--- /dev/null
+++ b/frontend/src/app/main/ui/workspace/review/tasks.scss
@@ -0,0 +1,333 @@
+// 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 *;
+
+// --- List
+
+.task-list {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+
+// --- The task of a comment thread
+
+.thread-task {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+}
+
+// --- Events
+
+.task-event {
+ --task-event-fg-color: var(--color-foreground-primary);
+ --task-event-icon-color: var(--color-accent-info);
+
+ display: flex;
+ align-items: flex-start;
+ gap: var(--sp-s);
+ padding: var(--sp-s);
+
+ // outlined on the background of the thread, apart from its messages,
+ // which are filled
+ border: $b-1 solid var(--color-background-quaternary);
+ border-radius: $br-8;
+ color: var(--task-event-fg-color);
+
+ &.is-warning {
+ --task-event-fg-color: var(--color-accent-warning);
+ --task-event-icon-color: var(--color-accent-warning);
+ }
+}
+
+.task-event-icon {
+ flex-shrink: 0;
+ color: var(--task-event-icon-color);
+}
+
+.task-event-text {
+ flex: 1;
+ min-inline-size: 0;
+}
+
+.task-event-time {
+ color: var(--color-foreground-primary);
+}
+
+// --- State and next step
+
+.task-state {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+}
+
+.task-state-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--sp-s);
+ min-inline-size: 0;
+}
+
+.task-state-status {
+ flex-shrink: 0;
+}
+
+.task-state-origin {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-xs);
+ min-inline-size: 0;
+}
+
+.task-state-review {
+ min-inline-size: 0;
+}
+
+.task-state-review-title {
+ @include text-ellipsis;
+
+ min-inline-size: 0;
+}
+
+.task-state-text {
+ flex-shrink: 0;
+ color: var(--color-foreground-primary);
+}
+
+.assignee-menu {
+ display: flex;
+
+ // the text of the trigger lines up with the tag above it
+ margin-inline-start: calc(-1 * var(--sp-xs));
+ min-inline-size: 0;
+
+ // the DS menu wraps its trigger in a div with no class to reach: a long name
+ // has to shrink through it and end in an ellipsis
+ > div {
+ min-inline-size: 0;
+ }
+}
+
+// the assignees replace the actions in the same popover, whose edge stays put:
+// a fixed width keeps long names from pushing it out of the screen
+.task-menu {
+ inline-size: $sz-224;
+}
+
+.assignee-trigger {
+ --assignee-trigger-bg-color: transparent;
+
+ display: inline-flex;
+ align-items: center;
+ gap: var(--sp-xxs);
+ max-inline-size: 100%;
+ padding-inline: var(--sp-xs);
+ border: 0;
+ border-radius: $br-4;
+ background-color: var(--assignee-trigger-bg-color);
+ color: var(--color-foreground-primary);
+ cursor: pointer;
+
+ &:hover,
+ &[aria-expanded="true"] {
+ --assignee-trigger-bg-color: var(--color-background-quaternary);
+ }
+
+ &:focus-visible {
+ outline: $b-1 solid var(--color-accent-primary);
+ }
+}
+
+.assignee-label {
+ @include text-ellipsis;
+
+ min-inline-size: 0;
+}
+
+.assignee-icon {
+ flex-shrink: 0;
+ color: var(--color-foreground-secondary);
+}
+
+.assignee-item {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-s);
+ min-inline-size: 0;
+ inline-size: 100%;
+}
+
+.assignee-name {
+ @include text-ellipsis;
+
+ flex: 1;
+ min-inline-size: 0;
+}
+
+.assignee-tick {
+ flex-shrink: 0;
+ color: var(--color-accent-primary);
+}
+
+.task-next-step {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-m);
+ padding: var(--sp-m);
+ border-radius: $br-8;
+ background-color: var(--color-background-tertiary);
+ color: var(--color-foreground-primary);
+
+ &.is-inline {
+ flex-direction: row;
+ justify-content: flex-end;
+ padding: 0;
+ background: none;
+ }
+}
+
+.task-next-step-actions {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: flex-end;
+ gap: var(--sp-s);
+}
+
+// --- The card of a mark on the canvas
+
+.task-preview {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: var(--sp-xs);
+}
+
+.task-preview-title {
+ color: var(--color-foreground-primary);
+ overflow-wrap: anywhere;
+}
+
+.task-preview-assignee {
+ color: var(--color-foreground-secondary);
+}
+
+// --- Floating panels on the canvas
+
+.floating-panel {
+ position: absolute;
+ display: flex;
+ flex-direction: column;
+ inline-size: $sz-284;
+ max-block-size: 60vh;
+ border: $b-1 solid var(--color-background-quaternary);
+ border-radius: $br-8;
+ background-color: var(--color-background-primary);
+ box-shadow: 0 0 px2rem(12) 0 var(--color-shadow-dark);
+ color: var(--color-foreground-primary);
+ overflow: hidden;
+ cursor: auto;
+ pointer-events: auto;
+}
+
+.floating-header {
+ display: flex;
+ align-items: center;
+ gap: var(--sp-s);
+ padding: var(--sp-s) var(--sp-s) var(--sp-s) var(--sp-m);
+ border-block-end: $b-1 solid var(--color-background-quaternary);
+}
+
+.floating-header-icon {
+ color: var(--color-accent-info);
+}
+
+.floating-title {
+ --floating-title-color: var(--color-foreground-secondary);
+
+ flex: 1;
+ min-inline-size: 0;
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ color: var(--floating-title-color);
+
+ &.is-strong {
+ --floating-title-color: var(--color-foreground-primary);
+ }
+}
+
+.floating-body {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-m);
+ padding: var(--sp-m);
+ overflow-y: auto;
+}
+
+// --- New task form
+
+.task-title-input {
+ --textarea-resize: none;
+}
+
+.form-hint {
+ margin: 0;
+ color: var(--color-foreground-secondary);
+}
+
+.form-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--sp-s);
+}
+
+.form-label {
+ flex-shrink: 0;
+ color: var(--color-foreground-primary);
+}
+
+.form-select {
+ max-inline-size: $sz-160;
+}
+
+.form-actions {
+ display: flex;
+ justify-content: flex-end;
+ gap: var(--sp-s);
+}
+
+// --- Progress
+
+.progress {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+}
+
+.progress-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+}
+
+.progress-label {
+ color: var(--color-foreground-primary);
+}
+
+.progress-bar {
+ --progress-bar-fill-radius: #{$br-4};
+}
diff --git a/frontend/src/app/main/ui/workspace/sidebar.cljs b/frontend/src/app/main/ui/workspace/sidebar.cljs
index c8a0ece18e..8137784dc9 100644
--- a/frontend/src/app/main/ui/workspace/sidebar.cljs
+++ b/frontend/src/app/main/ui/workspace/sidebar.cljs
@@ -31,6 +31,7 @@
[app.main.ui.hooks.resize :refer [use-resize-hook]]
[app.main.ui.workspace.comments :refer [comments-sidebar*]]
[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*]]
[app.main.ui.workspace.sidebar.assets :refer [assets-toolbox*]]
[app.main.ui.workspace.sidebar.debug :refer [debug-panel*]]
@@ -125,7 +126,9 @@
scroll-store* (mf/use-var {})
design-tokens? (features/use-feature "design-tokens/v1")
- mode-inspect? (= options-mode :inspect)
+ ;; a design review is read-only: it shows the pages and layers alone
+ reviewing? (some? (mf/deref refs/pull-request-preview))
+ mode-inspect? (or reviewing? (= options-mode :inspect))
shortcuts? (contains? layout :shortcuts)
show-debug? (contains? layout :debug-panel)
@@ -202,6 +205,12 @@
(true? show-debug?)
[:> debug-panel* {:class (stl/css :left-sidebar-content)}]
+ ^boolean reviewing?
+ [:div {:class (stl/css :left-sidebar-content)}
+ [:> layers-content* {:layout layout
+ :width width
+ :scroll-store scroll-store*}]]
+
:else
[:div {:class (stl/css :left-sidebar-content)}
[:> tab-switcher* {:tabs tabs
@@ -284,7 +293,8 @@
(mf/defc right-sidebar*
[{:keys [layout section file-id page-id drawing-tool active-tokens] :as props}]
- (let [is-comments? (= drawing-tool :comments)
+ (let [reviewing? (some? (mf/deref refs/pull-request-preview))
+ is-comments? (and (not reviewing?) (= drawing-tool :comments))
is-history? (contains? layout :document-history)
is-inspect? (= section :inspect)
is-debug? (= section :debug)
@@ -349,6 +359,17 @@
[:div {:class (stl/css :right-sidebar-content)}
(cond
+ ;; 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
+ (and reviewing? (not is-history?))
+ [:> review-panel* {:inspect
+ (mf/html
+ [:> options-toolbox*
+ (mf/spread-props props
+ {:on-change-section on-change-section
+ :on-expand on-expand})])}]
+
is-comments?
[:> comments-sidebar* {}]
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 17824afd93..feb2e55444 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
@@ -2,7 +2,7 @@
;; 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 INC Sucursal en España SL
+;; 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
@@ -97,55 +97,51 @@
(shape-icon-id item)
(get kind->icon (:kind item) i/git-branch)))
-(def ^:private kind->type-label
- {:shape "workspace.branches.compare.type.shape"
- :component "workspace.branches.compare.type.component"
- :color "workspace.branches.compare.type.color"
- :typography "workspace.branches.compare.type.typography"
- :media "workspace.branches.compare.type.media"
- :token "workspace.branches.compare.type.token"
- :page "workspace.branches.review.type.page"
- :page-attrs "workspace.branches.review.type.page-settings"
- :page-order "workspace.branches.review.type.page-order"
- :page-guide "workspace.branches.review.type.guides"
- :page-flow "workspace.branches.review.type.flows"
- :page-grid "workspace.branches.review.type.grids"
- :page-plugin "workspace.branches.review.type.plugin-data"
- :file-plugin "workspace.branches.review.type.plugin-data"
- :file-option "workspace.branches.review.type.file-options"
- :token-set "workspace.branches.review.type.token-set"
- :token-set-rename "workspace.branches.review.type.token-set"
- :token-set-order "workspace.branches.review.type.token-set-order"
- :token-theme "workspace.branches.review.type.theme"
- :token-active-themes "workspace.branches.review.type.active-themes"
- :token-active-sets "workspace.branches.review.type.active-sets"
- :tokens-source "workspace.branches.review.type.tokens-source"})
+(defn- shape-type-label
+ [shape-type]
+ (case shape-type
+ :frame (tr "workspace.branches.compare.shape.board")
+ (:rect :line) (tr "workspace.branches.compare.shape.rect")
+ :circle (tr "workspace.branches.compare.shape.ellipse")
+ :path (tr "workspace.branches.compare.shape.path")
+ :text (tr "workspace.branches.compare.shape.text")
+ (:image :svg-raw) (tr "workspace.branches.compare.shape.image")
+ :group (tr "workspace.branches.compare.shape.group")
+ :bool (tr "workspace.branches.compare.shape.bool")
+ (tr "workspace.branches.compare.type.shape")))
-(def ^:private shape-type->label
- {:frame "workspace.branches.compare.shape.board"
- :rect "workspace.branches.compare.shape.rect"
- :line "workspace.branches.compare.shape.rect"
- :circle "workspace.branches.compare.shape.ellipse"
- :path "workspace.branches.compare.shape.path"
- :text "workspace.branches.compare.shape.text"
- :image "workspace.branches.compare.shape.image"
- :svg-raw "workspace.branches.compare.shape.image"
- :group "workspace.branches.compare.shape.group"
- :bool "workspace.branches.compare.shape.bool"})
-
-(defn type-label-key
- "i18n key for an item's specific type — type-accurate for shapes
- (board/text/rectangle/component/…), generic for other kinds."
+(defn type-label
+ "The name of an item's specific type: type-accurate for shapes
+ (board/text/rectangle/component/...), generic for other kinds, nil for a
+ kind with no name."
[item]
- (if (= :shape (:kind item))
- (let [{:keys [component? component-copy? variant? shape-type]} item]
- (cond
- variant? "workspace.branches.compare.shape.variant"
- component? "workspace.branches.compare.shape.component"
- component-copy? "workspace.branches.compare.shape.component-copy"
- :else (get shape-type->label shape-type
- "workspace.branches.compare.type.shape")))
- (get kind->type-label (:kind item))))
+ (case (:kind item)
+ :shape (let [{:keys [component? component-copy? variant? shape-type]} item]
+ (cond
+ variant? (tr "workspace.branches.compare.shape.variant")
+ component? (tr "workspace.branches.compare.shape.component")
+ component-copy? (tr "workspace.branches.compare.shape.component-copy")
+ :else (shape-type-label shape-type)))
+ :component (tr "workspace.branches.compare.type.component")
+ :color (tr "workspace.branches.compare.type.color")
+ :typography (tr "workspace.branches.compare.type.typography")
+ :media (tr "workspace.branches.compare.type.media")
+ :token (tr "workspace.branches.compare.type.token")
+ :page (tr "workspace.branches.review.type.page")
+ :page-attrs (tr "workspace.branches.review.type.page-settings")
+ :page-order (tr "workspace.branches.review.type.page-order")
+ :page-guide (tr "workspace.branches.review.type.guides")
+ :page-flow (tr "workspace.branches.review.type.flows")
+ :page-grid (tr "workspace.branches.review.type.grids")
+ (:page-plugin :file-plugin) (tr "workspace.branches.review.type.plugin-data")
+ :file-option (tr "workspace.branches.review.type.file-options")
+ (:token-set :token-set-rename) (tr "workspace.branches.review.type.token-set")
+ :token-set-order (tr "workspace.branches.review.type.token-set-order")
+ :token-theme (tr "workspace.branches.review.type.theme")
+ :token-active-themes (tr "workspace.branches.review.type.active-themes")
+ :token-active-sets (tr "workspace.branches.review.type.active-sets")
+ :tokens-source (tr "workspace.branches.review.type.tokens-source")
+ nil))
;; --- Property labels and values
@@ -277,27 +273,36 @@
:constraints-v})
(def categories
- "Category order, the tone, label key and icon of each one. Colour is
+ "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" "workspace.branches.review.category.decisions" i/triangle-alert]
- [:copy "neutral" "workspace.branches.review.category.copy" i/text]
- [:colour "neutral" "workspace.branches.review.category.colour" i/swatches]
- [:layout "neutral" "workspace.branches.review.category.layout" i/flex]
- [:components "neutral" "workspace.branches.review.category.components" i/component]
- [:variants "neutral" "workspace.branches.review.category.variants" i/variant]
- [:tokens "neutral" "workspace.branches.review.category.tokens" i/tokens]
- [:other "neutral" "workspace.branches.review.category.other" i/layers]])
+ [[: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))
+ (into {} (map (fn [[k tone _]] [k tone])) categories))
-(def category->label
- (into {} (map (fn [[k _ label _]] [k label])) 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))
+ (into {} (map (fn [[k _ icon]] [k icon])) categories))
(defn category
"The one category a diff entry falls under, most specific first: a
@@ -363,7 +368,7 @@
[item]
(let [status (:status item)
attrs (visible-attrs (:changed-attrs item))
- lbl (some-> (type-label-key item) tr)
+ lbl (type-label item)
phrases (into [] (comp (map (comp change-phrase first)) (distinct)) attrs)
shown (take 2 phrases)
more (- (count phrases) (count shown))]
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
index 4d28e567d6..daf4c5074e 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/compare.cljs
+++ b/frontend/src/app/main/ui/workspace/sidebar/branch_review/compare.cljs
@@ -2,7 +2,7 @@
;; 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 INC Sucursal en España SL
+;; 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
@@ -34,6 +34,7 @@
[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]
@@ -54,10 +55,6 @@
[item]
(or (:key item) (dm/str (name (:kind item)) ":" (:id item))))
-(defn- category-label
- [cat]
- (tr (brc/category->label cat)))
-
;; --- List rows
(defn- dom-stop
@@ -144,6 +141,7 @@
(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)
@@ -151,7 +149,7 @@
:on-click dom-stop}
[:> checkbox* {:id (dm/str "change-" change-key)
:checked (not excluded)
- :on-change #(on-toggle toggle-keys)}]]))]
+ :on-change on-check}]]))]
[:> change-row* {:title (or (:label item) "")
:subtitle subtitle
:icon (brc/entry-icon item)
@@ -190,72 +188,113 @@
:on-click on-click}]
(when open? children)]))
-(mf/defc change-list*
+(mf/defc decisions-group*
+ "The changes both sides made, which wait for a decision."
{::mf/private true}
- [{:keys [groups conflicts cascades follow-counts selected excluded reviewed collapsed
- on-select on-toggle on-fold]}]
- [:*
- (when (seq conflicts)
- (let [open? (not (contains? collapsed "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-fold "decisions")}]
- (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}]))]))
+ [{: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}]))]))
- (for [{:keys [id name rows boards count] :as group} groups]
- (let [open? (not (contains? collapsed id))
- row-keys (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 row-keys)]
- [:div {:class (stl/css :group) :key id}
- [:> brl/group-head*
- {:label (dm/str name " (" count ")")
- :is-open open?
- :on-toggle #(on-fold id)
- :start (when (seq row-keys)
- (mf/html
- [:span {:class (stl/css :row-check)}
- [:> checkbox* {:id (dm/str "group-" id)
- :checked included?
- :on-change #(on-toggle row-keys (not included?))}]]))}]
- (when open?
- [:*
- (for [[idx item] rows]
+(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}])
- (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}])])])]))])
+ :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 "workspace.branches.review.view.side"]
- [:overlay i/boolean-intersection "workspace.branches.review.view.overlay"]])
+ [[: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."
@@ -314,22 +353,29 @@
leaves the view toggles out for a change with nothing to overlay."
{::mf/private true}
[{:keys [mode on-change show-modes expanded on-expand]}]
- [:div {:class (stl/css :view-modes)}
- (when show-modes
- (for [[m icon label] view-modes]
- [:> icon-button* {:key (name m)
- :variant "ghost"
- :class (stl/css :view-toggle)
- :icon icon
- :aria-label (tr label)
- :aria-pressed (= m mode)
- :on-click #(on-change m)}]))
- [:> icon-button* {:variant "ghost"
- :icon (if expanded i/collapse i/expand)
- :aria-label (tr (if expanded
- "workspace.branches.review.view.collapse"
- "workspace.branches.review.view.expand"))
- :on-click 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`."
@@ -396,7 +442,7 @@
{::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-key item)
+ (let [type-lbl (brc/type-label item)
cat (brc/category item)
attrs (:changed-attrs item)
visible (brc/visible-attrs attrs)
@@ -405,24 +451,25 @@
(brc/copies-entry copies item
(get-in data [:pages-index (:page-id item) :objects])))
mode* (mf/use-state :side)
- mode (deref mode*)]
+ 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* {} (tr 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)}
- (category-label 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 #(reset! mode* %)
+ :on-change on-mode
:show-modes (= :shape (:kind item))
:expanded expanded
:on-expand on-expand}]]
@@ -507,6 +554,7 @@
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)
@@ -525,7 +573,7 @@
(:name board)]
[:> tag* {} (tr "workspace.branches.compare.shape.board")]]
[:> view-modes* {:mode mode
- :on-change #(reset! mode* %)
+ :on-change on-mode
:show-modes true
:expanded expanded
:on-expand on-expand}]]
@@ -658,6 +706,12 @@
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)
@@ -746,21 +800,24 @@
[:*
[:> filter-chip* {:label (dm/str (tr "labels.all") " (" (count counted) ")")
:is-selected (= active-filter :all)
- :on-click #(on-filter :all)}]
- (for [[cat tone label icon] brc/categories
+ :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 (tr label) " (" n ")")
+ :label (dm/str (brc/category-label cat) " (" n ")")
:icon icon
:tone tone
:is-selected (= active-filter cat)
- :on-click #(on-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)
- :on-click #(on-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
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
index 8457bb07fe..17b06b4bd8 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/compare.scss
+++ b/frontend/src/app/main/ui/workspace/sidebar/branch_review/compare.scss
@@ -2,13 +2,10 @@
// 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 INC Sucursal en España SL
+// 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 *;
-@use "ds/typography.scss" as *;
// --- List
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
index 6c78c39f6d..2e09fd157c 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs
+++ b/frontend/src/app/main/ui/workspace/sidebar/branch_review/conflicts.cljs
@@ -2,7 +2,7 @@
;; 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 INC Sucursal en España SL
+;; 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
@@ -11,6 +11,7 @@
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]
@@ -41,11 +42,15 @@
(def ^:private branch-diff
(l/derived :workspace-branch-diff st/state))
-(def ^:private reason->label
- {:modify-modify "workspace.branches.conflicts.reason.modify-modify"
- :add-add "workspace.branches.conflicts.reason.add-add"
- :delete-modify "workspace.branches.conflicts.reason.delete-modify"
- :modify-delete "workspace.branches.conflicts.reason.modify-delete"})
+(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."
@@ -81,7 +86,7 @@
(str/join ", " (map brc/attr-label conflicting)))
:else
- (some-> (get reason->label (:reason conflict)) tr))))
+ (reason-label (:reason conflict)))))
(mf/defc conflict-row*
{::mf/private true}
@@ -110,17 +115,27 @@
;; --- 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 [k ["workspace.branches.resolve.th.property"
- "workspace.branches.resolve.th.main"
- "workspace.branches.resolve.th.branch"
- "workspace.branches.resolve.th.result"]]
- [:> text* {:key k :as "span" :typography t/headline-small :class (stl/css :th)} (tr k)])
+ (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)
@@ -137,17 +152,21 @@
(if (= source :branch)
[:> text* {:as "span" :typography t/body-small :class (stl/css :td-unchanged)}
(tr "workspace.branches.resolve.unchanged")]
- [:button {:class (stl/css-case :td-pick true :is-chosen (and conflicting? (= choice :main)))
- :disabled (not conflicting?)
- :on-click #(on-pick attr :main)}
- [:> brl/value-chip* {:value main :is-old (not= choice :main)}]])
+ [:> 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")]
- [:button {:class (stl/css-case :td-pick true :is-chosen (and conflicting? (= choice :branch)))
- :disabled (not conflicting?)
- :on-click #(on-pick attr :branch)}
- [:> brl/value-chip* {:value branch :is-old (not= choice :branch)}]])
+ [:> 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}]]
@@ -172,26 +191,27 @@
"A choice between the two versions, as a radio card."
{::mf/private true}
[{:keys [label side detail is-chosen warning on-choose children]}]
- [:button {:class (stl/css-case :option true :is-chosen is-chosen)
- :role "radio"
- :aria-checked (boolean is-chosen)
- :on-click on-choose}
- [: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))}
- (tr (if (= side :main)
- "workspace.branches.review.side.main"
- "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])])
+ (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}
@@ -216,6 +236,7 @@
{::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 []
@@ -228,16 +249,16 @@
(for [side [:main :branch]
:let [lost (dropped-paragraphs conflict side)]]
[:> option-card* {:key (name side)
- :label (tr (if (= side :main)
- "workspace.branches.resolve.keep-main-text"
- "workspace.branches.resolve.keep-branch-text"))
+ :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-pick :content side)}
+ :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)}
@@ -255,15 +276,15 @@
(for [side [:main :branch]
:let [value (get conflict side)]]
[:> option-card* {:key (name side)
- :label (tr (if (= side :main)
- "workspace.branches.resolve.keep-main-version"
- "workspace.branches.resolve.keep-branch-version"))
+ :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 side)}
+ :on-choose on-choose}
[:div {:class (stl/css :option-stage)}
[:> brp/entity-preview* {:kind (:kind conflict)
:value value
@@ -271,6 +292,23 @@
;; --- 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]}]
@@ -308,7 +346,8 @@
(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)))))
- (tr (get reason->label (:reason conflict) "workspace.branches.status.conflict")))])]
+ (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
@@ -344,17 +383,13 @@
(when per-attr?
(for [{:keys [attr main branch source]} rows
- :when (and (= :conflict source) (not= attr :content))
- :let [choice (brc/attr-choice res attr)]]
- [:div {:class (stl/css :inline-actions) :key (str attr)}
- [:> 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-pick attr :main)}
- (tr "workspace.branches.resolve.keep-main" (brc/display-val main))]
- [:> button* {:variant (if (= choice :branch) "primary" "secondary")
- :on-click #(on-pick attr :branch)}
- (tr "workspace.branches.resolve.keep-branch" (brc/display-val branch))]]))
+ :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
@@ -378,10 +413,9 @@
:as "span"
:typography t/body-small
:class (stl/css :outcome-line)}
- (tr (if (= side :main)
- "workspace.branches.resolve.drops.main-short"
- "workspace.branches.resolve.drops.branch-short")
- (str/lower (brc/attr-label attr)))
+ (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)}
@@ -465,6 +499,10 @@
(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 []
@@ -527,16 +565,16 @@
;; more than one decision
(when (> total 1)
[:div {:class (stl/css :bulk)}
- [:> button* {:variant "secondary" :on-click #(on-all :main)}
+ [:> button* {:variant "secondary" :on-click on-all-main}
(tr "workspace.branches.resolve.keep-all-main")]
- [:> button* {:variant "secondary" :on-click #(on-all :branch)}
+ [:> 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 [[idx c] (map-indexed vector conflicts)]
- [:> conflict-row* {:key idx
+ (for [c indexed]
+ [:> conflict-row* {:key (::d/index c)
:conflict c
- :index idx
+ :index (::d/index c)
:selected sel-idx
:res (get resolutions (:id c))
:on-select on-select}])]))
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
index 2045410587..7b906cbb49 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/conflicts.scss
+++ b/frontend/src/app/main/ui/workspace/sidebar/branch_review/conflicts.scss
@@ -2,7 +2,7 @@
// 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 INC Sucursal en España SL
+// Copyright (c) KALEIDOS SUBSIDIARY SL
@use "ds/_borders.scss" as *;
@use "ds/_sizes.scss" as *;
@@ -130,6 +130,9 @@
@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;
}
@@ -235,18 +238,23 @@
}
.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: $b-2 solid var(--color-foreground-secondary);
+ border: var(--option-radio-border-width) solid var(--option-radio-border-color);
border-radius: $br-circle;
&.is-chosen {
- border: px2rem(4) solid var(--color-accent-primary);
+ --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;
}
@@ -257,10 +265,12 @@
}
.option-side-label {
- color: var(--color-accent-primary);
+ --option-side-label-color: var(--color-accent-primary);
+
+ color: var(--option-side-label-color);
&.is-main {
- color: var(--color-accent-secondary);
+ --option-side-label-color: var(--color-accent-secondary);
}
}
@@ -269,20 +279,14 @@
}
.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;
-
- // the same checkerboard as `preview-card*`
- background-color: var(--color-static-white);
- background-image: repeating-conic-gradient(
- color-mix(in srgb, var(--color-canvas) 70%, var(--color-static-white)) 0% 25%,
- transparent 0% 50%
- );
- background-size: px2rem(20) px2rem(20);
}
.option-warning {
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 43b473f028..479c65af17 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
@@ -2,7 +2,7 @@
;; 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 INC Sucursal en España SL
+;; 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:
@@ -85,11 +85,11 @@
(when (and deleted? (pos? layers))
[:> brl/notice* {:level :warning
:title (tr "workspace.branches.review.facts.page-goes")}
- (tr (if incoming
- "workspace.branches.review.facts.page-goes-update"
- "workspace.branches.review.facts.page-goes-merge")
- (tr "workspace.branches.review.facts.boards" (i18n/c (count boards)))
- (tr "workspace.branches.review.facts.layers" (i18n/c layers)))])]
+ (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")}
@@ -149,7 +149,7 @@
of its other layers move."
[{:keys [name layout from to moved]}]
[(tr "workspace.branches.review.category.layout")
- (dm/str name " (" (tr (if (= :grid layout) "labels.grid-layout" "labels.flex-layout")) ") - "
+ (dm/str name " (" (if (= :grid layout) (tr "labels.grid-layout") (tr "labels.flex-layout")) ") - "
(if moved
(tr "workspace.branches.review.effects.moved" (i18n/c moved))
(dm/str (size-line from) " → " (size-line to))))])
@@ -172,9 +172,9 @@
(when (or (seq interactions) (seq flows) (seq rows))
[:div {:class (stl/css :section)}
[:> section-title* {}
- (tr (if deleted?
- "workspace.branches.review.effects.title-deleted"
- "workspace.branches.review.effects.title-added"))]
+ (if deleted?
+ (tr "workspace.branches.review.effects.title-deleted")
+ (tr "workspace.branches.review.effects.title-added"))]
(when (seq interactions)
[:> brl/notice* {:level :warning
:title (tr "workspace.branches.review.effects.interactions"
@@ -207,24 +207,23 @@
shape (get objects (:id item))
page (get-in data [:pages-index (:page-id item) :name])
deleted? (= :deleted (:status item))
- type-lbl (some-> (brc/type-label-key item) tr)
+ type-lbl (brc/type-label item)
copies (when (and deleted? shape (:main-instance shape))
(brc/component-copies data (:component-id shape)))]
(when shape
[:*
[:> fact-list*
- {:rows (into [[(tr (if deleted?
- "workspace.branches.review.facts.where-was"
- "workspace.branches.review.facts.where-lands"))
+ {:rows (into [[(if deleted?
+ (tr "workspace.branches.review.facts.where-was")
+ (tr "workspace.branches.review.facts.where-lands"))
(str/join " › " (cons page (brc/shape-path objects (:id item))))]]
(shape-rows shape data type-lbl))}]
(when (and copies (pos? copies))
[:> brl/notice* {:level :warning
:title (tr "workspace.branches.review.facts.copies-orphaned-title")}
- (tr (if incoming
- "workspace.branches.review.facts.copies-orphaned-update"
- "workspace.branches.review.facts.copies-orphaned-merge")
- (i18n/c copies))])
+ (if incoming
+ (tr "workspace.branches.review.facts.copies-orphaned-update" (i18n/c copies))
+ (tr "workspace.branches.review.facts.copies-orphaned-merge" (i18n/c copies)))])
[:> effects* {:item item :items items :objects objects
:inner inner :incoming incoming}]])))
@@ -252,10 +251,9 @@
(and deleted? (pos? n))
[:> brl/notice* {:level :warning
:title (tr "workspace.branches.review.facts.used-title" (i18n/c n))}
- (tr (if (= kind :component)
- "workspace.branches.review.facts.deleted-component-used"
- "workspace.branches.review.facts.deleted-used")
- (i18n/c n))]
+ (if (= kind :component)
+ (tr "workspace.branches.review.facts.deleted-component-used" (i18n/c n))
+ (tr "workspace.branches.review.facts.deleted-used" (i18n/c n)))]
deleted?
[:> brl/notice* {:level :success
@@ -265,10 +263,9 @@
:else
[:> fact-list*
{:rows [[(tr "workspace.branches.review.facts.used-by")
- (tr (if (= kind :component)
- "workspace.branches.review.facts.copies"
- "workspace.branches.review.facts.layers")
- (i18n/c n))]]}]))))
+ (if (= kind :component)
+ (tr "workspace.branches.review.facts.copies" (i18n/c n))
+ (tr "workspace.branches.review.facts.layers" (i18n/c n)))]]}]))))
;; --- Component copies
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 1be448d20d..8e23f0414c 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
@@ -2,7 +2,7 @@
// 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 INC Sucursal en España SL
+// Copyright (c) KALEIDOS SUBSIDIARY SL
@use "ds/_borders.scss" as *;
@use "ds/_sizes.scss" as *;
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 15a56cab79..1387a59ff2 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
@@ -2,7 +2,7 @@
;; 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 INC Sucursal en España SL
+;; 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
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 5da607cfd7..18997f9abd 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
@@ -2,7 +2,7 @@
// 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 INC Sucursal en España SL
+// Copyright (c) KALEIDOS SUBSIDIARY SL
@use "ds/_borders.scss" as *;
@use "ds/_sizes.scss" as *;
@@ -26,7 +26,7 @@
.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%, #{px2rem(400)});
+ --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
@@ -41,7 +41,7 @@
#{px2rem(600)}
);
- max-inline-size: min(var(--review-modal-inline-size), calc(100vw - #{px2rem(32)}));
+ max-inline-size: min(var(--review-modal-inline-size), calc(100vw - #{$sz-32}));
overflow: hidden;
}
@@ -52,6 +52,8 @@
}
.header-icon {
+ --header-icon-color: var(--color-foreground-secondary);
+
display: flex;
flex-shrink: 0;
align-items: center;
@@ -59,11 +61,11 @@
inline-size: $sz-32;
block-size: $sz-32;
border-radius: $br-8;
- color: var(--color-foreground-secondary);
+ color: var(--header-icon-color);
background-color: var(--color-background-tertiary);
&.is-warning {
- color: var(--color-accent-warning);
+ --header-icon-color: var(--color-accent-warning);
}
}
@@ -194,6 +196,7 @@
}
.notice-title {
+ // TODO: 600 is not a weight of the DS typographies.
font-weight: 600;
}
@@ -249,6 +252,9 @@
@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;
}
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
index 9edbc319a1..94f3e40797 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/previews.cljs
+++ b/frontend/src/app/main/ui/workspace/sidebar/branch_review/previews.cljs
@@ -2,7 +2,7 @@
;; 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 INC Sucursal en España SL
+;; 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
@@ -138,7 +138,6 @@
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."
- {::mf/private true}
[{:keys [shape objects highlight]}]
(let [{:keys [x y width height]} (shape-bounds shape)
width (max 1 width)
@@ -212,20 +211,24 @@
(case reason
:absent
[i/add
- (tr (if main? "workspace.branches.review.missing.not-in-main"
- "workspace.branches.review.missing.not-in-branch"))
- (tr (if main? "workspace.branches.review.missing.new-in-branch"
- "workspace.branches.review.missing.new-in-main"))]
+ (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
- (tr (if main? "workspace.branches.review.missing.deleted-in-main"
- "workspace.branches.review.missing.deleted-in-branch"))
+ (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))
- (tr (if main? "workspace.branches.review.missing.open-main"
- "workspace.branches.review.missing.open-branch")))])]
+ (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]
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
index 37f7fe741e..4051356ad9 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/branch_review/previews.scss
+++ b/frontend/src/app/main/ui/workspace/sidebar/branch_review/previews.scss
@@ -2,10 +2,9 @@
// 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 INC Sucursal en España SL
+// Copyright (c) KALEIDOS SUBSIDIARY SL
@use "ds/_borders.scss" as *;
-@use "ds/_utils.scss" as *;
@use "ds/typography.scss" as *;
.preview-svg {
@@ -18,6 +17,7 @@
.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;
@@ -38,6 +38,9 @@
@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;
}
@@ -51,6 +54,7 @@
// 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;
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branches.cljs b/frontend/src/app/main/ui/workspace/sidebar/branches.cljs
index d335caa37e..36cf1fc59a 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/branches.cljs
+++ b/frontend/src/app/main/ui/workspace/sidebar/branches.cljs
@@ -7,16 +7,23 @@
(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.drawing :as dwd]
+ [app.main.data.workspace.layout :as dwlo]
[app.main.data.workspace.pull-requests :as dwpr]
+ [app.main.data.workspace.review :as dwrv]
+ [app.main.data.workspace.tasks :as dwtk]
[app.main.refs :as refs]
+ [app.main.repo :as rp]
[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.controls.input :refer [input*]]
[app.main.ui.ds.foundations.assets.icon :as i]
[app.main.ui.ds.layout.menu :refer [menu* menu-item* menu-separator*]]
@@ -26,7 +33,7 @@
[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.hooks.resize :as r]
+ [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]
@@ -35,6 +42,7 @@
[app.util.globals :as globals]
[app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd]
+ [beicon.v2.core :as rx]
[cuerdas.core :as str]
[goog.events :as events]
[okulary.core :as l]
@@ -264,6 +272,16 @@
(let [comment* (mf/use-state "")
comment (deref comment*)
+ ;; the open tasks of the branch move to main as they are; their
+ ;; assignees may be told
+ tasks* (mf/use-state nil)
+ notify* (mf/use-state true)
+ notify? (deref notify*)
+ open-tasks (->> (deref tasks*)
+ (remove dwtk/closed?)
+ (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)
@@ -302,11 +320,20 @@
on-submit
(mf/use-fn
- (mf/deps branch comment excluded)
+ (mf/deps branch comment excluded notify? open-tasks)
(fn [_]
- (st/emit! (dwb/merge-branch branch {:comment comment :excluded excluded})
+ (st/emit! (dwb/merge-branch branch {:comment comment
+ :excluded excluded
+ :notify-assignees (boolean (and notify? (seq open-tasks)))})
(modal/hide))))]
+ (mf/with-effect [branch]
+ (when-let [branch-file-id (:branch-file-id branch)]
+ (when (dwtk/enabled?)
+ (->> (rp/cmd! :get-file-tasks {:file-id branch-file-id})
+ (rx/subs! #(reset! tasks* %)
+ (fn [_] (reset! tasks* [])))))))
+
[:> modal* {:is-open true
:on-open-change (prui/on-dismiss on-close)}
[:> modal-header* {:title (tr "workspace.branches.merge.confirm-title")}]
@@ -336,6 +363,21 @@
:on-change on-comment-change
:rows 3}]]
+ (when (seq open-tasks)
+ [:div {:class (stl/css :merge-tasks)}
+ [:> context-notification* {:level :warning :type :context}
+ (tr "workspace.branches.merge.open-tasks" (i18n/c (count open-tasks)))]
+ [:span {:class (stl/css :field-label)}
+ (tr "workspace.branches.merge.open-tasks-title")]
+ [:> rvt/task-list* {:tasks (vec (take 3 open-tasks))}]
+ (when (> (count open-tasks) 3)
+ [:span {:class (stl/css :merge-tasks-more)}
+ (tr "workspace.branches.merge.more-open-tasks" (i18n/c (- (count open-tasks) 3)))])
+ [:> checkbox* {:id "merge-notify-assignees"
+ :checked notify?
+ :on-change on-notify
+ :label (tr "workspace.branches.merge.notify-assignees")}]])
+
(if (pos? left-out)
;; deleting the branch takes the changes left out with it
[:> context-notification* {:level :warning :type :context}
@@ -349,7 +391,9 @@
[:> button* {:variant "primary"
:icon i/git-merge
:on-click on-submit}
- (tr "workspace.branches.merge.confirm-accept")]]]))
+ (if (seq open-tasks)
+ (tr "workspace.branches.merge.confirm-anyway")
+ (tr "workspace.branches.merge.confirm-accept"))]]]))
;; --- Confirmation for relevant branch actions (merge / update / materialize)
@@ -463,10 +507,10 @@
:status-merged merged?
:status-archived (= "archived" status)
:status-open (= "open" status))}
- (tr (case status
- "merged" "workspace.branches.info.status.merged"
- "archived" "workspace.branches.info.status.archived"
- "workspace.branches.info.status.open"))]]
+ (case status
+ "merged" (tr "workspace.branches.info.status.merged")
+ "archived" (tr "workspace.branches.info.status.archived")
+ (tr "workspace.branches.info.status.open"))]]
[:> modal-content* {:class (stl/css :dialog-content)}
;; description: shown read-only, editable inline by the author
@@ -477,7 +521,7 @@
[:> 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)
+ [:textarea {:class (stl/css :textarea :info-desc-input)
:value desc
:on-change on-desc-change
:rows 3
@@ -827,9 +871,9 @@
;; a merged branch cannot go back to work: its changes are in main
(when-not merged?
[:> menu-item* {:id "archive" :on-action on-archive}
- (tr (if archived?
- "workspace.branches.menu.restore"
- "workspace.branches.menu.archive"))])
+ (if archived?
+ (tr "workspace.branches.menu.restore")
+ (tr "workspace.branches.menu.archive"))])
;; a merged branch has its work in main already: only an open or an
;; archived branch can leave the branch engine as an ordinary file
(when-not merged?
@@ -1019,22 +1063,17 @@
;; --- Branch context banner (shown while editing a branch)
-(defn- publish-banner-clearance!
- "Publish the room the branch banner takes from the bottom edge of the
- canvas as `--branch-banner-clearance` on the app root, which the floating
- colour/typography palette bar reads to lift itself clear (`palette.scss`):
- the banner and the bar hang from the same edge and the bar draws over the
- banner's controls. The room is measured from the banner's live box rather
- than written down, so it follows the banner in both the collapsed and the
- expanded state, where one fixed offset would be wrong in one of the two."
- []
- (when-let [root (dom/get-root)]
- (when-let [node (dom/get-element "branch-banner")]
- (let [room (- (:bottom (dom/get-bounding-rect root))
- (:top (dom/get-bounding-rect node)))]
- (dom/set-css-property! root
- "--branch-banner-clearance"
- (dm/str (max 0 room) "px"))))))
+(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
@@ -1093,9 +1132,13 @@
merged? (= "merged" (:status ctx))
archived? (= "archived" (:status ctx))
- collapsed* (mf/use-state false)
- collapsed? (deref collapsed*)
- on-toggle (mf/use-fn #(swap! collapsed* not))
+ ;; it shares its level with the palettes: only one of them is open
+ has-bar? (some? ctx)
+ vport (mf/deref refs/workspace-vport)
+ rulers? (mf/deref refs/rulers?)
+ bottom-bar (mf/deref refs/bottom-bar)
+ collapsed? (and (some? bottom-bar) (not= :branch bottom-bar))
+ on-toggle (mf/use-fn #(st/emit! (dwlo/toggle-bottom-bar :branch)))
;; persistence status drives a refetch of the change counts on save
persistence (mf/deref refs/persistence)
@@ -1182,22 +1225,34 @@
"delete" (confirm-delete! ctx (:source-file-id ctx))
nil)))
- ;; publishes the room the banner takes from the bottom of the canvas
- ;; whenever its box changes size, which is what keeps the floating
- ;; colour/typography palette bar clear of it in both the collapsed and
- ;; the expanded state (see `publish-banner-clearance!`)
- banner-ref (r/use-resize-observer
- (mf/use-fn (fn [_ _] (publish-banner-clearance!))))
+ status (banner-status ctx open-pr)
- status (banner-status ctx open-pr)]
+ handle-label (if collapsed?
+ (tr "workspace.branches.banner.expand")
+ (tr "workspace.branches.banner.collapse"))
+
+ ;; the tasks of the open review that still need the user's work
+ tasks (mf/deref refs/tasks)
+ my-tasks (mf/with-memo [tasks open-pr profile]
+ (when (some? open-pr)
+ (count (dwtk/tasks-for (dwtk/review-tasks (vals tasks) (:id open-pr))
+ (:id profile)))))
+
+ on-my-tasks
+ (mf/use-fn
+ (fn [_]
+ (st/emit! (dwrv/set-panel-tab :tasks)
+ (dwrv/set-task-filter :mine)
+ (dwd/select-for-drawing :comments))))]
(mf/with-effect [file-id]
(when (contains? cf/flags :branching)
(st/emit! (dwb/fetch-branch-context)))
;; the primary action depends on whether the branch already has an
- ;; open pull request
+ ;; open pull request, and the bar counts the tasks for the user
(when (dwpr/enabled?)
- (st/emit! (dwpr/fetch-pull-requests))))
+ (st/emit! (dwpr/fetch-pull-requests)
+ (dwtk/fetch-tasks))))
;; refresh the change counts every time a save settles (and when
;; returning to the tab, so "main advanced" is surfaced too)
@@ -1212,31 +1267,22 @@
(st/emit! (dwb/fetch-branch-context)))))]
(fn [] (events/unlistenByKey key))))
- ;; it is cleared when there is no banner to clear, so a file that is not a
- ;; branch leaves the palette bar on its plain bottom anchor
- (mf/with-effect [ctx]
- (if (some? ctx)
- (publish-banner-clearance!)
- (dom/unset-css-property! (dom/get-root) "--branch-banner-clearance")))
-
- ;; the same goes when the banner goes away with the component, so nothing
- ;; is left behind for the palette bar to clear later
- (mf/with-effect []
- (fn [] (dom/unset-css-property! (dom/get-root) "--branch-banner-clearance")))
+ ;; a file that is not a branch has no bar, and the palettes stay as ever
+ (mf/with-effect [has-bar?]
+ (when has-bar?
+ (st/emit! (dwlo/mount-bottom-bars))
+ (fn [] (st/emit! (dwlo/unmount-bottom-bars)))))
(when ctx
[:div {:id "branch-banner"
- :ref banner-ref
+ :style (when (some? vport)
+ #js {"insetInlineStart" (dm/str (canvas-center vport rulers?) "px")})
:class (stl/css-case :branch-banner true
:branch-banner-merged (or merged? archived?)
:is-collapsed collapsed?)}
[:button {:class (stl/css :branch-banner-handle)
- :title (tr (if collapsed?
- "workspace.branches.banner.expand"
- "workspace.branches.banner.collapse"))
- :aria-label (tr (if collapsed?
- "workspace.branches.banner.expand"
- "workspace.branches.banner.collapse"))
+ :title handle-label
+ :aria-label handle-label
:on-click on-toggle}
[:div {:class (stl/css :branch-banner-handle-btn)}]]
;; the header row names the branch; the banner says where it
@@ -1246,9 +1292,19 @@
: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)]]
+ [: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?
diff --git a/frontend/src/app/main/ui/workspace/sidebar/branches.scss b/frontend/src/app/main/ui/workspace/sidebar/branches.scss
index 4fdde3b300..9d50c67a37 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/branches.scss
+++ b/frontend/src/app/main/ui/workspace/sidebar/branches.scss
@@ -170,6 +170,18 @@
color: var(--color-foreground-primary);
}
+.merge-tasks {
+ display: flex;
+ flex-direction: column;
+ gap: var(--sp-s);
+}
+
+.merge-tasks-more {
+ @include use-typography("body-small");
+
+ color: var(--color-accent-primary);
+}
+
.merge-summary {
@include use-typography("body-small");
@@ -276,9 +288,11 @@
min-block-size: $sz-28;
}
+// as high as 400px; a longer description scrolls inside
.info-desc {
@include use-typography("body-medium");
+ max-block-size: px2rem(400);
margin: 0;
padding: var(--sp-s);
border-radius: $br-8;
@@ -286,6 +300,7 @@
color: var(--color-foreground-primary);
white-space: pre-wrap;
overflow-wrap: break-word;
+ overflow-y: auto;
}
.info-desc-empty {
@@ -303,6 +318,11 @@
display: flex;
flex-direction: column;
gap: var(--sp-s);
+
+ // room to write: as high as the description may grow while read
+ .info-desc-input {
+ min-block-size: px2rem(400);
+ }
}
.info-desc-actions {
@@ -374,7 +394,9 @@
.branch-banner {
position: absolute;
- inset-block-end: var(--sp-xs);
+
+ // clear of the scroll of the canvas, at the level of the review banner
+ inset-block-end: var(--sp-m);
inset-inline-start: 50%;
transform: translateX(-50%);
max-inline-size: 90vw;
@@ -382,15 +404,6 @@
border: $b-2 solid var(--color-background-quaternary);
background-color: var(--color-background-primary);
- // The floating colour and typography palette bar hangs from the same bottom
- // edge of the canvas, and it draws over the banner's controls. The banner
- // publishes the room it takes from that edge, measured from its own box, as
- // `--branch-banner-clearance` on the app root
- // (`branches.cljs::publish-banner-clearance!`), and the palette bar lifts
- // itself by that value (`workspace/palette.scss`). One measured value, so
- // the bar follows the banner's collapsed and expanded states and the two
- // cannot drift apart.
-
// 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.
@@ -482,6 +495,15 @@
white-space: nowrap;
}
+.branch-banner-review {
+ color: var(--color-foreground-secondary);
+ white-space: nowrap;
+}
+
+.branch-banner-tasks {
+ --banner-button-gap: var(--sp-xs);
+}
+
.branch-banner-icon-warning {
color: var(--color-accent-warning);
}
diff --git a/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs b/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs
index 6438e63914..ce048433eb 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs
+++ b/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs
@@ -25,7 +25,7 @@
[app.main.ui.hooks :as hooks]
[app.main.ui.workspace.sidebar.layer-name :refer [layer-name*]]
[app.util.dom :as dom]
- [app.util.i18n :refer [tr]]
+ [app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd]
[app.util.shape-icon :as usi]
[app.util.timers :as ts]
@@ -59,6 +59,18 @@
(when (seq enter)
(apply st/emit! (map dw/highlight-shape enter))))))))
+(mf/defc layer-comments-count*
+ "The open comment threads that point at the layer, when it has any."
+ {::mf/private true}
+ [{:keys [id]}]
+ (let [counts (mf/deref refs/layer-comment-counts)
+ total (get counts id 0)]
+ (when (pos? total)
+ [:span {:class (stl/css :comments-count)
+ :title (tr "workspace.sidebar.layers.comments" (i18n/c total))}
+ [:> icon* {:icon-id i/comments :size "s"}]
+ total])))
+
(mf/defc layer-item-inner*
[{:keys [item depth parent-size name-ref children ref style rename-id
;; Flags
@@ -176,7 +188,8 @@
:variant-error variant-error
:component-id component-id
:is-hidden hidden?
- :on-tab-press on-tab-press}]]
+ :on-tab-press on-tab-press}]
+ [:> layer-comments-count* {:id id}]]
(when (not ^boolean is-read-only)
[:div {:class (stl/css-case
:element-actions true
diff --git a/frontend/src/app/main/ui/workspace/sidebar/layer_item.scss b/frontend/src/app/main/ui/workspace/sidebar/layer_item.scss
index 18a1395d52..f6b2ce1ac3 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/layer_item.scss
+++ b/frontend/src/app/main/ui/workspace/sidebar/layer_item.scss
@@ -7,6 +7,7 @@
@use "ds/_utils.scss" as *;
@use "ds/borders.scss" as *;
@use "ds/_sizes.scss" as *;
+@use "ds/typography.scss" as *;
.layer-row {
--layer-indentation-size: var(--sp-xxl);
@@ -328,3 +329,14 @@
min-height: 1px;
pointer-events: none;
}
+
+.comments-count {
+ @include use-typography("body-small");
+
+ display: inline-flex;
+ flex-shrink: 0;
+ align-items: center;
+ gap: var(--sp-xxs);
+ padding-inline-end: var(--sp-s);
+ color: var(--color-accent-info);
+}
diff --git a/frontend/src/app/main/ui/workspace/sidebar/options.scss b/frontend/src/app/main/ui/workspace/sidebar/options.scss
index 54b1702a1e..fb78f7a7f1 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/options.scss
+++ b/frontend/src/app/main/ui/workspace/sidebar/options.scss
@@ -31,7 +31,9 @@
/* FIXME: This is hacky and prone to break, we should tackle the whole layout
of the sidebar differently */
- --sidebar-element-options-height: calc(100vh - #{$sz-88});
+ // The whole sidebar below its header, unless the panel that holds the
+ // options gives them its own space (`--options-available-height`).
+ --sidebar-element-options-height: var(--options-available-height, calc(100vh - #{$sz-88}));
height: var(--sidebar-element-options-height);
padding-block-start: var(--sp-s);
@@ -39,7 +41,10 @@
.read-only {
grid-template-areas: "right-sidebar";
- padding: var(--sp-s);
+ padding: var(--options-read-only-padding, var(--sp-s));
+
+ // the grid row of `.tool-window` must not grow with what the inspect holds
+ min-block-size: 0;
}
.design-options,
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 f9c485f97f..8159ab7fc6 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/pull_requests.cljs
+++ b/frontend/src/app/main/ui/workspace/sidebar/pull_requests.cljs
@@ -2,7 +2,7 @@
;; 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 INC Sucursal en España SL
+;; Copyright (c) KALEIDOS SUBSIDIARY SL
(ns app.main.ui.workspace.sidebar.pull-requests
"Pull request UI. A pull request is presented as a STATE of its branch
@@ -19,6 +19,7 @@
[app.main.data.modal :as modal]
[app.main.data.team :as dtm]
[app.main.data.workspace.pull-requests :as dwpr]
+ [app.main.data.workspace.review :as dwrv]
[app.main.refs :as refs]
[app.main.store :as st]
[app.main.ui.ds.buttons.button :refer [button*]]
@@ -32,7 +33,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.branch-pill :refer [branch-pill*]]
+ [app.main.ui.ds.product.progress-bar :refer [progress-bar*]]
+ [app.main.ui.ds.tooltip :refer [tooltip*]]
[app.util.dom :as dom]
[app.util.i18n :refer [tr]]
[cuerdas.core :as str]
@@ -53,13 +55,15 @@
"in-review" :in-review
:open)))
-(def ^:private state->label
- {:open "workspace.pull-requests.state.open"
- :in-review "workspace.pull-requests.state.in-review"
- :approved "workspace.pull-requests.state.approved"
- :changes-requested "workspace.pull-requests.state.changes-requested"
- :merged "workspace.pull-requests.state.merged"
- :closed "workspace.pull-requests.state.closed"})
+(defn- state-label
+ [state]
+ (case state
+ :open (tr "workspace.pull-requests.state.open")
+ :in-review (tr "workspace.pull-requests.state.in-review")
+ :approved (tr "workspace.pull-requests.state.approved")
+ :changes-requested (tr "workspace.pull-requests.state.changes-requested")
+ :merged (tr "workspace.pull-requests.state.merged")
+ :closed (tr "workspace.pull-requests.state.closed")))
(mf/defc pr-state-badge*
[{:keys [pr]}]
@@ -71,7 +75,7 @@
:badge-changes (= state :changes-requested)
:badge-merged (= state :merged)
:badge-closed (= state :closed))}
- (tr (get state->label state))]))
+ (state-label state)]))
(defn current-approvals
"[current-approvals total-reviewers] of a pull request; stale verdicts
@@ -86,6 +90,7 @@
counts feed their action buttons)."
[pr]
{:id (:file-branch-id pr)
+ :branch-file-id (:source-file-id pr)
:name (:branch-name pr)
:status "open"
:ahead (:ahead pr)
@@ -120,6 +125,16 @@
:accept-style :danger
:on-accept (fn [_] (st/emit! (dwpr/close-pull-request (:id pr))))})))
+;; --- The action of a banner
+
+(mf/defc banner-button*
+ "A quiet action inside a banner on the canvas, with what it does as
+ `children`."
+ [{:keys [class children] :rest props}]
+ (let [props (mf/spread-props props {:class [class (stl/css :banner-button)]
+ :type "button"})]
+ [:> :button props children]))
+
;; --- Dialog header
(mf/defc dialog-header*
@@ -246,15 +261,17 @@
[:> avatar* {:profile member :variant "S"}]
[:span {:class (stl/css :reviewer-name)} (:fullname member)]
(when (contains? selected (:id member))
- [:> i/icon* {:icon-id i/tick :size "s"}])]])])]
+ [:> i/icon* {:icon-id i/tick :size "s" :class (stl/css :reviewer-tick)}])]])])]
[:> context-notification* {:level :info :type :context}
(tr "workspace.pull-requests.create.info")]]
[:> modal-footer* {:class (stl/css :dialog-footer)}
- [:> button* {:variant "secondary" :on-click on-close}
+ [:> button* {:class (stl/css :dialog-action)
+ :variant "secondary" :on-click on-close}
(tr "labels.cancel")]
- [:> button* {:variant "primary"
+ [:> button* {:class (stl/css :dialog-action)
+ :variant "primary"
:icon i/git-pull-request-create-arrow
:disabled (not valid?)
:on-click on-submit}
@@ -333,9 +350,11 @@
:rows 3}]]]
[:> modal-footer* {:class (stl/css :dialog-footer)}
- [:> button* {:variant "secondary" :on-click on-close}
+ [:> button* {:class (stl/css :dialog-action)
+ :variant "secondary" :on-click on-close}
(tr "labels.cancel")]
- [:> button* {:variant "primary"
+ [:> button* {:class (stl/css :dialog-action)
+ :variant "primary"
:on-click on-submit}
(tr "workspace.pull-requests.review.submit")]]]))
@@ -407,7 +426,7 @@
;; the route reads branch → target BRANCH (reviews always merge
;; into main); the target file name would be redundant here,
;; inside the file itself
- (dm/str (:branch-name pr) " → " (tr "workspace.branches.main"))]
+ (tr "workspace.review.route" (:branch-name pr) (tr "workspace.branches.main"))]
(when (and open? (:outdated pr))
[:span {:class (stl/css :pr-badge :badge-outdated)}
(tr "workspace.pull-requests.badge.outdated")])
@@ -470,117 +489,106 @@
:else
(tr "workspace.pull-requests.review-state.pending"))]
(when-not (str/blank? (:comment review))
- [:p {:class (stl/css :reviewer-comment)} (:comment review)])]))]])]
+ [:> text* {:as "p" :typography t/body-small :class (stl/css :reviewer-comment)}
+ (:comment review)])]))]])]
(when-not (str/blank? (:description pr))
[:div {:class (stl/css :pr-info-description-block)}
[:label {:class (stl/css :field-label)}
(tr "workspace.pull-requests.info.description")]
- [:p {:class (stl/css :pr-info-description)} (:description pr)]])]
+ [:> text* {:as "p" :typography t/body-medium :class (stl/css :pr-info-description)}
+ (:description pr)]])]
[:> modal-footer* {:class (stl/css :dialog-footer)}
(when (and (or author? admin?) open?)
- [:> button* {:variant "secondary"
+ [:> button* {:class (stl/css :dialog-action)
+ :variant "secondary"
:on-click on-close-pr}
(tr "workspace.pull-requests.actions.close")])
(when (and (or author? admin?) closed?)
- [:> button* {:variant "secondary"
+ [:> button* {:class (stl/css :dialog-action)
+ :variant "secondary"
:on-click on-reopen-pr}
(tr "workspace.pull-requests.actions.reopen")])
(when (and open? (not reviewing?))
- [:> button* {:variant "primary"
+ [:> button* {:class (stl/css :dialog-action)
+ :variant "primary"
:icon i/arrow-up-right
:on-click on-open-review}
(tr "workspace.pull-requests.actions.open-review")])
(when (and open? can-merge?)
- [:> button* {:variant "primary"
+ [:> button* {:class (stl/css :dialog-action)
+ :variant "primary"
:icon i/git-merge
:on-click on-merge}
(tr "workspace.pull-requests.actions.merge")])]]))
-;; --- Review sandbox banner (replaces the branch banner inside a sandbox)
+;; --- Review bar (replaces the branch banner inside a design review)
(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
+ the reviewer and the way out. The review is read-only; merging and
+ cancelling the review sit behind the menu.
+
+ When the branch moved past what the review shows, its author gets the
+ button that publishes the latest changes; everybody else gets a badge
+ that says the branch has changes they cannot see yet."
[]
- (let [preview (mf/deref refs/pull-request-preview)
- pr (:info preview)
- profile (mf/deref refs/profile)
- team (mf/deref refs/team)
- author? (= (:created-by pr) (:id profile))
- reviewer? (some #(= (:profile-id %) (:id profile)) (:reviews pr))
- ;; merging requires edition permissions on main, not on the open
- ;; branch file, so the team role tells whether this user could
- ;; integrate the branch
+ (let [preview (mf/deref refs/pull-request-preview)
+ pr (:info preview)
+ profile (mf/deref refs/profile)
+ team (mf/deref refs/team)
+ tasks* (mf/deref refs/tasks)
+ author? (= (:created-by pr) (:id profile))
+ reviewer? (some #(= (:profile-id %) (:id profile)) (:reviews pr))
can-merge? (boolean (get-in team [:permissions :can-edit]))
- ;; same rule as the details dialog's "Cancel pull request"
can-cancel? (and (or author? (boolean (get-in team [:permissions :is-admin])))
(= "open" (:status pr)))
- [approvals total] (current-approvals pr)
+ outdated? (boolean (:outdated pr))
- collapsed* (mf/use-state false)
- collapsed? (deref collapsed*)
- on-toggle (mf/use-fn #(swap! collapsed* not))
+ tasks (mf/with-memo [tasks* pr]
+ (filterv #(= (:id pr) (:pull-request-id %)) (vals tasks*)))
+ closed (count (filter #(contains? #{"verified" "wont-do"} (:status %)) tasks))
+ total (count tasks)
- ;; secondary actions live behind the kebab menu so the banner
- ;; only exposes the essential ones (compare / review)
menu-open* (mf/use-state false)
menu-open? (deref menu-open*)
on-toggle-menu (mf/use-fn #(swap! menu-open* not))
on-menu-change (mf/use-fn #(reset! menu-open* %))
- on-info
- (mf/use-fn
- (mf/deps pr)
- (fn [_]
- (reset! menu-open* false)
- (modal/show! :pull-request-info {:pr pr})))
+ on-details
+ (mf/use-fn #(st/emit! (dwrv/open-details "overview")))
- on-compare
- (mf/use-fn (mf/deps pr) #(open-compare! pr))
+ on-tasks
+ (mf/use-fn #(st/emit! (dwrv/set-panel-tab :tasks)))
on-review
(mf/use-fn (mf/deps pr) #(modal/show! :pull-request-review {:pr pr}))
on-exit
- (mf/use-fn
- (fn [_]
- (reset! menu-open* false)
- (st/emit! (dwpr/exit-pull-request-preview))))
-
- on-merge
- (mf/use-fn
- (mf/deps pr)
- (fn [_]
- (reset! menu-open* false)
- (confirm-merge! pr)))
-
- on-cancel
- (mf/use-fn
- (mf/deps pr)
- (fn [_]
- (reset! menu-open* false)
- (confirm-close! pr)))
+ (mf/use-fn #(st/emit! (dwpr/exit-pull-request-preview)))
on-publish
(mf/use-fn
(mf/deps pr)
- (fn [_]
+ #(st/emit! (dwpr/update-pull-request-snapshot (:id pr))))
+
+ on-menu-action
+ (mf/use-fn
+ (mf/deps pr)
+ (fn [action]
(reset! menu-open* false)
- (st/emit! (dwpr/update-pull-request-snapshot (:id pr))
- (dwpr/refresh-pull-request-preview-info (:id pr)))))]
+ (case action
+ "compare" (open-compare! pr)
+ "merge" (confirm-merge! pr)
+ "cancel" (confirm-close! pr)
+ nil)))]
(when (some? pr)
- [:div {:class (stl/css-case :pr-banner true
- :is-collapsed collapsed?)}
- [:button {:class (stl/css :pr-banner-handle)
- :title (tr (if collapsed?
- "workspace.branches.banner.expand"
- "workspace.branches.banner.collapse"))
- :aria-label (tr (if collapsed?
- "workspace.branches.banner.expand"
- "workspace.branches.banner.collapse"))
- :on-click on-toggle}
- [:div {:class (stl/css :pr-banner-handle-btn)}]]
+ [:div {:class (stl/css :pr-banner)
+ :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}]]
@@ -588,41 +596,47 @@
[:span {:class (stl/css :pr-banner-title)}
(tr "workspace.pull-requests.banner.reviewing")]
[:span {:class (stl/css :pr-banner-name)} (:title pr)]
- [:span {:class (stl/css :pr-banner-route)}
- [:> branch-pill* {:label (:branch-name pr) :is-review true}]
- [:> i/icon* {:icon-id i/arrow-long-right :size "s"}]
- [:> branch-pill* {:label (tr "workspace.branches.main") :is-main true}]]]
+ ;; 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-badges)}
- [:> pr-state-badge* {:pr pr}]
- (when (:outdated pr)
- [:span {:class (stl/css :pr-badge :badge-outdated)}
- (tr "workspace.pull-requests.badge.outdated")])
- (when (pos? (or (:conflicts pr) 0))
- [:span {:class (stl/css :pr-badge :badge-conflicts)}
- (tr "workspace.pull-requests.badge.conflicts" (dm/str (:conflicts pr)))])
- (when (pos? total)
- [:span {:class (stl/css :pr-banner-approvals)}
- [:> i/icon* {:icon-id i/tick :size "s"}]
- (dm/str approvals "/" total)])]
+ [: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}]]
+
+ [:div {:class (stl/css :pr-banner-separator)}]])
[:div {:class (stl/css :pr-banner-actions)}
- [:> button* {:variant "secondary"
- :icon i/git-compare-arrows
- :on-click on-compare}
- (tr "workspace.branches.compare")]
-
+ [:> 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"
- :icon i/tick
- :on-click on-review}
- (tr "workspace.pull-requests.banner.review")])
+ [:> button* {:variant "primary" :on-click on-review}
+ (tr "workspace.review.submit")])
+ [:> button* {:variant "ghost" :on-click on-exit}
+ (tr "workspace.pull-requests.banner.exit")]
- ;; the banner sits at the bottom of the canvas: its menu opens
- ;; upwards
+ ;; 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
@@ -631,16 +645,11 @@
:aria-label (tr "labels.options")
:aria-pressed menu-open?
:on-click on-toggle-menu}])}
- [:> menu-item* {:id "info" :on-action on-info}
- (tr "workspace.pull-requests.menu.info")]
- (when (and author? (:outdated pr))
- [:> menu-item* {:id "publish" :on-action on-publish}
- (tr "workspace.pull-requests.banner.publish")])
+ [:> menu-item* {:id "compare"}
+ (tr "workspace.branches.compare")]
(when can-merge?
- [:> menu-item* {:id "merge" :on-action on-merge}
+ [:> menu-item* {:id "merge"}
(tr "workspace.pull-requests.actions.merge")])
- [:> menu-item* {:id "exit" :on-action on-exit}
- (tr "workspace.pull-requests.banner.exit")]
(when can-cancel?
- [:> menu-item* {:id "cancel" :on-action on-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 de59e91089..a9b193cc3c 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/pull_requests.scss
+++ b/frontend/src/app/main/ui/workspace/sidebar/pull_requests.scss
@@ -2,10 +2,11 @@
// 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 INC Sucursal en España SL
+// Copyright (c) KALEIDOS SUBSIDIARY SL
@use "ds/_borders.scss" as *;
@use "ds/_sizes.scss" as *;
+@use "ds/_utils.scss" as *;
@use "ds/typography.scss" as *;
// --- State badges
@@ -15,47 +16,37 @@
padding: var(--sp-xxs) var(--sp-s);
border-radius: $br-12;
+ background-color: var(--pr-badge-bg-color);
+ color: var(--pr-badge-fg-color);
white-space: nowrap;
}
-.badge-open {
- color: var(--color-accent-info);
- background-color: var(--color-background-info);
-}
-
+.badge-open,
.badge-in-review {
- color: var(--color-accent-info);
- background-color: var(--color-background-info);
-}
-
-.badge-approved {
- color: var(--color-accent-success);
- background-color: var(--color-background-success);
-}
-
-.badge-changes {
- color: var(--color-accent-warning);
- background-color: var(--color-background-warning);
+ --pr-badge-bg-color: var(--color-background-info);
+ --pr-badge-fg-color: var(--color-accent-info);
}
+.badge-approved,
.badge-merged {
- color: var(--color-accent-success);
- background-color: var(--color-background-success);
+ --pr-badge-bg-color: var(--color-background-success);
+ --pr-badge-fg-color: var(--color-accent-success);
+}
+
+.badge-changes,
+.badge-outdated {
+ --pr-badge-bg-color: var(--color-background-warning);
+ --pr-badge-fg-color: var(--color-accent-warning);
}
.badge-closed {
- color: var(--color-foreground-secondary);
- background-color: var(--color-background-tertiary);
-}
-
-.badge-outdated {
- color: var(--color-accent-warning);
- background-color: var(--color-background-warning);
+ --pr-badge-bg-color: var(--color-background-tertiary);
+ --pr-badge-fg-color: var(--color-foreground-secondary);
}
.badge-conflicts {
- color: var(--color-foreground-error);
- background-color: var(--color-background-error);
+ --pr-badge-bg-color: var(--color-background-error);
+ --pr-badge-fg-color: var(--color-foreground-error);
}
// --- Dialogs (create / review / details)
@@ -69,6 +60,8 @@
}
.dialog-header-icon {
+ --dialog-header-icon-color: var(--color-accent-primary);
+
display: flex;
flex-shrink: 0;
align-items: center;
@@ -76,11 +69,11 @@
inline-size: $sz-32;
block-size: $sz-32;
border-radius: $br-8;
- color: var(--color-accent-primary);
+ color: var(--dialog-header-icon-color);
background-color: var(--color-background-tertiary);
&.is-warning {
- color: var(--color-accent-warning);
+ --dialog-header-icon-color: var(--color-accent-warning);
}
}
@@ -118,11 +111,10 @@
// long labels: the row of actions wraps, never the label inside a button
.dialog-footer {
flex-wrap: wrap;
+}
- // button: the DS buttons in the footer take no class from this module
- button {
- white-space: nowrap;
- }
+.dialog-action {
+ white-space: nowrap;
}
.field {
@@ -170,30 +162,33 @@
}
.reviewer-option {
+ --reviewer-option-bg-color: transparent;
+ --reviewer-option-border-color: transparent;
+
display: flex;
align-items: center;
gap: var(--sp-s);
inline-size: 100%;
padding: var(--sp-xs) var(--sp-s);
- border: $b-1 solid transparent;
+ border: $b-1 solid var(--reviewer-option-border-color);
border-radius: $br-8;
- background: none;
+ background: var(--reviewer-option-bg-color);
cursor: pointer;
color: var(--color-foreground-primary);
&:hover {
- background-color: var(--color-background-tertiary);
+ --reviewer-option-bg-color: var(--color-background-tertiary);
}
&.is-selected {
- border-color: var(--color-accent-primary);
- background-color: var(--color-background-tertiary);
+ --reviewer-option-bg-color: var(--color-background-tertiary);
+ --reviewer-option-border-color: var(--color-accent-primary);
}
+}
- > svg:last-child {
- margin-inline-start: auto;
- color: var(--color-accent-primary);
- }
+.reviewer-tick {
+ margin-inline-start: auto;
+ color: var(--color-accent-primary);
}
.reviewer-name {
@@ -213,24 +208,27 @@
}
.verdict-option {
+ --verdict-option-bg-color: transparent;
+ --verdict-option-border-color: var(--color-background-quaternary);
+
display: flex;
align-items: center;
gap: var(--sp-m);
padding: var(--sp-m);
- border: $b-1 solid var(--color-background-quaternary);
+ border: $b-1 solid var(--verdict-option-border-color);
border-radius: $br-8;
- background: none;
+ background: var(--verdict-option-bg-color);
cursor: pointer;
text-align: start;
color: var(--color-foreground-primary);
&:hover {
- background-color: var(--color-background-tertiary);
+ --verdict-option-bg-color: var(--color-background-tertiary);
}
&.is-selected {
- border-color: var(--color-accent-primary);
- background-color: var(--color-background-tertiary);
+ --verdict-option-bg-color: var(--color-background-tertiary);
+ --verdict-option-border-color: var(--color-accent-primary);
}
}
@@ -278,14 +276,17 @@
min-block-size: 0;
}
+// the same box as the description of a branch (its info dialog), as high
+// as 400px; a longer one scrolls inside
.pr-info-description {
- @include use-typography("body-medium");
-
+ max-block-size: px2rem(400);
margin: 0;
+ padding: var(--sp-s);
+ border-radius: $br-8;
+ background-color: var(--color-background-tertiary);
color: var(--color-foreground-primary);
white-space: pre-wrap;
overflow-y: auto;
- padding-inline-end: var(--sp-s);
// user content: long words / urls must never push past the card
overflow-wrap: anywhere;
@@ -354,12 +355,12 @@
.reviewer-stale {
color: var(--color-foreground-secondary);
+
+ // TODO: the DS typographies have no italic.
font-style: italic;
}
.reviewer-comment {
- @include use-typography("body-small");
-
flex-basis: 100%;
margin: 0;
color: var(--color-foreground-secondary);
@@ -389,49 +390,13 @@
transition:
inset-block-end 0.2s,
block-size 0.2s;
-
- &.is-collapsed {
- inset-block-end: 0;
- block-size: var(--sp-m);
- border-radius: $br-12 $br-12 0 0;
-
- .pr-banner-content {
- block-size: 0;
- padding-block: 0;
- visibility: hidden;
- }
- }
-}
-
-.pr-banner-handle {
- position: absolute;
- inset-inline: 0;
- inset-block-start: 0;
- display: flex;
- justify-content: center;
- align-items: center;
- block-size: var(--sp-m);
- border: none;
- background: none;
- cursor: pointer;
- inline-size: 100%;
- z-index: 1;
-}
-
-.pr-banner-handle-btn {
- block-size: var(--sp-xs);
- inline-size: 100%;
- max-inline-size: $sz-64;
- padding: 0;
- border-radius: $br-4;
- background-color: var(--color-background-quaternary);
}
.pr-banner-content {
display: flex;
align-items: center;
gap: var(--sp-m);
- padding: var(--sp-m) var(--sp-m) var(--sp-s);
+ padding: var(--sp-s) var(--sp-m);
}
.pr-banner-icon {
@@ -454,38 +419,14 @@
@include use-typography("body-small");
}
-.pr-banner-title,
-.pr-banner-route {
+.pr-banner-title {
color: var(--color-foreground-secondary);
}
-// branch -> main, as pills, the same way the compare dialog names them
-.pr-banner-route {
- display: flex;
- align-items: center;
- gap: var(--sp-xs);
- white-space: nowrap;
-}
-
.pr-banner-name {
color: var(--color-foreground-primary);
}
-.pr-banner-badges {
- display: flex;
- align-items: center;
- gap: var(--sp-xs);
-}
-
-.pr-banner-approvals {
- @include use-typography("code-font");
-
- display: inline-flex;
- align-items: center;
- gap: var(--sp-xxs);
- color: var(--color-accent-success);
-}
-
.pr-banner-actions {
display: flex;
align-items: center;
@@ -497,3 +438,35 @@
display: flex;
align-items: center;
}
+
+.pr-banner-separator {
+ align-self: stretch;
+ border-inline-start: $b-1 solid var(--color-background-quaternary);
+}
+
+.banner-button {
+ --banner-button-bg-color: transparent;
+ --banner-button-fg-color: var(--color-foreground-secondary);
+
+ @include use-typography("body-small");
+
+ display: inline-flex;
+ align-items: center;
+ gap: var(--banner-button-gap, var(--sp-s));
+ padding: var(--sp-xs) var(--sp-s);
+ border: none;
+ border-radius: $br-8;
+ background: var(--banner-button-bg-color);
+ color: var(--banner-button-fg-color);
+ white-space: nowrap;
+ cursor: pointer;
+
+ &:hover {
+ --banner-button-bg-color: var(--color-background-tertiary);
+ --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/reviews.cljs b/frontend/src/app/main/ui/workspace/sidebar/reviews.cljs
index 3289ad2c01..e672a3060e 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/reviews.cljs
+++ b/frontend/src/app/main/ui/workspace/sidebar/reviews.cljs
@@ -2,7 +2,7 @@
;; 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 INC Sucursal en España SL
+;; Copyright (c) KALEIDOS SUBSIDIARY SL
(ns app.main.ui.workspace.sidebar.reviews
"The reviews dialog: the merges into main, each with who made it, when
@@ -20,8 +20,11 @@
[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.buttons.link-button :refer [link-button*]]
[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.menu :refer [menu* menu-item*]]
[app.main.ui.ds.layout.modal :refer [modal* modal-header* modal-content*]]
[app.main.ui.ds.layout.tab-switcher :refer [tab-switcher*]]
@@ -83,10 +86,9 @@
:is-folded (not expanded?))}
text]
(when (or overflow? expanded?)
- [:button {:type "button"
- :class (stl/css :see-more)
- :aria-expanded expanded?
- :on-click on-toggle}
+ [:> link-button* {:class (stl/css :see-more)
+ :aria-expanded expanded?
+ :on-click on-toggle}
(if expanded?
(tr "workspace.branches.reviews.see-less")
(tr "workspace.branches.reviews.see-more"))])]))
@@ -151,7 +153,7 @@
[:span {:class (stl/css :entry-review-title)}
(tr "workspace.branches.reviews.from-review" title)]])
(if (str/blank? (:comment merge))
- [:p {:class (stl/css :entry-no-comment)}
+ [:> text* {:as "p" :typography t/body-medium :class (stl/css :entry-no-comment)}
(tr "workspace.branches.reviews.no-comment")]
[:> clamped-text* {:text (:comment merge)}])]]))
diff --git a/frontend/src/app/main/ui/workspace/sidebar/reviews.scss b/frontend/src/app/main/ui/workspace/sidebar/reviews.scss
index 63de4b3bb7..58b6590b96 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/reviews.scss
+++ b/frontend/src/app/main/ui/workspace/sidebar/reviews.scss
@@ -2,10 +2,11 @@
// 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 INC Sucursal en España SL
+// 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 *;
@use "ds/typography.scss" as *;
@@ -53,6 +54,7 @@
// the card of the comment or the description: a step lighter than the
// row, also while a clickable row is hovered
--entry-card-bg-color: var(--color-background-tertiary);
+ --entry-bg-color: transparent;
display: grid;
grid-template-columns: auto 1fr auto;
@@ -60,14 +62,14 @@
gap: var(--sp-m);
padding: var(--sp-m) var(--sp-s);
border-radius: $br-8;
+ background-color: var(--entry-bg-color);
&.is-clickable {
cursor: pointer;
&:hover {
+ --entry-bg-color: var(--color-background-tertiary);
--entry-card-bg-color: var(--color-background-quaternary);
-
- background-color: var(--color-background-tertiary);
}
&:focus-visible {
@@ -178,13 +180,13 @@
// the empty card of the branch info dialog's description
.entry-no-comment {
- @include use-typography("body-medium");
-
margin: 0;
margin-block-start: var(--sp-xs);
padding: var(--sp-s);
border: $b-1 dashed var(--color-background-quaternary);
border-radius: $br-8;
+
+ // TODO: the DS typographies have no italic.
font-style: italic;
color: var(--color-foreground-secondary);
}
@@ -208,33 +210,23 @@
background-color: var(--entry-card-bg-color);
}
+// unfolded, the text grows up to 400px and scrolls inside past it, as the
+// descriptions of the dialogs do
.clamped-text {
@include use-typography("body-medium");
+ max-block-size: px2rem(400);
margin: 0;
color: var(--color-foreground-primary);
white-space: pre-line;
overflow-wrap: anywhere;
+ overflow-y: auto;
}
.is-folded {
@include two-line-text-ellipsis;
}
-.see-more {
- @include use-typography("body-small");
-
- padding: 0;
- border: none;
- background: none;
- color: var(--color-accent-primary);
- cursor: pointer;
-
- &:hover {
- text-decoration: underline;
- }
-
- &:focus-visible {
- outline: $b-1 solid var(--color-accent-primary);
- }
+.see-more:focus-visible {
+ outline: $b-1 solid var(--color-accent-primary);
}
diff --git a/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs b/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs
index 3f1ec3ab8d..51d4c398ca 100644
--- a/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs
+++ b/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs
@@ -304,7 +304,9 @@
(-> event dom/get-current-target dom/blur!)))
read-only? (mf/use-ctx ctx/workspace-read-only?)
- permissions (mf/use-ctx ctx/permissions)]
+ permissions (mf/use-ctx ctx/permissions)
+ ;; a design review is read-only for everybody, editors included
+ reviewing? (some? (mf/deref refs/pull-request-preview))]
[:div {:class (stl/css :sitemap)
:style {:--height (dm/str height "px")}}
@@ -316,7 +318,7 @@
:class (stl/css :sitemap-title)}
(if ^boolean read-only?
- (when ^boolean (:can-edit permissions)
+ (when (or ^boolean (:can-edit permissions) ^boolean reviewing?)
[:& badge-notification {:is-focus true
:size :small
:content (tr "labels.view-only")}])
diff --git a/frontend/src/app/main/ui/workspace/top_toolbar.cljs b/frontend/src/app/main/ui/workspace/top_toolbar.cljs
index 7a7f767621..1ae9671c18 100644
--- a/frontend/src/app/main/ui/workspace/top_toolbar.cljs
+++ b/frontend/src/app/main/ui/workspace/top_toolbar.cljs
@@ -17,6 +17,7 @@
[app.main.data.workspace.drawing.common :as dwdc]
[app.main.data.workspace.media :as dwm]
[app.main.data.workspace.path.state :as pst]
+ [app.main.data.workspace.review :as dwrv]
[app.main.data.workspace.shortcuts :as sc]
[app.main.features :as features]
[app.main.refs :as refs]
@@ -293,6 +294,65 @@
: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."
+ {::mf/private true}
+ [{:keys [rulers-enabled toolbar-hidden on-toggle-toolbar]}]
+ (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)))]
+
+ [:div {:role "toolbar"
+ :aria-label (tr "workspace.review.toolbar.label")
+ :tab-index "0"
+ :class (stl/css-case :toolbar true
+ :no-rulers (not rulers-enabled)
+ :hidden toolbar-hidden)}
+ [:ul {:class (stl/css :toolbar-options)}
+ (for [[id icon label] [[:move i/move (tr "workspace.review.toolbar.move")]
+ [:comment i/comments (tr "workspace.review.toolbar.comment")]
+ [:comment-area i/comment-area (tr "workspace.review.toolbar.comment-area")]
+ [: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)
+ :tooltip-placement "bottom"
+ :aria-pressed (= tool id)
+ :aria-label label
+ :icon icon
+ :data-tool (name id)
+ :on-click on-select-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}]]]
+ [: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 top-toolbar*
{::mf/wrap [mf/memo]}
[{:keys [layout]}]
@@ -304,6 +364,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))
mcp-conn-status (get mcp :connection-status)
mcp-valid-token? (get mcp :token-valid)
@@ -357,7 +418,13 @@
(dom/blur! (dom/get-target event))
(st/emit! (dwc/toggle-toolbar-visibility))))]
- (when-not ^boolean read-only?
+ (cond
+ ^boolean reviewing?
+ [:> review-toolbar* {:rulers-enabled rulers-enabled
+ :toolbar-hidden toolbar-hidden
+ :on-toggle-toolbar on-toggle-toolbar}]
+
+ (not ^boolean read-only?)
[:div {:role "toolbar"
:aria-label (tr "workspace.toolbar.label")
:tab-index "0"
diff --git a/frontend/src/app/main/ui/workspace/top_toolbar.scss b/frontend/src/app/main/ui/workspace/top_toolbar.scss
index 71ad771b3c..41ba152be3 100644
--- a/frontend/src/app/main/ui/workspace/top_toolbar.scss
+++ b/frontend/src/app/main/ui/workspace/top_toolbar.scss
@@ -7,9 +7,6 @@
@use "ds/_borders.scss" as *;
@use "ds/_sizes.scss" as *;
@use "ds/_utils.scss" as *;
-@use "ds/spacing.scss" as *;
-@use "ds/typography.scss" as t;
-@use "ds/z-index.scss" as *;
.toolbar {
--toolbar-position-y: #{$sz-28};
@@ -45,6 +42,8 @@
--toolbar-offset-y: -4px;
block-size: $sz-16;
+
+ // TODO: no DS z-index token for 1.
z-index: 1;
border-radius: 0 0 $br-8 $br-8;
border-block-start: 0;
@@ -129,3 +128,15 @@
border-radius: $br-4;
background-color: var(--color-accent-default);
}
+
+// the tools of a design review use the review colour: blue on the tool in
+// use and on hover, instead of the accent of the drawing tools
+.review-tool:hover {
+ --button-hover-bg-color: var(--color-background-quaternary);
+ --button-hover-fg-color: var(--color-accent-info);
+}
+
+.review-tool[aria-pressed="true"] {
+ --button-active-bg-color: var(--color-background-info);
+ --button-active-fg-color: var(--color-accent-info);
+}
diff --git a/frontend/src/app/main/ui/workspace/viewport.cljs b/frontend/src/app/main/ui/workspace/viewport.cljs
index 9c3fcb77fd..e3e0aef469 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.review.overlays :refer [review-overlays*]]
[app.main.ui.workspace.shapes :as shapes]
[app.main.ui.workspace.shapes.path.editor :refer [path-editor*]]
[app.main.ui.workspace.shapes.text.editor :as editor-v1]
@@ -238,8 +239,13 @@
disable-events? (contains? layout :comments)
comments-mode? (= drawing-tool :comments)
- show-comments? (or comments-mode?
- (contains? layout :display-comments))
+ reviewing? (some? (mf/deref refs/pull-request-preview))
+ ;; inside a design review the global "show comments" option
+ ;; decides alone: it shows or hides comments and tasks
+ show-comments? (if reviewing?
+ (contains? layout :display-comments)
+ (or comments-mode?
+ (contains? layout :display-comments)))
show-cursor-tooltip? tooltip
show-draw-area? drawing-obj
show-gradient-handlers? (= (count selected) 1)
@@ -383,6 +389,12 @@
: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}])]
diff --git a/frontend/src/app/main/ui/workspace/viewport/comments.cljs b/frontend/src/app/main/ui/workspace/viewport/comments.cljs
index d17eed3ef2..931f343170 100644
--- a/frontend/src/app/main/ui/workspace/viewport/comments.cljs
+++ b/frontend/src/app/main/ui/workspace/viewport/comments.cljs
@@ -10,9 +10,12 @@
[app.common.data.macros :as dm]
[app.main.data.comments :as dcm]
[app.main.data.workspace.comments :as dwcm]
+ [app.main.data.workspace.tasks :as dwtk]
[app.main.refs :as refs]
[app.main.store :as st]
[app.main.ui.comments :as cmt]
+ [app.main.ui.workspace.review.markers :as rvm]
+ [app.main.ui.workspace.review.tasks :as rvt]
[app.main.ui.workspace.viewport.rulers :as rulers]
[rumext.v2 :as mf]))
@@ -67,7 +70,8 @@
{:thread thread
:viewport viewport
:position-modifier position-modifier
- :zoom zoom}]))
+ :zoom zoom
+ :task-section rvt/thread-task-section*}]))
(mf/defc comments-layer*
{::mf/wrap [mf/memo]}
@@ -84,13 +88,35 @@
local (mf/deref refs/comments-local)
threads-map (mf/deref refs/threads)
+ tasks (mf/deref refs/tasks)
+ objects (mf/deref refs/workspace-page-objects)
+ review-local (mf/deref refs/review-local)
+ drawing-tool (mf/deref refs/selected-drawing-tool)
+ reviewing? (some? (mf/deref refs/pull-request-preview))
- threads
+ task-thread-ids
+ (mf/with-memo [tasks]
+ (into #{} (keep :thread-id) (vals tasks)))
+
+ all-threads
(mf/with-memo [threads-map local profile page-id]
(->> (vals threads-map)
(filter #(= (:page-id %) page-id))
(dcm/apply-filters local profile)))
+ ;; the threads of the design reviews and of the tasks have marks of
+ ;; their own (`review-markers*`); the rest are plain bubbles
+ [review-threads threads]
+ (mf/with-memo [all-threads task-thread-ids]
+ ((juxt filterv (comp vec remove))
+ (partial rvm/review-thread? task-thread-ids)
+ all-threads))
+
+ area-tool?
+ (and reviewing?
+ (= :comments drawing-tool)
+ (= :comment-area (get review-local :tool)))
+
viewport
(assoc vport :offset-x pos-x :offset-y pos-y)
@@ -103,7 +129,8 @@
(st/emit! (dcm/create-thread-on-workspace draft))))]
(mf/with-effect [file-id]
- (st/emit! (dwcm/initialize-comments file-id))
+ (st/emit! (dwcm/initialize-comments file-id)
+ (dwtk/fetch-tasks))
(fn [] (st/emit! ::dwcm/finalize)))
;; Any viewport change (pan/zoom) collapses an expanded cluster back.
@@ -124,9 +151,19 @@
(dm/fmt "inset(%px 0 0 %px)"
rulers/ruler-area-size
rulers/ruler-area-size))}}
+ (when area-tool?
+ [:> rvm/area-layer* {:vbox vbox :zoom zoom}])
+
[:div {:class (stl/css :threads)
:style {:transform (dm/fmt "translate(%px, %px)" pos-x pos-y)}}
+ [:> rvm/review-markers* {:threads review-threads
+ :page-id page-id
+ :zoom zoom
+ :open-id (:open local)
+ :draft (:draft local)
+ :expanded (:expanded local)}]
+
(for [thread-group (dwcm/group-bubbles zoom threads)]
(let [group? (> (count thread-group) 1)
thread (first thread-group)
@@ -160,7 +197,8 @@
(when-let [thread (get threads-map id)]
(when (seq (dcm/apply-filters local profile [thread]))
[:> comment-floating-thread-wrapper*
- {:thread thread
+ ;; a thread on a layer opens by the layer, wherever it is now
+ {:thread (assoc thread :position (rvm/thread-position objects thread))
:viewport viewport
:zoom zoom}])))
diff --git a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs
index ae8397383e..84b9f3ee2d 100644
--- a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs
+++ b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs
@@ -23,6 +23,7 @@
[app.main.data.workspace.shortcuts :as wsc]
[app.main.data.workspace.text.shortcuts :as tsc]
[app.main.features :as features]
+ [app.main.refs :as refs]
[app.main.store :as st]
[app.main.streams :as ms]
[app.main.ui.css-cursors :as cur]
@@ -92,9 +93,17 @@
(when (not= size vport)
(st/emit! (dw/initialize-viewport (dom/get-client-size prnt)))))))
+(declare ^:private setup-cursor*)
+
(defn setup-cursor [cursor alt? mod? space? panning drawing-tool drawing-path? path-editing? path-drag-cursor z? workspace-read-only? can-alt-duplicate?]
+ ;; the task tool rides on the comments tool, with a cursor of its own
+ (let [local (mf/deref refs/review-local)
+ task-tool? (= :task (:tool local))]
+ (setup-cursor* cursor alt? mod? space? panning drawing-tool drawing-path? path-editing? path-drag-cursor z? workspace-read-only? can-alt-duplicate? task-tool?)))
+
+(defn- setup-cursor* [cursor alt? mod? space? panning drawing-tool drawing-path? path-editing? path-drag-cursor z? workspace-read-only? can-alt-duplicate? task-tool?]
(mf/use-effect
- (mf/deps @cursor @alt? @mod? @space? panning drawing-tool drawing-path? path-editing? path-drag-cursor z? workspace-read-only? can-alt-duplicate?)
+ (mf/deps @cursor @alt? @mod? @space? panning drawing-tool drawing-path? path-editing? path-drag-cursor z? workspace-read-only? can-alt-duplicate? task-tool?)
(fn []
(let [show-pen? (or (= drawing-tool :path)
(and drawing-path?
@@ -111,6 +120,7 @@
(or panning @space?) (utils/get-cursor :hand)
;; Keep the drag cursor across the viewport.
(some? path-drag-cursor) (cur/get-static path-drag-cursor)
+ (and task-tool? (= drawing-tool :comments)) (utils/get-cursor :create-task)
(= drawing-tool :comments) (utils/get-cursor :comments)
(= drawing-tool :frame) (utils/get-cursor :create-artboard)
(= drawing-tool :rect) (utils/get-cursor :create-rectangle)
diff --git a/frontend/src/app/main/ui/workspace/viewport/utils.cljs b/frontend/src/app/main/ui/workspace/viewport/utils.cljs
index 4e120af115..29d768a2e3 100644
--- a/frontend/src/app/main/ui/workspace/viewport/utils.cljs
+++ b/frontend/src/app/main/ui/workspace/viewport/utils.cljs
@@ -32,6 +32,7 @@
:draw-path (cur/get-static "draw")
:edit-path (cur/get-static "move")
:create-shape (cur/get-static "create-shape")
+ :create-task (cur/get-static "create-task")
:duplicate (cur/get-static "duplicate")
:zoom (cur/get-static "zoom")
:zoom-in (cur/get-static "zoom-in")
diff --git a/frontend/src/app/main/ui/workspace/viewport_wasm.cljs b/frontend/src/app/main/ui/workspace/viewport_wasm.cljs
index cfa1a3d38d..c2a24a0d3e 100644
--- a/frontend/src/app/main/ui/workspace/viewport_wasm.cljs
+++ b/frontend/src/app/main/ui/workspace/viewport_wasm.cljs
@@ -27,6 +27,7 @@
[app.main.ui.flex-controls :as mfc]
[app.main.ui.hooks :as ui-hooks]
[app.main.ui.measurements :as msr]
+ [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]
[app.main.ui.workspace.shapes.text.text-edition-outline :refer [text-edition-outline*]]
@@ -349,8 +350,13 @@
disable-events? (contains? layout :comments)
comments-mode? (= drawing-tool :comments)
- show-comments? (or comments-mode?
- (contains? layout :display-comments))
+ reviewing? (some? (mf/deref refs/pull-request-preview))
+ ;; inside a design review the global "show comments" option
+ ;; decides alone: it shows or hides comments and tasks
+ show-comments? (if reviewing?
+ (contains? layout :display-comments)
+ (or comments-mode?
+ (contains? layout :display-comments)))
show-cursor-tooltip? tooltip
show-draw-area? drawing-obj
show-gradient-handlers? (= (count selected) 1)
@@ -361,7 +367,7 @@
(not panning)
(not edition)
(not drawing-obj)
- (not (#{:comments :path :curve} drawing-tool))
+ (not (#{:path :curve} drawing-tool))
(not page-transition?))
show-pixel-grid? (and (contains? layout :show-pixel-grid)
@@ -693,6 +699,12 @@
: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}])]
@@ -795,10 +807,12 @@
:zoom zoom}]])]))
(when show-outlines?
+ ;; the comments tool outlines only what asks for it, like the
+ ;; layer of a hovered mark
[:> outline/shape-outlines*
{:objects objects-for-outlines
- :selected selected
- :hover #{(:id @hover) @frame-hover}
+ :selected (when-not comments-mode? selected)
+ :hover (when-not comments-mode? #{(:id @hover) @frame-hover})
:highlighted highlighted
:edition edition
:zoom zoom}])
diff --git a/frontend/test/frontend_tests/data/bottom_bars_test.cljs b/frontend/test/frontend_tests/data/bottom_bars_test.cljs
new file mode 100644
index 0000000000..eaed180a8f
--- /dev/null
+++ b/frontend/test/frontend_tests/data/bottom_bars_test.cljs
@@ -0,0 +1,53 @@
+;; 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.bottom-bars-test
+ (:require
+ [app.main.data.workspace.layout :as dwlo]
+ [cljs.test :as t :include-macros true]
+ [potok.v2.core :as ptk]))
+
+(defn- apply-events
+ [state & events]
+ (reduce #(ptk/update %2 %1) state events))
+
+(defn- bottom-bar
+ [state]
+ (get-in state [:workspace-global :bottom-bar]))
+
+(t/deftest the-bar-of-a-branch-comes-open
+ (t/is (= :branch (bottom-bar (apply-events {} (dwlo/mount-bottom-bars))))))
+
+(t/deftest opening-a-bar-folds-the-other
+ (let [state (apply-events {} (dwlo/mount-bottom-bars))]
+ (t/testing "the palettes fold the bar of the branch"
+ (t/is (= :palette (bottom-bar (apply-events state (dwlo/toggle-bottom-bar :palette))))))
+ (t/testing "and the other way around"
+ (t/is (= :branch (bottom-bar (apply-events state
+ (dwlo/toggle-bottom-bar :palette)
+ (dwlo/toggle-bottom-bar :branch))))))
+ (t/testing "a shortcut opens the palettes"
+ (t/is (= :palette (bottom-bar (apply-events state (dwlo/open-bottom-bar :palette))))))))
+
+(t/deftest folding-a-bar-opens-none
+ (let [state (apply-events {} (dwlo/mount-bottom-bars))]
+ (t/testing "the bar of the branch"
+ (t/is (= :none (bottom-bar (apply-events state (dwlo/toggle-bottom-bar :branch))))))
+ (t/testing "the palettes"
+ (t/is (= :none (bottom-bar (apply-events state
+ (dwlo/toggle-bottom-bar :palette)
+ (dwlo/toggle-bottom-bar :palette))))))))
+
+(t/deftest without-a-branch-nothing-changes
+ (let [state {:workspace-global {:options-mode :design}}]
+ (t/is (= state (apply-events state (dwlo/toggle-bottom-bar :palette))))
+ (t/is (= state (apply-events state (dwlo/open-bottom-bar :palette))))))
+
+(t/deftest leaving-the-branch-forgets-the-bars
+ (let [state (apply-events {}
+ (dwlo/mount-bottom-bars)
+ (dwlo/unmount-bottom-bars))]
+ (t/is (nil? (bottom-bar state)))))
diff --git a/frontend/test/frontend_tests/data/workspace_tasks_test.cljs b/frontend/test/frontend_tests/data/workspace_tasks_test.cljs
new file mode 100644
index 0000000000..801395f28c
--- /dev/null
+++ b/frontend/test/frontend_tests/data/workspace_tasks_test.cljs
@@ -0,0 +1,141 @@
+;; 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 INC Sucursal en España SL
+
+(ns frontend-tests.data.workspace-tasks-test
+ (:require
+ [app.common.geom.point :as gpt]
+ [app.common.types.shape :as cts]
+ [app.common.uuid :as uuid]
+ [app.main.data.comments :as dcmt]
+ [app.main.data.workspace.tasks :as dwtk]
+ [app.main.repo :as rp]
+ [beicon.v2.core :as rx]
+ [cljs.test :as t :include-macros true]
+ [frontend-tests.helpers.async :as hva]
+ [frontend-tests.helpers.mock :as mock]
+ [potok.v2.core :as ptk]))
+
+(def ^:private board-id (uuid/custom 1 1))
+(def ^:private button-id (uuid/custom 1 2))
+
+(defn- objects
+ []
+ (let [board (cts/setup-shape {:id board-id :type :frame :name "Checkout"
+ :x 0 :y 0 :width 400 :height 800
+ :parent-id uuid/zero :frame-id uuid/zero})
+ button (cts/setup-shape {:id button-id :type :rect :name "Pay button"
+ :x 20 :y 600 :width 300 :height 48
+ :parent-id board-id :frame-id board-id})
+ root (cts/setup-shape {:id uuid/zero :type :frame :name "Root"
+ :x 0 :y 0 :width 1 :height 1
+ :parent-id uuid/zero :frame-id uuid/zero})]
+ {uuid/zero (assoc root :shapes [board-id])
+ board-id (assoc board :shapes [button-id])
+ button-id button}))
+
+(t/deftest shape-at-position-prefers-the-layer-over-its-board
+ (t/is (= button-id (:id (dwtk/shape-at-position (objects) {:x 50 :y 610}))))
+ (t/is (= board-id (:id (dwtk/shape-at-position (objects) {:x 50 :y 50}))))
+ (t/is (nil? (dwtk/shape-at-position (objects) {:x 900 :y 900}))))
+
+(t/deftest anchor-position-falls-back-to-the-board-of-a-lost-layer
+ (let [objs (objects)]
+ (t/is (= (gpt/point 320 600)
+ (dwtk/anchor-position objs {:shape-id button-id :frame-id board-id})))
+ (t/is (= (gpt/point 400 0)
+ (dwtk/anchor-position (dissoc objs button-id)
+ {:shape-id button-id :frame-id board-id})))
+ (t/is (nil? (dwtk/anchor-position objs {:shape-id nil :frame-id uuid/zero})))))
+
+(t/deftest task-predicates
+ (t/is (dwtk/to-do? {:status "reopened"}))
+ (t/is (dwtk/to-verify? {:status "done"}))
+ (t/is (dwtk/closed? {:status "wont-do"}))
+ (t/is (dwtk/history? {:status "verified" :merge-id (uuid/next)}))
+ (t/is (not (dwtk/history? {:status "open" :merge-id (uuid/next)}))))
+
+(t/deftest tasks-for-counts-the-open-work-of-a-person
+ (let [me (uuid/next)]
+ (t/is (= 1 (count (dwtk/tasks-for [{:status "open" :assignee-id me}
+ {:status "done" :assignee-id me}
+ {:status "open" :assignee-id (uuid/next)}]
+ me))))))
+
+(t/deftest sort-tasks-puts-open-work-first
+ (t/is (= ["open" "done" "verified"]
+ (mapv :status (dwtk/sort-tasks [{:status "verified" :created-at 1}
+ {:status "done" :created-at 2}
+ {:status "open" :created-at 3}])))))
+
+;; --- Creating a task
+
+(def ^:private file-id (uuid/custom 2 1))
+(def ^:private page-id (uuid/custom 2 2))
+(def ^:private thread-id (uuid/custom 2 3))
+
+(defn- workspace-state
+ []
+ {:current-file-id file-id
+ :current-page-id page-id
+ :files {file-id {:data {:pages-index {page-id {:objects (objects)}}}}}})
+
+(defn- fake-server
+ "The backend of the tasks: the creation answers with the task in the
+ thread `thread-id`, the read of a thread answers with it. Every answer
+ arrives later, as from the network."
+ [calls]
+ (mock/stub
+ (fn [id params]
+ (swap! calls conj {:cmd id :params params})
+ (->> (case id
+ :create-task (rx/of (assoc params :id (uuid/next) :thread-id thread-id))
+ :get-comment-thread (rx/of {:id thread-id :page-id page-id :position (:position params)})
+ :get-file-tasks (rx/of [])
+ (rx/of nil))
+ (rx/observe-on :async)))))
+
+(defn- ^:async created-events
+ "Run the creation of a task with `params` and collect what it emits."
+ [params]
+ (let [calls (atom [])
+ seen (atom [])]
+ (await (mock/with-mocks*
+ {rp/cmd! (fake-server calls)}
+ (await (hva/observe (ptk/watch (dwtk/create-task params) (workspace-state) (rx/empty))
+ {:on-next #(swap! seen conj (ptk/type %))}))))
+ {:calls @calls :seen @seen}))
+
+(t/deftest ^:async task-on-a-selected-layer-gets-a-thread-of-its-own
+ (let [{:keys [calls seen]} (await (created-events {:title "Use the secondary token"
+ :page-id page-id
+ :frame-id board-id
+ :shape-id button-id}))
+ create (some #(when (= :create-task (:cmd %)) (:params %)) calls)]
+
+ (t/testing "its thread sits where its mark goes: the top right of the layer"
+ (t/is (= {:x 320 :y 600} (into {} (:position create))))
+ (t/is (nil? (:thread-id create))))
+
+ (t/testing "the new thread is kept before the task opens as it"
+ (t/is (some #(= {:cmd :get-comment-thread
+ :params {:file-id file-id :id thread-id}} %)
+ calls))
+ (let [kept (.indexOf seen ::dcmt/created-thread-on-workspace)
+ opened (.indexOf seen ::dwtk/open-task)]
+ (t/is (<= 0 kept))
+ (t/is (< kept opened))))))
+
+(t/deftest ^:async task-made-from-a-message-keeps-its-thread
+ (let [{:keys [calls seen]} (await (created-events {:title "fix the radius"
+ :page-id page-id
+ :frame-id board-id
+ :shape-id board-id
+ :position {:x 10 :y 10}
+ :thread-id thread-id
+ :comment-id (uuid/next)}))]
+ (t/is (not-any? #(= :get-comment-thread (:cmd %)) calls))
+ (t/is (not-any? #{::dcmt/created-thread-on-workspace} seen))
+ (t/is (some #{::dwtk/open-task} seen))))
diff --git a/frontend/test/frontend_tests/runner.cljs b/frontend/test/frontend_tests/runner.cljs
index 8cadb6c620..f0eb597672 100644
--- a/frontend/test/frontend_tests/runner.cljs
+++ b/frontend/test/frontend_tests/runner.cljs
@@ -10,6 +10,7 @@
[frontend-tests.composable-tests.comp.sync-test]
[frontend-tests.copy-as-svg-test]
[frontend-tests.data.auth-test]
+ [frontend-tests.data.bottom-bars-test]
[frontend-tests.data.comments-batches-test]
[frontend-tests.data.comments-filters-test]
[frontend-tests.data.dashboard-test]
@@ -48,6 +49,7 @@
[frontend-tests.data.workspace-path-edition-test]
[frontend-tests.data.workspace-reflow-test]
[frontend-tests.data.workspace-shortcuts-test]
+ [frontend-tests.data.workspace-tasks-test]
[frontend-tests.data.workspace-texts-test]
[frontend-tests.data.workspace-thumbnails-test]
[frontend-tests.data.workspace-undo-test]
@@ -164,6 +166,8 @@
[frontend-tests.ui.measurements-test]
[frontend-tests.ui.measures-menu-props-test]
[frontend-tests.ui.organization-team-switch-test]
+ [frontend-tests.ui.review-details-test]
+ [frontend-tests.ui.review-markers-test]
[frontend-tests.ui.routes-test]
[frontend-tests.ui.settings-password-schema-test]
[frontend-tests.ui.settings-shortcuts-test]
@@ -214,6 +218,7 @@
'frontend-tests.composable-tests.comp.sync-test
'frontend-tests.copy-as-svg-test
'frontend-tests.data.auth-test
+ 'frontend-tests.data.bottom-bars-test
'frontend-tests.data.comments-batches-test
'frontend-tests.data.comments-filters-test
'frontend-tests.data.dashboard-test
@@ -243,6 +248,7 @@
'frontend-tests.data.uploads-test
'frontend-tests.data.viewer-test
'frontend-tests.data.workspace-branches-test
+ 'frontend-tests.data.workspace-tasks-test
'frontend-tests.data.workspace-colors-test
'frontend-tests.data.workspace-comments-test
'frontend-tests.data.workspace-context-menu-test
@@ -366,6 +372,8 @@
'frontend-tests.ui.inspect-geometry-test
'frontend-tests.ui.inspect-stroke-tokens-test
'frontend-tests.ui.jobs-progress-test
+ 'frontend-tests.ui.review-details-test
+ 'frontend-tests.ui.review-markers-test
'frontend-tests.ui.layout-container-multiple-test
'frontend-tests.ui.measurements-test
'frontend-tests.ui.measures-menu-props-test
diff --git a/frontend/test/frontend_tests/ui/review_details_test.cljs b/frontend/test/frontend_tests/ui/review_details_test.cljs
new file mode 100644
index 0000000000..6bdd7d711d
--- /dev/null
+++ b/frontend/test/frontend_tests/ui/review_details_test.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 frontend-tests.ui.review-details-test
+ (:require
+ [app.main.data.workspace.review :as dwrv]
+ [app.main.ui.workspace.review.common :as rvc]
+ [app.main.ui.workspace.review.details :as details]
+ [cljs.test :as t :include-macros true]
+ [potok.v2.core :as ptk]))
+
+(def ^:private display-attr @#'details/display-attr)
+
+(t/deftest a-fill-without-tokens-shows-its-value
+ (let [fill-a [{:fill-color "#ff0000" :fill-opacity 1}]
+ fill-b [{:fill-color "#00ff00" :fill-opacity 1}]
+ [_ before after] (display-attr :fills [fill-a fill-b] nil)]
+ (t/is (= fill-a before))
+ (t/is (= fill-b after))))
+
+(t/deftest a-token-on-one-side-shows-the-token
+ (let [fill [{:fill-color "#ff0000" :fill-opacity 1}]
+ [_ before after] (display-attr :fills [fill fill] [nil {:fill "brand.primary"}])]
+ (t/is (= fill before))
+ (t/is (= "brand.primary" after))))
+
+(t/deftest a-property-that-takes-no-tokens-shows-its-value
+ (let [[_ before after] (display-attr :opacity [0.5 1] [{:fill "a"} {:fill "b"}])]
+ (t/is (= 0.5 before))
+ (t/is (= 1 after))))
+
+(t/deftest the-tasks-filter-keeps-one-state-or-all
+ (let [state (ptk/update (dwrv/set-task-status-filter "verified") {})]
+ (t/is (= "verified" (get-in state [:workspace-review-local :task-status-filter])))
+ (t/is (= :all (-> (ptk/update (dwrv/set-task-status-filter :all) state)
+ (get-in [:workspace-review-local :task-status-filter]))))))
+
+(t/deftest every-task-state-has-its-colour
+ (t/is (= ["info" "success" "warning" "purple" "error"]
+ (mapv rvc/status-tone dwrv/task-statuses))))
diff --git a/frontend/test/frontend_tests/ui/review_markers_test.cljs b/frontend/test/frontend_tests/ui/review_markers_test.cljs
new file mode 100644
index 0000000000..732975a740
--- /dev/null
+++ b/frontend/test/frontend_tests/ui/review_markers_test.cljs
@@ -0,0 +1,162 @@
+;; 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.review-markers-test
+ (:require
+ [app.common.geom.point :as gpt]
+ [app.common.uuid :as uuid]
+ [app.main.data.workspace.tasks :as dwtk]
+ [app.main.ui.workspace.review.markers :as rvm]
+ [cljs.test :as t :include-macros true]
+ [potok.v2.core :as ptk]))
+
+(def ^:private shape-a (uuid/next))
+(def ^:private shape-b (uuid/next))
+
+(def ^:private objects
+ {shape-a {:id shape-a :selrect {:x 0 :y 0 :width 100 :height 100}}
+ shape-b {:id shape-b :selrect {:x 0 :y 0 :width 120 :height 100}}})
+
+(defn- task
+ "A task on `shape-id`, in a thread of its own unless `attrs` names one:
+ every task lives in a thread."
+ [order shape-id & {:as attrs}]
+ (merge {:id (uuid/next)
+ :thread-id (uuid/next)
+ :shape-id shape-id
+ :created-at order}
+ attrs))
+
+(defn- thread
+ [order position & {:as attrs}]
+ (merge {:id (uuid/next)
+ :anchor-type :canvas
+ :position position
+ :created-at order}
+ attrs))
+
+(defn- cluster-sizes
+ "How many marks each cluster has and how many items each mark holds."
+ [clusters]
+ (->> clusters
+ (map (fn [marks]
+ (sort (map #(if (:thread %) 1 (count (:tasks %))) marks))))
+ (sort-by count)))
+
+(t/deftest tasks-of-a-layer-share-a-cluster
+ (let [tasks [(task 1 shape-a) (task 2 shape-a) (task 3 shape-a)]]
+ (t/is (= [[1 1 1]]
+ (cluster-sizes (rvm/mark-clusters objects 1 [] tasks))))))
+
+(t/deftest tasks-of-a-layer-stay-together-at-any-zoom
+ (let [tasks [(task 1 shape-a) (task 2 shape-a)]]
+ (t/is (= [[1 1]]
+ (cluster-sizes (rvm/mark-clusters objects 64 [] tasks))))))
+
+(t/deftest tasks-of-a-thread-make-one-mark
+ (let [thread-id (uuid/next)
+ tasks [(task 1 shape-a :thread-id thread-id)
+ (task 2 shape-a :thread-id thread-id)]]
+ (t/is (= [[2]]
+ (cluster-sizes (rvm/mark-clusters objects 1 [] tasks))))))
+
+(t/deftest tasks-of-a-thread-on-other-layers-make-a-mark-each
+ (let [thread-id (uuid/next)
+ tasks [(task 1 shape-a :thread-id thread-id)
+ (task 2 shape-b :thread-id thread-id)]]
+ (t/is (= [[1 1]]
+ (cluster-sizes (rvm/mark-clusters objects 1 [] tasks))))))
+
+(t/deftest marks-of-close-layers-group-by-zoom
+ (let [tasks [(task 1 shape-a) (task 2 shape-b)]]
+ (t/testing "their marks overlap on screen"
+ (t/is (= [[1 1]]
+ (cluster-sizes (rvm/mark-clusters objects 1 [] tasks)))))
+ (t/testing "zooming in separates them"
+ (t/is (= [[1] [1]]
+ (cluster-sizes (rvm/mark-clusters objects 4 [] tasks)))))))
+
+(t/deftest threads-of-a-layer-share-a-cluster
+ (let [threads [(thread 1 {:x 0 :y 0} :anchor-type :layer :shape-id shape-a)
+ (thread 2 {:x 50 :y 50} :anchor-type :layer :shape-id shape-a)]]
+ (t/is (= [[1 1]]
+ (cluster-sizes (rvm/mark-clusters objects 64 threads []))))))
+
+(t/deftest a-thread-and-a-task-of-a-layer-share-a-cluster
+ (let [threads [(thread 2 {:x 0 :y 0} :anchor-type :layer :shape-id shape-a)]
+ clusters (rvm/mark-clusters objects 1 threads [(task 1 shape-a)])]
+ (t/is (= [[1 1]] (cluster-sizes clusters)))
+ (t/testing "oldest first, whatever their kind"
+ (t/is (= [false true]
+ (->> (first clusters)
+ (sort-by :seqn)
+ (mapv #(some? (:thread %)))))))))
+
+(t/deftest threads-apart-keep-their-marks
+ (let [threads [(thread 1 {:x 0 :y 0}) (thread 2 {:x 500 :y 500})]]
+ (t/is (= [[1] [1]]
+ (cluster-sizes (rvm/mark-clusters objects 1 threads []))))))
+
+(t/deftest marks-keep-the-order-of-their-tasks
+ (let [first-task (task 1 shape-a)
+ second-task (task 2 shape-a)
+ clusters (rvm/mark-clusters objects 1 [] [second-task first-task])
+ marks (sort-by :seqn (first clusters))]
+ (t/is (= [(:id first-task) (:id second-task)]
+ (mapv :id marks)))))
+
+(t/deftest a-task-without-a-place-has-no-mark
+ (t/is (empty? (rvm/mark-clusters objects 1 [] [(task 1 (uuid/next))]))))
+
+(t/deftest marks-name-the-layer-to-outline
+ (let [threads [(thread 1 {:x 900 :y 900})
+ (thread 2 {:x 0 :y 0} :anchor-type :layer :shape-id shape-b)]
+ marks (->> (rvm/mark-clusters objects 1 threads [(task 3 shape-a)])
+ (apply concat)
+ (sort-by :seqn))]
+ (t/testing "a thread on the canvas names none"
+ (t/is (nil? (:shape-ids (first marks)))))
+ (t/testing "a thread on a layer names it"
+ (t/is (= [shape-b] (:shape-ids (second marks)))))
+ (t/testing "a task names its layer"
+ (t/is (= [shape-a] (:shape-ids (last marks)))))))
+
+(t/deftest a-task-of-a-deleted-layer-names-its-board
+ (let [board-id (uuid/next)
+ objects (assoc objects board-id {:id board-id
+ :selrect {:x 0 :y 0 :width 900 :height 900}})
+ task (task 1 (uuid/next) :frame-id board-id)
+ mark (ffirst (rvm/mark-clusters objects 1 [] [task]))]
+ (t/is (= [board-id] (:shape-ids mark)))))
+
+(t/deftest a-thread-on-a-layer-opens-by-the-layer-as-a-point
+ ;; the open thread takes this position, and answering it checks that the
+ ;; thread is valid: a plain map is not a point
+ (let [position (rvm/thread-position objects (thread 1 (gpt/point 0 0)
+ :anchor-type :layer
+ :shape-id shape-a))]
+ (t/is (gpt/point? position))
+ (t/is (= (gpt/point 100 0) position))))
+
+(t/deftest opening-a-task-collapses-the-fan
+ (let [state {:comments-local {:expanded #{(uuid/next)}}}
+ result (ptk/update (dwtk/open-task (uuid/next)) state)]
+ (t/is (nil? (get-in result [:comments-local :expanded])))))
+
+(t/deftest changing-the-assignee-shows-right-away
+ (let [task-id (uuid/next)
+ assignee (uuid/next)
+ state {:workspace-tasks {:data {task-id {:id task-id :assignee-id assignee}}}}]
+ (t/testing "to somebody else"
+ (let [other (uuid/next)
+ result (ptk/update (dwtk/update-task task-id {:assignee-id other}) state)]
+ (t/is (= other (get-in result [:workspace-tasks :data task-id :assignee-id])))))
+ (t/testing "to nobody"
+ (let [result (ptk/update (dwtk/update-task task-id {:assignee-id nil}) state)]
+ (t/is (nil? (get-in result [:workspace-tasks :data task-id :assignee-id])))))
+ (t/testing "a rename keeps it"
+ (let [result (ptk/update (dwtk/update-task task-id {:title "Other"}) state)]
+ (t/is (= assignee (get-in result [:workspace-tasks :data task-id :assignee-id])))))))
diff --git a/frontend/translations/en.po b/frontend/translations/en.po
index 7879fa9a19..d7c8d7716f 100644
--- a/frontend/translations/en.po
+++ b/frontend/translations/en.po
@@ -3295,6 +3295,14 @@ msgstr "Login"
msgid "labels.logout"
msgstr "Logout"
+#: src/app/main/ui/comments.cljs
+msgid "labels.mark-as-resolved"
+msgstr "Mark as resolved"
+
+#: src/app/main/ui/comments.cljs
+msgid "labels.mark-as-unresolved"
+msgstr "Mark as unresolved"
+
#: src/app/main/ui/onboarding/questions.cljs:88
msgid "labels.marketing"
msgstr "Marketing"
@@ -4014,6 +4022,18 @@ msgstr[1] "Are you sure you want to delete these %s assets?"
msgid "modals.delete-asset-group.title"
msgstr "Delete group"
+#: src/app/main/ui/comments.cljs
+msgid "modals.delete-comment.accept"
+msgstr "Delete comment"
+
+#: src/app/main/ui/comments.cljs
+msgid "modals.delete-comment.message"
+msgstr "Are you sure you want to delete this comment?"
+
+#: src/app/main/ui/comments.cljs
+msgid "modals.delete-comment.title"
+msgstr "Delete comment"
+
#: src/app/main/ui/comments.cljs:941
msgid "modals.delete-comment-thread.accept"
msgstr "Delete conversation"
@@ -4024,6 +4044,12 @@ msgstr ""
"Are you sure you want to delete this conversation? All comments in this "
"thread will be deleted."
+#: src/app/main/ui/comments.cljs
+msgid "modals.delete-comment-thread.message-tasks"
+msgstr ""
+"Are you sure you want to delete this conversation? All comments in this "
+"thread and the tasks they hold will be deleted."
+
#: src/app/main/ui/comments.cljs:939
msgid "modals.delete-comment-thread.title"
msgstr "Delete conversation"
@@ -4084,6 +4110,18 @@ msgstr "Deleting font"
msgid "modals.delete-organization-team-confirm.message"
msgstr "Are you sure you want to delete this team that is part of %s org?"
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "modals.delete-task.accept"
+msgstr "Delete task"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "modals.delete-task.message"
+msgstr "Are you sure you want to delete this task?"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "modals.delete-task.title"
+msgstr "Delete task"
+
#: src/app/main/ui/workspace/context_menu.cljs:816, src/app/main/ui/workspace/sidebar/sitemap.cljs:125
msgid "modals.delete-page.body"
msgstr "Are you sure you want to delete this page?"
@@ -6685,7 +6723,7 @@ msgstr[1] "%s conflicts with main"
#: src/app/main/ui/workspace/sidebar/branches.cljs:1847
msgid "workspace.branches.banner.status.in-review"
-msgstr "In review · %s of %s approved"
+msgstr "In review - %s of %s approved"
#: src/app/main/ui/workspace/sidebar/branches.cljs:1858
msgid "workspace.branches.banner.status.up-to-date"
@@ -7698,7 +7736,7 @@ msgstr ""
#: src/app/main/ui/workspace/sidebar/branches.cljs:439
#, unused
msgid "workspace.branches.you-editing"
-msgstr "%s · editing now"
+msgstr "%s - editing now"
#: src/app/main/data/workspace/clipboard.cljs:1242
msgid "workspace.clipboard.copying"
@@ -9821,7 +9859,12 @@ msgstr "%s conflicts"
#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:356, src/app/main/ui/workspace/sidebar/pull_requests.cljs:534, src/app/main/ui/workspace/sidebar/pull_requests.cljs:719
msgid "workspace.pull-requests.badge.outdated"
-msgstr "New changes on branch"
+msgstr "Unpublished changes"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs
+msgid "workspace.pull-requests.badge.outdated-hint"
+msgstr ""
+"The branch has changes the reviewers can't see yet. Merging includes them."
#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:623
msgid "workspace.pull-requests.banner.cancel"
@@ -9835,6 +9878,12 @@ msgstr "Exit review"
msgid "workspace.pull-requests.banner.publish"
msgstr "Publish latest changes"
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs
+msgid "workspace.pull-requests.banner.publish-hint"
+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"
@@ -12224,3 +12273,672 @@ msgstr[1] "Choosing a side here also decides %s copies."
#: src/app/main/ui/workspace/sidebar/branch_review/facts.cljs
msgid "workspace.branches.review.copies.via"
msgstr "%s follows the change through its copy of %s"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.merge.confirm-anyway"
+msgstr "Merge anyway"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.merge.notify-assignees"
+msgstr "Tell the assignees their tasks moved to main"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.merge.open-tasks-title"
+msgstr "Open tasks"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.all"
+msgstr "All"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.click-to-show"
+msgstr "Click to show it on the canvas"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.empty"
+msgstr "Nothing has changed since the review opened."
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.error"
+msgstr "The activity of the review could not be loaded."
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.now-points-to"
+msgstr "Now points to %s"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.open-task-to-relink"
+msgstr "Open the task to re-link it"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.opened"
+msgstr "%s opened the review - %s"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.show-on-canvas"
+msgstr "Show on canvas"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.summary"
+msgstr "%s changes by %s people since the review opened"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.today"
+msgstr "Today"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.yesterday"
+msgstr "Yesterday"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.review.anchor.area"
+msgstr "Area - %s × %s"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.review.anchor.deleted-layer"
+msgstr "Deleted layer"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.approved-of"
+msgstr "%s of %s approved"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs
+msgid "workspace.review.bar.details"
+msgstr "Details"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs
+msgid "workspace.review.bar.label"
+msgstr "Design review"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs
+msgid "workspace.review.bar.tasks"
+msgstr "%s/%s tasks"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.change.added"
+msgstr "Added"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.review.change.added-lower"
+msgstr "added"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.change.deleted"
+msgstr "Deleted"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.review.change.deleted-lower"
+msgstr "deleted"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.change.modified"
+msgstr "Modified"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.review.change.modified-lower"
+msgstr "modified"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.changes.back"
+msgstr "Back to details"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.changes.by"
+msgstr "%s by %s - %s"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.changes.label"
+msgstr "Changes of the review"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.changes.next"
+msgstr "Next change"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.changes.none"
+msgstr "No changes to show"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.changes.position"
+msgstr "%s / %s"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.changes.previous"
+msgstr "Previous change"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.comment-number"
+msgstr "#%s"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.comments.empty"
+msgstr "No comments here yet."
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.comments.no-replies"
+msgstr "No replies"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.comments.one-reply"
+msgstr "1 reply"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.comments.replies"
+msgstr "%s replies"
+
+#: src/app/main/ui/comments.cljs
+msgid "workspace.review.design-review"
+msgstr "Design review"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.activity"
+msgstr "Activity (%s)"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.add-reviewer"
+msgstr "Add reviewer"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.branch"
+msgstr "Branch"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.close-review"
+msgstr "Close review"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.closed"
+msgstr "Closed (%s)"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.comments"
+msgstr "Comments"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.comments-open"
+msgstr "%s open"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.comments-resolved"
+msgstr "%s resolved"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.last-change"
+msgstr "Last change"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.last-change-by"
+msgstr "%s by %s"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.no-description"
+msgstr "No description."
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.no-reviewers"
+msgstr "Nobody has been asked to review it yet."
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.opened"
+msgstr "Opened"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.opened-by"
+msgstr "Opened %s by %s"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.overview"
+msgstr "Overview"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.pick-reviewer"
+msgstr "Pick a reviewer"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.quoted-comment"
+msgstr "“%s”"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.up-to-date"
+msgstr "Up to date"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.x-of-y"
+msgstr "%s of %s"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.label-count"
+msgstr "%s %s"
+
+#: src/app/main/ui/workspace/review/markers.cljs
+msgid "workspace.review.marker.comment"
+msgstr "Comment %s"
+
+#: src/app/main/ui/workspace/review/markers.cljs
+msgid "workspace.review.marker.comments"
+msgstr "%s comments"
+
+#: src/app/main/ui/workspace/review/markers.cljs
+msgid "workspace.review.marker.items"
+msgstr "%s comments and tasks"
+
+#: src/app/main/ui/workspace/review/markers.cljs
+msgid "workspace.review.marker.more"
+msgstr "%s more"
+
+#: src/app/main/ui/workspace/review/markers.cljs
+msgid "workspace.review.marker.task"
+msgstr "Task: %s"
+
+#: src/app/main/ui/workspace/review/markers.cljs
+msgid "workspace.review.marker.tasks"
+msgstr "%s tasks"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.route"
+msgstr "%s → %s"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs
+msgid "workspace.review.submit"
+msgstr "Submit review"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.tab.comments"
+msgstr "Comments (%s)"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.tab.tasks"
+msgstr "Tasks (%s)"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.tab.tasks-plain"
+msgstr "Tasks"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.text-and-detail"
+msgstr "%s - %s"
+
+#: src/app/main/ui/workspace/top_toolbar.cljs
+msgid "workspace.review.toolbar.comment"
+msgstr "Comment"
+
+#: src/app/main/ui/workspace/top_toolbar.cljs
+msgid "workspace.review.toolbar.comment-area"
+msgstr "Comment an area"
+
+#: src/app/main/ui/workspace/top_toolbar.cljs
+msgid "workspace.review.toolbar.label"
+msgstr "Review tools"
+
+#: src/app/main/ui/workspace/top_toolbar.cljs
+msgid "workspace.review.toolbar.move"
+msgstr "Move"
+
+#: src/app/main/ui/workspace/top_toolbar.cljs
+msgid "workspace.review.toolbar.show-changes"
+msgstr "Show changes"
+
+#: src/app/main/ui/workspace/top_toolbar.cljs
+msgid "workspace.review.toolbar.task"
+msgstr "Create a task"
+
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.assign"
+msgstr "Assign to"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.delete"
+msgstr "Delete task"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.mark-done"
+msgstr "Mark as done"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.relink"
+msgstr "Link to another layer"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.relink-short"
+msgstr "Re-link"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.reopen"
+msgstr "Reopen"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.restore-layer"
+msgstr "Restore layer"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.show-change"
+msgstr "Show change"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.verify"
+msgstr "Verify"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.wont-do"
+msgstr "Won't do"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.assigned-to"
+msgstr "Assigned to %s"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.change-assignee"
+msgstr "Change assignee. Now: %s"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.assignee"
+msgstr "Assignee"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.assignee-me"
+msgstr "%s (you)"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.tasks.canvas"
+msgstr "Canvas"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.closed-of"
+msgstr "%s of %s closed"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.create"
+msgstr "Create task"
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.created"
+msgstr "Task created"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.tasks.empty"
+msgstr "No tasks here."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.error.generic"
+msgstr "The task could not be changed. Try again."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.error.comment-has-task"
+msgstr "This comment is a task already."
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.assigned"
+msgstr "%s assigned it to %s"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.assigned-to-you"
+msgstr "%s made this a task for you"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.done"
+msgstr "%s marked it as done"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.layer-deleted"
+msgstr "%s deleted %s"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.layer-restored"
+msgstr "%s restored %s"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.moved-to-main"
+msgstr "Moved to main with the merge of %s"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.relinked"
+msgstr "%s linked it to %s"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.renamed"
+msgstr "%s renamed it"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.reopened"
+msgstr "%s reopened it"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.status"
+msgstr "%s changed its state"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.unassigned"
+msgstr "%s left it without assignee"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.verified"
+msgstr "%s verified it"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.wont-do"
+msgstr "%s marked it as won't do"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.for-you"
+msgstr "For you"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.from"
+msgstr "from"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.tasks.group.other"
+msgstr "Other tasks"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.tasks.group.review"
+msgstr "From review - %s"
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.layer-deleted.many"
+msgstr "%s open tasks moved to the board of their deleted layer."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.layer-deleted.one"
+msgstr "%s had an open task. Moved to %s."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.layer-deleted.undo"
+msgstr "Undo"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.linked-to"
+msgstr "Linked to"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.lost.message"
+msgstr "This task now points to %s. Link it to another layer, or mark it as done if deleting was the fix."
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.make-task"
+msgstr "Make it a task"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.make-task.hint"
+msgstr "Title taken from the comment. The thread stays attached to the task."
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.new-task"
+msgstr "New task"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.new-task.hint"
+msgstr "The title is the first message of its thread, where anyone can go on commenting."
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.tasks.relink.link-to"
+msgstr "Link to %s"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.tasks.relink.pick"
+msgstr "Pick a layer for"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.tasks.status.done"
+msgstr "Done"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.tasks.status.open"
+msgstr "Open"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.tasks.status.reopened"
+msgstr "Reopened"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.tasks.status.verified"
+msgstr "Verified"
+
+#: src/app/main/ui/workspace/review/common.cljs
+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"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.title-placeholder"
+msgstr "What needs to be done?"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.to-verify"
+msgstr "%s to verify"
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.toast.done"
+msgstr "Marked as done."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.toast.done-verify"
+msgstr "Marked as done. %s will verify it."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.toast.layer-restored"
+msgstr "%s is back and the task points to it again."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.toast.relinked"
+msgstr "The task now points to %s."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.toast.reopened"
+msgstr "Task reopened."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.toast.verified"
+msgstr "Task verified and closed."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.toast.wont-do"
+msgstr "Task closed as won't do."
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.unassigned"
+msgstr "Unassigned"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.verify.message"
+msgstr "Does the change fix it? Verify to close the task, or reopen it for %s."
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.verify.message-unassigned"
+msgstr "Does the change fix it? Verify to close the task, or reopen it."
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.tasks.view.all"
+msgstr "Show all tasks"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.tasks.view.hide-closed"
+msgstr "Hide closed tasks"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.tasks.view.mine"
+msgstr "Show only your tasks"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.tasks.view.open"
+msgstr "Show only open tasks"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.tasks.view.to-verify"
+msgstr "Show only tasks to verify"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.you"
+msgstr "You"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.tasks.for-you-count"
+msgid_plural "workspace.tasks.for-you-count"
+msgstr[0] "1 task for you"
+msgstr[1] "%s tasks for you"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.merge.open-tasks"
+msgid_plural "workspace.branches.merge.open-tasks"
+msgstr[0] "1 task is still open. It will move to main as it is."
+msgstr[1] "%s tasks are still open. They will move to main as they are."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.merge.more-open-tasks"
+msgid_plural "workspace.branches.merge.more-open-tasks"
+msgstr[0] "+ 1 more open task"
+msgstr[1] "+ %s more open tasks"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.changed"
+msgid_plural "workspace.review.activity.changed"
+msgstr[0] "changed 1 element"
+msgstr[1] "changed %s elements"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.more"
+msgid_plural "workspace.review.activity.more"
+msgstr[0] "+1 more"
+msgstr[1] "+%s more"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.needs-approvals"
+msgid_plural "workspace.review.details.needs-approvals"
+msgstr[0] "Needs 1 more approval."
+msgstr[1] "Needs %s more approvals."
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.open-tasks-dont-block"
+msgid_plural "workspace.review.details.open-tasks-dont-block"
+msgstr[0] "1 open task won't block the merge."
+msgstr[1] "%s open tasks won't block the merge."
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.linked-tasks"
+msgid_plural "workspace.review.activity.linked-tasks"
+msgstr[0] "1 linked task"
+msgstr[1] "%s linked tasks"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.behind"
+msgid_plural "workspace.review.details.behind"
+msgstr[0] "1 change behind main"
+msgstr[1] "%s changes behind main"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.review.unknown-name"
+msgstr "—"
+
+#: src/app/main/ui/workspace/sidebar/layer_item.cljs
+msgid "workspace.sidebar.layers.comments"
+msgid_plural "workspace.sidebar.layers.comments"
+msgstr[0] "1 open comment"
+msgstr[1] "%s open comments"
diff --git a/frontend/translations/es.po b/frontend/translations/es.po
index aafb0eb9e3..f8143b15a5 100644
--- a/frontend/translations/es.po
+++ b/frontend/translations/es.po
@@ -3330,6 +3330,14 @@ msgstr "Entrar"
msgid "labels.logout"
msgstr "Salir"
+#: src/app/main/ui/comments.cljs
+msgid "labels.mark-as-resolved"
+msgstr "Marcar como resuelto"
+
+#: src/app/main/ui/comments.cljs
+msgid "labels.mark-as-unresolved"
+msgstr "Marcar como no resuelto"
+
#: src/app/main/ui/onboarding/questions.cljs:88
msgid "labels.marketing"
msgstr "Marketing"
@@ -4029,6 +4037,18 @@ msgstr[1] "¿Estás seguro de que quieres eliminar estos %s recursos?"
msgid "modals.delete-asset-group.title"
msgstr "Eliminar grupo"
+#: src/app/main/ui/comments.cljs
+msgid "modals.delete-comment.accept"
+msgstr "Eliminar comentario"
+
+#: src/app/main/ui/comments.cljs
+msgid "modals.delete-comment.message"
+msgstr "¿Seguro que quieres eliminar este comentario?"
+
+#: src/app/main/ui/comments.cljs
+msgid "modals.delete-comment.title"
+msgstr "Eliminar comentario"
+
#: src/app/main/ui/comments.cljs:941
msgid "modals.delete-comment-thread.accept"
msgstr "Eliminar conversación"
@@ -4039,6 +4059,12 @@ msgstr ""
"¿Seguro que quieres eliminar esta conversación? Todos los comentarios en "
"este hilo serán eliminados."
+#: src/app/main/ui/comments.cljs
+msgid "modals.delete-comment-thread.message-tasks"
+msgstr ""
+"¿Seguro que quieres eliminar esta conversación? Todos los comentarios en "
+"este hilo y sus tareas serán eliminados."
+
#: src/app/main/ui/comments.cljs:939
msgid "modals.delete-comment-thread.title"
msgstr "Eliminar conversación"
@@ -4101,6 +4127,18 @@ msgstr ""
"¿Estás seguro de que deseas eliminar este equipo que forma parte de la "
"organización %s?"
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "modals.delete-task.accept"
+msgstr "Eliminar tarea"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "modals.delete-task.message"
+msgstr "¿Seguro que quieres eliminar esta tarea?"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "modals.delete-task.title"
+msgstr "Eliminar tarea"
+
#: src/app/main/ui/workspace/context_menu.cljs:816, src/app/main/ui/workspace/sidebar/sitemap.cljs:125
msgid "modals.delete-page.body"
msgstr "¿Seguro que quieres borrar esta página?"
@@ -6687,7 +6725,7 @@ msgstr[1] "%s conflictos con main"
#: src/app/main/ui/workspace/sidebar/branches.cljs:1847
msgid "workspace.branches.banner.status.in-review"
-msgstr "En revisión · %s de %s aprobaciones"
+msgstr "En revisión - %s de %s aprobaciones"
#: src/app/main/ui/workspace/sidebar/branches.cljs:1858
msgid "workspace.branches.banner.status.up-to-date"
@@ -10329,6 +10367,694 @@ msgstr "Los autoguardados duran %s días."
msgid "workspace.pull-requests.header-label"
msgstr "Revisión:"
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs
+msgid "workspace.pull-requests.badge.outdated"
+msgstr "Cambios sin publicar"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs
+msgid "workspace.pull-requests.badge.outdated-hint"
+msgstr ""
+"La rama tiene cambios que los reviewers aún no ven. Al fusionar se incluyen."
+
#: src/app/main/ui/workspace/sidebar/pull_requests.cljs:623
msgid "workspace.pull-requests.banner.cancel"
msgstr "Cancelar revisión"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs
+msgid "workspace.pull-requests.banner.publish"
+msgstr "Publicar últimos cambios"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs
+msgid "workspace.pull-requests.banner.publish-hint"
+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/branches.cljs
+msgid "workspace.branches.merge.confirm-anyway"
+msgstr "Fusionar igualmente"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.merge.notify-assignees"
+msgstr "Avisar a los responsables de que sus tareas pasan a main"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.merge.open-tasks-title"
+msgstr "Tareas abiertas"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.all"
+msgstr "Todo"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.click-to-show"
+msgstr "Haz clic para verlo en el lienzo"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.empty"
+msgstr "No ha cambiado nada desde que se abrió la revisión."
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.error"
+msgstr "No se pudo cargar la actividad de la revisión."
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.now-points-to"
+msgstr "Ahora apunta a %s"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.open-task-to-relink"
+msgstr "Abre la tarea para enlazarla de nuevo"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.opened"
+msgstr "%s abrió la revisión - %s"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.show-on-canvas"
+msgstr "Ver en el lienzo"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.summary"
+msgstr "%s cambios de %s personas desde que se abrió la revisión"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.today"
+msgstr "Hoy"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.yesterday"
+msgstr "Ayer"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.review.anchor.area"
+msgstr "Área - %s × %s"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.review.anchor.deleted-layer"
+msgstr "Capa borrada"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.approved-of"
+msgstr "%s de %s aprobadas"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs
+msgid "workspace.review.bar.details"
+msgstr "Detalles"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs
+msgid "workspace.review.bar.label"
+msgstr "Revisión de diseño"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs
+msgid "workspace.review.bar.tasks"
+msgstr "%s/%s tareas"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.change.added"
+msgstr "Añadido"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.review.change.added-lower"
+msgstr "añadido"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.change.deleted"
+msgstr "Borrado"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.review.change.deleted-lower"
+msgstr "borrado"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.change.modified"
+msgstr "Modificado"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.review.change.modified-lower"
+msgstr "modificado"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.changes.back"
+msgstr "Volver a los detalles"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.changes.by"
+msgstr "%s por %s - %s"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.changes.label"
+msgstr "Cambios de la revisión"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.changes.next"
+msgstr "Cambio siguiente"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.changes.none"
+msgstr "No hay cambios que mostrar"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.changes.position"
+msgstr "%s / %s"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.review.changes.previous"
+msgstr "Cambio anterior"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.comment-number"
+msgstr "#%s"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.comments.empty"
+msgstr "Todavía no hay comentarios."
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.comments.no-replies"
+msgstr "Sin respuestas"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.comments.one-reply"
+msgstr "1 respuesta"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.comments.replies"
+msgstr "%s respuestas"
+
+#: src/app/main/ui/comments.cljs
+msgid "workspace.review.design-review"
+msgstr "Revisión de diseño"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.activity"
+msgstr "Actividad (%s)"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.add-reviewer"
+msgstr "Añadir revisor"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.branch"
+msgstr "Rama"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.close-review"
+msgstr "Cerrar revisión"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.closed"
+msgstr "Cerradas (%s)"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.comments"
+msgstr "Comentarios"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.comments-open"
+msgstr "%s abiertos"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.comments-resolved"
+msgstr "%s resueltos"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.last-change"
+msgstr "Último cambio"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.last-change-by"
+msgstr "%s por %s"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.no-description"
+msgstr "Sin descripción."
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.no-reviewers"
+msgstr "Todavía no se ha pedido a nadie que la revise."
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.opened"
+msgstr "Abierta"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.opened-by"
+msgstr "Abierta el %s por %s"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.overview"
+msgstr "Resumen"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.pick-reviewer"
+msgstr "Elige un revisor"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.quoted-comment"
+msgstr "“%s”"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.up-to-date"
+msgstr "Al día"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.x-of-y"
+msgstr "%s de %s"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.label-count"
+msgstr "%s %s"
+
+#: src/app/main/ui/workspace/review/markers.cljs
+msgid "workspace.review.marker.comment"
+msgstr "Comentario %s"
+
+#: src/app/main/ui/workspace/review/markers.cljs
+msgid "workspace.review.marker.comments"
+msgstr "%s comentarios"
+
+#: src/app/main/ui/workspace/review/markers.cljs
+msgid "workspace.review.marker.items"
+msgstr "%s comentarios y tareas"
+
+#: src/app/main/ui/workspace/review/markers.cljs
+msgid "workspace.review.marker.more"
+msgstr "%s más"
+
+#: src/app/main/ui/workspace/review/markers.cljs
+msgid "workspace.review.marker.task"
+msgstr "Tarea: %s"
+
+#: src/app/main/ui/workspace/review/markers.cljs
+msgid "workspace.review.marker.tasks"
+msgstr "%s tareas"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.route"
+msgstr "%s → %s"
+
+#: src/app/main/ui/workspace/sidebar/pull_requests.cljs
+msgid "workspace.review.submit"
+msgstr "Enviar revisión"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.tab.comments"
+msgstr "Comentarios (%s)"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.tab.tasks"
+msgstr "Tareas (%s)"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.tab.tasks-plain"
+msgstr "Tareas"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.review.text-and-detail"
+msgstr "%s - %s"
+
+#: src/app/main/ui/workspace/top_toolbar.cljs
+msgid "workspace.review.toolbar.comment"
+msgstr "Comentar"
+
+#: src/app/main/ui/workspace/top_toolbar.cljs
+msgid "workspace.review.toolbar.comment-area"
+msgstr "Comentar un área"
+
+#: src/app/main/ui/workspace/top_toolbar.cljs
+msgid "workspace.review.toolbar.label"
+msgstr "Herramientas de revisión"
+
+#: src/app/main/ui/workspace/top_toolbar.cljs
+msgid "workspace.review.toolbar.move"
+msgstr "Mover"
+
+#: src/app/main/ui/workspace/top_toolbar.cljs
+msgid "workspace.review.toolbar.show-changes"
+msgstr "Ver los cambios"
+
+#: src/app/main/ui/workspace/top_toolbar.cljs
+msgid "workspace.review.toolbar.task"
+msgstr "Crear una tarea"
+
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.assign"
+msgstr "Asignar a"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.delete"
+msgstr "Borrar tarea"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.mark-done"
+msgstr "Marcar como hecha"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.relink"
+msgstr "Enlazar a otra capa"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.relink-short"
+msgstr "Enlazar"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.reopen"
+msgstr "Reabrir"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.restore-layer"
+msgstr "Restaurar capa"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.show-change"
+msgstr "Ver el cambio"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.verify"
+msgstr "Verificar"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.actions.wont-do"
+msgstr "No se hará"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.assigned-to"
+msgstr "Asignada a %s"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.change-assignee"
+msgstr "Cambiar responsable. Ahora: %s"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.assignee"
+msgstr "Responsable"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.assignee-me"
+msgstr "%s (tú)"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.tasks.canvas"
+msgstr "Lienzo"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.closed-of"
+msgstr "%s de %s cerradas"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.create"
+msgstr "Crear tarea"
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.created"
+msgstr "Tarea creada"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.tasks.empty"
+msgstr "No hay tareas."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.error.generic"
+msgstr "No se pudo cambiar la tarea. Inténtalo de nuevo."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.error.comment-has-task"
+msgstr "Este comentario ya es una tarea."
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.assigned"
+msgstr "%s se la asignó a %s"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.assigned-to-you"
+msgstr "%s hizo de esto una tarea para ti"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.done"
+msgstr "%s la marcó como hecha"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.layer-deleted"
+msgstr "%s borró %s"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.layer-restored"
+msgstr "%s restauró %s"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.moved-to-main"
+msgstr "Pasó a main con la fusión de %s"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.relinked"
+msgstr "%s la enlazó a %s"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.renamed"
+msgstr "%s le cambió el título"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.reopened"
+msgstr "%s la reabrió"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.status"
+msgstr "%s cambió su estado"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.unassigned"
+msgstr "%s la dejó sin responsable"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.verified"
+msgstr "%s la verificó"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.event.wont-do"
+msgstr "%s la marcó como que no se hará"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.for-you"
+msgstr "Para ti"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.from"
+msgstr "de"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.tasks.group.other"
+msgstr "Otras tareas"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.tasks.group.review"
+msgstr "De la revisión - %s"
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.layer-deleted.many"
+msgstr "%s tareas abiertas pasaron al tablero de su capa borrada."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.layer-deleted.one"
+msgstr "%s tenía una tarea abierta. Pasó a %s."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.layer-deleted.undo"
+msgstr "Deshacer"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.linked-to"
+msgstr "Enlazada a"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.lost.message"
+msgstr "Esta tarea ahora apunta a %s. Enlázala a otra capa, o márcala como hecha si borrar la capa era la solución."
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.make-task"
+msgstr "Convertir en tarea"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.make-task.hint"
+msgstr "Título tomado del comentario. El hilo queda unido a la tarea."
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.new-task"
+msgstr "Nueva tarea"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.new-task.hint"
+msgstr "El título es el primer mensaje de su hilo, donde todos pueden seguir comentando."
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.tasks.relink.link-to"
+msgstr "Enlazar a %s"
+
+#: src/app/main/ui/workspace/review/overlays.cljs
+msgid "workspace.tasks.relink.pick"
+msgstr "Elige una capa para"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.tasks.status.done"
+msgstr "Hecha"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.tasks.status.open"
+msgstr "Abierta"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.tasks.status.reopened"
+msgstr "Reabierta"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.tasks.status.verified"
+msgstr "Verificada"
+
+#: src/app/main/ui/workspace/review/common.cljs
+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"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.title-placeholder"
+msgstr "¿Qué hay que hacer?"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.to-verify"
+msgstr "%s por verificar"
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.toast.done"
+msgstr "Marcada como hecha."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.toast.done-verify"
+msgstr "Marcada como hecha. %s la verificará."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.toast.layer-restored"
+msgstr "%s ha vuelto y la tarea vuelve a apuntar a ella."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.toast.relinked"
+msgstr "La tarea ahora apunta a %s."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.toast.reopened"
+msgstr "Tarea reabierta."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.toast.verified"
+msgstr "Tarea verificada y cerrada."
+
+#: src/app/main/data/workspace/tasks.cljs
+msgid "workspace.tasks.toast.wont-do"
+msgstr "Tarea cerrada como que no se hará."
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.unassigned"
+msgstr "Sin responsable"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.verify.message"
+msgstr "¿El cambio lo arregla? Verifica para cerrar la tarea, o reábrela para %s."
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.verify.message-unassigned"
+msgstr "¿El cambio lo arregla? Verifica para cerrar la tarea, o reábrela."
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.tasks.view.all"
+msgstr "Mostrar todas las tareas"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.tasks.view.hide-closed"
+msgstr "Ocultar las tareas cerradas"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.tasks.view.mine"
+msgstr "Mostrar solo tus tareas"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.tasks.view.open"
+msgstr "Mostrar solo las tareas abiertas"
+
+#: src/app/main/ui/workspace/review/panel.cljs
+msgid "workspace.tasks.view.to-verify"
+msgstr "Mostrar solo las tareas por verificar"
+
+#: src/app/main/ui/workspace/review/tasks.cljs
+msgid "workspace.tasks.you"
+msgstr "Tú"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.tasks.for-you-count"
+msgid_plural "workspace.tasks.for-you-count"
+msgstr[0] "1 tarea para ti"
+msgstr[1] "%s tareas para ti"
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.merge.open-tasks"
+msgid_plural "workspace.branches.merge.open-tasks"
+msgstr[0] "1 tarea sigue abierta. Pasará a main tal como está."
+msgstr[1] "%s tareas siguen abiertas. Pasarán a main tal como están."
+
+#: src/app/main/ui/workspace/sidebar/branches.cljs
+msgid "workspace.branches.merge.more-open-tasks"
+msgid_plural "workspace.branches.merge.more-open-tasks"
+msgstr[0] "+ 1 tarea abierta más"
+msgstr[1] "+ %s tareas abiertas más"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.changed"
+msgid_plural "workspace.review.activity.changed"
+msgstr[0] "cambió 1 elemento"
+msgstr[1] "cambió %s elementos"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.more"
+msgid_plural "workspace.review.activity.more"
+msgstr[0] "+1 más"
+msgstr[1] "+%s más"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.needs-approvals"
+msgid_plural "workspace.review.details.needs-approvals"
+msgstr[0] "Falta 1 aprobación."
+msgstr[1] "Faltan %s aprobaciones."
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.open-tasks-dont-block"
+msgid_plural "workspace.review.details.open-tasks-dont-block"
+msgstr[0] "1 tarea abierta no bloqueará la fusión."
+msgstr[1] "%s tareas abiertas no bloquearán la fusión."
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.activity.linked-tasks"
+msgid_plural "workspace.review.activity.linked-tasks"
+msgstr[0] "1 tarea enlazada"
+msgstr[1] "%s tareas enlazadas"
+
+#: src/app/main/ui/workspace/review/details.cljs
+msgid "workspace.review.details.behind"
+msgid_plural "workspace.review.details.behind"
+msgstr[0] "1 cambio por detrás de main"
+msgstr[1] "%s cambios por detrás de main"
+
+#: src/app/main/ui/workspace/review/common.cljs
+msgid "workspace.review.unknown-name"
+msgstr "—"
+
+#: src/app/main/ui/workspace/sidebar/layer_item.cljs
+msgid "workspace.sidebar.layers.comments"
+msgid_plural "workspace.sidebar.layers.comments"
+msgstr[0] "1 comentario abierto"
+msgstr[1] "%s comentarios abiertos"