Page MenuHomePhabricator

space-switching-ui.patch

Authored By
devurandom
Jul 28 2015, 4:59 PM
Size
8 KB
Referenced Files
None
Subscribers
None

space-switching-ui.patch

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
index d98c746..5650350 100644
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2230,6 +2230,7 @@ phutil_register_library_map(array(
'PhabricatorMailTarget' => 'applications/metamta/replyhandler/PhabricatorMailTarget.php',
'PhabricatorMailgunConfigOptions' => 'applications/config/option/PhabricatorMailgunConfigOptions.php',
'PhabricatorMainMenuSearchView' => 'view/page/menu/PhabricatorMainMenuSearchView.php',
+ 'PhabricatorMainMenuSpacesView' => 'view/page/menu/PhabricatorMainMenuSpacesView.php',
'PhabricatorMainMenuView' => 'view/page/menu/PhabricatorMainMenuView.php',
'PhabricatorManagementWorkflow' => 'infrastructure/management/PhabricatorManagementWorkflow.php',
'PhabricatorManiphestApplication' => 'applications/maniphest/application/PhabricatorManiphestApplication.php',
@@ -6099,6 +6100,7 @@ phutil_register_library_map(array(
'PhabricatorMailTarget' => 'Phobject',
'PhabricatorMailgunConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorMainMenuSearchView' => 'AphrontView',
+ 'PhabricatorMainMenuSpacesView' => 'AphrontView',
'PhabricatorMainMenuView' => 'AphrontView',
'PhabricatorManagementWorkflow' => 'PhutilArgumentWorkflow',
'PhabricatorManiphestApplication' => 'PhabricatorApplication',
diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php
index 7fbc806..ec2a2d1 100644
--- a/src/applications/maniphest/storage/ManiphestTask.php
+++ b/src/applications/maniphest/storage/ManiphestTask.php
@@ -52,13 +52,21 @@ final class ManiphestTask extends ManiphestDAO
$view_policy = $app->getPolicy(ManiphestDefaultViewCapability::CAPABILITY);
$edit_policy = $app->getPolicy(ManiphestDefaultEditCapability::CAPABILITY);
+ $current_space_key = PhabricatorUserPreferences::PREFERENCE_CURRENT_SPACE;
+ $space_phid = $actor->loadPreferences()->getPreference(
+ $current_space_key,
+ 'all');
+ if ($space_phid === null) {
+ $space_phid = $actor->getDefaultSpacePHID();
+ }
+
return id(new ManiphestTask())
->setStatus(ManiphestTaskStatus::getDefaultStatus())
->setPriority(ManiphestTaskPriority::getDefaultPriority())
->setAuthorPHID($actor->getPHID())
->setViewPolicy($view_policy)
->setEditPolicy($edit_policy)
- ->setSpacePHID($actor->getDefaultSpacePHID())
+ ->setSpacePHID($space_phid)
->attachProjectPHIDs(array())
->attachSubscriberPHIDs(array());
}
diff --git a/src/applications/settings/storage/PhabricatorUserPreferences.php b/src/applications/settings/storage/PhabricatorUserPreferences.php
index 1527f28..8c876b4 100644
--- a/src/applications/settings/storage/PhabricatorUserPreferences.php
+++ b/src/applications/settings/storage/PhabricatorUserPreferences.php
@@ -41,6 +41,8 @@ final class PhabricatorUserPreferences extends PhabricatorUserDAO {
const PREFERENCE_RESOURCE_POSTPROCESSOR = 'resource-postprocessor';
const PREFERENCE_DESKTOP_NOTIFICATIONS = 'desktop-notifications';
+ const PREFERENCE_CURRENT_SPACE = 'current-space';
+
// These are in an unusual order for historic reasons.
const MAILTAG_PREFERENCE_NOTIFY = 0;
const MAILTAG_PREFERENCE_EMAIL = 1;
diff --git a/src/view/page/menu/PhabricatorMainMenuView.php b/src/view/page/menu/PhabricatorMainMenuView.php
index 1dc8466..281d60d 100644
--- a/src/view/page/menu/PhabricatorMainMenuView.php
+++ b/src/view/page/menu/PhabricatorMainMenuView.php
@@ -52,6 +52,7 @@ final class PhabricatorMainMenuView extends AphrontView {
}
$search_menu = $this->renderPhabricatorSearchMenu();
+ $spaces_menu = $this->renderPhabricatorSpacesMenu();
if ($alerts) {
$alerts = javelin_tag(
@@ -98,6 +99,7 @@ final class PhabricatorMainMenuView extends AphrontView {
$aural,
$application_menu,
$search_menu,
+ $spaces_menu,
$menus,
));
}
@@ -149,6 +151,32 @@ final class PhabricatorMainMenuView extends AphrontView {
return $result;
}
+ private function renderSpaces() {
+ $user = $this->user;
+
+ $result = null;
+
+ $show_spaces = false;
+ if ($user->isLoggedIn()) {
+ $show_spaces = $user->isUserActivated();
+ }
+
+ if ($show_spaces) {
+ $spaces = new PhabricatorMainMenuSpacesView();
+ $spaces->setUser($user);
+
+ $result = $spaces;
+ }
+
+ if ($result) {
+ $result = id(new PHUIListItemView())
+ ->addClass('phabricator-main-menu-spaces')
+ ->appendChild($result);
+ }
+
+ return $result;
+ }
+
public function renderApplicationMenuButton($header_id) {
$button_id = celerity_generate_unique_node_id();
return javelin_tag(
@@ -251,6 +279,20 @@ final class PhabricatorMainMenuView extends AphrontView {
return $view;
}
+ private function renderPhabricatorSpacesMenu() {
+
+ $view = new PHUIListView();
+ $view->addClass('phabricator-dark-menu');
+ $view->addClass('phabricator-spaces-menu');
+
+ $spaces = $this->renderSpaces();
+ if ($spaces) {
+ $view->addMenuItem($spaces);
+ }
+
+ return $view;
+ }
+
private function renderPhabricatorLogo() {
$style_logo = null;
$custom_header = PhabricatorEnv::getEnvConfig('ui.custom-header');
diff --git a/webroot/rsrc/css/application/base/main-menu-view.css b/webroot/rsrc/css/application/base/main-menu-view.css
index b70e0b7..8c302ea 100644
--- a/webroot/rsrc/css/application/base/main-menu-view.css
+++ b/webroot/rsrc/css/application/base/main-menu-view.css
@@ -96,7 +96,8 @@
}
.phabricator-expand-application-menu,
-.phabricator-expand-search-menu {
+.phabricator-expand-search-menu,
+.phabricator-expand-spaces-menu {
float: right;
}
@@ -340,6 +341,125 @@ button.phabricator-main-menu-search-dropdown .caret:before {
+/* - Spaces --------------------------------------------------------------------
+
+ The main spaces selector in the menu bar.
+
+*/
+
+.device-desktop .phabricator-main-menu-spaces {
+ width: 220px;
+}
+
+.device .phabricator-main-menu-spaces {
+ height: 40px;
+}
+
+.phabricator-main-menu-spaces-container {
+ padding: 8px 0;
+ position: relative;
+ height: 24px;
+ margin: 0 8px;
+}
+
+.device .phabricator-main-menu-search-container {
+ padding: 4px 0;
+}
+
+.phabricator-main-menu-spaces button {
+// color: {$bluetext};
+ color: #fff;
+ position: absolute;
+ background: {$greybackground};
+ border: none;
+ outline: none;
+ box-shadow: none;
+ text-shadow: none;
+ min-width: 0;
+ height: 24px;
+ width: 28px;
+ top: 10px;
+ right: -6px;
+ margin: 0 8px 0 0;
+ padding: 0;
+ border-radius: 0;
+}
+
+.phabricator-main-menu-spaces button.phabricator-main-menu-spaces-dropdown {
+ position: absolute;
+ right: auto;
+ left: -45px;
+ width: 200px;
+ background: transparent;
+}
+
+.device-desktop .phabricator-main-menu-spaces
+ button.phabricator-main-menu-spaces-dropdown {
+ height: 28px;
+ top: 8px;
+ }
+
+.device-desktop .phabricator-main-menu-spaces
+ button.phabricator-main-menu-spaces-dropdown:hover .phui-icon-view {
+ color: #fff;
+}
+
+.device .phabricator-main-menu-spaces
+ button.phabricator-main-menu-spaces-dropdown {
+ left: 2px;
+ background: {$greybackground};
+}
+
+button.phabricator-main-menu-spaces-dropdown .caret:before {
+ content: "\f107";
+ font-family: FontAwesome;
+ color: {$hoverwhite};
+}
+
+.phabricator-main-menu-spaces button.phabricator-main-menu-spaces-dropdown
+ .phui-icon-view {
+ color: {$hoverwhite};
+ font-size: 15px;
+ top: 6px;
+ left: 8px;
+}
+
+.device
+ .phabricator-main-menu-spaces button.phabricator-main-menu-spaces-dropdown
+ .phui-icon-view {
+ color: {$bluetext};
+}
+
+.device button.phabricator-main-menu-spaces-dropdown .caret:before {
+ color: {$bluetext};
+}
+
+.phabricator-main-menu-spaces-dropdown .caret {
+ position: absolute;
+ right: 15px;
+ top: 5px;
+ border: none;
+ margin-top: 1px;
+}
+
+.phabricator-main-menu-spaces button:hover {
+ color: {$sky};
+}
+
+.device .phabricator-main-menu-spaces button {
+ top: 6px;
+ border-radius: 0;
+ height: 28px;
+ right: -6px;
+}
+
+.device .phabricator-application-menu-expanded.phabricator-spaces-menu-expanded
+ .phabricator-spaces-menu {
+ padding: 0;
+}
+
+
+
/* - Alert ---------------------------------------------------------------------
Alert menus are like icon menus but don't obey collapse rules.
@@ -460,6 +580,7 @@ button.phabricator-main-menu-search-dropdown .caret:before {
display: none;
}
+.device-desktop .phabricator-spaces-menu,
.device-desktop .phabricator-search-menu {
float: right;
}

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/co/ho/ywbrwnwscpn76fya
Default Alt Text
space-switching-ui.patch (8 KB)

Event Timeline