[Rt-commit] rt branch, 4.0/markasseen-in-selfservice, created. rt-4.0.17-87-gdc1ea73
Todd Wade
todd at bestpractical.com
Thu Sep 26 11:52:26 EDT 2013
The branch, 4.0/markasseen-in-selfservice has been created
at dc1ea730d5c365ca80524213953eb131fc209039 (commit)
- Log -----------------------------------------------------------------
commit 36a824fd54afc3e2de3f7eaf55ee40f90fb0f0ba
Author: Todd Wade <todd at bestpractical.com>
Date: Thu Sep 26 11:49:14 2013 -0400
Update self service ticket display to use MaybeRedirectForResults
like /Ticket/Display.html does.
diff --git a/share/html/SelfService/Display.html b/share/html/SelfService/Display.html
index 857ebfa..b95edfa 100644
--- a/share/html/SelfService/Display.html
+++ b/share/html/SelfService/Display.html
@@ -177,15 +177,13 @@ if ( defined ($id[0]) && $id[0] eq 'new' ) {
$m->abort();
}
- if (@results) {
- # We've done something, so we need to clear the decks to avoid
- # resubmission on refresh.
- # But we need to store Actions somewhere too, so we don't lose them.
- my $key = Digest::MD5::md5_hex(rand(1024));
- push @{ $session{"Actions"}->{$key} ||= [] }, @results;
- $session{'i'}++;
- RT::Interface::Web::Redirect( RT->Config->Get('WebURL') ."SelfService/Display.html?id=". $Ticket->id."&results=".$key);
- }
+ # This code does automatic redirection if any updates happen.
+ MaybeRedirectForResults(
+ Actions => \@results,
+ Path => '/SelfService/Display.html',
+ Anchor => $ARGS{'Anchor'},
+ Arguments => { id => $Ticket->id },
+ );
my $Transactions = $Ticket->Transactions;
commit dc1ea730d5c365ca80524213953eb131fc209039
Author: Todd Wade <todd at bestpractical.com>
Date: Thu Sep 26 11:51:14 2013 -0400
Add MarkAsSeen functionality to Self Service
See [issues:26416]
diff --git a/share/html/SelfService/Display.html b/share/html/SelfService/Display.html
index b95edfa..b2fdb53 100644
--- a/share/html/SelfService/Display.html
+++ b/share/html/SelfService/Display.html
@@ -50,6 +50,7 @@
% $m->callback(CallbackName => 'BeforeActionList', %ARGS, Actions => \@results, ARGSRef => \%ARGS, Ticket => $Ticket );
<& /Elements/ListActions, actions => \@results &>
+<& /Ticket/Elements/ShowUpdateStatus, Ticket => $Ticket &>
<table width="100%" class="ticketsummary" >
<tr>
@@ -177,6 +178,14 @@ if ( defined ($id[0]) && $id[0] eq 'new' ) {
$m->abort();
}
+ if ( $ARGS{'MarkAsSeen'} ) {
+ $Ticket->SetAttribute(
+ Name => 'User-'. $Ticket->CurrentUser->id .'-SeenUpTo',
+ Content => $Ticket->LastUpdated,
+ );
+ push @results, loc('Marked all messages as seen');
+ }
+
# This code does automatic redirection if any updates happen.
MaybeRedirectForResults(
Actions => \@results,
diff --git a/share/html/Ticket/Elements/ShowUpdateStatus b/share/html/Ticket/Elements/ShowUpdateStatus
index e9f5341..0e47224 100644
--- a/share/html/Ticket/Elements/ShowUpdateStatus
+++ b/share/html/Ticket/Elements/ShowUpdateStatus
@@ -49,8 +49,8 @@
<&| /Widgets/TitleBox, title => loc('New messages'), title_href => "#txn-". $txn->id &>
<&|/l&>There are unread messages on this ticket.</&>
<&|/l,
- RT->Config->Get('WebPath') ."/Ticket/Display.html?id=". $Ticket->id. "#txn-".$txn->id,
- RT->Config->Get('WebPath') ."/Ticket/Display.html?id=". $Ticket->id ."&MarkAsSeen=1&Anchor=txn-" . $txn->id
+ RT->Config->Get('WebPath') ."/$DisplayPath/Display.html?id=". $Ticket->id. "#txn-".$txn->id,
+ RT->Config->Get('WebPath') ."/$DisplayPath/Display.html?id=". $Ticket->id ."&MarkAsSeen=1&Anchor=txn-" . $txn->id
&>You can <a href="[_1]">jump to the first unread message</a> or <a href="[_2]">jump to the first unread message and mark all messages as seen</a>.</&>
</&>
</div>
@@ -60,4 +60,6 @@ $Ticket
<%INIT>
return unless (RT->Config->Get( 'ShowUnreadMessageNotifications', $session{'CurrentUser'}));
my $txn = $Ticket->SeenUpTo or return;
+
+my $DisplayPath = $session{'CurrentUser'}->Privileged ? 'Ticket' : 'SelfService';
</%INIT>
diff --git a/t/web/self_service.t b/t/web/self_service.t
index 49d9e37..adc90d7 100644
--- a/t/web/self_service.t
+++ b/t/web/self_service.t
@@ -1,13 +1,37 @@
use strict;
use warnings;
-use RT::Test tests => 9;
+
+use RT::Test
+ tests => 17,
+ config => 'Set( $ShowUnreadMessageNotifications, 1 );'
+;
my ($url, $m) = RT::Test->started_ok;
-my ($ticket) =
- RT::Test->create_ticket( Queue => 'General', Subject => 'test subject' );
+my $user_a = RT::Test->load_or_create_user(
+ Name => 'user_a',
+ Password => 'password',
+ EmailAddress => 'user_a at example.com',
+ Privileged => 0,
+);
+ok( $user_a && $user_a->id, 'loaded or created user' );
+ok( ! $user_a->Privileged, 'user is not privileged' );
+
+# Load Cc group
+my $Cc = RT::Group->new( RT->SystemUser );
+my($ok, $msg) = $Cc->LoadSystemRoleGroup( 'Cc' );
+ok($ok, $msg);
+RT::Test->add_rights( { Principal => $Cc, Right => ['ShowTicket'] } );
+
+my ($ticket) = RT::Test->create_ticket(
+ Queue => 'General',
+ Subject => 'test subject',
+ Cc => 'user_a at example.com',
+);
+
+my @results = $ticket->Correspond( Content => 'sample correspondence' );
-$m->login();
+ok( $m->login('user_a' => 'password'), 'unprivileged user logged in' );
$m->get_ok( '/SelfService/Display.html?id=' . $ticket->id,
'got selfservice display page' );
@@ -16,4 +40,16 @@ my $title = '#' . $ticket->id . ': test subject';
$m->title_is( $title );
$m->content_contains( "<h1>$title</h1>", "contains <h1>$title</h1>" );
+# $ShowUnreadMessageNotifications tests:
+$m->content_contains( "There are unread messages on this ticket." );
+
+# mark the message as read
+$m->follow_link_ok(
+ { text => 'jump to the first unread message and mark all messages as seen' },
+ 'followed mark as seen link'
+);
+
+$m->content_contains( "<h1>$title</h1>", "contains <h1>$title</h1>" );
+$m->content_lacks( "There are unread messages on this ticket." );
+
# TODO need more SelfService tests
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list