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

Sector Nord AG: Added TransitionAction parameter placeholder #145

Conversation

jsinagowitz
Copy link
Contributor

@jsinagowitz jsinagowitz commented Sep 23, 2021

Proposed change

Additional feature that provides a placeholder for adding parameters to TransitionActions.
Provided by Sector Nord AG as discussed with Roy Kaldung (@rkaldung) and Henrik Vetter (@Tronsy).

Type of change

  • '1 - πŸš€ feature'

Additional information

The placeholders can be modified in the System Configuration. The required parameters are marked with the tag (* required).

Checklist

  • The code change is tested and works locally.(❗)
  • There is no commented out code in this PR.(❕)
  • You improved or added new unit tests.(❕)
  • Local ZnunyCodePolicy run passes successfully.(❕)
  • Local unit tests pass.(❕)
  • GitHub workflow ZnunyCodePolicy passes.(❗)
  • GitHub workflow unit tests pass.(❗)

@rkaldung rkaldung self-assigned this Sep 23, 2021
@rkaldung rkaldung added this to the rel-6_2_1 milestone Sep 23, 2021
@rkaldung rkaldung added 1 - πŸš€ feature New feature or request 2 - System/ProcessManagement 3 - wait for reviewer Znuny, it's your turn. Znuny Feature New Znuny version. labels Sep 23, 2021
@dennykorsukewitz
Copy link
Member

dennykorsukewitz commented Oct 1, 2021

Hi @jsinagowitz ,

First of all, the positive statements. πŸš€
Thank you for this really good idea. I have already tested it and it is definitely a MUST HAVE for the framework. πŸ‘

Unfortunately, it is not possible to preview the current status correctly.

In the Kernel/Modules/AdminProcessManagementTransitionAction.pm, 1546 changes are displayed. In reality, the diff looks different.
I can't edit it like that.

145c145
<         # set entity sync state
---
>         # set entitty sync state
333c333
<         # set entity sync state
---
>         # set entitty sync state
414,436d413
<     # Add default parameter
<     # ------------------------------------------------------------ #
<     elsif ( $Self->{Subaction} eq 'GetDefaultConfigParameters' ) {
<
<         my $Module = $ParamObject->GetParam( Param => 'Module' );
<         my %ConfigParameter = $Self->_GetDefaultConfigParameters(
<             Module => $Module,
<         );
<
<         my $JSON = $LayoutObject->JSONEncode(
<             Data => {
<                 %ConfigParameter
<             }
<         );
<         return $LayoutObject->Attachment(
<             ContentType => 'application/json; charset=' . $LayoutObject->{Charset},
<             Content     => $JSON || '',
<             Type        => 'inline',
<             NoCache     => 1,
<         );
<     }
<
<     # ------------------------------------------------------------ #
773,796c750
< sub _GetDefaultConfigParameters {
<     my ( $Self, %Param ) = @_;
<
<     for my $Needed (qw(Module)) {
<         if ( !$Param{$Needed} ) {
<             $Kernel::OM->Get('Kernel::System::Log')->Log(
<                 Priority => 'error',
<                 Message  => 'Need '.$Needed.'!'
<             );
<             return;
<         }
<     }
<
<     # replace e.g. 'Kernel::System::ProcessManagement::TransitionAction::TicketCreate' to 'TicketCreate'
<     if ($Param{Module} =~ m/TransitionAction::(.+)$/) {
<         my $Settings = $Kernel::OM->Get('Kernel::Config')->Get('TransitionActionDefaultParameter::Settings');
<         if ( IsHashRefWithData($Settings) && IsHashRefWithData($Settings->{ $1 }) ) {
<             return %{ $Settings->{ $1 } };
<         }
<     }
<     return;
< }
<
< 1;
---
> 1;
\ No newline at end of file

The same applies to the following files:

  • Kernel/Language/en.pm
  • kernel/modules/AdminProcessManagementTransitionAction.pm
  • scripts/test/ProcessManagement/AdminProcessManagementTransitionActionParameter.t
  • var/httpd/htdocs/js/Core.Agent.Admin.ProcessManagement.js

Todo

Since I cannot go into detail, I will simply give you a few points to consider.

  • Fix git (github) diff for a better review like Kernel/Config/Files/XML/ProcessManagement.xml
  • SysConfig-Name should end with ###Framework, to loop over other settings (package). Please change to ProcessManagement::TransitionAction::DefaultParameters###Framework
  • make sure you can use these functions GetDefaultConfigParameters also for e.g. Transitions or something else in process context

I look forward to your changes. πŸ˜ƒ πŸš€

@dennykorsukewitz dennykorsukewitz added 3 - wait for merge Znuny, it's your turn. 4 - verified This issue or pull request was verified. 3 - wait for contributor Contributor, it's your turn. and removed 3 - wait for reviewer Znuny, it's your turn. 3 - wait for merge Znuny, it's your turn. labels Oct 1, 2021
@jsinagowitz
Copy link
Contributor Author

Hi @dennykorsukewitz

