Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/diff/PhabricatorInlineCommentController.php
| Show First 20 Lines • Show All 234 Lines • ▼ Show 20 Lines | switch ($op) { | ||||
| } | } | ||||
| } | } | ||||
| $edit_dialog = $this->buildEditDialog($inline) | $edit_dialog = $this->buildEditDialog($inline) | ||||
| ->setTitle(pht('Edit Inline Comment')); | ->setTitle(pht('Edit Inline Comment')); | ||||
| $view = $this->buildScaffoldForView($edit_dialog); | $view = $this->buildScaffoldForView($edit_dialog); | ||||
| return $this->newInlineResponse($inline, $view); | return $this->newInlineResponse($inline, $view, true); | ||||
| case 'cancel': | case 'cancel': | ||||
| $inline = $this->loadCommentByIDForEdit($this->getCommentID()); | $inline = $this->loadCommentByIDForEdit($this->getCommentID()); | ||||
| $inline->setIsEditing(false); | $inline->setIsEditing(false); | ||||
| // If the user uses "Undo" to get into an edited state ("AB"), then | // If the user uses "Undo" to get into an edited state ("AB"), then | ||||
| // clicks cancel to return to the previous state ("A"), we also want | // clicks cancel to return to the previous state ("A"), we also want | ||||
| // to set the stored state back to "A". | // to set the stored state back to "A". | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | switch ($op) { | ||||
| } | } | ||||
| if ($this->hasContentState()) { | if ($this->hasContentState()) { | ||||
| $this->updateCommentContentState($inline); | $this->updateCommentContentState($inline); | ||||
| } | } | ||||
| $this->saveComment($inline); | $this->saveComment($inline); | ||||
| // Reload the inline to attach context. | |||||
| $inline = $this->loadCommentByIDForEdit($inline->getID()); | |||||
| $edit_dialog = $this->buildEditDialog($inline); | $edit_dialog = $this->buildEditDialog($inline); | ||||
| if ($this->getOperation() == 'reply') { | if ($this->getOperation() == 'reply') { | ||||
| $edit_dialog->setTitle(pht('Reply to Inline Comment')); | $edit_dialog->setTitle(pht('Reply to Inline Comment')); | ||||
| } else { | } else { | ||||
| $edit_dialog->setTitle(pht('New Inline Comment')); | $edit_dialog->setTitle(pht('New Inline Comment')); | ||||
| } | } | ||||
| $view = $this->buildScaffoldForView($edit_dialog); | $view = $this->buildScaffoldForView($edit_dialog); | ||||
| return $this->newInlineResponse($inline, $view); | return $this->newInlineResponse($inline, $view, true); | ||||
| } | } | ||||
| } | } | ||||
| private function readRequestParameters() { | private function readRequestParameters() { | ||||
| $request = $this->getRequest(); | $request = $this->getRequest(); | ||||
| // NOTE: This isn't necessarily a DifferentialChangeset ID, just an | // NOTE: This isn't necessarily a DifferentialChangeset ID, just an | ||||
| // application identifier for the changeset. In Diffusion, it's a Path ID. | // application identifier for the changeset. In Diffusion, it's a Path ID. | ||||
| ▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | $view = id(new PHUIDiffInlineCommentDetailView()) | ||||
| ->setMarkupEngine($engine) | ->setMarkupEngine($engine) | ||||
| ->setHandles($handles) | ->setHandles($handles) | ||||
| ->setEditable(true) | ->setEditable(true) | ||||
| ->setCanMarkDone(false) | ->setCanMarkDone(false) | ||||
| ->setObjectOwnerPHID($object_owner_phid); | ->setObjectOwnerPHID($object_owner_phid); | ||||
| $view = $this->buildScaffoldForView($view); | $view = $this->buildScaffoldForView($view); | ||||
| return $this->newInlineResponse($inline, $view); | return $this->newInlineResponse($inline, $view, false); | ||||
| } | } | ||||
| private function buildScaffoldForView(PHUIDiffInlineCommentView $view) { | private function buildScaffoldForView(PHUIDiffInlineCommentView $view) { | ||||
| $renderer = DifferentialChangesetHTMLRenderer::getHTMLRendererByKey( | $renderer = DifferentialChangesetHTMLRenderer::getHTMLRendererByKey( | ||||
| $this->getRenderer()); | $this->getRenderer()); | ||||
| $view = $renderer->getRowScaffoldForInline($view); | $view = $renderer->getRowScaffoldForInline($view); | ||||
| return id(new PHUIDiffInlineCommentTableScaffold()) | return id(new PHUIDiffInlineCommentTableScaffold()) | ||||
| ->addRowScaffold($view); | ->addRowScaffold($view); | ||||
| } | } | ||||
| private function newInlineResponse( | private function newInlineResponse( | ||||
| PhabricatorInlineComment $inline, | PhabricatorInlineComment $inline, | ||||
| $view) { | $view, | ||||
| $is_edit) { | |||||
| if ($inline->getReplyToCommentPHID()) { | |||||
| $can_suggest = false; | |||||
| } else { | |||||
| $can_suggest = (bool)$inline->getInlineContext(); | |||||
| } | |||||
| if ($is_edit) { | |||||
| $viewer = $this->getViewer(); | |||||
| $content_state = $inline->getContentStateForEdit($viewer); | |||||
| } else { | |||||
| $content_state = $inline->getContentState(); | |||||
| } | |||||
| $state_map = $content_state->newStorageMap(); | |||||
| $response = array( | $response = array( | ||||
| 'inline' => array( | 'inline' => array( | ||||
| 'id' => $inline->getID(), | 'id' => $inline->getID(), | ||||
| 'contentState' => $state_map, | |||||
| 'canSuggestEdit' => $can_suggest, | |||||
| ), | ), | ||||
| 'view' => hsprintf('%s', $view), | 'view' => hsprintf('%s', $view), | ||||
| ); | ); | ||||
| return id(new AphrontAjaxResponse()) | return id(new AphrontAjaxResponse()) | ||||
| ->setContent($response); | ->setContent($response); | ||||
| } | } | ||||
| Show All 10 Lines | final protected function loadCommentByPHID($phid) { | ||||
| return $this->loadCommentByQuery($query); | return $this->loadCommentByQuery($query); | ||||
| } | } | ||||
| final protected function loadCommentByIDForEdit($id) { | final protected function loadCommentByIDForEdit($id) { | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $query = $this->newInlineCommentQuery() | $query = $this->newInlineCommentQuery() | ||||
| ->withIDs(array($id)); | ->withIDs(array($id)) | ||||
| ->needInlineContext(true); | |||||
| $inline = $this->loadCommentByQuery($query); | $inline = $this->loadCommentByQuery($query); | ||||
| if (!$inline) { | if (!$inline) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'Unable to load inline "%s".', | 'Unable to load inline "%s".', | ||||
| $id)); | $id)); | ||||
| ▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines | |||||