1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +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() { 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( 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( $this->newOption(
'differential.whitespace-matters', 'differential.whitespace-matters',
'list<regex>', 'list<regex>',

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -481,43 +481,7 @@ final class DifferentialRevision extends DifferentialDAO
public function getCustomFieldSpecificationForRole($role) { public function getCustomFieldSpecificationForRole($role) {
$fields = array( return PhabricatorEnv::getEnvConfig('differential.fields');
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;
} }
public function getCustomFieldBaseClass() { public function getCustomFieldBaseClass() {