diff --git a/components/graph/git-graph-actions.js b/components/graph/git-graph-actions.js index d690420a3..b30911fd5 100644 --- a/components/graph/git-graph-actions.js +++ b/components/graph/git-graph-actions.js @@ -10,6 +10,7 @@ const MergeViewModel = HoverActions.MergeViewModel; const ResetViewModel = HoverActions.ResetViewModel; const PushViewModel = HoverActions.PushViewModel; const SquashViewModel = HoverActions.SquashViewModel; +const MergeSquashViewModel = HoverActions.MergeSquashViewModel; class ActionBase { constructor(graph, text, style, icon) { @@ -18,13 +19,13 @@ class ActionBase { this.isRunning = ko.observable(false); this.isHighlighted = ko.computed(() => !graph.hoverGraphAction() || graph.hoverGraphAction() == this); this.text = text; - this.style = style; + this.style = ko.observable(style); this.icon = icon; this.cssClasses = ko.computed(() => { if (!this.isHighlighted() || this.isRunning()) { - return `${this.style} dimmed`; + return `${this.style()} dimmed`; } else { - return this.style; + return this.style(); } }); } @@ -168,6 +169,25 @@ class Merge extends ActionBase { } } +class MergeSquash extends Merge { + constructor(graph, node) { + super(graph, node) + this.text = "Merge Squash"; + this.style("merge-squash"); + } + + createHoverGraphic() { + let from = this.graph.currentActionContext(); + if (!from) return; + if (from instanceof RefViewModel) from = from.node(); + return new MergeSquashViewModel(from, this.node); + } + + perform() { + return this.server.postPromise('/squash', { path: this.graph.repoPath(), target: this.graph.currentActionContext().localRefName }) + .catch((err) => { if (err.errorCode != 'merge-failed') this.server.unhandledRejection(err); }); + } +} class Push extends ActionBase { constructor(graph, node) { @@ -369,6 +389,7 @@ const GraphActions = { Move: Move, Rebase: Rebase, Merge: Merge, + MergeSquash: MergeSquash, Push: Push, Reset: Reset, Checkout: Checkout, diff --git a/components/graph/git-node.js b/components/graph/git-node.js index 0941c9d5a..b972a8392 100644 --- a/components/graph/git-node.js +++ b/components/graph/git-node.js @@ -97,6 +97,7 @@ class GitNodeViewModel extends Animateable { new GraphActions.Move(this.graph, this), new GraphActions.Rebase(this.graph, this), new GraphActions.Merge(this.graph, this), + new GraphActions.MergeSquash(this.graph, this), new GraphActions.Push(this.graph, this), new GraphActions.Reset(this.graph, this), new GraphActions.Checkout(this.graph, this), diff --git a/components/graph/graph.less b/components/graph/graph.less index f00c14ec2..1e437c885 100644 --- a/components/graph/graph.less +++ b/components/graph/graph.less @@ -119,6 +119,9 @@ &.merge { background: rgba(208, 135, 212, 0.9); } + &.merge-squash { + background: darken(rgba(208, 135, 212, 0.9), 20%); + } &.checkout { background: rgba(205, 219, 55, 0.9); } diff --git a/components/graph/hover-actions.js b/components/graph/hover-actions.js index f79289fae..6c061cf47 100644 --- a/components/graph/hover-actions.js +++ b/components/graph/hover-actions.js @@ -101,3 +101,10 @@ class SquashViewModel extends HoverViewModel { } } exports.SquashViewModel = SquashViewModel; + +class MergeSquashViewModel extends SquashViewModel { + constructor(from, onto) { + super(from, onto); + } +} +exports.MergeSquashViewModel = MergeSquashViewModel;