QuickResolveandQuickReject

From Request Tracker Wiki
Revision as of 16:20, 6 April 2016 by Admin (talk | contribs) (7 revisions imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

RT3.x

Adding this feature to your RT installation, you will able to reject or resolve tickets in just one click, avoiding the Edit page.

Installing:

Create the following folder:

mkdir -p /path/to/your/rt/local/html/Callbacks/QuickClose/Ticket/Elements/Tabs/

Inside this folder, you must create a file called "Default", and add the following content to it:

<%ARGS>
$Ticket => undef
$actions => {}
</%ARGS>
<%INIT>
if ( $Ticket ) {
        my %can = map { $_, $Ticket->CurrentUserHasRight($_) }
                qw(ModifyTicket ReplyToTicket OwnTicket CommentOnTicket);

        my $id = $Ticket->Id();

        if ( $can{'ModifyTicket'} ) {
                if ( $Ticket->Status ne 'resolved' ) {
                        $actions->{'Acc'} = {
                                path  => "Ticket/Display.html?Status=resolved&id=$id",
                                title => loc('Quick Resolve'),
                        };
                }
        }

        if ( $can{'ModifyTicket'} || $can{'OwnTicket'} ) {
                if ( $Ticket->Status ne 'resolved' ) {
                        $actions->{'Bb'} = {
                                path  => "Ticket/Display.html?Status=rejected&TakeOrStealFirst=1&id=$id",
                                title => loc('Quick Reject'),
                        };
                }
        }
}

</%INIT>

Now restart your server and it'll be working :-))) :Restarting the server should be unnecessary if the URI in question has never been loaded since it will not be in Mason's cache.

RT4.x

As of RT4, enhancements like this are much simpler to implement as they are configured entirely within RT_SiteConfig.pm via the '%Lifecycles' hash.

Read the "Lifecycles" section of the perldoc for RT::Config for all of the details.

If you've installed from source:

perldoc /opt/rt4/etc/RT_Config.pm

If you're using the Debian package:

perldoc /usr/share/request-tracker4/etc/RT_Config.pm

Synopsis

Step 1:

Copy the default '%Lifecycles' hash from RT_Config.pm into your RT_SiteConfig.pm. Within the "default" section look for the subsection labeled "actions", it should look like this:

        actions => [
            'new -> open'      => { label => 'Open It',  update => 'Respond' },
            'new -> resolved'  => { label => 'Resolve',  update => 'Comment' },
            'new -> rejected'  => { label => 'Reject',   update => 'Respond' },
            'new -> deleted'   => { label => 'Delete'                        },

            'open -> stalled'  => { label => 'Stall',    update => 'Comment' },
            'open -> resolved' => { label => 'Resolve',  update => 'Comment' },
            'open -> rejected' => { label => 'Reject',   update => 'Respond' },

            'stalled -> open'  => { label => 'Open It'                       },
            'resolved -> open' => { label => 'Re-open',  update => 'Comment' },
            'rejected -> open' => { label => 'Re-open',  update => 'Comment' },
            'deleted -> open'  => { label => 'Undelete'                      },
        ],

Step2:

Add new actions as desired. In this case we want to add "Quick Resolve" and "Quick Reject", so we end up with something that looks like this:

          actions => [
            'new -> open'      => { label => 'Open It',  update => 'Respond' },
            'new -> resolved'  => { label => 'Resolve',  update => 'Comment' },
            'new -> resolved'  => { label => 'Quick Resolve'                 },
            'new -> rejected'  => { label => 'Reject',   update => 'Respond' },
            'new -> rejected'  => { label => 'Quick Reject',                       },
            'new -> deleted'   => { label => 'Delete'                        },

            'open -> stalled'  => { label => 'Stall',    update => 'Comment' },
            'open -> resolved' => { label => 'Resolve',  update => 'Comment' },
            'open -> resolved' => { label => 'Quick Resolve'                 },
            'open -> rejected' => { label => 'Reject',   update => 'Respond' },
            'open -> rejected' => { label => 'Quick Reject',                       },

            'stalled -> open'  => { label => 'Open It'                       },
            'resolved -> open' => { label => 'Re-open',  update => 'Comment' },
            'rejected -> open' => { label => 'Re-open',  update => 'Comment' },
            'deleted -> open'  => { label => 'Undelete'                      },
        ],

Notice that we are simply copying the existing lines for the "Resolve" and "Reject" actions, giving them a distinct label ("Quick Resolve" and "Quick Reject") and removing the "update" element.

Step 3:

Restart Apache when your RT_SiteConfig.pm edits are complete. You should see your new items in the Action menu when viewing a ticket.

Bookmarklet

You can access to similar one-click functionality without editing server-side via the use of simple bookmarklets like:

javascript:self.location=self.location+'&Status=resolved'

Note that the statuses appear to be case-sensitive, and that if you had to log-in to view the ticket, you will need to use your browsers back-button because RT uses session data rather than a redirect to a full urI with query to display the requested ticket... therefore the self.location will lack the ticket ID.