mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 08:42:41 +01:00
Title/Description quering for Passphrase credential
Summary: Fixes T6562, Title/Description querying for Passphrase Test Plan: Open Passphrase, open advanced queries, enter a title and/or description. Search results should show credentials matching the search. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6562 Differential Revision: https://secure.phabricator.com/D10953
This commit is contained in:
parent
d5e7cd5590
commit
edc4c219ca
5 changed files with 73 additions and 3 deletions
|
@ -1186,6 +1186,7 @@ phutil_register_library_map(array(
|
|||
'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 @@ phutil_register_library_map(array(
|
|||
'PassphraseRemarkupRule' => 'PhabricatorObjectRemarkupRule',
|
||||
'PassphraseSSHKey' => 'PassphraseAbstractKey',
|
||||
'PassphraseSchemaSpec' => 'PhabricatorConfigSchemaSpec',
|
||||
'PassphraseSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
|
||||
'PassphraseSecret' => 'PassphraseDAO',
|
||||
'PasteConduitAPIMethod' => 'ConduitAPIMethod',
|
||||
'PasteCreateConduitAPIMethod' => 'PasteConduitAPIMethod',
|
||||
|
|
|
@ -202,5 +202,7 @@ final class PassphraseCredentialTransactionEditor
|
|||
return $errors;
|
||||
}
|
||||
|
||||
|
||||
protected function supportsSearch() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ final class PassphraseCredentialQuery
|
|||
private $providesTypes;
|
||||
private $isDestroyed;
|
||||
private $allowConduit;
|
||||
private $nameContains;
|
||||
|
||||
private $needSecrets;
|
||||
|
||||
|
@ -42,6 +43,11 @@ final class PassphraseCredentialQuery
|
|||
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 @@ final class PassphraseCredentialQuery
|
|||
(int)$this->allowConduit);
|
||||
}
|
||||
|
||||
if (strlen($this->nameContains)) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'name LIKE %~',
|
||||
$this->nameContains);
|
||||
}
|
||||
|
||||
return $this->formatWhereClause($where);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ final class PassphraseCredentialSearchEngine
|
|||
$saved->setParameter(
|
||||
'isDestroyed',
|
||||
$this->readBoolFromRequest($request, 'isDestroyed'));
|
||||
$saved->setParameter('name', $request->getStr('name'));
|
||||
|
||||
return $saved;
|
||||
}
|
||||
|
@ -29,6 +30,11 @@ final class PassphraseCredentialSearchEngine
|
|||
$query->withIsDestroyed($destroyed);
|
||||
}
|
||||
|
||||
$name = $saved->getParameter('name');
|
||||
if (strlen($name)) {
|
||||
$query->withNameContains($name);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
@ -36,7 +42,10 @@ final class PassphraseCredentialSearchEngine
|
|||
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 @@ final class PassphraseCredentialSearchEngine
|
|||
'' => 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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue