[Rt-commit] rt branch 5.0/fix-lifecycle-new-status-remove created. rt-5.0.4-54-gc2a5eafa68

BPS Git Server git at git.bestpractical.com
Thu Jul 6 19:48:23 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/fix-lifecycle-new-status-remove has been created
        at  c2a5eafa683d45a1f4bae9d35093e700104c1916 (commit)

- Log -----------------------------------------------------------------
commit c2a5eafa683d45a1f4bae9d35093e700104c1916
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Tue May 2 12:31:59 2023 -0300

    Add on_create Lifecycle specific validation
    
    Lifecycle validator was emitting a non-specific error message when
    no state was specified for on_create default config.

diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index 9f8701438e..1fa2867eec 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -994,8 +994,20 @@ sub ValidateLifecycle {
     # ->{actions} are handled below
     for my $state ( keys %{ $lifecycle->{defaults} || {} } ) {
         my $status = $lifecycle->{defaults}{$state};
-        push @warnings, $current_user->loc( "Nonexistant status [_1] in default states in [_2] lifecycle", lc $status, $name )
-            unless $lifecycle->{canonical_case}{ lc $status };
+        if ( $state eq "on_create" && !$status ) {
+            push @warnings,
+                $current_user->loc(
+                "[_1] lifecycle has no default creation state", $name );
+        } else {
+            push @warnings,
+                $current_user->loc(
+                "Nonexistant status [_1] in default states in [_2] lifecycle",
+                lc $status,
+                $name
+                )
+                unless $lifecycle->{canonical_case}{ lc $status };
+        }
+
     }
     for my $from ( keys %{ $lifecycle->{transitions} || {} } ) {
         push @warnings, $current_user->loc( "Nonexistant status [_1] in transitions in [_2] lifecycle", lc $from, $name )

commit ca5ba968e4148ef941e71fa93795cec88c43cc8e
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Tue May 2 12:31:48 2023 -0300

    Improve Lifecycle update error messages
    
    When updating a Lifecycle from the UI, if the update fails, the user
    was presented with a generic error message comming from Lifecycle
    Validator. This commit adds a new log in @results specific for the UI
    letting the user know that the Lifecycle was not updated.

diff --git a/share/html/Admin/Lifecycles/Modify.html b/share/html/Admin/Lifecycles/Modify.html
index 6aec341897..4479d187a6 100644
--- a/share/html/Admin/Lifecycles/Modify.html
+++ b/share/html/Admin/Lifecycles/Modify.html
@@ -129,6 +129,7 @@ if ( $Update ) {
     }
     else {
         push @results, @warnings;
+        push @results, loc('Lifecycle not updated');
     }
 }
 else {

commit 2e77441ab084fb236a16661248dc1e4ad4ee93e8
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Tue May 2 12:05:46 2023 -0300

    Fix lifecycle new status removal
    
    on_create default config was not being replaced correctly with a new
    status, which caused an error when saving the lifecycle.
    We are now falling back to the next available state on config.initial
    and to config.active after that.

diff --git a/share/static/js/lifecycleui-model.js b/share/static/js/lifecycleui-model.js
index 2a1dae32cf..ec1c21d2f7 100644
--- a/share/static/js/lifecycleui-model.js
+++ b/share/static/js/lifecycleui-model.js
@@ -112,8 +112,10 @@ class LifecycleModel {
         self.DeleteLinksForNode(self.nodes[index]);
 
         self.DeleteRights(d);
+        self.DeleteFromStateTypes(d);
         self.DeleteDefaults(d);
         self.DeleteActions(d);
+        self.DeleteFromCreateNodes(d);
 
         self.nodes.splice(index, 1);
     }
@@ -139,7 +141,14 @@ class LifecycleModel {
 
         jQuery.each(self.config.defaults, function (key, value) {
             if (value && value.toLowerCase() === d.name.toLowerCase()) {
-                delete self.config.defaults[key];
+                if (key === 'on_create') {
+                    // Check if we have a status after the one to be delete
+                    // to replace the on_create default
+                    self.config.defaults.on_create = self.config.initial[0]
+                        || self.config.active[0] || null;
+                } else {
+                    delete self.config.defaults[key];
+                }
             }
         });
     }
@@ -197,6 +206,26 @@ class LifecycleModel {
         });
     }
 
+    DeleteFromCreateNodes(d) {
+        var self = this;
+        var index = self.create_nodes.findIndex(function(x) { return x == d.name });
+        if ( index >= 0 ) {
+            self.create_nodes.splice(index, 1);
+        }
+    }
+
+    DeleteFromStateTypes(d) {
+        var self = this;
+        ['initial', 'active', 'inactive'].forEach(function(type) {
+            self.config[type].filter(function (status) {
+                return status.toLowerCase() === d.name.toLowerCase();
+            }).forEach(function (status) {
+                var index = self.config[type].indexOf(status);
+                self.config[type].splice(index, 1);
+            });
+        });
+    }
+
     UpdateNodeModel(node, args) {
         var self = this;
 

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list