1
0
Fork 0
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:
epriestley 2015-06-10 15:53:51 -07:00
parent d118800d37
commit 814b586f5d
10 changed files with 113 additions and 3 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_spaces.spaces_namespace
ADD description LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL;

View 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};

View file

@ -2594,6 +2594,7 @@ phutil_register_library_map(array(
'PhabricatorSpacesNamespaceTransaction' => 'applications/spaces/storage/PhabricatorSpacesNamespaceTransaction.php', 'PhabricatorSpacesNamespaceTransaction' => 'applications/spaces/storage/PhabricatorSpacesNamespaceTransaction.php',
'PhabricatorSpacesNamespaceTransactionQuery' => 'applications/spaces/query/PhabricatorSpacesNamespaceTransactionQuery.php', 'PhabricatorSpacesNamespaceTransactionQuery' => 'applications/spaces/query/PhabricatorSpacesNamespaceTransactionQuery.php',
'PhabricatorSpacesRemarkupRule' => 'applications/spaces/remarkup/PhabricatorSpacesRemarkupRule.php', 'PhabricatorSpacesRemarkupRule' => 'applications/spaces/remarkup/PhabricatorSpacesRemarkupRule.php',
'PhabricatorSpacesSchemaSpec' => 'applications/spaces/storage/PhabricatorSpacesSchemaSpec.php',
'PhabricatorSpacesTestCase' => 'applications/spaces/__tests__/PhabricatorSpacesTestCase.php', 'PhabricatorSpacesTestCase' => 'applications/spaces/__tests__/PhabricatorSpacesTestCase.php',
'PhabricatorSpacesViewController' => 'applications/spaces/controller/PhabricatorSpacesViewController.php', 'PhabricatorSpacesViewController' => 'applications/spaces/controller/PhabricatorSpacesViewController.php',
'PhabricatorStandardCustomField' => 'infrastructure/customfield/standard/PhabricatorStandardCustomField.php', 'PhabricatorStandardCustomField' => 'infrastructure/customfield/standard/PhabricatorStandardCustomField.php',
@ -6110,6 +6111,7 @@ phutil_register_library_map(array(
'PhabricatorSpacesNamespaceTransaction' => 'PhabricatorApplicationTransaction', 'PhabricatorSpacesNamespaceTransaction' => 'PhabricatorApplicationTransaction',
'PhabricatorSpacesNamespaceTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'PhabricatorSpacesNamespaceTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhabricatorSpacesRemarkupRule' => 'PhabricatorObjectRemarkupRule', 'PhabricatorSpacesRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'PhabricatorSpacesSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'PhabricatorSpacesTestCase' => 'PhabricatorTestCase', 'PhabricatorSpacesTestCase' => 'PhabricatorTestCase',
'PhabricatorSpacesViewController' => 'PhabricatorSpacesController', 'PhabricatorSpacesViewController' => 'PhabricatorSpacesController',
'PhabricatorStandardCustomField' => 'PhabricatorCustomField', 'PhabricatorStandardCustomField' => 'PhabricatorCustomField',

View file

@ -54,6 +54,7 @@ final class PhabricatorSpacesEditController
$validation_exception = null; $validation_exception = null;
$e_name = true; $e_name = true;
$v_name = $space->getNamespaceName(); $v_name = $space->getNamespaceName();
$v_desc = $space->getDescription();
$v_view = $space->getViewPolicy(); $v_view = $space->getViewPolicy();
$v_edit = $space->getEditPolicy(); $v_edit = $space->getEditPolicy();
@ -62,10 +63,12 @@ final class PhabricatorSpacesEditController
$e_name = null; $e_name = null;
$v_name = $request->getStr('name'); $v_name = $request->getStr('name');
$v_desc = $request->getStr('description');
$v_view = $request->getStr('viewPolicy'); $v_view = $request->getStr('viewPolicy');
$v_edit = $request->getStr('editPolicy'); $v_edit = $request->getStr('editPolicy');
$type_name = PhabricatorSpacesNamespaceTransaction::TYPE_NAME; $type_name = PhabricatorSpacesNamespaceTransaction::TYPE_NAME;
$type_desc = PhabricatorSpacesNamespaceTransaction::TYPE_DESCRIPTION;
$type_default = PhabricatorSpacesNamespaceTransaction::TYPE_DEFAULT; $type_default = PhabricatorSpacesNamespaceTransaction::TYPE_DEFAULT;
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY; $type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY; $type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
@ -74,6 +77,10 @@ final class PhabricatorSpacesEditController
->setTransactionType($type_name) ->setTransactionType($type_name)
->setNewValue($v_name); ->setNewValue($v_name);
$xactions[] = id(new PhabricatorSpacesNamespaceTransaction())
->setTransactionType($type_desc)
->setNewValue($v_desc);
$xactions[] = id(new PhabricatorSpacesNamespaceTransaction()) $xactions[] = id(new PhabricatorSpacesNamespaceTransaction())
->setTransactionType($type_view) ->setTransactionType($type_view)
->setNewValue($v_view); ->setNewValue($v_view);
@ -128,6 +135,11 @@ final class PhabricatorSpacesEditController
->setName('name') ->setName('name')
->setValue($v_name) ->setValue($v_name)
->setError($e_name)) ->setError($e_name))
->appendControl(
id(new PhabricatorRemarkupControl())
->setLabel(pht('Description'))
->setName('description')
->setValue($v_desc))
->appendChild( ->appendChild(
id(new AphrontFormPolicyControl()) id(new AphrontFormPolicyControl())
->setUser($viewer) ->setUser($viewer)

View file

@ -75,6 +75,20 @@ final class PhabricatorSpacesViewController
pht('Editable By'), pht('Editable By'),
$descriptions[PhabricatorPolicyCapability::CAN_EDIT]); $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; return $list;
} }

View file

@ -15,6 +15,7 @@ final class PhabricatorSpacesNamespaceEditor
$types = parent::getTransactionTypes(); $types = parent::getTransactionTypes();
$types[] = PhabricatorSpacesNamespaceTransaction::TYPE_NAME; $types[] = PhabricatorSpacesNamespaceTransaction::TYPE_NAME;
$types[] = PhabricatorSpacesNamespaceTransaction::TYPE_DESCRIPTION;
$types[] = PhabricatorSpacesNamespaceTransaction::TYPE_DEFAULT; $types[] = PhabricatorSpacesNamespaceTransaction::TYPE_DEFAULT;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
@ -34,6 +35,11 @@ final class PhabricatorSpacesNamespaceEditor
return null; return null;
} }
return $name; return $name;
case PhabricatorSpacesNamespaceTransaction::TYPE_DESCRIPTION:
if ($this->getIsNewObject()) {
return null;
}
return $object->getDescription();
case PhabricatorSpacesNamespaceTransaction::TYPE_DEFAULT: case PhabricatorSpacesNamespaceTransaction::TYPE_DEFAULT:
return $object->getIsDefaultNamespace() ? 1 : null; return $object->getIsDefaultNamespace() ? 1 : null;
case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_VIEW_POLICY:
@ -51,6 +57,7 @@ final class PhabricatorSpacesNamespaceEditor
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case PhabricatorSpacesNamespaceTransaction::TYPE_NAME: case PhabricatorSpacesNamespaceTransaction::TYPE_NAME:
case PhabricatorSpacesNamespaceTransaction::TYPE_DESCRIPTION:
case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY:
return $xaction->getNewValue(); return $xaction->getNewValue();
@ -71,6 +78,9 @@ final class PhabricatorSpacesNamespaceEditor
case PhabricatorSpacesNamespaceTransaction::TYPE_NAME: case PhabricatorSpacesNamespaceTransaction::TYPE_NAME:
$object->setNamespaceName($new); $object->setNamespaceName($new);
return; return;
case PhabricatorSpacesNamespaceTransaction::TYPE_DESCRIPTION:
$object->setDescription($new);
return;
case PhabricatorSpacesNamespaceTransaction::TYPE_DEFAULT: case PhabricatorSpacesNamespaceTransaction::TYPE_DEFAULT:
$object->setIsDefaultNamespace($new ? 1 : null); $object->setIsDefaultNamespace($new ? 1 : null);
return; return;
@ -91,6 +101,7 @@ final class PhabricatorSpacesNamespaceEditor
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case PhabricatorSpacesNamespaceTransaction::TYPE_NAME: case PhabricatorSpacesNamespaceTransaction::TYPE_NAME:
case PhabricatorSpacesNamespaceTransaction::TYPE_DESCRIPTION:
case PhabricatorSpacesNamespaceTransaction::TYPE_DEFAULT: case PhabricatorSpacesNamespaceTransaction::TYPE_DEFAULT:
case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY:

