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(coral): Improve promotion information for schema #1513

Merged
merged 12 commits into from
Jul 27, 2023

Conversation

programmiri
Copy link
Contributor

@programmiri programmiri commented Jul 26, 2023

About this change - What it does

  • adds a shared component PromotionBanner to be used for topics as well as schemas
    • PromotionBanner takes the PromotionStatus as well as hasOpenRequest and based on that decides what to show. It's up to the components using PromotionBanner to decide if it should not be rendered at all because the user is not topicOwner
    • it takes topicName as explicit prop. The topicName is available on promotion details for topics, but not for schemas.
  • updated TopicPromotionBanner to use PromotionBanner internally.
    • TopicPromotionBanner is responsible for passing the right promote element (which differs for topic and schema) as well as passing the right properties through. I left this as a separate component because that way it is easier to tests this well without making the tests for TopicOverview more complex. I used a data-testid to enable easier testing in TopicOverview.
  • I updated the test in TopicOverview to not only use snapshots but confirm the rendering/absence of banner explicitly.
  • added SchemaPromotionBanner with use of PromotionBanner internally (same explanation as above)
  • updated TopicDetailsSchema to use the new component

Note:

There will be a follow up by backend to add hasOpenSchemaRequests to topicInfos, matching the existing properties. For now, we can check for hasOpenRequest && !hasOpenACLRequest && !hasOpenTopicReques -> if hasOpenRequest is true but hasOpenAclRequest and hasOpenTopicRequest are both false, the only open request is a schema request.

Doing a small follow up for this change does remove pressure from backend to do that urgently. We also don't need to wait for the BE change to be merged (and for testing stating to be updated).

@programmiri programmiri requested a review from a team as a code owner July 26, 2023 09:04
@programmiri programmiri marked this pull request as draft July 26, 2023 09:39
@programmiri programmiri self-assigned this Jul 26, 2023
@programmiri programmiri marked this pull request as ready for review July 26, 2023 10:11
@programmiri programmiri added the Frontend Relates to coral (react app) label Jul 26, 2023
Copy link
Contributor

@mathieu-anderson mathieu-anderson left a comment

Choose a reason for hiding this comment

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

Just a few comments ^^ Not sure if adding support for connector promotion is premature optimisation or forward thinking haha

@programmiri programmiri force-pushed the 1441-improve-promotion-information-for-schema branch 2 times, most recently from e7501e1 to 8136405 Compare July 27, 2023 07:24
Copy link
Contributor

@mathieu-anderson mathieu-anderson left a comment

Choose a reason for hiding this comment

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

👍

@mathieu-anderson mathieu-anderson dismissed their stale review July 27, 2023 12:55

Awaiting more changes

@programmiri programmiri force-pushed the 1441-improve-promotion-information-for-schema branch from 92acc19 to b6237e4 Compare July 27, 2023 13:37
Signed-off-by: Mirjam Aulbach <mirjam.aulbach@aiven.io>
…nternally

Signed-off-by: Mirjam Aulbach <mirjam.aulbach@aiven.io>
Signed-off-by: Mirjam Aulbach <mirjam.aulbach@aiven.io>
Signed-off-by: Mirjam Aulbach <mirjam.aulbach@aiven.io>
Signed-off-by: Mirjam Aulbach <mirjam.aulbach@aiven.io>
Signed-off-by: Mirjam Aulbach <mirjam.aulbach@aiven.io>
Signed-off-by: Mirjam Aulbach <mirjam.aulbach@aiven.io>
Signed-off-by: Mirjam Aulbach <mirjam.aulbach@aiven.io>
Signed-off-by: Mirjam Aulbach <mirjam.aulbach@aiven.io>
Signed-off-by: Mirjam Aulbach <mirjam.aulbach@aiven.io>
Signed-off-by: Mirjam Aulbach <mirjam.aulbach@aiven.io>
Signed-off-by: Mirjam Aulbach <mirjam.aulbach@aiven.io>
@programmiri programmiri force-pushed the 1441-improve-promotion-information-for-schema branch from b6237e4 to 5fbad29 Compare July 27, 2023 13:38
@@ -14,6 +14,8 @@ interface PromotionBannerProps {
type: "schema" | "topic";
promoteElement: ReactElement;
hasOpenRequest: boolean;
hasError: boolean;
errorMessage: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

I expect errorMessage is not optional because we often store error messages in a local state initialized with "" ? I'm thinking that often this could be avoided by using directly the error and isError returned by useMutation, and would maybe be a bit clearer?

This is definitely not in scope of this PR, but maybe it would be nice as a folow up? "Standardized mutation error handling"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"errorMessage" in this case is optional because for example TopicPromotionBanner does not have the need to show an error message. And if we use update this promotion banner to be more generic (e.g. also be used for claim) there may be cases where we need to be able to show an error here, but in most cases the "button" links to a form, which has it's own error handling.

"Standardized mutation error handling"?

We could do that, but for this component I don't think that we should assume that the error shown here is a mutation error. It is currently in the one use case, but it could also be a different kind of error. And tying or components too closely to structures of libs we're using may restrict us a bit. What if we want to / need to get rid of react-query -> or console wants to use components from us and they don't use react-query.

Copy link
Contributor

@mathieu-anderson mathieu-anderson left a comment

Choose a reason for hiding this comment

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

👍

@mathieu-anderson mathieu-anderson merged commit fef926a into main Jul 27, 2023
25 checks passed
@mathieu-anderson mathieu-anderson deleted the 1441-improve-promotion-information-for-schema branch July 27, 2023 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frontend Relates to coral (react app)
Projects
None yet
2 participants