Skip to content

Commit

Permalink
remove simulate index template
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanediondev committed Jun 23, 2024
1 parent b11a5fd commit 74839f4
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 96 deletions.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Elasticsearch is a trademark of Elasticsearch BV, registered in the U.S. and in
- Nodes: list, stats, reload secure settings [6.4], read, settings, usage [6.0], plugins
- Indices: list, stats, reindex, create, read, update, lifecycle [6.6] (explain, remove policy), delete, close / open, freeze / unfreeze [6.6], force merge [2.1], clear cache, flush, refresh, empty [5.0], search by query, export (CSV, TSV, ODS, XLSX, GEOJSON), import from file (ODS, XLSX), import from database (MySQL, PostgreSQL), aliases (list, create, delete)
- Legacy index templates: list, create, read, update, delete, copy
- Composable index templates [7.8]: list, create, read, update, delete, simulate, copy
- Composable index templates [7.8]: list, create, read, update, delete, copy
- Component templates [7.8]: list, create, read, update, delete, copy
- Index lifecycle management policies [6.6]: list, status, start, stop, create, read, update, delete, copy
- Shards: list, stats, cluster reroute (move, allocate replica, cancel allocation)
Expand Down
26 changes: 0 additions & 26 deletions src/Controller/ElasticsearchIndexTemplateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,30 +250,4 @@ public function delete(Request $request, string $name): Response
return $this->redirectToRoute('index_templates_read', ['name' => $template->getName()]);
}
}

#[Route('/index-templates/{name}/simulate', name: 'index_templates_simulate', methods: ['GET'])]
public function simulate(Request $request, string $name): Response
{
$this->denyAccessUnlessGranted('INDEX_TEMPLATES_LIST', 'index_template');

if (false === $this->callManager->hasFeature('composable_template')) {
throw new AccessDeniedException();
}

$template = $this->elasticsearchIndexTemplateManager->getByName($name);

if (null === $template) {
throw new NotFoundHttpException();
}

$callRequest = new CallRequestModel();
$callRequest->setMethod('POST');
$callRequest->setPath('/_index_template/_simulate/'.$template->getName());
$callResponse = $this->callManager->call($callRequest);

return $this->renderAbstract($request, 'Modules/index_template/index_template_simulate.html.twig', [
'template' => $template,
'simulate' => $callResponse->getContent(),
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
</li>
{% endif %}

<li class="nav-item">
<a class="nav-link {% if 'simulate' == active %}active{% endif %}" href="{{ path('index_templates_simulate', {'name': template.name}) }}">{{ 'simulate'|trans }}</a>
</li>

<li class="nav-item">
<a class="nav-link {% if 'settings' == active %}active{% endif %}" href="{{ path('index_templates_read_settings', {'name': template.name}) }}">{{ 'settings'|trans }}</a>
</li>
Expand Down
38 changes: 0 additions & 38 deletions templates/Modules/index_template/index_template_simulate.html.twig

This file was deleted.

26 changes: 0 additions & 26 deletions tests/Controller/ElasticsearchIndexTemplateControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,32 +242,6 @@ public function testMappings(): void
}
}

public function testSimulate404(): void
{
$this->client->request('GET', '/admin/index-templates/'.uniqid().'/simulate');

if (false == $this->callManager->hasFeature('composable_template')) {
$this->assertResponseStatusCodeSame(403);
} else {
$this->assertResponseStatusCodeSame(404);
}
}

public function testSimulate(): void
{
$this->client->request('GET', '/admin/index-templates/'.GENERATED_NAME.'/simulate');

if (false == $this->callManager->hasFeature('composable_template')) {
$this->assertResponseStatusCodeSame(403);
} else {
$this->assertResponseStatusCodeSame(200);
$this->assertPageTitleSame('Composable index templates - '.GENERATED_NAME.' - Simulate');
$this->assertSelectorTextSame('h1', 'Composable index templates');
$this->assertSelectorTextSame('h2', GENERATED_NAME);
$this->assertSelectorTextSame('h3', 'Simulate');
}
}

public function testDelete404(): void
{
$this->client->request('GET', '/admin/index-templates/'.uniqid().'/delete');
Expand Down
1 change: 0 additions & 1 deletion translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,6 @@ settings_persistent: "Persistent"
settings_transient: "Transient"
shard: "Shard"
shards: "Shards"
simulate: "Simulate"
size: "Size"
slm_policy: "SLM policy"
slm_short: "SLM policies"
Expand Down

0 comments on commit 74839f4

Please sign in to comment.