thank you for your feedback. I just started to improve my pull request.

I already found the problem with the high number of changes in some files. Unfortunately, my code editor changed the EOL to CRLF. I fixed that and updated three files in my pull request.

My first question is about the Sysconfig. Your proposal is to name the config ProcessManagement::TransitionAction::DefaultParameters###Framework. I did not find other Sysconfig-Names with ...###Framework at the end, but ...###001-Framework. Shall I better change the Sysconfg-Name to ProcessManagement::TransitionAction::DefaultParameters###001-Framework?

My second question is about the functionality of GetDefaultConfigParameters. I am not sure about the benefit to use the function for transitions. There is not the same kind of key-value pair needed when creating a new transition. We did not have that use-case for our customers yet and I think there is more coding necessary to get this feature done, e.g. a new config structure. Maybe we can deliver that feature later if there is a demand.

Best regards πŸš€

@dennykorsukewitz
Copy link
Member

Hi @jsinagowitz

I already found the problem with the high number of changes in some files. Unfortunately, my code editor changed the EOL to CRLF. I fixed that and updated three files in my pull request.

πŸ‘πŸΌ nice. This is so much better.

My first question is about the Sysconfig. Your proposal is to name the config ProcessManagement::TransitionAction::DefaultParameters###Framework. I did not find other Sysconfig-Names with ...###Framework at the end, but ...###001-Framework. Shall I better change the Sysconfg-Name to ProcessManagement::TransitionAction::DefaultParameters###001-Framework?

πŸ‘πŸΌ 001-Framework sounds also better.

My second question is about the functionality of GetDefaultConfigParameters. I am not sure about the benefit to use the function for transitions. There is not the same kind of key-value pair needed when creating a new transition. We did not have that use-case for our customers yet and I think there is more coding necessary to get this feature done, e.g. a new config structure. Maybe we can deliver that feature later if there is a demand.

I agree. That's how we'll do it for now.
Then please make the changes before I start the review. Thank you

πŸš€ πŸ’―

@jsinagowitz
Copy link
Contributor Author

Hi @dennykorsukewitz

I just updated the sysconfig name. I hope now is everything fine.

Thank you & best regards πŸš€

Copy link
Member

@dennykorsukewitz dennykorsukewitz left a comment

Choose a reason for hiding this comment

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

Hi @jsinagowitz,

here are my adjustments.
In general, everything looks good. πŸ‘πŸΌ

  • AdminProcessManagementTransitionAction: Loop over SysConfig (for Packages)
  • UnitTest: extended
  • JS: Division into individual functions
  • Tidied

If you have any questions you can reach me via Discord.

πŸš€ Thank you

Kernel/Config/Files/XML/ProcessManagement.xml Outdated Show resolved Hide resolved
Kernel/Config/Files/XML/ProcessManagement.xml Outdated Show resolved Hide resolved
Kernel/Modules/AdminProcessManagementTransitionAction.pm Outdated Show resolved Hide resolved
Kernel/Modules/AdminProcessManagementTransitionAction.pm Outdated Show resolved Hide resolved
Kernel/Modules/AdminProcessManagementTransitionAction.pm Outdated Show resolved Hide resolved
Kernel/Modules/AdminProcessManagementTransitionAction.pm Outdated Show resolved Hide resolved
var/httpd/htdocs/js/Core.Agent.Admin.ProcessManagement.js Outdated Show resolved Hide resolved
var/httpd/htdocs/js/Core.Agent.Admin.ProcessManagement.js Outdated Show resolved Hide resolved
Copy link
Member

@dennykorsukewitz dennykorsukewitz left a comment

Choose a reason for hiding this comment

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

Applied ZnunyCodePolicy

Kernel/Modules/AdminProcessManagementTransitionAction.pm Outdated Show resolved Hide resolved
@dennykorsukewitz
Copy link
Member

Hi @jsinagowitz,

so last changes.
NEEDED was missing, my fault.
Everything else fits then.

@dennykorsukewitz dennykorsukewitz added 3 - wait for merge Znuny, it's your turn. and removed 3 - wait for contributor Contributor, it's your turn. labels Oct 6, 2021
@jsinagowitz
Copy link
Contributor Author

@dennykorsukewitz I just fixed the code policy problem in the JS too.

@dennykorsukewitz dennykorsukewitz merged commit 6950149 into znuny:dev Oct 6, 2021
@dennykorsukewitz dennykorsukewitz removed the 3 - wait for merge Znuny, it's your turn. label Oct 6, 2021
znuny-robo pushed a commit that referenced this pull request Oct 6, 2021
Additional feature that provides a placeholder for adding parameters to TransitionActions.
Provided by Sector Nord AG.
@jsinagowitz jsinagowitz deleted the feature/snag-PMTransitionActionParameterHelper branch January 27, 2022 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 - πŸš€ feature New feature or request 4 - verified This issue or pull request was verified. Znuny Feature New Znuny version.
Development

Successfully merging this pull request may close these issues.

None yet

3 participants