2011-01-16 22:51:39 +01:00
|
|
|
<?php
|
|
|
|
|
2014-01-26 21:26:13 +01:00
|
|
|
abstract class PhabricatorHomeController extends PhabricatorController {
|
2011-01-16 22:51:39 +01:00
|
|
|
|
|
|
|
public function buildStandardPageResponse($view, array $data) {
|
2011-01-26 22:21:12 +01:00
|
|
|
$page = $this->buildStandardPageView();
|
2011-01-16 22:51:39 +01:00
|
|
|
|
|
|
|
$page->setBaseURI('/');
|
|
|
|
$page->setTitle(idx($data, 'title'));
|
2011-05-17 19:59:26 +02:00
|
|
|
|
2011-01-16 22:51:39 +01:00
|
|
|
$page->setGlyph("\xE2\x9A\x92");
|
|
|
|
$page->appendChild($view);
|
|
|
|
|
|
|
|
$response = new AphrontWebpageResponse();
|
|
|
|
return $response->setContent($page->render());
|
|
|
|
}
|
|
|
|
|
Replace home directory list with a dashboard
Summary:
Rough cut that still needs a lot of polish, but replace the directory list with
more of a dashboard type thing:
- Show "Unbreak Now", triage-in-your-projects, and other stuff that you're
supposed to deal with, then feed.
- Move tools a click a way behind nav -- this also lets us put more stuff
there and subtools, etc., later.
- Remove tabs.
- Merge the category/item editing views.
- I also added a light blue wash to the side nav, not sure if I like that or
not.
Test Plan:
- Viewed all elements in empty and nonempty states.
- Viewed applications, edited items/categories.
Reviewers: btrahan, aran
Reviewed By: btrahan
CC: aran, epriestley, davidreuss
Maniphest Tasks: T21, T631
Differential Revision: https://secure.phabricator.com/D1574
2012-02-08 01:04:48 +01:00
|
|
|
public function buildNav() {
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$nav = new AphrontSideNavFilterView();
|
|
|
|
$nav->setBaseURI(new PhutilURI('/'));
|
|
|
|
|
If a user can't see an application, prevent them from using its controllers
Summary:
Ref T603. Broadly, this allows you to implement a policy like "Only users in Engineering can use Differential."
This isn't complete, and there will be a long tail of special cases to deal with. Some examples:
- If you can't use Differential, should you still be able to attach/detach revisions from tasks?
- You currently will be able to.
- This actually seems pretty reasonable.
- But in other cases it might not be: the "send user a message" action should probably require access to Conpherence.
- If you can't use Differential, should you still be able to see feed stories about it?
- You currently will be able to, if you can see the revisions.
- This seems not-so-reasonable and we should probably lock it down.
- If you can't use Differential, can users CC you on revisions?
- Currently, they can, and you can't do anything about it.
- Probably they shouldn't be able to? This seems challenging to explain in the UI.
- If you can't use Differential, can you write a Herald rule against it?
- You currently will be able to.
- Seems like you obviously shouldn't be able to.
- I think this is a general issue right now (you can still write Differential herald rules even if you uninstall the application, I believe).
There are probably a few more things I haven't thought of. However, there are a finite number of these things and I suspect there aren't //too/ many more than this -- I can't come up with like 100 of them, and half of the ones above have easy fixes.
Despite the rough edges, I think this accomplishes 95% of what installs expect from it.
Test Plan: Restricted Differential and saw it vanish from the home page.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T603
Differential Revision: https://secure.phabricator.com/D7203
2013-10-03 21:39:41 +02:00
|
|
|
$applications = id(new PhabricatorApplicationQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withInstalled(true)
|
2014-03-14 19:53:17 +01:00
|
|
|
->withUnlisted(false)
|
If a user can't see an application, prevent them from using its controllers
Summary:
Ref T603. Broadly, this allows you to implement a policy like "Only users in Engineering can use Differential."
This isn't complete, and there will be a long tail of special cases to deal with. Some examples:
- If you can't use Differential, should you still be able to attach/detach revisions from tasks?
- You currently will be able to.
- This actually seems pretty reasonable.
- But in other cases it might not be: the "send user a message" action should probably require access to Conpherence.
- If you can't use Differential, should you still be able to see feed stories about it?
- You currently will be able to, if you can see the revisions.
- This seems not-so-reasonable and we should probably lock it down.
- If you can't use Differential, can users CC you on revisions?
- Currently, they can, and you can't do anything about it.
- Probably they shouldn't be able to? This seems challenging to explain in the UI.
- If you can't use Differential, can you write a Herald rule against it?
- You currently will be able to.
- Seems like you obviously shouldn't be able to.
- I think this is a general issue right now (you can still write Differential herald rules even if you uninstall the application, I believe).
There are probably a few more things I haven't thought of. However, there are a finite number of these things and I suspect there aren't //too/ many more than this -- I can't come up with like 100 of them, and half of the ones above have easy fixes.
Despite the rough edges, I think this accomplishes 95% of what installs expect from it.
Test Plan: Restricted Differential and saw it vanish from the home page.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T603
Differential Revision: https://secure.phabricator.com/D7203
2013-10-03 21:39:41 +02:00
|
|
|
->execute();
|
2013-01-16 00:41:22 +01:00
|
|
|
|
|
|
|
foreach ($applications as $key => $application) {
|
|
|
|
if (!$application->shouldAppearInLaunchView()) {
|
2013-01-16 18:00:11 +01:00
|
|
|
// Remove hidden applications (usually internal stuff).
|
|
|
|
unset($applications[$key]);
|
|
|
|
}
|
|
|
|
$invisible = PhabricatorApplication::TILE_INVISIBLE;
|
|
|
|
if ($application->getDefaultTileDisplay($user) == $invisible) {
|
|
|
|
// Remove invisible applications (e.g., admin apps for non-admins).
|
2013-01-16 00:41:22 +01:00
|
|
|
unset($applications[$key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-16 18:00:11 +01:00
|
|
|
$status = array();
|
|
|
|
foreach ($applications as $key => $application) {
|
|
|
|
$status[get_class($application)] = $application->loadStatus($user);
|
|
|
|
}
|
2013-01-16 00:41:22 +01:00
|
|
|
|
2013-01-16 18:00:11 +01:00
|
|
|
$tile_groups = array();
|
|
|
|
$prefs = $user->loadPreferences()->getPreference(
|
|
|
|
PhabricatorUserPreferences::PREFERENCE_APP_TILES,
|
|
|
|
array());
|
|
|
|
foreach ($applications as $key => $application) {
|
|
|
|
$display = idx(
|
|
|
|
$prefs,
|
|
|
|
get_class($application),
|
|
|
|
$application->getDefaultTileDisplay($user));
|
|
|
|
$tile_groups[$display][] = $application;
|
|
|
|
}
|
2013-01-16 00:41:22 +01:00
|
|
|
|
2013-01-16 18:00:11 +01:00
|
|
|
$tile_groups = array_select_keys(
|
|
|
|
$tile_groups,
|
|
|
|
array(
|
|
|
|
PhabricatorApplication::TILE_FULL,
|
|
|
|
PhabricatorApplication::TILE_SHOW,
|
|
|
|
PhabricatorApplication::TILE_HIDE,
|
|
|
|
));
|
|
|
|
|
|
|
|
foreach ($tile_groups as $tile_display => $tile_group) {
|
|
|
|
if (!$tile_group) {
|
|
|
|
continue;
|
2013-01-16 00:41:22 +01:00
|
|
|
}
|
|
|
|
|
2013-01-16 18:00:11 +01:00
|
|
|
$is_small_tiles = ($tile_display == PhabricatorApplication::TILE_SHOW) ||
|
|
|
|
($tile_display == PhabricatorApplication::TILE_HIDE);
|
2013-01-16 00:41:37 +01:00
|
|
|
|
2013-01-16 18:00:11 +01:00
|
|
|
if ($is_small_tiles) {
|
|
|
|
$groups = PhabricatorApplication::getApplicationGroups();
|
|
|
|
$tile_group = mgroup($tile_group, 'getApplicationGroup');
|
|
|
|
$tile_group = array_select_keys($tile_group, array_keys($groups));
|
|
|
|
} else {
|
|
|
|
$tile_group = array($tile_group);
|
2013-01-16 00:41:22 +01:00
|
|
|
}
|
|
|
|
|
2013-01-16 18:00:11 +01:00
|
|
|
$is_hide = ($tile_display == PhabricatorApplication::TILE_HIDE);
|
|
|
|
if ($is_hide) {
|
|
|
|
$show_item_id = celerity_generate_unique_node_id();
|
2013-02-05 16:43:58 +01:00
|
|
|
$hide_item_id = celerity_generate_unique_node_id();
|
2013-01-16 18:00:11 +01:00
|
|
|
|
2013-06-05 17:41:43 +02:00
|
|
|
$show_item = id(new PHUIListItemView())
|
2013-01-16 18:00:11 +01:00
|
|
|
->setName(pht('Show More Applications'))
|
|
|
|
->setHref('#')
|
2013-02-17 15:37:02 +01:00
|
|
|
->addSigil('reveal-content')
|
2013-01-16 18:00:11 +01:00
|
|
|
->setID($show_item_id);
|
|
|
|
|
2013-06-05 17:41:43 +02:00
|
|
|
$hide_item = id(new PHUIListItemView())
|
2013-01-16 18:00:11 +01:00
|
|
|
->setName(pht('Show Fewer Applications'))
|
|
|
|
->setHref('#')
|
2013-02-05 16:43:58 +01:00
|
|
|
->setStyle('display: none')
|
|
|
|
->setID($hide_item_id)
|
2013-02-17 15:37:02 +01:00
|
|
|
->addSigil('reveal-content');
|
2013-01-16 18:00:11 +01:00
|
|
|
|
|
|
|
$nav->addMenuItem($show_item);
|
2013-02-05 16:43:58 +01:00
|
|
|
$tile_ids = array($hide_item_id);
|
2013-01-16 00:41:22 +01:00
|
|
|
}
|
|
|
|
|
2013-01-16 18:00:11 +01:00
|
|
|
foreach ($tile_group as $group => $application_list) {
|
|
|
|
$tiles = array();
|
|
|
|
foreach ($application_list as $key => $application) {
|
|
|
|
$tile = id(new PhabricatorApplicationLaunchView())
|
|
|
|
->setApplication($application)
|
|
|
|
->setApplicationStatus(
|
|
|
|
idx($status, get_class($application), array()))
|
|
|
|
->setUser($user);
|
|
|
|
|
|
|
|
$tiles[] = $tile;
|
|
|
|
}
|
|
|
|
|
2013-02-05 16:43:58 +01:00
|
|
|
$group_id = celerity_generate_unique_node_id();
|
|
|
|
$tile_ids[] = $group_id;
|
2013-01-16 18:00:11 +01:00
|
|
|
$nav->addCustomBlock(
|
2013-02-02 15:12:36 +01:00
|
|
|
phutil_tag(
|
2013-01-16 18:00:11 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'application-tile-group',
|
2013-02-05 16:43:58 +01:00
|
|
|
'id' => $group_id,
|
|
|
|
'style' => ($is_hide ? 'display: none' : null),
|
2013-01-16 18:00:11 +01:00
|
|
|
),
|
2013-02-02 15:12:36 +01:00
|
|
|
mpull($tiles, 'render')));
|
2013-01-16 18:00:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($is_hide) {
|
2013-02-17 15:37:02 +01:00
|
|
|
Javelin::initBehavior('phabricator-reveal-content');
|
|
|
|
|
|
|
|
$show_item->setMetadata(
|
|
|
|
array(
|
|
|
|
'showIDs' => $tile_ids,
|
|
|
|
'hideIDs' => array($show_item_id),
|
|
|
|
));
|
|
|
|
$hide_item->setMetadata(
|
|
|
|
array(
|
|
|
|
'showIDs' => array($show_item_id),
|
|
|
|
'hideIDs' => $tile_ids,
|
|
|
|
));
|
2013-01-16 18:00:11 +01:00
|
|
|
$nav->addMenuItem($hide_item);
|
|
|
|
}
|
2013-01-16 00:41:22 +01:00
|
|
|
}
|
|
|
|
|
Add support for aural-only and visual-only elements
Summary:
Ref T4843. This adds support to `javelin_tag()` for an `aural` attribute. When specified, `true` values mean "this content is aural-only", while `false` values mean "this content is not aural".
- I've attempted to find the best modern approaches for marking this content, but the `aural` attribute should let us change the mechanism later.
- Make the "beta" markers on application navigation visual only (see T4843). This information is of very low importance, the application navigation is accessed frequently, and the information is available on the application list.
- Partially convert the main navigation. This is mostly to test things, since I want to get more concrete feedback about approaches here.
- Add a `?__aural__=1` attribute, which renders the page with aural-only elements visible and visual-only elements colored.
Test Plan: {F146476}
Reviewers: btrahan, scp, chad
Reviewed By: chad
Subscribers: aklapper, qgil, epriestley
Maniphest Tasks: T4843
Differential Revision: https://secure.phabricator.com/D8830
2014-05-01 16:18:18 +02:00
|
|
|
$nav->addFilter(
|
2013-01-16 18:00:11 +01:00
|
|
|
'',
|
|
|
|
pht('Customize Applications...'),
|
|
|
|
'/settings/panel/home/');
|
2013-01-16 00:41:22 +01:00
|
|
|
$nav->addClass('phabricator-side-menu-home');
|
|
|
|
$nav->selectFilter(null);
|
Replace home directory list with a dashboard
Summary:
Rough cut that still needs a lot of polish, but replace the directory list with
more of a dashboard type thing:
- Show "Unbreak Now", triage-in-your-projects, and other stuff that you're
supposed to deal with, then feed.
- Move tools a click a way behind nav -- this also lets us put more stuff
there and subtools, etc., later.
- Remove tabs.
- Merge the category/item editing views.
- I also added a light blue wash to the side nav, not sure if I like that or
not.
Test Plan:
- Viewed all elements in empty and nonempty states.
- Viewed applications, edited items/categories.
Reviewers: btrahan, aran
Reviewed By: btrahan
CC: aran, epriestley, davidreuss
Maniphest Tasks: T21, T631
Differential Revision: https://secure.phabricator.com/D1574
2012-02-08 01:04:48 +01:00
|
|
|
|
|
|
|
return $nav;
|
|
|
|
}
|
|
|
|
|
2011-01-16 22:51:39 +01:00
|
|
|
}
|