Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13974393
D15092.id36447.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D15092.id36447.diff
View Options
diff --git a/src/applications/project/controller/PhabricatorProjectBoardViewController.php b/src/applications/project/controller/PhabricatorProjectBoardViewController.php
--- a/src/applications/project/controller/PhabricatorProjectBoardViewController.php
+++ b/src/applications/project/controller/PhabricatorProjectBoardViewController.php
@@ -761,8 +761,15 @@
$board_uri = $this->getApplicationURI("board/{$id}/");
$import_uri = $this->getApplicationURI("board/{$id}/import/");
- switch ($type) {
- case 'backlog-only':
+ $set_default = $request->getBool('default');
+ if ($set_default) {
+ $this
+ ->getProfilePanelEngine()
+ ->adjustDefault(PhabricatorProject::PANEL_WORKBOARD);
+ }
+
+ if ($request->isFormPost()) {
+ if ($type == 'backlog-only') {
$column = PhabricatorProjectColumn::initializeNewColumn($viewer)
->setSequence(0)
->setProperty('isDefault', true)
@@ -773,12 +780,14 @@
return id(new AphrontRedirectResponse())
->setURI($board_uri);
- case 'import':
+ } else {
return id(new AphrontRedirectResponse())
->setURI($import_uri);
+ }
}
$new_selector = id(new AphrontFormRadioButtonControl())
+ ->setLabel(pht('Columns'))
->setName('initialize-type')
->setValue('backlog-only')
->addButton(
@@ -790,11 +799,20 @@
pht('Import Columns'),
pht('Import board columns from another project.'));
+ $default_checkbox = id(new AphrontFormCheckboxControl())
+ ->setLabel(pht('Make Default'))
+ ->addCheckbox(
+ 'default',
+ 1,
+ pht('Make the workboard the default view for this project.'),
+ true);
+
$form = id(new AphrontFormView())
->setUser($viewer)
->appendRemarkupInstructions(
pht('The workboard for this project has not been created yet.'))
->appendControl($new_selector)
+ ->appendControl($default_checkbox)
->appendControl(
id(new AphrontFormSubmitControl())
->addCancelButton($profile_uri)
diff --git a/src/applications/project/controller/PhabricatorProjectController.php b/src/applications/project/controller/PhabricatorProjectController.php
--- a/src/applications/project/controller/PhabricatorProjectController.php
+++ b/src/applications/project/controller/PhabricatorProjectController.php
@@ -133,6 +133,7 @@
if ($project) {
$engine = id(new PhabricatorProjectProfilePanelEngine())
->setViewer($viewer)
+ ->setController($this)
->setProfileObject($project);
$this->profilePanelEngine = $engine;
}
diff --git a/src/applications/search/engine/PhabricatorProfilePanelEngine.php b/src/applications/search/engine/PhabricatorProfilePanelEngine.php
--- a/src/applications/search/engine/PhabricatorProfilePanelEngine.php
+++ b/src/applications/search/engine/PhabricatorProfilePanelEngine.php
@@ -891,24 +891,84 @@
->addCancelButton($done_uri);
}
+ if ($request->isFormPost()) {
+ $key = $configuration->getID();
+ if (!$key) {
+ $key = $configuration->getBuiltinKey();
+ }
+
+ $this->adjustDefault($key);
+
+ return id(new AphrontRedirectResponse())
+ ->setURI($done_uri);
+ }
+
+ return $controller->newDialog()
+ ->setTitle(pht('Make Default'))
+ ->appendParagraph(
+ pht(
+ 'Set this item as the default for this menu? Users arriving on '.
+ 'this page will be shown the content of this item by default.'))
+ ->addCancelButton($done_uri)
+ ->addSubmitButton(pht('Make Default'));
+ }
+
+ protected function newPanel() {
+ return PhabricatorProfilePanelConfiguration::initializeNewBuiltin();
+ }
+
+ public function adjustDefault($key) {
+ $controller = $this->getController();
+ $request = $controller->getRequest();
+ $viewer = $request->getViewer();
+
+ $panels = $this->loadPanels();
+
+ // To adjust the default panel, we first change any existing panels that
+ // are marked as defaults to "visible", then make the new default panel
+ // the default.
+
+ $default = array();
+ $visible = array();
+
+ foreach ($panels as $panel) {
+ $builtin_key = $panel->getBuiltinKey();
+ $id = $panel->getID();
+
+ $is_target =
+ (($builtin_key !== null) && ($builtin_key === $key)) ||
+ (($id !== null) && ($id === (int)$key));
+
+ if ($is_target) {
+ if (!$panel->isDefault()) {
+ $default[] = $panel;
+ }
+ } else {
+ if ($panel->isDefault()) {
+ $visible[] = $panel;
+ }
+ }
+ }
+
$type_visibility =
PhabricatorProfilePanelConfigurationTransaction::TYPE_VISIBILITY;
$v_visible = PhabricatorProfilePanelConfiguration::VISIBILITY_VISIBLE;
$v_default = PhabricatorProfilePanelConfiguration::VISIBILITY_DEFAULT;
- if ($request->isFormPost()) {
- // First, mark any existing default panels as merely visible.
- foreach ($panels as $panel) {
- if (!$panel->isDefault()) {
- continue;
- }
+ $apply = array(
+ array($v_visible, $visible),
+ array($v_default, $default),
+ );
+ foreach ($apply as $group) {
+ list($value, $panels) = $group;
+ foreach ($panels as $panel) {
$xactions = array();
$xactions[] = id(new PhabricatorProfilePanelConfigurationTransaction())
->setTransactionType($type_visibility)
- ->setNewValue($v_visible);
+ ->setNewValue($value);
$editor = id(new PhabricatorProfilePanelEditor())
->setContentSourceFromRequest($request)
@@ -917,37 +977,9 @@
->setContinueOnNoEffect(true)
->applyTransactions($panel, $xactions);
}
-
- // Now, make this panel the default.
- $xactions = array();
-
- $xactions[] = id(new PhabricatorProfilePanelConfigurationTransaction())
- ->setTransactionType($type_visibility)
- ->setNewValue($v_default);
-
- $editor = id(new PhabricatorProfilePanelEditor())
- ->setContentSourceFromRequest($request)
- ->setActor($viewer)
- ->setContinueOnMissingFields(true)
- ->setContinueOnNoEffect(true)
- ->applyTransactions($configuration, $xactions);
-
- return id(new AphrontRedirectResponse())
- ->setURI($done_uri);
}
- return $controller->newDialog()
- ->setTitle(pht('Make Default'))
- ->appendParagraph(
- pht(
- 'Set this item as the default for this menu? Users arriving on '.
- 'this page will be shown the content of this item by default.'))
- ->addCancelButton($done_uri)
- ->addSubmitButton(pht('Make Default'));
- }
-
- protected function newPanel() {
- return PhabricatorProfilePanelConfiguration::initializeNewBuiltin();
+ return $this;
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 19 2024, 5:22 AM (4 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6730525
Default Alt Text
D15092.id36447.diff (6 KB)
Attached To
Mode
D15092: Add a "make the workboard the default view" checkbox when creating a workboard
Attached
Detach File
Event Timeline
Log In to Comment