[Rt-commit] rt branch 5.0/fix-lifecycle-new-status-remove created. rt-5.0.3-432-g274f3b817a
BPS Git Server
git at git.bestpractical.com
Tue May 2 15:34:33 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 274f3b817aa7768584470d8ad164f811b254ee4f (commit)
- Log -----------------------------------------------------------------
commit 274f3b817aa7768584470d8ad164f811b254ee4f
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 3133da6651..d523b3ad37 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -994,8 +994,12 @@ 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 49c0bb029cc9df0a76fe9e1dd0475385592d9e7e
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 an extra information 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 713584b9a1..0e95555a70 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 90d425778b7739c2c4afde0a0d4868f75b31a5dc
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