Allow projects to be archived.

Closes #771
This commit is contained in:
Alex Davyskiba 2015-01-31 11:50:57 +02:00 committed by Dan Cryer
parent edd26d12be
commit 36b39bfc0d
17 changed files with 107 additions and 3 deletions

View file

@ -137,7 +137,13 @@ class Application extends b8\Application
{
/** @var \PHPCI\Store\ProjectStore $projectStore */
$projectStore = b8\Store\Factory::getStore('Project');
$layout->projects = $projectStore->getAll();
$layout->projects = $projectStore->getWhere(
array('archived' => (int)isset($_GET['archived'])),
50,
0,
array(),
array('title' => 'ASC')
);
}
/**

View file

@ -48,7 +48,13 @@ class HomeController extends \PHPCI\Controller
{
$this->layout->title = Lang::get('dashboard');
$projects = $this->projectStore->getWhere(array(), 50, 0, array(), array('title' => 'ASC'));
$projects = $this->projectStore->getWhere(
array('archived' => (int)isset($_GET['archived'])),
50,
0,
array(),
array('title' => 'ASC')
);
$builds = $this->buildStore->getLatestBuilds(null, 10);

View file

@ -282,6 +282,7 @@ class ProjectController extends PHPCI\Controller
'ssh_public_key' => $this->getParam('pubkey', null),
'build_config' => $this->getParam('build_config', null),
'allow_public_status' => $this->getParam('allow_public_status', 0),
'archived' => $this->getParam('archived', 0),
'branch' => $this->getParam('branch', null),
);
@ -357,6 +358,12 @@ class ProjectController extends PHPCI\Controller
$field->setValue(0);
$form->addField($field);
$field = Form\Element\Checkbox::create('archived', Lang::get('archived'), false);
$field->setContainerClass('form-group');
$field->setCheckedValue(1);
$field->setValue(0);
$form->addField($field);
$field = new Form\Element\Submit();
$field->setValue(Lang::get('save_project'));
$field->setContainerClass('form-group');

View file

@ -112,6 +112,7 @@ i din foretrukne hosting-platform.',
(hvis du ikke har mulighed for at tilføje en phpci.yml fil i projektets repository)',
'default_branch' => 'Default branch navn',
'allow_public_status' => 'Tillad offentlig status-side og -billede for dette projekt?',
'archived' => 'Archived',
'save_project' => 'Gem Projekt',
'error_mercurial' => 'Mercurial repository-URL skal starte med http:// eller https://',

View file

@ -113,6 +113,7 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab
(falls Sie Ihrem Projektrepository kein phpci.yml hinzufügen können)',
'default_branch' => 'Name des Standardbranches',
'allow_public_status' => 'Öffentliche Statusseite und -bild für dieses Projekt einschalten?',
'archived' => 'Archived',
'save_project' => 'Projekt speichern',
'error_mercurial' => 'Mercurial Repository-URL muss mit http://, oder https:// beginnen',

View file

@ -113,6 +113,7 @@ PHPCI',
(αν δεν μπορείτε να προσθέσετε ένα αρχείο phpci.yml στο αποθετήριο έργων)',
'default_branch' => 'Προκαθορισμένο όνομα διακλάδωσης',
'allow_public_status' => 'Ενεργοποίηση της σελίδας δημόσιας κατάστασης και την εικόνα για το έργο αυτό;',
'archived' => 'Archived',
'save_project' => 'Αποθήκευση έργου',
'error_mercurial' => 'Ο σύνδεσμος URL του ευμετάβλητου αποθετηρίου πρέπει να ξεκινάει με http:// ή https://',

View file

@ -114,6 +114,7 @@ PHPCI',
(if you cannot add a phpci.yml file in the project repository)',
'default_branch' => 'Default branch name',
'allow_public_status' => 'Enable public status page and image for this project?',
'archived' => 'Archived',
'save_project' => 'Save Project',
'error_mercurial' => 'Mercurial repository URL must be start with http:// or https://',

View file

@ -113,6 +113,7 @@ PHPCI',
(si vous ne pouvez pas ajouter de fichier phpci.yml à la racine du dépôt)',
'default_branch' => 'Nom de la branche par défaut',
'allow_public_status' => 'Activer la page de statut publique et l\'image pour ce projet ?',
'archived' => 'Archived',
'save_project' => 'Enregistrer le projet',
'error_mercurial' => 'Les URLs de dépôt Mercurial doivent commencer par http:// ou https://',

View file

@ -113,6 +113,7 @@ PHPCI',
'default_branch' => 'Nome del branch di default',
'allow_public_status' => 'Vuoi rendere pubblica la pagina dello stato e l\'immagine per questo progetto?',
'save_project' => 'Salva il Progetto',
'archived' => 'Archived',
'error_mercurial' => 'L\'URL del repository Mercurial URL deve iniziare con http:// o https://',
'error_remote' => 'L\'URL del repository deve iniziare con git://, http:// o https://',

View file

@ -113,6 +113,7 @@ van je gekozen source code hosting platform',
(indien je geen phpci.yml bestand aan de project repository kan toevoegen)',
'default_branch' => 'Standaard branch naam',
'allow_public_status' => 'Publieke statuspagina en afbeelding beschikbaar maken voor dit project?',
'archived' => 'Archived',
'save_project' => 'Project opslaan',
'error_mercurial' => 'Mercurial repository URL dient te starten met http:// of https://',

View file

@ -114,6 +114,7 @@ od wybranego kodu źródłowego platformy hostingowej.',
(jeśli nie możesz dodać pliku phpci.yml do repozytorium projektu)',
'default_branch' => 'Domyślna nazwa gałęzi',
'allow_public_status' => 'Włączyć status publiczny dla tego projektu?',
'archived' => 'Archived',
'save_project' => 'Zachowaj Projekt',
'error_mercurial' => 'URL repozytorium Mercurialnego powinno zaczynać się od http:// and https://',

View file

@ -112,6 +112,7 @@ PHPCI',
(если вы не добавили файл phpci.yml в репозиторий вашего проекта)',
'default_branch' => 'Ветка по умолчанию',
'allow_public_status' => 'Разрешить публичный статус и изображение (статуса) для проекта',
'archived' => 'Archived',
'save_project' => 'Сохранить проект',
'error_mercurial' => 'URL репозитория Mercurial должен начинаться с http:// или https://',

View file

@ -112,6 +112,7 @@ PHPCI',
(якщо ви не додали файл phpci.yml до репозиторію вашого проекту)',
'default_branch' => 'Назва гілки за замовчуванням',
'allow_public_status' => 'Увімкнути публічну сторінку статусу та зображення для цього проекта?',
'archived' => 'Archived',
'save_project' => 'Зберегти проект',
'error_mercurial' => 'URL репозиторію Mercurial повинен починатись із http:// або https://',

View file

@ -0,0 +1,26 @@
<?php
use Phinx\Migration\AbstractMigration;
class ArchiveProject extends AbstractMigration
{
/**
* Migrate Up.
*/
public function up()
{
$project = $this->table('project');
$project->addColumn('archived', 'boolean');
$project->save();
}
/**
* Migrate Down.
*/
public function down()
{
$project = $this->table('project');
$project->removeColumn('archived');
$project->save();
}
}

