Add "Flags" to allow users to collect the things they love
Summary: Flags are a personal collection of things you want to take a look at later. You can use several different colors and add notes. Not really sure if this is actually a good idea or not but it was easy to build. Planned features: - Allow Herald rules to add flags. - In the "edit flag" dialog, have a "[x] Subscribe Me" checkbox that CCs you. - Support Diffusion. - Support Phriction. - Always show flags on an object if you have them (in every view)? - Edit dialog feels a little heavy? - More filtering in /flag/ tool. - Add a top-level links somewhere? Test Plan: Added, edited and removed flags from things. Viewed flags in flag view. Reviewers: aran, btrahan Reviewed By: btrahan CC: aran, epriestley, Koolvin Maniphest Tasks: T1041 Differential Revision: https://secure.phabricator.com/D2024
This commit is contained in:
@@ -164,13 +164,20 @@ final class DifferentialRevisionListController extends DifferentialController {
|
||||
|
||||
$views = $this->buildViews($this->filter, $params['phid'], $revisions);
|
||||
|
||||
$view_objects = ipull($views, 'view');
|
||||
$view_objects = array();
|
||||
foreach ($views as $view) {
|
||||
if (empty($view['special'])) {
|
||||
$view_objects[] = $view['view'];
|
||||
}
|
||||
}
|
||||
$phids = array_mergev(mpull($view_objects, 'getRequiredHandlePHIDs'));
|
||||
$phids[] = $params['phid'];
|
||||
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
||||
|
||||
foreach ($views as $view) {
|
||||
$view['view']->setHandles($handles);
|
||||
if (empty($view['special'])) {
|
||||
$view['view']->setHandles($handles);
|
||||
}
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader($view['title']);
|
||||
$panel->appendChild($view['view']);
|
||||
@@ -436,6 +443,26 @@ final class DifferentialRevisionListController extends DifferentialController {
|
||||
'view' => $view,
|
||||
);
|
||||
|
||||
// Flags are sort of private, so only show the flag panel if you're
|
||||
// looking at your own requests.
|
||||
if ($user_phid == $user->getPHID()) {
|
||||
$flags = id(new PhabricatorFlagQuery())
|
||||
->withOwnerPHIDs(array($user_phid))
|
||||
->withTypes(array(PhabricatorPHIDConstants::PHID_TYPE_DREV))
|
||||
->needHandles(true)
|
||||
->execute();
|
||||
|
||||
$view = id(new PhabricatorFlagListView())
|
||||
->setFlags($flags)
|
||||
->setUser($user);
|
||||
|
||||
$views[] = array(
|
||||
'title' => 'Flagged Revisions',
|
||||
'view' => $view,
|
||||
'special' => true,
|
||||
);
|
||||
}
|
||||
|
||||
$view = id(clone $template)
|
||||
->setRevisions($waiting)
|
||||
->setNoDataString("You have no active revisions waiting on others.");
|
||||
|
||||
@@ -11,7 +11,10 @@ phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||
phutil_require_module('phabricator', 'applications/differential/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/differential/query/revision');
|
||||
phutil_require_module('phabricator', 'applications/differential/view/revisionlist');
|
||||
phutil_require_module('phabricator', 'applications/flag/query/flag');
|
||||
phutil_require_module('phabricator', 'applications/flag/view/list');
|
||||
phutil_require_module('phabricator', 'applications/people/storage/user');
|
||||
phutil_require_module('phabricator', 'applications/phid/constants');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||
phutil_require_module('phabricator', 'view/control/pager');
|
||||
phutil_require_module('phabricator', 'view/form/base');
|
||||
|
||||
@@ -358,7 +358,8 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||
}
|
||||
|
||||
private function getRevisionActions(DifferentialRevision $revision) {
|
||||
$viewer_phid = $this->getRequest()->getUser()->getPHID();
|
||||
$user = $this->getRequest()->getUser();
|
||||
$viewer_phid = $user->getPHID();
|
||||
$viewer_is_owner = ($revision->getAuthorPHID() == $viewer_phid);
|
||||
$viewer_is_reviewer = in_array($viewer_phid, $revision->getReviewers());
|
||||
$viewer_is_cc = in_array($viewer_phid, $revision->getCCPHIDs());
|
||||
@@ -378,6 +379,28 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||
}
|
||||
|
||||
if (!$viewer_is_anonymous) {
|
||||
|
||||
require_celerity_resource('phabricator-flag-css');
|
||||
|
||||
$flag = PhabricatorFlagQuery::loadUserFlag($user, $revision_phid);
|
||||
if ($flag) {
|
||||
$class = PhabricatorFlagColor::getCSSClass($flag->getColor());
|
||||
$color = PhabricatorFlagColor::getColorName($flag->getColor());
|
||||
$links[] = array(
|
||||
'class' => 'flag-clear '.$class,
|
||||
'href' => '/flag/delete/'.$flag->getID().'/',
|
||||
'name' => phutil_escape_html('Remove '.$color.' Flag'),
|
||||
'sigil' => 'workflow',
|
||||
);
|
||||
} else {
|
||||
$links[] = array(
|
||||
'class' => 'flag-add phabricator-flag-ghost',
|
||||
'href' => '/flag/edit/'.$revision_phid.'/',
|
||||
'name' => 'Flag Revision',
|
||||
'sigil' => 'workflow',
|
||||
);
|
||||
}
|
||||
|
||||
if (!$viewer_is_owner && !$viewer_is_reviewer) {
|
||||
$action = $viewer_is_cc ? 'rem' : 'add';
|
||||
$links[] = array(
|
||||
|
||||
@@ -28,6 +28,8 @@ phutil_require_module('phabricator', 'applications/differential/view/revisioncom
|
||||
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/flag/constants/color');
|
||||
phutil_require_module('phabricator', 'applications/flag/query/flag');
|
||||
phutil_require_module('phabricator', 'applications/markup/syntax');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
||||
|
||||
Reference in New Issue
Block a user