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(detail-pages): add <{Info,Form,CustomForm}DetailPage> components #2594

Merged
merged 15 commits into from
May 16, 2022

Conversation

kark
Copy link
Contributor

@kark kark commented May 6, 2022

Summary

The aim of this PR was to implement new <InfoDetailPage>, <FormDetailPage> and <CustomFormDetailPage> components.
closes #2551

@kark kark added the 🚧 Status: WIP Work in progress label May 6, 2022
@vercel
Copy link

vercel bot commented May 6, 2022

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

Name Status Preview Updated
merchant-center-application-kit ✅ Ready (Inspect) Visit Preview May 10, 2022 at 2:14PM (UTC)

@changeset-bot
Copy link

changeset-bot bot commented May 6, 2022

🦋 Changeset detected

Latest commit: 120bc42

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

This PR includes changesets to release 8 packages
Name Type
@commercetools-frontend/application-components Minor
@commercetools-website/custom-applications Minor
@commercetools-website/components-playground Minor
@commercetools-frontend/application-shell Minor
merchant-center-application-template-starter Patch
playground Patch
@commercetools-local/visual-testing-app Patch
@commercetools-frontend/cypress Minor

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

@vercel vercel bot temporarily deployed to Preview May 6, 2022 15:02 Inactive
@vercel vercel bot temporarily deployed to Preview May 9, 2022 13:00 Inactive
@vercel vercel bot temporarily deployed to Preview May 9, 2022 13:35 Inactive
docs: improvements #2
@vercel vercel bot temporarily deployed to Preview May 9, 2022 14:11 Inactive
@vercel vercel bot temporarily deployed to Preview May 9, 2022 15:17 Inactive
@vercel vercel bot temporarily deployed to Preview May 9, 2022 15:33 Inactive
revert: defaultProps
@vercel vercel bot temporarily deployed to Preview May 9, 2022 15:47 Inactive
@vercel vercel bot temporarily deployed to Preview May 10, 2022 08:06 Inactive
@kark kark marked this pull request as ready for review May 10, 2022 08:28
@kark kark requested a review from a team May 10, 2022 08:28
@kark kark removed the 🚧 Status: WIP Work in progress label May 10, 2022
Copy link
Member

@emmenko emmenko 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 working on this 🙌

Had a quick look with some questions. Will have another look later.


## InfoDetailPage

Form Detail pages are controlled components used to render a page with detailed data.
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
Form Detail pages are controlled components used to render a page with detailed data.
Info Detail pages are controlled components used to render a page with detailed data.

Comment on lines 66 to 69
/**
* Makes page top bar visible
*/
showPageTopBar?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

Is this a new prop? What's the purpose of it? 🤔

Copy link
Contributor Author

@kark kark May 10, 2022

Choose a reason for hiding this comment

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

Thanks. Looking at what is expected at /customers/new in the MC:
Screenshot 2022-05-09 at 17 29 05
the top bar has to be optional.

The other though I had was to render it conditionally based on the onPreviousPathClick

Copy link
Member

Choose a reason for hiding this comment

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

The other though I had was to render it conditionally based on the onPreviousPathClick

Yeah maybe that's better so we don't need an extra prop for that.

packages/application-components/src/index.ts Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview May 10, 2022 09:59 Inactive
Copy link
Contributor

@CarlosCortizasCT CarlosCortizasCT left a comment

Choose a reason for hiding this comment

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

Awesome work 💪

I just left a comment with something to maybe discuss about.

Comment on lines 68 to 88
<FormDetailPage
title="Manage your account"
showPageTopBar
onPreviousPathClick={() => history.push('/starting-page')}
isPrimaryButtonDisabled={formik.isSubmitting}
onSecondaryButtonClick={() => {
formik.resetForm();
}}
onPrimaryButtonClick={formik.handleSubmit}
>
<TextField
name="email"
title="Email"
isRequired={true}
value={formik.values.email}
errors={formik.errors.email}
touched={formik.touched.email}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
/>
</FormDetailPage>
Copy link
Contributor

Choose a reason for hiding this comment

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

For both FormDetailPage and CustomFormDetailPage I'm missing the form html tag wrapping the input fields.

Personally, I would expect those components to internally add that element but, if we don't want that solution, at least I find it necessary to add it into the examples (both in the changelog and in the docs).

If we include the form tag in our components, perhaps we would also want to link the primary button to it using the form attribute (HTML attributes; form attribute explained). Although this can be tricky with the current implementation.

Copy link
Contributor

Choose a reason for hiding this comment

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

I pushed a branch (cm-details-pages) with an implementation idea (not a working solution) of what I meant with my previous comment in case we want to discuss adding the form tag to the new form components.

Changes can be seen here.

Copy link
Member

Choose a reason for hiding this comment

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

