Sync up UUIDs and create project configs.
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class PhabricatorRepositoryArcanistProjectEditController
|
||||
extends PhabricatorRepositoryController {
|
||||
|
||||
private $id;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = $data['id'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$project = id(new PhabricatorRepositoryArcanistProject())->load($this->id);
|
||||
if (!$project) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$repositories = id(new PhabricatorRepository())->loadAll();
|
||||
$repos = array(
|
||||
0 => 'None',
|
||||
);
|
||||
foreach ($repositories as $repository) {
|
||||
$callsign = $repository->getCallsign();
|
||||
$name = $repository->getname();
|
||||
$repos[$repository->getID()] = "r{$callsign} ({$name})";
|
||||
}
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$repo_id = $request->getInt('repository', 0);
|
||||
if (isset($repos[$repo_id])) {
|
||||
$project->setRepositoryID($repo_id);
|
||||
$project->save();
|
||||
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/repository/');
|
||||
}
|
||||
}
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($user)
|
||||
->appendChild(
|
||||
id(new AphrontFormStaticControl())
|
||||
->setLabel('Name')
|
||||
->setValue($project->getName()))
|
||||
->appendChild(
|
||||
id(new AphrontFormStaticControl())
|
||||
->setLabel('PHID')
|
||||
->setValue($project->getPHID()))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel('Repository')
|
||||
->setOptions($repos)
|
||||
->setName('repository')
|
||||
->setValue($project->getRepositoryID()))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->addCancelButton('/repository/')
|
||||
->setValue('Save'));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
|
||||
$panel->setHeader('Edit Arcanist Project');
|
||||
$panel->appendChild($form);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$panel,
|
||||
array(
|
||||
'title' => 'Edit Project',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/404');
|
||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||
phutil_require_module('phabricator', 'applications/repository/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/arcanistproject');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/repository');
|
||||
phutil_require_module('phabricator', 'view/form/base');
|
||||
phutil_require_module('phabricator', 'view/form/control/submit');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorRepositoryArcanistProjectEditController.php');
|
||||
@@ -86,8 +86,53 @@ class PhabricatorRepositoryListController
|
||||
$panel->setCreateButton('Create New Repository', '/repository/create/');
|
||||
$panel->appendChild($table);
|
||||
|
||||
$projects = id(new PhabricatorRepositoryArcanistProject())->loadAll();
|
||||
|
||||
$rows = array();
|
||||
foreach ($projects as $project) {
|
||||
$repo = idx($repos, $project->getRepositoryID());
|
||||
if ($repo) {
|
||||
$repo_name = phutil_escape_html($repo->getName());
|
||||
} else {
|
||||
$repo_name = '-';
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
phutil_escape_html($project->getName()),
|
||||
$repo_name,
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/repository/project/'.$project->getID().'/',
|
||||
'class' => 'button grey small',
|
||||
),
|
||||
'Edit'),
|
||||
);
|
||||
}
|
||||
|
||||
$project_table = new AphrontTableView($rows);
|
||||
$project_table->setHeaders(
|
||||
array(
|
||||
'Project ID',
|
||||
'Repository',
|
||||
'',
|
||||
));
|
||||
$project_table->setColumnClasses(
|
||||
array(
|
||||
'',
|
||||
'wide',
|
||||
'action',
|
||||
));
|
||||
|
||||
$project_panel = new AphrontPanelView();
|
||||
$project_panel->setHeader('Arcanist Projects');
|
||||
$project_panel->appendChild($project_table);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$panel,
|
||||
array(
|
||||
$panel,
|
||||
$project_panel,
|
||||
),
|
||||
array(
|
||||
'title' => 'Repository List',
|
||||
));
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
phutil_require_module('phabricator', 'applications/repository/constants/repositorytype');
|
||||
phutil_require_module('phabricator', 'applications/repository/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/arcanistproject');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/repository');
|
||||
phutil_require_module('phabricator', 'view/control/table');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
Reference in New Issue
Block a user