1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-16 03:42:41 +01:00
phorge-phorge/src/applications/differential/customfield/DifferentialCustomField.php
epriestley 2a5cf5e1b7 Separate "Revision" and "Diff" fields in Differential
Summary:
Fixes T5138. Some of the "revision" properties are really "diff" properties, but we only show the properties for the most recent / current diff.

  - Immediately, this makes it hard or impossible to review, e.g., lint/unit results for older diffs.
  - Longer-term, these limits will become more problematic with more data on diffs after Harbormaster.

Instead, separate "revision" from "diff" properties.

(In the long term, it might make sense to show more diffs in this panel -- e.g., tabs for the 8 most recent updates or something -- but I went with the simplest approach for now since I don't have a clean way to deal with 100-update revisions offhand.)

Test Plan: {F500480}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: cburroughs, epriestley

Maniphest Tasks: T5138

Differential Revision: https://secure.phabricator.com/D13282
2015-06-16 08:53:40 -07:00

251 lines
5.5 KiB
PHP

<?php
/**
* @task commitmessage Integration with Commit Messages
* @task diff Integration with Diff Properties
*/
abstract class DifferentialCustomField
extends PhabricatorCustomField {
const ROLE_COMMITMESSAGE = 'differential:commitmessage';
const ROLE_COMMITMESSAGEEDIT = 'differential:commitmessageedit';
/**
* TODO: It would be nice to remove this, but a lot of different code is
* bound together by it. Until everything is modernized, retaining the old
* field keys is the only reasonable way to update things one piece
* at a time.
*/
public function getFieldKeyForConduit() {
return $this->getFieldKey();
}
public function shouldEnableForRole($role) {
switch ($role) {
case self::ROLE_COMMITMESSAGE:
return $this->shouldAppearInCommitMessage();
case self::ROLE_COMMITMESSAGEEDIT:
return $this->shouldAppearInCommitMessage() &&
$this->shouldAllowEditInCommitMessage();
}
return parent::shouldEnableForRole($role);
}
protected function parseObjectList(
$value,
array $types,
$allow_partial = false) {
return id(new PhabricatorObjectListQuery())
->setViewer($this->getViewer())
->setAllowedTypes($types)
->setObjectList($value)
->setAllowPartialResults($allow_partial)
->execute();
}
protected function renderObjectList(array $handles) {
if (!$handles) {
return null;
}
$out = array();
foreach ($handles as $handle) {
if ($handle->getPolicyFiltered()) {
$out[] = $handle->getPHID();
} else if ($handle->isComplete()) {
$out[] = $handle->getObjectName();
}
}
return implode(', ', $out);
}
public function getWarningsForDetailView() {
if ($this->getProxy()) {
return $this->getProxy()->getWarningsForDetailView();
}
return array();
}
public function getRequiredHandlePHIDsForRevisionHeaderWarnings() {
return array();
}
public function getWarningsForRevisionHeader(array $handles) {
return array();
}
/* -( Integration with Commit Messages )----------------------------------- */
/**
* @task commitmessage
*/
public function shouldAppearInCommitMessage() {
if ($this->getProxy()) {
return $this->getProxy()->shouldAppearInCommitMessage();
}
return false;
}
/**
* @task commitmessage
*/
public function shouldAppearInCommitMessageTemplate() {
if ($this->getProxy()) {
return $this->getProxy()->shouldAppearInCommitMessageTemplate();
}
return false;
}
/**
* @task commitmessage
*/
public function shouldAllowEditInCommitMessage() {
if ($this->getProxy()) {
return $this->getProxy()->shouldAllowEditInCommitMessage();
}
return true;
}
/**
* @task commitmessage
*/
public function getProTips() {
if ($this->getProxy()) {
return $this->getProxy()->getProTips();
}
return array();
}
/**
* @task commitmessage
*/
public function getCommitMessageLabels() {
if ($this->getProxy()) {
return $this->getProxy()->getCommitMessageLabels();
}
return array($this->renderCommitMessageLabel());
}
/**
* @task commitmessage
*/
public function parseValueFromCommitMessage($value) {
if ($this->getProxy()) {
return $this->getProxy()->parseValueFromCommitMessage($value);
}
return $value;
}
/**
* @task commitmessage
*/
public function readValueFromCommitMessage($value) {
if ($this->getProxy()) {
$this->getProxy()->readValueFromCommitMessage($value);
return $this;
}
return $this;
}
/**
* @task commitmessage
*/
public function shouldOverwriteWhenCommitMessageIsEdited() {
if ($this->getProxy()) {
return $this->getProxy()->shouldOverwriteWhenCommitMessageIsEdited();
}
return false;
}
/**
* @task commitmessage
*/
public function getRequiredHandlePHIDsForCommitMessage() {
if ($this->getProxy()) {
return $this->getProxy()->getRequiredHandlePHIDsForCommitMessage();
}
return array();
}
/**
* @task commitmessage
*/
public function renderCommitMessageLabel() {
if ($this->getProxy()) {
return $this->getProxy()->renderCommitMessageLabel();
}
return $this->getFieldName();
}
/**
* @task commitmessage
*/
public function renderCommitMessageValue(array $handles) {
if ($this->getProxy()) {
return $this->getProxy()->renderCommitMessageValue($handles);
}
throw new PhabricatorCustomFieldImplementationIncompleteException($this);
}
/**
* @task commitmessage
*/
public function validateCommitMessageValue($value) {
if ($this->getProxy()) {
return $this->getProxy()->validateCommitMessageValue($value);
}
return;
}
/* -( Integration with Diff Properties )----------------------------------- */
/**
* @task diff
*/
public function shouldAppearInDiffPropertyView() {
if ($this->getProxy()) {
return $this->getProxy()->shouldAppearInDiffPropertyView();
}
return false;
}
/**
* @task diff
*/
public function renderDiffPropertyViewLabel(DifferentialDiff $diff) {
if ($this->proxy) {
return $this->proxy->renderDiffPropertyViewLabel($diff);
}
return $this->getFieldName();
}
/**
* @task diff
*/
public function renderDiffPropertyViewValue(DifferentialDiff $diff) {
if ($this->proxy) {
return $this->proxy->renderDiffPropertyViewValue($diff);
}
throw new PhabricatorCustomFieldImplementationIncompleteException($this);
}
}