1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-09 14:21:02 +01:00
phorge-phorge/src/applications/differential/xaction
epriestley b48a22bf50 Make "editing" state persistent for inline comments
Summary:
Ref T13513. This is mostly an infrastructure cleanup change.

In a perfect world, this would be a series of several changes, but they're tightly interconnected and don't have an obvious clean, nontrivial partition (or, at least, I don't see one). Followup changes will exercise this code repeatedly and all of these individual mutations are "obviously good", so I'm not too worried about the breadth of this change.

---

Inline comments are stored as transaction comments in the `PhabricatorAuditTransactionComment` and `DifferentialTransactionComment` classes.

On top of these two storage classes sit `PhabricatorAuditInlineComment` and `DifferentialInlineComment`. Historically, these were an indirection layer over significantly different storage classes, but nowadays both storage classes look pretty similar and most of the logic is actually the same. Prior to this change, these two classes were about 80% copy/pastes of one another.

Part of the reason they're so copy/pastey is that they implement a parent `Interface`. They are the only classes which implement this interface, and the interface does not provide any correctness guarantees (the storage objects are not actually constrained by it).

To simplify this:

  - Make `PhabricatorInlineCommentInterface` an abstract base class instead.
  - Lift as much code out of the `Audit` and `Differential` subclasses as possible.
  - Delete methods which no longer have callers, or have only trivial callers.

---

Inline comments have two `View` rendering classes, `DetailView` and `EditView`. They share very little code.

Partly, this is because `EditView` does not take an `$inline` object. Historically, it needed to be able to operate on inlines that did not have an ID yet, and even further back in history this was probably just an outgrowth of a simple `<form />`.

These classes can be significantly simplified by passing an `$inline` to the `EditView`, instead of individually setting all the properties on the `View` itself. This allows the `DetailView` and `EditView` classes to share a lot of code.

The `EditView` can not fully render its content. Move the content rendering code into the view.

---

Prior to this change, some operations need to work on inlines that don't have an inline ID yet (we assign an ID the first time you "Save" a comment). Since "editing" comments will now be saved, we can instead create a row immediately.

This means that all the inline code can always rely on having a valid ID to work with, even if that ID corresponds to an empty, draft, "isEditing" comment. This simplifies more code in `EditView` and allows the "create" and "reply" code to be merged in `PhabricatorInlineCommentController`.

---

Client-side inline events are currently handled through a mixture of `ChangesetList` listeners (good) and ad-hoc row-level listeners (less good). In particular, the "save", "cancel", and "undo" events are row-level. All other events are list-level.

Move all events to list-level. This is supported by all inlines now having an ID at all stages of their lifecycle.

This allows some of the client behavior to be simplified. It currently depends on binding complex ad-hoc dictionaries into event handlers in `_drawRows()`, but it seems like almost all of this code can be removed. In fact, no more than one row ever seems to be drawn, so this code can probably be simplified further.

---

Finally, save an "isEditing" state. When we rebuild a revision on the client, click the "edit" button if it's in this state. This is a little hacky, but simpler to get into a stable state, since the row layout of an inline depends on a "view row" followed by an "edit row".

Test Plan:
  - Created comments on either side of a diff.
  - Edited a comment, reloaded, saw edit stick.
  - Saved comments, reloaded, saw save stick.
  - Edited a comment, typed text, cancelled, "unedited" to get state back.
  - Created a comment, typed text, cancelled, "unedited" to get state back.
  - Deleted a comment, "undeleted" to get state back.

Weirdness / known issues:

  - Drafts don't autosave yet.
  - Fixed in D21187:
    - When you create an empty comment then reload, you get an empty editor. This is a bit silly.
    - "Cancel" does not save state, but should, once drafts autosave.
  - Mostly fixed in D21188:
    - "Editing" comments aren't handled specially by the overall submission flow.
    - "Editing" comments submitted in that state try to edit themselves again on load, which doesn't work.

Subscribers: jmeador

Maniphest Tasks: T13513

Differential Revision: https://secure.phabricator.com/D21186
2020-05-04 13:10:30 -07:00
..
DifferentialRevisionAbandonTransaction.php Expose Differential actions for "transaction.search" in a basic way 2018-06-28 08:51:55 -07:00
DifferentialRevisionAcceptTransaction.php Expose Differential actions for "transaction.search" in a basic way 2018-06-28 08:51:55 -07:00
DifferentialRevisionActionTransaction.php Stabilize sorting of feed stories with similar strength 2019-05-22 15:50:59 -07:00
DifferentialRevisionBuildableTransaction.php When publishing buildables in Differential, ignore autobuilds (local lint and unit) 2018-04-03 11:02:12 -07:00
DifferentialRevisionCloseTransaction.php When a revision is closed, always promote it out of draft 2019-06-04 06:56:22 -07:00
DifferentialRevisionCommandeerTransaction.php Allow "Abandoned" revisions to be commandeered 2018-11-26 10:13:52 -08:00
DifferentialRevisionHoldDraftTransaction.php Enrich "draft", "summary", and "testPlan" transactions from Differential in "transaction.search" 2019-05-16 10:50:28 -07:00
DifferentialRevisionInlineTransaction.php Make "editing" state persistent for inline comments 2020-05-04 13:10:30 -07:00
DifferentialRevisionPlanChangesTransaction.php Expose Differential actions for "transaction.search" in a basic way 2018-06-28 08:51:55 -07:00
DifferentialRevisionReclaimTransaction.php Expose Differential actions for "transaction.search" in a basic way 2018-06-28 08:51:55 -07:00
DifferentialRevisionRejectTransaction.php Expose Differential actions for "transaction.search" in a basic way 2018-06-28 08:51:55 -07:00
DifferentialRevisionReopenTransaction.php Expose Differential actions for "transaction.search" in a basic way 2018-06-28 08:51:55 -07:00
DifferentialRevisionRepositoryTransaction.php Add Summary and Repository EditEngine fields + Modular Transactions to Differential 2016-12-13 18:18:32 -08:00
DifferentialRevisionRequestReviewTransaction.php When you "Request Review" of a draft revision, change the button text from "Submit Quietly" to "Publish Revision" 2018-11-15 20:50:21 -08:00
DifferentialRevisionResignTransaction.php Expose Differential actions for "transaction.search" in a basic way 2018-06-28 08:51:55 -07:00
DifferentialRevisionReviewersTransaction.php Provide detailed information about reviewer changes in "transaction.search" 2020-05-01 14:18:12 -07:00
DifferentialRevisionReviewTransaction.php Allow custom actions in Differential to explicitly override "accept" stickiness 2018-03-12 17:10:43 -07:00
DifferentialRevisionStatusTransaction.php Fill in some straightforward Maniphest transactions for transaction.search 2017-11-07 15:33:55 -08:00
DifferentialRevisionSummaryTransaction.php Enrich "draft", "summary", and "testPlan" transactions from Differential in "transaction.search" 2019-05-16 10:50:28 -07:00
DifferentialRevisionTestPlanTransaction.php Enrich "draft", "summary", and "testPlan" transactions from Differential in "transaction.search" 2019-05-16 10:50:28 -07:00
DifferentialRevisionTitleTransaction.php Enrich "draft", "summary", and "testPlan" transactions from Differential in "transaction.search" 2019-05-16 10:50:28 -07:00
DifferentialRevisionTransactionType.php Allow users to resign if they have authority over any reviewer 2017-03-24 13:14:47 -07:00
DifferentialRevisionUpdateTransaction.php Make "Highlight As..." sticky across reloads in Diffusion and Differential 2020-04-19 08:58:39 -07:00
DifferentialRevisionVoidTransaction.php Allow custom actions in Differential to explicitly override "accept" stickiness 2018-03-12 17:10:43 -07:00
DifferentialRevisionWrongBuildsTransaction.php Stabilize sorting of feed stories with similar strength 2019-05-22 15:50:59 -07:00
DifferentialRevisionWrongStateTransaction.php Stabilize sorting of feed stories with similar strength 2019-05-22 15:50:59 -07:00