Page MenuHomePhabricator

D21848.id52072.diff
No OneTemporary

D21848.id52072.diff

diff --git a/resources/sql/autopatches/20220525.slowvote.08.status-type.sql b/resources/sql/autopatches/20220525.slowvote.08.status-type.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20220525.slowvote.08.status-type.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_slowvote.slowvote_poll
+ CHANGE isClosed status VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT};
diff --git a/resources/sql/autopatches/20220525.slowvote.09.status-value.sql b/resources/sql/autopatches/20220525.slowvote.09.status-value.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20220525.slowvote.09.status-value.sql
@@ -0,0 +1,5 @@
+UPDATE {$NAMESPACE}_slowvote.slowvote_poll
+ SET status = 'open' WHERE status = '0';
+
+UPDATE {$NAMESPACE}_slowvote.slowvote_poll
+ SET status = 'closed' WHERE status = '1';
diff --git a/resources/sql/autopatches/20220525.slowvote.10.status-xactions.sql b/resources/sql/autopatches/20220525.slowvote.10.status-xactions.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20220525.slowvote.10.status-xactions.sql
@@ -0,0 +1,19 @@
+UPDATE {$NAMESPACE}_slowvote.slowvote_transaction
+ SET transactionType = 'vote:status'
+ WHERE transactionType = 'vote:close';
+
+UPDATE {$NAMESPACE}_slowvote.slowvote_transaction
+ SET oldValue = '"open"' WHERE
+ transactionType = 'vote:status' AND oldValue IN ('0', '"0"', 'false');
+
+UPDATE {$NAMESPACE}_slowvote.slowvote_transaction
+ SET newValue = '"open"' WHERE
+ transactionType = 'vote:status' AND newValue IN ('0', '"0"', 'false');
+
+UPDATE {$NAMESPACE}_slowvote.slowvote_transaction
+ SET oldValue = '"closed"' WHERE
+ transactionType = 'vote:status' AND oldValue IN ('1', '"1"', 'true');
+
+UPDATE {$NAMESPACE}_slowvote.slowvote_transaction
+ SET newValue = '"closed"' WHERE
+ transactionType = 'vote:status' AND newValue IN ('1', '"1"', 'true');
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -4833,7 +4833,6 @@
'PhabricatorSlowvoteApplication' => 'applications/slowvote/application/PhabricatorSlowvoteApplication.php',
'PhabricatorSlowvoteChoice' => 'applications/slowvote/storage/PhabricatorSlowvoteChoice.php',
'PhabricatorSlowvoteCloseController' => 'applications/slowvote/controller/PhabricatorSlowvoteCloseController.php',
- 'PhabricatorSlowvoteCloseTransaction' => 'applications/slowvote/xaction/PhabricatorSlowvoteCloseTransaction.php',
'PhabricatorSlowvoteCommentController' => 'applications/slowvote/controller/PhabricatorSlowvoteCommentController.php',
'PhabricatorSlowvoteController' => 'applications/slowvote/controller/PhabricatorSlowvoteController.php',
'PhabricatorSlowvoteDAO' => 'applications/slowvote/storage/PhabricatorSlowvoteDAO.php',
@@ -4854,6 +4853,7 @@
'PhabricatorSlowvoteSchemaSpec' => 'applications/slowvote/storage/PhabricatorSlowvoteSchemaSpec.php',
'PhabricatorSlowvoteSearchEngine' => 'applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php',
'PhabricatorSlowvoteShuffleTransaction' => 'applications/slowvote/xaction/PhabricatorSlowvoteShuffleTransaction.php',
+ 'PhabricatorSlowvoteStatusTransaction' => 'applications/slowvote/xaction/PhabricatorSlowvoteStatusTransaction.php',
'PhabricatorSlowvoteTransaction' => 'applications/slowvote/storage/PhabricatorSlowvoteTransaction.php',
'PhabricatorSlowvoteTransactionComment' => 'applications/slowvote/storage/PhabricatorSlowvoteTransactionComment.php',
'PhabricatorSlowvoteTransactionQuery' => 'applications/slowvote/query/PhabricatorSlowvoteTransactionQuery.php',
@@ -11539,7 +11539,6 @@
'PhabricatorSlowvoteApplication' => 'PhabricatorApplication',
'PhabricatorSlowvoteChoice' => 'PhabricatorSlowvoteDAO',
'PhabricatorSlowvoteCloseController' => 'PhabricatorSlowvoteController',
- 'PhabricatorSlowvoteCloseTransaction' => 'PhabricatorSlowvoteTransactionType',
'PhabricatorSlowvoteCommentController' => 'PhabricatorSlowvoteController',
'PhabricatorSlowvoteController' => 'PhabricatorController',
'PhabricatorSlowvoteDAO' => 'PhabricatorLiskDAO',
@@ -11571,6 +11570,7 @@
'PhabricatorSlowvoteSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'PhabricatorSlowvoteSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorSlowvoteShuffleTransaction' => 'PhabricatorSlowvoteTransactionType',
+ 'PhabricatorSlowvoteStatusTransaction' => 'PhabricatorSlowvoteTransactionType',
'PhabricatorSlowvoteTransaction' => 'PhabricatorModularTransaction',
'PhabricatorSlowvoteTransactionComment' => 'PhabricatorApplicationTransactionComment',
'PhabricatorSlowvoteTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
diff --git a/src/applications/slowvote/constants/SlowvotePollStatus.php b/src/applications/slowvote/constants/SlowvotePollStatus.php
--- a/src/applications/slowvote/constants/SlowvotePollStatus.php
+++ b/src/applications/slowvote/constants/SlowvotePollStatus.php
@@ -3,8 +3,8 @@
final class SlowvotePollStatus
extends Phobject {
- const STATUS_OPEN = 0;
- const STATUS_CLOSED = 1;
+ const STATUS_OPEN = 'open';
+ const STATUS_CLOSED = 'closed';
private $key;
@@ -47,6 +47,10 @@
return $this->getProperty('header.tag.color');
}
+ public function getTransactionIcon() {
+ return $this->getProperty('transaction.icon');
+ }
+
private function getProperty($key, $default = null) {
$spec = idx(self::getMap(), $this->getKey(), array());
return idx($spec, $key, $default);
@@ -58,11 +62,13 @@
'name' => pht('Open'),
'header.tag.icon' => 'fa-square-o',
'header.tag.color' => 'bluegrey',
+ 'transaction.icon' => 'fa-pencil',
),
self::STATUS_CLOSED => array(
'name' => pht('Closed'),
'header.tag.icon' => 'fa-ban',
'header.tag.color' => 'indigo',
+ 'transaction.icon' => 'fa-ban',
),
);
}
diff --git a/src/applications/slowvote/controller/PhabricatorSlowvoteCloseController.php b/src/applications/slowvote/controller/PhabricatorSlowvoteCloseController.php
--- a/src/applications/slowvote/controller/PhabricatorSlowvoteCloseController.php
+++ b/src/applications/slowvote/controller/PhabricatorSlowvoteCloseController.php
@@ -20,7 +20,7 @@
return new Aphront404Response();
}
- $close_uri = '/V'.$poll->getID();
+ $close_uri = $poll->getURI();
if ($request->isFormPost()) {
if ($poll->isClosed()) {
@@ -33,7 +33,7 @@
$xactions[] = id(new PhabricatorSlowvoteTransaction())
->setTransactionType(
- PhabricatorSlowvoteCloseTransaction::TRANSACTIONTYPE)
+ PhabricatorSlowvoteStatusTransaction::TRANSACTIONTYPE)
->setNewValue($new_status);
id(new PhabricatorSlowvoteEditor())
diff --git a/src/applications/slowvote/query/PhabricatorSlowvoteQuery.php b/src/applications/slowvote/query/PhabricatorSlowvoteQuery.php
--- a/src/applications/slowvote/query/PhabricatorSlowvoteQuery.php
+++ b/src/applications/slowvote/query/PhabricatorSlowvoteQuery.php
@@ -7,7 +7,7 @@
private $phids;
private $authorPHIDs;
private $withVotesByViewer;
- private $isClosed;
+ private $statuses;
private $needOptions;
private $needChoices;
@@ -33,8 +33,8 @@
return $this;
}
- public function withIsClosed($with_closed) {
- $this->isClosed = $with_closed;
+ public function withStatuses(array $statuses) {
+ $this->statuses = $statuses;
return $this;
}
@@ -137,12 +137,13 @@
$this->authorPHIDs);
}
- if ($this->isClosed !== null) {
+ if ($this->statuses !== null) {
$where[] = qsprintf(
$conn,
- 'p.isClosed = %d',
- (int)$this->isClosed);
+ 'p.status IN (%Ls)',
+ $this->statuses);
}
+
return $where;
}
diff --git a/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php b/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php
--- a/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php
+++ b/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php
@@ -26,14 +26,8 @@
$query->withAuthorPHIDs($map['authorPHIDs']);
}
- $statuses = $map['statuses'];
- if (count($statuses) == 1) {
- $status = head($statuses);
- if ($status == 'open') {
- $query->withIsClosed(false);
- } else {
- $query->withIsClosed(true);
- }
+ if ($map['statuses']) {
+ $query->withStatuses($map['statuses']);
}
return $query;
@@ -41,6 +35,9 @@
protected function buildCustomSearchFields() {
+ $status_options = SlowvotePollStatus::getAll();
+ $status_options = mpull($status_options, 'getName');
+
return array(
id(new PhabricatorUsersSearchField())
->setKey('authorPHIDs')
@@ -61,11 +58,7 @@
id(new PhabricatorSearchCheckboxesField())
->setKey('statuses')
->setLabel(pht('Statuses'))
- ->setOptions(
- array(
- 'open' => pht('Open'),
- 'closed' => pht('Closed'),
- )),
+ ->setOptions($status_options),
);
}
@@ -137,9 +130,9 @@
$item = id(new PHUIObjectItemView())
->setUser($viewer)
->setObject($poll)
- ->setObjectName('V'.$poll->getID())
+ ->setObjectName($poll->getMonogram())
->setHeader($poll->getQuestion())
- ->setHref('/V'.$poll->getID())
+ ->setHref($poll->getURI())
->addIcon('none', $date_created);
if ($poll->isClosed()) {
diff --git a/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php b/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php
--- a/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php
+++ b/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php
@@ -20,7 +20,7 @@
protected $shuffle = 0;
protected $method;
protected $viewPolicy;
- protected $isClosed;
+ protected $status;
protected $spacePHID;
private $options = self::ATTACHABLE;
@@ -43,7 +43,7 @@
->setAuthorPHID($actor->getPHID())
->setViewPolicy($view_policy)
->setSpacePHID($actor->getDefaultSpacePHID())
- ->setIsClosed(SlowvotePollStatus::STATUS_OPEN)
+ ->setStatus(SlowvotePollStatus::STATUS_OPEN)
->setMethod($default_method)
->setResponseVisibility($default_responses);
}
@@ -57,7 +57,7 @@
'shuffle' => 'bool',
'method' => 'text32',
'description' => 'text',
- 'isClosed' => 'bool',
+ 'status' => 'text32',
),
self::CONFIG_KEY_SCHEMA => array(
),
@@ -69,11 +69,11 @@
}
public function getStatusObject() {
- return SlowvotePollStatus::newStatusObject($this->getIsClosed());
+ return SlowvotePollStatus::newStatusObject($this->getStatus());
}
public function isClosed() {
- return ($this->getIsClosed() == SlowvotePollStatus::STATUS_CLOSED);
+ return ($this->getStatus() == SlowvotePollStatus::STATUS_CLOSED);
}
public function getOptions() {
diff --git a/src/applications/slowvote/storage/PhabricatorSlowvoteTransaction.php b/src/applications/slowvote/storage/PhabricatorSlowvoteTransaction.php
--- a/src/applications/slowvote/storage/PhabricatorSlowvoteTransaction.php
+++ b/src/applications/slowvote/storage/PhabricatorSlowvoteTransaction.php
@@ -30,7 +30,7 @@
case PhabricatorSlowvoteQuestionTransaction::TRANSACTIONTYPE:
case PhabricatorSlowvoteDescriptionTransaction::TRANSACTIONTYPE:
case PhabricatorSlowvoteShuffleTransaction::TRANSACTIONTYPE:
- case PhabricatorSlowvoteCloseTransaction::TRANSACTIONTYPE:
+ case PhabricatorSlowvoteStatusTransaction::TRANSACTIONTYPE:
$tags[] = self::MAILTAG_DETAILS;
break;
case PhabricatorSlowvoteResponsesTransaction::TRANSACTIONTYPE:
diff --git a/src/applications/slowvote/xaction/PhabricatorSlowvoteCloseTransaction.php b/src/applications/slowvote/xaction/PhabricatorSlowvoteCloseTransaction.php
deleted file mode 100644
--- a/src/applications/slowvote/xaction/PhabricatorSlowvoteCloseTransaction.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-
-final class PhabricatorSlowvoteCloseTransaction
- extends PhabricatorSlowvoteTransactionType {
-
- const TRANSACTIONTYPE = 'vote:close';
-
- public function generateOldValue($object) {
- return (bool)$object->getIsClosed();
- }
-
- public function generateNewValue($object, $value) {
- return (bool)$value;
- }
-
- public function applyInternalEffects($object, $value) {
- $object->setIsClosed((int)$value);
- }
-
- public function getTitle() {
- $new = $this->getNewValue();
-
- if ($new) {
- return pht(
- '%s closed this poll.',
- $this->renderAuthor());
- } else {
- return pht(
- '%s reopened this poll.',
- $this->renderAuthor());
- }
- }
-
- public function getTitleForFeed() {
- $new = $this->getNewValue();
-
- if ($new) {
- return pht(
- '%s closed %s.',
- $this->renderAuthor(),
- $this->renderObject());
- } else {
- return pht(
- '%s reopened %s.',
- $this->renderAuthor(),
- $this->renderObject());
- }
- }
-
- public function getIcon() {
- $new = $this->getNewValue();
-
- if ($new) {
- return 'fa-ban';
- } else {
- return 'fa-pencil';
- }
- }
-
-}
diff --git a/src/applications/slowvote/xaction/PhabricatorSlowvoteStatusTransaction.php b/src/applications/slowvote/xaction/PhabricatorSlowvoteStatusTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/slowvote/xaction/PhabricatorSlowvoteStatusTransaction.php
@@ -0,0 +1,60 @@
+<?php
+
+final class PhabricatorSlowvoteStatusTransaction
+ extends PhabricatorSlowvoteTransactionType {
+
+ const TRANSACTIONTYPE = 'vote:status';
+
+ public function generateOldValue($object) {
+ return (string)$object->getStatus();
+ }
+
+ public function generateNewValue($object, $value) {
+ return (string)$value;
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setStatus($value);
+ }
+
+ public function getTitle() {
+ $old_name = $this->getOldStatusObject()->getName();
+ $new_name = $this->getNewStatusObject()->getName();
+
+ return pht(
+ '%s changed the status of this poll from %s to %s.',
+ $this->renderAuthor(),
+ $this->renderValue($old_name),
+ $this->renderValue($new_name));
+ }
+
+ public function getTitleForFeed() {
+ $old_name = $this->getOldStatusObject()->getName();
+ $new_name = $this->getNewStatusObject()->getName();
+
+
+ return pht(
+ '%s changed the status of %s from %s to %s.',
+ $this->renderAuthor(),
+ $this->renderObject(),
+ $this->renderValue($old_name),
+ $this->renderValue($new_name));
+ }
+
+ public function getIcon() {
+ return $this->getNewStatusObject()->getTransactionIcon();
+ }
+
+ private function getOldStatusObject() {
+ return $this->newStatusObject($this->getOldValue());
+ }
+
+ private function getNewStatusObject() {
+ return $this->newStatusObject($this->getNewValue());
+ }
+
+ private function newStatusObject($value) {
+ return SlowvotePollStatus::newStatusObject($value);
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 1:37 AM (18 h, 27 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6776682
Default Alt Text
D21848.id52072.diff (14 KB)

Event Timeline