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 AppDetailsPage to Macaw Next #3818

Merged
merged 4 commits into from
Jun 29, 2023
Merged

Conversation

lkostrowski
Copy link
Member

closes #...

This is part of saleor/apps#569

This PR:

  1. adds missing messages
  2. rewrite material to Macaw/Next
  3. small refactors

Next steps will be adding more features to this page, like removing permissions

Screenshots

Zrzut ekranu 2023-06-29 o 13 50 29

Pull Request Checklist

  1. This code contains UI changes
  2. All visible strings are translated with proper context including data-formatting
  3. Attributes data-test-id are added for new elements
  4. The changes are tested in Chrome/Firefox/Safari browsers and in light/dark mode
  5. Your code works with the latest stable version of the core
  6. I added changesets and read good practices

Test 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.

  1. stable
  2. giftCard
  3. category
  4. collection
  5. attribute
  6. productType
  7. shipping
  8. customer
  9. permissions
  10. menuNavigation
  11. pages
  12. sales
  13. vouchers
  14. homePage
  15. login
  16. orders
  17. products
  18. app
  19. plugins
  20. translations
  21. navigation
  22. variants
  23. payments

CONTAINERS=1

@lkostrowski lkostrowski requested a review from a team June 29, 2023 12:19
@lkostrowski lkostrowski self-assigned this Jun 29, 2023
@changeset-bot
Copy link

changeset-bot bot commented Jun 29, 2023

🦋 Changeset detected

Latest commit: 59f1cc7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
saleor-dashboard Patch

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

@github-actions github-actions bot temporarily deployed to refactor-app-details June 29, 2023 12:19 Inactive
@github-actions github-actions bot temporarily deployed to storybook refactor-app-details June 29, 2023 12:19 Inactive
@github-actions github-actions bot temporarily deployed to refactor-app-details June 29, 2023 12:26 Inactive
@github-actions github-actions bot temporarily deployed to storybook refactor-app-details June 29, 2023 12:26 Inactive
@lkostrowski lkostrowski requested review from andrzejewsky and a team June 29, 2023 12:27
Comment on lines 30 to 40
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");
Copy link
Member

@krzysztofwolski krzysztofwolski Jun 29, 2023

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.

Suggested change
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 🤔

Copy link
Member Author

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

Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

src/apps/components/AppDetailsPage/PermissionsCard.tsx Outdated Show resolved Hide resolved
}

if (aboutApp) {
return <ReactMarkdown source={aboutApp ?? ""} />;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return <ReactMarkdown source={aboutApp ?? ""} />;
return <ReactMarkdown source={aboutApp} />;

return <Text>{intl.formatMessage(messages.noDataPrivacyPage)}</Text>;
}

throw new Error("Leaking switch statement");
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member Author

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

@github-actions github-actions bot temporarily deployed to refactor-app-details June 29, 2023 13:14 Inactive
@github-actions github-actions bot temporarily deployed to storybook refactor-app-details June 29, 2023 13:14 Inactive
@lkostrowski lkostrowski enabled auto-merge (squash) June 29, 2023 13:48
@lkostrowski lkostrowski merged commit a1482cc into main Jun 29, 2023
@lkostrowski lkostrowski deleted the refactor-app-details branch June 29, 2023 13:50
@lkostrowski lkostrowski added this to the Saleor 3.15 milestone Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants