Skip to content

Commit

Permalink
chore: improved admin entity inspection page
Browse files Browse the repository at this point in the history
  • Loading branch information
jeabakker committed Aug 13, 2024
1 parent 45e7b14 commit fd14c35
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
2 changes: 2 additions & 0 deletions languages/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@
'opensearch:inspect:result:last_indexed:time' => "This entity was last indexed: %s",
'opensearch:inspect:result:reindex' => "Schedule for reindexing",
'opensearch:inspect:result:delete' => "Remove entity from index",
'opensearch:inspect:result:not_found:elgg' => "The entity could not be found in Elgg and the OpenSearch index",
'opensearch:inspect:result:not_found:index' => "The entity could not be found in Elgg, but still exists in the OpenSearch index",

// forms
'opensearch:forms:admin_search:query:placeholder' => "Enter your search query here",
Expand Down
6 changes: 4 additions & 2 deletions languages/nl.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php
/**
* This file was created by Translation Editor v11.1
* On 2023-05-17 15:01
* This file was created by Translation Editor v14.0
* On 2024-08-13 12:04
*/

return array (
'opensearch:inspect:result:not_found:elgg' => 'De entiteit kon niet worden gevonden in Elgg en de OpenSearch index',
'opensearch:inspect:result:not_found:index' => 'De entiteit kon niet worden gevonden in Elgg, maar bestaat nog wel in de OpenSearch index',
'opensearch:upgrade:2022061500:title' => 'Voeg aliassen toe aan de OpenSearch index',
'opensearch:upgrade:2022061500:description' => 'Wegens een aanpassing in de werking van de plugin moet de OpenSearch index een aantal extra aliassen krijgen. Deze upgrade zal deze toevoegen aan de index.',
'opensearch:cli:rebuild:description' => 'Herbouw de index met een nieuwe configuratie en/of mappings',
Expand Down
28 changes: 22 additions & 6 deletions views/default/admin/opensearch/inspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,36 @@
return;
}

$service = SearchService::instance();
$registered_types = opensearch_get_registered_entity_types();

$entity = elgg_call(ELGG_SHOW_DELETED_ENTITIES, function() use ($guid) {
return get_entity($guid);
});

$opensearch_content = $service->inspect($guid);

if (!$entity instanceof \ElggEntity) {
// Entity doesn't exist in Elgg or was trashed
$result = elgg_view('output/longtext', [
'value' => elgg_echo('notfound'),
]);
if (!empty($opensearch_content)) {
// entity still exists in OpenSearch index add button to delete entity from index
$result = elgg_view('output/longtext', [
'value' => elgg_echo('opensearch:inspect:result:not_found:index'),
]);

$result .= elgg_view('output/url', [
'icon' => 'delete',
'text' => elgg_echo('opensearch:inspect:result:delete'),
'href' => elgg_generate_action_url('opensearch/admin/delete_entity', [
'guid' => $entity->guid,
]),
'class' => 'elgg-button elgg-button-action',
]);
} else {
$result = elgg_view('output/longtext', [
'value' => elgg_echo('opensearch:inspect:result:not_found:elgg'),
]);
}
} elseif (!array_key_exists($entity->getType(), $registered_types) || (array_key_exists($entity->getType(), $registered_types) && !empty($entity->getSubtype()) && !in_array($entity->getSubtype(), $registered_types[$entity->getType()]))) {
// entity won't be exported to ES
$result = elgg_view('output/longtext', [
Expand Down Expand Up @@ -64,9 +83,6 @@
]);
}

$service = SearchService::instance();

$opensearch_content = $service->inspect($guid);
if (empty($opensearch_content)) {
$result = elgg_view('output/longtext', [
'value' => elgg_echo('opensearch:inspect:result:error:not_indexed'),
Expand Down

0 comments on commit fd14c35

Please sign in to comment.