-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 AppDetailsPage to Macaw Next #3818
Conversation
🦋 Changeset detectedLatest commit: 59f1cc7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
if (dataPrivacyUrl) { | ||
return ( | ||
<ExternalLink href={dataPrivacyUrl} target="_blank"> | ||
<FormattedMessage {...messages.dataPrivacyDescription} /> | ||
</ExternalLink> | ||
); | ||
} else { | ||
return <Text>{intl.formatMessage(messages.noDataPrivacyPage)}</Text>; | ||
} | ||
|
||
throw new Error("Leaking switch statement"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementing return early is optional (non-blocking).
Throw instruction can be removed since it's unreachable.
if (dataPrivacyUrl) { | |
return ( | |
<ExternalLink href={dataPrivacyUrl} target="_blank"> | |
<FormattedMessage {...messages.dataPrivacyDescription} /> | |
</ExternalLink> | |
); | |
} else { | |
return <Text>{intl.formatMessage(messages.noDataPrivacyPage)}</Text>; | |
} | |
throw new Error("Leaking switch statement"); | |
if (!dataPrivacyUrl) { | |
return <Text>{intl.formatMessage(messages.noDataPrivacyPage)}</Text> | |
} | |
return ( | |
<ExternalLink href={dataPrivacyUrl} target="_blank"> | |
<FormattedMessage {...messages.dataPrivacyDescription} /> | |
</ExternalLink> | |
); |
Was this error necessary? Seems strange 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Component should render only for cases I want it to. If none of conditions are met, this is a bug in the code. Should not happen. Just like leaky switch/cases. Hence throwing error to quickly see that something wrong happened. If I return "null" here, we will never now if there is a bug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's if/else with returning statements inside. Exception throw is unreachable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
} | ||
|
||
if (aboutApp) { | ||
return <ReactMarkdown source={aboutApp ?? ""} />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return <ReactMarkdown source={aboutApp ?? ""} />; | |
return <ReactMarkdown source={aboutApp} />; |
return <Text>{intl.formatMessage(messages.noDataPrivacyPage)}</Text>; | ||
} | ||
|
||
throw new Error("Leaking switch statement"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: shouldn't it be logged into sentry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't sentry automatically do that? Its unhandled on purpose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added error boundary and explicitely called Sentry
closes #...
This is part of saleor/apps#569
This PR:
Next steps will be adding more features to this page, like removing permissions
Screenshots
Pull Request Checklist
data-test-id
are added for new elementsTest environment config
API_URI=https://automation-dashboard.staging.saleor.cloud/graphql/
APPS_MARKETPLACE_API_URI=https://apps.staging.saleor.io/api/v2/saleor-apps
Do you want to run more stable tests?
To run all tests, just select the stable checkbox. To speed up tests, increase the number of containers. Tests will be re-run only when the "run e2e" label is added.
CONTAINERS=1