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

feat(stepfunctions): add comment ability for when condition #27010

Merged
merged 10 commits into from
Sep 19, 2023

Conversation

msambol
Copy link
Contributor

@msambol msambol commented Sep 5, 2023

Currently you can comment on a Choice state.
This adds the ability to comment on a when condition.

Screenshot 2023-09-05 at 7 47 35 AM Screenshot 2023-09-05 at 7 54 29 AM

Closes #27005.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team September 5, 2023 12:49
@github-actions github-actions bot added feature-request A feature should be added or improved. p2 valued-contributor [Pilot] contributed between 6-12 PRs to the CDK labels Sep 5, 2023
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 5, 2023
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

Thanks for contributing this @msambol. Just a minor nit on how the function looks

protected addChoice(condition: Condition, next: State) {
this.choices.push({ condition, next });
protected addChoice(condition: Condition, next: State, comment?: string) {
this.choices.push({ condition, next, comment });
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally this function would be

protected addChoice(choice: ChoiceTransition) {
  this.choices.push(choice);
}

but I guess we can't change the function signature now

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can do this to help make this function signature stable if we ever add more props to ChoiceTransition:

interface ChoiceTransition extends ChoiceTransitionOptions {
  condition;
  next;
}

interface ChoiceTransitionOptions {
  comment?;
}

protected addChoice(condition: Condition, next: State, options: ChoiceTransitionOptions) {}

This has 2 benefits:

  • using the function would look like
choice.when(sfn.Condition.stringEquals('$.color', 'BLUE'), handleBlueItem, {
  comment: 'blue item comment',
});

which imo makes it clear that we're providing a comment.

  • if we add an additional prop to ChoiceTransition in the future, like default or something, we can easily add it to ChoiceTransitionOptions

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 5, 2023
@mergify mergify bot dismissed kaizencc’s stale review September 5, 2023 18:35

Pull request has been modified.

@msambol
Copy link
Contributor Author

msambol commented Sep 5, 2023

@kaizencc I updated per your feedback—thanks!

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 5, 2023
/**
* Options for Choice Transition
*/
export interface IChoiceTransitionOptions {
Copy link
Contributor

Choose a reason for hiding this comment

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

@msambol what was the reason for naming this IChoiceTransitionOptions? I assume you ran into some linter rule that yelled at you? Want to find out because I don't think it makes sense here, and we should exempt this from that rule if thats the case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kaizencc Yep, I got:

aws-cdk-lib:     The declaring class is introduced here
aws-cdk-lib: aws-stepfunctions/lib/states/state.ts:503:3 - error JSII3008: The "comment" property of struct "aws-cdk-lib.aws_stepfunctions.ChoiceTransitionOptions" must be "readonly". Rename "aws-cdk-lib.aws_stepfunctions.ChoiceTransitionOptions" to "IChoiceTransitionOptions" if it is meant to be a behavioral interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kaizencc From what I'm reading there isn't a way to silence JSII errors? Hmm..

*
* @default No comment
*/
comment?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

does this fix the JSII error maybe?

Suggested change
comment?: string;
readonly comment?: string;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jogold It did. Good shout, Jonathan. I was following the pattern of state and condition but there is no reason this can't be readonly.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 8, 2023
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 8, 2023
@msambol
Copy link
Contributor Author

msambol commented Sep 13, 2023

@kaizencc Mind taking another look here?

@mergify
Copy link
Contributor

mergify bot commented Sep 19, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 19, 2023
@mergify
Copy link
Contributor

mergify bot commented Sep 19, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: feb3c0a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 70006ab into aws:main Sep 19, 2023
8 checks passed
@mergify
Copy link
Contributor

mergify bot commented Sep 19, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@msambol msambol deleted the sfn-comment branch September 19, 2023 13:29
HBobertz pushed a commit that referenced this pull request Sep 19, 2023
Currently you can comment on a `Choice` state. 
This adds the ability to comment on a when condition.

<img width="437" alt="Screenshot 2023-09-05 at 7 47 35 AM" src="https://github.com/aws/aws-cdk/assets/3310356/4cb92427-c16c-4994-9e86-0384c4c2b075">

<img width="473" alt="Screenshot 2023-09-05 at 7 54 29 AM" src="https://github.com/aws/aws-cdk/assets/3310356/4dc1857e-5515-4510-8fde-a5eb8bc93afe">

Closes #27005.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. p2 valued-contributor [Pilot] contributed between 6-12 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-stepfunctions: comment field appears not supported
5 participants