mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-15 11:22:40 +01:00
ab86523ac4
Summary: Fixes T10410. Immediate impact of this is that you can now actually delete properties from Almanac services, devices and bindings. The meat of the change is switching from CustomField to EditEngine for most of the actual editing logic. CustomField creates a lot of problems with using EditEngine for everything else (D15326), and weird, hard-to-resolve bugs like this one (not being able to delete stuff). Using EditEngine to do this stuff instead seems like it works out much better -- I did this in ProfilePanel first and am happy with how it looks. This also makes the internal storage for properties JSON instead of raw text. Test Plan: - Created, edited and deleted properties on services, devices and bindings. - Edited and reset builtin properties on repository services. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10410 Differential Revision: https://secure.phabricator.com/D15327
79 lines
1.8 KiB
PHP
79 lines
1.8 KiB
PHP
<?php
|
|
|
|
abstract class AlmanacPropertyEditEngine
|
|
extends PhabricatorEditEngine {
|
|
|
|
private $propertyKey;
|
|
|
|
public function setPropertyKey($property_key) {
|
|
$this->propertyKey = $property_key;
|
|
return $this;
|
|
}
|
|
|
|
public function getPropertyKey() {
|
|
return $this->propertyKey;
|
|
}
|
|
|
|
public function isEngineConfigurable() {
|
|
return false;
|
|
}
|
|
|
|
public function isEngineExtensible() {
|
|
return false;
|
|
}
|
|
|
|
public function getEngineName() {
|
|
return pht('Almanac Properties');
|
|
}
|
|
|
|
public function getSummaryHeader() {
|
|
return pht('Edit Almanac Property Configurations');
|
|
}
|
|
|
|
public function getSummaryText() {
|
|
return pht('This engine is used to edit Almanac properties.');
|
|
}
|
|
|
|
public function getEngineApplicationClass() {
|
|
return 'PhabricatorAlmanacApplication';
|
|
}
|
|
|
|
protected function newEditableObject() {
|
|
throw new PhutilMethodNotImplementedException();
|
|
}
|
|
|
|
protected function getObjectCreateTitleText($object) {
|
|
return pht('Create Property');
|
|
}
|
|
|
|
protected function getObjectCreateButtonText($object) {
|
|
return pht('Create Property');
|
|
}
|
|
|
|
protected function getObjectEditTitleText($object) {
|
|
return pht('Edit Property: %s', $object->getName());
|
|
}
|
|
|
|
protected function getObjectEditShortText($object) {
|
|
return pht('Edit Property');
|
|
}
|
|
|
|
protected function getObjectCreateShortText() {
|
|
return pht('Create Property');
|
|
}
|
|
|
|
protected function buildCustomEditFields($object) {
|
|
$property_key = $this->getPropertyKey();
|
|
$xaction_type = AlmanacTransaction::TYPE_PROPERTY_UPDATE;
|
|
|
|
return array(
|
|
id(new PhabricatorTextEditField())
|
|
->setKey('value')
|
|
->setMetadataValue('almanac.property', $property_key)
|
|
->setLabel($property_key)
|
|
->setTransactionType($xaction_type)
|
|
->setValue($object->getAlmanacPropertyValue($property_key)),
|
|
);
|
|
}
|
|
|
|
}
|