Module: tools
Branch: master
Commit: f919e7d33b48f261840fc1a637cb084970700a26
URL: https://source.winehq.org/git/tools.git/?a=commit;h=f919e7d33b48f261840fc1a…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Mon Apr 25 20:50:41 2022 +0200
testbot/web: Show the job submission date as a tooltip on the main page.
Only the jobs of the past few days are shown so the date is not very
useful. Delegating it to a tooltip avoids much line-wrapping in the
Submitted column, allowing more lines to fit on-screen.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/web/index.pl | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/testbot/web/index.pl b/testbot/web/index.pl
index 331ee85..4048cac 100644
--- a/testbot/web/index.pl
+++ b/testbot/web/index.pl
@@ -46,7 +46,8 @@ sub DisplayProperty($$)
return !1;
}
- return $self->SUPER::DisplayProperty($PropertyDescriptor);
+ return $PropertyName eq "Submitted" ? ("ro", "timetipdate") :
+ $self->SUPER::DisplayProperty($PropertyDescriptor);
}
sub GenerateHeaderView($$$)
@@ -58,6 +59,10 @@ sub GenerateHeaderView($$$)
{
print "<a class='title' title='Higher values indicate a lower priority'>Nice</a>";
}
+ elsif ($PropertyName eq "Submitted")
+ {
+ print "<a class='title' title='Date'>Submitted</a>";
+ }
elsif ($PropertyName eq "Ended")
{
print "<a class='title' title='Ended'>Time</a>";
Module: tools
Branch: master
Commit: 4df626aaeba5c9063b7826ebc56d6783e68f0bce
URL: https://source.winehq.org/git/tools.git/?a=commit;h=4df626aaeba5c9063b7826e…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Mon Apr 25 20:50:29 2022 +0200
testbot/cgi: Let DisplayProperty() specify how to format the property.
This applies to CollectionBlocks as well as FormPages.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/lib/ObjectModel/CGI/CollectionBlock.pm | 24 ++++++++++++----
testbot/lib/ObjectModel/CGI/FormPage.pm | 39 +++++++++++++++-----------
2 files changed, 42 insertions(+), 21 deletions(-)
diff --git a/testbot/lib/ObjectModel/CGI/CollectionBlock.pm b/testbot/lib/ObjectModel/CGI/CollectionBlock.pm
index 14e3cfe..b2ebb2e 100644
--- a/testbot/lib/ObjectModel/CGI/CollectionBlock.pm
+++ b/testbot/lib/ObjectModel/CGI/CollectionBlock.pm
@@ -166,10 +166,15 @@ sub GenerateErrorPopup($)
=item C<DisplayProperty()>
-Specifies whether to hide the given property.
+Specifies whether to hide the given property and how to format it.
-Any value evaluating to false specifies that the property should be hidden and
-all others that it should be shown.
+Returns a (display, format) array where the format value is optional.
+If the display value is false the property is hidden. Otherwise it should be
+"ro" to get a read-only view.
+
+The format value is passed to GenerateDataView() which can use it to decide
+how to format the property. By default it is simply passed to
+ValueFormatter::GenerateValueHTML().
=back
=cut
@@ -299,6 +304,14 @@ The object for the current row.
Furthermore one can get the link to the current object's details page by
passing the row to GetDetailsLink().
+The Col parameter has the following extra field:
+=over 12
+=item Format
+The format to be used to display the property.
+If undefined the default formatting is used.
+
+=back
+
=back
=cut
@@ -308,7 +321,7 @@ sub GenerateDataView($$$)
my $PropertyName = $Col->{Descriptor}->GetName();
my $Value = $Row->{Item}->$PropertyName;
- GenerateValueHTML($self, $Col->{Descriptor}, $Value);
+ GenerateValueHTML($self, $Col->{Descriptor}, $Value, $Col->{Format});
}
@@ -419,10 +432,11 @@ sub GenerateList($)
my (@Cols, $HasDT);
foreach my $PropertyDescriptor (@$PropertyDescriptors)
{
- my $Display = $self->DisplayProperty($PropertyDescriptor);
+ my ($Display, $Format) = $self->DisplayProperty($PropertyDescriptor);
next if (!$Display);
push @Cols, {Descriptor => $PropertyDescriptor,
Display => $Display,
+ Format => $Format,
Index => $ColIndex++};
$HasDT ||= ($PropertyDescriptor->GetClass() eq "Basic" and
$PropertyDescriptor->GetType() eq "DT");
diff --git a/testbot/lib/ObjectModel/CGI/FormPage.pm b/testbot/lib/ObjectModel/CGI/FormPage.pm
index 7fd2f56..e286880 100644
--- a/testbot/lib/ObjectModel/CGI/FormPage.pm
+++ b/testbot/lib/ObjectModel/CGI/FormPage.pm
@@ -156,16 +156,18 @@ sub GetPropertyDescriptorByName($$)
=item C<DisplayProperty()>
-Specifies whether to hide, display or allow editing the given property.
+Specifies whether to hide, display or allow editing the given property, and
+optionally how to format it.
-Return values:
+Returns a (display, format) array where the display value is one of the
+following:
=over
=item ""
Any value evaluating to false specifies that the property should be hidden.
=item "ro"
Specifies that the property is read-only, i.e. GenerateField() should display
-it instead of generating an edit field.
+it using the default format instead of generating an edit field.
=item "rw"
Specifies that GenerateField() should allow editing the property.
@@ -174,6 +176,11 @@ HTTP parameter name.
=back
+The optional format value is passed to GenerateValueInput() and
+GenerateValueView() which can use it to decide how to present the value.
+In the default implementation the format is only used for read-only properties
+and is passed to ValueFormatter::GenerateValueHTML().
+
=back
=cut
@@ -278,11 +285,11 @@ Generates an HTML snippet representing the value in a user-readable form.
=back
=cut
-sub GenerateValueView($$$)
+sub GenerateValueView($$$$)
{
- my ($self, $PropertyDescriptor, $Value) = @_;
+ my ($self, $PropertyDescriptor, $Value, $Format) = @_;
- GenerateValueHTML($self, $PropertyDescriptor, $Value);
+ GenerateValueHTML($self, $PropertyDescriptor, $Value, $Format);
}
sub GetInputType($$)
@@ -329,9 +336,9 @@ Generates an HTML snippet allowing the specified value to be edited.
=back
=cut
-sub GenerateValueInput($$$)
+sub GenerateValueInput($$$$)
{
- my ($self, $PropertyDescriptor, $Value) = @_;
+ my ($self, $PropertyDescriptor, $Value, $_Format) = @_;
my $InputType = $self->GetInputType($PropertyDescriptor);
if ($InputType eq "checkbox")
@@ -419,9 +426,9 @@ sub GenerateFormStart($)
"' method='$self->{Method}' enctype='multipart/form-data'>\n";
}
-sub GenerateField($$$)
+sub GenerateField($$$$)
{
- my ($self, $PropertyDescriptor, $Display) = @_;
+ my ($self, $PropertyDescriptor, $Display, $Format) = @_;
print "<div class='ItemProperty'><label>",
$self->escapeHTML($self->GetDisplayName($PropertyDescriptor)),
@@ -431,12 +438,12 @@ sub GenerateField($$$)
if ($Display eq "rw")
{
print "<div class='ItemValue'>";
- $self->GenerateValueInput($PropertyDescriptor, $Value);
+ $self->GenerateValueInput($PropertyDescriptor, $Value, $Format);
print "</div>";
}
else
{
- $self->GenerateValueView($PropertyDescriptor, $Value);
+ $self->GenerateValueView($PropertyDescriptor, $Value, $Format);
}
print "</div>\n";
@@ -448,8 +455,8 @@ sub GenerateFields($)
foreach my $PropertyDescriptor (@{$self->GetPropertyDescriptors()})
{
- my $Display = $self->DisplayProperty($PropertyDescriptor);
- $self->GenerateField($PropertyDescriptor, $Display) if ($Display);
+ my ($Display, $Format) = $self->DisplayProperty($PropertyDescriptor);
+ $self->GenerateField($PropertyDescriptor, $Display, $Format) if ($Display);
}
}
@@ -498,7 +505,7 @@ sub GenerateBody($)
if (defined $self->{ErrField})
{
my $PropertyDescriptor = $self->GetPropertyDescriptorByName($self->{ErrField});
- if ($PropertyDescriptor and !$self->DisplayProperty($PropertyDescriptor))
+ if ($PropertyDescriptor and !($self->DisplayProperty($PropertyDescriptor))[0])
{
$self->{ErrMessage} = "Internal error?\n$self->{ErrMessage}";
}
@@ -599,7 +606,7 @@ sub Save($)
{
if ($PropertyDescriptor->GetClass() eq "Basic" &&
$PropertyDescriptor->GetType() eq "B" &&
- $self->DisplayProperty($PropertyDescriptor) eq "rw" &&
+ ($self->DisplayProperty($PropertyDescriptor))[0] eq "rw" &&
! defined($self->GetParam($PropertyDescriptor->GetName())))
{
if (! $self->SaveProperty($PropertyDescriptor, ""))
Module: tools
Branch: master
Commit: 46ecbb6325b91c03be6d3a376d86c67e71f9d348
URL: https://source.winehq.org/git/tools.git/?a=commit;h=46ecbb6325b91c03be6d3a3…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Mon Apr 25 20:50:21 2022 +0200
testbot/cgi: Add a format parameter to GenerateHTMLValue().
This mostly allows specifying how it should format timestamps, though it
could also be used to force intepreting an integer property as a
boolean, etc.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/lib/ObjectModel/CGI/ValueFormatter.pm | 31 ++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/testbot/lib/ObjectModel/CGI/ValueFormatter.pm b/testbot/lib/ObjectModel/CGI/ValueFormatter.pm
index 62c1499..638504d 100644
--- a/testbot/lib/ObjectModel/CGI/ValueFormatter.pm
+++ b/testbot/lib/ObjectModel/CGI/ValueFormatter.pm
@@ -163,27 +163,48 @@ Generates an HTML snippet representing the value in a user-readable form.
The Parent parameter must point to a class that implements the escapeHTML()
method.
+The format parameter can be used to specify how to display the specified
+value and should have one of the basic property descriptor types with a couple
+of extensions for timestamps:
+
+=over
+
+=item "DT"
+Show the date and time mostly in ISO 8601 format. This is the default format
+for timestamp properties.
+
+=item "timetipdate"
+Same as above but put the date part in a tooltip.
+
+=back
+
=back
=cut
-sub GenerateValueHTML($$$);
+sub GenerateValueHTML($$$;$);
-sub GenerateValueHTML($$$)
+sub GenerateValueHTML($$$;$)
{
- my ($Parent, $PropertyDescriptor, $Value) = @_;
+ my ($Parent, $PropertyDescriptor, $Value, $Format) = @_;
if ($PropertyDescriptor->GetClass() eq "Basic")
{
- if ($PropertyDescriptor->GetType() eq "B")
+ $Format ||= $PropertyDescriptor->GetType();
+ if ($Format eq "B")
{
print $Value ? "Yes" : "No";
return;
}
- if ($PropertyDescriptor->GetType() eq "DT")
+ if ($Format eq "DT")
{
GenerateDateTime($Value);
return;
}
+ if ($Format eq "timetipdate")
+ {
+ GenerateTimeTipDate($Value);
+ return;
+ }
}
elsif ($PropertyDescriptor->GetClass() eq "Itemref" and defined $Value)
{