Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14910295
D13256.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
26 KB
Referenced Files
None
Subscribers
None
D13256.diff
View Options
diff --git a/resources/sql/autopatches/20150620.diviner.status.sql b/resources/sql/autopatches/20150620.diviner.status.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20150620.diviner.status.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_diviner.diviner_livebook
+ ADD COLUMN isArchived BOOL NOT NULL AFTER repositoryPHID;
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
@@ -648,6 +648,7 @@
'DivinerAtomSearchIndexer' => 'applications/diviner/search/DivinerAtomSearchIndexer.php',
'DivinerAtomizeWorkflow' => 'applications/diviner/workflow/DivinerAtomizeWorkflow.php',
'DivinerAtomizer' => 'applications/diviner/atomizer/DivinerAtomizer.php',
+ 'DivinerBookArchiveController' => 'applications/diviner/controller/DivinerBookArchiveController.php',
'DivinerBookController' => 'applications/diviner/controller/DivinerBookController.php',
'DivinerBookDatasource' => 'applications/diviner/typeahead/DivinerBookDatasource.php',
'DivinerBookEditController' => 'applications/diviner/controller/DivinerBookEditController.php',
@@ -2531,6 +2532,7 @@
'PhabricatorSearchApplicationStorageEnginePanel' => 'applications/search/applicationpanel/PhabricatorSearchApplicationStorageEnginePanel.php',
'PhabricatorSearchAttachController' => 'applications/search/controller/PhabricatorSearchAttachController.php',
'PhabricatorSearchBaseController' => 'applications/search/controller/PhabricatorSearchBaseController.php',
+ 'PhabricatorSearchBooksField' => 'applications/diviner/search/field/PhabricatorSearchBooksField.php',
'PhabricatorSearchCheckboxesField' => 'applications/search/field/PhabricatorSearchCheckboxesField.php',
'PhabricatorSearchConfigOptions' => 'applications/search/config/PhabricatorSearchConfigOptions.php',
'PhabricatorSearchController' => 'applications/search/controller/PhabricatorSearchController.php',
@@ -2562,6 +2564,7 @@
'PhabricatorSearchPreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorSearchPreferencesSettingsPanel.php',
'PhabricatorSearchProjectsField' => 'applications/search/field/PhabricatorSearchProjectsField.php',
'PhabricatorSearchRelationship' => 'applications/search/constants/PhabricatorSearchRelationship.php',
+ 'PhabricatorSearchRepositoryField' => 'applications/repository/search/field/PhabricatorSearchRepositoryField.php',
'PhabricatorSearchResultView' => 'applications/search/view/PhabricatorSearchResultView.php',
'PhabricatorSearchSelectController' => 'applications/search/controller/PhabricatorSearchSelectController.php',
'PhabricatorSearchSelectField' => 'applications/search/field/PhabricatorSearchSelectField.php',
@@ -4016,6 +4019,7 @@
'DivinerAtomSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
'DivinerAtomizeWorkflow' => 'DivinerWorkflow',
'DivinerAtomizer' => 'Phobject',
+ 'DivinerBookArchiveController' => 'DivinerController',
'DivinerBookController' => 'DivinerController',
'DivinerBookDatasource' => 'PhabricatorTypeaheadDatasource',
'DivinerBookEditController' => 'DivinerController',
@@ -6256,6 +6260,7 @@
'PhabricatorSearchApplicationStorageEnginePanel' => 'PhabricatorApplicationConfigurationPanel',
'PhabricatorSearchAttachController' => 'PhabricatorSearchBaseController',
'PhabricatorSearchBaseController' => 'PhabricatorController',
+ 'PhabricatorSearchBooksField' => 'PhabricatorSearchTokenizerField',
'PhabricatorSearchCheckboxesField' => 'PhabricatorSearchField',
'PhabricatorSearchConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorSearchController' => 'PhabricatorSearchBaseController',
@@ -6287,6 +6292,7 @@
'PhabricatorSearchPreferencesSettingsPanel' => 'PhabricatorSettingsPanel',
'PhabricatorSearchProjectsField' => 'PhabricatorSearchTokenizerField',
'PhabricatorSearchRelationship' => 'Phobject',
+ 'PhabricatorSearchRepositoryField' => 'PhabricatorSearchTokenizerField',
'PhabricatorSearchResultView' => 'AphrontView',
'PhabricatorSearchSelectController' => 'PhabricatorSearchBaseController',
'PhabricatorSearchSelectField' => 'PhabricatorSearchField',
diff --git a/src/applications/diviner/application/PhabricatorDivinerApplication.php b/src/applications/diviner/application/PhabricatorDivinerApplication.php
--- a/src/applications/diviner/application/PhabricatorDivinerApplication.php
+++ b/src/applications/diviner/application/PhabricatorDivinerApplication.php
@@ -39,6 +39,7 @@
'find/' => 'DivinerFindController',
),
'/book/(?P<book>[^/]+)/' => 'DivinerBookController',
+ '/book/(?P<book>[^/]+)/archive/' => 'DivinerBookArchiveController',
'/book/(?P<book>[^/]+)/edit/' => 'DivinerBookEditController',
'/book/'.
'(?P<book>[^/]+)/'.
diff --git a/src/applications/diviner/controller/DivinerBookArchiveController.php b/src/applications/diviner/controller/DivinerBookArchiveController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/diviner/controller/DivinerBookArchiveController.php
@@ -0,0 +1,64 @@
+<?php
+
+final class DivinerBookArchiveController extends DivinerController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+
+ $book = id(new DivinerBookQuery())
+ ->setViewer($viewer)
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->withNames(array($request->getURIData('book')))
+ ->executeOne();
+
+ if (!$book) {
+ return new Aphront404Response();
+ }
+
+ $view_uri = '/book/'.$book->getName().'/';
+
+ if ($request->isFormPost()) {
+ if ($book->getIsArchived()) {
+ $is_archived = false;
+ } else {
+ $is_archived = true;
+ }
+
+ $xactions = array();
+
+ $xactions[] = id(new DivinerLiveBookTransaction())
+ ->setTransactionType(DivinerLiveBookTransaction::TYPE_ARCHIVED)
+ ->setNewValue($is_archived);
+
+ id(new DivinerLiveBookEditor())
+ ->setActor($viewer)
+ ->setContentSourceFromRequest($request)
+ ->setContinueOnNoEffect(true)
+ ->setContinueOnMissingFields(true)
+ ->applyTransactions($book, $xactions);
+
+ return id(new AphrontRedirectResponse())->setURI($view_uri);
+ }
+
+ if ($book->getIsArchived()) {
+ $title = pht('Really activate book?');
+ $body = pht('This book will become active again.');
+ $button = pht('Activate Book');
+ } else {
+ $title = pht('Really archive book?');
+ $body = pht('This book will be moved to the archive.');
+ $button = pht('Archive Book');
+ }
+
+ return $this->newDialog()
+ ->setTitle($title)
+ ->appendChild($body)
+ ->addCancelButton($view_uri)
+ ->addSubmitButton($button);
+ }
+
+}
diff --git a/src/applications/diviner/controller/DivinerBookController.php b/src/applications/diviner/controller/DivinerBookController.php
--- a/src/applications/diviner/controller/DivinerBookController.php
+++ b/src/applications/diviner/controller/DivinerBookController.php
@@ -53,6 +53,12 @@
->setName($book->getRepository()->getMonogram()));
}
+ if ($book->getIsArchived()) {
+ $header->setStatus('fa-ban', 'red', pht('Archived'));
+ } else {
+ $header->setStatus('fa-check', 'bluegrey', pht('Active'));
+ }
+
$document = new PHUIDocumentView();
$document->setHeader($header);
$document->addClass('diviner-view');
@@ -136,6 +142,24 @@
->setHref('/book/'.$book->getName().'/edit/')
->setDisabled(!$can_edit));
+ if ($book->getIsArchived()) {
+ $action_view->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('Activate Book'))
+ ->setIcon('fa-check')
+ ->setHref('/book/'.$book->getName().'/archive/')
+ ->setDisabled(!$can_edit)
+ ->setWorkflow(true));
+ } else {
+ $action_view->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('Archive Book'))
+ ->setIcon('fa-ban')
+ ->setHref('/book/'.$book->getName().'/archive/')
+ ->setDisabled(!$can_edit)
+ ->setWorkflow(true));
+ }
+
return $action_view;
}
diff --git a/src/applications/diviner/controller/DivinerMainController.php b/src/applications/diviner/controller/DivinerMainController.php
--- a/src/applications/diviner/controller/DivinerMainController.php
+++ b/src/applications/diviner/controller/DivinerMainController.php
@@ -11,6 +11,7 @@
$books = id(new DivinerBookQuery())
->setViewer($viewer)
+ ->withIsArchived(false)
->execute();
$crumbs = $this->buildApplicationCrumbs();
diff --git a/src/applications/diviner/editor/DivinerLiveBookEditor.php b/src/applications/diviner/editor/DivinerLiveBookEditor.php
--- a/src/applications/diviner/editor/DivinerLiveBookEditor.php
+++ b/src/applications/diviner/editor/DivinerLiveBookEditor.php
@@ -17,7 +17,61 @@
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
+ $types[] = DivinerLiveBookTransaction::TYPE_ARCHIVED;
+
return $types;
}
+ protected function getCustomTransactionOldValue(
+ PhabricatorLiskDAO $object,
+ PhabricatorApplicationTransaction $xaction) {
+
+ switch ($xaction->getTransactionType()) {
+ case DivinerLiveBookTransaction::TYPE_ARCHIVED:
+ return $object->getIsArchived();
+ default:
+ return parent::getCustomTransactionOldValue($object, $xaction);
+ }
+ }
+
+ protected function getCustomTransactionNewValue(
+ PhabricatorLiskDAO $object,
+ PhabricatorApplicationTransaction $xaction) {
+
+ switch ($xaction->getTransactionType()) {
+ case DivinerLiveBookTransaction::TYPE_ARCHIVED:
+ return $xaction->getNewValue();
+ default:
+ return parent::getCustomTransactionNewValue($object, $xaction);
+ }
+ }
+
+ protected function applyCustomInternalTransaction(
+ PhabricatorLiskDAO $object,
+ PhabricatorApplicationTransaction $xaction) {
+
+ switch ($xaction->getTransactionType()) {
+ case DivinerLiveBookTransaction::TYPE_ARCHIVED:
+ $object->setIsArchived((int)$xaction->getNewValue());
+ return;
+ default:
+ return parent::applyCustomInternalTransaction($object, $xaction);
+ }
+ }
+
+ protected function applyCustomExternalTransaction(
+ PhabricatorLiskDAO $object,
+ PhabricatorApplicationTransaction $xaction) {
+
+ $old = $xaction->getOldValue();
+ $new = $xaction->getNewValue();
+
+ switch ($xaction->getTransactionType()) {
+ case DivinerLiveBookTransaction::TYPE_ARCHIVED:
+ return;
+ default:
+ return parent::applyCustomExternalTransaction($object, $xaction);
+ }
+ }
+
}
diff --git a/src/applications/diviner/query/DivinerAtomQuery.php b/src/applications/diviner/query/DivinerAtomQuery.php
--- a/src/applications/diviner/query/DivinerAtomQuery.php
+++ b/src/applications/diviner/query/DivinerAtomQuery.php
@@ -122,18 +122,7 @@
}
protected function loadPage() {
- $table = new DivinerLiveSymbol();
- $conn_r = $table->establishConnection('r');
-
- $data = queryfx_all(
- $conn_r,
- 'SELECT * FROM %T %Q %Q %Q',
- $table->getTableName(),
- $this->buildWhereClause($conn_r),
- $this->buildOrderClause($conn_r),
- $this->buildLimitClause($conn_r));
-
- return $table->loadAllFromArray($data);
+ return $this->loadStandardPage(new DivinerLiveSymbol());
}
protected function willFilterPage(array $atoms) {
@@ -299,40 +288,40 @@
return $atoms;
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
- $where = array();
+ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
+ $where = parent::buildWhereClauseParts($conn);
if ($this->ids) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->bookPHIDs) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'bookPHID IN (%Ls)',
$this->bookPHIDs);
}
if ($this->types) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'type IN (%Ls)',
$this->types);
}
if ($this->names) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'name IN (%Ls)',
$this->names);
}
@@ -347,7 +336,7 @@
}
$where[] = qsprintf(
- $conn_r,
+ $conn,
'titleSlugHash in (%Ls)',
$hashes);
}
@@ -366,46 +355,46 @@
if ($contexts && $with_null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'context IN (%Ls) OR context IS NULL',
$contexts);
} else if ($contexts) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'context IN (%Ls)',
$contexts);
} else if ($with_null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'context IS NULL');
}
}
if ($this->indexes) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'atomIndex IN (%Ld)',
$this->indexes);
}
if ($this->isDocumentable !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'isDocumentable = %d',
(int)$this->isDocumentable);
}
if ($this->isGhost !== null) {
if ($this->isGhost) {
- $where[] = qsprintf($conn_r, 'graphHash IS NULL');
+ $where[] = qsprintf($conn, 'graphHash IS NULL');
} else {
- $where[] = qsprintf($conn_r, 'graphHash IS NOT NULL');
+ $where[] = qsprintf($conn, 'graphHash IS NOT NULL');
}
}
if ($this->nodeHashes) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'nodeHash IN (%Ls)',
$this->nodeHashes);
}
@@ -415,21 +404,21 @@
// the column has binary collation. Eventually, this should move into
// fulltext.
$where[] = qsprintf(
- $conn_r,
+ $conn,
'CONVERT(name USING utf8) LIKE %~',
$this->nameContains);
}
if ($this->repositoryPHIDs) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'repositoryPHID IN (%Ls)',
$this->repositoryPHIDs);
}
- $where[] = $this->buildPagingClause($conn_r);
+ $where[] = $this->buildPagingClause($conn);
- return $this->formatWhereClause($where);
+ return $where;
}
/**
diff --git a/src/applications/diviner/query/DivinerAtomSearchEngine.php b/src/applications/diviner/query/DivinerAtomSearchEngine.php
--- a/src/applications/diviner/query/DivinerAtomSearchEngine.php
+++ b/src/applications/diviner/query/DivinerAtomSearchEngine.php
@@ -10,92 +10,52 @@
return 'PhabricatorDivinerApplication';
}
- public function buildSavedQueryFromRequest(AphrontRequest $request) {
- $saved = new PhabricatorSavedQuery();
-
- $saved->setParameter(
- 'bookPHIDs',
- $this->readPHIDsFromRequest($request, 'bookPHIDs'));
- $saved->setParameter(
- 'repositoryPHIDs',
- $this->readPHIDsFromRequest($request, 'repositoryPHIDs'));
- $saved->setParameter('name', $request->getStr('name'));
- $saved->setParameter(
- 'types',
- $this->readListFromRequest($request, 'types'));
-
- return $saved;
+ public function newResultObject() {
+ return new DivinerLiveAtom();
}
- public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
+ protected function buildCustomSearchFields() {
+ return array(
+ id(new PhabricatorSearchTextField())
+ ->setKey('name')
+ ->setLabel(pht('Name Contains')),
+ id(new PhabricatorSearchCheckboxesField())
+ ->setKey('types')
+ ->setLabel(pht('Types'))
+ ->setOptions(DivinerAtom::getAllTypes()),
+ id(new PhabricatorSearchBooksField())
+ ->setKey('bookPHIDs')
+ ->setAliases(array('books'))
+ ->setLabel(pht('Books')),
+ id(new PhabricatorSearchRepositoryField())
+ ->setKey('repositoryPHIDs')
+ ->setAliases(array('repositories'))
+ ->setLabel(pht('Repositories')),
+ );
+ }
+
+ protected function buildQueryFromParameters(array $map) {
$query = id(new DivinerAtomQuery());
- $books = $saved->getParameter('bookPHIDs');
- if ($books) {
- $query->withBookPHIDs($books);
+ if ($map['bookPHIDs']) {
+ $query->withBookPHIDs($map['bookPHIDs']);
}
- $repository_phids = $saved->getParameter('repositoryPHIDs');
- if ($repository_phids) {
- $query->withRepositoryPHIDs($repository_phids);
+ if ($map['repositoryPHIDs']) {
+ $query->withRepositoryPHIDs($map['repositoryPHIDs']);
}
- $name = $saved->getParameter('name');
- if ($name) {
- $query->withNameContains($name);
+ if ($map['name']) {
+ $query->withNameContains($map['name']);
}
- $types = $saved->getParameter('types');
- if ($types) {
- $query->withTypes($types);
+ if ($map['types']) {
+ $query->withTypes($map['types']);
}
return $query;
}
- public function buildSearchForm(
- AphrontFormView $form,
- PhabricatorSavedQuery $saved) {
-
- $form->appendChild(
- id(new AphrontFormTextControl())
- ->setLabel(pht('Name Contains'))
- ->setName('name')
- ->setValue($saved->getParameter('name')));
-
- $all_types = array();
- foreach (DivinerAtom::getAllTypes() as $type) {
- $all_types[$type] = DivinerAtom::getAtomTypeNameString($type);
- }
- asort($all_types);
-
- $types = $saved->getParameter('types', array());
- $types = array_fuse($types);
- $type_control = id(new AphrontFormCheckboxControl())
- ->setLabel(pht('Types'));
- foreach ($all_types as $type => $name) {
- $type_control->addCheckbox(
- 'types[]',
- $type,
- $name,
- isset($types[$type]));
- }
- $form->appendChild($type_control);
-
- $form->appendControl(
- id(new AphrontFormTokenizerControl())
- ->setDatasource(new DivinerBookDatasource())
- ->setName('bookPHIDs')
- ->setLabel(pht('Books'))
- ->setValue($saved->getParameter('bookPHIDs')));
-
- $form->appendControl(
- id(new AphrontFormTokenizerControl())
- ->setLabel(pht('Repositories'))
- ->setName('repositoryPHIDs')
- ->setDatasource(new DiffusionRepositoryDatasource())
- ->setValue($saved->getParameter('repositoryPHIDs')));
- }
protected function getURI($path) {
return '/diviner/'.$path;
diff --git a/src/applications/diviner/query/DivinerBookQuery.php b/src/applications/diviner/query/DivinerBookQuery.php
--- a/src/applications/diviner/query/DivinerBookQuery.php
+++ b/src/applications/diviner/query/DivinerBookQuery.php
@@ -8,6 +8,7 @@
private $nameLike;
private $namePrefix;
private $repositoryPHIDs;
+ private $isArchived;
private $needProjectPHIDs;
private $needRepositories;
@@ -42,6 +43,11 @@
return $this;
}
+ public function withIsArchived($is_archived) {
+ $this->isArchived = $is_archived;
+ return $this;
+ }
+
public function needProjectPHIDs($need_phids) {
$this->needProjectPHIDs = $need_phids;
return $this;
@@ -53,18 +59,7 @@
}
protected function loadPage() {
- $table = new DivinerLiveBook();
- $conn_r = $table->establishConnection('r');
-
- $data = queryfx_all(
- $conn_r,
- 'SELECT * FROM %T %Q %Q %Q',
- $table->getTableName(),
- $this->buildWhereClause($conn_r),
- $this->buildOrderClause($conn_r),
- $this->buildLimitClause($conn_r));
-
- return $table->loadAllFromArray($data);
+ return $this->loadStandardPage(new DivinerLiveBook());
}
protected function didFilterPage(array $books) {
@@ -116,54 +111,61 @@
return $books;
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
- $where = array();
+ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
+ $where = parent::buildWhereClauseParts($conn);
if ($this->ids) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'phid IN (%Ls)',
$this->phids);
}
if (strlen($this->nameLike)) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'name LIKE %~',
$this->nameLike);
}
if ($this->names !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'name IN (%Ls)',
$this->names);
}
if (strlen($this->namePrefix)) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'name LIKE %>',
$this->namePrefix);
}
if ($this->repositoryPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'repositoryPHID IN (%Ls)',
$this->repositoryPHIDs);
}
- $where[] = $this->buildPagingClause($conn_r);
+ if ($this->isArchived !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'isArchived = %d',
+ (int)$this->isArchived);
+ }
+
+ $where[] = $this->buildPagingClause($conn);
- return $this->formatWhereClause($where);
+ return $where;
}
public function getQueryApplicationClass() {
diff --git a/src/applications/diviner/search/DivinerBookSearchIndexer.php b/src/applications/diviner/search/DivinerBookSearchIndexer.php
--- a/src/applications/diviner/search/DivinerBookSearchIndexer.php
+++ b/src/applications/diviner/search/DivinerBookSearchIndexer.php
@@ -19,6 +19,14 @@
$book->getPreface());
$doc->addRelationship(
+ $book->getIsArchived()
+ ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED
+ : PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
+ $book->getPHID(),
+ DivinerBookPHIDType::TYPECONST,
+ PhabricatorTime::getNow());
+
+ $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY,
$book->getRepositoryPHID(),
PhabricatorRepositoryRepositoryPHIDType::TYPECONST,
diff --git a/src/applications/diviner/search/field/PhabricatorSearchBooksField.php b/src/applications/diviner/search/field/PhabricatorSearchBooksField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/diviner/search/field/PhabricatorSearchBooksField.php
@@ -0,0 +1,18 @@
+<?php
+
+final class PhabricatorSearchBooksField
+ extends PhabricatorSearchTokenizerField {
+
+ protected function getDefaultValue() {
+ return array();
+ }
+
+ protected function getValueFromRequest(AphrontRequest $request, $key) {
+ return $this->readPHIDsFromRequest($request, $key);
+ }
+
+ protected function newDatasource() {
+ return new DivinerBookDatasource();
+ }
+
+}
diff --git a/src/applications/diviner/storage/DivinerLiveBook.php b/src/applications/diviner/storage/DivinerLiveBook.php
--- a/src/applications/diviner/storage/DivinerLiveBook.php
+++ b/src/applications/diviner/storage/DivinerLiveBook.php
@@ -9,6 +9,7 @@
protected $name;
protected $repositoryPHID;
+ protected $isArchived = false;
protected $viewPolicy;
protected $editPolicy;
protected $configurationData = array();
@@ -25,6 +26,7 @@
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text64',
'repositoryPHID' => 'phid?',
+ 'isArchived' => 'bool',
),
self::CONFIG_KEY_SCHEMA => array(
'key_phid' => null,
diff --git a/src/applications/diviner/storage/DivinerLiveBookTransaction.php b/src/applications/diviner/storage/DivinerLiveBookTransaction.php
--- a/src/applications/diviner/storage/DivinerLiveBookTransaction.php
+++ b/src/applications/diviner/storage/DivinerLiveBookTransaction.php
@@ -3,6 +3,8 @@
final class DivinerLiveBookTransaction
extends PhabricatorApplicationTransaction {
+ const TYPE_ARCHIVED = 'diviner:book:archived';
+
public function getApplicationName() {
return 'diviner';
}
@@ -15,4 +17,86 @@
return null;
}
+ public function getColor() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
+ switch ($this->getTransactionType()) {
+ case self::TYPE_ARCHIVED:
+ if ($new) {
+ return 'red';
+ } else {
+ return 'green';
+ }
+ default:
+ return parent::getColor();
+ }
+ }
+
+ public function getIcon() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
+ switch ($this->getTransactionType()) {
+ case self::TYPE_ARCHIVED:
+ if ($new) {
+ return 'fa-ban';
+ } else {
+ return 'fa-check';
+ }
+ default:
+ return parent::getIcon();
+ }
+ }
+
+ public function getTitle() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+ $author_handle = $this->renderHandleLink($this->getAuthorPHID());
+
+ switch ($this->getTransactionType()) {
+ case self::TYPE_ARCHIVED:
+ if ($new) {
+ return pht(
+ '%s archived this book.',
+ $author_handle);
+ } else {
+ return pht(
+ '%s activated this book.',
+ $author_handle);
+ }
+ break;
+
+ default:
+ return parent::getTitle();
+ }
+ }
+
+ public function getTitleForFeed() {
+ $author_phid = $this->getAuthorPHID();
+ $object_phid = $this->getObjectPHID();
+ $author_handle = $this->renderHandleLink($author_phid);
+ $object_handle = $this->renderHandleLink($object_phid);
+
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
+ switch ($this->getTransactionType()) {
+ case self::TYPE_ARCHIVED:
+ if ($new) {
+ return pht(
+ '%s archived %s.',
+ $author_handle,
+ $object_handle);
+ } else {
+ return pht(
+ '%s activated %s.',
+ $author_handle,
+ $object_handle);
+ }
+ default:
+ return parent::getTitleForFeed();
+ }
+ }
+
}
diff --git a/src/applications/repository/search/field/PhabricatorSearchRepositoryField.php b/src/applications/repository/search/field/PhabricatorSearchRepositoryField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/repository/search/field/PhabricatorSearchRepositoryField.php
@@ -0,0 +1,18 @@
+<?php
+
+final class PhabricatorSearchRepositoryField
+ extends PhabricatorSearchTokenizerField {
+
+ protected function getDefaultValue() {
+ return array();
+ }
+
+ protected function getValueFromRequest(AphrontRequest $request, $key) {
+ return $this->readPHIDsFromRequest($request, $key);
+ }
+
+ protected function newDatasource() {
+ return new DiffusionRepositoryDatasource();
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Feb 12, 9:31 AM (6 h, 28 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7124094
Default Alt Text
D13256.diff (26 KB)
Attached To
Mode
D13256: Allow books to be archived
Attached
Detach File
Event Timeline
Log In to Comment