Page MenuHomePhabricator

D10953.id26304.diff
No OneTemporary

D10953.id26304.diff

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
@@ -1186,6 +1186,7 @@
'PassphraseRemarkupRule' => 'applications/passphrase/remarkup/PassphraseRemarkupRule.php',
'PassphraseSSHKey' => 'applications/passphrase/keys/PassphraseSSHKey.php',
'PassphraseSchemaSpec' => 'applications/passphrase/storage/PassphraseSchemaSpec.php',
+ 'PassphraseSearchIndexer' => 'applications/passphrase/search/PassphraseSearchIndexer.php',
'PassphraseSecret' => 'applications/passphrase/storage/PassphraseSecret.php',
'PasteConduitAPIMethod' => 'applications/paste/conduit/PasteConduitAPIMethod.php',
'PasteCreateConduitAPIMethod' => 'applications/paste/conduit/PasteCreateConduitAPIMethod.php',
@@ -4280,6 +4281,7 @@
'PassphraseRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'PassphraseSSHKey' => 'PassphraseAbstractKey',
'PassphraseSchemaSpec' => 'PhabricatorConfigSchemaSpec',
+ 'PassphraseSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
'PassphraseSecret' => 'PassphraseDAO',
'PasteConduitAPIMethod' => 'ConduitAPIMethod',
'PasteCreateConduitAPIMethod' => 'PasteConduitAPIMethod',
diff --git a/src/applications/passphrase/editor/PassphraseCredentialTransactionEditor.php b/src/applications/passphrase/editor/PassphraseCredentialTransactionEditor.php
--- a/src/applications/passphrase/editor/PassphraseCredentialTransactionEditor.php
+++ b/src/applications/passphrase/editor/PassphraseCredentialTransactionEditor.php
@@ -202,5 +202,7 @@
return $errors;
}
-
+ protected function supportsSearch() {
+ return true;
+ }
}
diff --git a/src/applications/passphrase/query/PassphraseCredentialQuery.php b/src/applications/passphrase/query/PassphraseCredentialQuery.php
--- a/src/applications/passphrase/query/PassphraseCredentialQuery.php
+++ b/src/applications/passphrase/query/PassphraseCredentialQuery.php
@@ -9,6 +9,7 @@
private $providesTypes;
private $isDestroyed;
private $allowConduit;
+ private $nameContains;
private $needSecrets;
@@ -42,6 +43,11 @@
return $this;
}
+ public function withNameContains($name_contains) {
+ $this->nameContains = $name_contains;
+ return $this;
+ }
+
public function needSecrets($need_secrets) {
$this->needSecrets = $need_secrets;
return $this;
@@ -140,6 +146,13 @@
(int)$this->allowConduit);
}
+ if (strlen($this->nameContains)) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'name LIKE %~',
+ $this->nameContains);
+ }
+
return $this->formatWhereClause($where);
}
diff --git a/src/applications/passphrase/query/PassphraseCredentialSearchEngine.php b/src/applications/passphrase/query/PassphraseCredentialSearchEngine.php
--- a/src/applications/passphrase/query/PassphraseCredentialSearchEngine.php
+++ b/src/applications/passphrase/query/PassphraseCredentialSearchEngine.php
@@ -17,6 +17,7 @@
$saved->setParameter(
'isDestroyed',
$this->readBoolFromRequest($request, 'isDestroyed'));
+ $saved->setParameter('name', $request->getStr('name'));
return $saved;
}
@@ -29,6 +30,11 @@
$query->withIsDestroyed($destroyed);
}
+ $name = $saved->getParameter('name');
+ if (strlen($name)) {
+ $query->withNameContains($name);
+ }
+
return $query;
}
@@ -36,7 +42,10 @@
AphrontFormView $form,
PhabricatorSavedQuery $saved_query) {
- $form->appendChild(
+ $name = $saved_query->getParameter('name');
+
+ $form
+ ->appendChild(
id(new AphrontFormSelectControl())
->setName('isDestroyed')
->setLabel(pht('Status'))
@@ -46,7 +55,12 @@
'' => pht('Show All Credentials'),
'false' => pht('Show Only Active Credentials'),
'true' => pht('Show Only Destroyed Credentials'),
- )));
+ )))
+ ->appendChild(
+ id(new AphrontFormTextControl())
+ ->setName('name')
+ ->setLabel(pht('Name Contains'))
+ ->setValue($name));
}
protected function getURI($path) {
diff --git a/src/applications/passphrase/search/PassphraseSearchIndexer.php b/src/applications/passphrase/search/PassphraseSearchIndexer.php
new file mode 100644
--- /dev/null
+++ b/src/applications/passphrase/search/PassphraseSearchIndexer.php
@@ -0,0 +1,39 @@
+<?php
+
+final class PassphraseSearchIndexer extends PhabricatorSearchDocumentIndexer {
+
+ public function getIndexableObject() {
+ return new PassphraseCredential();
+ }
+
+ protected function buildAbstractDocumentByPHID($phid) {
+ $credential = $this->loadDocumentByPHID($phid);
+
+ $doc = new PhabricatorSearchAbstractDocument();
+ $doc->setPHID($credential->getPHID());
+ $doc->setDocumentType(PassphraseCredentialPHIDType::TYPECONST);
+ $doc->setDocumentTitle($credential->getName());
+ $doc->setDocumentCreated($credential->getDateCreated());
+ $doc->setDocumentModified($credential->getDateModified());
+
+ $doc->addField(
+ PhabricatorSearchField::FIELD_BODY,
+ $credential->getDescription());
+
+ $doc->addRelationship(
+ $credential->getIsDestroyed()
+ ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED
+ : PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
+ $credential->getPHID(),
+ PassphraseCredentialPHIDType::TYPECONST,
+ time());
+
+ $this->indexTransactions(
+ $doc,
+ new PassphraseCredentialTransactionQuery(),
+ array($phid));
+
+ return $doc;
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 24, 7:29 AM (2 w, 1 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7706343
Default Alt Text
D10953.id26304.diff (5 KB)

Event Timeline