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

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
This commit is contained in:
epriestley 2016-01-22 07:40:11 -08:00
parent b64d67f47a
commit 9f56a014e2
4 changed files with 68 additions and 10 deletions

View file

@ -0,0 +1,60 @@
<?php
// Populate the newish `hasWorkboard` column for projects with workboard.
// Set the default menu item to "Workboard" for projects which used to have
// that default.
$project_table = new PhabricatorProject();
$conn_w = $project_table->establishConnection('w');
$panel_table = id(new PhabricatorProfilePanelConfiguration());
$panel_conn = $panel_table->establishConnection('w');
foreach (new LiskMigrationIterator($project_table) as $project) {
$columns = queryfx_all(
$conn_w,
'SELECT * FROM %T WHERE projectPHID = %s',
id(new PhabricatorProjectColumn())->getTableName(),
$project->getPHID());
// This project has no columns, so we don't need to change anything.
if (!$columns) {
continue;
}
// This project has columns, so set its workboard flag.
queryfx(
$conn_w,
'UPDATE %T SET hasWorkboard = 1 WHERE id = %d',
$project->getTableName(),
$project->getID());
// Try to set the default menu item to "Workboard".
$config = queryfx_all(
$panel_conn,
'SELECT * FROM %T WHERE profilePHID = %s',
$panel_table->getTableName(),
$project->getPHID());
// There are already some settings, so don't touch them.
if ($config) {
continue;
}
queryfx(
$panel_conn,
'INSERT INTO %T
(phid, profilePHID, panelKey, builtinKey, visibility, panelProperties,
panelOrder, dateCreated, dateModified)
VALUES (%s, %s, %s, %s, %s, %s, %d, %d, %d)',
$panel_table->getTableName(),
$panel_table->generatePHID(),
$project->getPHID(),
PhabricatorProjectWorkboardProfilePanel::PANELKEY,
PhabricatorProject::PANEL_WORKBOARD,
PhabricatorProfilePanelConfiguration::VISIBILITY_DEFAULT,
'{}',
2,
PhabricatorTime::getNow(),
PhabricatorTime::getNow());
}

View file

@ -57,6 +57,9 @@ final class PhabricatorProjectBoardImportController
->setProperties($import_column->getProperties()) ->setProperties($import_column->getProperties())
->save(); ->save();
} }
$project->setHasWorkboard(1)->save();
$table->saveTransaction(); $table->saveTransaction();
return id(new AphrontRedirectResponse())->setURI($board_uri); return id(new AphrontRedirectResponse())->setURI($board_uri);

View file

@ -769,6 +769,8 @@ final class PhabricatorProjectBoardViewController
->setProjectPHID($project->getPHID()) ->setProjectPHID($project->getPHID())
->save(); ->save();
$project->setHasWorkboard(1)->save();
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())
->setURI($board_uri); ->setURI($board_uri);
case 'import': case 'import':

View file

@ -52,15 +52,7 @@ final class PhabricatorProjectWorkboardProfilePanel
$project = $config->getProfileObject(); $project = $config->getProfileObject();
$columns = id(new PhabricatorProjectColumnQuery()) $has_workboard = $project->getHasWorkboard();
->setViewer($viewer)
->withProjectPHIDs(array($project->getPHID()))
->execute();
if ($columns) {
$icon = 'fa-columns';
} else {
$icon = 'fa-columns grey';
}
$id = $project->getID(); $id = $project->getID();
$href = "/project/board/{$id}/"; $href = "/project/board/{$id}/";
@ -69,7 +61,8 @@ final class PhabricatorProjectWorkboardProfilePanel
$item = $this->newItem() $item = $this->newItem()
->setHref($href) ->setHref($href)
->setName($name) ->setName($name)
->setIcon($icon); ->setDisabled(!$has_workboard)
->setIcon('fa-columns');
return array( return array(
$item, $item,