From 66c1d623c3406120b65dab78f1bd297195c01a85 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 21 Mar 2019 13:37:43 -0700 Subject: [PATCH] If the user cancels a workboard drop flow, put things back where they were Summary: Ref T13074. If you hit a prompt on a drop operation (today: MFA; in the future, maybe "add a comment" or "assign this task"), we currently leave the board in a bad semi-frozen state if you cancel the workflow by pressing "Cancel" on the dialog. Instead, put things back the way they were. Test Plan: Dragged an MFA-required card, cancelled the MFA prompt, got a functional board instead of a semi-frozen board I needed to reload. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13074 Differential Revision: https://secure.phabricator.com/D20305 --- resources/celerity/map.php | 28 +++++++++---------- .../js/application/projects/WorkboardBoard.js | 25 +++++++++++++++++ 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index ffb8209f41..62cdf2f1e3 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -409,7 +409,7 @@ return array( 'rsrc/js/application/phortune/phortune-credit-card-form.js' => 'd12d214f', 'rsrc/js/application/policy/behavior-policy-control.js' => '0eaa33a9', 'rsrc/js/application/policy/behavior-policy-rule-editor.js' => '9347f172', - 'rsrc/js/application/projects/WorkboardBoard.js' => '31766c31', + 'rsrc/js/application/projects/WorkboardBoard.js' => '65afb173', 'rsrc/js/application/projects/WorkboardCard.js' => '0392a5d8', 'rsrc/js/application/projects/WorkboardCardTemplate.js' => '2a61f8d4', 'rsrc/js/application/projects/WorkboardColumn.js' => 'c3d24e63', @@ -737,7 +737,7 @@ return array( 'javelin-view-renderer' => '9aae2b66', 'javelin-view-visitor' => '308f9fe4', 'javelin-websocket' => 'fdc13e4e', - 'javelin-workboard-board' => '31766c31', + 'javelin-workboard-board' => '65afb173', 'javelin-workboard-card' => '0392a5d8', 'javelin-workboard-card-template' => '2a61f8d4', 'javelin-workboard-column' => 'c3d24e63', @@ -1182,18 +1182,6 @@ return array( 'javelin-install', 'javelin-util', ), - '31766c31' => array( - 'javelin-install', - 'javelin-dom', - 'javelin-util', - 'javelin-stratcom', - 'javelin-workflow', - 'phabricator-draggable-list', - 'javelin-workboard-column', - 'javelin-workboard-header-template', - 'javelin-workboard-card-template', - 'javelin-workboard-order-template', - ), '32755edb' => array( 'javelin-install', 'javelin-util', @@ -1468,6 +1456,18 @@ return array( '60cd9241' => array( 'javelin-behavior', ), + '65afb173' => array( + 'javelin-install', + 'javelin-dom', + 'javelin-util', + 'javelin-stratcom', + 'javelin-workflow', + 'phabricator-draggable-list', + 'javelin-workboard-column', + 'javelin-workboard-header-template', + 'javelin-workboard-card-template', + 'javelin-workboard-order-template', + ), '65bb0011' => array( 'javelin-behavior', 'javelin-dom', diff --git a/webroot/rsrc/js/application/projects/WorkboardBoard.js b/webroot/rsrc/js/application/projects/WorkboardBoard.js index f96e82fb8b..a7786a86f4 100644 --- a/webroot/rsrc/js/application/projects/WorkboardBoard.js +++ b/webroot/rsrc/js/application/projects/WorkboardBoard.js @@ -479,6 +479,17 @@ JX.install('WorkboardBoard', { data.visiblePHIDs = visible_phids.join(','); + // If the user cancels the workflow (for example, by hitting an MFA + // prompt that they click "Cancel" on), put the card back where it was + // and reset the UI state. + var on_revert = JX.bind( + this, + this._revertCard, + list, + item, + src_phid, + dst_phid); + var onupdate = JX.bind( this, this._oncardupdate, @@ -489,9 +500,23 @@ JX.install('WorkboardBoard', { new JX.Workflow(this.getController().getMoveURI(), data) .setHandler(onupdate) + .setCloseHandler(on_revert) .start(); }, + _revertCard: function(list, item, src_phid, dst_phid) { + JX.DOM.alterClass(item, 'drag-sending', false); + + var src_column = this.getColumn(src_phid); + var dst_column = this.getColumn(dst_phid); + + src_column.markForRedraw(); + dst_column.markForRedraw(); + this._redrawColumns(); + + list.unlock(); + }, + _oncardupdate: function(list, src_phid, dst_phid, after_phid, response) { var src_column = this.getColumn(src_phid); var dst_column = this.getColumn(dst_phid);