Page MenuHomePhabricator

D16797.id40458.diff
No OneTemporary

D16797.id40458.diff

diff --git a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php
--- a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php
+++ b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php
@@ -405,11 +405,11 @@
}
protected function getNewUserBody() {
- $create_button = id(new PHUIButtonView())
- ->setTag('a')
- ->setText(pht('Create a Task'))
- ->setHref('/maniphest/task/edit/')
- ->setColor(PHUIButtonView::GREEN);
+ $viewer = $this->requireViewer();
+
+ $create_button = id(new ManiphestEditEngine())
+ ->setViewer($viewer)
+ ->newNUXBUtton(pht('Create a Task'));
$icon = $this->getApplication()->getIcon();
$app_name = $this->getApplication()->getName();
diff --git a/src/applications/paste/query/PhabricatorPasteSearchEngine.php b/src/applications/paste/query/PhabricatorPasteSearchEngine.php
--- a/src/applications/paste/query/PhabricatorPasteSearchEngine.php
+++ b/src/applications/paste/query/PhabricatorPasteSearchEngine.php
@@ -204,11 +204,11 @@
}
protected function getNewUserBody() {
- $create_button = id(new PHUIButtonView())
- ->setTag('a')
- ->setText(pht('Create a Paste'))
- ->setHref('/paste/create/')
- ->setColor(PHUIButtonView::GREEN);
+ $viewer = $this->requireViewer();
+
+ $create_button = id(new PhabricatorPasteEditEngine())
+ ->setViewer($viewer)
+ ->newNUXButton(pht('Create a Paste'));
$icon = $this->getApplication()->getIcon();
$app_name = $this->getApplication()->getName();
diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php
--- a/src/applications/transactions/editengine/PhabricatorEditEngine.php
+++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php
@@ -1352,11 +1352,80 @@
}
+ public function newNUXButton($text) {
+ $specs = $this->newCreateActionSpecifications(array());
+ $head = head($specs);
+
+ return id(new PHUIButtonView())
+ ->setTag('a')
+ ->setText($text)
+ ->setHref($head['uri'])
+ ->setDisabled($head['disabled'])
+ ->setWorkflow($head['workflow'])
+ ->setColor(PHUIButtonView::GREEN);
+ }
+
+
final public function addActionToCrumbs(
PHUICrumbsView $crumbs,
array $parameters = array()) {
$viewer = $this->getViewer();
+ $specs = $this->newCreateActionSpecifications($parameters);
+
+ $head = head($specs);
+ $menu_uri = $head['uri'];
+
+ $dropdown = null;
+ if (count($specs) > 1) {
+ $menu_icon = 'fa-caret-square-o-down';
+ $menu_name = $this->getObjectCreateShortText();
+ $workflow = false;
+ $disabled = false;
+
+ $dropdown = id(new PhabricatorActionListView())
+ ->setUser($viewer);
+
+ foreach ($specs as $spec) {
+ $dropdown->addAction(
+ id(new PhabricatorActionView())
+ ->setName($spec['name'])
+ ->setIcon($spec['icon'])
+ ->setHref($spec['uri']))
+ ->setDisabled($head['disabled'])
+ ->setWorkflow($head['workflow']);
+ }
+
+ } else {
+ $menu_icon = $head['icon'];
+ $menu_name = $head['name'];
+
+ $workflow = $head['workflow'];
+ $disabled = $head['disabled'];
+ }
+
+ $action = id(new PHUIListItemView())
+ ->setName($menu_name)
+ ->setHref($menu_uri)
+ ->setIcon($menu_icon)
+ ->setWorkflow($workflow)
+ ->setDisabled($disabled);
+
+ if ($dropdown) {
+ $action->setDropdownMenu($dropdown);
+ }
+
+ $crumbs->addAction($action);
+ }
+
+
+ /**
+ * Build a raw description of available "Create New Object" UI options so
+ * other methods can build menus or buttons.
+ */
+ private function newCreateActionSpecifications(array $parameters) {
+ $viewer = $this->getViewer();
+
$can_create = $this->hasCreateCapability();
if ($can_create) {
$configs = $this->loadUsableConfigurationsForCreate();
@@ -1364,12 +1433,11 @@
$configs = array();
}
- $dropdown = null;
$disabled = false;
$workflow = false;
$menu_icon = 'fa-plus-square';
-
+ $specs = array();
if (!$configs) {
if ($viewer->isLoggedIn()) {
$disabled = true;
@@ -1385,54 +1453,35 @@
} else {
$create_uri = $this->getEditURI(null, 'nocreate/');
}
- } else {
- $config = head($configs);
- $form_key = $config->getIdentifier();
- $create_uri = $this->getEditURI(null, "form/{$form_key}/");
-
- if ($parameters) {
- $create_uri = (string)id(new PhutilURI($create_uri))
- ->setQueryParams($parameters);
- }
-
- if (count($configs) > 1) {
- $menu_icon = 'fa-caret-square-o-down';
-
- $dropdown = id(new PhabricatorActionListView())
- ->setUser($viewer);
-
- foreach ($configs as $config) {
- $form_key = $config->getIdentifier();
- $config_uri = $this->getEditURI(null, "form/{$form_key}/");
- if ($parameters) {
- $config_uri = (string)id(new PhutilURI($config_uri))
- ->setQueryParams($parameters);
- }
-
- $item_icon = 'fa-plus';
+ $specs[] = array(
+ 'name' => $this->getObjectCreateShortText(),
+ 'uri' => $create_uri,
+ 'icon' => $menu_icon,
+ 'disabled' => $disabled,
+ 'workflow' => $workflow,
+ );
+ } else {
+ foreach ($configs as $config) {
+ $form_key = $config->getIdentifier();
+ $config_uri = $this->getEditURI(null, "form/{$form_key}/");
- $dropdown->addAction(
- id(new PhabricatorActionView())
- ->setName($config->getDisplayName())
- ->setIcon($item_icon)
- ->setHref($config_uri));
+ if ($parameters) {
+ $config_uri = (string)id(new PhutilURI($config_uri))
+ ->setQueryParams($parameters);
}
- }
- }
-
- $action = id(new PHUIListItemView())
- ->setName($this->getObjectCreateShortText())
- ->setHref($create_uri)
- ->setIcon($menu_icon)
- ->setWorkflow($workflow)
- ->setDisabled($disabled);
- if ($dropdown) {
- $action->setDropdownMenu($dropdown);
+ $specs[] = array(
+ 'name' => $config->getDisplayName(),
+ 'uri' => $config_uri,
+ 'icon' => 'fa-plus',
+ 'disabled' => false,
+ 'workflow' => false,
+ );
+ }
}
- $crumbs->addAction($action);
+ return $specs;
}
final public function buildEditEngineCommentView($object) {

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 10, 12:33 PM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6719824
Default Alt Text
D16797.id40458.diff (6 KB)

Event Timeline