mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-20 13:52:40 +01:00
Revision comment drafts.
This commit is contained in:
parent
50bfcd0a30
commit
1c586db9be
13 changed files with 120 additions and 6 deletions
|
@ -27,7 +27,7 @@ celerity_register_resource_map(array(
|
|||
),
|
||||
'aphront-error-view-css' =>
|
||||
array(
|
||||
'uri' => '/res/43b5ae86/rsrc/css/aphront/error-view.css',
|
||||
'uri' => '/res/5ea93eb4/rsrc/css/aphront/error-view.css',
|
||||
'type' => 'css',
|
||||
'requires' =>
|
||||
array(
|
||||
|
|
|
@ -148,6 +148,8 @@ phutil_register_library_map(array(
|
|||
'PhabricatorDirectoryItemEditController' => 'applications/directory/controller/itemedit',
|
||||
'PhabricatorDirectoryItemListController' => 'applications/directory/controller/itemlist',
|
||||
'PhabricatorDirectoryMainController' => 'applications/directory/controller/main',
|
||||
'PhabricatorDraft' => 'applications/draft/storage/draft',
|
||||
'PhabricatorDraftDAO' => 'applications/draft/storage/base',
|
||||
'PhabricatorEmailLoginController' => 'applications/auth/controller/email',
|
||||
'PhabricatorEmailTokenController' => 'applications/auth/controller/emailtoken',
|
||||
'PhabricatorEnv' => 'infrastructure/env',
|
||||
|
@ -327,6 +329,8 @@ phutil_register_library_map(array(
|
|||
'PhabricatorDirectoryItemEditController' => 'PhabricatorDirectoryController',
|
||||
'PhabricatorDirectoryItemListController' => 'PhabricatorDirectoryController',
|
||||
'PhabricatorDirectoryMainController' => 'PhabricatorDirectoryController',
|
||||
'PhabricatorDraft' => 'PhabricatorDraftDAO',
|
||||
'PhabricatorDraftDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorEmailLoginController' => 'PhabricatorAuthController',
|
||||
'PhabricatorEmailTokenController' => 'PhabricatorAuthController',
|
||||
'PhabricatorFacebookAuthController' => 'PhabricatorAuthController',
|
||||
|
|
|
@ -47,6 +47,13 @@ class DifferentialCommentPreviewController extends DifferentialController {
|
|||
$view->setMarkupEngine($engine);
|
||||
$view->setPreview(true);
|
||||
|
||||
$draft = new PhabricatorDraft();
|
||||
$draft
|
||||
->setAuthorPHID($author_phid)
|
||||
->setDraftKey('differential-comment-'.$this->id)
|
||||
->setDraft($comment->getContent())
|
||||
->replace();
|
||||
|
||||
return id(new AphrontAjaxResponse())
|
||||
->setContent($view->render());
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'applications/differential/controller/base'
|
|||
phutil_require_module('phabricator', 'applications/differential/parser/markup');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/comment');
|
||||
phutil_require_module('phabricator', 'applications/differential/view/revisioncomment');
|
||||
phutil_require_module('phabricator', 'applications/draft/storage/draft');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
|
|
@ -47,7 +47,14 @@ class DifferentialCommentSaveController extends DifferentialController {
|
|||
->save();
|
||||
|
||||
// TODO: Diff change detection?
|
||||
// TODO: Clear draft
|
||||
|
||||
$draft = id(new PhabricatorDraft())->loadOneWhere(
|
||||
'authorPHID = %s AND draftKey = %s',
|
||||
$request->getUser()->getPHID(),
|
||||
'differential-comment-'.$revision->getID());
|
||||
if ($draft) {
|
||||
$draft->delete();
|
||||
}
|
||||
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/D'.$revision->getID());
|
||||
|
|
|
@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'aphront/response/redirect');
|
|||
phutil_require_module('phabricator', 'applications/differential/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/differential/editor/comment');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/revision');
|
||||
phutil_require_module('phabricator', 'applications/draft/storage/draft');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ class DifferentialRevisionViewController extends DifferentialController {
|
|||
public function processRequest() {
|
||||
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$revision = id(new DifferentialRevision())->load($this->revisionID);
|
||||
if (!$revision) {
|
||||
|
@ -60,7 +61,7 @@ class DifferentialRevisionViewController extends DifferentialController {
|
|||
$revision->getCCPHIDs(),
|
||||
array(
|
||||
$revision->getAuthorPHID(),
|
||||
$request->getUser()->getPHID(),
|
||||
$user->getPHID(),
|
||||
),
|
||||
mpull($comments, 'getAuthorPHID'));
|
||||
$object_phids = array_unique($object_phids);
|
||||
|
@ -111,7 +112,7 @@ class DifferentialRevisionViewController extends DifferentialController {
|
|||
$comment_view->setHandles($handles);
|
||||
$comment_view->setInlineComments($inlines);
|
||||
$comment_view->setChangesets($changesets);
|
||||
$comment_view->setUser($request->getUser());
|
||||
$comment_view->setUser($user);
|
||||
|
||||
$diff_history = new DifferentialRevisionUpdateHistoryView();
|
||||
$diff_history->setDiffs($diffs);
|
||||
|
@ -127,11 +128,22 @@ class DifferentialRevisionViewController extends DifferentialController {
|
|||
$changeset_view->setRevision($revision);
|
||||
$changeset_view->setVsMap($vs_map);
|
||||
|
||||
$draft = id(new PhabricatorDraft())->loadOneWhere(
|
||||
'authorPHID = %s AND draftKey = %s',
|
||||
$user->getPHID(),
|
||||
'differential-comment-'.$revision->getID());
|
||||
if ($draft) {
|
||||
$draft = $draft->getDraft();
|
||||
} else {
|
||||
$draft = null;
|
||||
}
|
||||
|
||||
$comment_form = new DifferentialAddCommentView();
|
||||
$comment_form->setRevision($revision);
|
||||
$comment_form->setActions($this->getRevisionCommentActions($revision));
|
||||
$comment_form->setActionURI('/differential/comment/save/');
|
||||
$comment_form->setUser($request->getUser());
|
||||
$comment_form->setUser($user);
|
||||
$comment_form->setDraft($draft);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
'<div class="differential-primary-pane">'.
|
||||
|
|
|
@ -20,6 +20,7 @@ phutil_require_module('phabricator', 'applications/differential/view/difftableof
|
|||
phutil_require_module('phabricator', 'applications/differential/view/revisioncommentlist');
|
||||
phutil_require_module('phabricator', 'applications/differential/view/revisiondetail');
|
||||
phutil_require_module('phabricator', 'applications/differential/view/revisionupdatehistory');
|
||||
phutil_require_module('phabricator', 'applications/draft/storage/draft');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||
phutil_require_module('phabricator', 'view/form/error');
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ final class DifferentialAddCommentView extends AphrontView {
|
|||
private $actions;
|
||||
private $actionURI;
|
||||
private $user;
|
||||
private $draft;
|
||||
|
||||
public function setRevision($revision) {
|
||||
$this->revision = $revision;
|
||||
|
@ -41,6 +42,11 @@ final class DifferentialAddCommentView extends AphrontView {
|
|||
$this->user = $user;
|
||||
}
|
||||
|
||||
public function setDraft($draft) {
|
||||
$this->draft = $draft;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
require_celerity_resource('differential-revision-add-comment-css');
|
||||
|
@ -75,7 +81,8 @@ final class DifferentialAddCommentView extends AphrontView {
|
|||
id(new AphrontFormTextAreaControl())
|
||||
->setName('comment')
|
||||
->setID('comment-content')
|
||||
->setLabel('Comment'))
|
||||
->setLabel('Comment')
|
||||
->setValue($this->draft))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->setValue('Comment'));
|
||||
|
|
25
src/applications/draft/storage/base/PhabricatorDraftDAO.php
Normal file
25
src/applications/draft/storage/base/PhabricatorDraftDAO.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class PhabricatorDraftDAO extends PhabricatorLiskDAO {
|
||||
|
||||
public function getApplicationName() {
|
||||
return 'draft';
|
||||
}
|
||||
|
||||
}
|
12
src/applications/draft/storage/base/__init__.php
Normal file
12
src/applications/draft/storage/base/__init__.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/base/storage/lisk');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorDraftDAO.php');
|
25
src/applications/draft/storage/draft/PhabricatorDraft.php
Normal file
25
src/applications/draft/storage/draft/PhabricatorDraft.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class PhabricatorDraft extends PhabricatorDraftDAO {
|
||||
|
||||
protected $authorPHID;
|
||||
protected $draftKey;
|
||||
protected $draft;
|
||||
|
||||
}
|
12
src/applications/draft/storage/draft/__init__.php
Normal file
12
src/applications/draft/storage/draft/__init__.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/draft/storage/base');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorDraft.php');
|
Loading…
Reference in a new issue