drop "inversion of control" loading them this way we can remove MooseX::Object::Pluggable completely, which did a filesystem search on _every_ panel page called. Change-Id: If22dbb1a5a2ab24dee7af68a0085072ab1b2b855changes/25/5925/2
parent
cbad4ce55d
commit
d659ae10ed
@ -1,35 +0,0 @@
|
||||
package NGCP::Panel::Widget;
|
||||
use Moose;
|
||||
with 'MooseX::Object::Pluggable';
|
||||
|
||||
sub handle {
|
||||
my ($self, $c) = @_;
|
||||
return;
|
||||
}
|
||||
|
||||
sub filter {
|
||||
my ($self, $c) = @_;
|
||||
return;
|
||||
}
|
||||
|
||||
sub instantiate_plugins {
|
||||
my ($self, $c, $type_filter) = @_;
|
||||
my @plugins = map { s/^.*:://r; } $self->_plugin_locator->plugins;
|
||||
|
||||
my @instances = ();
|
||||
foreach(@plugins) {
|
||||
my $inst = NGCP::Panel::Widget->new;
|
||||
$inst->load_plugin($_);
|
||||
if($inst->filter($c, $type_filter)) {
|
||||
push @instances, { instance => $inst, name => $_ };
|
||||
}
|
||||
}
|
||||
my @sorted_instances = sort {$a->{instance}->priority <=> $b->{instance}->priority} @instances;
|
||||
return @sorted_instances;
|
||||
}
|
||||
|
||||
no Moose;
|
||||
__PACKAGE__->meta->make_immutable;
|
||||
|
||||
1;
|
||||
# vim: set tabstop=4 expandtab:
|
@ -1,32 +0,0 @@
|
||||
package NGCP::Panel::Widget::Plugin::AdminTopMenuSettings;
|
||||
use Moose::Role;
|
||||
|
||||
has 'template' => (
|
||||
is => 'ro',
|
||||
isa => 'Str',
|
||||
default => 'widgets/admin_topmenu_settings.tt'
|
||||
);
|
||||
|
||||
has 'type' => (
|
||||
is => 'ro',
|
||||
isa => 'Str',
|
||||
default => 'topmenu_widgets',
|
||||
);
|
||||
|
||||
around handle => sub {
|
||||
my ($foo, $self, $c) = @_;
|
||||
return;
|
||||
};
|
||||
|
||||
sub filter {
|
||||
my ($self, $c, $type) = @_;
|
||||
|
||||
return $self if(
|
||||
$type eq $self->type &&
|
||||
$c->user->roles eq 'admin'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
1;
|
||||
# vim: set syntax=perl tabstop=4 expandtab:
|
@ -1,32 +0,0 @@
|
||||
package NGCP::Panel::Widget::Plugin::ResellerTopMenuSettings;
|
||||
use Moose::Role;
|
||||
|
||||
has 'template' => (
|
||||
is => 'ro',
|
||||
isa => 'Str',
|
||||
default => 'widgets/reseller_topmenu_settings.tt'
|
||||
);
|
||||
|
||||
has 'type' => (
|
||||
is => 'ro',
|
||||
isa => 'Str',
|
||||
default => 'topmenu_widgets',
|
||||
);
|
||||
|
||||
around handle => sub {
|
||||
my ($foo, $self, $c) = @_;
|
||||
return;
|
||||
};
|
||||
|
||||
sub filter {
|
||||
my ($self, $c, $type) = @_;
|
||||
|
||||
return $self if(
|
||||
$type eq $self->type &&
|
||||
$c->user->roles eq 'reseller'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
1;
|
||||
# vim: set syntax=perl tabstop=4 expandtab:
|
@ -1,32 +0,0 @@
|
||||
package NGCP::Panel::Widget::Plugin::SubscriberAdminTopMenuSettings;
|
||||
use Moose::Role;
|
||||
|
||||
has 'template' => (
|
||||
is => 'ro',
|
||||
isa => 'Str',
|
||||
default => 'widgets/subscriberadmin_topmenu_settings.tt'
|
||||
);
|
||||
|
||||
has 'type' => (
|
||||
is => 'ro',
|
||||
isa => 'Str',
|
||||
default => 'topmenu_widgets',
|
||||
);
|
||||
|
||||
around handle => sub {
|
||||
my ($foo, $self, $c) = @_;
|
||||
return;
|
||||
};
|
||||
|
||||
sub filter {
|
||||
my ($self, $c, $type) = @_;
|
||||
|
||||
return $self if(
|
||||
$type eq $self->type &&
|
||||
$c->user->roles eq 'subscriberadmin'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
1;
|
||||
# vim: set syntax=perl tabstop=4 expandtab:
|
@ -1,32 +0,0 @@
|
||||
package NGCP::Panel::Widget::Plugin::SubscriberTopMenuSettings;
|
||||
use Moose::Role;
|
||||
|
||||
has 'template' => (
|
||||
is => 'ro',
|
||||
isa => 'Str',
|
||||
default => 'widgets/subscriber_topmenu_settings.tt'
|
||||
);
|
||||
|
||||
has 'type' => (
|
||||
is => 'ro',
|
||||
isa => 'Str',
|
||||
default => 'topmenu_widgets',
|
||||
);
|
||||
|
||||
around handle => sub {
|
||||
my ($foo, $self, $c) = @_;
|
||||
return;
|
||||
};
|
||||
|
||||
sub filter {
|
||||
my ($self, $c, $type) = @_;
|
||||
|
||||
return $self if(
|
||||
$type eq $self->type &&
|
||||
$c->user->roles eq 'subscriber'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
1;
|
||||
# vim: set syntax=perl tabstop=4 expandtab:
|
Loading…
Reference in new issue