Skip to content

Commit

Permalink
Merge pull request #3383 from rbayet/feat-indices-allow-hiding-extern…
Browse files Browse the repository at this point in the history
…al-indices

[Indices] Allow hiding external indices
  • Loading branch information
rbayet authored Sep 16, 2024
2 parents 586eb5f + 5c3c0c8 commit 2edcc07
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 4 deletions.
20 changes: 17 additions & 3 deletions src/module-elasticsuite-indices/Model/Index/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,18 @@ public function __construct(
*/
public function addFieldToFilter($field, $condition = null)
{
if (in_array($field, ['index_alias', 'index_name'])) {
$type = 'include';
if ($field === 'index_status') {
$type = 'exclude';
}
if (in_array($field, ['index_alias', 'index_name', 'index_status'])) {
if (is_array($condition)) {
foreach ($condition as $value) {
$this->addFilter($field, preg_replace('/[^A-Za-z0-9\-_]/', '', $value->__toString()));
$this->addFilter(
$field,
preg_replace('/[^A-Za-z0-9\-_]/', '', (string) $value),
$type
);
}
}
}
Expand Down Expand Up @@ -108,7 +116,13 @@ private function applyPostFilters(array $filters = [], array $indices = [])
foreach ($filters as $filter) {
$column = $filter->getField();
$value = $filter->getValue();
if (strpos((string) $index->getData($column), $value) === false) {
$type = $filter->getType();
if ($type === 'exclude') {
if (strpos((string) $index->getData($column), $value) !== false) {
$keep = false;
break;
}
} elseif (strpos((string) $index->getData($column), $value) === false) {
$keep = false;
break;
}
Expand Down
2 changes: 2 additions & 0 deletions src/module-elasticsuite-indices/i18n/de_DE.csv
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@
"Position","Position"
"Start Offset","Start-Versatz"
"End Offset","Ende Versatz"
"Show all indices","Alle Indizes anzeigen"
"Hide external indices","Externe Indizes ausblenden"
2 changes: 2 additions & 0 deletions src/module-elasticsuite-indices/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@
"Position","Position"
"Start Offset","Start Offset"
"End Offset","End Offset"
"Show all indices","Show all indices"
"Hide external indices","Hide external indices"
2 changes: 2 additions & 0 deletions src/module-elasticsuite-indices/i18n/fr_FR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@
"Position","Position"
"Start Offset","Début de la chaîne"
"End Offset","Fin de la chaîne"
"Show all indices","Voir tous les index"
"Hide external indices","Cacher les index externes"
2 changes: 2 additions & 0 deletions src/module-elasticsuite-indices/i18n/nl_NL.csv
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@
"Position","Positie"
"Start Offset","Start Compensatie"
"End Offset","Offset eindigen"
"Show all indices","Toon alle indexen"
"Hide external indices","Externe indexen verbergen"
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,17 @@
<arguments>
<argument name="header" xsi:type="string" translate="true">Index Status</argument>
<argument name="index" xsi:type="string">index_status</argument>
<argument name="filter" xsi:type="string">0</argument>
<argument name="filter" xsi:type="string">Magento\Backend\Block\Widget\Grid\Column\Filter\Select</argument>
<argument name="options" xsi:type="array">
<item name="all" xsi:type="array">
<item name="value" xsi:type="string"> </item>
<item name="label" xsi:type="string" translate="true">Show all indices</item>
</item>
<item name="skip_external" xsi:type="array">
<item name="value" xsi:type="string">external</item>
<item name="label" xsi:type="string" translate="true">Hide external indices</item>
</item>
</argument>
<argument name="type" xsi:type="string">text</argument>
<argument name="align" xsi:type="string">left</argument>
<argument name="renderer" xsi:type="string">Smile\ElasticsuiteIndices\Block\Widget\Grid\Column\Renderer\IndexStatus</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,14 @@
background: #000000;
color: #e22626;
}

.smile_elasticsuite_indices-index-index {
.data-grid {
.col-index_status {
max-width: 13rem;
}
.col-number_of_documents, .col-size {
text-align: right;
}
}
}

0 comments on commit 2edcc07

Please sign in to comment.