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

Issue #3080424 by baldwinlouie, yas: Refactor UnusedSnapshotsBlock

parent 96fdb9fb
No related branches found
No related tags found
No related merge requests found
...@@ -13,12 +13,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface; ...@@ -13,12 +13,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* Provides a block displaying unused snapshots. * Provides a block displaying unused snapshots.
* *
* @Block( * @Block(
* id = "aws_cloud_unused_snapshots_block", * id = "aws_cloud_disassociated_snapshots_block",
* admin_label = @Translation("Unused Snapshots"), * admin_label = @Translation("Disassociated Snapshots"),
* category = @Translation("AWS Cloud") * category = @Translation("AWS Cloud")
* ) * )
*/ */
class UnusedSnapshotsBlock extends BlockBase implements ContainerFactoryPluginInterface { class DisassociatedSnapshotsBlock extends BlockBase implements ContainerFactoryPluginInterface {
use StringTranslationTrait; use StringTranslationTrait;
...@@ -83,17 +83,17 @@ class UnusedSnapshotsBlock extends BlockBase implements ContainerFactoryPluginIn ...@@ -83,17 +83,17 @@ class UnusedSnapshotsBlock extends BlockBase implements ContainerFactoryPluginIn
} }
/** /**
* Build a list of unused volumes. * Build a list of unused snapshots.
* *
* @return array * @return array
* A set of render arrays. * A set of render arrays.
*/ */
private function buildSnapshotList() { private function buildSnapshotList() {
$build = []; $build = [];
$snapshots = $this->getUnusedSnapshots(); $snapshots = $this->getDisassociatedSnapshots();
if (count($snapshots)) { if (count($snapshots)) {
$urls = []; $urls = [];
/* @var \Drupal\aws_cloud\Entity\Ec2\Volume $volume */ /* @var \Drupal\aws_cloud\Entity\Ec2\Snapshot $snapshot */
foreach ($snapshots as $snapshot) { foreach ($snapshots as $snapshot) {
$urls[] = $snapshot->toLink($snapshot->getName()); $urls[] = $snapshot->toLink($snapshot->getName());
} }
...@@ -107,19 +107,19 @@ class UnusedSnapshotsBlock extends BlockBase implements ContainerFactoryPluginIn ...@@ -107,19 +107,19 @@ class UnusedSnapshotsBlock extends BlockBase implements ContainerFactoryPluginIn
} }
else { else {
$build = [ $build = [
'#markup' => $this->t('Great job! You have no unused snapshots.'), '#markup' => $this->t('Great job! You have no disassociated snapshots.'),
]; ];
} }
return $build; return $build;
} }
/** /**
* Get a list of unused snapshots. * Get a list of disassociated snapshots.
* *
* @return array * @return array
* Array of unused snapshots. * Array of disassociated snapshots.
*/ */
private function getUnusedSnapshots() { private function getDisassociatedSnapshots() {
$snapshots = aws_cloud_get_unused_snapshots(); $snapshots = aws_cloud_get_unused_snapshots();
if (!$this->currentUser->hasPermission('view any aws cloud snapshot')) { if (!$this->currentUser->hasPermission('view any aws cloud snapshot')) {
/* @var \Drupal\aws_cloud\Entity\Ec2\Snapshot $snapshot */ /* @var \Drupal\aws_cloud\Entity\Ec2\Snapshot $snapshot */
......
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