View file

@ -44,6 +44,7 @@ class ProjectBase extends Model
'build_config' => null,
'ssh_public_key' => null,
'allow_public_status' => null,
'archived' => null,
);
/**
@ -62,6 +63,7 @@ class ProjectBase extends Model
'build_config' => 'getBuildConfig',
'ssh_public_key' => 'getSshPublicKey',
'allow_public_status' => 'getAllowPublicStatus',
'archived' => 'getArchived',
// Foreign key getters:
);
@ -82,6 +84,7 @@ class ProjectBase extends Model
'build_config' => 'setBuildConfig',
'ssh_public_key' => 'setSshPublicKey',
'allow_public_status' => 'setAllowPublicStatus',
'archived' => 'setArchived',
// Foreign key setters:
);
@ -148,6 +151,12 @@ class ProjectBase extends Model
'type' => 'int',
'length' => 11,
),
'archived' => array(
'type' => 'tinyint',
'length' => 4,
'nullable' => true,
'default' => null,
),
);
/**
@ -296,6 +305,18 @@ class ProjectBase extends Model
return $rtn;
}
/**
* Get the value of Archived / archived.
*
* @return int
*/
public function getArchived()
{
$rtn = $this->data['archived'];
return $rtn;
}
/**
* Set the value of Id / id.
*
@ -506,6 +527,24 @@ class ProjectBase extends Model
$this->_setModified('allow_public_status');
}
/**
* Set the value of Archived / archived.
*
* @param $value int
*/
public function setArchived($value)
{
$this->_validateInt('Archived', $value);
if ($this->data['archived'] === $value) {
return;
}
$this->data['archived'] = $value;
$this->_setModified('archived');
}
/**
* Get Build models by ProjectId for this Project.
*

View file

@ -81,6 +81,10 @@ class ProjectService
$project->setAllowPublicStatus((int)$options['allow_public_status']);
}
if (array_key_exists('archived', $options)) {
$project->setArchived((bool)$options['archived']);
}
if (array_key_exists('branch', $options)) {
$project->setBranch($options['branch']);
}

View file

@ -147,7 +147,7 @@
<i class="fa fa-dashboard"></i> <span><?php Lang::out('dashboard'); ?></span>
</a>
</li>
<?php if ($this->User()->getIsAdmin()): ?>
<li class="treeview">
<a href="#">
@ -242,6 +242,12 @@
</li>
<?php endif; ?>
<li class="archive">
<a href="<?php print PHPCI_URL; ?>?archived">
<i class="fa fa-archive"></i> <span><?php Lang::out('archived'); ?></span>
</a>
</li>
</ul>
</section>
<!-- /.sidebar -->