mirror of
https://github.com/penpot/penpot.git
synced 2026-10-29 05:50:35 +00:00
✨ Sum up what a merge applies and leaves out
The compare dialog no longer opens on an overview, so the merge confirmation now says what the merge does: how many changes go into main and how many were left out. When changes are left out and the branch is not kept archived, a warning replaces the deletion note: deleting the branch loses those changes. The counts show when the compare dialog of that branch asked for the merge, as it holds the comparison.
This commit is contained in:
parent
c68daed816
commit
e4e237346e
@ -44,6 +44,9 @@
|
||||
(def ^:private branches
|
||||
(l/derived :workspace-branches st/state))
|
||||
|
||||
(def ^:private branch-diff
|
||||
(l/derived :workspace-branch-diff st/state))
|
||||
|
||||
(def ^:private branch-context
|
||||
;; see refs/branch-context: the state entry wraps the row under :info
|
||||
(l/derived #(get-in % [:workspace-branch-context :info]) st/state))
|
||||
@ -205,6 +208,16 @@
|
||||
(let [archive?* (mf/use-state false)
|
||||
archive? (deref archive?*)
|
||||
|
||||
;; what goes in and what stays out, when the compare dialog of this
|
||||
;; branch is the one that asked for the merge
|
||||
diff-st (mf/deref branch-diff)
|
||||
changes (when (and (= (:id branch) (:branch-id diff-st))
|
||||
(= :loaded (:status diff-st)))
|
||||
(filterv #(contains? #{:added :modified :deleted} (:status %))
|
||||
(get-in diff-st [:diff :changes])))
|
||||
left-out (count (filter #(contains? (or excluded #{}) (:key %)) changes))
|
||||
going-in (- (count changes) left-out)
|
||||
|
||||
;; The branch name and "main" are highlighted (foreground-primary)
|
||||
;; within the otherwise secondary-colored prompt. We wrap each of
|
||||
;; them with a sentinel in the `tr` args and split on it, so the
|
||||
@ -241,14 +254,28 @@
|
||||
[:span {:key idx :class (stl/css :modal-message-emphasis)} part]
|
||||
[:span {:key idx} part]))]
|
||||
|
||||
(when (seq changes)
|
||||
[:ul {:class (stl/css :merge-summary)}
|
||||
[:li (tr "workspace.branches.merge.summary-in" (i18n/c going-in))]
|
||||
(when (pos? left-out)
|
||||
[:li (tr "workspace.branches.merge.summary-out" (i18n/c left-out))])])
|
||||
|
||||
[:> checkbox* {:id "merge-archive-branch"
|
||||
:label (tr "workspace.branches.merge.archive-label")
|
||||
:checked archive?
|
||||
:on-change on-toggle-archive}]
|
||||
|
||||
(if archive?
|
||||
(cond
|
||||
archive?
|
||||
[:> context-notification* {:level :warning :type :context}
|
||||
(tr "workspace.branches.merge.archive-warning")]
|
||||
|
||||
;; deleting the branch takes the changes left out with it
|
||||
(pos? left-out)
|
||||
[:> context-notification* {:level :warning :type :context}
|
||||
(tr "workspace.branches.merge.left-out-lost" (i18n/c left-out))]
|
||||
|
||||
:else
|
||||
[:> context-notification* {:level :info :type :context}
|
||||
(tr "workspace.branches.merge.delete-info")])]
|
||||
|
||||
|
||||
@ -169,6 +169,17 @@
|
||||
color: var(--color-foreground-primary);
|
||||
}
|
||||
|
||||
.merge-summary {
|
||||
@include use-typography("body-small");
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--sp-xs);
|
||||
margin: 0;
|
||||
padding-inline-start: var(--sp-l);
|
||||
color: var(--color-foreground-primary);
|
||||
list-style: disc;
|
||||
}
|
||||
|
||||
.field {
|
||||
display: flex;
|
||||
|
||||
@ -11556,8 +11556,23 @@ msgstr "Main's %s:"
|
||||
msgid "workspace.branches.resolve.drops.branch-short"
|
||||
msgstr "The branch's %s:"
|
||||
|
||||
#: src/app/main/ui/workspace/sidebar/branches.cljs
|
||||
msgid "workspace.branches.merge.summary-in"
|
||||
msgid_plural "workspace.branches.merge.summary-in"
|
||||
msgstr[0] "1 change goes into main."
|
||||
msgstr[1] "%s changes go into main."
|
||||
|
||||
#: src/app/main/ui/workspace/sidebar/branches.cljs
|
||||
msgid "workspace.branches.merge.summary-out"
|
||||
msgid_plural "workspace.branches.merge.summary-out"
|
||||
msgstr[0] "1 change is left out."
|
||||
msgstr[1] "%s changes are left out."
|
||||
|
||||
#: src/app/main/ui/workspace/sidebar/branches.cljs
|
||||
msgid "workspace.branches.merge.left-out-lost"
|
||||
msgid_plural "workspace.branches.merge.left-out-lost"
|
||||
msgstr[0] "The change you left out is lost when the branch is deleted. Archive the branch to keep it."
|
||||
msgstr[1] "The %s changes you left out are lost when the branch is deleted. Archive the branch to keep them."
|
||||
|
||||
#: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs
|
||||
msgid "workspace.branches.review.view.expand"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user