1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Allow configuration of Differential custom fields

Summary: Ref T2222. Ref T3886. This is a little early for general use, but the message parse/generate stuff requires CustomFields and FieldSpecifications to be closely aligned, so this provides at least a plausbile approach for any installs that run into trouble.

Test Plan: Viewed config; reordered fields.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2222, T3886

Differential Revision: https://secure.phabricator.com/D8450
This commit is contained in:
epriestley 2014-03-08 09:13:51 -08:00
parent ae3c1f7819
commit 6dd191a3c1
14 changed files with 99 additions and 38 deletions

View file

@ -12,7 +12,60 @@ final class PhabricatorDifferentialConfigOptions
}
public function getOptions() {
$custom_field_type = 'custom:PhabricatorCustomFieldConfigOptionType';
$fields = array(
new DifferentialTitleField(),
new DifferentialSummaryField(),
new DifferentialTestPlanField(),
new DifferentialAuthorField(),
new DifferentialReviewersField(),
new DifferentialProjectReviewersField(),
new DifferentialReviewedByField(),
new DifferentialSubscribersField(),
new DifferentialRepositoryField(),
new DifferentialLintField(),
new DifferentialUnitField(),
new DifferentialViewPolicyField(),
new DifferentialEditPolicyField(),
new DifferentialDependsOnField(),
new DifferentialDependenciesField(),
new DifferentialManiphestTasksField(),
new DifferentialCommitsField(),
new DifferentialJIRAIssuesField(),
new DifferentialAsanaRepresentationField(),
new DifferentialBlameRevisionField(),
new DifferentialPathField(),
new DifferentialHostField(),
new DifferentialRevertPlanField(),
new DifferentialApplyPatchField(),
new DifferentialRevisionIDField(),
);
$default_fields = array();
foreach ($fields as $field) {
$default_fields[$field->getFieldKey()] = array(
'disabled' => $field->shouldDisableByDefault(),
);
}
return array(
$this->newOption(
'differential.fields',
$custom_field_type,
$default_fields)
->setCustomData(
id(new DifferentialRevision())->getCustomFieldBaseClass())
->setDescription(
pht(
"Select and reorder revision fields.\n\n".
"NOTE: This feature is under active development and subject ".
"to change.")),
$this->newOption(
'differential.whitespace-matters',
'list<regex>',

View file

@ -11,6 +11,10 @@ final class DifferentialAsanaRepresentationField
return pht('In Asana');
}
public function canDisableField() {
return false;
}
public function getFieldDescription() {
return pht('Shows revision representation in Asana.');
}

View file

@ -32,6 +32,10 @@ final class DifferentialAuditorsField
return true;
}
public function canDisableField() {
return false;
}
public function getRequiredHandlePHIDsForCommitMessage() {
return nonempty($this->getValue(), array());
}

View file

@ -15,6 +15,10 @@ final class DifferentialAuthorField
return pht('Stores the revision author.');
}
public function canDisableField() {
return false;
}
public function shouldAppearInPropertyView() {
return true;
}

View file

@ -107,7 +107,7 @@ final class DifferentialBlameRevisionField
);
}
public function renderCommitMessageValue() {
public function renderCommitMessageValue(array $handles) {
return $this->getValue();
}

View file

@ -11,6 +11,10 @@ final class DifferentialCommitsField
return pht('Commits');
}
public function canDisableField() {
return false;
}
public function getFieldDescription() {
return pht('Shows associated commits.');
}

View file

@ -11,6 +11,10 @@ final class DifferentialDependenciesField
return pht('Dependencies');
}
public function canDisableField() {
return false;
}
public function getFieldDescription() {
return pht('Lists revisions this one is depended on by.');
}

View file

@ -11,6 +11,10 @@ final class DifferentialDependsOnField
return pht('Depends On');
}
public function canDisableField() {
return false;
}
public function getFieldDescription() {
return pht('Lists revisions this one depends on.');
}

View file

@ -13,6 +13,10 @@ final class DifferentialJIRAIssuesField
return 'jira.issues';
}
public function canDisableField() {
return false;
}
public function getValueForStorage() {
return json_encode($this->getValue());
}

View file

@ -11,6 +11,10 @@ final class DifferentialManiphestTasksField
return 'maniphestTaskPHIDs';
}
public function canDisableField() {
return false;
}
public function getFieldName() {
return pht('Maniphest Tasks');
}

View file

@ -19,6 +19,10 @@ final class DifferentialProjectReviewersField
return true;
}
public function canDisableField() {
return false;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}

View file

@ -27,6 +27,10 @@ final class DifferentialReviewedByField
return false;
}
public function canDisableField() {
return true;
}
protected function readValueFromRevision(
DifferentialRevision $revision) {

View file

@ -4,6 +4,10 @@ final class DifferentialRevisionIDField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:revision-id';
}
public function getFieldKeyForConduit() {
return 'revisionID';
}

View file

@ -481,43 +481,7 @@ final class DifferentialRevision extends DifferentialDAO
public function getCustomFieldSpecificationForRole($role) {
$fields = array(
new DifferentialAuthorField(),
new DifferentialTitleField(),
new DifferentialSummaryField(),
new DifferentialTestPlanField(),
new DifferentialReviewersField(),
new DifferentialProjectReviewersField(),
new DifferentialSubscribersField(),
new DifferentialRepositoryField(),
new DifferentialViewPolicyField(),
new DifferentialEditPolicyField(),
new DifferentialDependsOnField(),
new DifferentialDependenciesField(),
new DifferentialManiphestTasksField(),
new DifferentialCommitsField(),
new DifferentialJIRAIssuesField(),
new DifferentialAsanaRepresentationField(),
new DifferentialBlameRevisionField(),
new DifferentialPathField(),
new DifferentialHostField(),
new DifferentialRevertPlanField(),
new DifferentialApplyPatchField(),
);
$result = array();
foreach ($fields as $field) {
$result[$field->getFieldKey()] = array(
'disabled' => $field->shouldDisableByDefault(),
);
}
return $result;
return PhabricatorEnv::getEnvConfig('differential.fields');
}
public function getCustomFieldBaseClass() {