1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-21 17:58:47 +02:00
phorge-phorge/src/applications/releeph/storage/ReleephProject.php

164 lines
3.9 KiB
PHP
Raw Normal View History

<?php
final class ReleephProject extends ReleephDAO
Transactions - deploy buildTransactionTimeline to remaining applications Summary: Ref T4712. Specifically... - Differential - needed getApplicationTransactionViewObject() implemented - Audit - needed getApplicationTransactionViewObject() implemented - Repository - one object needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) - Ponder - BONUS BUG FIX - leaving a comment on an answer had a bad redirect URI - both PonderQuestion and PonderAnswer needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) on both "history" controllers - left a "TODO" on buildAnswers on the question view controller, which is non-standard and should be re-written eventually - Phortune - BONUS BUG FIX - fix new user "createNewAccount" code to not fatal - PhortuneAccount, PhortuneMerchant, and PhortuneCart needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) on Account view, merchant view, and cart view controller - Fund - Legalpad - Nuance - NuanceSource needed PhabricatorApplicationTransactionInterface implemented - Releeph (this product is kind of a mess...) - HACKQUEST - had to manually create an arcanist project to even be able to make a "product" and get started...! - BONUS BUG FIX - make sure to "setName" on product edit - ReleephProject (should be ReleepProduct...?), ReleephBranch, and ReleepRequest needed PhabricatorApplicationTransactionInterface implemented - Harbormaster - HarbormasterBuildable, HarbormasterBuild, HarbormasterBuildPlan, and HarbormasterBuildStep all needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) all over the place Test Plan: foreach application, viewed the timeline(s) and made sure they still rendered Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T4712 Differential Revision: https://secure.phabricator.com/D10925
2014-12-04 00:35:47 +01:00
implements
PhabricatorApplicationTransactionInterface,
PhabricatorPolicyInterface {
const DEFAULT_BRANCH_NAMESPACE = 'releeph-releases';
const SYSTEM_AGENT_USERNAME_PREFIX = 'releeph-agent-';
protected $name;
// Specifying the place to pick from is a requirement for svn, though not
// for git. It's always useful though for reasoning about what revs have
// been picked and which haven't.
protected $trunkBranch;
protected $repositoryPHID;
protected $isActive;
protected $createdByUserPHID;
protected $arcanistProjectID;
protected $details = array();
private $repository = self::ATTACHABLE;
protected function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_SERIALIZATION => array(
'details' => self::SERIALIZATION_JSON,
),
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text128',
'trunkBranch' => 'text255',
'isActive' => 'bool',
'arcanistProjectID' => 'id?',
),
self::CONFIG_KEY_SCHEMA => array(
'projectName' => array(
'columns' => array('name'),
'unique' => true,
),
),
) + parent::getConfiguration();
}
public function generatePHID() {
return PhabricatorPHID::generateNewPHID(ReleephProductPHIDType::TYPECONST);
}
public function getDetail($key, $default = null) {
return idx($this->details, $key, $default);
}
public function getURI($path = null) {
$components = array(
'/releeph/product',
$this->getID(),
$path,
);
return implode('/', $components);
}
public function setDetail($key, $value) {
$this->details[$key] = $value;
return $this;
}
public function getPushers() {
return $this->getDetail('pushers', array());
}
public function isPusher(PhabricatorUser $user) {
// TODO Deprecate this once `isPusher` is out of the Facebook codebase.
return $this->isAuthoritative($user);
}
public function isAuthoritative(PhabricatorUser $user) {
return $this->isAuthoritativePHID($user->getPHID());
}
public function isAuthoritativePHID($phid) {
$pushers = $this->getPushers();
if (!$pushers) {
return true;
} else {
return in_array($phid, $pushers);
}
}
public function attachRepository(PhabricatorRepository $repository) {
$this->repository = $repository;
return $this;
}
public function getRepository() {
return $this->assertAttached($this->repository);
}
public function getReleephFieldSelector() {
return new ReleephDefaultFieldSelector();
}
public function isTestFile($filename) {
$test_paths = $this->getDetail('testPaths', array());
foreach ($test_paths as $test_path) {
if (preg_match($test_path, $filename)) {
return true;
}
}
return false;
}
Transactions - deploy buildTransactionTimeline to remaining applications Summary: Ref T4712. Specifically... - Differential - needed getApplicationTransactionViewObject() implemented - Audit - needed getApplicationTransactionViewObject() implemented - Repository - one object needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) - Ponder - BONUS BUG FIX - leaving a comment on an answer had a bad redirect URI - both PonderQuestion and PonderAnswer needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) on both "history" controllers - left a "TODO" on buildAnswers on the question view controller, which is non-standard and should be re-written eventually - Phortune - BONUS BUG FIX - fix new user "createNewAccount" code to not fatal - PhortuneAccount, PhortuneMerchant, and PhortuneCart needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) on Account view, merchant view, and cart view controller - Fund - Legalpad - Nuance - NuanceSource needed PhabricatorApplicationTransactionInterface implemented - Releeph (this product is kind of a mess...) - HACKQUEST - had to manually create an arcanist project to even be able to make a "product" and get started...! - BONUS BUG FIX - make sure to "setName" on product edit - ReleephProject (should be ReleepProduct...?), ReleephBranch, and ReleepRequest needed PhabricatorApplicationTransactionInterface implemented - Harbormaster - HarbormasterBuildable, HarbormasterBuild, HarbormasterBuildPlan, and HarbormasterBuildStep all needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) all over the place Test Plan: foreach application, viewed the timeline(s) and made sure they still rendered Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T4712 Differential Revision: https://secure.phabricator.com/D10925
2014-12-04 00:35:47 +01:00
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
public function getApplicationTransactionEditor() {
return new ReleephProductEditor();
}
public function getApplicationTransactionObject() {
return $this;
}
public function getApplicationTransactionTemplate() {
return new ReleephProductTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
Transactions - deploy buildTransactionTimeline to remaining applications Summary: Ref T4712. Specifically... - Differential - needed getApplicationTransactionViewObject() implemented - Audit - needed getApplicationTransactionViewObject() implemented - Repository - one object needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) - Ponder - BONUS BUG FIX - leaving a comment on an answer had a bad redirect URI - both PonderQuestion and PonderAnswer needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) on both "history" controllers - left a "TODO" on buildAnswers on the question view controller, which is non-standard and should be re-written eventually - Phortune - BONUS BUG FIX - fix new user "createNewAccount" code to not fatal - PhortuneAccount, PhortuneMerchant, and PhortuneCart needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) on Account view, merchant view, and cart view controller - Fund - Legalpad - Nuance - NuanceSource needed PhabricatorApplicationTransactionInterface implemented - Releeph (this product is kind of a mess...) - HACKQUEST - had to manually create an arcanist project to even be able to make a "product" and get started...! - BONUS BUG FIX - make sure to "setName" on product edit - ReleephProject (should be ReleepProduct...?), ReleephBranch, and ReleepRequest needed PhabricatorApplicationTransactionInterface implemented - Harbormaster - HarbormasterBuildable, HarbormasterBuild, HarbormasterBuildPlan, and HarbormasterBuildStep all needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) all over the place Test Plan: foreach application, viewed the timeline(s) and made sure they still rendered Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T4712 Differential Revision: https://secure.phabricator.com/D10925
2014-12-04 00:35:47 +01:00
/* -( PhabricatorPolicyInterface )----------------------------------------- */
Transactions - deploy buildTransactionTimeline to remaining applications Summary: Ref T4712. Specifically... - Differential - needed getApplicationTransactionViewObject() implemented - Audit - needed getApplicationTransactionViewObject() implemented - Repository - one object needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) - Ponder - BONUS BUG FIX - leaving a comment on an answer had a bad redirect URI - both PonderQuestion and PonderAnswer needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) on both "history" controllers - left a "TODO" on buildAnswers on the question view controller, which is non-standard and should be re-written eventually - Phortune - BONUS BUG FIX - fix new user "createNewAccount" code to not fatal - PhortuneAccount, PhortuneMerchant, and PhortuneCart needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) on Account view, merchant view, and cart view controller - Fund - Legalpad - Nuance - NuanceSource needed PhabricatorApplicationTransactionInterface implemented - Releeph (this product is kind of a mess...) - HACKQUEST - had to manually create an arcanist project to even be able to make a "product" and get started...! - BONUS BUG FIX - make sure to "setName" on product edit - ReleephProject (should be ReleepProduct...?), ReleephBranch, and ReleepRequest needed PhabricatorApplicationTransactionInterface implemented - Harbormaster - HarbormasterBuildable, HarbormasterBuild, HarbormasterBuildPlan, and HarbormasterBuildStep all needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) all over the place Test Plan: foreach application, viewed the timeline(s) and made sure they still rendered Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T4712 Differential Revision: https://secure.phabricator.com/D10925
2014-12-04 00:35:47 +01:00
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
Move edit/deactivate operations onto project view page in Releeph Summary: Ref T3092. Releeph's objects basically go like this: - At the top level, we have Projects (like "www" or "libphutil") - Each project has Branches (like "LATEST" or "v1.1.3") - Each branch has Requests (like pull requests, e.g. "please merge commit X into branch Y (in project Z)") Currently, there's no real "project detail" or "branch detail" page. Instead, we have a search results page for their contained objects. That is, the "project detail" page shows a list of branches in the project, using ApplicationSearch. This means that operations like "edit" and "deactivate" are one level up, on the respective list pages. Instead, move details onto the detail pages. This gives us more room for actions and information, and simplifies the list views. Basically, these are "detail pages" where the object content is a search interface. We do something simliar to this in Phame right now, although it's messier there (no ApplicationSearch yet). @chad, you might have some ideas here. Roughly, the design question is "How should we present an object's detail view when its content is really a search interface (Phame Blog for Posts, Releeph Project for Branches)?" I think the simple approach I've taken here (see screenshot) gives us reasonable results, but overall it's something we haven't done much or done too much thinking about, I think. Test Plan: {F54774} Reviewers: btrahan Reviewed By: btrahan CC: chad, aran Maniphest Tasks: T3092 Differential Revision: https://secure.phabricator.com/D6771
2013-08-20 03:30:30 +02:00
PhabricatorPolicyCapability::CAN_EDIT,
);
}
public function getPolicy($capability) {
return PhabricatorPolicies::POLICY_USER;
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}