FYI: I think using the form element is a valid point and we should discuss this separately, as we're also not really using it in many parts of the MC at the moment.

@CarlosCortizasCT Can you maybe open a discussion or issue to talk about it and how we plan to use it? We should also check with the other teams if there are other concerns about having it set by default in the components.

Thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also value this as I know many locations inside the MC where it's not used. Let's discuss it separately. I think we can either scan the next child and if it's a form not wrap it or have a disableWrapByForm prop which is false by default but can be disabled for instance. Similar to Next.js Link migration strategy which has a oldBehaviour prop.

Copy link
Contributor

@CarlosCortizasCT CarlosCortizasCT left a comment

Choose a reason for hiding this comment

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

💯

@vercel vercel bot temporarily deployed to Preview May 10, 2022 14:14 Inactive
@kark kark requested a review from emmenko May 11, 2022 06:09
Copy link
Contributor

@tdeekens tdeekens left a comment

Choose a reason for hiding this comment

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

Super cool. Can't wait to get rid of more homegrown internal things inside the MC with this 💟.

'@commercetools-website/components-playground': minor
---

Add three new layout components: `<InfoDetailPage>`, `<FormDetailPage>` and `<CustomFormDetailPage>`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Add three new layout components: `<InfoDetailPage>`, `<FormDetailPage>` and `<CustomFormDetailPage>`.
Adds three new layout components: `<InfoDetailPage>`, `<FormDetailPage>` and `<CustomFormDetailPage>`.

Comment on lines 127 to 129
onClick={() => {
formik.resetForm();
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit as we do that below

Suggested change
onClick={() => {
formik.resetForm();
}}
onClick={formik.resetForm}

@@ -0,0 +1,59 @@
import Text from '@commercetools-uikit/text';
Copy link
Contributor

Choose a reason for hiding this comment

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

GitHub doesn't have syntax highlighting on this file but I guess that's unrelated to the file itself.

<Spec label="InfoDetailPage" size="xl">
<DetailPageContainer onPreviousPathClick={() => alert('Go back clicked')}>
<Text.Body>
{`Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur nec turpis in risus elementum fringilla. Vestibulum nec vulputate metus, fringilla luctus nisl. Vestibulum mattis ultricies augue sagittis vestibulum. Nulla facilisi. Quisque tempor pulvinar efficitur. Praesent interdum ultrices leo. Vivamus non ex maximus justo egestas suscipit eget sed purus. Aliquam ut venenatis nulla. Fusce ac ligula viverra, blandit augue eget, congue turpis. Curabitur a sagittis leo. Nunc sed quam dictum, placerat nunc quis, luctus erat.`}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need tow rap these in {``}. There are some places in this PR we do so and others we don't.

Copy link
Contributor

@tdeekens tdeekens left a comment

Choose a reason for hiding this comment

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

Thanks. This looks good from my view.

@github-actions github-actions bot temporarily deployed to Preview May 11, 2022 11:49 Destroyed
@github-actions
Copy link
Contributor

github-actions bot commented May 11, 2022

Deploy preview for merchant-center-application-kit ready!

✅ Preview
https://merchant-center-application-d6uavsnfk-commercetools.vercel.app
https://appkit-sha-3b70baebb8e5a69920b1196094bef199e801d096.commercetools.vercel.app
https://appkit-pr-2594.commercetools.vercel.app

Built with commit 120bc42.
This pull request is being automatically deployed with vercel-action

@github-actions github-actions bot temporarily deployed to Preview May 12, 2022 15:36 Destroyed
@github-actions github-actions bot temporarily deployed to Preview May 13, 2022 12:02 Destroyed
@emmenko
Copy link
Member

emmenko commented May 13, 2022

@kark Looks good, thanks!

One minor thing: the list of components got longer now and I think it would be nice to group things a bit (e.g. Dialogs, Modal pages, Detail pages, etc.)

image

Can also be a follow up.

Copy link
Member

@emmenko emmenko left a comment

Choose a reason for hiding this comment

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

🚀

Let's do the docs improvements as a follow up, as discussed. Thanks!

Comment on lines 139 to 141
onClick={() => {
formikProps.resetForm();
}}
Copy link
Member

Choose a reason for hiding this comment

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

I would keep it like this actually, as resetForm accepts an argument as the nextState and that could lead to unexpected issues if the function is called with the event resetForm(event).

https://formik.org/docs/api/formik#resetform-nextstate-partialformikstatevalues--void

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks 😊

@github-actions github-actions bot temporarily deployed to Preview May 16, 2022 13:18 Destroyed
@emmenko emmenko merged commit d20638e into main May 16, 2022
@emmenko emmenko deleted the kk-detail-pages branch May 16, 2022 13:38
@ghost ghost mentioned this pull request May 16, 2022
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.

Implement {Info,Form,CustomForm}DetailPage
4 participants