mirror of
https://github.com/penpot/penpot.git
synced 2026-11-26 21:00:32 +00:00
Merge branch 'interface-vocabulary' into iop-vc-preview
This commit is contained in:
commit
be49abf2cf
@ -109,11 +109,10 @@
|
||||
;; validates against, then writes the whole payload
|
||||
;; (`files_branch.clj::detach-file-branch`), so it sits between
|
||||
;; the anchor and the merge pair.
|
||||
;; * `create-branch-review` and `update-branch-review-revision` realize
|
||||
;; the branch once and write one review snapshot
|
||||
;; (`files_branch_review.clj::create-branch-review`,
|
||||
;; `files_branch_review.clj::update-branch-review-revision`), which is
|
||||
;; the anchor's shape again.
|
||||
;; * `create-branch-review` realizes no document and writes no
|
||||
;; snapshot (`files_branch_review.clj::create-branch-review`): it
|
||||
;; checks the branch, inserts the review rows, and queues the
|
||||
;; reviewer emails, so it is far below the anchor's cost.
|
||||
;;
|
||||
;; The numbers here are example defaults, not measurements. Every entry
|
||||
;; of this file carries a queue because `climit_test.clj` checks this
|
||||
@ -191,30 +190,15 @@
|
||||
:get-file-branch-diff/global
|
||||
{:permits 6 :queue 15 :timeout 60000}
|
||||
|
||||
;; Creating a branch review realizes the branch and pins one review
|
||||
;; snapshot, the anchor's shape. Provisional.
|
||||
;; Creating a branch review writes the review rows and queues the
|
||||
;; reviewer emails; it realizes no document. The anchor's count keeps it
|
||||
;; bounded beside the other write-side branch operations. Provisional.
|
||||
:create-branch-review/global
|
||||
{:permits 3 :queue 5 :timeout 60000}
|
||||
|
||||
:create-branch-review/by-profile
|
||||
{:permits 1 :queue 2 :timeout 60000}
|
||||
|
||||
;; Publishing the branch state also realizes the branch and pins one
|
||||
;; snapshot. The command declares a single instance-wide queue
|
||||
;; (`files_branch_review.clj::update-branch-review-revision`), so the
|
||||
;; bounded wait sits on the global entry here rather than on a
|
||||
;; per-profile entry. Provisional.
|
||||
:update-branch-review-revision/global
|
||||
{:permits 3 :queue 4 :timeout 60000}
|
||||
|
||||
;; The review sandbox decodes the pinned snapshot and serves it whole:
|
||||
;; one realized document and one whole-file payload in memory, the
|
||||
;; anchor's shape with no snapshot write behind it. Three at once is the
|
||||
;; anchor's count, and eight waiters give the reviewers of one review
|
||||
;; room to open their sandboxes together. Provisional.
|
||||
:get-branch-review-bundle/global
|
||||
{:permits 3 :queue 8 :timeout 60000}
|
||||
|
||||
;; The activity decodes one blob per row of the review, folds the rows
|
||||
;; as they stream, and serves the folded history. No document is
|
||||
;; realized, but the work grows with the number of saves rather than
|
||||
|
||||
@ -602,7 +602,10 @@
|
||||
:fn (mg/resource "app/migrations/sql/0817-file-family-and-branch-review.sql")}
|
||||
|
||||
{:name "0818-mod-comment-thread-add-lost-layer"
|
||||
:fn (mg/resource "app/migrations/sql/0818-mod-comment-thread-add-lost-layer.sql")}])
|
||||
:fn (mg/resource "app/migrations/sql/0818-mod-comment-thread-add-lost-layer.sql")}
|
||||
|
||||
{:name "0819-mod-file-branch-review-drop-pinned-revision"
|
||||
:fn (mg/resource "app/migrations/sql/0819-mod-file-branch-review-drop-pinned-revision.sql")}])
|
||||
|
||||
(defn apply-migrations!
|
||||
[pool name migrations]
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
-- A branch review no longer pins a revision of its branch: reviewers see
|
||||
-- the live branch, and a verdict is stale once the branch file's `revn`
|
||||
-- passes the verdict's `verdict_revn`. The pinned snapshot of every open
|
||||
-- review is released to the snapshot GC first, the way closing a review
|
||||
-- released it, because nothing names it once the column goes. A closed
|
||||
-- review released its snapshot already.
|
||||
|
||||
UPDATE file_change
|
||||
SET deleted_at = now(),
|
||||
updated_at = now()
|
||||
WHERE id IN (SELECT pinned_snapshot_id
|
||||
FROM file_branch_review
|
||||
WHERE status = 'open'
|
||||
AND pinned_snapshot_id IS NOT NULL);
|
||||
|
||||
UPDATE file_data
|
||||
SET deleted_at = now()
|
||||
WHERE type = 'snapshot'
|
||||
AND id IN (SELECT pinned_snapshot_id
|
||||
FROM file_branch_review
|
||||
WHERE status = 'open'
|
||||
AND pinned_snapshot_id IS NOT NULL);
|
||||
|
||||
-- Dropping `pinned_snapshot_id` drops its index
|
||||
-- `file_branch_review__pinned_snapshot_id__idx` with it.
|
||||
ALTER TABLE file_branch_review
|
||||
DROP COLUMN pinned_snapshot_id,
|
||||
DROP COLUMN pinned_revn,
|
||||
DROP COLUMN pinned_at;
|
||||
@ -425,18 +425,17 @@
|
||||
;; circular dependency.
|
||||
|
||||
(def ^:private sql:get-open-branch-reviews
|
||||
"SELECT id, title, pinned_snapshot_id
|
||||
"SELECT id, title
|
||||
FROM file_branch_review
|
||||
WHERE file_branch_id = ?
|
||||
AND status = 'open'
|
||||
AND deleted_at IS NULL")
|
||||
|
||||
(defn- close-branch-reviews
|
||||
"Close (or mark merged) any open review of `branch` and release its
|
||||
pinned snapshot: the snapshot lives in the branch file's history and
|
||||
must not outlive the branch. The review row itself is kept as history.
|
||||
Must run inside a transaction."
|
||||
[{:keys [::db/conn] :as cfg} {:keys [id branch-file-id]} {:keys [profile-id status deleted-at]}]
|
||||
"Close (or mark merged) any open review of `branch`, for a branch that
|
||||
merges, goes, is archived, or stops being a branch. The review row
|
||||
itself is kept as history. Must run inside a transaction."
|
||||
[{:keys [::db/conn]} {:keys [id]} {:keys [profile-id status]}]
|
||||
(doseq [review (db/exec! conn [sql:get-open-branch-reviews id])]
|
||||
(let [ts (ct/now)]
|
||||
(db/update! conn :file-branch-review
|
||||
@ -445,12 +444,7 @@
|
||||
:closed-by profile-id
|
||||
:updated-at ts}
|
||||
{:id (:id review)}
|
||||
{::db/return-keys false})
|
||||
(when-let [snapshot-id (:pinned-snapshot-id review)]
|
||||
(fsnap/delete! cfg
|
||||
:id snapshot-id
|
||||
:file-id branch-file-id
|
||||
:deleted-at deleted-at)))))
|
||||
{::db/return-keys false}))))
|
||||
|
||||
;; --- Helpers: branch deletion (shared by delete-file-branch and merge)
|
||||
|
||||
@ -473,12 +467,10 @@
|
||||
{:id id}
|
||||
{::db/return-keys false})
|
||||
(release-base-snapshot! cfg branch dt)
|
||||
;; the pinned review snapshot must not outlive the branch (`status`
|
||||
;; above is the BRANCH status; a review closed this way is just
|
||||
;; "closed")
|
||||
;; an open review has nothing left to review (`status` above is the
|
||||
;; BRANCH status; a review closed this way is just "closed")
|
||||
(close-branch-reviews cfg branch {:profile-id profile-id
|
||||
:status "closed"
|
||||
:deleted-at dt})
|
||||
:status "closed"})
|
||||
(jobs/submit cfg
|
||||
{::jobs/name :delete-object
|
||||
::jobs/params {:object :file :deleted-at dt :id branch-file-id}})
|
||||
@ -1379,17 +1371,14 @@
|
||||
:updated-at ts}
|
||||
{:id branch-id}
|
||||
{::db/return-keys false})
|
||||
(let [team (teams/get-team conn :profile-id profile-id :file-id main-id)
|
||||
delay (ldel/get-deletion-delay team)]
|
||||
;; an open review of this branch has served its
|
||||
;; purpose: mark it merged and release its snapshot
|
||||
(close-branch-reviews cfg branch
|
||||
{:profile-id profile-id
|
||||
:status "merged"
|
||||
:deleted-at (ct/in-future delay)})
|
||||
(vswap! messages conj
|
||||
(delete-branch! cfg branch {:profile-id profile-id
|
||||
:session-id session-id}))))]
|
||||
;; an open review of this branch has served its
|
||||
;; purpose: mark it merged
|
||||
(close-branch-reviews cfg branch
|
||||
{:profile-id profile-id
|
||||
:status "merged"})
|
||||
(vswap! messages conj
|
||||
(delete-branch! cfg branch {:profile-id profile-id
|
||||
:session-id session-id})))]
|
||||
(cond
|
||||
(seq unresolved)
|
||||
;; `:copies` tells the conflict dialog which copies the
|
||||
@ -2052,8 +2041,7 @@
|
||||
;; nothing left to review
|
||||
(close-branch-reviews cfg branch
|
||||
{:profile-id profile-id
|
||||
:status "closed"
|
||||
:deleted-at (ct/in-future delay)})
|
||||
:status "closed"})
|
||||
|
||||
;; nothing derives from the base any more, so the pin goes
|
||||
(release-base-snapshot! cfg branch (ct/in-future delay))
|
||||
@ -2225,7 +2213,7 @@
|
||||
(files/check-read-permissions! cfg profile-id main-id)
|
||||
(db/exec! conn [sql:get-file-branch-merges main-id])))))
|
||||
|
||||
;; --- COMMANDS: the changes a profile marked as reviewed
|
||||
;; --- COMMANDS: the changes a profile marked as viewed
|
||||
|
||||
(defn- get-readable-branch
|
||||
"The branch `branch-id`, once `profile-id` is known to read its main.
|
||||
@ -2253,7 +2241,7 @@
|
||||
AND r.direction = ?")
|
||||
|
||||
(sv/defmethod ::get-branch-change-marks
|
||||
"The changes of a comparison the profile marked as reviewed, each with
|
||||
"The changes of a comparison the profile marked as viewed, each with
|
||||
the fingerprint of the change when it was marked. The marks are the
|
||||
profile's own: nobody else's are returned. A mark whose fingerprint no
|
||||
longer matches its change is stale, which the reader of the comparison
|
||||
@ -2274,7 +2262,7 @@
|
||||
[:direction [:enum :branch->source :source->branch]]
|
||||
[:change-key [:string {:max 500}]]
|
||||
[:fingerprint [:string {:max 250}]]
|
||||
[:reviewed ::sm/boolean]])
|
||||
[:viewed ::sm/boolean]])
|
||||
|
||||
(def ^:private sql:upsert-branch-change-mark
|
||||
"INSERT INTO file_branch_change_mark
|
||||
@ -2285,7 +2273,7 @@
|
||||
created_at = clock_timestamp()")
|
||||
|
||||
(sv/defmethod ::set-branch-change-mark
|
||||
"Mark a change of a comparison as reviewed by the profile, with the
|
||||
"Mark a change of a comparison as viewed by the profile, with the
|
||||
fingerprint of the change as it stands, or clear the mark. Reading the
|
||||
branch is enough: the mark is the profile's own note and changes
|
||||
nothing of the branch."
|
||||
@ -2293,10 +2281,10 @@
|
||||
::sm/params schema:set-branch-change-mark
|
||||
::db/transaction true}
|
||||
[{:keys [::db/conn] :as cfg}
|
||||
{:keys [::rpc/profile-id branch-id direction change-key fingerprint reviewed]}]
|
||||
{:keys [::rpc/profile-id branch-id direction change-key fingerprint viewed]}]
|
||||
(check-branching-enabled!)
|
||||
(get-readable-branch cfg profile-id branch-id)
|
||||
(if reviewed
|
||||
(if viewed
|
||||
(db/exec-one! conn [sql:upsert-branch-change-mark
|
||||
branch-id profile-id (name direction) change-key fingerprint])
|
||||
(db/delete! conn :file-branch-change-mark
|
||||
@ -2386,12 +2374,8 @@
|
||||
;; archiving hides the branch from the default flow, so its open
|
||||
;; review has no reason to stay open either
|
||||
(when (= "archived" status)
|
||||
(let [team (teams/get-team conn :profile-id profile-id
|
||||
:file-id (:branch-file-id branch))
|
||||
dt (ct/in-future (ldel/get-deletion-delay team))]
|
||||
(close-branch-reviews cfg branch {:profile-id profile-id
|
||||
:status "closed"
|
||||
:deleted-at dt})))
|
||||
(close-branch-reviews cfg branch {:profile-id profile-id
|
||||
:status "closed"}))
|
||||
(audited {:id branch-id :status status} tpoint
|
||||
(if (false? archived) :restore-branch :archive-branch))))))
|
||||
|
||||
|
||||
@ -6,16 +6,14 @@
|
||||
|
||||
(ns app.rpc.commands.files-branch-review
|
||||
"RPC commands for branch reviews on top of file branching: a review
|
||||
request over a pinned revision of a branch. A branch review does NOT
|
||||
create a new file. Reviewers open the live branch file, which stays
|
||||
editable, so their edits change the branch and mark the review
|
||||
`outdated` (the branch revn moved past the pinned one). The pinned
|
||||
snapshot serves only the read-only views: the interactions viewer
|
||||
(`viewer/get-view-only-bundle` with `:review-id`) and
|
||||
`get-branch-review-bundle`. Both refuse once the review is no longer
|
||||
open, and closing it releases the snapshot pin. Merging stays on
|
||||
`app.rpc.commands.files-branch`; a verdict is informative and never a
|
||||
gate for the merge.
|
||||
request over the live state of a branch. A branch review does NOT
|
||||
create a new file and does not freeze the branch. Reviewers open the
|
||||
live branch file, which stays editable, and the interactions viewer
|
||||
(`viewer/get-view-only-bundle` with `:review-id`) plays the live branch
|
||||
read-only while the review is open. A verdict records the branch revn
|
||||
it was issued over, so every later save of the branch file makes it
|
||||
stale. Merging stays on `app.rpc.commands.files-branch`; a verdict is
|
||||
informative and never a gate for the merge.
|
||||
|
||||
The review's two sides are derived, never stored: the branch file is
|
||||
the `file_branch` edge's `branch_file_id` and the target its
|
||||
@ -27,7 +25,6 @@
|
||||
[app.binfile.common :as bfc]
|
||||
[app.common.data :as d]
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.features :as-alias cfeat]
|
||||
[app.common.files.review-activity :as ra]
|
||||
[app.common.schema :as sm]
|
||||
[app.common.time :as ct]
|
||||
@ -36,8 +33,6 @@
|
||||
[app.config :as cf]
|
||||
[app.db :as db]
|
||||
[app.email :as eml]
|
||||
[app.features.file-snapshots :as fsnap]
|
||||
[app.features.logical-deletion :as ldel]
|
||||
[app.loggers.webhooks :as-alias webhooks]
|
||||
[app.msgbus :as mbus]
|
||||
[app.rpc :as-alias rpc]
|
||||
@ -75,9 +70,6 @@
|
||||
r.created_at,
|
||||
r.updated_at,
|
||||
r.status,
|
||||
r.pinned_snapshot_id,
|
||||
r.pinned_revn,
|
||||
r.pinned_at,
|
||||
r.closed_at,
|
||||
r.closed_by,
|
||||
fb.name AS branch_name,
|
||||
@ -124,29 +116,6 @@
|
||||
:code :object-not-found
|
||||
:hint "not found"))))
|
||||
|
||||
(defn- release-review-snapshot!
|
||||
"Reschedule a branch review's pinned snapshot for normal deletion: it is
|
||||
pinned ~10 years while the review is open and must be released when the
|
||||
review is closed, merged or its snapshot is repositioned. The snapshot
|
||||
belongs to the BRANCH file (the review's source)."
|
||||
[cfg {:keys [pinned-snapshot-id source-file-id]} deleted-at]
|
||||
(when pinned-snapshot-id
|
||||
(fsnap/delete! cfg
|
||||
:id pinned-snapshot-id
|
||||
:file-id source-file-id
|
||||
:deleted-at deleted-at)))
|
||||
|
||||
(defn- pin-review-snapshot!
|
||||
"Materialize the review snapshot of the branch file: what reviewers see
|
||||
in the sandbox, pinned so the snapshot GC does not prune it while the
|
||||
review is open."
|
||||
[cfg branch-file title profile-id]
|
||||
(fsnap/create! cfg branch-file
|
||||
{:label (str "branch-review/" title)
|
||||
:profile-id profile-id
|
||||
:created-by "system"
|
||||
:deleted-at (ct/in-future {:days 3650})}))
|
||||
|
||||
(defn- validate-reviewers!
|
||||
"Check every reviewer id is a member of `team-id`; the author is
|
||||
silently dropped (requesting a review from yourself is meaningless).
|
||||
@ -176,23 +145,26 @@
|
||||
|
||||
(defn- get-reviews-map
|
||||
"{review-id -> [reviewer ...]} for the given branch reviews, each
|
||||
reviewer annotated with `:stale` (verdict submitted over a previous
|
||||
review revision). A NULL verdict is a pending reviewer."
|
||||
reviewer annotated with `:stale` (verdict issued over an earlier revn
|
||||
of the branch file: the branch was saved since). A NULL verdict is a
|
||||
pending reviewer."
|
||||
[cfg reviews]
|
||||
(if (empty? reviews)
|
||||
{}
|
||||
(let [ids (db/create-array (db/get-connection cfg) "uuid" (mapv :id reviews))
|
||||
revn (into {} (map (juxt :id :pinned-revn)) reviews)]
|
||||
revn (into {} (map (juxt :id :branch-revn)) reviews)]
|
||||
(->> (db/exec! cfg [sql:get-reviews ids])
|
||||
(mapv (fn [{:keys [review-id verdict verdict-revn] :as row}]
|
||||
(assoc row :stale (and (some? verdict)
|
||||
(not= verdict-revn (get revn review-id))))))
|
||||
(let [branch-revn (get revn review-id)]
|
||||
(assoc row :stale (boolean (and (some? verdict)
|
||||
(some? branch-revn)
|
||||
(> branch-revn verdict-revn)))))))
|
||||
(group-by :review-id)))))
|
||||
|
||||
(defn- overall-verdict
|
||||
"Aggregate verdict of a branch review: `changes-requested` beats
|
||||
`approved`; stale verdicts (submitted over a previous review
|
||||
revision) only count as `in-review`; no verdict at all is `pending`."
|
||||
`approved`; stale verdicts (issued over an earlier revn of the branch
|
||||
file) only count as `in-review`; no verdict at all is `pending`."
|
||||
[reviews]
|
||||
(let [submitted (remove #(nil? (:verdict %)) reviews)
|
||||
current (remove :stale submitted)]
|
||||
@ -204,10 +176,9 @@
|
||||
|
||||
(defn- decorate-branch-review
|
||||
"Attach the derived attributes the UI needs: the reviewers (+ aggregate
|
||||
`overall-verdict`), `outdated` (the branch moved past the pinned
|
||||
revision, cheap revn gate) and entity-level ahead/behind/conflicts
|
||||
counts against the target (only for open reviews, gated like the
|
||||
branches listing).
|
||||
`overall-verdict`) and entity-level ahead/behind/conflicts counts
|
||||
against the target (only for open reviews, gated like the branches
|
||||
listing).
|
||||
|
||||
The row carries the review's two sides as the SQL of the edge aliases
|
||||
them (`source-file-id` the branch file, `target-file-id` the target),
|
||||
@ -218,8 +189,7 @@
|
||||
the branches listing uses, so ten open reviews on one file cost one
|
||||
computation per branch and nothing at all once that panel has been
|
||||
opened."
|
||||
[cfg target-data reviews-map counts-map {:keys [id status file-branch-id source-file-id target-file-id
|
||||
pinned-revn branch-revn]
|
||||
[cfg target-data reviews-map counts-map {:keys [id status file-branch-id source-file-id target-file-id]
|
||||
:as row}]
|
||||
(let [reviews (get reviews-map id [])
|
||||
open? (= "open" status)
|
||||
@ -234,12 +204,11 @@
|
||||
(-> row
|
||||
(assoc :reviews (mapv #(dissoc % :review-id) reviews))
|
||||
(assoc :overall-verdict (overall-verdict reviews))
|
||||
(assoc :outdated (and open? (> branch-revn pinned-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-source-revn :base-branch-revn :pinned-snapshot-id))))
|
||||
:base-source-revn :base-branch-revn))))
|
||||
|
||||
(def ^:private sql:get-open-branch-review-for-branch
|
||||
"SELECT id FROM file_branch_review
|
||||
@ -297,11 +266,10 @@
|
||||
|
||||
(sv/defmethod ::create-branch-review
|
||||
"Create a branch review from an open branch towards the file the branch
|
||||
was cut from (its source). Pins a snapshot of the branch (the revision
|
||||
reviewers see) and registers the requested reviewers, who must be
|
||||
members of the team. At most one open review may exist per branch. The
|
||||
review joins the family of the target file, which is what outlives the
|
||||
branch."
|
||||
was cut from (its source). Registers the requested reviewers, who must
|
||||
be members of the team; they review the live branch. At most one open
|
||||
review may exist per branch. The review joins the family of the target
|
||||
file, which is what outlives the branch."
|
||||
{::doc/added "2.16"
|
||||
::webhooks/event? true
|
||||
::sm/params schema:create-branch-review
|
||||
@ -349,10 +317,9 @@
|
||||
msgbus
|
||||
messages
|
||||
(fn [{:keys [::db/conn] :as cfg}]
|
||||
;; Serialize against concurrent update-file on the branch so
|
||||
;; the review snapshot captures a consistent state (same
|
||||
;; advisory lock the save path takes), and against a
|
||||
;; concurrent create-branch-review on the same branch.
|
||||
;; Serialize against a concurrent create-branch-review on the
|
||||
;; same branch (the advisory lock the save path takes on the
|
||||
;; branch file).
|
||||
(db/xact-lock! conn branch-file-id)
|
||||
|
||||
;; Serialize against a merge of the same branch (which locks
|
||||
@ -378,10 +345,7 @@
|
||||
:hint "the branch already has an open review"
|
||||
:branch-id branch-id))
|
||||
|
||||
(let [branch-file (bfc/get-file cfg branch-file-id :realize? true)
|
||||
snapshot (pin-review-snapshot! cfg branch-file title profile-id)
|
||||
review-id (uuid/next)
|
||||
ts (ct/now)]
|
||||
(let [review-id (uuid/next)]
|
||||
|
||||
(db/insert! conn :file-branch-review
|
||||
{:id review-id
|
||||
@ -390,10 +354,7 @@
|
||||
:title title
|
||||
:description description
|
||||
:created-by profile-id
|
||||
:status "open"
|
||||
:pinned-snapshot-id (:id snapshot)
|
||||
:pinned-revn (:revn branch-file)
|
||||
:pinned-at ts}
|
||||
:status "open"}
|
||||
{::db/return-keys false})
|
||||
|
||||
(doseq [reviewer-id reviewers]
|
||||
@ -427,7 +388,6 @@
|
||||
:title title
|
||||
:description description
|
||||
:status "open"
|
||||
:pinned-revn (:revn branch-file)
|
||||
:reviewers reviewers}))))))))
|
||||
|
||||
;; --- COMMAND QUERY: get-file-branch-reviews
|
||||
@ -451,9 +411,6 @@
|
||||
r.created_at,
|
||||
r.updated_at,
|
||||
r.status,
|
||||
r.pinned_snapshot_id,
|
||||
r.pinned_revn,
|
||||
r.pinned_at,
|
||||
r.closed_at,
|
||||
r.closed_by,
|
||||
fb.name AS branch_name,
|
||||
@ -478,8 +435,8 @@
|
||||
(sv/defmethod ::get-file-branch-reviews
|
||||
"List the branch reviews of a file. Accepts either the target file or a
|
||||
branch file id (it resolves to its source through the branch edge).
|
||||
Every open review is annotated with its reviewers, the aggregate
|
||||
`overall-verdict`, the `outdated` flag and the entity-level
|
||||
Every open review is annotated with its reviewers (each with its
|
||||
`stale` flag), the aggregate `overall-verdict` and the entity-level
|
||||
ahead/behind/conflicts counts (gated by the cheap revn deltas, with the
|
||||
target realized once and shared, like the branches listing).
|
||||
|
||||
@ -666,56 +623,6 @@
|
||||
(files/check-read-permissions! cfg profile-id (:target-file-id review))
|
||||
(get-activity conn id)))))
|
||||
|
||||
;; --- COMMAND QUERY: get-branch-review-bundle
|
||||
|
||||
(def ^:private schema:get-branch-review-bundle
|
||||
[:map {:title "get-branch-review-bundle"}
|
||||
[:id ::sm/uuid]
|
||||
[:features {:optional true} ::cfeat/features]])
|
||||
|
||||
(sv/defmethod ::get-branch-review-bundle
|
||||
"Retrieve the review sandbox of an OPEN branch review: the branch file
|
||||
bundle with the data of the pinned snapshot overlaid, served with
|
||||
edition permissions stripped so the client always opens it read-only.
|
||||
Does not modify any database state. Refuses when the snapshot cannot be
|
||||
resolved — silently serving the live branch would show reviewers a
|
||||
state nobody asked them to review."
|
||||
{::doc/added "2.16"
|
||||
::sm/params schema:get-branch-review-bundle
|
||||
::sm/result files/schema:file-with-permissions
|
||||
::climit/id [[:get-branch-review-bundle/global]]
|
||||
::db/transaction true}
|
||||
[cfg {:keys [::rpc/profile-id id]}]
|
||||
(check-branch-reviews-enabled!)
|
||||
(let [review (get-branch-review* cfg id)]
|
||||
(when (not= "open" (:status review))
|
||||
(ex/raise :type :validation
|
||||
:code :branch-review-not-open
|
||||
:hint "the review sandbox only exists while the branch review is open"
|
||||
:review-id id))
|
||||
(let [perms (perms/get-file-read-permissions cfg profile-id (:target-file-id review))]
|
||||
(files/check-read-permissions! perms)
|
||||
(let [snapshot (when (:pinned-snapshot-id review)
|
||||
(fsnap/get-snapshot cfg (:source-file-id review) (:pinned-snapshot-id review)))]
|
||||
(when-not snapshot
|
||||
(ex/raise :type :not-found
|
||||
:code :review-snapshot-missing
|
||||
:hint "the branch review snapshot cannot be resolved"
|
||||
:review-id id))
|
||||
(let [base-file (bfc/get-file cfg (:source-file-id review) :load-data? false)]
|
||||
(-> base-file
|
||||
(assoc :data (:data snapshot))
|
||||
(assoc :version (:version snapshot))
|
||||
(assoc :features (:features snapshot))
|
||||
(assoc :revn (:revn snapshot))
|
||||
(assoc :vern (rand-int 100000))
|
||||
;; the sandbox is read-only by construction, whatever the
|
||||
;; caller's role on the team is
|
||||
(assoc :permissions (assoc perms
|
||||
:can-edit false
|
||||
:is-admin false
|
||||
:is-owner false))))))))
|
||||
|
||||
;; --- COMMAND: update-branch-review-info
|
||||
|
||||
(def ^:private schema:update-branch-review-info
|
||||
@ -797,73 +704,6 @@
|
||||
:title (or title (:title review))
|
||||
:description (or description (:description review))})))))
|
||||
|
||||
;; --- COMMAND: update-branch-review-revision
|
||||
|
||||
(def ^:private schema:update-branch-review-revision
|
||||
[:map {:title "update-branch-review-revision"}
|
||||
[:id ::sm/uuid]])
|
||||
|
||||
(sv/defmethod ::update-branch-review-revision
|
||||
"Publish the branch's current state to the reviewers: reposition the
|
||||
pinned snapshot to the head of the branch (releasing the previous pin).
|
||||
Verdicts submitted over the previous revision become stale
|
||||
(`verdict-revn` no longer matches) but are kept for the history. It is
|
||||
an explicit author action — the sandbox never moves on its own."
|
||||
{::doc/added "2.16"
|
||||
::webhooks/event? true
|
||||
::sm/params schema:update-branch-review-revision
|
||||
::climit/id [[:update-branch-review-revision/global]]}
|
||||
[{:keys [::mbus/msgbus] :as cfg} {:keys [::rpc/profile-id id]}]
|
||||
(check-branch-reviews-enabled!)
|
||||
(let [review (get-branch-review* cfg id)
|
||||
messages (volatile! [])]
|
||||
(when (not= "open" (:status review))
|
||||
(ex/raise :type :validation
|
||||
:code :branch-review-not-open
|
||||
:review-id id))
|
||||
|
||||
;; publishing the branch state is an author-side action, like
|
||||
;; creating the branch review
|
||||
(files/check-edition-permissions! cfg profile-id (:source-file-id review))
|
||||
|
||||
(fbranch/tx-run-notify!
|
||||
cfg
|
||||
msgbus
|
||||
messages
|
||||
(fn [{:keys [::db/conn] :as cfg}]
|
||||
;; serialize against concurrent update-file on the branch so the
|
||||
;; new snapshot captures a consistent state
|
||||
(db/xact-lock! conn (:source-file-id review))
|
||||
|
||||
(let [branch-file (bfc/get-file cfg (:source-file-id review) :realize? true)]
|
||||
(if (= (:revn branch-file) (:pinned-revn review))
|
||||
;; nothing new to publish: the sandbox already shows this state
|
||||
{:id id :pinned-revn (:pinned-revn review) :updated false}
|
||||
|
||||
(let [team (teams/get-team conn :profile-id profile-id
|
||||
:file-id (:target-file-id review))
|
||||
delay (ldel/get-deletion-delay team)
|
||||
snapshot (pin-review-snapshot! cfg branch-file (:title review) profile-id)
|
||||
ts (ct/now)]
|
||||
;; the previous review snapshot is superseded: release its pin
|
||||
(release-review-snapshot! cfg review (ct/in-future delay))
|
||||
(db/update! conn :file-branch-review
|
||||
{:pinned-snapshot-id (:id snapshot)
|
||||
:pinned-revn (:revn branch-file)
|
||||
:pinned-at ts
|
||||
:updated-at ts}
|
||||
{:id id}
|
||||
{::db/return-keys false})
|
||||
|
||||
(vswap! messages conj
|
||||
{:topic (:target-file-id review)
|
||||
:message {:type :branch-review-updated
|
||||
:file-id (:target-file-id review)
|
||||
:review-id id
|
||||
:profile-id profile-id}})
|
||||
|
||||
{:id id :pinned-revn (:revn branch-file) :updated true})))))))
|
||||
|
||||
;; --- COMMAND: submit-branch-review-verdict
|
||||
|
||||
(def ^:private schema:submit-branch-review-verdict
|
||||
@ -877,9 +717,10 @@
|
||||
(sv/defmethod ::submit-branch-review-verdict
|
||||
"Submit (or retract, with a null `:verdict`) a verdict on an open branch
|
||||
review. Only assigned reviewers may submit; the verdict records the
|
||||
branch revision it was issued over, so it goes stale when the author
|
||||
publishes newer changes. Approval is informative: it never gates the
|
||||
merge, which keeps requiring edition permissions on the target."
|
||||
revn of the branch file it was issued over, so it goes stale as soon
|
||||
as the branch file is saved again. Approval is informative: it never
|
||||
gates the merge, which keeps requiring edition permissions on the
|
||||
target."
|
||||
{::doc/added "2.16"
|
||||
::webhooks/event? true
|
||||
::sm/params schema:submit-branch-review-verdict}
|
||||
@ -899,8 +740,11 @@
|
||||
msgbus
|
||||
messages
|
||||
(fn [{:keys [::db/conn]}]
|
||||
(let [reviewer (db/get* conn :file-branch-reviewer
|
||||
{:review-id id :profile-id profile-id})]
|
||||
(let [reviewer (db/get* conn :file-branch-reviewer
|
||||
{:review-id id :profile-id profile-id})
|
||||
verdict-revn (when (some? verdict)
|
||||
(:revn (db/get conn :file {:id (:source-file-id review)}
|
||||
{:columns [:revn]})))]
|
||||
(when-not reviewer
|
||||
(ex/raise :type :validation
|
||||
:code :not-a-reviewer
|
||||
@ -909,7 +753,7 @@
|
||||
|
||||
(db/update! conn :file-branch-reviewer
|
||||
{:verdict verdict
|
||||
:verdict-revn (when (some? verdict) (:pinned-revn review))
|
||||
:verdict-revn verdict-revn
|
||||
:comment comment
|
||||
:updated-at (ct/now)}
|
||||
{:review-id id :profile-id profile-id}
|
||||
@ -926,7 +770,7 @@
|
||||
{:id id
|
||||
:profile-id profile-id
|
||||
:verdict verdict
|
||||
:verdict-revn (:pinned-revn review)})))))
|
||||
:verdict-revn verdict-revn})))))
|
||||
|
||||
;; --- COMMAND: close-branch-review
|
||||
|
||||
@ -935,10 +779,9 @@
|
||||
[:id ::sm/uuid]])
|
||||
|
||||
(sv/defmethod ::close-branch-review
|
||||
"Close (discard) an open branch review: the review sandbox stops
|
||||
resolving and the pinned snapshot is released to the normal snapshot
|
||||
GC. The branch itself is not touched. Allowed to the author and to team
|
||||
admins/owners."
|
||||
"Close (discard) an open branch review: its read-only viewer stops
|
||||
resolving and reviewers can no longer submit verdicts. The branch
|
||||
itself is not touched. Allowed to the author and to team admins/owners."
|
||||
{::doc/added "2.16"
|
||||
::webhooks/event? true
|
||||
::sm/params schema:close-branch-review}
|
||||
@ -956,11 +799,8 @@
|
||||
cfg
|
||||
msgbus
|
||||
messages
|
||||
(fn [{:keys [::db/conn] :as cfg}]
|
||||
(let [team (teams/get-team conn :profile-id profile-id
|
||||
:file-id (:target-file-id review))
|
||||
delay (ldel/get-deletion-delay team)
|
||||
ts (ct/now)]
|
||||
(fn [{:keys [::db/conn]}]
|
||||
(let [ts (ct/now)]
|
||||
(db/update! conn :file-branch-review
|
||||
{:status "closed"
|
||||
:closed-at ts
|
||||
@ -968,7 +808,6 @@
|
||||
:updated-at ts}
|
||||
{:id id}
|
||||
{::db/return-keys false})
|
||||
(release-review-snapshot! cfg review (ct/in-future delay))
|
||||
|
||||
(vswap! messages conj
|
||||
{:topic (:target-file-id review)
|
||||
@ -987,9 +826,9 @@
|
||||
|
||||
(sv/defmethod ::reopen-branch-review
|
||||
"Reopen a closed branch review, as long as its branch is still open and
|
||||
the branch has no other open review. The pinned snapshot is re-pinned at
|
||||
the CURRENT head of the branch (the previous one may already be
|
||||
garbage-collected). Allowed to the author and to team admins/owners."
|
||||
the branch has no other open review. Reviewers find the live branch,
|
||||
so a verdict issued before the close is stale if the branch was saved
|
||||
since. Allowed to the author and to team admins/owners."
|
||||
{::doc/added "2.16"
|
||||
::sm/params schema:reopen-branch-review}
|
||||
[{:keys [::mbus/msgbus] :as cfg} {:keys [::rpc/profile-id id]}]
|
||||
@ -1015,7 +854,7 @@
|
||||
cfg
|
||||
msgbus
|
||||
messages
|
||||
(fn [{:keys [::db/conn] :as cfg}]
|
||||
(fn [{:keys [::db/conn]}]
|
||||
(db/xact-lock! conn (:source-file-id review))
|
||||
|
||||
;; Serialize against a merge of the same branch (which locks the
|
||||
@ -1035,16 +874,11 @@
|
||||
:hint "the branch already has an open review"
|
||||
:branch-id (:file-branch-id review)))
|
||||
|
||||
(let [branch-file (bfc/get-file cfg (:source-file-id review) :realize? true)
|
||||
snapshot (pin-review-snapshot! cfg branch-file (:title review) profile-id)
|
||||
ts (ct/now)]
|
||||
(let [ts (ct/now)]
|
||||
(db/update! conn :file-branch-review
|
||||
{:status "open"
|
||||
:closed-at nil
|
||||
:closed-by nil
|
||||
:pinned-snapshot-id (:id snapshot)
|
||||
:pinned-revn (:revn branch-file)
|
||||
:pinned-at ts
|
||||
:updated-at ts}
|
||||
{:id id}
|
||||
{::db/return-keys false})
|
||||
@ -1056,7 +890,7 @@
|
||||
:review-id id
|
||||
:profile-id profile-id}})
|
||||
|
||||
{:id id :status "open" :pinned-revn (:revn branch-file)}))))))
|
||||
{:id id :status "open"}))))))
|
||||
|
||||
;; --- COMMAND QUERY: get-profile-review-requests
|
||||
|
||||
@ -1069,7 +903,6 @@
|
||||
r.title,
|
||||
r.created_by,
|
||||
r.created_at,
|
||||
r.pinned_at,
|
||||
fb.branch_file_id AS source_file_id,
|
||||
fb.source_file_id AS target_file_id,
|
||||
fb.name AS branch_name,
|
||||
@ -1078,6 +911,7 @@
|
||||
FROM file_branch_reviewer AS v
|
||||
JOIN file_branch_review AS r ON (r.id = v.review_id)
|
||||
JOIN file_branch AS fb ON (fb.id = r.file_branch_id)
|
||||
JOIN file AS bf ON (bf.id = fb.branch_file_id)
|
||||
JOIN file AS sf ON (sf.id = fb.source_file_id)
|
||||
JOIN project AS p ON (p.id = sf.project_id)
|
||||
WHERE v.profile_id = ?
|
||||
@ -1087,13 +921,13 @@
|
||||
AND sf.deleted_at IS NULL
|
||||
AND p.deleted_at IS NULL
|
||||
AND (v.verdict IS NULL
|
||||
OR v.verdict_revn IS DISTINCT FROM r.pinned_revn)
|
||||
ORDER BY r.pinned_at DESC")
|
||||
OR v.verdict_revn < bf.revn)
|
||||
ORDER BY r.created_at DESC")
|
||||
|
||||
(sv/defmethod ::get-profile-review-requests
|
||||
"The open branch reviews of a team where the calling profile is a
|
||||
reviewer without a CURRENT verdict (never reviewed, or the author
|
||||
published newer changes since their last verdict). Feeds the dashboard
|
||||
reviewer without a CURRENT verdict (never reviewed, or the branch file
|
||||
was saved since their last verdict). Feeds the dashboard
|
||||
notifications area."
|
||||
{::doc/added "2.16"
|
||||
::sm/params schema:get-profile-review-requests}
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
[app.config :as cf]
|
||||
[app.db :as db]
|
||||
[app.features.fdata :as fdata]
|
||||
[app.features.file-snapshots :as fsnap]
|
||||
[app.rpc :as-alias rpc]
|
||||
[app.rpc.commands.files-branch-review :as fbr]
|
||||
[app.rpc.commands.teams :as teams]
|
||||
@ -140,16 +139,6 @@
|
||||
file (-> (bfc/get-file cfg file-id)
|
||||
(bfc/file->response))
|
||||
|
||||
;; branch review sandbox: the viewer shows the pinned snapshot
|
||||
;; of the branch, not its live state
|
||||
file (if-let [snapshot (::snapshot params)]
|
||||
(-> file
|
||||
(assoc :data (:data snapshot))
|
||||
(assoc :version (:version snapshot))
|
||||
(assoc :features (:features snapshot))
|
||||
(assoc :revn (:revn snapshot)))
|
||||
file)
|
||||
|
||||
project (db/get conn :project
|
||||
{:id (:project-id file)}
|
||||
{:columns [:id :name :team-id]})
|
||||
@ -233,7 +222,6 @@
|
||||
(def ^:private sql:get-branch-review-for-viewer
|
||||
"SELECT r.id,
|
||||
r.status,
|
||||
r.pinned_snapshot_id,
|
||||
fb.branch_file_id AS source_file_id,
|
||||
fb.source_file_id AS target_file_id
|
||||
FROM file_branch_review AS r
|
||||
@ -241,14 +229,12 @@
|
||||
WHERE r.id = ?
|
||||
AND r.deleted_at IS NULL")
|
||||
|
||||
(defn- get-branch-review-view-context
|
||||
"Resolve the review-sandbox context of `review-id`: permissions taken
|
||||
from the review's TARGET file (share-links do not apply here) with
|
||||
edition stripped, plus the pinned snapshot whose data replaces the
|
||||
branch file's live state. Refuses when the review is not open or its
|
||||
branch file is not `file-id` — the sandbox must never silently degrade
|
||||
to the live branch. Both sides come from the branch edge, which is the
|
||||
only place they live."
|
||||
(defn- get-branch-review-view-perms
|
||||
"Resolve the viewer permissions of `review-id`: taken from the review's
|
||||
TARGET file (share-links do not apply here) with edition stripped, so
|
||||
the viewer plays the live branch file read-only. Refuses when the
|
||||
review is not open or its branch file is not `file-id`. Both sides come
|
||||
from the branch edge, which is the only place they live."
|
||||
[system profile-id file-id review-id]
|
||||
(fbr/check-branch-reviews-enabled!)
|
||||
(let [review (db/exec-one! system [sql:get-branch-review-for-viewer review-id])]
|
||||
@ -261,18 +247,10 @@
|
||||
(when (not= "open" (:status review))
|
||||
(ex/raise :type :validation
|
||||
:code :branch-review-not-open
|
||||
:hint "the review sandbox only exists while the branch review is open"
|
||||
:hint "the review viewer only exists while the branch review is open"
|
||||
:review-id review-id))
|
||||
(let [perms (perms/get-file-read-permissions system profile-id (:target-file-id review))
|
||||
snapshot (when (:pinned-snapshot-id review)
|
||||
(fsnap/get-snapshot system (:source-file-id review) (:pinned-snapshot-id review)))]
|
||||
(when (and perms (nil? snapshot))
|
||||
(ex/raise :type :not-found
|
||||
:code :review-snapshot-missing
|
||||
:hint "the branch review snapshot cannot be resolved"
|
||||
:review-id review-id))
|
||||
{:perms (some-> perms (assoc :can-edit false :is-admin false :is-owner false))
|
||||
:snapshot snapshot})))
|
||||
(some-> (perms/get-file-read-permissions system profile-id (:target-file-id review))
|
||||
(assoc :can-edit false :is-admin false :is-owner false))))
|
||||
|
||||
(def schema:get-view-only-bundle
|
||||
[:map {:title "get-view-only-bundle"}
|
||||
@ -288,15 +266,13 @@
|
||||
[system {:keys [::rpc/profile-id file-id share-id review-id] :as params}]
|
||||
(db/run! system
|
||||
(fn [system]
|
||||
(let [{:keys [perms snapshot]}
|
||||
(if (some? review-id)
|
||||
(get-branch-review-view-context system profile-id file-id review-id)
|
||||
{:perms (perms/get-file-read-permissions system profile-id file-id share-id)})
|
||||
(let [perms (if (some? review-id)
|
||||
(get-branch-review-view-perms system profile-id file-id review-id)
|
||||
(perms/get-file-read-permissions system profile-id file-id share-id))
|
||||
|
||||
params (-> params
|
||||
(assoc ::perms perms)
|
||||
(assoc :profile-id profile-id)
|
||||
(cond-> (some? snapshot) (assoc ::snapshot snapshot)))]
|
||||
(assoc :profile-id profile-id))]
|
||||
|
||||
;; When we have neither profile nor share, we just return a not
|
||||
;; found response to the user.
|
||||
|
||||
@ -85,8 +85,7 @@
|
||||
WHERE r.file_branch_id = ?
|
||||
AND NOT EXISTS (SELECT 1
|
||||
FROM file_branch_merge AS fbm
|
||||
WHERE fbm.review_id = r.id)
|
||||
RETURNING r.pinned_snapshot_id")
|
||||
WHERE fbm.review_id = r.id)")
|
||||
|
||||
(defn- delete-unmerged-branch
|
||||
"Delete what belonged to a branch that no merge accepted, before its
|
||||
@ -106,15 +105,7 @@
|
||||
;; first and the tasks are still found by their file afterwards
|
||||
(db/delete! conn :comment-thread {:file-id file-id} {::db/return-keys false})
|
||||
(db/delete! conn :file-task {:file-id file-id} {::db/return-keys false})
|
||||
(doseq [{:keys [pinned-snapshot-id]} (db/exec! conn [sql:delete-unmerged-branch-reviews edge-id])]
|
||||
;; the pinned revision is a change row of the branch file, held for
|
||||
;; years while the review lives; it dies with the review, or it would
|
||||
;; keep the file row from being collected
|
||||
(when (some? pinned-snapshot-id)
|
||||
(fsnap/delete! cfg
|
||||
:id pinned-snapshot-id
|
||||
:file-id file-id
|
||||
:deleted-at deleted-at)))
|
||||
(db/exec-one! conn [sql:delete-unmerged-branch-reviews edge-id])
|
||||
;; the merge base is a change row of the source, pinned while the
|
||||
;; branch is open; it dies with the branch, or the source file row
|
||||
;; could not be collected either
|
||||
|
||||
@ -214,7 +214,7 @@
|
||||
:direction :branch->source
|
||||
:change-key (str "shape:" rect-id)
|
||||
:fingerprint "0c0ffee"
|
||||
:reviewed true})]
|
||||
:viewed true})]
|
||||
(t/is (nil? (:error out))))
|
||||
|
||||
;; the branch deletes the layer its thread points at: the review is
|
||||
@ -445,7 +445,7 @@
|
||||
:direction :branch->source
|
||||
:change-key "shape:pay-button"
|
||||
:fingerprint "0c0ffee"
|
||||
:reviewed true})]
|
||||
:viewed true})]
|
||||
(t/is (nil? (:error out))))
|
||||
|
||||
;; a save of the branch while the review is open records activity
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
[app.rpc :as-alias rpc]
|
||||
[app.util.blob :as blob]
|
||||
[backend-tests.helpers :as th]
|
||||
[clojure.string :as str]
|
||||
[clojure.test :as t]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
@ -95,15 +94,6 @@
|
||||
(t/is (= [(:id reviewer)] (:reviewers result)))
|
||||
(vreset! review-id (:id result)))))
|
||||
|
||||
(t/testing "review snapshot is pinned on the branch file"
|
||||
(let [rows (->> (th/db-query :file-change {:file-id branch-file-id})
|
||||
(filter #(some-> (:label %) (str/starts-with? "branch-review/"))))]
|
||||
(t/is (= 1 (count rows)))
|
||||
(t/is (every? (fn [{:keys [deleted-at]}]
|
||||
(and (some? deleted-at)
|
||||
(ct/is-after? deleted-at (ct/in-future {:days 3000}))))
|
||||
rows))))
|
||||
|
||||
(t/testing "list from the target file"
|
||||
(let [out (th/command! {::th/type :get-file-branch-reviews
|
||||
::rpc/profile-id (:id author)
|
||||
@ -116,7 +106,6 @@
|
||||
(t/is (= "feature" (:branch-name row)))
|
||||
(t/is (= (:name file) (:target-name row)))
|
||||
(t/is (= "pending" (:overall-verdict row)))
|
||||
(t/is (false? (:outdated row)))
|
||||
;; the branch carries one change (the added color)
|
||||
(t/is (= 1 (:ahead row)))
|
||||
(t/is (= 0 (:behind row)))
|
||||
@ -184,113 +173,34 @@
|
||||
out (create-review* viewer (:id branch2) {})]
|
||||
(t/is (some? (:error out))))))))
|
||||
|
||||
(t/deftest bundle-serves-the-pinned-snapshot
|
||||
(t/deftest viewer-bundle-plays-the-live-branch
|
||||
(with-redefs [cf/flags (pr-flags)]
|
||||
(let [author (th/create-profile* 1 {:is-active true})
|
||||
file (th/create-file* 1 {:profile-id (:id author)
|
||||
:project-id (:default-project-id author)})
|
||||
branch (create-branch* author file "feature")
|
||||
bfid (:branch-file-id branch)
|
||||
color-1 (uuid/random)
|
||||
color-2 (uuid/random)]
|
||||
bfid (:branch-file-id branch)]
|
||||
|
||||
(apply-change* author bfid
|
||||
{:type :add-color
|
||||
:color {:id color-1 :name "One" :color "#111111" :opacity 1}})
|
||||
(add-color* author bfid "One")
|
||||
|
||||
(let [pr (:result (create-review* author (:id branch) {}))]
|
||||
|
||||
;; the branch keeps moving AFTER the branch review was created
|
||||
(apply-change* author bfid
|
||||
{:type :add-color
|
||||
:color {:id color-2 :name "Two" :color "#222222" :opacity 1}})
|
||||
|
||||
(t/testing "the sandbox shows the reviewed state, not the live branch"
|
||||
(let [out (th/command! {::th/type :get-branch-review-bundle
|
||||
::rpc/profile-id (:id author)
|
||||
:id (:id pr)})
|
||||
result (:result out)
|
||||
colors (-> result :data :colors)]
|
||||
(t/is (nil? (:error out)))
|
||||
(t/is (contains? colors color-1))
|
||||
(t/is (not (contains? colors color-2)))
|
||||
;; read-only by construction, whatever the caller's role is
|
||||
(t/is (false? (-> result :permissions :can-edit)))))
|
||||
|
||||
(t/testing "the branch review reports the branch moved on"
|
||||
(let [out (th/command! {::th/type :get-branch-review
|
||||
::rpc/profile-id (:id author)
|
||||
:id (:id pr)})]
|
||||
(t/is (true? (-> out :result :outdated)))))
|
||||
|
||||
(t/testing "publishing the branch state refreshes the sandbox"
|
||||
(let [out (th/command! {::th/type :update-branch-review-revision
|
||||
::rpc/profile-id (:id author)
|
||||
:id (:id pr)})]
|
||||
(t/is (nil? (:error out)))
|
||||
(t/is (true? (-> out :result :updated))))
|
||||
|
||||
(let [out (th/command! {::th/type :get-branch-review-bundle
|
||||
::rpc/profile-id (:id author)
|
||||
:id (:id pr)})
|
||||
colors (-> out :result :data :colors)]
|
||||
(t/is (contains? colors color-2)))
|
||||
|
||||
(let [out (th/command! {::th/type :get-branch-review
|
||||
::rpc/profile-id (:id author)
|
||||
:id (:id pr)})]
|
||||
(t/is (false? (-> out :result :outdated)))))
|
||||
|
||||
(t/testing "publishing again with no new changes is a no-op"
|
||||
(let [out (th/command! {::th/type :update-branch-review-revision
|
||||
::rpc/profile-id (:id author)
|
||||
:id (:id pr)})]
|
||||
(t/is (nil? (:error out)))
|
||||
(t/is (false? (-> out :result :updated)))))))))
|
||||
|
||||
(t/deftest viewer-bundle-serves-the-pinned-snapshot
|
||||
(with-redefs [cf/flags (pr-flags)]
|
||||
(let [author (th/create-profile* 1 {:is-active true})
|
||||
file (th/create-file* 1 {:profile-id (:id author)
|
||||
:project-id (:default-project-id author)})
|
||||
branch (create-branch* author file "feature")
|
||||
bfid (:branch-file-id branch)
|
||||
color-1 (uuid/random)
|
||||
color-2 (uuid/random)]
|
||||
|
||||
(apply-change* author bfid
|
||||
{:type :add-color
|
||||
:color {:id color-1 :name "One" :color "#111111" :opacity 1}})
|
||||
|
||||
(let [pr (:result (create-review* author (:id branch) {}))]
|
||||
|
||||
;; the branch keeps moving AFTER the branch review was created
|
||||
(apply-change* author bfid
|
||||
{:type :add-color
|
||||
:color {:id color-2 :name "Two" :color "#222222" :opacity 1}})
|
||||
(add-color* author bfid "Two")
|
||||
|
||||
;; the bundle strips file :data down to pages/components, so the
|
||||
;; served state is asserted through :revn (the overlay carries the
|
||||
;; snapshot's revn; the live branch is one save ahead)
|
||||
(t/testing "the viewer bundle shows the reviewed state, read-only"
|
||||
;; served state is asserted through :revn
|
||||
(t/testing "the viewer bundle of a review shows the live branch, read-only"
|
||||
(let [out (th/command! {::th/type :get-view-only-bundle
|
||||
::rpc/profile-id (:id author)
|
||||
:file-id bfid
|
||||
:review-id (:id pr)})
|
||||
result (:result out)]
|
||||
result (:result out)
|
||||
bf (th/db-get :file {:id bfid})]
|
||||
(t/is (nil? (:error out)))
|
||||
(t/is (= (:pinned-revn pr) (-> result :file :revn)))
|
||||
(t/is (= (:revn bf) (-> result :file :revn)))
|
||||
(t/is (false? (-> result :permissions :can-edit)))))
|
||||
|
||||
(t/testing "the viewer bundle without review-id keeps the live state"
|
||||
(let [out (th/command! {::th/type :get-view-only-bundle
|
||||
::rpc/profile-id (:id author)
|
||||
:file-id bfid})
|
||||
bf (th/db-get :file {:id bfid})]
|
||||
(t/is (nil? (:error out)))
|
||||
(t/is (= (:revn bf) (-> out :result :file :revn)))
|
||||
(t/is (< (:pinned-revn pr) (:revn bf)))))
|
||||
|
||||
(t/testing "the viewer bundle refuses a closed branch review"
|
||||
(th/command! {::th/type :close-branch-review
|
||||
::rpc/profile-id (:id author)
|
||||
@ -347,12 +257,8 @@
|
||||
(t/is (= "approved" (:overall-verdict row)))
|
||||
(t/is (false? (-> row :reviews first :stale)))))
|
||||
|
||||
(t/testing "publishing new changes makes the verdict stale"
|
||||
(t/testing "a save of the branch makes the verdict stale"
|
||||
(add-color* author bfid "Another")
|
||||
(let [out (th/command! {::th/type :update-branch-review-revision
|
||||
::rpc/profile-id (:id author)
|
||||
:id (:id pr)})]
|
||||
(t/is (nil? (:error out))))
|
||||
(let [row (:result (th/command! {::th/type :get-branch-review
|
||||
::rpc/profile-id (:id author)
|
||||
:id (:id pr)}))]
|
||||
@ -372,6 +278,81 @@
|
||||
:id (:id pr)}))]
|
||||
(t/is (= "changes-requested" (:overall-verdict row)))))))))
|
||||
|
||||
(t/deftest verdict-goes-stale-after-a-branch-save
|
||||
(with-redefs [cf/flags (pr-flags)]
|
||||
(let [author (th/create-profile* 1 {:is-active true})
|
||||
reviewer (th/create-profile* 2 {:is-active true})
|
||||
team-id (:default-team-id author)
|
||||
file (th/create-file* 1 {:profile-id (:id author)
|
||||
:project-id (:default-project-id author)})]
|
||||
|
||||
(th/create-team-role* {:team-id team-id
|
||||
:profile-id (:id reviewer)
|
||||
:role :editor})
|
||||
|
||||
(let [branch (create-branch* author file "feature")
|
||||
bfid (:branch-file-id branch)
|
||||
_ (add-color* author bfid "Brand")
|
||||
pr (:result (create-review* author (:id branch)
|
||||
{:reviewers [(:id reviewer)]}))
|
||||
review (fn []
|
||||
(:result (th/command! {::th/type :get-branch-review
|
||||
::rpc/profile-id (:id author)
|
||||
:id (:id pr)})))
|
||||
listed (fn []
|
||||
(->> (th/command! {::th/type :get-file-branch-reviews
|
||||
::rpc/profile-id (:id author)
|
||||
:file-id (:id file)})
|
||||
:result
|
||||
(filter #(= (:id pr) (:id %)))
|
||||
(first)))
|
||||
requests (fn []
|
||||
(->> (th/command! {::th/type :get-profile-review-requests
|
||||
::rpc/profile-id (:id reviewer)
|
||||
:team-id team-id})
|
||||
:result
|
||||
(mapv :id)))]
|
||||
|
||||
(t/testing "a pending reviewer is asked for a verdict"
|
||||
(t/is (= [(:id pr)] (requests))))
|
||||
|
||||
(t/testing "a verdict records the live revn of the branch file"
|
||||
(let [out (th/command! {::th/type :submit-branch-review-verdict
|
||||
::rpc/profile-id (:id reviewer)
|
||||
:id (:id pr)
|
||||
:verdict "approved"})]
|
||||
(t/is (nil? (:error out)))
|
||||
(t/is (= (:revn (th/db-get :file {:id bfid}))
|
||||
(-> out :result :verdict-revn)))))
|
||||
|
||||
(t/testing "the verdict is current before any save of the branch"
|
||||
(let [row (review)]
|
||||
(t/is (= "approved" (:overall-verdict row)))
|
||||
(t/is (false? (-> row :reviews first :stale)))
|
||||
(t/is (not (contains? row :outdated)))
|
||||
(t/is (not (contains? row :pinned-revn))))
|
||||
(t/is (false? (-> (listed) :reviews first :stale)))
|
||||
(t/is (= [] (requests))))
|
||||
|
||||
(t/testing "a save of the branch file makes the verdict stale"
|
||||
(t/is (nil? (:error (add-color* author bfid "Accent"))))
|
||||
(let [row (review)]
|
||||
(t/is (= "in-review" (:overall-verdict row)))
|
||||
(t/is (= "approved" (-> row :reviews first :verdict)))
|
||||
(t/is (true? (-> row :reviews first :stale))))
|
||||
(t/is (true? (-> (listed) :reviews first :stale)))
|
||||
(t/is (= [(:id pr)] (requests))))
|
||||
|
||||
(t/testing "a new verdict over the live branch is current again"
|
||||
(th/command! {::th/type :submit-branch-review-verdict
|
||||
::rpc/profile-id (:id reviewer)
|
||||
:id (:id pr)
|
||||
:verdict "approved"})
|
||||
(let [row (review)]
|
||||
(t/is (= "approved" (:overall-verdict row)))
|
||||
(t/is (false? (-> row :reviews first :stale))))
|
||||
(t/is (= [] (requests))))))))
|
||||
|
||||
(t/deftest update-branch-review-metadata-and-reviewers
|
||||
(with-redefs [cf/flags (pr-flags)]
|
||||
(let [author (th/create-profile* 1 {:is-active true})
|
||||
@ -437,7 +418,6 @@
|
||||
:role :admin})
|
||||
|
||||
(let [branch (create-branch* author file "feature")
|
||||
bfid (:branch-file-id branch)
|
||||
pr (:result (create-review* author (:id branch) {}))]
|
||||
|
||||
(t/testing "a plain editor cannot close someone else's branch review"
|
||||
@ -453,32 +433,12 @@
|
||||
(t/is (nil? (:error out)))
|
||||
(t/is (= "closed" (-> out :result :status)))))
|
||||
|
||||
(t/testing "the sandbox stops resolving once closed"
|
||||
(let [out (th/command! {::th/type :get-branch-review-bundle
|
||||
::rpc/profile-id (:id author)
|
||||
:id (:id pr)})
|
||||
error (:error out)]
|
||||
(t/is (some? error))
|
||||
(t/is (= :branch-review-not-open (-> error ex-data :code)))))
|
||||
|
||||
(t/testing "the review snapshot pin is released on close"
|
||||
(let [rows (->> (th/db-query :file-change {:file-id bfid})
|
||||
(filter #(some-> (:label %) (str/starts-with? "branch-review/"))))]
|
||||
(t/is (seq rows))
|
||||
(t/is (every? (fn [{:keys [deleted-at]}]
|
||||
(and (some? deleted-at)
|
||||
(ct/is-before? deleted-at (ct/in-future {:days 400}))))
|
||||
rows))))
|
||||
|
||||
(t/testing "the author can reopen it, re-pinned at the current head"
|
||||
(add-color* author bfid "Late")
|
||||
(t/testing "the author can reopen it"
|
||||
(let [out (th/command! {::th/type :reopen-branch-review
|
||||
::rpc/profile-id (:id author)
|
||||
:id (:id pr)})
|
||||
bf (th/db-get :file {:id bfid})]
|
||||
:id (:id pr)})]
|
||||
(t/is (nil? (:error out)))
|
||||
(t/is (= "open" (-> out :result :status)))
|
||||
(t/is (= (:revn bf) (-> out :result :pinned-revn)))))))))
|
||||
(t/is (= "open" (-> out :result :status)))))))))
|
||||
|
||||
(t/deftest branch-lifecycle-closes-reviews
|
||||
(with-redefs [cf/flags (pr-flags)]
|
||||
@ -716,17 +676,6 @@
|
||||
[:title]))
|
||||
:expected (constantly {:title "renamed"})}
|
||||
|
||||
{:label "update-branch-review-revision"
|
||||
:type :update-branch-review-revision
|
||||
:actor :author
|
||||
;; the sandbox only republishes when the branch moved
|
||||
:before (fn [] (add-color* author bfid "Extra"))
|
||||
:params (fn [id] {:id id})
|
||||
:message-type :branch-review-updated
|
||||
:view (fn [id] (select-keys (th/db-get :file-branch-review {:id id})
|
||||
[:pinned-revn]))
|
||||
:expected (fn [_] {:pinned-revn (:revn (th/db-get :file {:id bfid}))})}
|
||||
|
||||
{:label "submit-branch-review-verdict"
|
||||
:type :submit-branch-review-verdict
|
||||
:actor :reviewer
|
||||
@ -736,8 +685,8 @@
|
||||
{:review-id id
|
||||
:profile-id (:id reviewer)})
|
||||
[:verdict :verdict-revn]))
|
||||
:expected (fn [id] {:verdict "approved"
|
||||
:verdict-revn (:pinned-revn (th/db-get :file-branch-review {:id id}))})}
|
||||
:expected (fn [_] {:verdict "approved"
|
||||
:verdict-revn (:revn (th/db-get :file {:id bfid}))})}
|
||||
|
||||
{:label "close-branch-review"
|
||||
:type :close-branch-review
|
||||
@ -758,10 +707,9 @@
|
||||
:expected (constantly {:status "open"})}]]
|
||||
(loop [cases cases
|
||||
review-id nil]
|
||||
(when-some [{:keys [label type actor before params message-type view expected]}
|
||||
(when-some [{:keys [label type actor params message-type view expected]}
|
||||
(first cases)]
|
||||
(let [seen (atom [])
|
||||
_ (when before (before))
|
||||
out (with-redefs [mbus/pub!
|
||||
(fn [_ & {:keys [message]}]
|
||||
(swap! seen conj {:message message
|
||||
|
||||
@ -3504,7 +3504,7 @@
|
||||
(= :deleted (:status %)))
|
||||
(:changes diff))))))))
|
||||
|
||||
;;; --- The changes a profile marked as reviewed ---
|
||||
;;; --- The changes a profile marked as viewed ---
|
||||
|
||||
(t/deftest review-marks-belong-to-a-profile-a-direction-and-a-change
|
||||
(with-redefs [cf/flags (conj cf/flags :branching)]
|
||||
@ -3521,14 +3521,14 @@
|
||||
::rpc/profile-id (:id owner)
|
||||
:file-id (:id file)
|
||||
:name "review-marks"}))
|
||||
mark (fn [profile direction change-key fingerprint reviewed]
|
||||
mark (fn [profile direction change-key fingerprint viewed]
|
||||
(th/command! {::th/type :set-branch-change-mark
|
||||
::rpc/profile-id (:id profile)
|
||||
:branch-id (:id branch)
|
||||
:direction direction
|
||||
:change-key change-key
|
||||
:fingerprint fingerprint
|
||||
:reviewed reviewed}))
|
||||
:viewed viewed}))
|
||||
marks (fn [profile direction]
|
||||
(let [out (th/command! {::th/type :get-branch-change-marks
|
||||
::rpc/profile-id (:id profile)
|
||||
|
||||
@ -206,8 +206,8 @@
|
||||
:export-link-later
|
||||
|
||||
;; Enables file branching: isolated file copies ("branches") that
|
||||
;; can be merged back to their source file, including design reviews
|
||||
;; (review requests over a pinned snapshot of a branch). Disabled by
|
||||
;; can be merged back to their source file, including branch reviews
|
||||
;; (review requests over the live state of a branch). Disabled by
|
||||
;; default.
|
||||
:branching
|
||||
|
||||
|
||||
@ -9,8 +9,6 @@
|
||||
"~:created-at": "~m1713536343369",
|
||||
"~:updated-at": "~m1713873823633",
|
||||
"~:status": "open",
|
||||
"~:pinned-revn": 11,
|
||||
"~:pinned-at": "~m1713873823633",
|
||||
"~:closed-at": null,
|
||||
"~:closed-by": null,
|
||||
"~:branch-name": "checkout",
|
||||
@ -26,7 +24,6 @@
|
||||
}
|
||||
],
|
||||
"~:overall-verdict": "pending",
|
||||
"~:outdated": false,
|
||||
"~:ahead": 1,
|
||||
"~:behind": 0,
|
||||
"~:conflicts": 0
|
||||
@ -10,8 +10,6 @@
|
||||
"~:created-at": "~m1713536343369",
|
||||
"~:updated-at": "~m1713873823633",
|
||||
"~:status": "open",
|
||||
"~:pinned-revn": 11,
|
||||
"~:pinned-at": "~m1713873823633",
|
||||
"~:closed-at": null,
|
||||
"~:closed-by": null,
|
||||
"~:branch-name": "checkout",
|
||||
@ -27,7 +25,6 @@
|
||||
}
|
||||
],
|
||||
"~:overall-verdict": "pending",
|
||||
"~:outdated": false,
|
||||
"~:ahead": 1,
|
||||
"~:behind": 0,
|
||||
"~:conflicts": 0
|
||||
@ -223,7 +223,7 @@ export class WorkspacePage extends BaseWebSocketPage {
|
||||
pageId = this.pageId ?? WorkspacePage.anyPageId,
|
||||
pageName = "Page 1",
|
||||
// extra query params appended verbatim, e.g. "&pr-id=<uuid>" for the
|
||||
// pull request review sandbox
|
||||
// branch review sandbox
|
||||
extraParams = "",
|
||||
} = {}) {
|
||||
// Helpers often call setup (and this) several times per test with the
|
||||
|
||||
@ -14,11 +14,11 @@ const setupBranch = async (workspacePage, diff) => {
|
||||
await workspacePage.setupEmptyFile();
|
||||
await workspacePage.mockRPCs({
|
||||
"get-file-branch-info?file-id=*":
|
||||
"pull-requests/get-file-branch-info-branch.json",
|
||||
"get-file-branches?file-id=*": "pull-requests/get-file-branches-empty.json",
|
||||
"branch-reviews/get-file-branch-info-branch.json",
|
||||
"get-file-branches?file-id=*": "branch-reviews/get-file-branches-empty.json",
|
||||
"get-file-branch-reviews?file-id=*":
|
||||
"pull-requests/get-file-branches-empty.json",
|
||||
"get-file-tasks?file-id=*": "pull-requests/get-file-branches-empty.json",
|
||||
"branch-reviews/get-file-branches-empty.json",
|
||||
"get-file-tasks?file-id=*": "branch-reviews/get-file-branches-empty.json",
|
||||
"get-file-branch-diff?branch-id=*": `compare/${diff}`,
|
||||
"get-branch-change-marks?branch-id=*":
|
||||
"compare/get-branch-change-marks-empty.json",
|
||||
|
||||
@ -4,33 +4,33 @@ import { WorkspacePage } from "../pages/WorkspacePage";
|
||||
const PR_ID = "c7ce0794-0992-8105-8004-38f280443999";
|
||||
|
||||
// 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" });
|
||||
// which replaces the branch bar while a branch review is open.
|
||||
const reviewBar = (page) => page.getByRole("region", { name: "Branch review" });
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await WorkspacePage.init(page);
|
||||
await WorkspacePage.mockConfigFlags(page, ["enable-branching"]);
|
||||
});
|
||||
|
||||
const setupPullRequestSandbox = async (workspacePage) => {
|
||||
const setupBranchReview = async (workspacePage) => {
|
||||
await workspacePage.setupEmptyFile();
|
||||
await workspacePage.mockRPCs({
|
||||
"get-file-branch-info?file-id=*":
|
||||
"pull-requests/get-file-branch-info-none.json",
|
||||
"get-file-branches?file-id=*": "pull-requests/get-file-branches-empty.json",
|
||||
"branch-reviews/get-file-branch-info-none.json",
|
||||
"get-file-branches?file-id=*": "branch-reviews/get-file-branches-empty.json",
|
||||
"get-file-branch-reviews?file-id=*":
|
||||
"pull-requests/get-file-branch-reviews.json",
|
||||
"get-branch-review?id=*": "pull-requests/get-branch-review.json",
|
||||
"branch-reviews/get-file-branch-reviews.json",
|
||||
"get-branch-review?id=*": "branch-reviews/get-branch-review.json",
|
||||
"get-file-branch-diff?branch-id=*":
|
||||
"pull-requests/get-file-branch-diff-empty.json",
|
||||
"branch-reviews/get-file-branch-diff-empty.json",
|
||||
"submit-branch-review-verdict":
|
||||
"pull-requests/submit-branch-review-verdict.json",
|
||||
"branch-reviews/submit-branch-review-verdict.json",
|
||||
});
|
||||
};
|
||||
|
||||
test("opening a file with pr-id enters the design review", async ({ page }) => {
|
||||
test("opening a file with pr-id enters the branch review", async ({ page }) => {
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await setupPullRequestSandbox(workspacePage);
|
||||
await setupBranchReview(workspacePage);
|
||||
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
||||
|
||||
// the review bar names the review being read, and the header trades the
|
||||
@ -47,21 +47,21 @@ test("opening a file with pr-id enters the design review", async ({ page }) => {
|
||||
// assigned reviewer, and the way out
|
||||
await expect(bar.getByRole("button", { name: "Details" })).toBeVisible();
|
||||
await expect(
|
||||
bar.getByRole("button", { name: "Submit review" }),
|
||||
bar.getByRole("button", { name: "Review", exact: true }),
|
||||
).toBeVisible();
|
||||
await expect(bar.getByRole("button", { name: "Exit review" })).toBeVisible();
|
||||
|
||||
// comparing, merging and cancelling live behind the kebab menu
|
||||
// comparing, merging and closing 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("Cancel review")).toBeVisible();
|
||||
await expect(page.getByText("Merge into main")).toBeVisible();
|
||||
await expect(page.getByText("Close review")).toBeVisible();
|
||||
});
|
||||
|
||||
test("comparing shows the proposed changes on the canvas", async ({ page }) => {
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await setupPullRequestSandbox(workspacePage);
|
||||
await setupBranchReview(workspacePage);
|
||||
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
||||
|
||||
// comparing is one of the review bar's options
|
||||
@ -82,23 +82,25 @@ test("comparing shows the proposed changes on the canvas", async ({ page }) => {
|
||||
await expect(bar.getByText("In review", { exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test("accepting the pull request opens the merge dialog", async ({ page }) => {
|
||||
test("accepting the branch review opens the merge dialog", async ({ page }) => {
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await setupPullRequestSandbox(workspacePage);
|
||||
await setupBranchReview(workspacePage);
|
||||
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
||||
|
||||
const banner = reviewBar(page);
|
||||
await banner.getByRole("button", { name: "Options" }).click();
|
||||
await page.getByText("Merge to main").click();
|
||||
await page.getByText("Merge into main").click();
|
||||
|
||||
// the branching merge dialog handles the actual integration
|
||||
await expect(page.getByText("Merge into main")).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("dialog").getByText("Merge into main"),
|
||||
).toBeVisible();
|
||||
await expect(page.getByText("checkout").first()).toBeVisible();
|
||||
});
|
||||
|
||||
test("the review is read-only", async ({ page }) => {
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await setupPullRequestSandbox(workspacePage);
|
||||
await setupBranchReview(workspacePage);
|
||||
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
||||
|
||||
await expect(reviewBar(page)).toBeVisible();
|
||||
@ -130,52 +132,78 @@ test("the review is read-only", async ({ page }) => {
|
||||
await expect(page.getByRole("tab", { name: "Tasks (0)" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("an assigned reviewer can submit a verdict from the review bar", async ({
|
||||
test("without a comment, a verdict button submits at once", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await setupPullRequestSandbox(workspacePage);
|
||||
await setupBranchReview(workspacePage);
|
||||
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
||||
|
||||
// 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 bar.getByRole("button", { name: "Review", exact: true }).click();
|
||||
|
||||
const dialog = page.getByRole("dialog");
|
||||
await expect(dialog).toBeVisible();
|
||||
await expect(
|
||||
dialog.getByRole("heading", { name: "Submit review" }),
|
||||
dialog.getByRole("heading", { name: "Checkout redesign" }),
|
||||
).toBeVisible();
|
||||
await expect(dialog.getByRole("button", { name: "Send" })).toBeHidden();
|
||||
|
||||
// the verdicts are a choice of one: radios, each with its hint
|
||||
const requestChanges = dialog.getByRole("radio", { name: /Request changes/ });
|
||||
await requestChanges.click();
|
||||
await expect(requestChanges).toBeChecked();
|
||||
await dialog.getByRole("button", { name: "Submit review" }).click();
|
||||
await dialog.getByRole("button", { name: "Request changes" }).click();
|
||||
|
||||
await expect(page.getByText("Review submitted")).toBeVisible();
|
||||
});
|
||||
|
||||
test("closing the pull request asks for confirmation", async ({ page }) => {
|
||||
test("with a comment, the verdict buttons pick and Send submits", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await setupPullRequestSandbox(workspacePage);
|
||||
await setupBranchReview(workspacePage);
|
||||
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
||||
|
||||
const bar = reviewBar(page);
|
||||
await bar.getByRole("button", { name: "Review", exact: true }).click();
|
||||
|
||||
const dialog = page.getByRole("dialog");
|
||||
await dialog.getByRole("button", { name: "Add a comment" }).click();
|
||||
|
||||
// Send waits for a verdict
|
||||
const send = dialog.getByRole("button", { name: "Send" });
|
||||
await expect(send).toBeDisabled();
|
||||
|
||||
await dialog.getByRole("textbox").fill("Looks good");
|
||||
const approve = dialog.getByRole("button", { name: "Approve" });
|
||||
await approve.click();
|
||||
|
||||
// picking a verdict submits nothing yet
|
||||
await expect(approve).toHaveAttribute("aria-pressed", "true");
|
||||
await expect(dialog).toBeVisible();
|
||||
|
||||
await send.click();
|
||||
await expect(page.getByText("Review submitted")).toBeVisible();
|
||||
});
|
||||
|
||||
test("closing the branch review asks for confirmation", async ({ page }) => {
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await setupBranchReview(workspacePage);
|
||||
await workspacePage.mockRPC(
|
||||
"close-branch-review",
|
||||
"pull-requests/close-branch-review.json",
|
||||
"branch-reviews/close-branch-review.json",
|
||||
);
|
||||
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
||||
|
||||
const banner = reviewBar(page);
|
||||
await banner.getByRole("button", { name: "Options" }).click();
|
||||
await page.getByText("Cancel review").click();
|
||||
await page.getByText("Close review").click();
|
||||
|
||||
// nothing is closed yet: a confirmation dialog takes over
|
||||
await expect(page.getByText("will be cancelled")).toBeVisible();
|
||||
await expect(page.getByText("will be closed")).toBeVisible();
|
||||
|
||||
// confirming closes the pull request; being inside its sandbox, the
|
||||
// confirming closes the branch review; being inside its sandbox, the
|
||||
// user is taken back to the file (no pr-id in the url)
|
||||
await page.getByRole("button", { name: "Cancel design review" }).click();
|
||||
await page.getByRole("button", { name: "Close review" }).click();
|
||||
await expect(page).not.toHaveURL(/pr-id/);
|
||||
});
|
||||
|
||||
@ -183,13 +211,13 @@ test("on a branch, requesting a review is the primary action", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await setupPullRequestSandbox(workspacePage);
|
||||
// the open file IS a branch without an open pull request
|
||||
await setupBranchReview(workspacePage);
|
||||
// the open file IS a branch without an open branch review
|
||||
await workspacePage.mockRPCs({
|
||||
"get-file-branch-info?file-id=*":
|
||||
"pull-requests/get-file-branch-info-branch.json",
|
||||
"branch-reviews/get-file-branch-info-branch.json",
|
||||
"get-file-branch-reviews?file-id=*":
|
||||
"pull-requests/get-file-branches-empty.json",
|
||||
"branch-reviews/get-file-branches-empty.json",
|
||||
});
|
||||
await workspacePage.goToWorkspace();
|
||||
|
||||
@ -198,18 +226,20 @@ test("on a branch, requesting a review is the primary action", async ({
|
||||
page.getByRole("button", { name: "Request review" }),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Merge to main" }),
|
||||
page.getByRole("button", { name: "Merge into main" }),
|
||||
).toBeHidden();
|
||||
|
||||
const banner = page.locator("#branch-banner");
|
||||
await banner.getByRole("button", { name: "Options" }).click();
|
||||
await page.getByText("Merge to main").click();
|
||||
await expect(page.getByText("Merge into main")).toBeVisible();
|
||||
await page.getByText("Merge into main").click();
|
||||
await expect(
|
||||
page.getByRole("dialog").getByText("Merge into main"),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test("exiting the review takes the user back to the file", async ({ page }) => {
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await setupPullRequestSandbox(workspacePage);
|
||||
await setupBranchReview(workspacePage);
|
||||
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
||||
|
||||
// the way out is an icon button on the bar, named by its tooltip
|
||||
@ -227,11 +257,11 @@ test("during a review the header names the branch under review", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await setupPullRequestSandbox(workspacePage);
|
||||
await setupBranchReview(workspacePage);
|
||||
// the review link opens the author's branch
|
||||
await workspacePage.mockRPC(
|
||||
"get-file-branch-info?file-id=*",
|
||||
"pull-requests/get-file-branch-info-branch.json",
|
||||
"branch-reviews/get-file-branch-info-branch.json",
|
||||
);
|
||||
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
||||
|
||||
@ -243,11 +273,11 @@ test("during a review the header names the branch under review", async ({
|
||||
|
||||
test("a branch that cannot be compared with main says so", async ({ page }) => {
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await setupPullRequestSandbox(workspacePage);
|
||||
await setupBranchReview(workspacePage);
|
||||
// the backend answers nil counts when it cannot compare the branch
|
||||
await workspacePage.mockRPC(
|
||||
"get-file-branch-info?file-id=*",
|
||||
"pull-requests/get-file-branch-info-uncompared.json",
|
||||
"branch-reviews/get-file-branch-info-uncompared.json",
|
||||
);
|
||||
await workspacePage.goToWorkspace();
|
||||
|
||||
@ -262,10 +292,10 @@ test("on a branch, the all-branches dialog offers no new branch", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await setupPullRequestSandbox(workspacePage);
|
||||
await setupBranchReview(workspacePage);
|
||||
await workspacePage.mockRPC(
|
||||
"get-file-branch-info?file-id=*",
|
||||
"pull-requests/get-file-branch-info-branch.json",
|
||||
"branch-reviews/get-file-branch-info-branch.json",
|
||||
);
|
||||
await workspacePage.goToWorkspace();
|
||||
|
||||
@ -13,12 +13,12 @@ const setupMainWithBranches = async (workspacePage) => {
|
||||
await workspacePage.setupEmptyFile();
|
||||
await workspacePage.mockRPCs({
|
||||
"get-file-branch-info?file-id=*":
|
||||
"pull-requests/get-file-branch-info-none.json",
|
||||
"branch-reviews/get-file-branch-info-none.json",
|
||||
"get-file-branch-count?file-id=*":
|
||||
"branches/get-file-branch-count-two.json",
|
||||
"get-file-branches?file-id=*": "branches/get-file-branches-two.json",
|
||||
"get-file-branch-reviews?file-id=*":
|
||||
"pull-requests/get-file-branches-empty.json",
|
||||
"branch-reviews/get-file-branches-empty.json",
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -10,10 +10,10 @@ const setupBranching = async (workspacePage, rpcs) => {
|
||||
await workspacePage.setupEmptyFile();
|
||||
await workspacePage.mockRPCs({
|
||||
"get-file-branch-info?file-id=*":
|
||||
"pull-requests/get-file-branch-info-none.json",
|
||||
"get-file-branches?file-id=*": "pull-requests/get-file-branches-empty.json",
|
||||
"branch-reviews/get-file-branch-info-none.json",
|
||||
"get-file-branches?file-id=*": "branch-reviews/get-file-branches-empty.json",
|
||||
"get-file-branch-reviews?file-id=*":
|
||||
"pull-requests/get-file-branches-empty.json",
|
||||
"branch-reviews/get-file-branches-empty.json",
|
||||
...rpcs,
|
||||
});
|
||||
};
|
||||
@ -24,7 +24,7 @@ test("on a branch of a library, the header says consumers read main", async ({
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await setupBranching(workspacePage, {
|
||||
"get-file-branch-info?file-id=*":
|
||||
"pull-requests/get-file-branch-info-library-branch.json",
|
||||
"branch-reviews/get-file-branch-info-library-branch.json",
|
||||
});
|
||||
await workspacePage.goToWorkspace();
|
||||
|
||||
@ -45,9 +45,9 @@ test("on a library, the create dialog says consumers read main", async ({
|
||||
await setupBranching(workspacePage, {
|
||||
"get-file-branch-count?file-id=*":
|
||||
"branches/get-file-branch-count-two.json",
|
||||
"get-file-branches?file-id=*": "pull-requests/get-file-branches-one.json",
|
||||
"get-file-branches?file-id=*": "branch-reviews/get-file-branches-one.json",
|
||||
});
|
||||
await workspacePage.mockGetFile("pull-requests/get-file-blank-shared.json");
|
||||
await workspacePage.mockGetFile("branch-reviews/get-file-blank-shared.json");
|
||||
await workspacePage.goToWorkspace();
|
||||
|
||||
await expect(page.getByText("Default branch", { exact: true })).toBeVisible();
|
||||
@ -70,7 +70,7 @@ test("on an ordinary file, the create dialog keeps its note", async ({
|
||||
await setupBranching(workspacePage, {
|
||||
"get-file-branch-count?file-id=*":
|
||||
"branches/get-file-branch-count-two.json",
|
||||
"get-file-branches?file-id=*": "pull-requests/get-file-branches-one.json",
|
||||
"get-file-branches?file-id=*": "branch-reviews/get-file-branches-one.json",
|
||||
});
|
||||
await workspacePage.goToWorkspace();
|
||||
|
||||
|
||||
@ -9,13 +9,13 @@ test.beforeEach(async ({ page }) => {
|
||||
const setupBranchFile = async (workspacePage, branchInfo) => {
|
||||
await workspacePage.setupEmptyFile();
|
||||
await workspacePage.mockRPCs({
|
||||
"get-file-branch-info?file-id=*": `pull-requests/${branchInfo}`,
|
||||
"get-file-branch-info?file-id=*": `branch-reviews/${branchInfo}`,
|
||||
"get-file-branches?file-id=*":
|
||||
"pull-requests/get-file-branches-closed.json",
|
||||
"branch-reviews/get-file-branches-closed.json",
|
||||
"get-file-branch-reviews?file-id=*":
|
||||
"pull-requests/get-file-branches-empty.json",
|
||||
"branch-reviews/get-file-branches-empty.json",
|
||||
"get-file-branch-diff?branch-id=*":
|
||||
"pull-requests/get-file-branch-diff-empty.json",
|
||||
"branch-reviews/get-file-branch-diff-empty.json",
|
||||
});
|
||||
};
|
||||
|
||||
@ -45,7 +45,7 @@ test("an archived branch opens read-only and offers its ways out", async ({
|
||||
await setupBranchFile(workspacePage, "get-file-branch-info-archived.json");
|
||||
await workspacePage.mockRPC(
|
||||
"archive-file-branch",
|
||||
"pull-requests/archive-file-branch-restore.json",
|
||||
"branch-reviews/archive-file-branch-restore.json",
|
||||
);
|
||||
await workspacePage.goToWorkspace();
|
||||
|
||||
@ -65,7 +65,7 @@ test("an archived branch opens read-only and offers its ways out", async ({
|
||||
// its new status
|
||||
await workspacePage.mockRPC(
|
||||
"get-file-branch-info?file-id=*",
|
||||
"pull-requests/get-file-branch-info-branch.json",
|
||||
"branch-reviews/get-file-branch-info-branch.json",
|
||||
);
|
||||
const restore = page.waitForRequest(
|
||||
(req) =>
|
||||
|
||||
@ -299,7 +299,7 @@
|
||||
permissions (get state :permissions)]
|
||||
|
||||
;; Historical previews must not create edits to the live file, and
|
||||
;; a design review and the comparison of a branch with main are
|
||||
;; a branch review and the comparison of a branch with main are
|
||||
;; read-only (the branch is edited outside them).
|
||||
;; Check this when creating commits so previously queued edits can
|
||||
;; still save. While saves fail, a user edit would queue behind the
|
||||
|
||||
@ -150,9 +150,9 @@
|
||||
(uuid? share-id)
|
||||
(assoc :share-id share-id)
|
||||
|
||||
;; pull request review sandbox: the bundle serves
|
||||
;; the pinned review snapshot instead of the live
|
||||
;; branch state
|
||||
;; branch review: the backend checks the review is
|
||||
;; open on this branch file and serves the live
|
||||
;; branch to its reviewers
|
||||
(uuid? pr-id)
|
||||
(assoc :review-id pr-id))
|
||||
|
||||
|
||||
@ -4,14 +4,13 @@
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS INC Sucursal en España SL
|
||||
|
||||
(ns app.main.data.workspace.pull-requests
|
||||
"Data layer for pull requests over file branches. A pull request points
|
||||
to a pinned review snapshot of its branch. Reviewing opens the live
|
||||
branch file as a normal, editable workspace with a review context
|
||||
attached (`:workspace-pr-preview`, which drives the review banner and
|
||||
header), so a reviewer's edits change the branch and mark the pull
|
||||
request outdated. The pinned snapshot backs the interactions viewer and
|
||||
the outdated flag, not the canvas. Mirrors the patterns of
|
||||
(ns app.main.data.workspace.branch-reviews
|
||||
"Data layer for branch reviews. Reviewing opens the live branch file as
|
||||
a normal, editable workspace with a review context attached
|
||||
(`:workspace-pr-preview`, which drives the review banner and header),
|
||||
so a reviewer's edits change the branch. Reviewers always see the live
|
||||
branch, in the canvas and in the interactions viewer: a verdict given
|
||||
before the branch changed again is stale. Mirrors the patterns of
|
||||
`app.main.data.workspace.branches`."
|
||||
(:require
|
||||
[app.config :as cf]
|
||||
@ -32,46 +31,46 @@
|
||||
(contains? cf/flags :branching))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; PULL REQUEST LIST (sidebar section)
|
||||
;; BRANCH REVIEW LIST (sidebar section)
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defonce default-state
|
||||
{:status :loading
|
||||
:data nil})
|
||||
|
||||
(defn- update-pull-requests-state
|
||||
(defn- update-branch-reviews-state
|
||||
[pr-state]
|
||||
(ptk/reify ::update-pull-requests-state
|
||||
(ptk/reify ::update-branch-reviews-state
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update state :workspace-pull-requests merge pr-state))))
|
||||
(update state :workspace-branch-reviews merge pr-state))))
|
||||
|
||||
(defn fetch-pull-requests
|
||||
"Load the pull requests of the current file into
|
||||
`:workspace-pull-requests`. The backend resolves a branch file id to
|
||||
(defn fetch-branch-reviews
|
||||
"Load the branch reviews of the current file into
|
||||
`:workspace-branch-reviews`. The backend resolves a branch file id to
|
||||
its source, so the list is complete whether the user is on main or on
|
||||
a branch. Closed ones are included; the UI decides what to show."
|
||||
[]
|
||||
(ptk/reify ::fetch-pull-requests
|
||||
(ptk/reify ::fetch-branch-reviews
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(when (enabled?)
|
||||
(when-let [file-id (:current-file-id state)]
|
||||
(->> (rp/cmd! :get-file-branch-reviews {:file-id file-id :include-closed true})
|
||||
(rx/map #(update-pull-requests-state {:status :loaded :data %}))
|
||||
(rx/map #(update-branch-reviews-state {:status :loaded :data %}))
|
||||
(rx/catch (fn [_]
|
||||
(rx/of (update-pull-requests-state {:status :loaded :data []}))))))))))
|
||||
(rx/of (update-branch-reviews-state {:status :loaded :data []}))))))))))
|
||||
|
||||
(defn init-pull-requests-state
|
||||
(defn init-branch-reviews-state
|
||||
[]
|
||||
(ptk/reify ::init-pull-requests-state
|
||||
(ptk/reify ::init-branch-reviews-state
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc state :workspace-pull-requests default-state))
|
||||
(assoc state :workspace-branch-reviews default-state))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(rx/of (fetch-pull-requests)))))
|
||||
(rx/of (fetch-branch-reviews)))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; PENDING REVIEWS (dashboard notifications area)
|
||||
@ -85,7 +84,7 @@
|
||||
(assoc state :dashboard-pending-reviews rows))))
|
||||
|
||||
(defn fetch-pending-reviews
|
||||
"Load into `:dashboard-pending-reviews` the open pull requests of
|
||||
"Load into `:dashboard-pending-reviews` the open branch reviews of
|
||||
`team-id` where the current profile is a reviewer without a current
|
||||
verdict. Feeds the dashboard notifications dropdown."
|
||||
[team-id]
|
||||
@ -98,20 +97,20 @@
|
||||
(rx/catch (fn [_] (rx/of (set-pending-reviews [])))))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; LIFECYCLE (create / edit / publish / close / reopen)
|
||||
;; LIFECYCLE (create / edit / close / reopen)
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(declare refresh-pull-request-preview-info)
|
||||
(declare refresh-branch-review-preview-info)
|
||||
|
||||
(defn create-pull-request
|
||||
"Create a pull request from `branch-id` towards its source file. When
|
||||
(defn create-branch-review
|
||||
"Create a branch review from `branch-id` towards its source file. When
|
||||
the branch is the currently open file, pending local changes are
|
||||
force-persisted first so the review snapshot captures them. Errors
|
||||
surface as a toast; the caller closes the dialog."
|
||||
force-persisted first so the review starts from the branch the author
|
||||
sees. Errors surface as a toast; the caller closes the dialog."
|
||||
[branch-id {:keys [title description reviewers]}]
|
||||
(assert (uuid? branch-id) "expected valid uuid for `branch-id`")
|
||||
(assert (string? title) "expected string for `title`")
|
||||
(ptk/reify ::create-pull-request
|
||||
(ptk/reify ::create-branch-review
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [;; the branch context is the open file's, and it is loaded
|
||||
@ -124,8 +123,8 @@
|
||||
(rx/of :ready))]
|
||||
(rx/concat
|
||||
(if from-ws?
|
||||
(rx/of ::dwp/force-persist (ev/event {::ev/name "create-pull-request"}))
|
||||
(rx/of (ev/event {::ev/name "create-pull-request"})))
|
||||
(rx/of ::dwp/force-persist (ev/event {::ev/name "create-branch-review"}))
|
||||
(rx/of (ev/event {::ev/name "create-branch-review"})))
|
||||
(->> wait
|
||||
(rx/mapcat #(rp/cmd! :create-branch-review
|
||||
{:branch-id branch-id
|
||||
@ -134,20 +133,20 @@
|
||||
:reviewers (vec (or reviewers []))}))
|
||||
(rx/mapcat
|
||||
(fn [_]
|
||||
(rx/of (ntf/success (tr "workspace.pull-requests.create.success" title))
|
||||
(fetch-pull-requests))))
|
||||
(rx/of (ntf/success (tr "workspace.branch-review.create.success" title))
|
||||
(fetch-branch-reviews))))
|
||||
(rx/catch
|
||||
(fn [cause]
|
||||
(if (= :branch-review-already-exists (:code (ex-data cause)))
|
||||
(rx/of (ntf/warn (tr "workspace.pull-requests.create.already-exists")))
|
||||
(rx/of (ntf/error (tr "workspace.pull-requests.create.error"))))))))))))
|
||||
(rx/of (ntf/warn (tr "workspace.branch-review.create.already-exists")))
|
||||
(rx/of (ntf/error (tr "workspace.branch-review.create.error"))))))))))))
|
||||
|
||||
(defn update-pull-request
|
||||
"Edit a pull request's title, description or reviewer list (author or
|
||||
(defn update-branch-review
|
||||
"Edit a branch review's title, description or reviewer list (author or
|
||||
team admins only, enforced server-side)."
|
||||
[id {:keys [title description reviewers]}]
|
||||
(assert (uuid? id) "expected valid uuid for `id`")
|
||||
(ptk/reify ::update-pull-request
|
||||
(ptk/reify ::update-branch-review
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(->> (rp/cmd! :update-branch-review-info
|
||||
@ -155,41 +154,12 @@
|
||||
(some? title) (assoc :title title)
|
||||
(some? description) (assoc :description description)
|
||||
(some? reviewers) (assoc :reviewers (vec reviewers))))
|
||||
(rx/mapcat (fn [_] (rx/of (fetch-pull-requests)
|
||||
(refresh-pull-request-preview-info id))))
|
||||
(rx/catch (fn [_] (rx/of (ntf/error (tr "workspace.pull-requests.lifecycle.error")))))))))
|
||||
|
||||
(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. 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
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [from-ws? (some? (:current-file-id state))
|
||||
wait (if from-ws? (dwp/wait-persisted) (rx/of :ready))]
|
||||
(rx/concat
|
||||
(if from-ws?
|
||||
(rx/of ::dwp/force-persist (ev/event {::ev/name "update-pull-request-snapshot"}))
|
||||
(rx/of (ev/event {::ev/name "update-pull-request-snapshot"})))
|
||||
(->> wait
|
||||
(rx/mapcat #(rp/cmd! :update-branch-review-revision {:id id}))
|
||||
(rx/mapcat
|
||||
(fn [{:keys [updated]}]
|
||||
(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)
|
||||
(refresh-pull-request-preview-info id))))
|
||||
(rx/catch
|
||||
(fn [_]
|
||||
(rx/of (ntf/error (tr "workspace.pull-requests.lifecycle.error")))))))))))
|
||||
(rx/mapcat (fn [_] (rx/of (fetch-branch-reviews)
|
||||
(refresh-branch-review-preview-info id))))
|
||||
(rx/catch (fn [_] (rx/of (ntf/error (tr "workspace.branch-review.lifecycle.error")))))))))
|
||||
|
||||
(defn submit-review
|
||||
"Submit a verdict on a pull request, or retract it with `nil`. Only
|
||||
"Submit a verdict on a branch review, or retract it with `nil`. Only
|
||||
assigned reviewers may submit (enforced server-side)."
|
||||
[id verdict comment]
|
||||
(assert (uuid? id) "expected valid uuid for `id`")
|
||||
@ -200,30 +170,30 @@
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(rx/concat
|
||||
(rx/of (ev/event {::ev/name "submit-pull-request-review"}))
|
||||
(rx/of (ev/event {::ev/name "submit-branch-review-verdict"}))
|
||||
(->> (rp/cmd! :submit-branch-review-verdict
|
||||
(cond-> {:id id}
|
||||
(some? verdict) (assoc :verdict verdict)
|
||||
(some? comment) (assoc :comment comment)))
|
||||
(rx/mapcat
|
||||
(fn [_]
|
||||
(rx/of (ntf/success (tr "workspace.pull-requests.review.submitted"))
|
||||
(fetch-pull-requests)
|
||||
(refresh-pull-request-preview-info id))))
|
||||
(rx/of (ntf/success (tr "workspace.branch-review.review.submitted"))
|
||||
(fetch-branch-reviews)
|
||||
(refresh-branch-review-preview-info id))))
|
||||
(rx/catch
|
||||
(fn [cause]
|
||||
(if (= :not-a-reviewer (:code (ex-data cause)))
|
||||
(rx/of (ntf/warn (tr "workspace.pull-requests.review.not-a-reviewer")))
|
||||
(rx/of (ntf/error (tr "workspace.pull-requests.lifecycle.error")))))))))))
|
||||
(rx/of (ntf/warn (tr "workspace.branch-review.review.not-a-reviewer")))
|
||||
(rx/of (ntf/error (tr "workspace.branch-review.lifecycle.error")))))))))))
|
||||
|
||||
(declare exit-pull-request-preview)
|
||||
(declare exit-branch-review-preview)
|
||||
|
||||
(defn close-pull-request
|
||||
"Close (discard) a pull request. Its sandbox stops existing; if the user
|
||||
(defn close-branch-review
|
||||
"Close (discard) a branch review. Its sandbox stops existing; if the user
|
||||
is currently inside it, take them back to the branch file."
|
||||
[id]
|
||||
(assert (uuid? id) "expected valid uuid for `id`")
|
||||
(ptk/reify ::close-pull-request
|
||||
(ptk/reify ::close-branch-review
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [inside? (= id (get-in state [:workspace-pr-preview :pr-id]))]
|
||||
@ -231,47 +201,47 @@
|
||||
(rx/mapcat
|
||||
(fn [_]
|
||||
(rx/concat
|
||||
(rx/of (ntf/success (tr "workspace.pull-requests.lifecycle.closed"))
|
||||
(fetch-pull-requests))
|
||||
(rx/of (ntf/success (tr "workspace.branch-review.lifecycle.closed"))
|
||||
(fetch-branch-reviews))
|
||||
(if inside?
|
||||
(rx/of (exit-pull-request-preview))
|
||||
(rx/of (exit-branch-review-preview))
|
||||
(rx/empty)))))
|
||||
(rx/catch
|
||||
(fn [_]
|
||||
(rx/of (ntf/error (tr "workspace.pull-requests.lifecycle.error"))))))))))
|
||||
(rx/of (ntf/error (tr "workspace.branch-review.lifecycle.error"))))))))))
|
||||
|
||||
(defn reopen-pull-request
|
||||
(defn reopen-branch-review
|
||||
[id]
|
||||
(assert (uuid? id) "expected valid uuid for `id`")
|
||||
(ptk/reify ::reopen-pull-request
|
||||
(ptk/reify ::reopen-branch-review
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(->> (rp/cmd! :reopen-branch-review {:id id})
|
||||
(rx/mapcat (fn [_] (rx/of (ntf/success (tr "workspace.pull-requests.lifecycle.reopened"))
|
||||
(fetch-pull-requests))))
|
||||
(rx/mapcat (fn [_] (rx/of (ntf/success (tr "workspace.branch-review.lifecycle.reopened"))
|
||||
(fetch-branch-reviews))))
|
||||
(rx/catch
|
||||
(fn [cause]
|
||||
(case (:code (ex-data cause))
|
||||
:branch-not-open
|
||||
(rx/of (ntf/warn (tr "workspace.pull-requests.lifecycle.branch-gone")))
|
||||
(rx/of (ntf/warn (tr "workspace.branch-review.lifecycle.branch-gone")))
|
||||
|
||||
:branch-review-already-exists
|
||||
(rx/of (ntf/warn (tr "workspace.pull-requests.create.already-exists")))
|
||||
(rx/of (ntf/warn (tr "workspace.branch-review.create.already-exists")))
|
||||
|
||||
(rx/of (ntf/error (tr "workspace.pull-requests.lifecycle.error"))))))))))
|
||||
(rx/of (ntf/error (tr "workspace.branch-review.lifecycle.error"))))))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; REVIEW CONTEXT (the live, editable branch file plus the review banner)
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn open-pull-request
|
||||
(defn open-branch-review
|
||||
"Navigate into the review of `pr`: the branch file's workspace with the
|
||||
`pr-id` query param, which attaches the review context once the file is
|
||||
initialized (`initialize-pull-request-preview`). The canvas is the live
|
||||
initialized (`initialize-branch-review-preview`). The canvas is the live
|
||||
branch, editable as always."
|
||||
[pr]
|
||||
(assert (uuid? (:id pr)) "expected a pull request row with a valid `:id`")
|
||||
(ptk/reify ::open-pull-request
|
||||
(assert (uuid? (:id pr)) "expected a branch review row with a valid `:id`")
|
||||
(ptk/reify ::open-branch-review
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [params (-> (rt/get-params state)
|
||||
@ -281,23 +251,23 @@
|
||||
(dissoc :page-id))]
|
||||
(rx/of (rt/nav :workspace params))))))
|
||||
|
||||
(defn- set-pull-request-preview
|
||||
(defn- set-branch-review-preview
|
||||
[preview]
|
||||
(ptk/reify ::set-pull-request-preview
|
||||
(ptk/reify ::set-branch-review-preview
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(if (nil? preview)
|
||||
(dissoc state :workspace-pr-preview)
|
||||
(update state :workspace-pr-preview merge preview)))))
|
||||
|
||||
(defn refresh-pull-request-preview-info
|
||||
"Refetch the pull request row backing the active sandbox (verdicts,
|
||||
counts, outdated flag). No-op when the sandbox is not active or shows
|
||||
another pull request. If the pull request finished meanwhile (merged
|
||||
or cancelled), the review context is dropped: the branch is a normal
|
||||
(defn refresh-branch-review-preview-info
|
||||
"Refetch the branch review row backing the active sandbox (verdicts and
|
||||
their staleness, counts). No-op when the sandbox is not active or shows
|
||||
another branch review. If the branch review finished meanwhile (merged
|
||||
or closed), the review context is dropped: the branch is a normal
|
||||
branch again."
|
||||
[id]
|
||||
(ptk/reify ::refresh-pull-request-preview-info
|
||||
(ptk/reify ::refresh-branch-review-preview-info
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(when (= id (get-in state [:workspace-pr-preview :pr-id]))
|
||||
@ -305,17 +275,17 @@
|
||||
(rx/mapcat
|
||||
(fn [info]
|
||||
(if (not= "open" (:status info))
|
||||
(rx/of (exit-pull-request-preview))
|
||||
(rx/of (set-pull-request-preview {:info info})))))
|
||||
(rx/of (exit-branch-review-preview))
|
||||
(rx/of (set-branch-review-preview {:info info})))))
|
||||
(rx/catch (fn [_] (rx/empty))))))))
|
||||
|
||||
(defn exit-pull-request-preview
|
||||
(defn exit-branch-review-preview
|
||||
"Leave the review context: drop the state entry and the `pr-id` query
|
||||
param. The file itself was never altered (it is the live branch file,
|
||||
opened normally), so no reload is needed — the branch banner simply
|
||||
takes over again."
|
||||
[]
|
||||
(ptk/reify ::exit-pull-request-preview
|
||||
(ptk/reify ::exit-branch-review-preview
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(dissoc state :workspace-pr-preview :workspace-review-local :workspace-review-activity))
|
||||
@ -328,16 +298,15 @@
|
||||
(dcmt/close-thread)
|
||||
(rt/nav :workspace params))))))
|
||||
|
||||
(defn- enter-pull-request-preview
|
||||
"Worker for `initialize-pull-request-preview`: load the pull request
|
||||
(defn- enter-branch-review-preview
|
||||
"Worker for `initialize-branch-review-preview`: load the branch review
|
||||
info and attach the review context to the open file. The file stays a
|
||||
NORMAL workspace file — fully navigable and editable, so reviewers can
|
||||
try and validate anything (edits go to the branch, as always); the
|
||||
pinned snapshot backs the interactions viewer and the outdated
|
||||
tracking, not the canvas. Cleans the url when the pull request does
|
||||
not belong to the open file or cannot be loaded."
|
||||
try and validate anything (edits go to the branch, as always). Cleans
|
||||
the url when the branch review does not belong to the open file or
|
||||
cannot be loaded."
|
||||
[pr-id]
|
||||
(ptk/reify ::enter-pull-request-preview
|
||||
(ptk/reify ::enter-branch-review-preview
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc state :workspace-pr-preview {:pr-id pr-id
|
||||
@ -353,16 +322,16 @@
|
||||
;; a stale pr-id param carried over a navigation (e.g.
|
||||
;; landing on main after merging from the review)
|
||||
(not= file-id (:source-file-id info))
|
||||
(rx/of (exit-pull-request-preview))
|
||||
(rx/of (exit-branch-review-preview))
|
||||
|
||||
;; the pull request already finished (merged or
|
||||
;; cancelled): the branch is a normal branch again, so
|
||||
;; the branch review already finished (merged or
|
||||
;; closed): the branch is a normal branch again, so
|
||||
;; there is no review context to restore
|
||||
(not= "open" (:status info))
|
||||
(rx/of (exit-pull-request-preview))
|
||||
(rx/of (exit-branch-review-preview))
|
||||
|
||||
:else
|
||||
(rx/of (set-pull-request-preview {:status :loaded :info info})
|
||||
(rx/of (set-branch-review-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
|
||||
@ -370,18 +339,18 @@
|
||||
(dwl/toggle-layout-flag :display-comments :force? true)))))
|
||||
(rx/catch
|
||||
(fn [_]
|
||||
(rx/of (ntf/warn (tr "workspace.pull-requests.preview.unavailable"))
|
||||
(exit-pull-request-preview)))))))))
|
||||
(rx/of (ntf/warn (tr "workspace.branch-review.preview.unavailable"))
|
||||
(exit-branch-review-preview)))))))))
|
||||
|
||||
(defn initialize-pull-request-preview
|
||||
(defn initialize-branch-review-preview
|
||||
"Attach the review context for `pr-id` to the open file. Split from the
|
||||
worker event so a re-emission (page navigation re-runs the workspace
|
||||
effect) is a cheap no-op."
|
||||
[pr-id]
|
||||
(assert (uuid? pr-id) "expected valid uuid for `pr-id`")
|
||||
(ptk/reify ::initialize-pull-request-preview
|
||||
(ptk/reify ::initialize-branch-review-preview
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(if (= pr-id (get-in state [:workspace-pr-preview :pr-id]))
|
||||
(rx/empty)
|
||||
(rx/of (enter-pull-request-preview pr-id))))))
|
||||
(rx/of (enter-branch-review-preview pr-id))))))
|
||||
@ -92,23 +92,30 @@
|
||||
the switcher or the all-branches dialog. A count belonging to ANOTHER
|
||||
file is dropped synchronously, as `fetch-branch-context` drops its own.
|
||||
A failure is kept as an error, which shows the row: a count that is
|
||||
unknown must not hide branches the file may have. The count lives under
|
||||
its own key because `init-branches-state` resets `:workspace-branches`."
|
||||
[]
|
||||
(ptk/reify ::fetch-branch-count
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [file-id (:current-file-id state)]
|
||||
(if (= file-id (get-in state [:workspace-branch-count :file-id]))
|
||||
state
|
||||
(dissoc state :workspace-branch-count))))
|
||||
unknown must not hide branches the file may have. With `listed`, the
|
||||
number of branches a listing just returned, a failure keeps that number
|
||||
instead: the listing is a lower bound of the family's count, which is
|
||||
all the header needs to show its row. The count lives under its own key
|
||||
because `init-branches-state` resets `:workspace-branches`."
|
||||
([] (fetch-branch-count nil))
|
||||
([listed]
|
||||
(ptk/reify ::fetch-branch-count
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [file-id (:current-file-id state)]
|
||||
(if (= file-id (get-in state [:workspace-branch-count :file-id]))
|
||||
state
|
||||
(dissoc state :workspace-branch-count))))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(when-let [file-id (:current-file-id state)]
|
||||
(->> (rp/cmd! :get-file-branch-count {:file-id file-id})
|
||||
(rx/map #(set-branch-count file-id {:count (:count %)}))
|
||||
(rx/catch (fn [_] (rx/of (set-branch-count file-id {:status :error})))))))))
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(when-let [file-id (:current-file-id state)]
|
||||
(->> (rp/cmd! :get-file-branch-count {:file-id file-id})
|
||||
(rx/map #(set-branch-count file-id {:count (:count %)}))
|
||||
(rx/catch (fn [_]
|
||||
(rx/of (set-branch-count file-id (if (some? listed)
|
||||
{:count listed}
|
||||
{:status :error})))))))))))
|
||||
|
||||
(defn branch-count-failed?
|
||||
"True when the branch count of the open file could not be loaded."
|
||||
@ -121,7 +128,8 @@
|
||||
branches. A successful listing also reloads the branch count, so the
|
||||
header follows a delete or a materialize made from the listing. The
|
||||
count is reloaded rather than taken from the listing, which holds only
|
||||
the branches of one source while the count covers the family."
|
||||
the branches of one source while the count covers the family; the
|
||||
listing's size stands in only when that reload fails."
|
||||
[]
|
||||
(ptk/reify ::fetch-branches
|
||||
ptk/WatchEvent
|
||||
@ -136,7 +144,7 @@
|
||||
(rp/cmd! :get-file-branches {:file-id root :include-archived true}))))
|
||||
(rx/mapcat (fn [data]
|
||||
(rx/of (update-branches-state {:status :loaded :data data})
|
||||
(fetch-branch-count))))
|
||||
(fetch-branch-count (count data)))))
|
||||
(rx/catch (fn [_]
|
||||
(rx/of (update-branches-state {:status :error})))))))))
|
||||
|
||||
@ -428,7 +436,7 @@
|
||||
|
||||
(defn item-key
|
||||
"The key a change or a conflict of a diff is chosen and marked as
|
||||
reviewed by: its change key
|
||||
viewed by: its change key
|
||||
(`app.common.files.branch-merge/change-key`), or its kind and id for an
|
||||
entry that carries none."
|
||||
[item]
|
||||
@ -441,7 +449,7 @@
|
||||
[item]
|
||||
(str (hash [(:status item) (:changed-attrs item) (:shape item) (:source item) (:branch item)])))
|
||||
|
||||
(declare fetch-diff-reviewed)
|
||||
(declare fetch-diff-viewed)
|
||||
|
||||
(defn update-branch-diff
|
||||
[diff-state]
|
||||
@ -477,13 +485,13 @@
|
||||
:excluded (if same? (or (:excluded prev) {}) {})
|
||||
;; the review marks are the ones of the direction: they
|
||||
;; stay while it reloads, and load again with the diff
|
||||
:reviewed (if same-direction? (or (:reviewed prev) #{}) #{})
|
||||
:viewed (if same-direction? (or (:viewed prev) #{}) #{})
|
||||
:resolutions (when same? (:resolutions prev))})))
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ stream]
|
||||
(->> (rp/cmd! :get-file-branch-diff {:branch-id branch-id :direction direction})
|
||||
(rx/mapcat #(rx/of (update-branch-diff {:status :loaded :diff %})
|
||||
(fetch-diff-reviewed)))
|
||||
(fetch-diff-viewed)))
|
||||
(rx/catch (fn [_]
|
||||
(rx/of (update-branch-diff {:status :error}))))
|
||||
(rx/take-until (rx/filter (ptk/type? ::fetch-branch-diff) stream)))))))
|
||||
@ -528,28 +536,28 @@
|
||||
(concat (get-in diff-state [:diff :changes])
|
||||
(get-in diff-state [:diff :conflicts]))))
|
||||
|
||||
(defn- set-diff-reviewed
|
||||
"Keep `reviewed` as the review marks of the diff of `branch-id` in
|
||||
(defn- set-diff-viewed
|
||||
"Keep `viewed` as the review marks of the diff of `branch-id` in
|
||||
`direction`, when that is still the one in the store."
|
||||
[branch-id direction reviewed]
|
||||
(ptk/reify ::set-diff-reviewed
|
||||
[branch-id direction viewed]
|
||||
(ptk/reify ::set-diff-viewed
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [diff-st (:workspace-branch-diff state)]
|
||||
(if (and (= branch-id (:branch-id diff-st))
|
||||
(= direction (:direction diff-st)))
|
||||
(assoc-in state [:workspace-branch-diff :reviewed] reviewed)
|
||||
(assoc-in state [:workspace-branch-diff :viewed] viewed)
|
||||
state)))))
|
||||
|
||||
(defn fetch-diff-reviewed
|
||||
"Load the changes the profile marked as reviewed in the comparison the
|
||||
(defn fetch-diff-viewed
|
||||
"Load the changes the profile marked as viewed in the comparison the
|
||||
store holds. A mark counts while its change is still what it was when
|
||||
it was marked (`change-fingerprint`): a layer that changed again asks
|
||||
to be reviewed again. The marks are the profile's own and the same
|
||||
inside and outside a design review. A failure leaves the marks as they
|
||||
to be viewed again. The marks are the profile's own and the same
|
||||
inside and outside a branch review. A failure leaves the marks as they
|
||||
are."
|
||||
[]
|
||||
(ptk/reify ::fetch-diff-reviewed
|
||||
(ptk/reify ::fetch-diff-viewed
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [{:keys [branch-id direction status] :as diff-st} (:workspace-branch-diff state)]
|
||||
@ -557,7 +565,7 @@
|
||||
(let [items (diff-items diff-st)]
|
||||
(->> (rp/cmd! :get-branch-change-marks {:branch-id branch-id :direction direction})
|
||||
(rx/map (fn [marks]
|
||||
(set-diff-reviewed
|
||||
(set-diff-viewed
|
||||
branch-id direction
|
||||
(into #{}
|
||||
(keep (fn [{:keys [change-key fingerprint]}]
|
||||
@ -568,30 +576,30 @@
|
||||
(rx/catch (fn [_] (rx/empty)))))
|
||||
(rx/empty))))))
|
||||
|
||||
(defn toggle-diff-reviewed
|
||||
"Mark the change `item-key` as reviewed in the compare mode, or clear
|
||||
the mark. `reviewed?` forces one side; nil flips it. The mark shows at
|
||||
(defn toggle-diff-viewed
|
||||
"Mark the change `item-key` as viewed in the compare mode, or clear
|
||||
the mark. `viewed?` forces one side; nil flips it. The mark shows at
|
||||
once and is kept for the profile, with the fingerprint of the change
|
||||
as it stands; if it cannot be kept, the marks are read again. The
|
||||
marks only guide the review: the merge does not read them."
|
||||
([item-key] (toggle-diff-reviewed item-key nil))
|
||||
([item-key reviewed?]
|
||||
(ptk/reify ::toggle-diff-reviewed
|
||||
([item-key] (toggle-diff-viewed item-key nil))
|
||||
([item-key viewed?]
|
||||
(ptk/reify ::toggle-diff-viewed
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update-in state [:workspace-branch-diff :reviewed]
|
||||
(fn [reviewed]
|
||||
(let [reviewed (or reviewed #{})
|
||||
reviewed? (if (some? reviewed?)
|
||||
reviewed?
|
||||
(not (contains? reviewed item-key)))]
|
||||
(if reviewed?
|
||||
(conj reviewed item-key)
|
||||
(disj reviewed item-key))))))
|
||||
(update-in state [:workspace-branch-diff :viewed]
|
||||
(fn [viewed]
|
||||
(let [viewed (or viewed #{})
|
||||
viewed? (if (some? viewed?)
|
||||
viewed?
|
||||
(not (contains? viewed item-key)))]
|
||||
(if viewed?
|
||||
(conj viewed item-key)
|
||||
(disj viewed item-key))))))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [{:keys [branch-id direction reviewed] :as diff-st} (:workspace-branch-diff state)
|
||||
(let [{:keys [branch-id direction viewed] :as diff-st} (:workspace-branch-diff state)
|
||||
item (get (diff-items diff-st) item-key)]
|
||||
;; only a change of the diff has a mark to keep
|
||||
(if (and (some? item) (uuid? branch-id))
|
||||
@ -600,9 +608,9 @@
|
||||
:direction direction
|
||||
:change-key item-key
|
||||
:fingerprint (change-fingerprint item)
|
||||
:reviewed (contains? reviewed item-key)})
|
||||
:viewed (contains? viewed item-key)})
|
||||
(rx/ignore)
|
||||
(rx/catch (fn [_] (rx/of (fetch-diff-reviewed)))))
|
||||
(rx/catch (fn [_] (rx/of (fetch-diff-viewed)))))
|
||||
(rx/empty)))))))
|
||||
|
||||
(defn clear-diff-excluded
|
||||
|
||||
@ -126,7 +126,7 @@
|
||||
(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;
|
||||
;; inside a branch 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))
|
||||
|
||||
@ -93,7 +93,7 @@
|
||||
;; --- Entries
|
||||
|
||||
(def item-key
|
||||
"The key a change or a conflict is chosen and marked as reviewed by
|
||||
"The key a change or a conflict is chosen and marked as viewed by
|
||||
(`dwb/item-key`)."
|
||||
dwb/item-key)
|
||||
|
||||
@ -208,7 +208,7 @@
|
||||
(rx/of (modal/hide)
|
||||
(dwdc/clear-drawing)
|
||||
(dws/deselect-all true)
|
||||
;; the changes of a design review give way to these ones
|
||||
;; the changes of a branch review give way to these ones
|
||||
(dwrv/hide-changes)
|
||||
(dwb/fetch-branch-diff (:id branch)))
|
||||
(rx/empty)))))
|
||||
|
||||
@ -20,11 +20,11 @@
|
||||
[app.main.data.plugins :as dpl]
|
||||
[app.main.data.websocket :as dws]
|
||||
[app.main.data.workspace :as-alias dw]
|
||||
[app.main.data.workspace.branch-reviews :as dwbr]
|
||||
[app.main.data.workspace.common :as dwc]
|
||||
[app.main.data.workspace.edition :as dwe]
|
||||
[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]
|
||||
@ -45,7 +45,7 @@
|
||||
(declare handle-file-deleted)
|
||||
(declare handle-file-restored)
|
||||
(declare handle-file-merged)
|
||||
(declare handle-pull-request-change)
|
||||
(declare handle-branch-review-change)
|
||||
(declare handle-library-change)
|
||||
(declare handle-pointer-send)
|
||||
(declare handle-export-update)
|
||||
@ -166,10 +166,10 @@
|
||||
:file-restored (handle-file-restored msg)
|
||||
:file-merged (handle-file-merged msg)
|
||||
:library-change (handle-library-change msg)
|
||||
:branch-review-created (handle-pull-request-change msg)
|
||||
:branch-review-updated (handle-pull-request-change msg)
|
||||
:branch-review-verdict-submitted (handle-pull-request-change msg)
|
||||
:branch-review-closed (handle-pull-request-change msg)
|
||||
:branch-review-created (handle-branch-review-change msg)
|
||||
:branch-review-updated (handle-branch-review-change msg)
|
||||
:branch-review-verdict-submitted (handle-branch-review-change msg)
|
||||
:branch-review-closed (handle-branch-review-change msg)
|
||||
:file-tasks-change (dwtk/handle-tasks-change msg)
|
||||
:notification (dc/handle-notification msg)
|
||||
:team-role-change (handle-change-team-role msg)
|
||||
@ -393,16 +393,16 @@
|
||||
(when (= file-id (:current-file-id state))
|
||||
(rx/of (ptk/event ::dw/reload-current-file))))))
|
||||
|
||||
(defn handle-pull-request-change
|
||||
"A pull request of this file changed (created / edited / reviewed /
|
||||
(defn handle-branch-review-change
|
||||
"A branch review of this file changed (created / edited / reviewed /
|
||||
closed): refresh the sidebar list, and the sandbox banner when it is
|
||||
showing that pull request."
|
||||
showing that branch review."
|
||||
[{:keys [review-id] :as _msg}]
|
||||
(ptk/reify ::handle-pull-request-change
|
||||
(ptk/reify ::handle-branch-review-change
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(rx/of (dwpr/fetch-pull-requests)
|
||||
(dwpr/refresh-pull-request-preview-info review-id)))))
|
||||
(rx/of (dwbr/fetch-branch-reviews)
|
||||
(dwbr/refresh-branch-review-preview-info review-id)))))
|
||||
|
||||
(def ^:private schema:handle-library-change
|
||||
[:map {:title "handle-library-change"}
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
(some? (:workspace-pr-preview state)))
|
||||
|
||||
(defn review-id
|
||||
"The id of the design review open now."
|
||||
"The id of the branch review open now."
|
||||
[state]
|
||||
(get-in state [:workspace-pr-preview :pr-id]))
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
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.
|
||||
branch 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
|
||||
@ -43,7 +43,7 @@
|
||||
[potok.v2.core :as ptk]))
|
||||
|
||||
(defn enabled?
|
||||
"Tasks ride on the branching feature, like design reviews."
|
||||
"Tasks ride on the branching feature, like branch reviews."
|
||||
[]
|
||||
(contains? cf/flags :branching))
|
||||
|
||||
@ -309,7 +309,7 @@
|
||||
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."
|
||||
the branch review it belongs to."
|
||||
[params]
|
||||
(ptk/reify ::start-new-task
|
||||
ptk/UpdateEvent
|
||||
@ -677,7 +677,7 @@
|
||||
(filter #(and (to-do? %) (= profile-id (:assignee-id %))) tasks))
|
||||
|
||||
(defn review-tasks
|
||||
"The tasks of the design review `review-id`."
|
||||
"The tasks of the branch review `review-id`."
|
||||
[tasks review-id]
|
||||
(filter #(= review-id (:review-id %)) tasks))
|
||||
|
||||
|
||||
@ -60,10 +60,10 @@
|
||||
outside it."
|
||||
(l/derived :workspace-compare st/state))
|
||||
|
||||
(def pull-requests
|
||||
(l/derived :workspace-pull-requests st/state))
|
||||
(def branch-reviews
|
||||
(l/derived :workspace-branch-reviews st/state))
|
||||
|
||||
(def pull-request-preview
|
||||
(def branch-review-preview
|
||||
;; active review context: {:pr-id .. :status .. :info <pr-row>}; the
|
||||
;; open file is the live branch, opened normally — this only drives
|
||||
;; the review banner/actions. nil when no review is active.
|
||||
@ -91,7 +91,7 @@
|
||||
(l/derived :workspace-review-activity st/state))
|
||||
|
||||
(def pending-reviews
|
||||
;; dashboard: open pull requests awaiting the current profile's review
|
||||
;; dashboard: open branch reviews awaiting the current profile's review
|
||||
(l/derived #(get % :dashboard-pending-reviews) st/state))
|
||||
|
||||
(def fetch-failures
|
||||
@ -119,7 +119,7 @@
|
||||
(= (:file-id ctx) (:current-file-id state)))))
|
||||
|
||||
(defn- reviewing?
|
||||
"True while the open file is shown inside a design review: the review
|
||||
"True while the open file is shown inside a branch review: the review
|
||||
is read-only, the branch is edited outside it."
|
||||
[state]
|
||||
(some? (:workspace-pr-preview state)))
|
||||
@ -132,7 +132,7 @@
|
||||
|
||||
(def permissions
|
||||
"The team permissions, without edition on a merged or archived branch,
|
||||
inside a design review or while comparing a branch with main."
|
||||
inside a branch review or while comparing a branch with main."
|
||||
(l/derived (fn [state]
|
||||
(cond-> (:permissions (dsh/lookup-team state))
|
||||
(or (open-closed-branch? state)
|
||||
@ -184,6 +184,16 @@
|
||||
(get files file-id)))
|
||||
st/state))
|
||||
|
||||
(def open-file-revision
|
||||
"The `:id` and the saved `:revn` of the open file. The revision rises
|
||||
with each save of the file, its own or a peer's
|
||||
(`app.main.data.persistence/update-file-revn`)."
|
||||
(l/derived (fn [state]
|
||||
(let [file-id (:current-file-id state)]
|
||||
{:id file-id
|
||||
:revn (dm/get-in state [:files file-id :revn])}))
|
||||
st/state =))
|
||||
|
||||
(def shared-files
|
||||
"A derived state that points to the current list of shared
|
||||
files (without the content, only summary)"
|
||||
|
||||
@ -1208,7 +1208,7 @@
|
||||
|
||||
(when (some? (:review-id thread))
|
||||
[:> review-label* {:label (or (:review-title thread)
|
||||
(tr "workspace.review.design-review"))}])
|
||||
(tr "workspace.review.branch-review"))}])
|
||||
|
||||
;; the workspace passes what a message shows about its task
|
||||
[:div {:class (stl/css :floating-thread-main)}
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.comments :as dcm]
|
||||
[app.main.data.event :as ev]
|
||||
[app.main.data.workspace.branch-reviews :as dwbr]
|
||||
[app.main.data.workspace.comments :as dwcm]
|
||||
[app.main.data.workspace.pull-requests :as dwpr]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.comments :as cmt]
|
||||
@ -78,7 +78,7 @@
|
||||
(first))]
|
||||
(when row
|
||||
(on-hide-comments)
|
||||
(st/emit! (-> (dwpr/open-pull-request row)
|
||||
(st/emit! (-> (dwbr/open-branch-review row)
|
||||
(with-meta {::ev/origin "dashboard"})))))))
|
||||
|
||||
on-read-all
|
||||
@ -91,7 +91,7 @@
|
||||
(mf/deps team-id)
|
||||
(fn []
|
||||
(st/emit! (dcm/retrieve-unread-comment-threads team-id)
|
||||
(dwpr/fetch-pending-reviews team-id))))
|
||||
(dwbr/fetch-pending-reviews team-id))))
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps show?)
|
||||
|
||||
@ -95,7 +95,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// --- Pending review requests (pull requests awaiting my review)
|
||||
// --- Pending review requests (branch reviews awaiting my review)
|
||||
|
||||
.review-requests {
|
||||
display: flex;
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
(mf/defc branch-pill*
|
||||
"A branch name inside running text, as a static pill. Main is drawn
|
||||
muted; any other branch in the accent color, or in the info blue when
|
||||
it is the branch of a pull request under review."
|
||||
it is the branch of a branch review under review."
|
||||
{::mf/schema schema:branch-pill}
|
||||
[{:keys [class label is-main is-review] :rest props}]
|
||||
(let [is-main (d/nilv is-main false)
|
||||
|
||||
@ -22,8 +22,8 @@ apart from the words around it.
|
||||
|
||||
<Canvas of={BranchPill.Main} />
|
||||
|
||||
`is-review` draws the branch in the info blue that marks pull requests
|
||||
and design reviews. It has no effect on main.
|
||||
`is-review` draws the branch in the info blue that marks branch reviews
|
||||
and branch reviews. It has no effect on main.
|
||||
|
||||
<Canvas of={BranchPill.Review} />
|
||||
|
||||
@ -45,7 +45,7 @@ The label is mandatory. Any other prop goes to the underlying `span`.
|
||||
### Where to use
|
||||
|
||||
Wherever a branch is named inside a line of text: the compare dialog
|
||||
header, the pull request banner.
|
||||
header, the branch review banner.
|
||||
|
||||
### Interaction / Behavior
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@
|
||||
:class (stl/css-case :pill true
|
||||
:pill-pending (= review "pending")
|
||||
:pill-approved (= review "approved"))
|
||||
:title (tr "workspace.pull-requests.info.approvals")}
|
||||
:title (tr "workspace.branch-review.info.approvals")}
|
||||
[:> icon* {:icon-id i/git-pull-request-arrow :size "s"}]
|
||||
(when (pos? reviewers)
|
||||
(dm/str approvals "/" reviewers))])]))
|
||||
|
||||
@ -18,7 +18,7 @@ and one pill with what blocks or moves its merge.
|
||||
|
||||
## Variants
|
||||
|
||||
The pill shows the review state of an open pull request, pending or
|
||||
The pill shows the review state of an open branch review, pending or
|
||||
approved, with its approvals.
|
||||
|
||||
<Canvas of={BranchStatus.InReview} />
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
(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
|
||||
(`anchor`, a chip). The whole card opens it. `review` names the branch 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
|
||||
|
||||
@ -20,7 +20,7 @@ its replies.
|
||||
|
||||
`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.
|
||||
of the branch review it belongs to.
|
||||
|
||||
<Canvas of={CommentCard.Open} />
|
||||
<Canvas of={CommentCard.InAReview} />
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
[:label :string]])
|
||||
|
||||
(mf/defc review-label*
|
||||
"Says that a comment or a task belongs to a design review, with the name
|
||||
"Says that a comment or a task belongs to a branch review, with the name
|
||||
of the review."
|
||||
{::mf/schema schema:review-label}
|
||||
[{:keys [class label] :rest props}]
|
||||
|
||||
@ -11,7 +11,7 @@ import * as ReviewLabel from "./review_label.stories";
|
||||
|
||||
# ReviewLabel
|
||||
|
||||
Says that a comment or a task belongs to a design review, with the name of
|
||||
Says that a comment or a task belongs to a branch review, with the name of
|
||||
the review.
|
||||
|
||||
<Canvas of={ReviewLabel.Default} />
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
[:aria-label :string]])
|
||||
|
||||
(mf/defc review-marker*
|
||||
"The mark a design review leaves on the canvas. A comment is a round
|
||||
"The mark a branch 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
|
||||
|
||||
@ -11,7 +11,7 @@ import * as ReviewMarker from "./review_marker.stories";
|
||||
|
||||
# ReviewMarker
|
||||
|
||||
The mark a design review leaves on the canvas: a round mark with the
|
||||
The mark a branch review leaves on the canvas: a round mark with the
|
||||
number of a comment, or a square one with the task icon.
|
||||
|
||||
<Canvas of={ReviewMarker.AllMarkers} />
|
||||
|
||||
@ -18,7 +18,7 @@ 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.
|
||||
with `is-review`. `review` shows the name of the branch review it belongs to.
|
||||
|
||||
<Canvas of={TaskRow.Selected} />
|
||||
<Canvas of={TaskRow.InAReview} />
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
[app.main.data.persistence :as dps]
|
||||
[app.main.data.plugins :as dpl]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.branch-reviews :as dwbr]
|
||||
[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]
|
||||
@ -37,9 +37,9 @@
|
||||
[app.main.ui.workspace.plugins]
|
||||
[app.main.ui.workspace.review.details]
|
||||
[app.main.ui.workspace.sidebar :refer [sidebar*]]
|
||||
[app.main.ui.workspace.sidebar.branch-reviews :refer [review-banner*]]
|
||||
[app.main.ui.workspace.sidebar.branches :refer [branch-context-banner*]]
|
||||
[app.main.ui.workspace.sidebar.history :refer [history-toolbox*]]
|
||||
[app.main.ui.workspace.sidebar.pull-requests :refer [pr-review-banner*]]
|
||||
[app.main.ui.workspace.tokens.export]
|
||||
[app.main.ui.workspace.tokens.export.modal]
|
||||
[app.main.ui.workspace.tokens.import]
|
||||
@ -96,14 +96,14 @@
|
||||
|
||||
node-ref (use-resize-observer on-resize)
|
||||
|
||||
pr-preview (mf/deref refs/pull-request-preview)]
|
||||
pr-preview (mf/deref refs/branch-review-preview)]
|
||||
[:*
|
||||
(when (not ^boolean hide-ui?)
|
||||
;; during a pull request review the review banner replaces the
|
||||
;; branch banner. The canvas is still the live, editable branch:
|
||||
;; edits change it and mark the pull request outdated
|
||||
;; during a branch review the review banner replaces the branch
|
||||
;; banner. The canvas is still the live, editable branch, which
|
||||
;; is what the reviewers see
|
||||
(if (some? pr-preview)
|
||||
[:> pr-review-banner* {}]
|
||||
[:> review-banner* {}]
|
||||
[:> branch-context-banner* {:file-id (get file :id)}]))
|
||||
|
||||
(when (not ^boolean hide-ui?)
|
||||
@ -271,13 +271,13 @@
|
||||
(st/emit! (dcm/go-to-workspace :file-id file-id ::rt/replace true))))
|
||||
|
||||
;; Review context: once the (branch) file is initialized, attach the
|
||||
;; pull request info so the review banner and actions show up; the
|
||||
;; branch review info so the review banner and actions show up; the
|
||||
;; file itself stays a normal, editable workspace file. The event is
|
||||
;; idempotent per pr-id, so page navigation re-running this effect
|
||||
;; is harmless.
|
||||
(mf/with-effect [file-id page-id pr-id file-loaded?]
|
||||
(when (and file-loaded? page-id pr-id)
|
||||
(st/emit! (dwpr/initialize-pull-request-preview pr-id))))
|
||||
(st/emit! (dwbr/initialize-branch-review-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?]
|
||||
|
||||
@ -15,8 +15,8 @@
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cf]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.workspace.branch-reviews :as dwbr]
|
||||
[app.main.data.workspace.branches :as dwb]
|
||||
[app.main.data.workspace.pull-requests :as dwpr]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.ds.controls.input :refer [input*]]
|
||||
@ -28,7 +28,7 @@
|
||||
[app.main.ui.ds.product.branch-row :refer [branch-row*]]
|
||||
[app.main.ui.ds.product.branch-status :refer [branch-status*]]
|
||||
[app.main.ui.workspace.menu-shortcuts :refer [shortcuts*]]
|
||||
[app.main.ui.workspace.sidebar.pull-requests :as prui]
|
||||
[app.main.ui.workspace.sidebar.branch-reviews :as brui]
|
||||
;; registers the reviews dialog the popover opens
|
||||
[app.main.ui.workspace.sidebar.reviews]
|
||||
[app.util.dom :as dom]
|
||||
@ -52,7 +52,7 @@
|
||||
(l/derived #(boolean (:workspace-branch-switcher %)) st/state))
|
||||
|
||||
(defn- open-pr-by-branch
|
||||
"The open pull requests indexed by the id of their branch."
|
||||
"The open branch reviews indexed by the id of their branch."
|
||||
[prs]
|
||||
(->> (:data prs)
|
||||
(filter #(= "open" (:status %)))
|
||||
@ -60,11 +60,12 @@
|
||||
(into {})))
|
||||
|
||||
(mf/defc row-status*
|
||||
"The `branch-status*` of a branch row and its open pull request (nil
|
||||
"The `branch-status*` of a branch row and its open branch review (nil
|
||||
when it has none)."
|
||||
{::mf/private true}
|
||||
[{:keys [row pr]}]
|
||||
(let [[approvals reviewers] (if pr (prui/current-approvals pr) [0 0])
|
||||
(let [pr (brui/use-live-verdicts pr)
|
||||
[approvals reviewers] (if pr (brui/current-approvals pr) [0 0])
|
||||
review (when (some? pr)
|
||||
(if (and (pos? reviewers) (= approvals reviewers)) "approved" "pending"))]
|
||||
[:> branch-status* {:ahead (:ahead row)
|
||||
@ -292,11 +293,11 @@
|
||||
open? (mf/deref switcher-open)
|
||||
ctx (mf/deref refs/branch-context)
|
||||
profile (mf/deref refs/profile)
|
||||
prs (mf/deref refs/pull-requests)
|
||||
prs (mf/deref refs/branch-reviews)
|
||||
|
||||
prs-by-branch
|
||||
(mf/with-memo [prs]
|
||||
(when (dwpr/enabled?)
|
||||
(when (dwbr/enabled?)
|
||||
(open-pr-by-branch prs)))
|
||||
|
||||
;; what the open file is: its branch row, or main
|
||||
|
||||
@ -17,8 +17,8 @@
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.ds.foundations.assets.icon :as i]
|
||||
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-review.sides :as brs]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.sides :as brs]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.webapi :as wapi]
|
||||
@ -32,7 +32,7 @@
|
||||
`:phase`, `:selected`, `:hovered` and `:attr`;
|
||||
`:status` of the diff (`:loading`, `:loaded`, `:error`);
|
||||
`:incoming` true when the changes listed are main's;
|
||||
`:excluded`, `:reviewed`, `:resolutions` the marks on the diff;
|
||||
`:excluded`, `:viewed`, `:resolutions` the marks on the diff;
|
||||
`:diff`, `:data`, `:copies` what the detail and the export read;
|
||||
`:model` the list of changes (`brc/change-model`);
|
||||
`:conflicts` the list of conflicts (`brc/conflict-model`);
|
||||
@ -49,7 +49,7 @@
|
||||
{:keys [status diff resolutions]} diff-st
|
||||
incoming? (= :source->branch (:direction diff-st))
|
||||
excluded (dwb/diff-excluded diff-st)
|
||||
reviewed (or (:reviewed diff-st) #{})
|
||||
viewed (or (:viewed diff-st) #{})
|
||||
active (:filter mode)
|
||||
|
||||
model (mf/with-memo [diff active excluded data]
|
||||
@ -73,7 +73,7 @@
|
||||
:status status
|
||||
:incoming incoming?
|
||||
:excluded excluded
|
||||
:reviewed reviewed
|
||||
:viewed viewed
|
||||
:resolutions (or resolutions {})
|
||||
:diff diff
|
||||
:data data
|
||||
@ -222,15 +222,15 @@
|
||||
(when-let [item-key (brc/step rows selected offset)]
|
||||
(st/emit! (dwcp/select item-key))))
|
||||
|
||||
(defn mark-reviewed
|
||||
"Mark the change chosen as reviewed and go to the next one not reviewed
|
||||
(defn mark-viewed
|
||||
"Mark the change chosen as viewed and go to the next one not viewed
|
||||
yet."
|
||||
[{:keys [rows selected item reviewed]}]
|
||||
[{:keys [rows selected item viewed]}]
|
||||
(when (some? item)
|
||||
(st/emit! (dwb/toggle-diff-reviewed selected true)))
|
||||
(st/emit! (dwb/toggle-diff-viewed selected true)))
|
||||
(when-let [item-key (brc/next-pending rows selected
|
||||
#(or (bm/settled? %)
|
||||
(contains? reviewed (dwcp/item-key %))))]
|
||||
(contains? viewed (dwcp/item-key %))))]
|
||||
(st/emit! (dwcp/select item-key))))
|
||||
|
||||
(defn toggle-excluded
|
||||
@ -322,11 +322,11 @@
|
||||
(st/emit! (dwcp/apply-resolutions)))
|
||||
|
||||
(defn- compare-bar
|
||||
[{:keys [branch status incoming model reviewed excluded]}]
|
||||
[{:keys [branch status incoming model viewed excluded]}]
|
||||
(let [{:keys [counted decisions kept left-out]} model
|
||||
loaded? (= status :loaded)
|
||||
total (count counted)
|
||||
reviewed-n (count (filter #(contains? reviewed (dwcp/item-key %)) counted))]
|
||||
viewed-n (count (filter #(contains? viewed (dwcp/item-key %)) counted))]
|
||||
{:icon (if incoming i/arrow-down i/git-compare-arrows)
|
||||
:title (if (and incoming loaded?)
|
||||
(tr "workspace.branches.banner.status.behind" (i18n/c total))
|
||||
@ -339,30 +339,30 @@
|
||||
(remove nil?
|
||||
[(tr "workspace.branches.compare.footer-changes" (i18n/c total))
|
||||
(when (pos? left-out)
|
||||
(tr "workspace.branches.review.footer.left-out" (i18n/c left-out)))
|
||||
(when (pos? reviewed-n)
|
||||
(tr "workspace.branches.review.footer.reviewed"
|
||||
(str reviewed-n) (str total)))])))
|
||||
(tr "workspace.branches.compare.footer.left-out" (i18n/c left-out)))
|
||||
(when (pos? viewed-n)
|
||||
(tr "workspace.branches.compare.footer.viewed"
|
||||
(str viewed-n) (str total)))])))
|
||||
:progress (when loaded?
|
||||
(tr "workspace.branches.review.footer.reviewed" (str reviewed-n) (str total)))
|
||||
(tr "workspace.branches.compare.footer.viewed" (str viewed-n) (str total)))
|
||||
:exit {:label (tr "workspace.compare.bar.exit") :icon i/close :on-click on-exit}
|
||||
:action (cond
|
||||
(not loaded?)
|
||||
nil
|
||||
|
||||
(pos? decisions)
|
||||
{:label (tr "workspace.branches.review.action.resolve" (i18n/c decisions))
|
||||
{:label (tr "workspace.branches.compare.action.resolve" (i18n/c decisions))
|
||||
:icon i/git-merge-conflict
|
||||
:on-click on-resolve}
|
||||
|
||||
incoming
|
||||
{:label (tr "workspace.branches.review.action.update" (i18n/c kept))
|
||||
{:label (tr "workspace.branches.compare.action.update" (i18n/c kept))
|
||||
:icon i/status-update
|
||||
:disabled (zero? kept)
|
||||
:on-click #(brc/confirm-update! branch excluded)}
|
||||
|
||||
:else
|
||||
{:label (tr "workspace.branches.review.action.merge" (i18n/c kept))
|
||||
{:label (tr "workspace.branches.compare.action.merge" (i18n/c kept))
|
||||
:icon i/git-merge
|
||||
:merge true
|
||||
:disabled (zero? kept)
|
||||
|
||||
@ -22,8 +22,8 @@
|
||||
[app.main.ui.workspace.compare.common :as cc]
|
||||
[app.main.ui.workspace.review.panel :refer [thread-card*]]
|
||||
[app.main.ui.workspace.review.tasks :refer [task-list*]]
|
||||
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-review.detail :as brd]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.detail :as brd]
|
||||
[app.util.i18n :refer [tr]]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
@ -139,7 +139,7 @@
|
||||
(mf/defc compare-detail*
|
||||
[]
|
||||
(let [comparison (cc/use-comparison)
|
||||
preview (mf/deref refs/pull-request-preview)
|
||||
preview (mf/deref refs/branch-review-preview)
|
||||
review? (some? preview)
|
||||
{:keys [item phase status]} comparison]
|
||||
(cond
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
@use "ds/mixins.scss" as *;
|
||||
|
||||
// its blocks over the whole width undo this padding
|
||||
// (`branch_review/detail.scss`)
|
||||
// (`branch_compare/detail.scss`)
|
||||
.compare-detail {
|
||||
@include custom-scrollbar;
|
||||
|
||||
|
||||
@ -25,8 +25,8 @@
|
||||
[app.main.ui.ds.product.filter-chip :refer [filter-chip*]]
|
||||
[app.main.ui.ds.product.tag :refer [tag*]]
|
||||
[app.main.ui.workspace.compare.common :as cc]
|
||||
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-review.list :as brli]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.list :as brli]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :refer [tr]]
|
||||
[rumext.v2 :as mf]))
|
||||
@ -94,13 +94,13 @@
|
||||
:data-filter "layers"
|
||||
:on-click on-filter}])
|
||||
(when (pos? (:library counts))
|
||||
[:> filter-chip* {:label (dm/str (tr "workspace.branches.review.group.library")
|
||||
[:> filter-chip* {:label (dm/str (tr "workspace.branches.compare.group.library")
|
||||
" (" (:library counts) ")")
|
||||
:is-selected (= selected :library)
|
||||
:data-filter "library"
|
||||
:on-click on-filter}])
|
||||
(when (pos? (:left-out counts))
|
||||
[:> filter-chip* {:label (dm/str (tr "workspace.branches.review.row.left-out")
|
||||
[:> filter-chip* {:label (dm/str (tr "workspace.branches.compare.row.left-out")
|
||||
" (" (:left-out counts) ")")
|
||||
:is-selected (= selected :left-out)
|
||||
:data-filter "left-out"
|
||||
@ -118,7 +118,7 @@
|
||||
"The changes of the direction shown, under the tabs that switch it."
|
||||
{::mf/private true}
|
||||
[{:keys [comparison]}]
|
||||
(let [{:keys [mode status incoming model selected excluded reviewed copies]} comparison
|
||||
(let [{:keys [mode status incoming model selected excluded viewed copies]} comparison
|
||||
counts (:counts mode)
|
||||
direction (if incoming :source->branch :branch->source)
|
||||
tabs (mf/with-memo [counts]
|
||||
@ -159,7 +159,7 @@
|
||||
:follow-counts follows
|
||||
:selected selected
|
||||
:excluded excluded
|
||||
:reviewed reviewed
|
||||
:viewed viewed
|
||||
:collapsed (:collapsed mode)
|
||||
:on-select on-select
|
||||
:on-toggle on-toggle
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
[app.main.ui.workspace.compare.common :as cc]
|
||||
[app.main.ui.workspace.compare.side :refer [side-view*]]
|
||||
[app.main.ui.workspace.review.overlays :as rvo]
|
||||
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-review.detail :as brd]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.detail :as brd]
|
||||
[app.render-wasm.api :as wasm.api]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :refer [tr]]
|
||||
@ -163,7 +163,7 @@
|
||||
|
||||
on-previous (mf/use-fn (mf/deps comparison) #(cc/select-step comparison -1))
|
||||
on-next (mf/use-fn (mf/deps comparison) #(cc/select-step comparison 1))
|
||||
on-mark (mf/use-fn (mf/deps comparison) #(cc/mark-reviewed comparison))
|
||||
on-mark (mf/use-fn (mf/deps comparison) #(cc/mark-viewed comparison))
|
||||
on-pending (mf/use-fn (mf/deps comparison) #(cc/next-pending comparison))
|
||||
on-clear (mf/use-fn (mf/deps comparison) #(cc/clear-choice comparison))
|
||||
|
||||
@ -207,7 +207,7 @@
|
||||
(not resolving?)
|
||||
[:> button* {:variant "ghost" :class (stl/css :navigator-action)
|
||||
:disabled (nil? item) :on-click on-mark}
|
||||
(tr "workspace.compare.navigator.mark-reviewed")]
|
||||
(tr "workspace.compare.navigator.mark-viewed")]
|
||||
|
||||
(and resolved? all-done?)
|
||||
[:> button* {:variant "ghost" :class (stl/css :navigator-action) :on-click on-clear}
|
||||
@ -221,7 +221,7 @@
|
||||
|
||||
(def ^:private next-key? (kbd/is-key-ignore-case? "j"))
|
||||
(def ^:private previous-key? (kbd/is-key-ignore-case? "k"))
|
||||
(def ^:private reviewed-key? (kbd/is-key-ignore-case? "r"))
|
||||
(def ^:private viewed-key? (kbd/is-key-ignore-case? "r"))
|
||||
(def ^:private exclude-key? (kbd/is-key-ignore-case? "x"))
|
||||
(def ^:private peek-key? (kbd/is-key-ignore-case? "m"))
|
||||
(def ^:private align-key? (kbd/is-key-ignore-case? "a"))
|
||||
@ -241,7 +241,7 @@
|
||||
(defn- use-shortcuts
|
||||
"The keys of the compare mode: Escape leaves it (or goes back from the
|
||||
conflicts to the changes), J and K go to the next and the previous
|
||||
row, R marks the change as reviewed, X leaves it out or takes it back
|
||||
row, R marks the change as viewed, X leaves it out or takes it back
|
||||
in, M shows main for as long as it is held, and A lines main up with
|
||||
the change chosen, or links it again, while it is beside the branch.
|
||||
A dialog, a field or a tool in use keeps its own keys."
|
||||
@ -274,8 +274,8 @@
|
||||
(next-key? event) (cc/select-step comparison 1)
|
||||
(previous-key? event) (cc/select-step comparison -1)
|
||||
|
||||
(and (reviewed-key? event) (not resolving?))
|
||||
(cc/mark-reviewed comparison)
|
||||
(and (viewed-key? event) (not resolving?))
|
||||
(cc/mark-viewed comparison)
|
||||
|
||||
(and (exclude-key? event) (not resolving?))
|
||||
(cc/toggle-excluded comparison)
|
||||
@ -320,7 +320,7 @@
|
||||
[{:keys [vbox vport zoom page-id show-rulers hover-ids]}]
|
||||
(let [comparison (cc/use-comparison)
|
||||
objects (mf/deref refs/workspace-page-objects)
|
||||
review? (some? (mf/deref refs/pull-request-preview))
|
||||
review? (some? (mf/deref refs/branch-review-preview))
|
||||
|
||||
{:keys [mode phase status incoming selected hovered item rows model
|
||||
conflicts excluded resolutions data res attr]} comparison
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
[app.main.ui.ds.product.branch-pill :refer [branch-pill*]]
|
||||
[app.main.ui.workspace.compare.common :as cc]
|
||||
[app.main.ui.workspace.review.overlays :as rvo]
|
||||
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.common :as brc]
|
||||
[app.main.ui.workspace.viewport.rulers :as rulers]
|
||||
[app.render-wasm.api :as wasm.api]
|
||||
[app.util.i18n :refer [tr]]
|
||||
|
||||
@ -51,7 +51,7 @@
|
||||
side? (and wasm? (= view :side) (not hidden))
|
||||
aligned? (= side-mode :aligned)
|
||||
highlight (tr "workspace.compare.view.highlight")
|
||||
side (tr "workspace.branches.review.view.side")
|
||||
side (tr "workspace.branches.compare.view.side")
|
||||
linked (tr "workspace.compare.view.side.linked")
|
||||
lined-up (tr "workspace.compare.view.side.aligned")
|
||||
;; the mode of the side view is told by the note on the canvas
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
@use "ds/_sizes.scss" as *;
|
||||
|
||||
// the active element of the toolbar: the accent of the drawing tools on a
|
||||
// branch, the blue of the review inside a design review
|
||||
// branch, the blue of the review inside a branch review
|
||||
.trigger {
|
||||
--trigger-bg-color: var(--color-background-quaternary);
|
||||
--trigger-fg-color: var(--color-accent-primary);
|
||||
|
||||
@ -43,17 +43,17 @@
|
||||
branch-ctx (mf/deref refs/branch-context)
|
||||
branch? (and (some? branch-ctx) (some? (:source-name branch-ctx)))
|
||||
|
||||
;; When a pull request review is active the header gets a
|
||||
;; distinct badge and the pull request title, so the user knows a
|
||||
;; When a branch review is active the header gets a
|
||||
;; distinct badge and the branch review title, so the user knows a
|
||||
;; review is open. The file is still the live, editable branch.
|
||||
pr-preview (mf/deref refs/pull-request-preview)
|
||||
pr-preview (mf/deref refs/branch-review-preview)
|
||||
review? (some? pr-preview)
|
||||
pr-title (get-in pr-preview [:info :title] "")
|
||||
|
||||
display-name
|
||||
(cond
|
||||
^boolean review?
|
||||
(tr "workspace.pull-requests.header-title" pr-title)
|
||||
(tr "workspace.branch-review.header-title" pr-title)
|
||||
|
||||
^boolean branch?
|
||||
(:source-name branch-ctx)
|
||||
@ -166,7 +166,7 @@
|
||||
:error (tr "workspace.header.save-error")
|
||||
nil)}]
|
||||
(when ^boolean review?
|
||||
[:> tooltip* {:content (tr "workspace.pull-requests.header-badge-tooltip" pr-title)
|
||||
[:> tooltip* {:content (tr "workspace.branch-review.header-badge-tooltip" pr-title)
|
||||
:placement "bottom"}
|
||||
[:span {:class (stl/css :review-badge)}
|
||||
[:> icon* {:icon-id i/git-pull-request-arrow :size "s"}]]])
|
||||
@ -174,7 +174,7 @@
|
||||
(if ^boolean review?
|
||||
[:*
|
||||
[:span {:class (stl/css :review-label)}
|
||||
(tr "workspace.pull-requests.header-label")]
|
||||
(tr "workspace.branch-review.header-label")]
|
||||
" " pr-title]
|
||||
display-name)]])]
|
||||
(when ^boolean shared?
|
||||
|
||||
@ -103,7 +103,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// pull request review: info blue, as every review mark (the banner, the
|
||||
// branch review: info blue, as every review mark (the banner, the
|
||||
// review pill), so an active review stands out from the plain branch badge
|
||||
.review-badge {
|
||||
display: flex;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
;; 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
|
||||
"The details of a branch 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])
|
||||
@ -15,7 +15,7 @@
|
||||
[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.branch-reviews :as dwbr]
|
||||
[app.main.data.workspace.review :as dwrv]
|
||||
[app.main.data.workspace.tasks :as dwtk]
|
||||
[app.main.refs :as refs]
|
||||
@ -42,9 +42,9 @@
|
||||
[app.main.ui.workspace.review.common :as rvc]
|
||||
[app.main.ui.workspace.review.shape-preview :refer [shape-preview*]]
|
||||
[app.main.ui.workspace.review.tasks :as rvt]
|
||||
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-review.layout :as brl]
|
||||
[app.main.ui.workspace.sidebar.pull-requests :as prui :refer [pr-state-badge* dialog-header*]]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.layout :as brl]
|
||||
[app.main.ui.workspace.sidebar.branch-reviews :as brui :refer [review-state-badge* dialog-header*]]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[cuerdas.core :as str]
|
||||
@ -82,12 +82,12 @@
|
||||
(mf/deps pr value)
|
||||
(fn [_]
|
||||
(reset! editing* false)
|
||||
(st/emit! (dwpr/update-pull-request (:id pr) {:description (str/trim value)}))))]
|
||||
(st/emit! (dwbr/update-branch-review (: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")]
|
||||
(tr "workspace.branch-review.info.description")]
|
||||
(when (and can-edit (not editing?))
|
||||
[:> button* {:variant "ghost" :on-click on-edit}
|
||||
(tr "labels.edit")])]
|
||||
@ -100,7 +100,7 @@
|
||||
:rows 3
|
||||
:max-length 4000
|
||||
:auto-focus true
|
||||
:aria-label (tr "workspace.pull-requests.info.description")
|
||||
:aria-label (tr "workspace.branch-review.info.description")
|
||||
:on-change on-change}]
|
||||
[:div {:class (stl/css :edit-actions)}
|
||||
[:> button* {:variant "secondary" :on-click on-cancel} (tr "labels.cancel")]
|
||||
@ -114,14 +114,6 @@
|
||||
[:> text* {:as "p" :typography t/body-medium :class (stl/css :description)}
|
||||
(:description pr)])]))
|
||||
|
||||
(defn- verdict-label
|
||||
[{:keys [verdict stale]}]
|
||||
(cond
|
||||
stale (tr "workspace.pull-requests.review-state.stale")
|
||||
(= "approved" verdict) (tr "workspace.pull-requests.review-state.approved")
|
||||
(= "changes-requested" verdict) (tr "workspace.pull-requests.review-state.changes-requested")
|
||||
:else (tr "workspace.pull-requests.review-state.pending")))
|
||||
|
||||
(defn- verdict-tone
|
||||
[{:keys [verdict stale]}]
|
||||
(cond
|
||||
@ -153,14 +145,14 @@
|
||||
(mf/deps pr current)
|
||||
(fn [id]
|
||||
(reset! adding* false)
|
||||
(st/emit! (dwpr/update-pull-request
|
||||
(st/emit! (dwbr/update-branch-review
|
||||
(: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")]
|
||||
(tr "workspace.branch-review.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")])]
|
||||
@ -186,7 +178,7 @@
|
||||
[:> tag* {:variant "pill"
|
||||
:tone (verdict-tone review)
|
||||
:class (stl/css :push-end)}
|
||||
(verdict-label review)]]
|
||||
(brui/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))])]))])]))
|
||||
@ -201,7 +193,7 @@
|
||||
can-edit (or (= (:created-by pr) (:id profile))
|
||||
(boolean (get-in team [:permissions :is-admin])))
|
||||
|
||||
[approvals total] (prui/current-approvals pr)
|
||||
[approvals total] (brui/current-approvals pr)
|
||||
missing (- total approvals)
|
||||
open (count (remove dwtk/closed? tasks))
|
||||
closed (count (filter dwtk/closed? tasks))
|
||||
@ -212,7 +204,7 @@
|
||||
[: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")]
|
||||
(tr "workspace.branch-review.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))]]]
|
||||
@ -229,7 +221,7 @@
|
||||
(tr "workspace.review.details.last-change-by"
|
||||
(ct/timeago (:created-at last-save))
|
||||
(rvc/profile-name profiles (:profile-id last-save)))
|
||||
(ct/timeago (:pinned-at pr)))]]]
|
||||
(ct/timeago (:created-at pr)))]]]
|
||||
|
||||
(when (and (pos? missing) (= "open" (:status pr)))
|
||||
[:> context-notification* {:level :warning :appearance :ghost}
|
||||
@ -238,7 +230,7 @@
|
||||
(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")}
|
||||
[:> stat-card* {:label (tr "workspace.branch-review.info.approvals")}
|
||||
[:span (tr "workspace.review.details.x-of-y" approvals total)]
|
||||
[:span {:class (stl/css :avatars)}
|
||||
(for [review (:reviews pr)]
|
||||
@ -254,7 +246,7 @@
|
||||
[:> 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)))]
|
||||
[:span {:class (stl/css :warning)} (tr "workspace.branch-review.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)))]
|
||||
@ -601,9 +593,10 @@
|
||||
{::mf/register modal/components
|
||||
::mf/register-as :review-details}
|
||||
[{:keys [pr tab]}]
|
||||
(let [preview (mf/deref refs/pull-request-preview)
|
||||
(let [preview (mf/deref refs/branch-review-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)
|
||||
pr (brui/use-live-verdicts pr)
|
||||
profile (mf/deref refs/profile)
|
||||
team (mf/deref refs/team)
|
||||
tasks* (mf/deref refs/tasks)
|
||||
@ -633,9 +626,9 @@
|
||||
(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))]
|
||||
on-compare (mf/use-fn (mf/deps pr) #(brui/open-compare! pr))
|
||||
on-review (mf/use-fn (mf/deps pr) #(modal/show! :branch-review-verdict {:pr pr}))
|
||||
on-close-review (mf/use-fn (mf/deps pr) #(brui/confirm-close! pr))]
|
||||
|
||||
(mf/with-effect [pr]
|
||||
(st/emit! (dwrv/fetch-activity (:id pr))
|
||||
@ -650,7 +643,7 @@
|
||||
:subtitle
|
||||
(mf/html
|
||||
[:div {:class (stl/css :subtitle)}
|
||||
[:> pr-state-badge* {:pr pr}]
|
||||
[:> review-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)
|
||||
|
||||
@ -5,11 +5,11 @@
|
||||
;; 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
|
||||
"The marks of the branch 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
|
||||
A thread written in a branch 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,
|
||||
@ -49,7 +49,7 @@
|
||||
|
||||
(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."
|
||||
bubbles: a thread of a branch review, or one attached to a task."
|
||||
[task-thread-ids thread]
|
||||
(or (some? (:review-id thread))
|
||||
(contains? task-thread-ids (:id thread))))
|
||||
|
||||
@ -87,7 +87,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// the change in front of a design review keeps its tag in the colour of
|
||||
// the change in front of a branch review keeps its tag in the colour of
|
||||
// the review, added or not
|
||||
.review-change .change-tag.is-active {
|
||||
--change-tag-bg-color: var(--color-accent-info);
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
[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.main.ui.workspace.sidebar.branch-reviews :as brui :refer [review-state-badge*]]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :refer [tr]]
|
||||
[rumext.v2 :as mf]))
|
||||
@ -43,7 +43,7 @@
|
||||
(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."
|
||||
it names the branch review it belongs to."
|
||||
[{:keys [thread objects is-open show-review]}]
|
||||
(let [owner (d/without-nils (dcmt/get-owner thread))
|
||||
replies (dec (or (:count-comments thread) 1))
|
||||
@ -71,7 +71,7 @@
|
||||
:icon (rvc/thread-anchor-icon thread)}])
|
||||
:review (when (and show-review review?)
|
||||
(or (:review-title thread)
|
||||
(tr "workspace.review.design-review")))
|
||||
(tr "workspace.review.branch-review")))
|
||||
:is-review review?
|
||||
:is-open is-open
|
||||
:is-resolved (:is-resolved thread)
|
||||
@ -81,7 +81,7 @@
|
||||
(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."
|
||||
the branch review it belongs to."
|
||||
[{:keys [threads show-page show-review]}]
|
||||
(let [profile (mf/deref refs/profile)
|
||||
clocal (mf/deref refs/comments-local)
|
||||
@ -145,7 +145,7 @@
|
||||
(mf/defc tasks-tab*
|
||||
"The tasks of the review (`review-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."
|
||||
names the branch review it belongs to."
|
||||
[{:keys [tasks review-id grouped show-review]}]
|
||||
(let [profile (mf/deref refs/profile)
|
||||
local (mf/deref refs/review-local)
|
||||
@ -227,14 +227,15 @@
|
||||
(mf/defc review-header*
|
||||
{::mf/private true}
|
||||
[{:keys [pr]}]
|
||||
(let [[approvals total] (prui/current-approvals pr)
|
||||
(let [pr (brui/use-live-verdicts pr)
|
||||
[approvals total] (brui/current-approvals pr)
|
||||
route (tr "workspace.review.route" (:branch-name pr)
|
||||
(rvc/route-target 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}]]
|
||||
[:> review-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))
|
||||
@ -245,7 +246,7 @@
|
||||
(`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)
|
||||
(let [preview (mf/deref refs/branch-review-preview)
|
||||
pr (:info preview)
|
||||
pr-id (:pr-id preview)
|
||||
threads* (mf/deref refs/threads)
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
|
||||
(ns app.main.ui.workspace.review.shape-preview
|
||||
"A small drawing of a layer, for the card of a change in the details of
|
||||
a design review."
|
||||
a branch review."
|
||||
(:require-macros [app.main.style :as stl])
|
||||
(:require
|
||||
[app.common.data.macros :as dm]
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
[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.branch-reviews :as dwbr]
|
||||
[app.main.data.workspace.review :as dwrv]
|
||||
[app.main.data.workspace.tasks :as dwtk]
|
||||
[app.main.refs :as refs]
|
||||
@ -228,7 +228,7 @@
|
||||
:is-selected is-selected
|
||||
:is-review review?
|
||||
:review (when (and show-review review?)
|
||||
(or (:review-title task) (tr "workspace.review.design-review")))
|
||||
(or (:review-title task) (tr "workspace.review.branch-review")))
|
||||
:on-click on-click
|
||||
:assignee (when assignee
|
||||
(mf/html [:> avatar* {:profile assignee :variant "S"}]))
|
||||
@ -236,7 +236,7 @@
|
||||
|
||||
(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."
|
||||
`show-review`, each one names the branch review it belongs to."
|
||||
[{:keys [tasks show-review]}]
|
||||
(let [data (mf/deref refs/workspace-data)
|
||||
profiles (mf/deref refs/profiles)
|
||||
@ -381,7 +381,7 @@
|
||||
(let [profiles (mf/deref refs/profiles)
|
||||
profile (mf/deref refs/profile)
|
||||
data (mf/deref refs/workspace-data)
|
||||
preview (mf/deref refs/pull-request-preview)
|
||||
preview (mf/deref refs/branch-review-preview)
|
||||
objects (page-objects data (:page-id task))
|
||||
for-me? (= (:assignee-id task) (:id profile))
|
||||
lost? (dwtk/lost? task)
|
||||
@ -395,8 +395,8 @@
|
||||
(mf/use-fn
|
||||
(mf/deps task file-id)
|
||||
(fn [_]
|
||||
(st/emit! (dwpr/open-pull-request {:id (:review-id task)
|
||||
:source-file-id file-id}))))]
|
||||
(st/emit! (dwbr/open-branch-review {:id (:review-id task)
|
||||
:source-file-id file-id}))))]
|
||||
|
||||
[:div {:class (stl/css :task-state)}
|
||||
[:div {:class (stl/css :task-state-row)}
|
||||
@ -433,7 +433,7 @@
|
||||
(let [profiles (mf/deref refs/profiles)
|
||||
events (get (mf/deref refs/task-events) (:id task))
|
||||
data (mf/deref refs/workspace-data)
|
||||
preview (mf/deref refs/pull-request-preview)
|
||||
preview (mf/deref refs/branch-review-preview)
|
||||
objects (page-objects data (:page-id task))
|
||||
status (:status task)
|
||||
|
||||
@ -672,7 +672,7 @@
|
||||
(count (filter f tasks)))
|
||||
|
||||
(defn group-tasks
|
||||
"The tasks of the branch workspace list: those of each design review
|
||||
"The tasks of the branch workspace list: those of each branch review
|
||||
first (the open review first), then the others."
|
||||
[tasks]
|
||||
(let [[review other] ((juxt filter remove) (comp some? :review-id) tasks)]
|
||||
|
||||
@ -129,8 +129,8 @@
|
||||
file-id (get file :id)
|
||||
|
||||
design-tokens? (features/use-feature "design-tokens/v1")
|
||||
;; a design review is read-only: it shows the pages and layers alone
|
||||
reviewing? (some? (mf/deref refs/pull-request-preview))
|
||||
;; a branch review is read-only: it shows the pages and layers alone
|
||||
reviewing? (some? (mf/deref refs/branch-review-preview))
|
||||
;; comparing the branch with main, the changes take their place
|
||||
comparing? (some? (mf/deref refs/compare-mode))
|
||||
mode-inspect? (or reviewing? (= options-mode :inspect))
|
||||
@ -301,7 +301,7 @@
|
||||
|
||||
(mf/defc right-sidebar*
|
||||
[{:keys [layout section file-id page-id drawing-tool active-tokens] :as props}]
|
||||
(let [reviewing? (some? (mf/deref refs/pull-request-preview))
|
||||
(let [reviewing? (some? (mf/deref refs/branch-review-preview))
|
||||
;; comparing the branch with main, the panel shows the change
|
||||
;; chosen; a commenting tool brings the comments and tasks back
|
||||
is-comparing? (and (some? (mf/deref refs/compare-mode))
|
||||
@ -376,7 +376,7 @@
|
||||
(and is-comparing? (not is-history?))
|
||||
[:> compare-detail* {}]
|
||||
|
||||
;; inside a design review the panel shows the inspect of the
|
||||
;; inside a branch 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?))
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
||||
|
||||
(ns app.main.ui.workspace.sidebar.branch-review.common
|
||||
(ns app.main.ui.workspace.sidebar.branch-compare.common
|
||||
"What the compare mode says about a diff entry, kept free of rendering:
|
||||
labels, values, one-line summaries, the page/board a change lives on,
|
||||
the list the changes make and the marks they leave on the canvas, how a
|
||||
@ -129,20 +129,20 @@
|
||||
: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")
|
||||
:page (tr "workspace.branches.compare.type.page")
|
||||
:page-attrs (tr "workspace.branches.compare.type.page-settings")
|
||||
:page-order (tr "workspace.branches.compare.type.page-order")
|
||||
:page-guide (tr "workspace.branches.compare.type.guides")
|
||||
:page-flow (tr "workspace.branches.compare.type.flows")
|
||||
:page-grid (tr "workspace.branches.compare.type.grids")
|
||||
(:page-plugin :file-plugin) (tr "workspace.branches.compare.type.plugin-data")
|
||||
:file-option (tr "workspace.branches.compare.type.file-options")
|
||||
(:token-set :token-set-rename) (tr "workspace.branches.compare.type.token-set")
|
||||
:token-set-order (tr "workspace.branches.compare.type.token-set-order")
|
||||
:token-theme (tr "workspace.branches.compare.type.theme")
|
||||
:token-active-themes (tr "workspace.branches.compare.type.active-themes")
|
||||
:token-active-sets (tr "workspace.branches.compare.type.active-sets")
|
||||
:tokens-source (tr "workspace.branches.compare.type.tokens-source")
|
||||
nil))
|
||||
|
||||
;; --- Property labels and values
|
||||
@ -156,11 +156,11 @@
|
||||
[attr]
|
||||
(case attr
|
||||
(:rx :ry :r1 :r2 :r3 :r4) (tr "workspace.branches.compare.attr.corner-radius")
|
||||
:content (tr "workspace.branches.review.attr.text")
|
||||
:fills (tr "workspace.branches.review.attr.fill")
|
||||
:strokes (tr "workspace.branches.review.attr.stroke")
|
||||
:layout-gap (tr "workspace.branches.review.attr.gap")
|
||||
:layout-padding (tr "workspace.branches.review.attr.padding")
|
||||
:content (tr "workspace.branches.compare.attr.text")
|
||||
:fills (tr "workspace.branches.compare.attr.fill")
|
||||
:strokes (tr "workspace.branches.compare.attr.stroke")
|
||||
:layout-gap (tr "workspace.branches.compare.attr.gap")
|
||||
:layout-padding (tr "workspace.branches.compare.attr.padding")
|
||||
:grow-type (tr "workspace.branches.compare.attr.text-auto-grow")
|
||||
:blend-mode (tr "workspace.branches.compare.attr.blend-mode")
|
||||
:shape-ref (tr "workspace.branches.compare.attr.component-reference")
|
||||
@ -292,20 +292,20 @@
|
||||
than its values, which the detail pane shows."
|
||||
[attr]
|
||||
(case attr
|
||||
:content (tr "workspace.branches.review.summary.text")
|
||||
:name (tr "workspace.branches.review.summary.renamed")
|
||||
(:x :y) (tr "workspace.branches.review.summary.moved")
|
||||
(:width :height) (tr "workspace.branches.review.summary.resized")
|
||||
:rotation (tr "workspace.branches.review.summary.rotated")
|
||||
(:parent-id :frame-id) (tr "workspace.branches.review.summary.reparented")
|
||||
:hidden (tr "workspace.branches.review.summary.visibility")
|
||||
:content (tr "workspace.branches.compare.summary.text")
|
||||
:name (tr "workspace.branches.compare.summary.renamed")
|
||||
(:x :y) (tr "workspace.branches.compare.summary.moved")
|
||||
(:width :height) (tr "workspace.branches.compare.summary.resized")
|
||||
:rotation (tr "workspace.branches.compare.summary.rotated")
|
||||
(:parent-id :frame-id) (tr "workspace.branches.compare.summary.reparented")
|
||||
:hidden (tr "workspace.branches.compare.summary.visibility")
|
||||
(:layout-gap :layout-padding :layout-padding-type :layout-gap-type)
|
||||
(tr "workspace.branches.review.summary.spacing")
|
||||
(tr "workspace.branches.compare.summary.spacing")
|
||||
(:layout :layout-flex-dir :layout-wrap-type :layout-justify-content
|
||||
:layout-align-items :layout-align-content :layout-justify-items
|
||||
:layout-grid-rows :layout-grid-columns :layout-grid-cells)
|
||||
(tr "workspace.branches.review.summary.layout")
|
||||
(tr "workspace.branches.review.summary.attr" (attr-label attr))))
|
||||
(tr "workspace.branches.compare.summary.layout")
|
||||
(tr "workspace.branches.compare.summary.attr" (attr-label attr))))
|
||||
|
||||
(defn change-summary
|
||||
"One line that says what a change did, in words: what was added or
|
||||
@ -321,13 +321,13 @@
|
||||
more (- (count phrases) (count shown))]
|
||||
(case status
|
||||
:added (tr "workspace.branches.compare.subtitle-new" (or lbl ""))
|
||||
:deleted (tr "workspace.branches.review.summary.deleted" (or lbl ""))
|
||||
:settled (tr "workspace.branches.review.copies.settled-row")
|
||||
:deleted (tr "workspace.branches.compare.summary.deleted" (or lbl ""))
|
||||
:settled (tr "workspace.branches.compare.copies.settled-row")
|
||||
(if (empty? phrases)
|
||||
(or lbl (tr "workspace.branches.review.summary.changed"))
|
||||
(or lbl (tr "workspace.branches.compare.summary.changed"))
|
||||
(cond-> (str/join ", " shown)
|
||||
(pos? more)
|
||||
(dm/str " " (tr "workspace.branches.review.summary.more" (i18n/c more))))))))
|
||||
(dm/str " " (tr "workspace.branches.compare.summary.more" (i18n/c more))))))))
|
||||
|
||||
;; --- Where a change lives: page and board
|
||||
|
||||
@ -513,7 +513,7 @@
|
||||
vec)]
|
||||
{:id (str page-id)
|
||||
:page-id page-id
|
||||
:name (or (:name page) (tr "workspace.branches.review.unknown-page"))
|
||||
:name (or (:name page) (tr "workspace.branches.compare.unknown-page"))
|
||||
:rows (into [] (comp (remove second) (map first)) placed)
|
||||
:boards boards
|
||||
:count (count (remove bm/settled? page-items))}))
|
||||
@ -528,14 +528,14 @@
|
||||
vec)
|
||||
(seq page-rows)
|
||||
(conj {:id "pages"
|
||||
:name (tr "workspace.branches.review.group.pages")
|
||||
:name (tr "workspace.branches.compare.group.pages")
|
||||
:rows page-rows
|
||||
:boards []
|
||||
:count (count page-rows)})
|
||||
|
||||
(seq library)
|
||||
(conj {:id "library"
|
||||
:name (tr "workspace.branches.review.group.library")
|
||||
:name (tr "workspace.branches.compare.group.library")
|
||||
:rows library
|
||||
:boards []
|
||||
:count (count library)}))))
|
||||
@ -970,50 +970,50 @@
|
||||
[group]
|
||||
(let [gname (name group)]
|
||||
(case group
|
||||
:name-group (tr "workspace.branches.review.copies.group.name")
|
||||
:fill-group (tr "workspace.branches.review.copies.group.fill")
|
||||
:stroke-group (tr "workspace.branches.review.copies.group.stroke")
|
||||
:content-group (tr "workspace.branches.review.copies.group.content")
|
||||
:geometry-group (tr "workspace.branches.review.copies.group.geometry")
|
||||
:radius-group (tr "workspace.branches.review.copies.group.radius")
|
||||
:visibility-group (tr "workspace.branches.review.copies.group.visibility")
|
||||
:modifiable-group (tr "workspace.branches.review.copies.group.lock")
|
||||
:text-font-group (tr "workspace.branches.review.copies.group.font")
|
||||
:text-display-group (tr "workspace.branches.review.copies.group.text-display")
|
||||
:layer-effects-group (tr "workspace.branches.review.copies.group.layer")
|
||||
:shadow-group (tr "workspace.branches.review.copies.group.shadow")
|
||||
:blur-group (tr "workspace.branches.review.copies.group.blur")
|
||||
:mask-group (tr "workspace.branches.review.copies.group.mask")
|
||||
:constraints-group (tr "workspace.branches.review.copies.group.constraints")
|
||||
:exports-group (tr "workspace.branches.review.copies.group.exports")
|
||||
:grids-group (tr "workspace.branches.review.copies.group.grids")
|
||||
:show-content (tr "workspace.branches.review.copies.group.clip")
|
||||
:name-group (tr "workspace.branches.compare.copies.group.name")
|
||||
:fill-group (tr "workspace.branches.compare.copies.group.fill")
|
||||
:stroke-group (tr "workspace.branches.compare.copies.group.stroke")
|
||||
:content-group (tr "workspace.branches.compare.copies.group.content")
|
||||
:geometry-group (tr "workspace.branches.compare.copies.group.geometry")
|
||||
:radius-group (tr "workspace.branches.compare.copies.group.radius")
|
||||
:visibility-group (tr "workspace.branches.compare.copies.group.visibility")
|
||||
:modifiable-group (tr "workspace.branches.compare.copies.group.lock")
|
||||
:text-font-group (tr "workspace.branches.compare.copies.group.font")
|
||||
:text-display-group (tr "workspace.branches.compare.copies.group.text-display")
|
||||
:layer-effects-group (tr "workspace.branches.compare.copies.group.layer")
|
||||
:shadow-group (tr "workspace.branches.compare.copies.group.shadow")
|
||||
:blur-group (tr "workspace.branches.compare.copies.group.blur")
|
||||
:mask-group (tr "workspace.branches.compare.copies.group.mask")
|
||||
:constraints-group (tr "workspace.branches.compare.copies.group.constraints")
|
||||
:exports-group (tr "workspace.branches.compare.copies.group.exports")
|
||||
:grids-group (tr "workspace.branches.compare.copies.group.grids")
|
||||
:show-content (tr "workspace.branches.compare.copies.group.clip")
|
||||
(cond
|
||||
(ctk/swap-slot? group) (tr "workspace.branches.review.copies.group.swap")
|
||||
(str/starts-with? gname "layout-item") (tr "workspace.branches.review.copies.group.layout-item")
|
||||
(str/starts-with? gname "layout") (tr "workspace.branches.review.copies.group.layout")
|
||||
(ctk/swap-slot? group) (tr "workspace.branches.compare.copies.group.swap")
|
||||
(str/starts-with? gname "layout-item") (tr "workspace.branches.compare.copies.group.layout-item")
|
||||
(str/starts-with? gname "layout") (tr "workspace.branches.compare.copies.group.layout")
|
||||
:else (-> gname (str/replace #"-group$" "") (str/replace "-" " ") str/capital)))))
|
||||
|
||||
(defn token-slot-label
|
||||
"A token slot (token attr of `:applied-tokens`) in words: the property
|
||||
the token drives."
|
||||
[slot]
|
||||
(tr "workspace.branches.review.copies.token-slot" (str/lower (attr-label slot))))
|
||||
(tr "workspace.branches.compare.copies.token-slot" (str/lower (attr-label slot))))
|
||||
|
||||
(defn reason-label
|
||||
"Why the copy rule gave a property to a side, in words."
|
||||
[reason]
|
||||
(case reason
|
||||
:follows-component (tr "workspace.branches.review.copies.reason.follows-component")
|
||||
:override-source (tr "workspace.branches.review.copies.reason.override-main")
|
||||
:override-branch (tr "workspace.branches.review.copies.reason.override-branch")
|
||||
(tr "workspace.branches.review.copies.reason.override-both")))
|
||||
:follows-component (tr "workspace.branches.compare.copies.reason.follows-component")
|
||||
:override-source (tr "workspace.branches.compare.copies.reason.override-main")
|
||||
:override-branch (tr "workspace.branches.compare.copies.reason.override-branch")
|
||||
(tr "workspace.branches.compare.copies.reason.override-both")))
|
||||
|
||||
(defn side-label
|
||||
[side]
|
||||
(if (= side :source)
|
||||
(tr "workspace.branches.review.side.main")
|
||||
(tr "workspace.branches.review.side.branch")))
|
||||
(tr "workspace.branches.compare.side.main")
|
||||
(tr "workspace.branches.compare.side.branch")))
|
||||
|
||||
(defn copies-entry
|
||||
"The `:copies` entry of the summary (`app.common.files.branch-merge/compute-merge`)
|
||||
@ -4,7 +4,7 @@
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
||||
|
||||
(ns app.main.ui.workspace.sidebar.branch-review.detail
|
||||
(ns app.main.ui.workspace.sidebar.branch-compare.detail
|
||||
"The detail of the entry chosen in a comparison. A change says what it
|
||||
did, property by property, as `before → after`, and what else comes
|
||||
with it. A conflict shows the two sides of each property: only the
|
||||
@ -22,9 +22,9 @@
|
||||
[app.main.ui.ds.foundations.typography.text :refer [text*]]
|
||||
[app.main.ui.ds.product.branch-pill :refer [branch-pill*]]
|
||||
[app.main.ui.ds.product.tag :refer [tag*]]
|
||||
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-review.facts :as brf]
|
||||
[app.main.ui.workspace.sidebar.branch-review.layout :as brl]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.facts :as brf]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.layout :as brl]
|
||||
[app.util.clipboard :as clipboard]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
@ -62,7 +62,7 @@
|
||||
:added [:> tag* {:tone "success"} (tr "workspace.branches.status.added")]
|
||||
:deleted [:> tag* {:tone "error"} (tr "workspace.branches.status.deleted")]
|
||||
:conflict [:> tag* {:tone "warning"} (tr "workspace.branches.status.conflict")]
|
||||
:settled [:> tag* {} (tr "workspace.branches.review.copies.settled-tag")]
|
||||
:settled [:> tag* {} (tr "workspace.branches.compare.copies.settled-tag")]
|
||||
[:> tag* {:tone "info"} (tr "workspace.branches.status.modified")]))
|
||||
|
||||
;; --- A change
|
||||
@ -83,11 +83,11 @@
|
||||
:summary (when-not (bm/settled? item) (brc/change-summary item))}
|
||||
[:> status-tag* {:status (:status item)}]
|
||||
(when excluded
|
||||
[:> tag* {:tone "info"} (tr "workspace.branches.review.row.left-out")])]
|
||||
[:> tag* {:tone "info"} (tr "workspace.branches.compare.row.left-out")])]
|
||||
|
||||
(when conflict?
|
||||
[:> brl/notice* {:level :warning}
|
||||
(tr "workspace.branches.review.decision.body")])
|
||||
(tr "workspace.branches.compare.decision.body")])
|
||||
|
||||
;; a copy the copy rule settled changes nothing: its section below
|
||||
;; says what the rule decided instead
|
||||
@ -142,7 +142,7 @@
|
||||
:else (tr "workspace.compare.action.leave-out-merge"))])
|
||||
(when on-resolve
|
||||
[:> button* {:variant "secondary" :class (stl/css :wide-action) :on-click on-resolve}
|
||||
(tr "workspace.branches.review.row.choose")])])]))
|
||||
(tr "workspace.branches.compare.row.choose")])])]))
|
||||
|
||||
;; --- A choice between the two sides
|
||||
|
||||
@ -151,7 +151,7 @@
|
||||
[{:keys [side branch-name is-review]}]
|
||||
(if (= side :source)
|
||||
[:> branch-pill* {:label (tr "workspace.branches.main") :is-main true}]
|
||||
[:> branch-pill* {:label (or branch-name (tr "workspace.branches.review.side.branch"))
|
||||
[:> branch-pill* {:label (or branch-name (tr "workspace.branches.compare.side.branch"))
|
||||
:is-review (boolean is-review)}]))
|
||||
|
||||
(mf/defc option-card*
|
||||
@ -4,7 +4,7 @@
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
||||
|
||||
(ns app.main.ui.workspace.sidebar.branch-review.facts
|
||||
(ns app.main.ui.workspace.sidebar.branch-compare.facts
|
||||
"What the detail says about an entry that has no before and after:
|
||||
a new or deleted page or layer, and the library entries other layers
|
||||
depend on. It answers what the entry is, where it lands and what it
|
||||
@ -18,9 +18,9 @@
|
||||
[app.main.ui.ds.foundations.typography :as t]
|
||||
[app.main.ui.ds.foundations.typography.text :refer [text*]]
|
||||
[app.main.ui.ds.product.tag :refer [tag*]]
|
||||
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-review.layout :as brl]
|
||||
[app.main.ui.workspace.sidebar.branch-review.sides :as brs]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.layout :as brl]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.sides :as brs]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[cuerdas.core :as str]
|
||||
[rumext.v2 :as mf]))
|
||||
@ -34,7 +34,7 @@
|
||||
[names]
|
||||
(dm/str (str/join ", " (take max-names names))
|
||||
(when (> (count names) max-names)
|
||||
(dm/str " " (tr "workspace.branches.review.summary.more"
|
||||
(dm/str " " (tr "workspace.branches.compare.summary.more"
|
||||
(i18n/c (- (count names) max-names)))))))
|
||||
|
||||
(mf/defc fact-list*
|
||||
@ -67,23 +67,23 @@
|
||||
(when page
|
||||
[:*
|
||||
[:> fact-list*
|
||||
{:rows [[(tr "workspace.branches.review.facts.contents")
|
||||
{:rows [[(tr "workspace.branches.compare.facts.contents")
|
||||
(if (zero? layers)
|
||||
(tr "workspace.branches.review.facts.empty-page")
|
||||
(dm/str (tr "workspace.branches.review.facts.boards" (i18n/c (count boards)))
|
||||
(tr "workspace.branches.compare.facts.empty-page")
|
||||
(dm/str (tr "workspace.branches.compare.facts.boards" (i18n/c (count boards)))
|
||||
" - "
|
||||
(tr "workspace.branches.review.facts.layers" (i18n/c layers))))]
|
||||
(tr "workspace.branches.compare.facts.layers" (i18n/c layers))))]
|
||||
(when (seq names)
|
||||
[(tr "workspace.branches.review.facts.board-names")
|
||||
[(tr "workspace.branches.compare.facts.board-names")
|
||||
(names-line names)])]}]
|
||||
(when (and deleted? (pos? layers))
|
||||
[:> brl/notice* {:level :warning
|
||||
:title (tr "workspace.branches.review.facts.page-goes")}
|
||||
(let [boards (tr "workspace.branches.review.facts.boards" (i18n/c (count boards)))
|
||||
layers (tr "workspace.branches.review.facts.layers" (i18n/c layers))]
|
||||
:title (tr "workspace.branches.compare.facts.page-goes")}
|
||||
(let [boards (tr "workspace.branches.compare.facts.boards" (i18n/c (count boards)))
|
||||
layers (tr "workspace.branches.compare.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)))])])))
|
||||
(tr "workspace.branches.compare.facts.page-goes-update" boards layers)
|
||||
(tr "workspace.branches.compare.facts.page-goes-merge" boards layers)))])])))
|
||||
|
||||
;; --- Layers
|
||||
|
||||
@ -98,22 +98,22 @@
|
||||
(get-in data [:components component-id :name]))]
|
||||
(cond-> []
|
||||
type-label
|
||||
(conj [(tr "workspace.branches.review.facts.type") type-label])
|
||||
(conj [(tr "workspace.branches.compare.facts.type") type-label])
|
||||
|
||||
(and (number? width) (number? height))
|
||||
(conj [(tr "workspace.branches.review.facts.size")
|
||||
(conj [(tr "workspace.branches.compare.facts.size")
|
||||
(dm/str (brc/display-val width) " × " (brc/display-val height))])
|
||||
|
||||
(and (number? x) (number? y))
|
||||
(conj [(tr "workspace.branches.review.facts.position")
|
||||
(conj [(tr "workspace.branches.compare.facts.position")
|
||||
(dm/str (brc/display-val x) ", " (brc/display-val y))])
|
||||
|
||||
fill
|
||||
(conj [(tr "workspace.branches.review.attr.fill")
|
||||
(conj [(tr "workspace.branches.compare.attr.fill")
|
||||
(mf/html [:> brl/value-chip* {:value fill}])])
|
||||
|
||||
text
|
||||
(conj [(tr "workspace.branches.review.attr.text") (brc/display-val text)])
|
||||
(conj [(tr "workspace.branches.compare.attr.text") (brc/display-val text)])
|
||||
|
||||
component
|
||||
(conj [(tr "workspace.branches.compare.attr.component") component]))))
|
||||
@ -128,10 +128,10 @@
|
||||
"A board with a layout around the layer: how it resizes, or how many
|
||||
of its other layers move."
|
||||
[{:keys [name layout from to moved]}]
|
||||
[(tr "workspace.branches.review.category.layout")
|
||||
[(tr "workspace.branches.compare.category.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))
|
||||
(tr "workspace.branches.compare.effects.moved" (i18n/c moved))
|
||||
(dm/str (size-line from) " → " (size-line to))))])
|
||||
|
||||
(mf/defc effects*
|
||||
@ -148,22 +148,22 @@
|
||||
deleted? (= :deleted (:status item))
|
||||
rows (cond-> (mapv layout-row layouts)
|
||||
(seq names)
|
||||
(conj [(tr "workspace.branches.review.facts.contents") (names-line names)]))]
|
||||
(conj [(tr "workspace.branches.compare.facts.contents") (names-line names)]))]
|
||||
(when (or (seq interactions) (seq flows) (seq rows))
|
||||
[:div {:class (stl/css :section)}
|
||||
[:> section-title* {}
|
||||
(if deleted?
|
||||
(tr "workspace.branches.review.effects.title-deleted")
|
||||
(tr "workspace.branches.review.effects.title-added"))]
|
||||
(tr "workspace.branches.compare.effects.title-deleted")
|
||||
(tr "workspace.branches.compare.effects.title-added"))]
|
||||
(when (seq interactions)
|
||||
[:> brl/notice* {:level :warning
|
||||
:title (tr "workspace.branches.review.effects.interactions"
|
||||
:title (tr "workspace.branches.compare.effects.interactions"
|
||||
(i18n/c (reduce + (map :count interactions))))}
|
||||
(tr "workspace.branches.review.effects.interactions-from"
|
||||
(tr "workspace.branches.compare.effects.interactions-from"
|
||||
(names-line (map :label interactions)))])
|
||||
(when (seq flows)
|
||||
[:> brl/notice* {:level :warning
|
||||
:title (tr "workspace.branches.review.effects.flows"
|
||||
:title (tr "workspace.branches.compare.effects.flows"
|
||||
(i18n/c (count flows)))}
|
||||
(names-line flows)])
|
||||
(when (seq rows)
|
||||
@ -195,16 +195,16 @@
|
||||
[:*
|
||||
[:> fact-list*
|
||||
{:rows (into [[(if deleted?
|
||||
(tr "workspace.branches.review.facts.where-was")
|
||||
(tr "workspace.branches.review.facts.where-lands"))
|
||||
(tr "workspace.branches.compare.facts.where-was")
|
||||
(tr "workspace.branches.compare.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")}
|
||||
:title (tr "workspace.branches.compare.facts.copies-orphaned-title")}
|
||||
(if incoming
|
||||
(tr "workspace.branches.review.facts.copies-orphaned-update" (i18n/c copies))
|
||||
(tr "workspace.branches.review.facts.copies-orphaned-merge" (i18n/c copies)))])
|
||||
(tr "workspace.branches.compare.facts.copies-orphaned-update" (i18n/c copies))
|
||||
(tr "workspace.branches.compare.facts.copies-orphaned-merge" (i18n/c copies)))])
|
||||
[:> effects* {:item item :items items :objects objects
|
||||
:inner inner :incoming incoming}]])))
|
||||
|
||||
@ -222,22 +222,22 @@
|
||||
(cond
|
||||
(and deleted? (pos? n))
|
||||
[:> brl/notice* {:level :warning
|
||||
:title (tr "workspace.branches.review.facts.used-title" (i18n/c n))}
|
||||
:title (tr "workspace.branches.compare.facts.used-title" (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)))]
|
||||
(tr "workspace.branches.compare.facts.deleted-component-used" (i18n/c n))
|
||||
(tr "workspace.branches.compare.facts.deleted-used" (i18n/c n)))]
|
||||
|
||||
deleted?
|
||||
[:> brl/notice* {:level :success
|
||||
:title (tr "workspace.branches.review.facts.unused-title")}
|
||||
(tr "workspace.branches.review.facts.deleted-unused")]
|
||||
:title (tr "workspace.branches.compare.facts.unused-title")}
|
||||
(tr "workspace.branches.compare.facts.deleted-unused")]
|
||||
|
||||
:else
|
||||
[:> fact-list*
|
||||
{:rows [[(tr "workspace.branches.review.facts.used-by")
|
||||
{:rows [[(tr "workspace.branches.compare.facts.used-by")
|
||||
(if (= kind :component)
|
||||
(tr "workspace.branches.review.facts.copies" (i18n/c n))
|
||||
(tr "workspace.branches.review.facts.layers" (i18n/c n)))]]}]))))
|
||||
(tr "workspace.branches.compare.facts.copies" (i18n/c n))
|
||||
(tr "workspace.branches.compare.facts.layers" (i18n/c n)))]]}]))))
|
||||
|
||||
;; --- Component copies
|
||||
|
||||
@ -257,19 +257,19 @@
|
||||
own? (or (seq keeps) (seq open))]
|
||||
(cond-> []
|
||||
(not own?)
|
||||
(conj (tr "workspace.branches.review.copies.follows-all"))
|
||||
(conj (tr "workspace.branches.compare.copies.follows-all"))
|
||||
|
||||
(seq (:source keeps))
|
||||
(conj (tr "workspace.branches.review.copies.keeps-main" (lower-list (:source keeps))))
|
||||
(conj (tr "workspace.branches.compare.copies.keeps-main" (lower-list (:source keeps))))
|
||||
|
||||
(seq (:branch keeps))
|
||||
(conj (tr "workspace.branches.review.copies.keeps-branch" (lower-list (:branch keeps))))
|
||||
(conj (tr "workspace.branches.compare.copies.keeps-branch" (lower-list (:branch keeps))))
|
||||
|
||||
(seq open)
|
||||
(conj (tr "workspace.branches.review.copies.slots-open" (lower-list open)))
|
||||
(conj (tr "workspace.branches.compare.copies.slots-open" (lower-list open)))
|
||||
|
||||
(and own? (seq follows))
|
||||
(conj (tr "workspace.branches.review.copies.follows" (lower-list follows))))))
|
||||
(conj (tr "workspace.branches.compare.copies.follows" (lower-list follows))))))
|
||||
|
||||
(defn- keeps-own?
|
||||
[copy]
|
||||
@ -300,14 +300,14 @@
|
||||
(when (pos? n)
|
||||
[:div {:class (stl/css :section)}
|
||||
[:> brl/group-head*
|
||||
{:label (cond-> (tr "workspace.branches.review.copies.follow" (i18n/c n))
|
||||
{:label (cond-> (tr "workspace.branches.compare.copies.follow" (i18n/c n))
|
||||
(pos? keeping)
|
||||
(dm/str " - " (tr "workspace.branches.review.copies.keeping" (i18n/c keeping))))
|
||||
(dm/str " - " (tr "workspace.branches.compare.copies.keeping" (i18n/c keeping))))
|
||||
:is-open open?
|
||||
:on-toggle on-toggle}]
|
||||
(when via
|
||||
[:> text* {:as "p" :typography t/body-small :class (stl/css :copy-via)}
|
||||
(tr "workspace.branches.review.copies.via"
|
||||
(tr "workspace.branches.compare.copies.via"
|
||||
(:component-name entry) (component-name copies data via))])
|
||||
(when open?
|
||||
[:div {:class (stl/css :copy-list)}
|
||||
@ -319,7 +319,7 @@
|
||||
(:label copy)]
|
||||
[:> text* {:as "span" :typography t/body-small :class (stl/css :copy-page)}
|
||||
(or (get-in data [:pages-index (:page-id copy) :name])
|
||||
(tr "workspace.branches.review.unknown-page"))]]
|
||||
(tr "workspace.branches.compare.unknown-page"))]]
|
||||
(for [[idx line] (map-indexed vector (copy-lines copy))]
|
||||
[:> text* {:key idx :as "span" :typography t/body-small
|
||||
:class (stl/css :copy-line)}
|
||||
@ -331,7 +331,7 @@
|
||||
[{:keys [n]}]
|
||||
(when (pos? n)
|
||||
[:> brl/notice* {:level :info}
|
||||
(tr "workspace.branches.review.copies.affected" (i18n/c n))]))
|
||||
(tr "workspace.branches.compare.copies.affected" (i18n/c n))]))
|
||||
|
||||
(mf/defc settled-facts*
|
||||
"What the copy rule decided on a copy (`settled`, the entry's
|
||||
@ -346,10 +346,10 @@
|
||||
(when (seq rows)
|
||||
[:div {:class (stl/css :section)}
|
||||
[:> section-title* {}
|
||||
(tr "workspace.branches.review.copies.settled-title")]
|
||||
(tr "workspace.branches.compare.copies.settled-title")]
|
||||
(when is-settled
|
||||
[:> brl/notice* {:level :info}
|
||||
(tr "workspace.branches.review.copies.settled-notice")])
|
||||
(tr "workspace.branches.compare.copies.settled-notice")])
|
||||
[:> fact-list*
|
||||
{:rows (mapv (fn [{:keys [label side reason]}]
|
||||
[label
|
||||
@ -361,4 +361,4 @@
|
||||
rows)}]
|
||||
(when (and is-conflict (seq open))
|
||||
[:> brl/notice* {:level :info}
|
||||
(tr "workspace.branches.review.copies.open-note" (lower-list open))])])))
|
||||
(tr "workspace.branches.compare.copies.open-note" (lower-list open))])])))
|
||||
@ -4,7 +4,7 @@
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
||||
|
||||
(ns app.main.ui.workspace.sidebar.branch-review.layout
|
||||
(ns app.main.ui.workspace.sidebar.branch-compare.layout
|
||||
"The small pieces the list and the detail of a comparison share: the
|
||||
heading of a group, a note, and a property value alone or as `before →
|
||||
after`."
|
||||
@ -14,7 +14,7 @@
|
||||
[app.main.ui.ds.foundations.typography :as t]
|
||||
[app.main.ui.ds.foundations.typography.text :refer [text*]]
|
||||
[app.main.ui.ds.notifications.context-notification :refer [context-notification*]]
|
||||
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.common :as brc]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(mf/defc group-head*
|
||||
@ -4,7 +4,7 @@
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
||||
|
||||
(ns app.main.ui.workspace.sidebar.branch-review.list
|
||||
(ns app.main.ui.workspace.sidebar.branch-compare.list
|
||||
"The rows of a comparison: the changes of a branch, grouped by page and
|
||||
board, each with the checkbox that keeps it in or leaves it out; and
|
||||
the conflicts of a merge or an update, with the ones that still wait
|
||||
@ -18,8 +18,8 @@
|
||||
[app.main.ui.ds.foundations.assets.icon :as i]
|
||||
[app.main.ui.ds.product.change-row :refer [change-row*]]
|
||||
[app.main.ui.ds.product.tag :refer [tag*]]
|
||||
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-review.layout :as brl]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.layout :as brl]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[cuerdas.core :as str]
|
||||
@ -29,25 +29,25 @@
|
||||
|
||||
(mf/defc row-end*
|
||||
{::mf/private true}
|
||||
[{:keys [item excluded reviewed]}]
|
||||
[{:keys [item excluded viewed]}]
|
||||
(let [status (:status item)
|
||||
edits (count (brc/visible-attrs (:changed-attrs item)))]
|
||||
(cond
|
||||
(= :conflict status)
|
||||
[:> tag* {:tone "warning" :variant "pill"}
|
||||
(tr "workspace.branches.review.row.choose")]
|
||||
(tr "workspace.branches.compare.row.choose")]
|
||||
|
||||
;; information, not a change: nothing to choose or leave out
|
||||
(= :settled status)
|
||||
[:> tag* {:variant "pill"} (tr "workspace.branches.review.copies.settled-tag")]
|
||||
[:> tag* {:variant "pill"} (tr "workspace.branches.compare.copies.settled-tag")]
|
||||
|
||||
excluded
|
||||
[:> tag* {:tone "info" :variant "pill"} (tr "workspace.branches.review.row.left-out")]
|
||||
[:> tag* {:tone "info" :variant "pill"} (tr "workspace.branches.compare.row.left-out")]
|
||||
|
||||
;; reviewing is the user's progress, not what happened to the
|
||||
;; entry: a quiet tag in the place of the coloured status
|
||||
reviewed
|
||||
[:> tag* {:variant "pill"} (tr "workspace.branches.review.row.reviewed")]
|
||||
viewed
|
||||
[:> tag* {:variant "pill"} (tr "workspace.branches.compare.row.viewed")]
|
||||
|
||||
(= :added status)
|
||||
[:> tag* {:tone "success" :variant "pill"} (tr "workspace.branches.status.added")]
|
||||
@ -57,7 +57,7 @@
|
||||
|
||||
(pos? edits)
|
||||
[:> tag* {:tone "info" :variant "pill"}
|
||||
(tr "workspace.branches.review.row.edits" (i18n/c edits))]
|
||||
(tr "workspace.branches.compare.row.edits" (i18n/c edits))]
|
||||
|
||||
:else nil)))
|
||||
|
||||
@ -78,17 +78,17 @@
|
||||
under it: the row counts them and its checkbox takes them along.
|
||||
`follows` is how many copies follow the component the row changes.
|
||||
Without `on-toggle` the row has no checkbox."
|
||||
[{:keys [item inner follows selected excluded reviewed on-select on-toggle]}]
|
||||
[{:keys [item inner follows selected excluded viewed on-select on-toggle]}]
|
||||
(let [item-key (dwcp/item-key item)
|
||||
selectable? (and (some? on-toggle) (brc/selectable-item? item))
|
||||
toggle-keys (brc/row-keys item inner)
|
||||
subtitle (cond-> (brc/change-summary item)
|
||||
(seq inner)
|
||||
(dm/str " - " (tr "workspace.branches.review.facts.layers"
|
||||
(dm/str " - " (tr "workspace.branches.compare.facts.layers"
|
||||
(i18n/c (count inner))))
|
||||
|
||||
(and follows (pos? follows))
|
||||
(dm/str " - " (tr "workspace.branches.review.copies.row-follow"
|
||||
(dm/str " - " (tr "workspace.branches.compare.copies.row-follow"
|
||||
(i18n/c follows))))
|
||||
pointed? (= item-key (mf/use-ctx pointed-row))
|
||||
on-click (mf/use-fn (mf/deps item-key on-select) #(on-select item-key))
|
||||
@ -111,13 +111,13 @@
|
||||
;; for whoever follows the pointer over the list
|
||||
:data-item-key item-key
|
||||
:start start
|
||||
:end (mf/html [:> row-end* {:item item :excluded excluded :reviewed reviewed}])
|
||||
:end (mf/html [:> row-end* {:item item :excluded excluded :viewed viewed}])
|
||||
:on-click on-click}]))
|
||||
|
||||
(mf/defc rows*
|
||||
"The rows of `items`, each with what the list knows about it."
|
||||
{::mf/private true}
|
||||
[{:keys [items cascades follow-counts selected excluded reviewed on-select on-toggle]}]
|
||||
[{:keys [items cascades follow-counts selected excluded viewed on-select on-toggle]}]
|
||||
(for [item items
|
||||
:let [item-key (dwcp/item-key item)]]
|
||||
[:> item-row* {:key item-key
|
||||
@ -126,7 +126,7 @@
|
||||
:follows (follows-of follow-counts item)
|
||||
:selected selected
|
||||
:excluded (contains? excluded (:key item))
|
||||
:reviewed (contains? reviewed item-key)
|
||||
:viewed (contains? viewed item-key)
|
||||
:on-select on-select
|
||||
:on-toggle on-toggle}]))
|
||||
|
||||
@ -148,7 +148,7 @@
|
||||
"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
|
||||
[{:keys [group cascades follow-counts selected excluded viewed collapsed
|
||||
on-select on-toggle on-fold]}]
|
||||
(let [{:keys [id name rows boards count]} group
|
||||
open? (not (contains? collapsed id))
|
||||
@ -177,7 +177,7 @@
|
||||
:follow-counts follow-counts
|
||||
:selected selected
|
||||
:excluded excluded
|
||||
:reviewed reviewed
|
||||
:viewed viewed
|
||||
:on-select on-select
|
||||
:on-toggle on-toggle}]
|
||||
(for [board boards]
|
||||
@ -191,7 +191,7 @@
|
||||
:follow-counts follow-counts
|
||||
:selected selected
|
||||
:excluded excluded
|
||||
:reviewed reviewed
|
||||
:viewed viewed
|
||||
:on-select on-select
|
||||
:on-toggle on-toggle}]])])]))
|
||||
|
||||
@ -199,7 +199,7 @@
|
||||
"The list of a comparison (`model`, a `brc/change-model`): the changes
|
||||
both sides made, which wait for a decision, and then the clean ones by
|
||||
page and board."
|
||||
[{:keys [model follow-counts selected excluded reviewed collapsed
|
||||
[{:keys [model follow-counts selected excluded viewed collapsed
|
||||
on-select on-toggle on-fold]}]
|
||||
(let [{:keys [conflicts groups cascades]} model
|
||||
open? (not (contains? collapsed "decisions"))
|
||||
@ -207,7 +207,7 @@
|
||||
[:*
|
||||
(when (seq conflicts)
|
||||
[:div {:class (stl/css :group)}
|
||||
[:> brl/group-head* {:label (tr "workspace.branches.review.group.decisions"
|
||||
[:> brl/group-head* {:label (tr "workspace.branches.compare.group.decisions"
|
||||
(str (count conflicts)))
|
||||
:is-open open?
|
||||
:on-toggle on-header}]
|
||||
@ -215,7 +215,7 @@
|
||||
[:> rows* {:items conflicts
|
||||
:follow-counts follow-counts
|
||||
:selected selected
|
||||
:reviewed reviewed
|
||||
:viewed viewed
|
||||
:on-select on-select}])])
|
||||
|
||||
(for [group groups]
|
||||
@ -225,7 +225,7 @@
|
||||
:follow-counts follow-counts
|
||||
:selected selected
|
||||
:excluded excluded
|
||||
:reviewed reviewed
|
||||
:viewed viewed
|
||||
:collapsed collapsed
|
||||
:on-select on-select
|
||||
:on-toggle on-toggle
|
||||
@ -278,7 +278,7 @@
|
||||
(tr "workspace.branches.resolve.row.loses-work")]
|
||||
:else
|
||||
[:> tag* {:tone "warning" :variant "pill"}
|
||||
(tr "workspace.branches.review.row.choose")]))
|
||||
(tr "workspace.branches.compare.row.choose")]))
|
||||
:on-click on-click}]))
|
||||
|
||||
(mf/defc conflict-group*
|
||||
@ -4,7 +4,7 @@
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
||||
|
||||
(ns app.main.ui.workspace.sidebar.branch-review.sides
|
||||
(ns app.main.ui.workspace.sidebar.branch-compare.sides
|
||||
"The two sides of a change, main and the branch. The diff carries whole
|
||||
entities for conflicts and for added or deleted shapes; for a modified
|
||||
entity the open file holds one side and the changed attrs give the
|
||||
@ -4,13 +4,13 @@
|
||||
;;
|
||||
;; 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
|
||||
(one branch → at most one open pull request), so there is no separate
|
||||
pull request list: the branch entries in the sidebar surface the review
|
||||
(ns app.main.ui.workspace.sidebar.branch-reviews
|
||||
"Branch review UI. A branch review is presented as a STATE of its
|
||||
branch (one branch → at most one open review), so there is no separate
|
||||
review list: the branch entries in the sidebar surface the review
|
||||
state (see `app.main.ui.workspace.sidebar.branches`), and this namespace
|
||||
provides the shared pieces — state badge, action helpers, the creation /
|
||||
review / details modals and the review-sandbox banner."
|
||||
verdict / details modals and the review bar."
|
||||
(:require-macros [app.main.style :as stl])
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
@ -19,8 +19,8 @@
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.team :as dtm]
|
||||
[app.main.data.workspace.branch-reviews :as dwbr]
|
||||
[app.main.data.workspace.compare :as dwcp]
|
||||
[app.main.data.workspace.pull-requests :as dwpr]
|
||||
[app.main.data.workspace.review :as dwrv]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
@ -36,7 +36,6 @@
|
||||
[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.tooltip :refer [tooltip*]]
|
||||
[app.main.ui.workspace.compare.common :as cc]
|
||||
[app.main.ui.workspace.review.common :as rvc]
|
||||
[app.util.dom :as dom]
|
||||
@ -46,8 +45,61 @@
|
||||
|
||||
;; --- Derived display state
|
||||
|
||||
(defn verdict-stale?
|
||||
"True when the verdict of `review` was given on an earlier revision of
|
||||
the branch of `pr`. While that branch is the open file, `file` decides
|
||||
at once: it is the `:id` and the saved `:revn` of the open file
|
||||
(`app.main.refs/open-file-revision`), and
|
||||
`app.main.data.persistence/update-file-revn` raises that `:revn` after
|
||||
each save of the file, its own or a peer's. The verdict is then stale
|
||||
once the revision passes its `:verdict-revn`. Otherwise the `:stale`
|
||||
the server computed stands."
|
||||
[pr file review]
|
||||
(let [revn (:revn file)
|
||||
verdict-revn (:verdict-revn review)]
|
||||
(if (and (some? (:id file))
|
||||
(= (:id file) (:source-file-id pr))
|
||||
(int? revn)
|
||||
(int? verdict-revn))
|
||||
(> revn verdict-revn)
|
||||
(boolean (:stale review)))))
|
||||
|
||||
(defn- overall-verdict
|
||||
"The aggregate verdict of `reviews`, as the server computes it:
|
||||
changes requested beats approved, a stale verdict only counts as in
|
||||
review, and no verdict at all is pending."
|
||||
[reviews]
|
||||
(let [submitted (filter #(contains? #{"approved" "changes-requested"} (:verdict %)) reviews)
|
||||
current (remove :stale submitted)]
|
||||
(cond
|
||||
(some #(= "changes-requested" (:verdict %)) current) "changes-requested"
|
||||
(some #(= "approved" (:verdict %)) current) "approved"
|
||||
(seq submitted) "in-review"
|
||||
:else "pending")))
|
||||
|
||||
(defn live-verdicts
|
||||
"`pr` with the `:stale` of each of its reviews (`verdict-stale?`) and its
|
||||
`:overall-verdict` brought up to the open file `file`. A review of
|
||||
another branch than the open file stays as the server sent it."
|
||||
[pr file]
|
||||
(if (and (some? pr)
|
||||
(some? (:id file))
|
||||
(= (:id file) (:source-file-id pr)))
|
||||
(let [reviews (mapv #(assoc % :stale (verdict-stale? pr file %)) (:reviews pr))]
|
||||
(assoc pr
|
||||
:reviews reviews
|
||||
:overall-verdict (overall-verdict reviews)))
|
||||
pr))
|
||||
|
||||
(defn use-live-verdicts
|
||||
"`live-verdicts` of `pr` against the open file, followed save by save."
|
||||
[pr]
|
||||
(let [file (mf/deref refs/open-file-revision)]
|
||||
(mf/with-memo [pr file]
|
||||
(live-verdicts pr file))))
|
||||
|
||||
(defn- display-state
|
||||
"The single most relevant label for a pull request: its stored status
|
||||
"The single most relevant label for a branch review: its stored status
|
||||
for finished ones, the aggregate review verdict for open ones."
|
||||
[{:keys [status overall-verdict]}]
|
||||
(case status
|
||||
@ -62,16 +114,16 @@
|
||||
(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")))
|
||||
:open (tr "workspace.branch-review.state.open")
|
||||
:in-review (tr "workspace.branch-review.state.in-review")
|
||||
:approved (tr "workspace.branch-review.state.approved")
|
||||
:changes-requested (tr "workspace.branch-review.state.changes-requested")
|
||||
:merged (tr "workspace.branch-review.state.merged")
|
||||
:closed (tr "workspace.branch-review.state.closed")))
|
||||
|
||||
(mf/defc pr-state-badge*
|
||||
(mf/defc review-state-badge*
|
||||
[{:keys [pr]}]
|
||||
(let [state (display-state pr)]
|
||||
(let [state (display-state (use-live-verdicts pr))]
|
||||
[:span {:class (stl/css-case :pr-badge true
|
||||
:badge-open (= state :open)
|
||||
:badge-in-review (= state :in-review)
|
||||
@ -82,14 +134,31 @@
|
||||
(state-label state)]))
|
||||
|
||||
(defn current-approvals
|
||||
"[current-approvals total-reviewers] of a pull request; stale verdicts
|
||||
"[current-approvals total-reviewers] of a branch review; stale verdicts
|
||||
do not count."
|
||||
[{:keys [reviews]}]
|
||||
[(count (filter #(and (= "approved" (:verdict %)) (not (:stale %))) reviews))
|
||||
(count reviews)])
|
||||
|
||||
(defn verdict-label
|
||||
"What the row of a reviewer says: the verdict, or that it was given on
|
||||
an earlier version when the branch changed after it."
|
||||
[{:keys [verdict stale]}]
|
||||
(case verdict
|
||||
"approved"
|
||||
(if stale
|
||||
(tr "workspace.branch-review.review-state.stale-approved")
|
||||
(tr "workspace.branch-review.review-state.approved"))
|
||||
|
||||
"changes-requested"
|
||||
(if stale
|
||||
(tr "workspace.branch-review.review-state.stale-changes-requested")
|
||||
(tr "workspace.branch-review.state.changes-requested"))
|
||||
|
||||
(tr "workspace.branch-review.review-state.pending")))
|
||||
|
||||
(defn- pr->branch
|
||||
"A branch-row-shaped map for the pull request's branch, enough for the
|
||||
"A branch-row-shaped map for the branch review's branch, enough for the
|
||||
branching compare / merge dialogs (they key on :id and :name; the
|
||||
counts feed their action buttons)."
|
||||
[pr]
|
||||
@ -102,32 +171,32 @@
|
||||
:conflicts (:conflicts pr)})
|
||||
|
||||
(defn open-compare!
|
||||
"Compare the pull request's branch with main on the canvas, so the
|
||||
"Compare the branch review's branch with main on the canvas, so the
|
||||
proposed changes can be inspected. Like merging, it diffs the LIVE
|
||||
branch against main. The branch is the open file inside its review."
|
||||
[pr]
|
||||
(st/emit! (dwcp/enter (pr->branch pr))))
|
||||
|
||||
(defn confirm-merge!
|
||||
"Open the branching merge dialog for the pull request's branch:
|
||||
accepting a pull request goes through the exact same integration flow
|
||||
"Open the branching merge dialog for the branch review's branch:
|
||||
accepting a branch review goes through the exact same integration flow
|
||||
(confirmation, conflict resolution, safety snapshot) as merging the
|
||||
branch directly. Merging always integrates the LIVE branch state, so
|
||||
an outdated pull request merges the newest changes, not the snapshot."
|
||||
branch directly. Merging integrates the live branch, the same state
|
||||
the reviewers see."
|
||||
[pr]
|
||||
(modal/show! :merge-branch {:branch (pr->branch pr)}))
|
||||
|
||||
(defn confirm-close!
|
||||
"Ask for confirmation before cancelling a pull request: the review is
|
||||
discarded and the branch simply goes back to being a normal branch
|
||||
(it is NOT deleted)."
|
||||
"Ask for confirmation before closing a branch review: the review ends
|
||||
and the branch simply goes back to being a normal branch (it is NOT
|
||||
deleted)."
|
||||
[pr]
|
||||
(st/emit! (modal/show {:type :confirm
|
||||
:title (tr "workspace.pull-requests.close.title")
|
||||
:message (tr "workspace.pull-requests.close.message" (:title pr))
|
||||
:accept-label (tr "workspace.pull-requests.actions.close")
|
||||
:title (tr "workspace.branch-review.close.title")
|
||||
:message (tr "workspace.branch-review.close.message" (:title pr))
|
||||
:accept-label (tr "workspace.branch-review.actions.close")
|
||||
:accept-style :danger
|
||||
:on-accept (fn [_] (st/emit! (dwpr/close-pull-request (:id pr))))})))
|
||||
:on-accept (fn [_] (st/emit! (dwbr/close-branch-review (:id pr))))})))
|
||||
|
||||
;; --- The action of a banner
|
||||
|
||||
@ -144,7 +213,7 @@
|
||||
;; --- Dialog header
|
||||
|
||||
(mf/defc dialog-header*
|
||||
"The header the branch and pull request dialogs share: an icon tile,
|
||||
"The header the branch and branch review dialogs share: an icon tile,
|
||||
the title and a subtitle (a plain string, or any element), then
|
||||
whatever the dialog adds after them, such as a status chip. The close
|
||||
button belongs to `modal*`."
|
||||
@ -175,11 +244,11 @@
|
||||
(when-not open?
|
||||
(on-close))))
|
||||
|
||||
;; --- Create pull request dialog (modal)
|
||||
;; --- Create branch review dialog (modal)
|
||||
|
||||
(mf/defc create-pull-request-dialog*
|
||||
(mf/defc create-branch-review-dialog*
|
||||
{::mf/register modal/components
|
||||
::mf/register-as :create-pull-request}
|
||||
::mf/register-as :create-branch-review}
|
||||
[{:keys [branch]}]
|
||||
(let [profile (mf/deref refs/profile)
|
||||
team (mf/deref refs/team)
|
||||
@ -218,7 +287,7 @@
|
||||
(mf/deps branch title description selected valid?)
|
||||
(fn [_]
|
||||
(when valid?
|
||||
(st/emit! (dwpr/create-pull-request
|
||||
(st/emit! (dwbr/create-branch-review
|
||||
(:id branch)
|
||||
{:title (str/trim title)
|
||||
:description (str/trim description)
|
||||
@ -233,32 +302,32 @@
|
||||
:on-open-change (on-dismiss on-close)
|
||||
:size "large"}
|
||||
[:> dialog-header* {:icon i/git-pull-request-create-arrow
|
||||
:title (tr "workspace.pull-requests.create.title")
|
||||
:subtitle (tr "workspace.pull-requests.create.subtitle" (or (:name branch) ""))}]
|
||||
:title (tr "workspace.branch-review.create.title")
|
||||
:subtitle (tr "workspace.branch-review.create.subtitle" (or (:name branch) ""))}]
|
||||
|
||||
[:> modal-content* {:class (stl/css :dialog-content)}
|
||||
[:> input* {:label (tr "workspace.pull-requests.create.name-label")
|
||||
[:> input* {:label (tr "workspace.branch-review.create.name-label")
|
||||
:icon i/git-pull-request-arrow
|
||||
:placeholder (tr "workspace.pull-requests.create.name-placeholder")
|
||||
:placeholder (tr "workspace.branch-review.create.name-placeholder")
|
||||
:value title
|
||||
:on-change on-title-change}]
|
||||
|
||||
[:div {:class (stl/css :field)}
|
||||
[:label {:class (stl/css :field-label) :for desc-id}
|
||||
(tr "workspace.pull-requests.create.description-label")]
|
||||
(tr "workspace.branch-review.create.description-label")]
|
||||
[:> textarea* {:id desc-id
|
||||
:class (stl/css :field-textarea)
|
||||
:value description
|
||||
:placeholder (tr "workspace.pull-requests.create.description-placeholder")
|
||||
:placeholder (tr "workspace.branch-review.create.description-placeholder")
|
||||
:on-change on-description-change
|
||||
:rows 3}]]
|
||||
|
||||
[:div {:class (stl/css :field)}
|
||||
[:label {:class (stl/css :field-label)}
|
||||
(tr "workspace.pull-requests.create.reviewers-label")]
|
||||
(tr "workspace.branch-review.create.reviewers-label")]
|
||||
(if (empty? members)
|
||||
[:span {:class (stl/css :reviewers-empty)}
|
||||
(tr "workspace.pull-requests.create.no-members")]
|
||||
(tr "workspace.branch-review.create.no-members")]
|
||||
[:ul {:class (stl/css :reviewers-list)}
|
||||
(for [member members]
|
||||
[:li {:key (dm/str (:id member))}
|
||||
@ -276,7 +345,7 @@
|
||||
[:> 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")]]
|
||||
(tr "workspace.branch-review.create.info")]]
|
||||
|
||||
[:> modal-footer* {:class (stl/css :dialog-footer)}
|
||||
[:> button* {:class (stl/css :dialog-action)
|
||||
@ -287,105 +356,120 @@
|
||||
:icon i/git-pull-request-create-arrow
|
||||
:disabled (not valid?)
|
||||
:on-click on-submit}
|
||||
(tr "workspace.pull-requests.create.submit")]]]))
|
||||
(tr "workspace.branch-review.create.submit")]]]))
|
||||
|
||||
;; --- Review dialog (approve / request changes)
|
||||
|
||||
(mf/defc pull-request-review-dialog*
|
||||
(mf/defc branch-review-verdict-dialog*
|
||||
"The verdict of a reviewer: Approve or Request changes. Without a
|
||||
comment, each button submits its verdict at once. Once the reviewer
|
||||
adds a comment, the buttons pick the verdict and Send submits both."
|
||||
{::mf/register modal/components
|
||||
::mf/register-as :pull-request-review}
|
||||
::mf/register-as :branch-review-verdict}
|
||||
[{:keys [pr]}]
|
||||
(let [comment-id (mf/use-id)
|
||||
verdict* (mf/use-state "approved")
|
||||
verdict (deref verdict*)
|
||||
comment* (mf/use-state "")
|
||||
comment (deref comment*)
|
||||
(let [comment-id (mf/use-id)
|
||||
commenting* (mf/use-state false)
|
||||
commenting? (deref commenting*)
|
||||
verdict* (mf/use-state nil)
|
||||
verdict (deref verdict*)
|
||||
comment* (mf/use-state "")
|
||||
comment (deref comment*)
|
||||
|
||||
submit
|
||||
(mf/use-fn
|
||||
(mf/deps pr comment)
|
||||
(fn [verdict]
|
||||
(st/emit! (dwbr/submit-review (:id pr) verdict
|
||||
(let [c (str/trim comment)]
|
||||
(when-not (str/blank? c) c)))
|
||||
(modal/hide))))
|
||||
|
||||
on-comment-change
|
||||
(mf/use-fn #(reset! comment* (dom/get-target-val %)))
|
||||
|
||||
on-select-verdict
|
||||
on-add-comment
|
||||
(mf/use-fn #(reset! commenting* true))
|
||||
|
||||
on-verdict
|
||||
(mf/use-fn
|
||||
(mf/deps commenting? submit)
|
||||
(fn [event]
|
||||
(reset! verdict* (-> (dom/get-current-target event)
|
||||
(dom/get-data "verdict")))))
|
||||
(let [verdict (-> (dom/get-current-target event)
|
||||
(dom/get-data "verdict"))]
|
||||
(if commenting?
|
||||
(reset! verdict* verdict)
|
||||
(submit verdict)))))
|
||||
|
||||
on-send
|
||||
(mf/use-fn
|
||||
(mf/deps verdict submit)
|
||||
(fn [_]
|
||||
(when (some? verdict)
|
||||
(submit verdict))))
|
||||
|
||||
on-close
|
||||
(mf/use-fn #(st/emit! (modal/hide)))
|
||||
|
||||
on-submit
|
||||
(mf/use-fn
|
||||
(mf/deps pr verdict comment)
|
||||
(fn [_]
|
||||
(st/emit! (dwpr/submit-review (:id pr) verdict
|
||||
(let [c (str/trim comment)]
|
||||
(when-not (str/blank? c) c)))
|
||||
(modal/hide))))]
|
||||
(mf/use-fn #(st/emit! (modal/hide)))]
|
||||
|
||||
[:> modal* {:is-open true
|
||||
:on-open-change (on-dismiss on-close)
|
||||
:size "large"}
|
||||
[:> dialog-header* {:icon i/git-pull-request-arrow
|
||||
:title (tr "workspace.pull-requests.review.title")
|
||||
:subtitle (:title pr)}]
|
||||
:title (:title pr)
|
||||
:subtitle (tr "workspace.review.route" (:branch-name pr)
|
||||
(rvc/route-target pr (tr "workspace.branches.main")))}]
|
||||
|
||||
[:> modal-content* {:class (stl/css :dialog-content)}
|
||||
;; one of two, each with a hint the DS radio buttons have no room for
|
||||
[:div {:class (stl/css :verdict-options)
|
||||
:role "radiogroup"
|
||||
:aria-label (tr "workspace.pull-requests.review.title")}
|
||||
[:button {:class (stl/css-case :verdict-option true
|
||||
:is-selected (= verdict "approved"))
|
||||
:role "radio"
|
||||
:aria-checked (= verdict "approved")
|
||||
:data-verdict "approved"
|
||||
:on-click on-select-verdict}
|
||||
[:> i/icon* {:icon-id i/tick}]
|
||||
[:div {:class (stl/css :verdict-option-text)}
|
||||
[:span {:class (stl/css :verdict-option-title)}
|
||||
(tr "workspace.pull-requests.review.approve")]
|
||||
[:span {:class (stl/css :verdict-option-hint)}
|
||||
(tr "workspace.pull-requests.review.approve-hint")]]]
|
||||
;; with a comment the buttons only pick the verdict, so they say
|
||||
;; which one is picked
|
||||
[:div {:class (stl/css :verdict-buttons)}
|
||||
[:> button* {:variant (if (= verdict "approved") "primary" "secondary")
|
||||
:icon i/tick
|
||||
:aria-pressed (when commenting? (= verdict "approved"))
|
||||
:data-verdict "approved"
|
||||
:on-click on-verdict}
|
||||
(tr "workspace.branch-review.review.approve")]
|
||||
[:> button* {:variant (if (= verdict "changes-requested") "primary" "secondary")
|
||||
:icon i/triangle-alert
|
||||
:aria-pressed (when commenting? (= verdict "changes-requested"))
|
||||
:data-verdict "changes-requested"
|
||||
:on-click on-verdict}
|
||||
(tr "workspace.branch-review.review.request-changes")]]
|
||||
|
||||
[:button {:class (stl/css-case :verdict-option true
|
||||
:is-selected (= verdict "changes-requested"))
|
||||
:role "radio"
|
||||
:aria-checked (= verdict "changes-requested")
|
||||
:data-verdict "changes-requested"
|
||||
:on-click on-select-verdict}
|
||||
[:> i/icon* {:icon-id i/triangle-alert}]
|
||||
[:div {:class (stl/css :verdict-option-text)}
|
||||
[:span {:class (stl/css :verdict-option-title)}
|
||||
(tr "workspace.pull-requests.review.request-changes")]
|
||||
[:span {:class (stl/css :verdict-option-hint)}
|
||||
(tr "workspace.pull-requests.review.request-changes-hint")]]]]
|
||||
|
||||
[:div {:class (stl/css :field)}
|
||||
[:label {:class (stl/css :field-label) :for comment-id}
|
||||
(tr "workspace.pull-requests.review.comment-label")]
|
||||
[:> textarea* {:id comment-id
|
||||
:class (stl/css :field-textarea)
|
||||
:value comment
|
||||
:placeholder (tr "workspace.pull-requests.review.comment-placeholder")
|
||||
:on-change on-comment-change
|
||||
:rows 3}]]]
|
||||
(if commenting?
|
||||
[:div {:class (stl/css :field)}
|
||||
[:label {:class (stl/css :field-label) :for comment-id}
|
||||
(tr "workspace.branch-review.review.comment-label")]
|
||||
[:> textarea* {:id comment-id
|
||||
:class (stl/css :field-textarea)
|
||||
:value comment
|
||||
:placeholder (tr "workspace.branch-review.review.comment-placeholder")
|
||||
:on-change on-comment-change
|
||||
:rows 3}]]
|
||||
[:> button* {:class (stl/css :add-comment)
|
||||
:variant "ghost"
|
||||
:icon i/add
|
||||
:on-click on-add-comment}
|
||||
(tr "workspace.branch-review.review.add-comment")])]
|
||||
|
||||
[:> modal-footer* {:class (stl/css :dialog-footer)}
|
||||
[:> button* {:class (stl/css :dialog-action)
|
||||
:variant "secondary" :on-click on-close}
|
||||
(tr "labels.cancel")]
|
||||
[:> button* {:class (stl/css :dialog-action)
|
||||
:variant "primary"
|
||||
:on-click on-submit}
|
||||
(tr "workspace.pull-requests.review.submit")]]]))
|
||||
(when commenting?
|
||||
[:> button* {:class (stl/css :dialog-action)
|
||||
:variant "primary"
|
||||
:disabled (nil? verdict)
|
||||
:on-click on-send}
|
||||
(tr "workspace.branch-review.review.send")])]]))
|
||||
|
||||
;; --- Details dialog
|
||||
|
||||
(mf/defc pull-request-info-dialog*
|
||||
(mf/defc branch-review-info-dialog*
|
||||
{::mf/register modal/components
|
||||
::mf/register-as :pull-request-info}
|
||||
::mf/register-as :branch-review-info}
|
||||
[{:keys [pr]}]
|
||||
(let [profiles (mf/deref refs/profiles)
|
||||
(let [pr (use-live-verdicts pr)
|
||||
profiles (mf/deref refs/profiles)
|
||||
profile (mf/deref refs/profile)
|
||||
team (mf/deref refs/team)
|
||||
author (get profiles (:created-by pr))
|
||||
@ -394,10 +478,10 @@
|
||||
can-merge? (boolean (get-in team [:permissions :can-edit]))
|
||||
open? (= "open" (:status pr))
|
||||
closed? (= "closed" (:status pr))
|
||||
;; already inside this pull request's review sandbox: offering to
|
||||
;; already inside this branch review's review sandbox: offering to
|
||||
;; open it again would be a no-op
|
||||
reviewing? (= (:id pr)
|
||||
(:pr-id (mf/deref refs/pull-request-preview)))
|
||||
(:pr-id (mf/deref refs/branch-review-preview)))
|
||||
[approvals total] (current-approvals pr)
|
||||
|
||||
on-close
|
||||
@ -415,7 +499,7 @@
|
||||
(mf/deps pr)
|
||||
(fn [_]
|
||||
(st/emit! (modal/hide)
|
||||
(dwpr/open-pull-request pr))))
|
||||
(dwbr/open-branch-review pr))))
|
||||
|
||||
on-close-pr
|
||||
(mf/use-fn
|
||||
@ -429,7 +513,7 @@
|
||||
(mf/deps pr)
|
||||
(fn [_]
|
||||
(st/emit! (modal/hide)
|
||||
(dwpr/reopen-pull-request (:id pr)))))]
|
||||
(dwbr/reopen-branch-review (:id pr)))))]
|
||||
|
||||
[:> modal* {:is-open true
|
||||
:on-open-change (on-dismiss on-close)
|
||||
@ -440,7 +524,7 @@
|
||||
:subtitle
|
||||
(mf/html
|
||||
[:div {:class (stl/css :dialog-subtitle-row)}
|
||||
[:> pr-state-badge* {:pr pr}]
|
||||
[:> review-state-badge* {:pr pr}]
|
||||
[:> text* {:as "span"
|
||||
:typography t/body-small
|
||||
:class (stl/css :dialog-subtitle)}
|
||||
@ -449,41 +533,33 @@
|
||||
;; itself, and the target's name for a branch of a branch
|
||||
(tr "workspace.review.route" (:branch-name pr)
|
||||
(rvc/route-target pr (tr "workspace.branches.main")))]
|
||||
(when (and open? (:outdated pr))
|
||||
[:span {:class (stl/css :pr-badge :badge-outdated)}
|
||||
(tr "workspace.pull-requests.badge.outdated")])
|
||||
(when (and open? (pos? (or (:conflicts pr) 0)))
|
||||
[:span {:class (stl/css :pr-badge :badge-conflicts)}
|
||||
(tr "workspace.pull-requests.badge.conflicts" (dm/str (:conflicts pr)))])])}]
|
||||
(tr "workspace.branch-review.badge.conflicts" (dm/str (:conflicts pr)))])])}]
|
||||
|
||||
[:> modal-content* {:class (stl/css :dialog-content)}
|
||||
[:div {:class (stl/css :pr-info-card)}
|
||||
[:div {:class (stl/css :pr-info-grid)}
|
||||
[:div {:class (stl/css :pr-info-item)}
|
||||
[:span {:class (stl/css :field-label)} (tr "workspace.pull-requests.info.author")]
|
||||
[:span {:class (stl/css :field-label)} (tr "workspace.branch-review.info.author")]
|
||||
[:div {:class (stl/css :pr-info-value)}
|
||||
(when author [:> avatar* {:profile author :variant "S"}])
|
||||
[:span (get author :fullname "—")]]]
|
||||
|
||||
[:div {:class (stl/css :pr-info-item)}
|
||||
[:span {:class (stl/css :field-label)} (tr "workspace.pull-requests.info.created-at")]
|
||||
[:span {:class (stl/css :field-label)} (tr "workspace.branch-review.info.created-at")]
|
||||
[:div {:class (stl/css :pr-info-value)}
|
||||
[:span (ct/format-inst (:created-at pr) :localized-date-time)]]]
|
||||
|
||||
[:div {:class (stl/css :pr-info-item)}
|
||||
[:span {:class (stl/css :field-label)} (tr "workspace.pull-requests.info.updated-at")]
|
||||
[:div {:class (stl/css :pr-info-value)}
|
||||
[:span (ct/format-inst (:pinned-at pr) :localized-date-time)]]]
|
||||
|
||||
[:div {:class (stl/css :pr-info-item)}
|
||||
[:span {:class (stl/css :field-label)} (tr "workspace.pull-requests.info.approvals")]
|
||||
[:span {:class (stl/css :field-label)} (tr "workspace.branch-review.info.approvals")]
|
||||
[:div {:class (stl/css :pr-info-value)}
|
||||
[:span (dm/str approvals "/" total)]]]]
|
||||
|
||||
(when (pos? total)
|
||||
[:div {:class (stl/css :field)}
|
||||
[:label {:class (stl/css :field-label)}
|
||||
(tr "workspace.pull-requests.info.reviewers")]
|
||||
(tr "workspace.branch-review.info.reviewers")]
|
||||
[:ul {:class (stl/css :pr-info-reviewers)}
|
||||
(for [review (:reviews pr)]
|
||||
(let [reviewer (get profiles (:profile-id review))]
|
||||
@ -498,18 +574,7 @@
|
||||
:reviewer-changes (and (= "changes-requested" (:verdict review))
|
||||
(not (:stale review)))
|
||||
:reviewer-stale (:stale review))}
|
||||
(cond
|
||||
(:stale review)
|
||||
(tr "workspace.pull-requests.review-state.stale")
|
||||
|
||||
(= "approved" (:verdict review))
|
||||
(tr "workspace.pull-requests.review-state.approved")
|
||||
|
||||
(= "changes-requested" (:verdict review))
|
||||
(tr "workspace.pull-requests.review-state.changes-requested")
|
||||
|
||||
:else
|
||||
(tr "workspace.pull-requests.review-state.pending"))]
|
||||
(verdict-label review)]
|
||||
(when-not (str/blank? (:comment review))
|
||||
[:> text* {:as "p" :typography t/body-small :class (stl/css :reviewer-comment)}
|
||||
(:comment review)])]))]])]
|
||||
@ -517,7 +582,7 @@
|
||||
(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")]
|
||||
(tr "workspace.branch-review.info.description")]
|
||||
[:> text* {:as "p" :typography t/body-medium :class (stl/css :pr-info-description)}
|
||||
(:description pr)]])]
|
||||
|
||||
@ -526,26 +591,26 @@
|
||||
[:> button* {:class (stl/css :dialog-action)
|
||||
:variant "secondary"
|
||||
:on-click on-close-pr}
|
||||
(tr "workspace.pull-requests.actions.close")])
|
||||
(tr "workspace.branch-review.actions.close")])
|
||||
(when (and (or author? admin?) closed?)
|
||||
[:> button* {:class (stl/css :dialog-action)
|
||||
:variant "secondary"
|
||||
:on-click on-reopen-pr}
|
||||
(tr "workspace.pull-requests.actions.reopen")])
|
||||
(tr "workspace.branch-review.actions.reopen")])
|
||||
(when (and open? (not reviewing?))
|
||||
[:> 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")])
|
||||
(tr "workspace.branch-review.actions.open-review")])
|
||||
(when (and open? can-merge?)
|
||||
[:> button* {:class (stl/css :dialog-action)
|
||||
:variant "primary"
|
||||
:icon i/git-merge
|
||||
:on-click on-merge}
|
||||
(tr "workspace.pull-requests.actions.merge")])]]))
|
||||
(tr "workspace.branch-review.actions.merge")])]]))
|
||||
|
||||
;; --- Review bar (replaces the branch banner inside a design review)
|
||||
;; --- Review bar (replaces the branch banner inside a branch review)
|
||||
|
||||
(mf/defc compare-banner-content*
|
||||
"What the review bar says and offers while the branch of the review is
|
||||
@ -608,17 +673,13 @@
|
||||
rulers (if rulers? 22 0)]
|
||||
(+ left rulers (/ (- (:width vport) rulers) 2))))
|
||||
|
||||
(mf/defc pr-review-banner*
|
||||
"The bar at the bottom of the canvas inside a design review: the review
|
||||
(mf/defc review-banner*
|
||||
"The bar at the bottom of the canvas inside a branch 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."
|
||||
the reviewer and the way out. Merging and closing the review sit behind
|
||||
the menu."
|
||||
[]
|
||||
(let [preview (mf/deref refs/pull-request-preview)
|
||||
(let [preview (mf/deref refs/branch-review-preview)
|
||||
vport (mf/deref refs/workspace-vport)
|
||||
rulers? (mf/deref refs/rulers?)
|
||||
pr (:info preview)
|
||||
@ -629,9 +690,8 @@
|
||||
author? (= (:created-by pr) (:id profile))
|
||||
reviewer? (some #(= (:profile-id %) (:id profile)) (:reviews pr))
|
||||
can-merge? (boolean (get-in team [:permissions :can-edit]))
|
||||
can-cancel? (and (or author? (boolean (get-in team [:permissions :is-admin])))
|
||||
(= "open" (:status pr)))
|
||||
outdated? (boolean (:outdated pr))
|
||||
can-close? (and (or author? (boolean (get-in team [:permissions :is-admin])))
|
||||
(= "open" (:status pr)))
|
||||
|
||||
tasks (mf/with-memo [tasks* pr]
|
||||
(filterv #(= (:id pr) (:review-id %)) (vals tasks*)))
|
||||
@ -650,15 +710,10 @@
|
||||
(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}))
|
||||
(mf/use-fn (mf/deps pr) #(modal/show! :branch-review-verdict {:pr pr}))
|
||||
|
||||
on-exit
|
||||
(mf/use-fn #(st/emit! (dwpr/exit-pull-request-preview)))
|
||||
|
||||
on-publish
|
||||
(mf/use-fn
|
||||
(mf/deps pr)
|
||||
#(st/emit! (dwpr/update-pull-request-snapshot (:id pr))))
|
||||
(mf/use-fn #(st/emit! (dwbr/exit-branch-review-preview)))
|
||||
|
||||
on-menu-action
|
||||
(mf/use-fn
|
||||
@ -668,7 +723,7 @@
|
||||
(case action
|
||||
"compare" (open-compare! pr)
|
||||
"merge" (confirm-merge! pr)
|
||||
"cancel" (confirm-close! pr)
|
||||
"close" (confirm-close! pr)
|
||||
nil)))]
|
||||
|
||||
(when (some? pr)
|
||||
@ -686,15 +741,9 @@
|
||||
[:> i/icon* {:icon-id i/git-pull-request-arrow}]]
|
||||
[:div {:class (stl/css :pr-banner-text)}
|
||||
[:span {:class (stl/css :pr-banner-title)}
|
||||
(tr "workspace.pull-requests.banner.reviewing")]
|
||||
(tr "workspace.branch-review.banner.reviewing")]
|
||||
;; cut short when it is long: the whole of it on hover
|
||||
[:span {:class (stl/css :pr-banner-name) :title (:title pr)} (:title pr)]
|
||||
;; the author publishes them with the button instead
|
||||
(when (and outdated? (not author?))
|
||||
[:> tooltip* {:content (tr "workspace.pull-requests.badge.outdated-hint")
|
||||
:placement "top"}
|
||||
[:span {:class (stl/css :pr-badge :badge-outdated)}
|
||||
(tr "workspace.pull-requests.badge.outdated")]])]
|
||||
[:span {:class (stl/css :pr-banner-name) :title (:title pr)} (:title pr)]]
|
||||
|
||||
[:div {:class (stl/css :pr-banner-separator)}]
|
||||
|
||||
@ -710,17 +759,12 @@
|
||||
[:div {:class (stl/css :pr-banner-actions)}
|
||||
[:> button* {:variant "secondary" :on-click on-details}
|
||||
(tr "workspace.review.bar.details")]
|
||||
(when (and outdated? author?)
|
||||
[:> tooltip* {:content (tr "workspace.pull-requests.banner.publish-hint")
|
||||
:placement "top"}
|
||||
[:> button* {:variant "primary" :on-click on-publish}
|
||||
(tr "workspace.pull-requests.banner.publish")]])
|
||||
(when reviewer?
|
||||
[:> button* {:variant "primary" :on-click on-review}
|
||||
(tr "workspace.review.submit")])
|
||||
[:> icon-button* {:variant "ghost"
|
||||
:icon i/exit
|
||||
:aria-label (tr "workspace.pull-requests.banner.exit")
|
||||
:aria-label (tr "workspace.branch-review.banner.exit")
|
||||
:tooltip-placement "top"
|
||||
:on-click on-exit}]
|
||||
|
||||
@ -741,7 +785,7 @@
|
||||
(tr "workspace.branches.compare")]
|
||||
(when can-merge?
|
||||
[:> menu-item* {:id "merge"}
|
||||
(tr "workspace.pull-requests.actions.merge")])
|
||||
(when can-cancel?
|
||||
[:> menu-item* {:id "cancel"}
|
||||
(tr "workspace.pull-requests.banner.cancel")])]]]])])))
|
||||
(tr "workspace.branch-review.actions.merge")])
|
||||
(when can-close?
|
||||
[:> menu-item* {:id "close"}
|
||||
(tr "workspace.branch-review.actions.close")])]]]])])))
|
||||
@ -34,8 +34,7 @@
|
||||
--pr-badge-fg-color: var(--color-accent-success);
|
||||
}
|
||||
|
||||
.badge-changes,
|
||||
.badge-outdated {
|
||||
.badge-changes {
|
||||
--pr-badge-bg-color: var(--color-background-warning);
|
||||
--pr-badge-fg-color: var(--color-accent-warning);
|
||||
}
|
||||
@ -192,58 +191,20 @@
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
// --- Review dialog (verdict options)
|
||||
// --- Review dialog (verdict buttons)
|
||||
|
||||
.verdict-options {
|
||||
.verdict-buttons {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--sp-s);
|
||||
}
|
||||
|
||||
.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(--verdict-option-border-color);
|
||||
border-radius: $br-8;
|
||||
background: var(--verdict-option-bg-color);
|
||||
cursor: pointer;
|
||||
text-align: start;
|
||||
color: var(--color-foreground-primary);
|
||||
|
||||
&:hover {
|
||||
--verdict-option-bg-color: var(--color-background-tertiary);
|
||||
}
|
||||
|
||||
&.is-selected {
|
||||
--verdict-option-bg-color: var(--color-background-tertiary);
|
||||
--verdict-option-border-color: var(--color-accent-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.verdict-option-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--sp-xxs);
|
||||
}
|
||||
|
||||
.verdict-option-title {
|
||||
@include use-typography("body-medium");
|
||||
}
|
||||
|
||||
.verdict-option-hint {
|
||||
@include use-typography("body-small");
|
||||
|
||||
color: var(--color-foreground-secondary);
|
||||
.add-comment {
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
// --- Details dialog
|
||||
|
||||
// the pull request metadata (author / dates / approvals / reviewers)
|
||||
// the branch review metadata (author / dates / approvals / reviewers)
|
||||
// gets its own card, visually separated from the free-text description
|
||||
// (same surface treatment as the reviewer rows and the create dialog's
|
||||
// "derived from" box: tertiary background + $br-8 radius)
|
||||
@ -11,11 +11,11 @@
|
||||
[app.common.time :as ct]
|
||||
[app.config :as cf]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.workspace.branch-reviews :as dwbr]
|
||||
[app.main.data.workspace.branches :as dwb]
|
||||
[app.main.data.workspace.compare :as dwcp]
|
||||
[app.main.data.workspace.drawing :as dwd]
|
||||
[app.main.data.workspace.layout :as dwlo]
|
||||
[app.main.data.workspace.pull-requests :as dwpr]
|
||||
[app.main.data.workspace.review :as dwrv]
|
||||
[app.main.data.workspace.tasks :as dwtk]
|
||||
[app.main.refs :as refs]
|
||||
@ -37,8 +37,8 @@
|
||||
[app.main.ui.ds.tooltip :refer [tooltip*]]
|
||||
[app.main.ui.workspace.compare.common :as cc]
|
||||
[app.main.ui.workspace.review.tasks :as rvt]
|
||||
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.pull-requests :as prui :refer [pr-state-badge*]]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-reviews :as brui :refer [review-state-badge*]]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.globals :as globals]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
@ -89,8 +89,8 @@
|
||||
(modal/hide)))))]
|
||||
|
||||
[:> modal* {:is-open true
|
||||
:on-open-change (prui/on-dismiss on-close)}
|
||||
[:> prui/dialog-header* {:icon i/git-branch
|
||||
:on-open-change (brui/on-dismiss on-close)}
|
||||
[:> brui/dialog-header* {:icon i/git-branch
|
||||
:title (tr "workspace.branches.create.title")}]
|
||||
|
||||
[:> modal-content* {:class (stl/css :dialog-content)}
|
||||
@ -170,8 +170,8 @@
|
||||
(on-submit event))))]
|
||||
|
||||
[:> modal* {:is-open true
|
||||
:on-open-change (prui/on-dismiss on-close)}
|
||||
[:> prui/dialog-header* {:icon i/git-branch
|
||||
:on-open-change (brui/on-dismiss on-close)}
|
||||
[:> brui/dialog-header* {:icon i/git-branch
|
||||
:title (tr "workspace.branches.rename.title")
|
||||
:subtitle (:name branch)}]
|
||||
|
||||
@ -224,8 +224,8 @@
|
||||
(st/emit! (dwb/fetch-branching-limits)))
|
||||
|
||||
[:> modal* {:is-open true
|
||||
:on-open-change (prui/on-dismiss on-close)}
|
||||
[:> prui/dialog-header* {:icon i/git-branch
|
||||
:on-open-change (brui/on-dismiss on-close)}
|
||||
[:> brui/dialog-header* {:icon i/git-branch
|
||||
:title (tr "workspace.branches.limits.title")
|
||||
:subtitle (tr "workspace.branches.limits.subtitle")}]
|
||||
|
||||
@ -329,7 +329,7 @@
|
||||
(fn [_] (reset! tasks* [])))))))
|
||||
|
||||
[:> modal* {:is-open true
|
||||
:on-open-change (prui/on-dismiss on-close)}
|
||||
:on-open-change (brui/on-dismiss on-close)}
|
||||
[:> modal-header* {:title (tr "workspace.branches.merge.confirm-title")}]
|
||||
|
||||
[:> modal-content* {:class (stl/css :dialog-content)}
|
||||
@ -499,8 +499,8 @@
|
||||
on-materialize (mf/use-fn (mf/deps branch)
|
||||
#(confirm-materialize! branch))]
|
||||
[:> modal* {:is-open true
|
||||
:on-open-change (prui/on-dismiss on-close)}
|
||||
[:> prui/dialog-header* {:icon i/git-branch
|
||||
:on-open-change (brui/on-dismiss on-close)}
|
||||
[:> brui/dialog-header* {:icon i/git-branch
|
||||
:title (tr "workspace.branches.info.title")
|
||||
:subtitle (:name branch)}
|
||||
[:span {:class (stl/css-case :info-status true
|
||||
@ -622,7 +622,8 @@
|
||||
(mf/defc branch-entry*
|
||||
{::mf/private true}
|
||||
[{:keys [entry profiles current pr menu-open? on-set-menu]}]
|
||||
(let [author (get profiles (:created-by entry))
|
||||
(let [pr (brui/use-live-verdicts pr)
|
||||
author (get profiles (:created-by entry))
|
||||
ahead (:ahead entry)
|
||||
behind (:behind entry)
|
||||
main? (:is-main entry)
|
||||
@ -632,7 +633,7 @@
|
||||
;; branch work, and dimmed in the list
|
||||
closed? (or merged? archived?)
|
||||
|
||||
;; `pr` is the branch's open pull request (nil when none): the
|
||||
;; `pr` is the branch's open branch review (nil when none): the
|
||||
;; review is a STATE of the branch, so the entry surfaces it as a
|
||||
;; badge and swaps "Request review" for the review actions
|
||||
profile (mf/deref refs/profile)
|
||||
@ -641,7 +642,7 @@
|
||||
admin? (boolean (get-in team [:permissions :is-admin]))
|
||||
can-merge? (boolean (get-in team [:permissions :can-edit]))
|
||||
|
||||
[approvals total] (if pr (prui/current-approvals pr) [0 0])
|
||||
[approvals total] (if pr (brui/current-approvals pr) [0 0])
|
||||
|
||||
editing? (mf/use-state false)
|
||||
|
||||
@ -694,7 +695,7 @@
|
||||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
(on-set-menu false)
|
||||
(modal/show! :create-pull-request {:branch entry})))
|
||||
(modal/show! :create-branch-review {:branch entry})))
|
||||
|
||||
on-open-review
|
||||
(mf/use-fn
|
||||
@ -702,7 +703,7 @@
|
||||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
(on-set-menu false)
|
||||
(st/emit! (dwpr/open-pull-request pr))))
|
||||
(st/emit! (dwbr/open-branch-review pr))))
|
||||
|
||||
on-review-details
|
||||
(mf/use-fn
|
||||
@ -710,15 +711,7 @@
|
||||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
(on-set-menu false)
|
||||
(modal/show! :pull-request-info {:pr pr})))
|
||||
|
||||
on-publish-review
|
||||
(mf/use-fn
|
||||
(mf/deps pr)
|
||||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
(on-set-menu false)
|
||||
(st/emit! (dwpr/update-pull-request-snapshot (:id pr)))))
|
||||
(modal/show! :branch-review-info {:pr pr})))
|
||||
|
||||
on-merge-review
|
||||
(mf/use-fn
|
||||
@ -728,13 +721,13 @@
|
||||
(on-set-menu false)
|
||||
(brc/confirm-merge! entry)))
|
||||
|
||||
on-cancel-review
|
||||
on-close-review
|
||||
(mf/use-fn
|
||||
(mf/deps pr)
|
||||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
(on-set-menu false)
|
||||
(prui/confirm-close! pr)))
|
||||
(brui/confirm-close! pr)))
|
||||
|
||||
on-rename-commit
|
||||
(mf/use-fn
|
||||
@ -809,10 +802,10 @@
|
||||
(when (some? pr)
|
||||
[:div {:class (stl/css :branch-entry-badges)}
|
||||
[:> i/icon* {:icon-id i/git-pull-request-arrow :size "s"}]
|
||||
[:> pr-state-badge* {:pr pr}]
|
||||
[:> review-state-badge* {:pr pr}]
|
||||
(when (pos? total)
|
||||
[:span {:class (stl/css :branch-pr-approvals)
|
||||
:title (tr "workspace.pull-requests.info.approvals")}
|
||||
:title (tr "workspace.branch-review.info.approvals")}
|
||||
[:> i/icon* {:icon-id i/tick :size "s"}]
|
||||
(dm/str approvals "/" total)])])]
|
||||
|
||||
@ -862,28 +855,25 @@
|
||||
(when (and (not closed?) (pos? (or behind 0)))
|
||||
[:> menu-item* {:id "update" :on-action on-update}
|
||||
(tr "workspace.branches.update")])
|
||||
;; review lifecycle: a branch without an open pull request offers to
|
||||
;; review lifecycle: a branch without an open branch review offers to
|
||||
;; request one; with it, the review actions take its place (the
|
||||
;; review either ends merging the branch or is cancelled, leaving
|
||||
;; review either ends merging the branch or is closed, leaving
|
||||
;; the branch as a normal branch again)
|
||||
(when (and (not closed?) (dwpr/enabled?) (nil? pr))
|
||||
(when (and (not closed?) (dwbr/enabled?) (nil? pr))
|
||||
[:> menu-item* {:id "request-review" :on-action on-request-review}
|
||||
(tr "workspace.pull-requests.menu.request-review")])
|
||||
(tr "workspace.branch-review.menu.request-review")])
|
||||
(when (some? pr)
|
||||
[:> menu-item* {:id "open-review" :on-action on-open-review}
|
||||
(tr "workspace.pull-requests.actions.open-review")])
|
||||
(tr "workspace.branch-review.actions.open-review")])
|
||||
(when (some? pr)
|
||||
[:> menu-item* {:id "review-details" :on-action on-review-details}
|
||||
(tr "workspace.pull-requests.menu.review-details")])
|
||||
(when (and (some? pr) author?)
|
||||
[:> menu-item* {:id "publish-review" :on-action on-publish-review}
|
||||
(tr "workspace.pull-requests.menu.publish")])
|
||||
(tr "workspace.branch-review.menu.review-details")])
|
||||
(when (and (some? pr) can-merge?)
|
||||
[:> menu-item* {:id "merge-review" :on-action on-merge-review}
|
||||
(tr "workspace.pull-requests.actions.merge")])
|
||||
(tr "workspace.branch-review.actions.merge")])
|
||||
(when (and (some? pr) (or author? admin?))
|
||||
[:> menu-item* {:id "cancel-review" :on-action on-cancel-review}
|
||||
(tr "workspace.pull-requests.actions.close")])
|
||||
[:> menu-item* {:id "close-review" :on-action on-close-review}
|
||||
(tr "workspace.branch-review.actions.close")])
|
||||
(when-not closed?
|
||||
[:> menu-item* {:id "rename" :on-action on-start-rename}
|
||||
(tr "labels.rename")])
|
||||
@ -923,7 +913,7 @@
|
||||
profile (mf/deref refs/profile)
|
||||
file (mf/deref refs/file)
|
||||
branch-ctx (mf/deref branch-context)
|
||||
prs (mf/deref refs/pull-requests)
|
||||
prs (mf/deref refs/branch-reviews)
|
||||
profile-id (:id profile)
|
||||
|
||||
profiles (cond-> profiles
|
||||
@ -931,7 +921,7 @@
|
||||
|
||||
prs-by-branch
|
||||
(mf/with-memo [prs]
|
||||
(when (dwpr/enabled?)
|
||||
(when (dwbr/enabled?)
|
||||
(->> (:data prs)
|
||||
(filter #(= "open" (:status %)))
|
||||
(map (juxt :file-branch-id identity))
|
||||
@ -1004,8 +994,8 @@
|
||||
;; place of the loading state
|
||||
(mf/with-layout-effect []
|
||||
(st/emit! (dwb/init-branches-state))
|
||||
(when (dwpr/enabled?)
|
||||
(st/emit! (dwpr/fetch-pull-requests))))
|
||||
(when (dwbr/enabled?)
|
||||
(st/emit! (dwbr/fetch-branch-reviews))))
|
||||
|
||||
[:> modal* {:is-open true
|
||||
:on-open-change on-open-change
|
||||
@ -1117,7 +1107,7 @@
|
||||
:label (tr "workspace.branches.banner.status.behind" (i18n/c behind))}
|
||||
|
||||
(some? pr)
|
||||
(let [[approvals total] (prui/current-approvals pr)]
|
||||
(let [[approvals total] (brui/current-approvals pr)]
|
||||
{:id :review
|
||||
:icon i/git-pull-request-arrow
|
||||
:label (tr "workspace.branches.banner.status.in-review"
|
||||
@ -1181,15 +1171,16 @@
|
||||
persistence (mf/deref refs/persistence)
|
||||
pstatus (:status persistence)
|
||||
|
||||
;; with pull requests enabled the merge action moves behind the
|
||||
;; with branch reviews enabled the merge action moves behind the
|
||||
;; kebab menu and requesting a review becomes the primary action
|
||||
;; (or opening the branch's already-open pull request)
|
||||
prs-enabled? (dwpr/enabled?)
|
||||
;; (or opening the branch's already-open branch review)
|
||||
prs-enabled? (dwbr/enabled?)
|
||||
open-pr (when prs-enabled?
|
||||
(->> (:data (mf/deref refs/pull-requests))
|
||||
(->> (:data (mf/deref refs/branch-reviews))
|
||||
(filter #(and (= "open" (:status %))
|
||||
(= (:id ctx) (:file-branch-id %))))
|
||||
(first)))
|
||||
open-pr (brui/use-live-verdicts open-pr)
|
||||
|
||||
profile (mf/deref refs/profile)
|
||||
team (mf/deref refs/team)
|
||||
@ -1234,12 +1225,12 @@
|
||||
on-request-review
|
||||
(mf/use-fn
|
||||
(mf/deps ctx)
|
||||
#(modal/show! :create-pull-request {:branch ctx}))
|
||||
#(modal/show! :create-branch-review {:branch ctx}))
|
||||
|
||||
on-open-review
|
||||
(mf/use-fn
|
||||
(mf/deps open-pr)
|
||||
#(st/emit! (dwpr/open-pull-request open-pr)))
|
||||
#(st/emit! (dwbr/open-branch-review open-pr)))
|
||||
|
||||
;; the same options as the branch's entry in the branch list;
|
||||
;; deleting the open branch lands on the file it comes from
|
||||
@ -1250,12 +1241,11 @@
|
||||
(case action
|
||||
"info" (modal/show! :branch-info {:branch ctx})
|
||||
"update" (brc/confirm-update! ctx)
|
||||
"request-review" (modal/show! :create-pull-request {:branch ctx})
|
||||
"open-review" (st/emit! (dwpr/open-pull-request open-pr))
|
||||
"review-details" (modal/show! :pull-request-info {:pr open-pr})
|
||||
"publish-review" (st/emit! (dwpr/update-pull-request-snapshot (:id open-pr)))
|
||||
"request-review" (modal/show! :create-branch-review {:branch ctx})
|
||||
"open-review" (st/emit! (dwbr/open-branch-review open-pr))
|
||||
"review-details" (modal/show! :branch-review-info {:pr open-pr})
|
||||
"merge" (brc/confirm-merge! ctx)
|
||||
"cancel-review" (prui/confirm-close! open-pr)
|
||||
"close-review" (brui/confirm-close! open-pr)
|
||||
"rename" (modal/show! :rename-branch {:branch ctx})
|
||||
"archive" (confirm-archive! ctx true)
|
||||
"materialize" (confirm-materialize! ctx)
|
||||
@ -1286,9 +1276,9 @@
|
||||
(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, and the bar counts the tasks for the user
|
||||
(when (dwpr/enabled?)
|
||||
(st/emit! (dwpr/fetch-pull-requests)
|
||||
;; open branch review, and the bar counts the tasks for the user
|
||||
(when (dwbr/enabled?)
|
||||
(st/emit! (dwbr/fetch-branch-reviews)
|
||||
(dwtk/fetch-tasks))))
|
||||
|
||||
;; refresh the change counts every time a save settles (and when
|
||||
@ -1313,7 +1303,7 @@
|
||||
(when ctx
|
||||
[:div {:id "branch-banner"
|
||||
:style (when (some? vport)
|
||||
#js {"insetInlineStart" (dm/str (prui/canvas-center vport rulers?) "px")})
|
||||
#js {"insetInlineStart" (dm/str (brui/canvas-center vport rulers?) "px")})
|
||||
:class (stl/css-case :branch-banner true
|
||||
:branch-banner-merged (or merged? archived?)
|
||||
:is-collapsed collapsed?)}
|
||||
@ -1339,7 +1329,7 @@
|
||||
|
||||
(when (pos? (or my-tasks 0))
|
||||
[:*
|
||||
[:> prui/banner-button* {:class (stl/css :branch-banner-tasks)
|
||||
[:> brui/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))]
|
||||
@ -1378,7 +1368,7 @@
|
||||
:on-click on-compare}
|
||||
(tr "workspace.branches.compare")]
|
||||
|
||||
;; with pull requests enabled the primary flow is asking for a
|
||||
;; with branch reviews enabled the primary flow is asking for a
|
||||
;; review (merging moves to the options menu)
|
||||
(case primary
|
||||
:resolve
|
||||
@ -1397,13 +1387,13 @@
|
||||
[:> button* {:variant "primary"
|
||||
:icon i/git-pull-request-arrow
|
||||
:on-click on-open-review}
|
||||
(tr "workspace.pull-requests.actions.open-review")]
|
||||
(tr "workspace.branch-review.actions.open-review")]
|
||||
|
||||
:request-review
|
||||
[:> button* {:variant "primary"
|
||||
:icon i/git-pull-request-create-arrow
|
||||
:on-click on-request-review}
|
||||
(tr "workspace.pull-requests.menu.request-review")]
|
||||
(tr "workspace.branch-review.menu.request-review")]
|
||||
|
||||
:merge
|
||||
[:> button* {:variant "primary"
|
||||
@ -1435,23 +1425,20 @@
|
||||
(tr "workspace.branches.update")])
|
||||
(when (and open? prs-enabled? (nil? open-pr) (not= primary :request-review))
|
||||
[:> menu-item* {:id "request-review"}
|
||||
(tr "workspace.pull-requests.menu.request-review")])
|
||||
(tr "workspace.branch-review.menu.request-review")])
|
||||
(when (and (some? open-pr) (not= primary :open-review))
|
||||
[:> menu-item* {:id "open-review"}
|
||||
(tr "workspace.pull-requests.actions.open-review")])
|
||||
(tr "workspace.branch-review.actions.open-review")])
|
||||
(when (some? open-pr)
|
||||
[:> menu-item* {:id "review-details"}
|
||||
(tr "workspace.pull-requests.menu.review-details")])
|
||||
(when pr-author?
|
||||
[:> menu-item* {:id "publish-review"}
|
||||
(tr "workspace.pull-requests.menu.publish")])
|
||||
(tr "workspace.branch-review.menu.review-details")])
|
||||
(when (and open? prs-enabled? (not= primary :merge)
|
||||
(or (nil? open-pr) can-merge?))
|
||||
[:> menu-item* {:id "merge"}
|
||||
(tr "workspace.pull-requests.actions.merge")])
|
||||
(tr "workspace.branch-review.actions.merge")])
|
||||
(when (and (some? open-pr) (or pr-author? admin?))
|
||||
[:> menu-item* {:id "cancel-review"}
|
||||
(tr "workspace.pull-requests.actions.close")])
|
||||
[:> menu-item* {:id "close-review"}
|
||||
(tr "workspace.branch-review.actions.close")])
|
||||
(when open?
|
||||
[:> menu-item* {:id "rename"}
|
||||
(tr "labels.rename")])
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
|
||||
(ns app.main.ui.workspace.sidebar.reviews
|
||||
"The reviews dialog: the merges into main, each with who made it, when
|
||||
and the comment left with it, and the design reviews (pull requests) of
|
||||
and the comment left with it, and the branch reviews of
|
||||
the file. It follows the all-branches dialog: tabs with their counts,
|
||||
a search box and one list per tab."
|
||||
(:require-macros [app.main.style :as stl])
|
||||
@ -14,8 +14,8 @@
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.time :as ct]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.workspace.branch-reviews :as dwbr]
|
||||
[app.main.data.workspace.branches :as dwb]
|
||||
[app.main.data.workspace.pull-requests :as dwpr]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.ds.buttons.button :refer [button*]]
|
||||
@ -31,7 +31,7 @@
|
||||
[app.main.ui.ds.product.avatar :refer [avatar*]]
|
||||
[app.main.ui.ds.product.branch-pill :refer [branch-pill*]]
|
||||
[app.main.ui.ds.product.empty-state :refer [empty-state*]]
|
||||
[app.main.ui.workspace.sidebar.pull-requests :as prui :refer [pr-state-badge*]]
|
||||
[app.main.ui.workspace.sidebar.branch-reviews :as brui :refer [review-state-badge*]]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :refer [tr]]
|
||||
[app.util.keyboard :as kbd]
|
||||
@ -129,7 +129,7 @@
|
||||
[:div {:class (stl/css :entry-avatar :entry-avatar-unknown)}
|
||||
[:> i/icon* {:icon-id i/user :size "s"}]]))
|
||||
|
||||
;; --- Merge reviews
|
||||
;; --- Merges
|
||||
|
||||
(mf/defc merge-entry*
|
||||
{::mf/private true}
|
||||
@ -146,7 +146,7 @@
|
||||
[:span {:class (stl/css :entry-meta-text)}
|
||||
(tr "workspace.branches.reviews.merged")]
|
||||
[:> route* {:branch-name (:branch-name merge)}]]
|
||||
;; the merge accepted a design review: name it, it may be gone by now
|
||||
;; the merge accepted a branch review: name it, it may be gone by now
|
||||
(when-let [title (:review-title merge)]
|
||||
[:div {:class (stl/css :entry-review)}
|
||||
[:> i/icon* {:icon-id i/git-pull-request-arrow :size "s"}]
|
||||
@ -157,17 +157,18 @@
|
||||
(tr "workspace.branches.reviews.no-comment")]
|
||||
[:> clamped-text* {:text (:comment merge)}])]]))
|
||||
|
||||
;; --- Design reviews
|
||||
;; --- Branch reviews
|
||||
|
||||
(mf/defc design-review-entry*
|
||||
"A design review: the entry opens it while it is open; a finished one
|
||||
"A branch review: the entry opens it while it is open; a finished one
|
||||
(merged or closed) can no longer be opened, so the entry shows its
|
||||
details instead. Its options menu shows the details of every review and
|
||||
reopens a closed one for its author or a team admin, as the details
|
||||
dialog does."
|
||||
{::mf/private true}
|
||||
[{:keys [pr profiles]}]
|
||||
(let [author (get profiles (:created-by pr))
|
||||
(let [pr (brui/use-live-verdicts pr)
|
||||
author (get profiles (:created-by pr))
|
||||
profile (mf/deref refs/profile)
|
||||
team (mf/deref refs/team)
|
||||
open? (= "open" (:status pr))
|
||||
@ -175,7 +176,7 @@
|
||||
can-reopen? (and closed?
|
||||
(or (= (:created-by pr) (:id profile))
|
||||
(boolean (get-in team [:permissions :is-admin]))))
|
||||
[approvals total] (prui/current-approvals pr)
|
||||
[approvals total] (brui/current-approvals pr)
|
||||
|
||||
;; each entry keeps its own menu state: the DS menu closes every
|
||||
;; other open menu by itself when one opens
|
||||
@ -189,8 +190,8 @@
|
||||
(mf/deps pr)
|
||||
(fn [action]
|
||||
(case action
|
||||
"details" (modal/show! :pull-request-info {:pr pr})
|
||||
"reopen" (st/emit! (dwpr/reopen-pull-request (:id pr)))
|
||||
"details" (modal/show! :branch-review-info {:pr pr})
|
||||
"reopen" (st/emit! (dwbr/reopen-branch-review (:id pr)))
|
||||
nil)))
|
||||
|
||||
on-open
|
||||
@ -199,8 +200,8 @@
|
||||
(fn [_]
|
||||
(if open?
|
||||
(st/emit! (modal/hide)
|
||||
(dwpr/open-pull-request pr))
|
||||
(modal/show! :pull-request-info {:pr pr}))))
|
||||
(dwbr/open-branch-review pr))
|
||||
(modal/show! :branch-review-info {:pr pr}))))
|
||||
|
||||
on-key-down
|
||||
(mf/use-fn
|
||||
@ -214,15 +215,15 @@
|
||||
:role "button"
|
||||
:tab-index 0
|
||||
:title (if open?
|
||||
(tr "workspace.pull-requests.actions.open-review")
|
||||
(tr "workspace.pull-requests.menu.review-details"))
|
||||
(tr "workspace.branch-review.actions.open-review")
|
||||
(tr "workspace.branch-review.menu.review-details"))
|
||||
:on-click on-open
|
||||
:on-key-down on-key-down}
|
||||
[:> author* {:profile author}]
|
||||
[:div {:class (stl/css :entry-body)}
|
||||
[:div {:class (stl/css :entry-head)}
|
||||
[:span {:class (stl/css :entry-title)} (:title pr)]
|
||||
[:> pr-state-badge* {:pr pr}]
|
||||
[:> review-state-badge* {:pr pr}]
|
||||
[:> entry-date* {:date (:created-at pr)}]]
|
||||
[:div {:class (stl/css :entry-meta)}
|
||||
[:span {:class (stl/css :entry-meta-text)}
|
||||
@ -230,7 +231,7 @@
|
||||
[:> route* {:branch-name (:branch-name pr) :is-review open?}]
|
||||
(when (pos? total)
|
||||
[:span {:class (stl/css :entry-approvals)
|
||||
:title (tr "workspace.pull-requests.info.approvals")}
|
||||
:title (tr "workspace.branch-review.info.approvals")}
|
||||
[:> i/icon* {:icon-id i/tick :size "s"}]
|
||||
(dm/str approvals "/" total)])]
|
||||
(when-not (str/blank? (:description pr))
|
||||
@ -253,10 +254,10 @@
|
||||
:aria-pressed menu-open?
|
||||
:on-click on-toggle-menu}])}
|
||||
[:> menu-item* {:id "details"}
|
||||
(tr "workspace.pull-requests.menu.review-details")]
|
||||
(tr "workspace.branch-review.menu.review-details")]
|
||||
(when can-reopen?
|
||||
[:> menu-item* {:id "reopen"}
|
||||
(tr "workspace.pull-requests.actions.reopen")])]]]))
|
||||
(tr "workspace.branch-review.actions.reopen")])]]]))
|
||||
|
||||
;; --- Dialog
|
||||
|
||||
@ -288,9 +289,9 @@
|
||||
::mf/register-as :branch-reviews}
|
||||
[]
|
||||
(let [merges-state (mf/deref merges)
|
||||
prs-state (mf/deref refs/pull-requests)
|
||||
prs-state (mf/deref refs/branch-reviews)
|
||||
profiles (mf/deref refs/profiles)
|
||||
prs-enabled? (dwpr/enabled?)
|
||||
prs-enabled? (dwbr/enabled?)
|
||||
|
||||
tab* (mf/use-state "merges")
|
||||
tab (deref tab*)
|
||||
@ -355,8 +356,8 @@
|
||||
;; place of the loading state
|
||||
(mf/with-layout-effect []
|
||||
(st/emit! (dwb/fetch-branch-merges))
|
||||
(when (dwpr/enabled?)
|
||||
(st/emit! (dwpr/fetch-pull-requests))))
|
||||
(when (dwbr/enabled?)
|
||||
(st/emit! (dwbr/fetch-branch-reviews))))
|
||||
|
||||
[:> modal* {:is-open true
|
||||
:on-open-change on-open-change
|
||||
|
||||
@ -312,8 +312,8 @@
|
||||
|
||||
read-only? (mf/use-ctx ctx/workspace-read-only?)
|
||||
permissions (mf/use-ctx ctx/permissions)
|
||||
;; a design review is read-only for everybody, editors included
|
||||
reviewing? (some? (mf/deref refs/pull-request-preview))]
|
||||
;; a branch review is read-only for everybody, editors included
|
||||
reviewing? (some? (mf/deref refs/branch-review-preview))]
|
||||
|
||||
;; NOTE: a layout effect, so the saved position is back before the
|
||||
;; selected page item runs its `scroll-into-view-if-needed!` effect.
|
||||
|
||||
@ -303,11 +303,11 @@
|
||||
(st/emit! (dwrv/set-tool tool))))
|
||||
|
||||
(mf/defc read-only-toolbar*
|
||||
"The toolbar of a read-only mode of the workspace (a design review, the
|
||||
"The toolbar of a read-only mode of the workspace (a branch review, the
|
||||
comparison of a branch with main). It offers no drawing: moving
|
||||
around, commenting on a spot or a layer, commenting on an area and
|
||||
creating a task, and then what the mode adds (`children`). Inside a
|
||||
design review (`is-review`) the tool in use takes the review colour;
|
||||
branch review (`is-review`) the tool in use takes the review colour;
|
||||
outside it, the accent of the drawing tools."
|
||||
{::mf/private true}
|
||||
[{:keys [aria-label is-review rulers-enabled toolbar-hidden on-toggle-toolbar children]}]
|
||||
@ -369,7 +369,7 @@
|
||||
:on-click on-toggle-changes}]]))
|
||||
|
||||
(mf/defc compare-toolbar*
|
||||
"The toolbar of the compare mode, with or without a design review
|
||||
"The toolbar of the compare mode, with or without a branch review
|
||||
around it: the same tools, and the control that says how the canvas
|
||||
shows the changes in place of the one that shows them."
|
||||
{::mf/private true}
|
||||
@ -395,7 +395,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))
|
||||
reviewing? (some? (mf/deref refs/branch-review-preview))
|
||||
compare-mode (mf/deref refs/compare-mode)
|
||||
|
||||
mcp-conn-status (get mcp :connection-status)
|
||||
|
||||
@ -129,7 +129,7 @@
|
||||
background-color: var(--color-accent-default);
|
||||
}
|
||||
|
||||
// the tools of a design review use the review colour: blue on the tool in
|
||||
// the tools of a branch 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);
|
||||
|
||||
@ -252,8 +252,8 @@
|
||||
|
||||
disable-events? (contains? layout :comments)
|
||||
comments-mode? (= drawing-tool :comments)
|
||||
reviewing? (some? (mf/deref refs/pull-request-preview))
|
||||
;; inside a design review the global "show comments" option
|
||||
reviewing? (some? (mf/deref refs/branch-review-preview))
|
||||
;; inside a branch review the global "show comments" option
|
||||
;; decides alone: it shows or hides comments and tasks
|
||||
show-comments? (if reviewing?
|
||||
(contains? layout :display-comments)
|
||||
@ -398,7 +398,7 @@
|
||||
:edition edition}])]]]
|
||||
|
||||
|
||||
;; the changes of a design review and the layer picker of a task
|
||||
;; the changes of a branch review and the layer picker of a task
|
||||
[:> review-overlays* {:vbox vbox
|
||||
:vport vport
|
||||
:zoom zoom
|
||||
|
||||
@ -92,7 +92,7 @@
|
||||
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))
|
||||
reviewing? (some? (mf/deref refs/branch-review-preview))
|
||||
|
||||
task-thread-ids
|
||||
(mf/with-memo [tasks]
|
||||
@ -104,7 +104,7 @@
|
||||
(filter #(= (:page-id %) page-id))
|
||||
(dcm/apply-filters local profile)))
|
||||
|
||||
;; the threads of the design reviews and of the tasks have marks of
|
||||
;; the threads of the branch 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]
|
||||
|
||||
@ -370,8 +370,8 @@
|
||||
|
||||
disable-events? (contains? layout :comments)
|
||||
comments-mode? (= drawing-tool :comments)
|
||||
reviewing? (some? (mf/deref refs/pull-request-preview))
|
||||
;; inside a design review the global "show comments" option
|
||||
reviewing? (some? (mf/deref refs/branch-review-preview))
|
||||
;; inside a branch review the global "show comments" option
|
||||
;; decides alone: it shows or hides comments and tasks
|
||||
show-comments? (if reviewing?
|
||||
(contains? layout :display-comments)
|
||||
@ -726,7 +726,7 @@
|
||||
;; (`actions/on-mouse-wheel`)
|
||||
[:div {:class (stl/css :viewport-overlays)
|
||||
:data-canvas-overlays true}
|
||||
;; the changes of a design review and the layer picker of a task
|
||||
;; the changes of a branch review and the layer picker of a task
|
||||
[:> review-overlays* {:vbox vbox
|
||||
:vport vport
|
||||
:zoom zoom
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
[app.main.data.common :as dcm]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.persistence :as dwp]
|
||||
[app.main.data.workspace.branch-reviews :as dwbr]
|
||||
[app.main.data.workspace.branches :as dwb]
|
||||
[app.main.data.workspace.pull-requests :as dwpr]
|
||||
[app.main.repo :as rp]
|
||||
[beicon.v2.core :as rx]
|
||||
[cljs.test :as t :include-macros true]
|
||||
@ -292,9 +292,9 @@
|
||||
[calls cmd]
|
||||
(->> @calls (filter #(= cmd (first %))) (last) (second)))
|
||||
|
||||
(defn- reviewed
|
||||
(defn- viewed
|
||||
[store]
|
||||
(get-in @store [:workspace-branch-diff :reviewed]))
|
||||
(get-in @store [:workspace-branch-diff :viewed]))
|
||||
|
||||
(t/deftest ^:async a-mark-counts-while-its-change-is-what-it-was
|
||||
(let [calls (atom [])
|
||||
@ -308,8 +308,8 @@
|
||||
(mock/with-mocks* {rp/cmd! (review-stub calls marks false)}
|
||||
(let [store (make-store)]
|
||||
(ptk/emit! store (dwb/fetch-branch-diff (:id branch)))
|
||||
(await (async/wait-for-store store #(seq (reviewed store)) "the marks load"))
|
||||
(t/is (= #{(:key title)} (reviewed store)))
|
||||
(await (async/wait-for-store store #(seq (viewed store)) "the marks load"))
|
||||
(t/is (= #{(:key title)} (viewed store)))
|
||||
(t/is (= {:branch-id (:id branch) :direction :branch->source}
|
||||
(last-call calls :get-branch-change-marks))
|
||||
"the marks are the ones of the direction compared")
|
||||
@ -325,19 +325,19 @@
|
||||
(ptk/emit! store (dwb/fetch-branch-diff (:id branch)))
|
||||
(await (async/wait-for #(some? (last-call calls :get-branch-change-marks))
|
||||
"the marks are asked for"))
|
||||
(ptk/emit! store (dwb/toggle-diff-reviewed (:key logo) true))
|
||||
(t/is (= #{(:key logo)} (reviewed store)) "the mark shows at once")
|
||||
(ptk/emit! store (dwb/toggle-diff-viewed (:key logo) true))
|
||||
(t/is (= #{(:key logo)} (viewed store)) "the mark shows at once")
|
||||
(await (async/wait-for #(some? (last-call calls :set-branch-change-mark))
|
||||
"the mark is kept"))
|
||||
(t/is (= {:branch-id (:id branch)
|
||||
:direction :branch->source
|
||||
:change-key (:key logo)
|
||||
:fingerprint (dwb/change-fingerprint logo)
|
||||
:reviewed true}
|
||||
:viewed true}
|
||||
(last-call calls :set-branch-change-mark)))
|
||||
(ptk/emit! store (dwb/toggle-diff-reviewed (:key logo)))
|
||||
(t/is (= #{} (reviewed store)) "without a side it flips")
|
||||
(await (async/wait-for #(false? (:reviewed (last-call calls :set-branch-change-mark)))
|
||||
(ptk/emit! store (dwb/toggle-diff-viewed (:key logo)))
|
||||
(t/is (= #{} (viewed store)) "without a side it flips")
|
||||
(await (async/wait-for #(false? (:viewed (last-call calls :set-branch-change-mark)))
|
||||
"the mark is cleared"))
|
||||
(rx/dispose! store))))))
|
||||
|
||||
@ -351,10 +351,10 @@
|
||||
(ptk/emit! store (dwb/fetch-branch-diff (:id branch)))
|
||||
(await (async/wait-for #(some? (last-call calls :get-branch-change-marks))
|
||||
"the marks are asked for"))
|
||||
(ptk/emit! store (dwb/toggle-diff-reviewed (:key title) true))
|
||||
(await (async/wait-for-store store #(empty? (reviewed store))
|
||||
(ptk/emit! store (dwb/toggle-diff-viewed (:key title) true))
|
||||
(await (async/wait-for-store store #(empty? (viewed store))
|
||||
"the marks are read again"))
|
||||
(t/is (= #{} (reviewed store)))
|
||||
(t/is (= #{} (viewed store)))
|
||||
(rx/dispose! store))))))
|
||||
|
||||
(t/deftest the-fingerprint-follows-what-the-change-is
|
||||
@ -491,7 +491,7 @@
|
||||
(t/is (false? (dwb/has-branches? @store)))
|
||||
(rx/dispose! store)))))
|
||||
|
||||
(t/deftest ^:async a-pull-request-from-the-open-branch-saves-first-without-the-listing
|
||||
(t/deftest ^:async a-branch-review-from-the-open-branch-saves-first-without-the-listing
|
||||
(let [waits (atom 0)
|
||||
branch-id (uuid/next)]
|
||||
(await (mock/with-mocks*
|
||||
@ -504,7 +504,7 @@
|
||||
{:file-id file-id
|
||||
:loaded? true
|
||||
:info {:id branch-id :branch-file-id file-id}}))]
|
||||
(ptk/emit! store (dwpr/create-pull-request branch-id {:title "Review me"}))
|
||||
(ptk/emit! store (dwbr/create-branch-review branch-id {:title "Review me"}))
|
||||
(await (async/wait-for #(pos? @waits) "the pending edits are saved first"))
|
||||
(rx/dispose! store))))))
|
||||
|
||||
|
||||
@ -159,8 +159,9 @@
|
||||
[frontend-tests.tokens.tokenscript-test]
|
||||
[frontend-tests.tokens.typography-form-test]
|
||||
[frontend-tests.tokens.workspace-tokens-remap-test]
|
||||
[frontend-tests.ui.branch-review-common-test]
|
||||
[frontend-tests.ui.branch-review-sides-test]
|
||||
[frontend-tests.ui.branch-compare-common-test]
|
||||
[frontend-tests.ui.branch-compare-sides-test]
|
||||
[frontend-tests.ui.branch-reviews-test]
|
||||
[frontend-tests.ui.branches-compare-labels-test]
|
||||
[frontend-tests.ui.check-updates-test]
|
||||
[frontend-tests.ui.color-token-position-test]
|
||||
@ -396,8 +397,9 @@
|
||||
'frontend-tests.tokens.logic.tokens-source-test
|
||||
'frontend-tests.tokens.logic.tokens-status-test
|
||||
'frontend-tests.tokens.workspace-tokens-remap-test
|
||||
'frontend-tests.ui.branch-review-common-test
|
||||
'frontend-tests.ui.branch-review-sides-test
|
||||
'frontend-tests.ui.branch-compare-common-test
|
||||
'frontend-tests.ui.branch-compare-sides-test
|
||||
'frontend-tests.ui.branch-reviews-test
|
||||
'frontend-tests.ui.branches-compare-labels-test
|
||||
'frontend-tests.ui.check-updates-test
|
||||
'frontend-tests.ui.color-token-position-test
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
||||
|
||||
(ns frontend-tests.ui.branch-review-common-test
|
||||
(ns frontend-tests.ui.branch-compare-common-test
|
||||
"What the compare mode says about a diff: how a conflict splits into the
|
||||
properties both sides moved and the ones a single side moved, what an
|
||||
entry is and affects, the list the changes make and the marks they
|
||||
@ -13,7 +13,7 @@
|
||||
[app.common.files.branch-merge :as bm]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.workspace.compare :as dwcp]
|
||||
[app.main.ui.workspace.sidebar.branch-review.common :as brc]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.common :as brc]
|
||||
[cljs.test :as t :include-macros true]))
|
||||
|
||||
(def ^:private card
|
||||
@ -4,7 +4,7 @@
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
||||
|
||||
(ns frontend-tests.ui.branch-review-sides-test
|
||||
(ns frontend-tests.ui.branch-compare-sides-test
|
||||
"How the compare mode rebuilds the side the open file lacks: a deleted
|
||||
layer comes back from the diff, inside the board it was in, and a
|
||||
resized board takes its own size."
|
||||
@ -14,7 +14,7 @@
|
||||
[app.main.ui.workspace.compare.common :as cc]
|
||||
[app.main.ui.workspace.compare.detail :as detail]
|
||||
[app.main.ui.workspace.compare.side :as side]
|
||||
[app.main.ui.workspace.sidebar.branch-review.sides :as brs]
|
||||
[app.main.ui.workspace.sidebar.branch-compare.sides :as brs]
|
||||
[cljs.test :as t :include-macros true]))
|
||||
|
||||
(def ^:private board-id (uuid/next))
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user