Files
phabricator/src/applications/project/profilepanel/PhabricatorProjectWorkboardProfilePanel.php
epriestley 9f56a014e2 Migrate existing projects to retain "Workboard" as default item
Summary:
Ref T10054. Ref T6961.

  - Existing projects with workboards had "Workboard" as the default menu item. Retain this behavior.
  - Populate the recently-added `hasWorkboard` flag so we can do a couple of things a little faster (see T6961).

Test Plan:
  - Ran migration.
  - Verified a bunch of projects looked sensible/correct after the migration.
  - Created a workboard, verified `hasWorkboard` got set properly.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T6961, T10054

Differential Revision: https://secure.phabricator.com/D15093
2016-01-22 09:44:43 -08:00

73 lines
1.7 KiB
PHP

<?php
final class PhabricatorProjectWorkboardProfilePanel
extends PhabricatorProfilePanel {
const PANELKEY = 'project.workboard';
public function getPanelTypeName() {
return pht('Project Workboard');
}
private function getDefaultName() {
return pht('Workboard');
}
public function canMakeDefault(
PhabricatorProfilePanelConfiguration $config) {
return true;
}
public function getDisplayName(
PhabricatorProfilePanelConfiguration $config) {
$name = $config->getPanelProperty('name');
if (strlen($name)) {
return $name;
}
return $this->getDefaultName();
}
public function buildEditEngineFields(
PhabricatorProfilePanelConfiguration $config) {
return array(
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setPlaceholder($this->getDefaultName())
->setValue($config->getPanelProperty('name')),
);
}
protected function newNavigationMenuItems(
PhabricatorProfilePanelConfiguration $config) {
$viewer = $this->getViewer();
// Workboards are only available if Maniphest is installed.
$class = 'PhabricatorManiphestApplication';
if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
return array();
}
$project = $config->getProfileObject();
$has_workboard = $project->getHasWorkboard();
$id = $project->getID();
$href = "/project/board/{$id}/";
$name = $this->getDisplayName($config);
$item = $this->newItem()
->setHref($href)
->setName($name)
->setDisabled(!$has_workboard)
->setIcon('fa-columns');
return array(
$item,
);
}
}