Skip to content
Snippets Groups Projects
Commit 994d15e5 authored by baldwinlouie's avatar baldwinlouie Committed by Yas Naoi
Browse files

Issue #3175280 by baldwinlouie, yas: Display a warning message before stop...

Issue #3175280 by baldwinlouie, yas: Display a warning message before stop Cloud Orchestrator itself
parent 48ccc2df
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,9 @@ class InstanceStopForm extends AwsDeleteUpdateEntityForm {
public function getQuestion() {
$entity = $this->entity;
if ($this->ec2Service->isInstanceCloudOrchestrator($this->entity->getInstanceId()) === TRUE) {
$this->messenger()->addWarning($this->t('Attempting to stop Cloud Orchestrator instance. Cloud Orchestrator will stop responding until the instance is restarted.'));
}
return $this->t('Are you sure you want to stop instance: %name?', [
'%name' => $entity->label(),
]);
......
......@@ -2,6 +2,7 @@
namespace Drupal\aws_cloud\Form\Ec2;
use Drupal\aws_cloud\Entity\Ec2\Instance;
use Drupal\cloud\Entity\CloudContentEntityBase;
/**
......@@ -13,7 +14,7 @@ class InstanceStopMultipleForm extends AwsCloudProcessMultipleForm {
* {@inheritdoc}
*/
public function getQuestion() {
$this->checkCloudOrchestratorIp();
return $this->formatPlural(count($this->selection),
'Are you sure you want to stop this @item?',
'Are you sure you want to stop these @items?', [
......@@ -23,6 +24,22 @@ class InstanceStopMultipleForm extends AwsCloudProcessMultipleForm {
);
}
/**
* Check if Cloud Orchestrator is being stopped.
*
* Notify the user with a warning message if Cloud Orchestrator's IP
* is one of the selected IPs.
*/
private function checkCloudOrchestratorIp(): void {
foreach ($this->selection as $id => $selection) {
$instance = Instance::load($id);
if (!empty($instance) && $this->ec2Service->isInstanceCloudOrchestrator($instance->getInstanceId()) === TRUE) {
$this->messenger()->addWarning($this->t('Attempting to stop Cloud Orchestrator instance. Cloud Orchestrator will stop responding until the instance is restarted.'));
break;
}
}
}
/**
* {@inheritdoc}
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment