Page MenuHomePhabricator

D13801.diff
No OneTemporary

D13801.diff

diff --git a/resources/sql/autopatches/20150805.paste.status.1.sql b/resources/sql/autopatches/20150805.paste.status.1.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20150805.paste.status.1.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_pastebin.pastebin_paste
+ ADD status VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT};
diff --git a/resources/sql/autopatches/20150805.paste.status.2.sql b/resources/sql/autopatches/20150805.paste.status.2.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20150805.paste.status.2.sql
@@ -0,0 +1,2 @@
+UPDATE {$NAMESPACE}_pastebin.pastebin_paste
+ SET status = 'active' WHERE status = '';
diff --git a/src/applications/paste/controller/PhabricatorPasteEditController.php b/src/applications/paste/controller/PhabricatorPasteEditController.php
--- a/src/applications/paste/controller/PhabricatorPasteEditController.php
+++ b/src/applications/paste/controller/PhabricatorPasteEditController.php
@@ -64,6 +64,7 @@
}
$v_view_policy = $paste->getViewPolicy();
$v_edit_policy = $paste->getEditPolicy();
+ $v_status = $paste->getStatus();
if ($is_create) {
$v_projects = array();
@@ -85,6 +86,7 @@
$v_edit_policy = $request->getStr('can_edit');
$v_projects = $request->getArr('projects');
$v_space = $request->getStr('spacePHID');
+ $v_status = $request->getStr('status');
// NOTE: The author is the only editor and can always view the paste,
// so it's impossible for them to choose an invalid policy.
@@ -115,6 +117,9 @@
$xactions[] = id(new PhabricatorPasteTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_SPACE)
->setNewValue($v_space);
+ $xactions[] = id(new PhabricatorPasteTransaction())
+ ->setTransactionType(PhabricatorPasteTransaction::TYPE_STATUS)
+ ->setNewValue($v_status);
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
$xactions[] = id(new PhabricatorPasteTransaction())
@@ -180,6 +185,13 @@
->setValue($v_edit_policy)
->setName('can_edit'));
+ $form->appendChild(
+ id(new AphrontFormSelectControl())
+ ->setLabel(pht('Status'))
+ ->setName('status')
+ ->setValue($v_status)
+ ->setOptions($paste->getStatusNameMap()));
+
$form->appendControl(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Projects'))
diff --git a/src/applications/paste/controller/PhabricatorPasteViewController.php b/src/applications/paste/controller/PhabricatorPasteViewController.php
--- a/src/applications/paste/controller/PhabricatorPasteViewController.php
+++ b/src/applications/paste/controller/PhabricatorPasteViewController.php
@@ -115,9 +115,21 @@
private function buildHeaderView(PhabricatorPaste $paste) {
$title = (nonempty($paste->getTitle())) ?
$paste->getTitle() : pht('(An Untitled Masterwork)');
+
+ if ($paste->isArchived()) {
+ $header_icon = 'fa-ban';
+ $header_name = pht('Archived');
+ $header_color = 'dark';
+ } else {
+ $header_icon = 'fa-check';
+ $header_name = pht('Active');
+ $header_color = 'bluegrey';
+ }
+
$header = id(new PHUIHeaderView())
->setHeader($title)
->setUser($this->getRequest()->getUser())
+ ->setStatus($header_icon, $header_color, $header_name)
->setPolicyObject($paste);
return $header;
diff --git a/src/applications/paste/editor/PhabricatorPasteEditor.php b/src/applications/paste/editor/PhabricatorPasteEditor.php
--- a/src/applications/paste/editor/PhabricatorPasteEditor.php
+++ b/src/applications/paste/editor/PhabricatorPasteEditor.php
@@ -33,6 +33,7 @@
$types[] = PhabricatorPasteTransaction::TYPE_CONTENT;
$types[] = PhabricatorPasteTransaction::TYPE_TITLE;
$types[] = PhabricatorPasteTransaction::TYPE_LANGUAGE;
+ $types[] = PhabricatorPasteTransaction::TYPE_STATUS;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
$types[] = PhabricatorTransactions::TYPE_COMMENT;
@@ -51,6 +52,8 @@
return $object->getTitle();
case PhabricatorPasteTransaction::TYPE_LANGUAGE:
return $object->getLanguage();
+ case PhabricatorPasteTransaction::TYPE_STATUS:
+ return $object->getStatus();
}
}
@@ -62,6 +65,7 @@
case PhabricatorPasteTransaction::TYPE_CONTENT:
case PhabricatorPasteTransaction::TYPE_TITLE:
case PhabricatorPasteTransaction::TYPE_LANGUAGE:
+ case PhabricatorPasteTransaction::TYPE_STATUS:
return $xaction->getNewValue();
}
}
@@ -80,6 +84,9 @@
case PhabricatorPasteTransaction::TYPE_LANGUAGE:
$object->setLanguage($xaction->getNewValue());
return;
+ case PhabricatorPasteTransaction::TYPE_STATUS:
+ $object->setStatus($xaction->getNewValue());
+ return;
}
return parent::applyCustomInternalTransaction($object, $xaction);
@@ -93,6 +100,7 @@
case PhabricatorPasteTransaction::TYPE_CONTENT:
case PhabricatorPasteTransaction::TYPE_TITLE:
case PhabricatorPasteTransaction::TYPE_LANGUAGE:
+ case PhabricatorPasteTransaction::TYPE_STATUS:
return;
}
diff --git a/src/applications/paste/storage/PhabricatorPaste.php b/src/applications/paste/storage/PhabricatorPaste.php
--- a/src/applications/paste/storage/PhabricatorPaste.php
+++ b/src/applications/paste/storage/PhabricatorPaste.php
@@ -20,8 +20,12 @@
protected $viewPolicy;
protected $editPolicy;
protected $mailKey;
+ protected $status;
protected $spacePHID;
+ const STATUS_ACTIVE = 'active';
+ const STATUS_ARCHIVED = 'archived';
+
private $content = self::ATTACHABLE;
private $rawContent = self::ATTACHABLE;
@@ -36,12 +40,20 @@
return id(new PhabricatorPaste())
->setTitle('')
+ ->setStatus(self::STATUS_ACTIVE)
->setAuthorPHID($actor->getPHID())
->setViewPolicy($view_policy)
->setEditPolicy($edit_policy)
->setSpacePHID($actor->getDefaultSpacePHID());
}
+ public static function getStatusNameMap() {
+ return array(
+ self::STATUS_ACTIVE => pht('Active'),
+ self::STATUS_ARCHIVED => pht('Archived'),
+ );
+ }
+
public function getURI() {
return '/'.$this->getMonogram();
}
@@ -54,6 +66,7 @@
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
+ 'status' => 'text32',
'title' => 'text255',
'language' => 'text64',
'mailKey' => 'bytes20',
@@ -85,6 +98,10 @@
PhabricatorPastePastePHIDType::TYPECONST);
}
+ public function isArchived() {
+ return ($this->getStatus() == self::STATUS_ARCHIVED);
+ }
+
public function save() {
if (!$this->getMailKey()) {
$this->setMailKey(Filesystem::readRandomCharacters(20));
diff --git a/src/applications/paste/storage/PhabricatorPasteTransaction.php b/src/applications/paste/storage/PhabricatorPasteTransaction.php
--- a/src/applications/paste/storage/PhabricatorPasteTransaction.php
+++ b/src/applications/paste/storage/PhabricatorPasteTransaction.php
@@ -6,6 +6,7 @@
const TYPE_CONTENT = 'paste.create';
const TYPE_TITLE = 'paste.title';
const TYPE_LANGUAGE = 'paste.language';
+ const TYPE_STATUS = 'paste.status';
const MAILTAG_CONTENT = 'paste-content';
const MAILTAG_OTHER = 'paste-other';
@@ -89,6 +90,12 @@
"%s updated the paste's language.",
$this->renderHandleLink($author_phid));
break;
+ case self::TYPE_STATUS:
+ return pht(
+ "%s updated the paste's status.",
+ $this->renderHandleLink($author_phid));
+ break;
+
}
return parent::getTitle();
@@ -128,6 +135,20 @@
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
break;
+ case self::TYPE_STATUS:
+ switch ($new) {
+ case self::STATUS_OPEN:
+ return pht(
+ '%s activated %s.',
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($object_phid));
+ case self::STATUS_CLOSED:
+ return pht(
+ '%s archived %s.',
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($object_phid));
+ }
+ break;
}
return parent::getTitleForFeed();

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 8, 3:45 AM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6722989
Default Alt Text
D13801.diff (8 KB)

Event Timeline