[tools] testbot/cgi: Improve the Add button label for multi-word item class names.

Francois Gouget fgouget at codeweavers.com
Wed Apr 6 17:31:18 CDT 2022


Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/lib/ObjectModel/CGI/CollectionBlock.pm | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/testbot/lib/ObjectModel/CGI/CollectionBlock.pm b/testbot/lib/ObjectModel/CGI/CollectionBlock.pm
index 13c2a62bd..736c3f8a3 100644
--- a/testbot/lib/ObjectModel/CGI/CollectionBlock.pm
+++ b/testbot/lib/ObjectModel/CGI/CollectionBlock.pm
@@ -570,6 +570,15 @@ sub OnItemAction($$$)
 # Actions handling
 #
 
+sub GetAddButtonLabel($)
+{
+  my ($self) = @_;
+
+  my $Label = $self->{Collection}->GetItemName();
+  $Label =~ s/([a-z])([A-Z])/$1 $2/g;
+  return "Add $Label";
+}
+
 =pod
 =over 12
 
@@ -587,9 +596,7 @@ sub GetActions($)
 {
   my ($self) = @_;
 
-  return $self->GetDetailsPage() ?
-         ["Add ". $self->{Collection}->GetItemName()] :
-         [];
+  return $self->GetDetailsPage() ? [$self->GetAddButtonLabel()] : [];
 }
 
 =pod
@@ -614,7 +621,7 @@ sub OnAction($$)
 {
   my ($self, $Action) = @_;
 
-  if ($self->{RW} and $Action eq "Add ". $self->{Collection}->GetItemName())
+  if ($self->{RW} and $Action eq $self->GetAddButtonLabel())
   {
     my $Target = $self->GetDetailsPage();
     my ($MasterColNames, $MasterColValues) = $self->{Collection}->GetMasterCols();
-- 
2.30.2




More information about the wine-devel mailing list