Francois Gouget : testbot/web: Use SimpleCollectionPage for the VMs page.

Alexandre Julliard julliard at winehq.org
Mon Apr 4 15:32:47 CDT 2022


Module: tools
Branch: master
Commit: b06fc8af3d41468e47ea7834f373fc61c27ccd80
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=b06fc8af3d41468e47ea7834f373fc61c27ccd80

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Mon Apr  4 18:15:13 2022 +0200

testbot/web: Use SimpleCollectionPage for the VMs page.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 testbot/web/admin/VMsList.pl | 49 ++++++++++++++++++++++++--------------------
 1 file changed, 27 insertions(+), 22 deletions(-)

diff --git a/testbot/web/admin/VMsList.pl b/testbot/web/admin/VMsList.pl
index 1895225..d957b44 100644
--- a/testbot/web/admin/VMsList.pl
+++ b/testbot/web/admin/VMsList.pl
@@ -2,6 +2,7 @@
 # VM list page
 #
 # Copyright 2009 Ge van Geldorp
+# Copyright 2022 Francois Gouget
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -19,58 +20,62 @@
 
 use strict;
 
-package VMsListPage;
+package VMsBlock;
 
-use ObjectModel::CGI::CollectionPage;
-our @ISA = qw(ObjectModel::CGI::CollectionPage);
-
-use WineTestBot::VMs;
+use ObjectModel::CGI::CollectionBlock;
+our @ISA = qw(ObjectModel::CGI::CollectionBlock);
 
 
-sub _initialize($$$)
+sub Create($$)
 {
-  my ($self, $Request, $RequiredRole) = @_;
+  my ($Collection, $EnclosingPage) = @_;
 
-  $self->SUPER::_initialize($Request, $RequiredRole, CreateVMs());
+  return VMsBlock->new($Collection, $EnclosingPage);
 }
 
-sub DisplayProperty($$$)
+sub DisplayProperty($$)
 {
-  my ($self, $CollectionBlock, $PropertyDescriptor) = @_;
+  my ($self, $PropertyDescriptor) = @_;
 
   my $PropertyName = $PropertyDescriptor->GetName();
-
   return $PropertyName eq "Name" || $PropertyName eq "Type" ||
          $PropertyName eq "Role" || $PropertyName eq "Status" ||
          $PropertyName eq "Description";
 }
 
-sub SortKeys($$$)
+sub SortKeys($$)
 {
-  my ($self, $CollectionBlock, $Keys) = @_;
+  my ($self, $Keys) = @_;
 
   return $self->{Collection}->SortKeysBySortOrder($Keys);
 }
 
-sub OnItemAction($$$$)
+sub OnItemAction($$$)
 {
-  my ($self, $CollectionBlock, $VM, $Action) = @_;
+  my ($self, $VM, $Action) = @_;
 
   if ($Action eq "Delete")
   {
     $VM->Role("deleted");
-    # Setting $self->{ErrField} is only useful on form pages
-    (my $_ErrProperty, $self->{ErrMessage}) = $VM->Save();
-    return !defined $self->{ErrMessage};
+    my ($_ErrProperty, $ErrMessage) = $VM->Save();
+    if (defined $ErrMessage)
+    {
+      # Setting ErrField is only useful on form pages
+      $self->{EnclosingPage}->SetError(undef, $ErrMessage);
+      return 0;
+    }
+    return 1;
   }
 
-  return $self->SUPER::OnItemAction($CollectionBlock, $VM, $Action);
+  return $self->SUPER::OnItemAction($VM, $Action);
 }
 
 
 package main;
 
-my $Request = shift;
+use ObjectModel::CGI::SimpleCollectionPage;
+use WineTestBot::VMs;
 
-my $VMsListPage = VMsListPage->new($Request, "admin");
-$VMsListPage->GeneratePage();
+my $Request = shift;
+my $Page = ObjectModel::CGI::SimpleCollectionPage->new($Request, "admin", CreateVMs(), \&VMsBlock::Create);
+$Page->GeneratePage();




More information about the wine-cvs mailing list