[Rt-commit] rt 09/10: Show dependencies and ask confirmation before deleting dashboards

sunnavy sunnavy at bestpractical.com
Fri Jul 9 16:45:33 EDT 2021


This is an automated email from the git hooks/post-receive script.

sunnavy pushed a commit to branch 5.0/use-dashboard-for-homepage-select-ui
in repository rt.

commit 98bcd789a04f72b8748fcdfc7c3646357eb9af38
Author: sunnavy <sunnavy at bestpractical.com>
AuthorDate: Sat Jul 10 01:29:39 2021 +0800

    Show dependencies and ask confirmation before deleting dashboards
    
    Here we just concern about DefaultDashboard settings. DashboardsInMenu
    is not considered as it automatically cleans up deleted dashboards.
---
 share/html/Dashboards/Modify.html | 83 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)

diff --git a/share/html/Dashboards/Modify.html b/share/html/Dashboards/Modify.html
index 5a1da61cbd..28e31e8ed5 100644
--- a/share/html/Dashboards/Modify.html
+++ b/share/html/Dashboards/Modify.html
@@ -76,6 +76,17 @@
       <& /Dashboards/Elements/SelectPrivacy, Name => "Privacy", Objects => \@privacies, Default => $Dashboard->Privacy &>
     </div>
   </div>
+
+% if ($Dashboard->Id && $can_delete && $Dashboard->{Attribute}->DependedOnBy->Count ) {
+  <div class="form-row">
+    <div class="label col-3"><&|/l&>Depended on by</&>:</div>
+    <div class="col-9">
+      <span class="form-control current-value">
+        <a href="#" data-toggle="modal" data-target="#dashboard-depended-on-by-list-modal"><% loc('View') %></a>
+      </span>
+    </div>
+  </div>
+% }
 </&>
 
   <div class="form-row">
@@ -87,9 +98,57 @@
 % if ($Dashboard->Id && $can_delete) {
   <div class="form-row">
     <div class="col-12">
+%   if ( $Dashboard->{Attribute}->DependedOnBy->Count ) {
+      <div class="text-right">
+        <input type="button" class="form-control btn btn-primary button" data-toggle="modal" data-target="#delete-dashboard-confirm-modal" value="<%loc('Delete')%>" />
+      </div>
+%   } else {
       <& /Elements/Submit, Name => 'Delete', Label => loc('Delete') &>
+%   }
+    </div>
+  </div>
+
+% if ($Dashboard->Id && $can_delete && $Dashboard->{Attribute}->DependedOnBy->Count ) {
+<div class="modal" id="delete-dashboard-confirm-modal">
+  <div class="modal-dialog modal-dialog-centered" role="document">
+    <div class="modal-content">
+      <div class="modal-header">
+        <h5 class="modal-title"><&|/l&>Really Delete?</&></h5>
+        <a href="javascript:void(0)" class="close" data-dismiss="modal" aria-label="Close">
+          <span aria-hidden="true">×</span>
+        </a>
+      </div>
+      <div class="modal-body">
+        <& SELF:GetDependedOnByList, Object => $Dashboard &>
+      </div>
+      <div class="modal-footer">
+        <div class="form-row justify-content-end">
+          <div class="col-auto">
+            <input type="submit" class="button btn btn-primary" name="Delete" value="<% loc('Delete') %>" />
+          </div>
+        </div>
+      </div>
+    </div>
+  </div>
+</div>
+
+<div class="modal" id="dashboard-depended-on-by-list-modal">
+  <div class="modal-dialog modal-dialog-centered" role="document">
+    <div class="modal-content">
+      <div class="modal-header">
+        <h5 class="modal-title"><&|/l&>Depended On By List</&></h5>
+        <a href="javascript:void(0)" class="close" data-dismiss="modal" aria-label="Close">
+          <span aria-hidden="true">×</span>
+        </a>
+      </div>
+      <div class="modal-body">
+        <& SELF:GetDependedOnByList, Object => $Dashboard &>
+      </div>
     </div>
   </div>
+</div>
+% }
+
 % }
 </form>
 <%INIT>
@@ -197,3 +256,27 @@ $id => '' unless defined $id
 $Delete => undef
 </%ARGS>
 
+<%METHOD GetDependedOnByList>
+
+  <p>
+    <&|/l&>This dashboard is used in homepage of these users</&>:
+  </p>
+  <ul class="dashboard-depended-on-by-list list-group-compact">
+% my $links = $Object->{Attribute}->DependedOnBy;
+% while ( my $link = $links->Next ) {
+    <li class="list-group-item">
+%   if ( $link->BaseObj->ObjectType eq 'RT::System' ) {
+      <% loc('Global') %>
+%   } elsif ( $link->BaseObj->ObjectType eq 'RT::User' ) {
+      <% loc('User') %>: <& /Elements/ShowUser, User => $link->BaseObj->Object, LinkTarget => '_blank' &>
+%   } else {
+       <% $link->BaseObj->ObjectType %>: #<% $link->BaseObj->ObjectId %>
+%   }
+    </li>
+% }
+  </ul>
+
+<%ARGS>
+$Object
+</%ARGS>
+</%METHOD>

-- 
To stop receiving notification emails like this one, please contact
sysadmin at bestpractical.com.


More information about the rt-commit mailing list