View file

@ -32,9 +32,12 @@ final class PhabricatorSpacesNamespacePHIDType
foreach ($handles as $phid => $handle) { foreach ($handles as $phid => $handle) {
$namespace = $objects[$phid]; $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); $handle->setURI('/'.$monogram);
} }
} }

View file

@ -11,6 +11,7 @@ final class PhabricatorSpacesNamespace
protected $viewPolicy; protected $viewPolicy;
protected $editPolicy; protected $editPolicy;
protected $isDefaultNamespace; protected $isDefaultNamespace;
protected $description;
public static function initializeNewNamespace(PhabricatorUser $actor) { public static function initializeNewNamespace(PhabricatorUser $actor) {
$app = id(new PhabricatorApplicationQuery()) $app = id(new PhabricatorApplicationQuery())
@ -26,7 +27,8 @@ final class PhabricatorSpacesNamespace
return id(new PhabricatorSpacesNamespace()) return id(new PhabricatorSpacesNamespace())
->setIsDefaultNamespace(null) ->setIsDefaultNamespace(null)
->setViewPolicy($view_policy) ->setViewPolicy($view_policy)
->setEditPolicy($edit_policy); ->setEditPolicy($edit_policy)
->setDescription('');
} }
protected function getConfiguration() { protected function getConfiguration() {
@ -35,6 +37,7 @@ final class PhabricatorSpacesNamespace
self::CONFIG_COLUMN_SCHEMA => array( self::CONFIG_COLUMN_SCHEMA => array(
'namespaceName' => 'text255', 'namespaceName' => 'text255',
'isDefaultNamespace' => 'bool?', 'isDefaultNamespace' => 'bool?',
'description' => 'text',
), ),
self::CONFIG_KEY_SCHEMA => array( self::CONFIG_KEY_SCHEMA => array(
'key_default' => array( 'key_default' => array(

View file

@ -5,6 +5,7 @@ final class PhabricatorSpacesNamespaceTransaction
const TYPE_NAME = 'spaces:name'; const TYPE_NAME = 'spaces:name';
const TYPE_DEFAULT = 'spaces:default'; const TYPE_DEFAULT = 'spaces:default';
const TYPE_DESCRIPTION = 'spaces:description';
public function getApplicationName() { public function getApplicationName() {
return 'spaces'; return 'spaces';
@ -18,6 +19,38 @@ final class PhabricatorSpacesNamespaceTransaction
return null; 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() { public function getTitle() {
$old = $this->getOldValue(); $old = $this->getOldValue();
$new = $this->getNewValue(); $new = $this->getNewValue();
@ -37,6 +70,10 @@ final class PhabricatorSpacesNamespaceTransaction
$old, $old,
$new); $new);
} }
case self::TYPE_DESCRIPTION:
return pht(
'%s updated the description for this space.',
$this->renderHandleLink($author_phid));
case self::TYPE_DEFAULT: case self::TYPE_DEFAULT:
return pht( return pht(
'%s made this the default space.', '%s made this the default space.',

View file

@ -0,0 +1,10 @@
<?php
final class PhabricatorSpacesSchemaSpec
extends PhabricatorConfigSchemaSpec {
public function buildSchemata() {
$this->buildEdgeSchemata(new PhabricatorSpacesNamespace());
}
}