mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +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() {
|
||||
return PhabricatorProject::initializeNewProject($this->getViewer());
|
||||
$parent = nonempty($this->parentProject, $this->milestoneProject);
|
||||
|
||||
return PhabricatorProject::initializeNewProject(
|
||||
$this->getViewer(),
|
||||
$parent);
|
||||
}
|
||||
|
||||
protected function newObjectQuery() {
|
||||
|
@ -112,6 +116,7 @@ final class PhabricatorProjectEditEngine
|
|||
PhabricatorTransactions::TYPE_VIEW_POLICY,
|
||||
PhabricatorTransactions::TYPE_EDIT_POLICY,
|
||||
PhabricatorTransactions::TYPE_JOIN_POLICY,
|
||||
PhabricatorTransactions::TYPE_SPACE,
|
||||
PhabricatorProjectIconTransaction::TRANSACTIONTYPE,
|
||||
PhabricatorProjectColorTransaction::TRANSACTIONTYPE,
|
||||
);
|
||||
|
|
|
@ -61,7 +61,10 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
|||
const ITEM_MILESTONES = 'project.milestones';
|
||||
const ITEM_SUBPROJECTS = 'project.subprojects';
|
||||
|
||||
public static function initializeNewProject(PhabricatorUser $actor) {
|
||||
public static function initializeNewProject(
|
||||
PhabricatorUser $actor,
|
||||
PhabricatorProject $parent = null) {
|
||||
|
||||
$app = id(new PhabricatorApplicationQuery())
|
||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
||||
->withClasses(array('PhabricatorProjectApplication'))
|
||||
|
@ -74,6 +77,14 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
|||
$join_policy = $app->getPolicy(
|
||||
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_color = PhabricatorProjectIconSet::getDefaultColorKey();
|
||||
|
||||
|
@ -84,7 +95,7 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
|||
->setViewPolicy($view_policy)
|
||||
->setEditPolicy($edit_policy)
|
||||
->setJoinPolicy($join_policy)
|
||||
->setSpacePHID($actor->getDefaultSpacePHID())
|
||||
->setSpacePHID($space_phid)
|
||||
->setIsMembershipLocked(0)
|
||||
->attachMemberPHIDs(array())
|
||||
->attachSlugs(array())
|
||||
|
@ -704,6 +715,9 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
|||
|
||||
|
||||
public function getSpacePHID() {
|
||||
if ($this->isMilestone()) {
|
||||
return $this->getParentProject()->getSpacePHID();
|
||||
}
|
||||
return $this->spacePHID;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue