Add subprojects to a main project.
Summary: Quite basic subproject attachment. Test Plan: Go to some proj ect and add another as a subproject. Play around the ui. Reviewers: epr iestley CC:
This commit is contained in:
@@ -43,8 +43,6 @@ class PhabricatorProjectListController
|
||||
$handles = id(new PhabricatorObjectHandleData($author_phids))
|
||||
->loadHandles();
|
||||
|
||||
$project_phids = mpull($projects, 'getPHID');
|
||||
|
||||
$query = id(new ManiphestTaskQuery())
|
||||
->withProjects($project_phids)
|
||||
->withAnyProject(true)
|
||||
|
||||
@@ -58,12 +58,12 @@ class PhabricatorProjectProfileController
|
||||
'statistics' => 'Statistics',
|
||||
'<hr />', */
|
||||
'<h2>Information</h2>',
|
||||
'edit' => 'Edit Profile',
|
||||
'edit' => 'Edit Project',
|
||||
'affiliation' => 'Edit Affiliation',
|
||||
);
|
||||
|
||||
if (empty($pages[$this->page])) {
|
||||
$this->page = 'action'; // key($pages);
|
||||
$this->page = 'action';
|
||||
}
|
||||
|
||||
switch ($this->page) {
|
||||
@@ -106,6 +106,9 @@ class PhabricatorProjectProfileController
|
||||
));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Helper functions
|
||||
|
||||
private function renderBasicInformation($project, $profile) {
|
||||
$blurb = nonempty(
|
||||
$profile->getBlurb(),
|
||||
@@ -118,7 +121,10 @@ class PhabricatorProjectProfileController
|
||||
|
||||
$phids = array_merge(
|
||||
array($project->getAuthorPHID()),
|
||||
mpull($affiliations, 'getUserPHID'));
|
||||
$project->getSubprojectPHIDs(),
|
||||
mpull($affiliations, 'getUserPHID')
|
||||
);
|
||||
$phids = array_unique($phids);
|
||||
$handles = id(new PhabricatorObjectHandleData($phids))
|
||||
->loadHandles();
|
||||
|
||||
@@ -134,12 +140,24 @@ class PhabricatorProjectProfileController
|
||||
|
||||
$affiliated[] = '<li>'.$user.' — '.$role.$status.'</li>';
|
||||
}
|
||||
|
||||
if ($affiliated) {
|
||||
$affiliated = '<ul>'.implode("\n", $affiliated).'</ul>';
|
||||
} else {
|
||||
$affiliated = '<p><em>No one is affiliated with this project.</em></p>';
|
||||
}
|
||||
|
||||
if ($project->getSubprojectPHIDs()) {
|
||||
$table = $this->renderSubprojectTable(
|
||||
$handles,
|
||||
$project->getSubprojectPHIDs());
|
||||
$subproject_list = $table->render();
|
||||
} else {
|
||||
$subproject_list =
|
||||
'<p><em>There are no projects attached for such specie.</em></p>';
|
||||
}
|
||||
|
||||
|
||||
$timestamp = phabricator_format_timestamp($project->getDateCreated());
|
||||
$status = PhabricatorProjectStatus::getNameForStatus(
|
||||
$project->getStatus());
|
||||
@@ -174,12 +192,19 @@ class PhabricatorProjectProfileController
|
||||
</div>';
|
||||
|
||||
$content .=
|
||||
'<div class="phabricator-profile-info-group">
|
||||
<h1 class="phabricator-profile-info-header">Resources</h1>
|
||||
<div class="phabricator-profile-info-pane">'.
|
||||
'<div class="phabricator-profile-info-group">'.
|
||||
'<h1 class="phabricator-profile-info-header">Resources</h1>'.
|
||||
'<div class="phabricator-profile-info-pane">'.
|
||||
$affiliated.
|
||||
'</div>
|
||||
</div>';
|
||||
'</div>'.
|
||||
'</div>';
|
||||
|
||||
$content .= '<div class="phabricator-profile-info-group">'.
|
||||
'<h1 class="phabricator-profile-info-header">Subprojects</h1>'.
|
||||
'<div class="phabricator-profile-info-pane">'.
|
||||
$subproject_list.
|
||||
'</div>'.
|
||||
'</div>';
|
||||
|
||||
$query = id(new ManiphestTaskQuery())
|
||||
->withProjects(array($project->getPHID()))
|
||||
@@ -234,4 +259,39 @@ class PhabricatorProjectProfileController
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
private function renderSubprojectTable(
|
||||
PhabricatorObjectHandleData $handles,
|
||||
$subprojects_phids) {
|
||||
|
||||
$rows = array();
|
||||
foreach ($subprojects_phids as $subproject_phid) {
|
||||
$phid = $handles[$subproject_phid]->getPHID();
|
||||
|
||||
$rows[] = array(
|
||||
phutil_escape_html($handles[$phid]->getFullName()),
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'class' => 'small grey button',
|
||||
'href' => $handles[$phid]->getURI(),
|
||||
),
|
||||
'View Project Profile'),
|
||||
);
|
||||
}
|
||||
|
||||
$table = new AphrontTableView($rows);
|
||||
$table->setHeaders(
|
||||
array(
|
||||
'Name',
|
||||
'',
|
||||
));
|
||||
$table->setColumnClasses(
|
||||
array(
|
||||
'pri',
|
||||
'action right',
|
||||
));
|
||||
|
||||
return $table;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ phutil_require_module('phabricator', 'applications/project/constants/status');
|
||||
phutil_require_module('phabricator', 'applications/project/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/project/storage/profile');
|
||||
phutil_require_module('phabricator', 'applications/project/storage/project');
|
||||
phutil_require_module('phabricator', 'view/control/table');
|
||||
phutil_require_module('phabricator', 'view/layout/profile');
|
||||
phutil_require_module('phabricator', 'view/utils');
|
||||
|
||||
|
||||
@@ -38,6 +38,15 @@ class PhabricatorProjectProfileEditController
|
||||
$profile = new PhabricatorProjectProfile();
|
||||
}
|
||||
|
||||
if ($project->getSubprojectPHIDs()) {
|
||||
$phids = $project->getSubprojectPHIDs();
|
||||
$handles = id(new PhabricatorObjectHandleData($phids))
|
||||
->loadHandles();
|
||||
$subprojects = mpull($handles, 'getFullName', 'getPHID');
|
||||
} else {
|
||||
$subprojects = array();
|
||||
}
|
||||
|
||||
$options = PhabricatorProjectStatus::getStatusMap();
|
||||
|
||||
$e_name = true;
|
||||
@@ -45,6 +54,7 @@ class PhabricatorProjectProfileEditController
|
||||
if ($request->isFormPost()) {
|
||||
$project->setName($request->getStr('name'));
|
||||
$project->setStatus($request->getStr('status'));
|
||||
$project->setSubprojectPHIDs($request->getArr('set_subprojects'));
|
||||
$profile->setBlurb($request->getStr('blurb'));
|
||||
|
||||
if (!strlen($project->getName())) {
|
||||
@@ -121,6 +131,12 @@ class PhabricatorProjectProfileEditController
|
||||
->setLabel('Blurb')
|
||||
->setName('blurb')
|
||||
->setValue($profile->getBlurb()))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource('/typeahead/common/projects/')
|
||||
->setLabel('Subprojects')
|
||||
->setName('set_subprojects')
|
||||
->setValue($subprojects))
|
||||
->appendChild(
|
||||
id(new AphrontFormFileControl())
|
||||
->setLabel('Change Image')
|
||||
@@ -132,7 +148,7 @@ class PhabricatorProjectProfileEditController
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader($header_name);
|
||||
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
|
||||
$panel->setWidth(AphrontPanelView::WIDTH_WIDE);
|
||||
$panel->appendChild($form);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
|
||||
@@ -10,6 +10,7 @@ phutil_require_module('phabricator', 'aphront/response/404');
|
||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||
phutil_require_module('phabricator', 'applications/files/storage/file');
|
||||
phutil_require_module('phabricator', 'applications/files/transform');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||
phutil_require_module('phabricator', 'applications/project/constants/status');
|
||||
phutil_require_module('phabricator', 'applications/project/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/project/storage/profile');
|
||||
@@ -20,6 +21,7 @@ phutil_require_module('phabricator', 'view/form/control/select');
|
||||
phutil_require_module('phabricator', 'view/form/control/submit');
|
||||
phutil_require_module('phabricator', 'view/form/control/text');
|
||||
phutil_require_module('phabricator', 'view/form/control/textarea');
|
||||
phutil_require_module('phabricator', 'view/form/control/tokenizer');
|
||||
phutil_require_module('phabricator', 'view/form/error');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user