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

refactor: extract add strategy diff #8877

Merged
merged 1 commit into from
Nov 28, 2024
Merged

Conversation

kwasniew
Copy link
Contributor

@kwasniew kwasniew commented Nov 28, 2024

About the changes

Extract component for AddStrategy

Screenshot 2024-11-28 at 09 54 56

Also:

  • added tests
  • making diffing less magical (details inline)

Important files

Discussion points

Copy link

vercel bot commented Nov 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 28, 2024 8:55am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Nov 28, 2024 8:55am

Copy link
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

>
<StrategyDiff
change={change}
currentStrategy={currentStrategy}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we were relying on the fact that current strategy is undefined because we look it up by change payload id that happens to be missing in the add strategy change payload.
'id' in change.payload && strategy.id === change.payload.id
This is very difficult to reason about

>
<StrategyDiff
change={change}
currentStrategy={undefined}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's much more obvious when we pass undefined as currentStrategy for the AddStrategy component. You don't have to analyze useCurrentStrategy why it returns undefined

@@ -267,6 +267,56 @@ const UpdateStrategy: FC<{
);
};

const AddStrategy: FC<{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is extract component refactoring with one minor change described below

</StyledBox>
)}
</>
<AddStrategy change={change} actions={actions} />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

now AddStrategy is a one liner like UpdateStrategy and DeleteStrategy

@kwasniew kwasniew merged commit 6e9b65b into main Nov 28, 2024
13 checks passed
@kwasniew kwasniew deleted the add-strategy-extract-refactoring branch November 28, 2024 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant