1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 11:30:55 +01:00

Move general workboard actions to "Manage Board" dropdown

Summary: See D9719.

Test Plan:
  - Used hide/show columns.
  - Used "add column".
  - Filtered board.

{F170133}

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9726
This commit is contained in:
epriestley 2014-06-25 12:30:53 -07:00
parent f1c638d231
commit 60157ed40d
3 changed files with 105 additions and 66 deletions

View file

@ -411,7 +411,7 @@ return array(
'rsrc/js/application/policy/behavior-policy-control.js' => 'f3fef818',
'rsrc/js/application/policy/behavior-policy-rule-editor.js' => '92918fcb',
'rsrc/js/application/ponder/behavior-votebox.js' => '4e9b766b',
'rsrc/js/application/projects/behavior-boards-filter.js' => '8be7c2f0',
'rsrc/js/application/projects/behavior-boards-dropdown.js' => '0ec56e1d',
'rsrc/js/application/projects/behavior-project-boards.js' => '1cb113dc',
'rsrc/js/application/projects/behavior-project-create.js' => '065227cc',
'rsrc/js/application/releeph/releeph-preview-branch.js' => 'b2b4fbaf',
@ -553,7 +553,7 @@ return array(
'javelin-behavior-audio-source' => '59b251eb',
'javelin-behavior-audit-preview' => 'd835b03a',
'javelin-behavior-balanced-payment-form' => '3b3e1664',
'javelin-behavior-boards-filter' => '8be7c2f0',
'javelin-behavior-boards-dropdown' => '0ec56e1d',
'javelin-behavior-config-reorder-fields' => '14a827de',
'javelin-behavior-conpherence-menu' => 'f0a41b9f',
'javelin-behavior-conpherence-pontificate' => '85ab3c8e',
@ -918,6 +918,13 @@ return array(
3 => 'javelin-util',
4 => 'phabricator-notification-css',
),
'0ec56e1d' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-dom',
2 => 'javelin-stratcom',
3 => 'phuix-dropdown-menu',
),
'0f764c35' =>
array(
0 => 'javelin-install',
@ -1515,13 +1522,6 @@ return array(
0 => 'javelin-magical-init',
1 => 'javelin-util',
),
'8be7c2f0' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-dom',
2 => 'javelin-stratcom',
3 => 'phuix-dropdown-menu',
),
'8d199d97' =>
array(
0 => 'javelin-behavior',

View file

@ -217,26 +217,54 @@ final class PhabricatorProjectBoardViewController
$board->addPanel($panel);
}
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$project,
PhabricatorPolicyCapability::CAN_EDIT);
$add_icon = id(new PHUIIconView())
->setIconFont('fa-plus bluegrey');
$add_button = id(new PHUIButtonView())
->setText(pht('Add Column'))
->setIcon($add_icon)
->setTag('a')
->setHref($this->getApplicationURI('board/'.$this->id.'/edit/'))
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit);
Javelin::initBehavior(
'boards-filter',
'boards-dropdown',
array());
$filter_menu = $this->buildFilterMenu(
$viewer,
$custom_query,
$engine,
$query_key);
$manage_menu = $this->buildManageMenu($project, $show_hidden);
$header_link = phutil_tag(
'a',
array(
'href' => $this->getApplicationURI('view/'.$project->getID().'/')
),
$project->getName());
$header = id(new PHUIHeaderView())
->setHeader($header_link)
->setUser($viewer)
->setNoBackground(true)
->setImage($project->getProfileImageURI())
->setImageURL($this->getApplicationURI('view/'.$project->getID().'/'))
->addActionLink($filter_menu)
->addActionLink($manage_menu)
->setPolicyObject($project);
$board_box = id(new PHUIBoxView())
->appendChild($board)
->addClass('project-board-wrapper');
return $this->buildApplicationPage(
array(
$header,
$board_box,
),
array(
'title' => pht('%s Board', $project->getName()),
));
}
private function buildFilterMenu(
PhabricatorUser $viewer,
$custom_query,
PhabricatorApplicationSearchEngine $engine,
$query_key) {
$filter_icon = id(new PHUIIconView())
->setIconFont('fa-search-plus bluegrey');
@ -300,62 +328,73 @@ final class PhabricatorProjectBoardViewController
->setIcon($filter_icon)
->setTag('a')
->setHref('#')
->addSigil('boards-filter-menu')
->addSigil('boards-dropdown-menu')
->setMetadata(
array(
'items' => hsprintf('%s', $filter_menu),
));
$header_link = phutil_tag(
'a',
array(
'href' => $this->getApplicationURI('view/'.$project->getID().'/')
),
$project->getName());
return $filter_button;
}
private function buildManageMenu(
PhabricatorProject $project,
$show_hidden) {
$request = $this->getRequest();
$viewer = $request->getUser();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$project,
PhabricatorPolicyCapability::CAN_EDIT);
$manage_icon = id(new PHUIIconView())
->setIconFont('fa-cog bluegrey');
$manage_items = array();
$manage_items[] = id(new PhabricatorActionView())
->setIcon('fa-plus')
->setName(pht('Add Column'))
->setHref($this->getApplicationURI('board/'.$this->id.'/edit/'));
if ($show_hidden) {
$hidden_uri = $request->getRequestURI()
->setQueryParam('hidden', null);
$hidden_icon = id(new PHUIIconView())
->setIconFont('fa-eye-slash bluegrey');
$hidden_icon = 'fa-eye-slash';
$hidden_text = pht('Hide Hidden Columns');
} else {
$hidden_uri = $request->getRequestURI()
->setQueryParam('hidden', 'true');
$hidden_icon = id(new PHUIIconView())
->setIconFont('fa-eye bluegrey');
$hidden_icon = 'fa-eye';
$hidden_text = pht('Show Hidden Columns');
}
$hidden_button = id(new PHUIButtonView())
->setText($hidden_text)
$manage_items[] = id(new PhabricatorActionView())
->setIcon($hidden_icon)
->setTag('a')
->setName($hidden_text)
->setHref($hidden_uri);
$header = id(new PHUIHeaderView())
->setHeader($header_link)
->setUser($viewer)
->setNoBackground(true)
->setImage($project->getProfileImageURI())
->setImageURL($this->getApplicationURI('view/'.$project->getID().'/'))
->addActionLink($hidden_button)
->addActionLink($filter_button)
->addActionLink($add_button)
->setPolicyObject($project);
$manage_menu = id(new PhabricatorActionListView())
->setUser($viewer);
foreach ($manage_items as $item) {
$manage_menu->addAction($item);
}
$board_box = id(new PHUIBoxView())
->appendChild($board)
->addClass('project-board-wrapper');
$manage_button = id(new PHUIButtonView())
->setText(pht('Manage Board'))
->setIcon($manage_icon)
->setTag('a')
->setHref('#')
->addSigil('boards-dropdown-menu')
->setMetadata(
array(
'items' => hsprintf('%s', $manage_menu),
));
return $this->buildApplicationPage(
array(
$header,
$board_box,
),
array(
'title' => pht('%s Board', $project->getName()),
));
return $manage_button;
}
}

View file

@ -1,15 +1,15 @@
/**
* @provides javelin-behavior-boards-filter
* @provides javelin-behavior-boards-dropdown
* @requires javelin-behavior
* javelin-dom
* javelin-stratcom
* phuix-dropdown-menu
*/
JX.behavior('boards-filter', function() {
JX.behavior('boards-dropdown', function() {
JX.Stratcom.listen('click', 'boards-filter-menu', function(e) {
var data = e.getNodeData('boards-filter-menu');
JX.Stratcom.listen('click', 'boards-dropdown-menu', function(e) {
var data = e.getNodeData('boards-dropdown-menu');
if (data.menu) {
return;
}
@ -18,7 +18,7 @@ JX.behavior('boards-filter', function() {
var list = JX.$H(data.items).getFragment().firstChild;
var button = e.getNode('boards-filter-menu');
var button = e.getNode('boards-dropdown-menu');
data.menu = new JX.PHUIXDropdownMenu(button);
data.menu.setContent(list);
data.menu.open();