Differential D17054 Diff 41023 src/applications/differential/editor/DifferentialRevisionEditEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/editor/DifferentialRevisionEditEngine.php
| Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | protected function buildCustomEditFields($object) { | ||||
| $diff = $this->getDiff(); | $diff = $this->getDiff(); | ||||
| if ($diff) { | if ($diff) { | ||||
| $diff_phid = $diff->getPHID(); | $diff_phid = $diff->getPHID(); | ||||
| } else { | } else { | ||||
| $diff_phid = null; | $diff_phid = null; | ||||
| } | } | ||||
| $is_update = ($diff && $object->getID()); | $is_create = $this->getIsCreate(); | ||||
| $is_update = ($diff && !$is_create); | |||||
| $fields = array(); | $fields = array(); | ||||
| if ($diff || $is_create) { | |||||
| $fields[] = id(new PhabricatorHandlesEditField()) | $fields[] = id(new PhabricatorHandlesEditField()) | ||||
| ->setKey('update') | ->setKey('update') | ||||
| ->setLabel(pht('Update Diff')) | ->setLabel(pht('Update Diff')) | ||||
| ->setDescription(pht('New diff to create or update the revision with.')) | ->setDescription(pht('New diff to create or update the revision with.')) | ||||
| ->setConduitDescription(pht('Create or update a revision with a diff.')) | ->setConduitDescription(pht('Create or update a revision with a diff.')) | ||||
| ->setConduitTypeDescription(pht('PHID of the diff.')) | ->setConduitTypeDescription(pht('PHID of the diff.')) | ||||
| ->setTransactionType(DifferentialTransaction::TYPE_UPDATE) | ->setTransactionType(DifferentialTransaction::TYPE_UPDATE) | ||||
| ->setHandleParameterType(new AphrontPHIDListHTTPParameterType()) | ->setHandleParameterType(new AphrontPHIDListHTTPParameterType()) | ||||
| ->setSingleValue($diff_phid) | ->setSingleValue($diff_phid) | ||||
| ->setIsReorderable(false) | ->setIsReorderable(false) | ||||
| ->setIsDefaultable(false) | ->setIsDefaultable(false) | ||||
| ->setIsInvisible(true) | ->setIsInvisible(true) | ||||
| ->setIsLockable(false); | ->setIsLockable(false); | ||||
| } | |||||
| if ($is_update) { | if ($is_update) { | ||||
| $fields[] = id(new PhabricatorInstructionsEditField()) | $fields[] = id(new PhabricatorInstructionsEditField()) | ||||
| ->setKey('update.help') | ->setKey('update.help') | ||||
| ->setValue(pht('Describe the updates you have made to the diff.')); | ->setValue(pht('Describe the updates you have made to the diff.')); | ||||
| $fields[] = id(new PhabricatorCommentEditField()) | $fields[] = id(new PhabricatorCommentEditField()) | ||||
| ->setKey('update.comment') | ->setKey('update.comment') | ||||
| ->setLabel(pht('Comment')) | ->setLabel(pht('Comment')) | ||||
| ▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | $fields[] = id(new PhabricatorDatasourceEditField()) | ||||
| ->setSingleValue($object->getRepositoryPHID()); | ->setSingleValue($object->getRepositoryPHID()); | ||||
| return $fields; | return $fields; | ||||
| } | } | ||||
| private function isCustomFieldEnabled(DifferentialRevision $revision, $key) { | private function isCustomFieldEnabled(DifferentialRevision $revision, $key) { | ||||
| $field_list = PhabricatorCustomField::getObjectFields( | $field_list = PhabricatorCustomField::getObjectFields( | ||||
| $revision, | $revision, | ||||
| PhabricatorCustomField::ROLE_EDIT); | PhabricatorCustomField::ROLE_VIEW); | ||||
| $fields = $field_list->getFields(); | $fields = $field_list->getFields(); | ||||
| return isset($fields[$key]); | return isset($fields[$key]); | ||||
| } | } | ||||
| } | } | ||||