diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 52e3386953..d747c3b38b 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -138,6 +138,7 @@ phutil_register_library_map(array( 'DifferentialRevisionStatus' => 'applications/differential/constants/revisionstatus', 'DifferentialRevisionUpdateHistoryView' => 'applications/differential/view/revisionupdatehistory', 'DifferentialRevisionViewController' => 'applications/differential/controller/revisionview', + 'DifferentialSubscribeController' => 'applications/differential/controller/subscribe', 'DifferentialUnitStatus' => 'applications/differential/constants/unitstatus', 'Javelin' => 'infrastructure/javelin/api', 'LiskDAO' => 'storage/lisk/dao', @@ -149,7 +150,6 @@ phutil_register_library_map(array( 'ManiphestTaskListController' => 'applications/maniphest/controller/tasklist', 'ManiphestTaskListView' => 'applications/maniphest/view/tasklist', 'ManiphestTaskPriority' => 'applications/maniphest/constants/priority', - 'ManiphestTaskSelectorController' => 'applications/maniphest/controller/taskselector', 'ManiphestTaskSelectorSearchController' => 'applications/maniphest/controller/taskselectorsearch', 'ManiphestTaskStatus' => 'applications/maniphest/constants/status', 'ManiphestTaskSummaryView' => 'applications/maniphest/view/tasksummary', @@ -382,6 +382,7 @@ phutil_register_library_map(array( 'DifferentialRevisionListController' => 'DifferentialController', 'DifferentialRevisionUpdateHistoryView' => 'AphrontView', 'DifferentialRevisionViewController' => 'DifferentialController', + 'DifferentialSubscribeController' => 'DifferentialController', 'ManiphestController' => 'PhabricatorController', 'ManiphestDAO' => 'PhabricatorLiskDAO', 'ManiphestTask' => 'ManiphestDAO', @@ -389,7 +390,6 @@ phutil_register_library_map(array( 'ManiphestTaskDetailController' => 'ManiphestController', 'ManiphestTaskListController' => 'ManiphestController', 'ManiphestTaskListView' => 'AphrontView', - 'ManiphestTaskSelectorController' => 'ManiphestController', 'ManiphestTaskSelectorSearchController' => 'ManiphestController', 'ManiphestTaskSummaryView' => 'AphrontView', 'ManiphestTransaction' => 'ManiphestDAO', diff --git a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php index d2bb937c58..4664cec0e7 100644 --- a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php @@ -93,6 +93,8 @@ class AphrontDefaultApplicationConfiguration ), ), 'attach/(?P\d+)/(?P\w+)/$' => 'DifferentialAttachController', + 'subscribe/(?Padd|rem)/(?P\d+)/$' + => 'DifferentialSubscribeController', ), '/res/' => array( @@ -144,7 +146,6 @@ class AphrontDefaultApplicationConfiguration 'transaction/' => array( 'save/' => 'ManiphestTransactionSaveController', ), - 'select/$' => 'ManiphestTaskSelectorController', 'select/search/$' => 'ManiphestTaskSelectorSearchController', ), @@ -152,6 +153,7 @@ class AphrontDefaultApplicationConfiguration '/github-post-receive/(?P\d+)/(?P[^/]+)/$' => 'PhabricatorRepositoryGitHubPostReceiveController', + '/repository/' => array( '$' => 'PhabricatorRepositoryListController', 'create/$' => 'PhabricatorRepositoryCreateController', diff --git a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php index a428eb3bbf..c08b5e0b31 100644 --- a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php @@ -271,6 +271,7 @@ class DifferentialRevisionViewController extends DifferentialController { 'class' => $viewer_is_cc ? 'subscribe-rem' : 'subscribe-add', 'href' => "/differential/subscribe/{$action}/{$revision_id}/", 'name' => $viewer_is_cc ? 'Unsubscribe' : 'Subscribe', + 'sigil' => 'workflow', ); } else { $links[] = array( @@ -436,79 +437,6 @@ class DifferentialRevisionViewController extends DifferentialController { /* - protected function getRevisionActions(DifferentialRevision $revision) { - - $viewer_id = $this->getRequest()->getViewerContext()->getUserID(); - $viewer_is_owner = ($viewer_id == $revision->getOwnerID()); - $viewer_is_reviewer = - ((array_search($viewer_id, $revision->getReviewers())) !== false); - $viewer_is_cc = - ((array_search($viewer_id, $revision->getCCFBIDs())) !== false); - $status = $revision->getStatus(); - - $links = array(); - - if (!$viewer_is_owner && !$viewer_is_reviewer) { - $action = $viewer_is_cc - ? 'rem' - : 'add'; - $revision_id = $revision->getID(); - $href = "/differential/subscribe/{$action}/{$revision_id}"; - $links[] = array( - $viewer_is_cc ? 'subscribe-disabled' : 'subscribe-enabled', - {$viewer_is_cc ? 'Unsubscribe' : 'Subscribe'}, - ); - } else { - $links[] = array( - 'subscribe-disabled unavailable', - Automatically Subscribed, - ); - } - - $blast_uri = RedirectURI( - '/intern/differential/?action=tasks&fbid='.$revision->getFBID()) - ->setTier('intern'); - $links[] = array( - 'tasks', - Edit Tasks, - ); - - $engineering_repository_id = RepositoryRef::getByCallsign('E')->getID(); - $svn_revision = $revision->getSVNRevision(); - if ($status == DifferentialConstants::COMMITTED && - $svn_revision && - $revision->getRepositoryID() == $engineering_repository_id) { - $href = '/intern/push/request.php?rev='.$svn_revision; - $href = RedirectURI($href)->setTier('intern'); - $links[] = array( - 'merge', - Ask for Merge, - ); - } - - $links[] = array( - 'herald-transcript', - getFBID()} - >Herald Transcripts, - ); - $links[] = array( - 'metamta-transcript', - getFBID()} - >MetaMTA Transcripts, - ); - - - $list =
    ; - foreach ($links as $link) { - list($class, $tag) = $link; - $list->appendChild(
  • {$tag}
  • ); - } - - return $list; - - - - protected function getSandcastleURI(Diff $diff) { $uri = $this->getDiffProperty($diff, 'facebook:sandcastle_uri'); if (!$uri) { @@ -561,8 +489,6 @@ class DifferentialRevisionViewController extends DifferentialController { } - $changesets = array_psort($changesets, 'getSortKey'); - $feedback = id(new DifferentialFeedback())->loadAllWithRevision($revision); $feedback = array_merge($implied_feedback, $feedback); @@ -584,94 +510,11 @@ class DifferentialRevisionViewController extends DifferentialController { $hidden_changesets[$id] = $diff_map[$changeset->getDiffID()]; } - $revision->loadRelationships(); - $ccs = $revision->getCCFBIDs(); - $reviewers = $revision->getReviewers(); - - $actors = array_pull($feedback, 'getUserID'); - $actors[] = $revision->getOwnerID(); - - $tasks = array(); - assoc_get_by_type( - $revision->getFBID(), - 22284182462, // TODO: include issue, DIFFCAMP_TASK_ASSOC - $start = null, - $limit = null, - $pending = true, - $tasks); - memcache_dispatch(); - $tasks = array_keys($tasks); - - $preparer = new Preparer(); - $fbids = array_merge_fast( - array($actors, array($viewer_id), $reviewers, $ccs, $tasks), - true); - $handles = array(); - $handle_data = id(new ToolsHandleData($fbids, $handles)) - ->needNames() - ->needAlternateNames() - ->needAlternateIDs() - ->needThumbnails(); - $preparer->waitFor($handle_data); - $preparer->go(); - - $revision->attachTaskHandles(array_select_keys($handles, $tasks)); - - $inline_comments = array_group($inline_comments, 'getFeedbackID'); $engine = new RemarkupEngine(); $engine->enableFeature(RemarkupEngine::FEATURE_GUESS_IMAGES); $engine->enableFeature(RemarkupEngine::FEATURE_YOUTUBE); $engine->setCurrentSandcastle($this->getSandcastleURI($target_diff)); - $feed = array(); - foreach ($feedback as $comment) { - $inlines = null; - if (isset($inline_comments[$comment->getID()])) { - $inlines = $inline_comments[$comment->getID()]; - } - $feed[] = - getUserID()]} - engine={$engine} - inline={$inlines} - changesets={$changesets} - hidden={$hidden_changesets} />; - } - - $feed = $this->renderFeedbackList($feed, $feedback, $viewer_id); - - $fields = $this->getDetailFields($revision, $diff, $handles); - $table = ; - foreach ($fields as $key => $value) { - $table->appendChild( - - - ); - } - - $quick_links = $this->getQuickLinks($revision); - - - $info = -
    -
    - {$quick_links} -
    -
    -

    {$revision->getName()}{$edit_link}

    - {$table} -
    -
    ; - - $actions = $this->getRevisionActions($revision); - $revision_id = $revision->getID(); - - $content = SavedCopy::loadData( - $viewer_id, - SavedCopy::Type_DifferentialRevisionFeedback, - $revision->getFBID()); - $syntax_link = ; } - protected function getQuickLinks(DifferentialRevision $revision) { - - $viewer_id = $this->getRequest()->getViewerContext()->getUserID(); - $viewer_is_owner = ($viewer_id == $revision->getOwnerID()); - $viewer_is_reviewer = - ((array_search($viewer_id, $revision->getReviewers())) !== false); - $viewer_is_cc = - ((array_search($viewer_id, $revision->getCCFBIDs())) !== false); - $status = $revision->getStatus(); - - $links = array(); - - if (!$viewer_is_owner && !$viewer_is_reviewer) { - $action = $viewer_is_cc - ? 'rem' - : 'add'; - $revision_id = $revision->getID(); - $href = "/differential/subscribe/{$action}/{$revision_id}"; - $links[] = array( - $viewer_is_cc ? 'subscribe-disabled' : 'subscribe-enabled', - {$viewer_is_cc ? 'Unsubscribe' : 'Subscribe'}, - ); - } else { - $links[] = array( - 'subscribe-disabled unavailable', - Automatically Subscribed, - ); - } $blast_uri = RedirectURI( '/intern/differential/?action=blast&fbid='.$revision->getFBID()) @@ -727,23 +542,7 @@ class DifferentialRevisionViewController extends DifferentialController { Blast Revision, ); - $blast_uri = RedirectURI( - '/intern/differential/?action=tasks&fbid='.$revision->getFBID()) - ->setTier('intern'); - $links[] = array( - 'tasks', - Edit Tasks, - ); - if ($viewer_is_owner && false) { - $perflab_uri = RedirectURI( - '/intern/differential/?action=perflab&fbid='.$revision->getFBID()) - ->setTier('intern'); - $links[] = array( - 'perflab', - Run in Perflab, - ); - } $engineering_repository_id = RepositoryRef::getByCallsign('E')->getID(); $svn_revision = $revision->getSVNRevision(); @@ -763,20 +562,7 @@ class DifferentialRevisionViewController extends DifferentialController { getFBID()} >Herald Transcripts, ); - $links[] = array( - 'metamta-transcript', - getFBID()} - >MetaMTA Transcripts, - ); - - $list =
      ; - foreach ($links as $link) { - list($class, $tag) = $link; - $list->appendChild(
    • {$tag}
    • ); - } - - return $list; } @@ -875,10 +661,6 @@ class DifferentialRevisionViewController extends DifferentialController { Diff $diff, array $handles) { - $fields = array(); - $fields['Revision Status'] = $this->getRevisionStatusDisplay($revision); - - $sandcastle = $this->getSandcastleURI($diff); if ($sandcastle) { $fields['Sandcastle'] = {$sandcastle}; @@ -898,15 +680,6 @@ class DifferentialRevisionViewController extends DifferentialController { } } - $tasks = $revision->getTaskHandles(); - - if ($tasks) { - $links = array(); - foreach ($tasks as $task) { - $links[] = ; - } - $fields['Tasks'] = array_implode(
      , $links); - } $bugzilla_id = $revision->getBugzillaID(); if ($bugzilla_id) { diff --git a/src/applications/differential/controller/subscribe/DifferentialSubscribeController.php b/src/applications/differential/controller/subscribe/DifferentialSubscribeController.php new file mode 100644 index 0000000000..9c5f06f97d --- /dev/null +++ b/src/applications/differential/controller/subscribe/DifferentialSubscribeController.php @@ -0,0 +1,106 @@ +id = $data['id']; + $this->action = $data['action']; + } + + public function processRequest() { + + $request = $this->getRequest(); + $user = $request->getUser(); + + $revision = id(new DifferentialRevision())->load($this->id); + if (!$revision) { + return new Aphront404Response(); + } + + if (!$request->isFormPost()) { + // TODO: This dialog is silly but we're CSRF-able otherwise. + + $dialog = new AphrontDialogView(); + + switch ($this->action) { + case 'add': + $button = 'Subscribe'; + $title = 'Subscribe to Revision'; + $prompt = 'Really subscribe to this revision?'; + break; + case 'rem': + $button = 'Unsubscribe'; + $title = 'Unsubscribe from Revision'; + // TODO: Once herald is in, add a notice about not getting any more + // herald notifications. + $prompt = 'Really unsubscribe from this revision?'; + break; + default: + return new Aphront400Response(); + } + + $dialog + ->setUser($user) + ->setTitle($title) + ->appendChild('

      '.$prompt.'

      ') + ->setSubmitURI($request->getRequestURI()) + ->addSubmitButton($button) + ->addCancelButton('/D'.$revision->getID()); + + return id(new AphrontDialogResponse())->setDialog($dialog); + } + + $revision->loadRelationships(); + $phid = $user->getPHID(); + + switch ($this->action) { + case 'add': + DifferentialRevisionEditor::addCC( + $revision, + $phid, + $phid); + $unsubscribed = $revision->getUnsubscribed(); + if (isset($unsubscribed[$phid])) { + unset($unsubscribed[$phid]); + $revision->setUnsubscribed($unsubscribed); + $revision->save(); + } + break; + case 'rem': + DifferentialRevisionEditor::removeCC( + $revision, + $user->getPHID(), + $user->getPHID()); + $unsubscribed = $revision->getUnsubscribed(); + if (empty($unsubscribed[$phid])) { + $unsubscribed[$phid] = true; + $revision->setUnsubscribed($unsubscribed); + $revision->save(); + } + break; + default: + return new Aphront400Response(); + } + + return id(new AphrontRedirectResponse())->setURI('/D'.$revision->getID()); + } +} diff --git a/src/applications/differential/controller/subscribe/__init__.php b/src/applications/differential/controller/subscribe/__init__.php new file mode 100644 index 0000000000..316ced79bd --- /dev/null +++ b/src/applications/differential/controller/subscribe/__init__.php @@ -0,0 +1,21 @@ +getCCPHIDs(), + $rem = array(), + $add = array($phid), + $reason); + } + + public static function removeCC( + DifferentialRevision $revision, + $phid, + $reason) { + return self::alterCCs( + $revision, + $revision->getCCPHIDs(), + $rem = array($phid), + $add = array(), + $reason); + } + protected static function alterCCs( DifferentialRevision $revision, array $stable_phids, diff --git a/src/applications/differential/storage/revision/DifferentialRevision.php b/src/applications/differential/storage/revision/DifferentialRevision.php index 7d139d57a4..a99c16ec59 100755 --- a/src/applications/differential/storage/revision/DifferentialRevision.php +++ b/src/applications/differential/storage/revision/DifferentialRevision.php @@ -33,6 +33,7 @@ class DifferentialRevision extends DifferentialDAO { protected $lineCount; protected $attached = array(); + protected $unsubscribed = array(); private $relationships; @@ -40,13 +41,13 @@ class DifferentialRevision extends DifferentialDAO { const RELATION_REVIEWER = 'revw'; const RELATION_SUBSCRIBED = 'subd'; - const RELATION_UNSUBSCRIBED = 'usub'; public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, self::CONFIG_SERIALIZATION => array( - 'attached' => self::SERIALIZATION_JSON, + 'attached' => self::SERIALIZATION_JSON, + 'unsubscribed' => self::SERIALIZATION_JSON, ), ) + parent::getConfiguration(); } diff --git a/src/applications/maniphest/controller/taskselector/ManiphestTaskSelectorController.php b/src/applications/maniphest/controller/taskselector/ManiphestTaskSelectorController.php deleted file mode 100644 index 94b0e3fe5b..0000000000 --- a/src/applications/maniphest/controller/taskselector/ManiphestTaskSelectorController.php +++ /dev/null @@ -1,50 +0,0 @@ -getRequest(); - $user = $request->getUser(); - - $phids = $request->getArr('phids'); - - $handles = id(new PhabricatorObjectHandleData($phids)) - ->loadHandles(); - - $obj_dialog = new PhabricatorObjectSelectorDialog(); - $obj_dialog - ->setUser($user) - ->setHandles($handles) - ->setFilters(array( - 'assigned' => 'Assigned to Me', - 'created' => 'Created By Me', - 'open' => 'All Open Tasks', - 'all' => 'All Tasks', - )) - ->setCancelURI('#') - ->setSearchURI('/maniphest/select/search/') - ->setNoun('Tasks'); - - $dialog = $obj_dialog->buildDialog(); - - - return id(new AphrontDialogResponse())->setDialog($dialog); - } - -} diff --git a/src/applications/maniphest/controller/taskselector/__init__.php b/src/applications/maniphest/controller/taskselector/__init__.php deleted file mode 100644 index cf69aa48ca..0000000000 --- a/src/applications/maniphest/controller/taskselector/__init__.php +++ /dev/null @@ -1,17 +0,0 @@ -
    {$key}:{$value}