Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N°3366 - Multiple target state on approbal-extended #7

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

accognet
Copy link

@accognet accognet commented Jun 24, 2024

need change in approval base (branche feature/3366-Add_status_informations_on_approval )

Allows you to configure which classes are affected by the approval and from which statuses. Multiple starting statuses are allowed for a class.

new configuration for this module:

_'combodo-approval-extended' => array (
	'targets' => array (
	  'UserRequest' => 
	  array (
	    'target_states' => ['new','assigned'],
	    'bypass_profiles' => 'Service Manager',
	    'reuse_previous_answers' => true,
	  ),
	)
),_

You can configure different triggers to send different messages for approval:
image

Different approval stages are visible on the object in the Approval tab with the starting and ending status (thanks to the functionality implemented in the approval-base)
image

@accognet accognet self-assigned this Jun 24, 2024
@accognet accognet added the enhancement New feature or request label Jun 24, 2024
@Hipska
Copy link

Hipska commented Jun 25, 2024

Sounds interesting, does that mean it could be used to have a ruleset for NormalChange objects to go from new to validated/rejected and also from planned to approved/notapproved?

In your example I see it went from assigned towards escalated_ttr. Is there a way to specify what the target state should be?

@accognet
Copy link
Author

Yes, this is the target.
The target status is defined in XML as the current approval with 2 transitions: ev_approve and ev_reject

@Hipska
Copy link

Hipska commented Jun 25, 2024

Okay, so the transitions from starting state towards ending state should be named exactly ev_approve and ev_reject?

datamodel.combodo-approval-extended.xml Outdated Show resolved Hide resolved
datamodel.combodo-approval-extended.xml Outdated Show resolved Hide resolved
datamodel.combodo-approval-extended.xml Outdated Show resolved Hide resolved
datamodel.combodo-approval-extended.xml Outdated Show resolved Hide resolved
datamodel.combodo-approval-extended.xml Outdated Show resolved Hide resolved
@accognet
Copy link
Author

There are a lot of logs, because the code is not finished yet. I still have to do a lot of tests to validate this code. To not forget what I did I have already created the PR. I will have time in August to finish it.

@Hipska
Copy link

Hipska commented Jul 12, 2024

Sure, I gave suggestions to apply correct line indentations and log debug messages as actual debug, not error ;)

@Molkobain
Copy link
Contributor

Support PRs review:

  • Don't forget to add the conf migration during setup, see combodo-autoclose-tickets for an equivalent example
  • Change target_state to target_states
  • Change target_states format from a CSV list to an array (will work out of the box when config edition wil be through GUI)
  • Mind to add the target_states default value in HideButtonsPlugin::OnDisplayProperties()

Good :

  • Store start/end states instead of computing them on the fly, that way what has been done won't change even in case of conf / lifecycle changes
  • New conf format

Sounds nice! Will take a closer look.

datamodel.combodo-approval-extended.xml Outdated Show resolved Hide resolved
datamodel.combodo-approval-extended.xml Outdated Show resolved Hide resolved
Copy link

@Hipska Hipska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentations sometimes still not correct. (Is your IDE correctly configured?)

Also, what with users that already have customised their config? Shouldn't there be a migration method during iTop Setup? Currently the old config is ignored and reverted to default.

datamodel.combodo-approval-extended.xml Outdated Show resolved Hide resolved
main.combodo-approval-extended.php Show resolved Hide resolved
main.combodo-approval-extended.php Outdated Show resolved Hide resolved
@Molkobain
Copy link
Contributor

Also, what with users that already have customised their config? Shouldn't there be a migration method during iTop Setup? Currently the old config is ignored and reverted to default.

Totally, the config migration was asked during the support PRs review:

  • Don't forget to add the conf migration during setup, see combodo-autoclose-tickets for an equivalent example

Copy link

@Hipska Hipska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The installer looks good 👍

module.combodo-approval-extended.php Outdated Show resolved Hide resolved
module.combodo-approval-extended.php Show resolved Hide resolved
main.combodo-approval-extended.php Outdated Show resolved Hide resolved
main.combodo-approval-extended.php Show resolved Hide resolved
datamodel.combodo-approval-extended.xml Outdated Show resolved Hide resolved
Copy link

@Hipska Hipska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the code looks much more readable now. Some minor remarks:

Comment on lines +93 to +102
// Replacing old conf parameters value to indicate that it is obsolete
$aParamsToRemove = array('target_states', 'bypass_profiles', 'reuse_previous_answers');
foreach($aParamsToRemove as $sParamToRemove)
{
$sParamCurrentValue = $oConfiguration->GetModuleSetting('combodo-approval-extended', $sParamToRemove, null);
if(!empty($sParamCurrentValue))
{
$oConfiguration->SetModuleSetting('combodo-approval-extended', $sParamToRemove, 'No longer used, you can remove this parameter.');
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this section, since you said this: https://github.com/Combodo/combodo-approval-extended/pull/7/files#r1763440755

Comment on lines +84 to +90
$newConfiguration = [
'UserRequest' => [
'target_states' => [$oConfiguration->GetModuleSetting('combodo-approval-extended', 'target_states', null) ],
'bypass_profiles' =>$oConfiguration->GetModuleSetting('combodo-approval-extended', 'bypass_profiles', 'Service Manager') ,
'reuse_previous_answers' => $oConfiguration->GetModuleSetting('combodo-approval-extended', 'reuse_previous_answers', true) ,
]
];
Copy link

@Hipska Hipska Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still some indentation problem, a typo and to keep backward compatibility, the admin profile should also be included when migrating.

Suggested change
$newConfiguration = [
'UserRequest' => [
'target_states' => [$oConfiguration->GetModuleSetting('combodo-approval-extended', 'target_states', null) ],
'bypass_profiles' =>$oConfiguration->GetModuleSetting('combodo-approval-extended', 'bypass_profiles', 'Service Manager') ,
'reuse_previous_answers' => $oConfiguration->GetModuleSetting('combodo-approval-extended', 'reuse_previous_answers', true) ,
]
];
$newConfiguration = [
'UserRequest' => [
'target_states' => [$oConfiguration->GetModuleSetting('combodo-approval-extended', 'target_state', 'new')],
'bypass_profiles' => $oConfiguration->GetModuleSetting('combodo-approval-extended', 'bypass_profiles', 'Administrator, Service Manager'),
'reuse_previous_answers' => $oConfiguration->GetModuleSetting('combodo-approval-extended', 'reuse_previous_answers', true),
]
];

Comment on lines +389 to +390
$aAllowedClasses = MetaModel::GetConfig()->GetModuleSetting('combodo-approval-extended', 'targets', ApprovalConfiguration::DEFAULT_TARGET);
if (array_key_exists(get_class($oObject), $aAllowedClasses) === false) {
Copy link

@Hipska Hipska Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make more sense later in the code when this var is named differently..

Suggested change
$aAllowedClasses = MetaModel::GetConfig()->GetModuleSetting('combodo-approval-extended', 'targets', ApprovalConfiguration::DEFAULT_TARGET);
if (array_key_exists(get_class($oObject), $aAllowedClasses) === false) {
$aTargets = MetaModel::GetConfig()->GetModuleSetting('combodo-approval-extended', 'targets', ApprovalConfiguration::DEFAULT_TARGET);
if (array_key_exists(get_class($oObject), $aTargets) === false) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants