Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cloud-3363995
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
cloud-3363995
Commits
68fef82c
Commit
68fef82c
authored
5 years ago
by
baldwinlouie
Committed by
Yas Naoi
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3080424
by baldwinlouie, yas: Refactor UnusedSnapshotsBlock
parent
96fdb9fb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/cloud_service_providers/aws_cloud/src/Plugin/Block/DisassociatedSnapshotsBlock.php
+10
-10
10 additions, 10 deletions
...ws_cloud/src/Plugin/Block/DisassociatedSnapshotsBlock.php
with
10 additions
and
10 deletions
modules/cloud_service_providers/aws_cloud/src/Plugin/Block/
Unus
edSnapshotsBlock.php
→
modules/cloud_service_providers/aws_cloud/src/Plugin/Block/
Disassociat
edSnapshotsBlock.php
+
10
−
10
View file @
68fef82c
...
@@ -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_
unus
ed_snapshots_block",
* id = "aws_cloud_
disassociat
ed_snapshots_block",
* admin_label = @Translation("
Unus
ed Snapshots"),
* admin_label = @Translation("
Disassociat
ed Snapshots"),
* category = @Translation("AWS Cloud")
* category = @Translation("AWS Cloud")
* )
* )
*/
*/
class
Unus
edSnapshotsBlock
extends
BlockBase
implements
ContainerFactoryPluginInterface
{
class
Disassociat
edSnapshotsBlock
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
volume
s.
* Build a list of unused
snapshot
s.
*
*
* @return array
* @return array
* A set of render arrays.
* A set of render arrays.
*/
*/
private
function
buildSnapshotList
()
{
private
function
buildSnapshotList
()
{
$build
=
[];
$build
=
[];
$snapshots
=
$this
->
get
Unus
edSnapshots
();
$snapshots
=
$this
->
get
Disassociat
edSnapshots
();
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
unus
ed snapshots.'
),
'#markup'
=>
$this
->
t
(
'Great job! You have no
disassociat
ed snapshots.'
),
];
];
}
}
return
$build
;
return
$build
;
}
}
/**
/**
* Get a list of
unus
ed snapshots.
* Get a list of
disassociat
ed snapshots.
*
*
* @return array
* @return array
* Array of
unus
ed snapshots.
* Array of
disassociat
ed snapshots.
*/
*/
private
function
get
Unus
edSnapshots
()
{
private
function
get
Disassociat
edSnapshots
()
{
$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 */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment