Skip to content

Commit

Permalink
Add history tab to rights pages
Browse files Browse the repository at this point in the history
  • Loading branch information
craigkai committed Nov 15, 2024
1 parent 1f924c3 commit fac48ce
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
45 changes: 45 additions & 0 deletions share/html/Admin/Elements/EditRightsCategoryTabs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,31 @@ $acldesc ||= join '-', ($Principal ? $Principal->PrincipalId : 'addprincipal'),
ref($Context), $Context->Id;

$available_rights{$_} = loc( $available_rights{$_} ) for keys %available_rights;

my $history;
if ($Principal) {
my $objectType = ref $Principal;
my $aclEquivID = $Principal->PrincipalId;

if ($objectType eq 'RT::User') {
$aclEquivID = my $equiv_group = RT::Group->new( $session{CurrentUser} );
$equiv_group->LoadACLEquivalenceGroup( $Principal->PrincipalId );
$aclEquivID = $equiv_group->Id;
}
my $transactions = RT::Transactions->new( $session{CurrentUser} );

$transactions->Limit( FIELD => 'type', VALUE => 'RevokeRight' );
$transactions->Limit( FIELD => 'type', VALUE => 'GrantRight' );
$transactions->Limit( FIELD => 'ObjectType', VALUE => $Context ? ref $Context : 'RT::System' );
$transactions->Limit( FIELD => 'field', VALUE => $aclEquivID );

my $order = RT->Config->Get('TransactionDefaultSearchResultOrderBy')->{'RT::ACE'} || "Created";
my $order_type = RT->Config->Get('TransactionDefaultSearchResultOrder')->{'RT::ACE'} || "DESC";

$transactions->OrderBy( FIELD => $order, ORDER => $order_type );
$history = $transactions;
}
my ($path) = $m->request_comp->path =~ /([^\/]+)$/;
</%init>

<div class="category-tabs">
Expand All @@ -112,6 +137,13 @@ $available_rights{$_} = loc( $available_rights{$_} ) for keys %available_rights;
</a>
</li>
% }

<li class="nav-item">
<a class="nav-link" href="#<% "$id-history" %>" id="<% "category-tab-$id-history" %>" data-toggle="tab" role="tab" aria-controls="<% "$id-history" %>" aria-selected="false">
History
</a>
</li>

</ul>
<div class="tab-content">
% for my $category (sort { $catsort{$a} <=> $catsort{$b} } keys %categories) {
Expand Down Expand Up @@ -139,7 +171,20 @@ $available_rights{$_} = loc( $available_rights{$_} ) for keys %available_rights;
% }
</ul>
</div>

<div id="<% "$id-history" %>" class="tab-pane fade" role="tabpanel" aria-labelledby="<% "category-tab-$id-history" %>">
% if ( $history ) {
<& /Elements/ShowHistory,
Object => $Principal,
Transactions => $history,
ShowDisplayModes => 0,
ShowTitle => 0,
DisplayPath => $path,
&>
% }
</div>
% }

</div>
</div>
<input type="hidden" name="CheckACL" value="<% $acldesc %>" />
4 changes: 3 additions & 1 deletion share/html/Elements/ShowTransaction
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,10 @@ my @classes = (
($RowNum % 2 ? 'odd' : 'even')
);

my $is_ace = $Transaction->Type =~ /RevokeRight|GrantRight/;
my $desc = $Transaction->BriefDescriptionAsHTML;
if ( $Object->id && $Object->id != $Transaction->ObjectId ) {
# We do not display this if it is an ACE transaction
if ( !$is_ace && $Object->id && $Object->id != $Transaction->ObjectId && undef ) {
# merged objects
$desc = join " - ",
$m->interp->apply_escapes(
Expand Down

0 comments on commit fac48ce

Please sign in to comment.