mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
Add a "Description" field to Spaces
Summary: Ref T8377. - Add a description field. - Add edges so files can be attached. Test Plan: {F492410} Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T8377 Differential Revision: https://secure.phabricator.com/D13235
This commit is contained in:
parent
d118800d37
commit
814b586f5d
10 changed files with 113 additions and 3 deletions
2
resources/sql/autopatches/20150610.spaces.1.desc.sql
Normal file
2
resources/sql/autopatches/20150610.spaces.1.desc.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE {$NAMESPACE}_spaces.spaces_namespace
|
||||
ADD description LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL;
|
16
resources/sql/autopatches/20150610.spaces.2.edge.sql
Normal file
16
resources/sql/autopatches/20150610.spaces.2.edge.sql
Normal file
|
@ -0,0 +1,16 @@
|
|||
CREATE TABLE {$NAMESPACE}_spaces.edge (
|
||||
src VARBINARY(64) NOT NULL,
|
||||
type INT UNSIGNED NOT NULL,
|
||||
dst VARBINARY(64) NOT NULL,
|
||||
dateCreated INT UNSIGNED NOT NULL,
|
||||
seq INT UNSIGNED NOT NULL,
|
||||
dataID INT UNSIGNED,
|
||||
PRIMARY KEY (src, type, dst),
|
||||
KEY `src` (src, type, dateCreated, seq),
|
||||
UNIQUE KEY `key_dst` (dst, type, src)
|
||||
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
|
||||
|
||||
CREATE TABLE {$NAMESPACE}_spaces.edgedata (
|
||||
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
data LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}
|
||||
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
|
|
@ -2594,6 +2594,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorSpacesNamespaceTransaction' => 'applications/spaces/storage/PhabricatorSpacesNamespaceTransaction.php',
|
||||
'PhabricatorSpacesNamespaceTransactionQuery' => 'applications/spaces/query/PhabricatorSpacesNamespaceTransactionQuery.php',
|
||||
'PhabricatorSpacesRemarkupRule' => 'applications/spaces/remarkup/PhabricatorSpacesRemarkupRule.php',
|
||||
'PhabricatorSpacesSchemaSpec' => 'applications/spaces/storage/PhabricatorSpacesSchemaSpec.php',
|
||||
'PhabricatorSpacesTestCase' => 'applications/spaces/__tests__/PhabricatorSpacesTestCase.php',
|
||||
'PhabricatorSpacesViewController' => 'applications/spaces/controller/PhabricatorSpacesViewController.php',
|
||||
'PhabricatorStandardCustomField' => 'infrastructure/customfield/standard/PhabricatorStandardCustomField.php',
|
||||
|
@ -6110,6 +6111,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorSpacesNamespaceTransaction' => 'PhabricatorApplicationTransaction',
|
||||
'PhabricatorSpacesNamespaceTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||
'PhabricatorSpacesRemarkupRule' => 'PhabricatorObjectRemarkupRule',
|
||||
'PhabricatorSpacesSchemaSpec' => 'PhabricatorConfigSchemaSpec',
|
||||
'PhabricatorSpacesTestCase' => 'PhabricatorTestCase',
|
||||
'PhabricatorSpacesViewController' => 'PhabricatorSpacesController',
|
||||
'PhabricatorStandardCustomField' => 'PhabricatorCustomField',
|
||||
|
|
|
@ -54,6 +54,7 @@ final class PhabricatorSpacesEditController
|
|||
$validation_exception = null;
|
||||
$e_name = true;
|
||||
$v_name = $space->getNamespaceName();
|
||||
$v_desc = $space->getDescription();
|
||||
$v_view = $space->getViewPolicy();
|
||||
$v_edit = $space->getEditPolicy();
|
||||
|
||||
|
@ -62,10 +63,12 @@ final class PhabricatorSpacesEditController
|
|||
$e_name = null;
|
||||
|
||||
$v_name = $request->getStr('name');
|
||||
$v_desc = $request->getStr('description');
|
||||
$v_view = $request->getStr('viewPolicy');
|
||||
$v_edit = $request->getStr('editPolicy');
|
||||
|
||||
$type_name = PhabricatorSpacesNamespaceTransaction::TYPE_NAME;
|
||||
$type_desc = PhabricatorSpacesNamespaceTransaction::TYPE_DESCRIPTION;
|
||||
$type_default = PhabricatorSpacesNamespaceTransaction::TYPE_DEFAULT;
|
||||
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||
|
@ -74,6 +77,10 @@ final class PhabricatorSpacesEditController
|
|||
->setTransactionType($type_name)
|
||||
->setNewValue($v_name);
|
||||
|
||||
$xactions[] = id(new PhabricatorSpacesNamespaceTransaction())
|
||||
->setTransactionType($type_desc)
|
||||
->setNewValue($v_desc);
|
||||
|
||||
$xactions[] = id(new PhabricatorSpacesNamespaceTransaction())
|
||||
->setTransactionType($type_view)
|
||||
->setNewValue($v_view);
|
||||
|
@ -128,6 +135,11 @@ final class PhabricatorSpacesEditController
|
|||
->setName('name')
|
||||
->setValue($v_name)
|
||||
->setError($e_name))
|
||||
->appendControl(
|
||||
id(new PhabricatorRemarkupControl())
|
||||
->setLabel(pht('Description'))
|
||||
->setName('description')
|
||||
->setValue($v_desc))
|
||||
->appendChild(
|
||||
id(new AphrontFormPolicyControl())
|
||||
->setUser($viewer)
|
||||
|
|
|
@ -75,6 +75,20 @@ final class PhabricatorSpacesViewController
|
|||
pht('Editable By'),
|
||||
$descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
|
||||
|
||||
$description = $space->getDescription();
|
||||
if (strlen($description)) {
|
||||
$description = PhabricatorMarkupEngine::renderOneObject(
|
||||
id(new PhabricatorMarkupOneOff())->setContent($description),
|
||||
'default',
|
||||
$viewer);
|
||||
|
||||
$list->addSectionHeader(
|
||||
pht('Description'),
|
||||
PHUIPropertyListView::ICON_SUMMARY);
|
||||
|
||||
$list->addTextContent($description);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ final class PhabricatorSpacesNamespaceEditor
|
|||
$types = parent::getTransactionTypes();
|
||||
|
||||
$types[] = PhabricatorSpacesNamespaceTransaction::TYPE_NAME;
|
||||
$types[] = PhabricatorSpacesNamespaceTransaction::TYPE_DESCRIPTION;
|
||||
$types[] = PhabricatorSpacesNamespaceTransaction::TYPE_DEFAULT;
|
||||
|
||||
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||
|
@ -34,6 +35,11 @@ final class PhabricatorSpacesNamespaceEditor
|
|||
return null;
|
||||
}
|
||||
return $name;
|
||||
case PhabricatorSpacesNamespaceTransaction::TYPE_DESCRIPTION:
|
||||
if ($this->getIsNewObject()) {
|
||||
return null;
|
||||
}
|
||||
return $object->getDescription();
|
||||
case PhabricatorSpacesNamespaceTransaction::TYPE_DEFAULT:
|
||||
return $object->getIsDefaultNamespace() ? 1 : null;
|
||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||
|
@ -51,6 +57,7 @@ final class PhabricatorSpacesNamespaceEditor
|
|||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorSpacesNamespaceTransaction::TYPE_NAME:
|
||||
case PhabricatorSpacesNamespaceTransaction::TYPE_DESCRIPTION:
|
||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||
return $xaction->getNewValue();
|
||||
|
@ -71,6 +78,9 @@ final class PhabricatorSpacesNamespaceEditor
|
|||
case PhabricatorSpacesNamespaceTransaction::TYPE_NAME:
|
||||
$object->setNamespaceName($new);
|
||||
return;
|
||||
case PhabricatorSpacesNamespaceTransaction::TYPE_DESCRIPTION:
|
||||
$object->setDescription($new);
|
||||
return;
|
||||
case PhabricatorSpacesNamespaceTransaction::TYPE_DEFAULT:
|
||||
$object->setIsDefaultNamespace($new ? 1 : null);
|
||||
return;
|
||||
|
@ -91,6 +101,7 @@ final class PhabricatorSpacesNamespaceEditor
|
|||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorSpacesNamespaceTransaction::TYPE_NAME:
|
||||
case PhabricatorSpacesNamespaceTransaction::TYPE_DESCRIPTION:
|
||||
case PhabricatorSpacesNamespaceTransaction::TYPE_DEFAULT:
|
||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||
|
|
|
@ -32,9 +32,12 @@ final class PhabricatorSpacesNamespacePHIDType
|
|||
|
||||
foreach ($handles as $phid => $handle) {
|
||||
$namespace = $objects[$phid];
|
||||
$monogram = $namespace->getMonogram();
|
||||
|
||||
$handle->setName($namespace->getNamespaceName());
|
||||
$monogram = $namespace->getMonogram();
|
||||
$name = $namespace->getNamespaceName();
|
||||
|
||||
$handle->setName($name);
|
||||
$handle->setFullName(pht('%s %s', $monogram, $name));
|
||||
$handle->setURI('/'.$monogram);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ final class PhabricatorSpacesNamespace
|
|||
protected $viewPolicy;
|
||||
protected $editPolicy;
|
||||
protected $isDefaultNamespace;
|
||||
protected $description;
|
||||
|
||||
public static function initializeNewNamespace(PhabricatorUser $actor) {
|
||||
$app = id(new PhabricatorApplicationQuery())
|
||||
|
@ -26,7 +27,8 @@ final class PhabricatorSpacesNamespace
|
|||
return id(new PhabricatorSpacesNamespace())
|
||||
->setIsDefaultNamespace(null)
|
||||
->setViewPolicy($view_policy)
|
||||
->setEditPolicy($edit_policy);
|
||||
->setEditPolicy($edit_policy)
|
||||
->setDescription('');
|
||||
}
|
||||
|
||||
protected function getConfiguration() {
|
||||
|
@ -35,6 +37,7 @@ final class PhabricatorSpacesNamespace
|
|||
self::CONFIG_COLUMN_SCHEMA => array(
|
||||
'namespaceName' => 'text255',
|
||||
'isDefaultNamespace' => 'bool?',
|
||||
'description' => 'text',
|
||||
),
|
||||
self::CONFIG_KEY_SCHEMA => array(
|
||||
'key_default' => array(
|
||||
|
|
|
@ -5,6 +5,7 @@ final class PhabricatorSpacesNamespaceTransaction
|
|||
|
||||
const TYPE_NAME = 'spaces:name';
|
||||
const TYPE_DEFAULT = 'spaces:default';
|
||||
const TYPE_DESCRIPTION = 'spaces:description';
|
||||
|
||||
public function getApplicationName() {
|
||||
return 'spaces';
|
||||
|
@ -18,6 +19,38 @@ final class PhabricatorSpacesNamespaceTransaction
|
|||
return null;
|
||||
}
|
||||
|
||||
public function shouldHide() {
|
||||
$old = $this->getOldValue();
|
||||
|
||||
switch ($this->getTransactionType()) {
|
||||
case self::TYPE_DESCRIPTION:
|
||||
return ($old === null);
|
||||
}
|
||||
|
||||
return parent::shouldHide();
|
||||
}
|
||||
|
||||
public function hasChangeDetails() {
|
||||
switch ($this->getTransactionType()) {
|
||||
case self::TYPE_DESCRIPTION:
|
||||
return true;
|
||||
}
|
||||
|
||||
return parent::hasChangeDetails();
|
||||
}
|
||||
|
||||
public function getRemarkupBlocks() {
|
||||
$blocks = parent::getRemarkupBlocks();
|
||||
|
||||
switch ($this->getTransactionType()) {
|
||||
case self::TYPE_DESCRIPTION:
|
||||
$blocks[] = $this->getNewValue();
|
||||
break;
|
||||
}
|
||||
|
||||
return $blocks;
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
$old = $this->getOldValue();
|
||||
$new = $this->getNewValue();
|
||||
|
@ -37,6 +70,10 @@ final class PhabricatorSpacesNamespaceTransaction
|
|||
$old,
|
||||
$new);
|
||||
}
|
||||
case self::TYPE_DESCRIPTION:
|
||||
return pht(
|
||||
'%s updated the description for this space.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
case self::TYPE_DEFAULT:
|
||||
return pht(
|
||||
'%s made this the default space.',
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorSpacesSchemaSpec
|
||||
extends PhabricatorConfigSchemaSpec {
|
||||
|
||||
public function buildSchemata() {
|
||||
$this->buildEdgeSchemata(new PhabricatorSpacesNamespace());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue