[Rt-commit] rt branch, 4.6/lifecycle-ui-cleanup, created. rt-4.4.1-265-g2d03d605b

Craig Kaiser craig at bestpractical.com
Thu Oct 10 08:28:11 EDT 2019


The branch, 4.6/lifecycle-ui-cleanup has been created
        at  2d03d605bc3a2c201e4940e7b560a64829a074c1 (commit)

- Log -----------------------------------------------------------------
commit e04fde3376de1cec418d26dda6057df25cff9069
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Fri Sep 27 09:34:09 2019 -0400

    Signal lifecycle cache needs update using system LifecycleCacheNeedsUpdate method
    
    Lifecycle can now be edited in the web UI, meaning that all RT threads need to
    know when the cache is in need of update.

diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index 784b38453..073b7526a 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -57,6 +57,8 @@ our %LIFECYCLES;
 our %LIFECYCLES_CACHE;
 our %LIFECYCLES_TYPES;
 
+my $lifecycle_cache_time = 0;
+
 # cache structure:
 #    {
 #        lifecycle_x => {
@@ -109,7 +111,7 @@ sub new {
     my $proto = shift;
     my $self = bless {}, ref($proto) || $proto;
 
-    $self->FillCache unless keys %LIFECYCLES_CACHE;
+    RT->System->LifecycleCacheNeedsUpdate(1);
 
     return $self;
 }
@@ -144,13 +146,19 @@ sub Load {
         @_,
     );
 
+    my $needs_update = RT->System->LifecycleCacheNeedsUpdate;
+    if ($needs_update > $lifecycle_cache_time) {
+        $self->FillCache();
+        $lifecycle_cache_time = $needs_update;
+    }
+
     if (defined $args{Name} and exists $LIFECYCLES_CACHE{ $args{Name} }) {
         $self->{'name'} = $args{Name};
         $self->{'data'} = $LIFECYCLES_CACHE{ $args{Name} };
         $self->{'type'} = $args{Type};
 
         my $found_type = $self->{'data'}{'type'};
-        warn "Found type of $found_type ne $args{Type}" if $found_type ne $args{Type};
+        warn "Found type of $found_type ne ".$args{'Type'} if $found_type ne $args{Type};
     } elsif (not $args{Name} and exists $LIFECYCLES_TYPES{ $args{Type} }) {
         $self->{'data'} = $LIFECYCLES_TYPES{ $args{Type} };
         $self->{'type'} = $args{Type};
@@ -198,8 +206,6 @@ sub ListAll {
     my $self = shift;
     my $for = shift || 'ticket';
 
-    $self->FillCache unless keys %LIFECYCLES_CACHE;
-
     return sort grep {$LIFECYCLES_CACHE{$_}{type} eq $for}
         grep $_ ne '__maps__', keys %LIFECYCLES_CACHE;
 }
@@ -468,8 +474,6 @@ sub RightsDescription {
     my $self = shift;
     my $type = shift;
 
-    $self->FillCache unless keys %LIFECYCLES_CACHE;
-
     my %tmp;
     foreach my $lifecycle ( values %LIFECYCLES_CACHE ) {
         next unless exists $lifecycle->{'rights'};
@@ -519,8 +523,6 @@ sub Actions {
     my $from = shift || return ();
     $from = lc $from;
 
-    $self->FillCache unless keys %LIFECYCLES_CACHE;
-
     my @res = grep lc $_->{'from'} eq $from || ( $_->{'from'} eq '*' && lc $_->{'to'} ne $from ),
         @{ $self->{'data'}{'actions'} };
 
@@ -595,7 +597,6 @@ that require translation.
 
 sub ForLocalization {
     my $self = shift;
-    $self->FillCache unless keys %LIFECYCLES_CACHE;
 
     my @res = ();
 
@@ -789,6 +790,8 @@ sub FillCache {
             and $class->can("RegisterRights");
     }
 
+    $lifecycle_cache_time = time;
+
     return;
 }
 
@@ -839,7 +842,7 @@ sub _SaveLifecycles {
         return ($ok, $msg) if !$ok;
     }
 
-    RT::Lifecycle->FillCache;
+    RT->System->LifecycleCacheNeedsUpdate(1);
 
     return 1;
 }
diff --git a/lib/RT/System.pm b/lib/RT/System.pm
index 08d79dde4..68a7f817d 100644
--- a/lib/RT/System.pm
+++ b/lib/RT/System.pm
@@ -256,6 +256,27 @@ sub ConfigCacheNeedsUpdate {
     }
 }
 
+=head2 LifecycleCacheNeedsUpdate ( 1 )
+
+Attribute to decide when we need to flush the list of lifecycles
+and re-register any changes. This is needed for the lifecycle UI editor.
+
+If passed a true value, will update the attribute to be the current time.
+
+=cut
+
+sub LifecycleCacheNeedsUpdate {
+    my $self   = shift;
+    my $update = shift;
+
+    if ($update) {
+        return $self->SetAttribute(Name => 'LifecycleCacheNeedsUpdate', Content => time);
+    } else {
+        my $cache = $self->FirstAttribute('LifecycleCacheNeedsUpdate');
+        return (defined $cache ? $cache->Content : 0 );
+    }
+}
+
 =head2 AddUpgradeHistory package, data
 
 Adds an entry to the upgrade history database. The package can be either C<RT>

commit 5d1f486e1a74b4084cad92e4f705edf7e0e1a223
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Fri Sep 27 09:44:40 2019 -0400

    Show 'select' and 'create' page menu options for lifecycle pages

diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
index e3baabedd..9556e3f1d 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -1156,6 +1156,13 @@ sub _BuildAdminMenu {
                 RT::Interface::Web::EscapeURI(\$Name_uri);
                 RT::Interface::Web::EscapeURI(\$Type_uri);
 
+                my $lifecycles = $page->child( lifecycles =>
+                    title => loc('Lifecycles'),
+                    path  => '/Admin/Lifecycles/',
+                );
+                $lifecycles->child( select => title => loc('Select'), path => '/Admin/Lifecycles/');
+                $lifecycles->child( create => title => loc('Create'), path => '/Admin/Lifecycles/Create.html');
+
                 $page->child( basics => title => loc('Modify'),  path => "/Admin/Lifecycles/Modify.html?Type=" . $Type_uri . "&Name=" . $Name_uri );
                 $page->child( mappings => title => loc('Mappings'),  path => "/Admin/Lifecycles/Mappings.html?Type=" . $Type_uri . "&Name=" . $Name_uri );
             }

commit 1b671fc786ec025331568337d781e14d6232abff
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Fri Sep 27 10:24:59 2019 -0400

    Make sure default value for lifecycle type is 'ticket'

diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index 073b7526a..bec9fb72d 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -145,6 +145,7 @@ sub Load {
         Name => '',
         @_,
     );
+    $args{'Type'} = $args{'Type'} // 'ticket';
 
     my $needs_update = RT->System->LifecycleCacheNeedsUpdate;
     if ($needs_update > $lifecycle_cache_time) {

commit 9f8cedda33ab54e77d5b14bf6ff856994d731a54
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Fri Sep 27 10:47:04 2019 -0400

    Add message when no lifecycle mappings available

diff --git a/share/html/Admin/Lifecycles/Mappings.html b/share/html/Admin/Lifecycles/Mappings.html
index 891936d79..c587293cd 100644
--- a/share/html/Admin/Lifecycles/Mappings.html
+++ b/share/html/Admin/Lifecycles/Mappings.html
@@ -83,6 +83,10 @@
     </&>
 % }
 
+% unless ( scalar @lifecycles ) {
+    <p><&|/l&>Mapping only available when more than one lifecycle exists</&></p>
+% }
+
 <& /Elements/Submit, Name => 'Update', Label => loc('Save Changes') &>
 
 </form>

commit 28653f03e99cc1c79af3d4ce3ab4c53bfdd0b340
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Fri Sep 27 11:55:34 2019 -0400

    Remove checkered background from lifecycle editor graph

diff --git a/share/static/css/base/lifecycleui-editor.css b/share/static/css/base/lifecycleui-editor.css
index 7e83c6852..bd168915d 100644
--- a/share/static/css/base/lifecycleui-editor.css
+++ b/share/static/css/base/lifecycleui-editor.css
@@ -4,12 +4,6 @@
     width: 809px;
     height: 500px;
 
-    /* checkerboard pattern */
-    background: #F9F9F9 url('data:image/svg+xml,\
-        <svg xmlns="http://www.w3.org/2000/svg" width="400" height="400"         fill-opacity=".05" >\
-            <rect x="200" width="200" height="200" />\
-            <rect y="200" width="200" height="200" />\
-    </svg>');
     background-size: 25px 25px;
 }
 

commit 2d03d605bc3a2c201e4940e7b560a64829a074c1
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Fri Sep 27 12:10:39 2019 -0400

    Center lifecycle editor

diff --git a/share/static/css/base/lifecycleui-editor.css b/share/static/css/base/lifecycleui-editor.css
index bd168915d..732a82043 100644
--- a/share/static/css/base/lifecycleui-editor.css
+++ b/share/static/css/base/lifecycleui-editor.css
@@ -1,19 +1,19 @@
+.lifecycle-ui {
+    margin-left: 10%;
+}
+
 .lifecycle-ui.editing svg {
-    display: inline-block;
     float: left;
-    width: 809px;
+    width: 60%;
     height: 500px;
-
-    background-size: 25px 25px;
 }
 
 .lifecycle-ui.editing .overlay-buttons {
-    left: 700px;
+    left: 50%;
 }
 
 .lifecycle-ui .inspector {
     display: inline-block;
-    width: 250px;
     min-height: 500px;
     border: 1px solid black;
 }

-----------------------------------------------------------------------


More information about the rt-commit mailing list