mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 07:11:04 +01:00
Improve Space behavior for subprojects and milestones
Summary: Depends on D19549. Ref T13164. See PHI774. - Make milestones inherit their parent project's space automatically, like they inherit their parent policies. - Make subprojects default to their parent project's space. Test Plan: Created subprojects and milestones, got sensible default/effective Space behavior. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13164 Differential Revision: https://secure.phabricator.com/D19550
This commit is contained in:
parent
13cac5c362
commit
d9b5b04950
2 changed files with 22 additions and 3 deletions
|
@ -51,7 +51,11 @@ final class PhabricatorProjectEditEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function newEditableObject() {
|
protected function newEditableObject() {
|
||||||
return PhabricatorProject::initializeNewProject($this->getViewer());
|
$parent = nonempty($this->parentProject, $this->milestoneProject);
|
||||||
|
|
||||||
|
return PhabricatorProject::initializeNewProject(
|
||||||
|
$this->getViewer(),
|
||||||
|
$parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function newObjectQuery() {
|
protected function newObjectQuery() {
|
||||||
|
@ -112,6 +116,7 @@ final class PhabricatorProjectEditEngine
|
||||||
PhabricatorTransactions::TYPE_VIEW_POLICY,
|
PhabricatorTransactions::TYPE_VIEW_POLICY,
|
||||||
PhabricatorTransactions::TYPE_EDIT_POLICY,
|
PhabricatorTransactions::TYPE_EDIT_POLICY,
|
||||||
PhabricatorTransactions::TYPE_JOIN_POLICY,
|
PhabricatorTransactions::TYPE_JOIN_POLICY,
|
||||||
|
PhabricatorTransactions::TYPE_SPACE,
|
||||||
PhabricatorProjectIconTransaction::TRANSACTIONTYPE,
|
PhabricatorProjectIconTransaction::TRANSACTIONTYPE,
|
||||||
PhabricatorProjectColorTransaction::TRANSACTIONTYPE,
|
PhabricatorProjectColorTransaction::TRANSACTIONTYPE,
|
||||||
);
|
);
|
||||||
|
|
|
@ -61,7 +61,10 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
||||||
const ITEM_MILESTONES = 'project.milestones';
|
const ITEM_MILESTONES = 'project.milestones';
|
||||||
const ITEM_SUBPROJECTS = 'project.subprojects';
|
const ITEM_SUBPROJECTS = 'project.subprojects';
|
||||||
|
|
||||||
public static function initializeNewProject(PhabricatorUser $actor) {
|
public static function initializeNewProject(
|
||||||
|
PhabricatorUser $actor,
|
||||||
|
PhabricatorProject $parent = null) {
|
||||||
|
|
||||||
$app = id(new PhabricatorApplicationQuery())
|
$app = id(new PhabricatorApplicationQuery())
|
||||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
->setViewer(PhabricatorUser::getOmnipotentUser())
|
||||||
->withClasses(array('PhabricatorProjectApplication'))
|
->withClasses(array('PhabricatorProjectApplication'))
|
||||||
|
@ -74,6 +77,14 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
||||||
$join_policy = $app->getPolicy(
|
$join_policy = $app->getPolicy(
|
||||||
ProjectDefaultJoinCapability::CAPABILITY);
|
ProjectDefaultJoinCapability::CAPABILITY);
|
||||||
|
|
||||||
|
// If this is the child of some other project, default the Space to the
|
||||||
|
// Space of the parent.
|
||||||
|
if ($parent) {
|
||||||
|
$space_phid = $parent->getSpacePHID();
|
||||||
|
} else {
|
||||||
|
$space_phid = $actor->getDefaultSpacePHID();
|
||||||
|
}
|
||||||
|
|
||||||
$default_icon = PhabricatorProjectIconSet::getDefaultIconKey();
|
$default_icon = PhabricatorProjectIconSet::getDefaultIconKey();
|
||||||
$default_color = PhabricatorProjectIconSet::getDefaultColorKey();
|
$default_color = PhabricatorProjectIconSet::getDefaultColorKey();
|
||||||
|
|
||||||
|
@ -84,7 +95,7 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
||||||
->setViewPolicy($view_policy)
|
->setViewPolicy($view_policy)
|
||||||
->setEditPolicy($edit_policy)
|
->setEditPolicy($edit_policy)
|
||||||
->setJoinPolicy($join_policy)
|
->setJoinPolicy($join_policy)
|
||||||
->setSpacePHID($actor->getDefaultSpacePHID())
|
->setSpacePHID($space_phid)
|
||||||
->setIsMembershipLocked(0)
|
->setIsMembershipLocked(0)
|
||||||
->attachMemberPHIDs(array())
|
->attachMemberPHIDs(array())
|
||||||
->attachSlugs(array())
|
->attachSlugs(array())
|
||||||
|
@ -704,6 +715,9 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
||||||
|
|
||||||
|
|
||||||
public function getSpacePHID() {
|
public function getSpacePHID() {
|
||||||
|
if ($this->isMilestone()) {
|
||||||
|
return $this->getParentProject()->getSpacePHID();
|
||||||
|
}
|
||||||
return $this->spacePHID;
|
return $this->spacePHID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue