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

ref(contactus): stylings for contact us page editor #1458

Merged
merged 11 commits into from
Aug 30, 2023

Conversation

dcshzj
Copy link
Contributor

@dcshzj dcshzj commented Aug 29, 2023

Problem

Closes IS-474.

Solution

Breaking Changes

  • Yes - this PR contains breaking changes
  • No - this PR is backwards compatible

Improvements:

  • The contact us page editor has been refactored to make use of the new stylings. This is placed behind a feature flag for now.

Before & After Screenshots

BEFORE:

Screenshot 2023-08-29 at 5 33 49 PM
Screenshot 2023-08-29 at 5 34 16 PM

AFTER:

Screenshot 2023-08-29 at 5 34 50 PM
Screenshot 2023-08-29 at 5 35 06 PM

Tests

  • Unit tests (using npm run tests)
  • e2e tests (comment on this PR with the text !run e2e)
  • Smoke tests
    • Navigate to Contact Us page for a site that has this new stylings enabled (defined in OGP_SITES and TESTING_SITES)
    • Add new location section and contact information section. This should work as intended.
    • Edit the fields in existing and new sections, the preview should update and validation feedback should appear immediately.
    • Delete a card in the location section and contact information section.
    • Add cards in the operating hours section of any location.
    • Edit the fields in the operating hours card.
    • Delete an operating hours card.
    • Drag and drop for first level (locations and contact information), and for second level (operating hours in location) should work as intended.
    • Save changes to the contact us page. The staging site should build in a way that is similar to how the preview looks.

Deploy Notes

None

@dcshzj dcshzj requested a review from a team August 29, 2023 09:41
@dcshzj dcshzj temporarily deployed to staging August 29, 2023 09:43 — with GitHub Actions Inactive
@dcshzj dcshzj temporarily deployed to staging August 29, 2023 10:00 — with GitHub Actions Inactive
@dcshzj dcshzj temporarily deployed to staging August 30, 2023 02:40 — with GitHub Actions Inactive
@dcshzj dcshzj temporarily deployed to staging August 30, 2023 02:55 — with GitHub Actions Inactive
Copy link
Contributor

@seaerchin seaerchin left a comment

Choose a reason for hiding this comment

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

my main issues are that:

  1. the changes in EditContactUs are q big and it isn't immediately obvious why it changed so idk if functionality is still preserved :monkas:
  2. not entirely sure if the cast is safe - this might lead to breakage. i'm ok w the cast itself, just that because fields can be undefined, the cast needs to prove that the required fields always exist

Copy link
Contributor

Choose a reason for hiding this comment

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

actually very tempted to put in folder but ok... i'll take the L

src/utils/validators.js Outdated Show resolved Hide resolved
src/layouts/FeatureFlaggedContactUs.tsx Outdated Show resolved Hide resolved
src/layouts/EditContactUs.jsx Show resolved Hide resolved
src/layouts/EditContactUs.jsx Outdated Show resolved Hide resolved
}
} else if (_.startsWith(strippedValue, "1800")) {
if (
!strippedValue.includes("_") &&
Copy link
Contributor

Choose a reason for hiding this comment

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

sanity check here, should this not be -?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm no, this is an extension of the check just above where it checks if the strippedValue includes _, so it should remain as _.

Copy link
Contributor

Choose a reason for hiding this comment

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

wait do international numbers use _? i always thought was - (based off tv + movie ._.)

Copy link
Contributor

Choose a reason for hiding this comment

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

ok with this as-is cos it's existing behaviour, fix can come later.

}
break
}
case "maps_link": {
if (value.length > 0 && !value.startsWith("https://")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we also allow http || www?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For www we should not, because it will not correctly format the link for the end-user, so we definitely need to specify the protocol. For http, I decided that generally since our sites are in HTTPS, we should also make links go to other HTTPS sites as much as possible. At least for Google Maps and OneMap, they are in HTTPS so this should not affect them.

Copy link
Contributor

Choose a reason for hiding this comment

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

to double check - this is new functionality that wasn't previously present right? i actually don't mind this (and i agree w/ your reasoning here), just wanted to confirm this

@seaerchin
Copy link
Contributor

fyi - didn't run manual tests, will do so tmrw. pls tell me that you did actually run the manual tests on local :monkas:

@dcshzj dcshzj temporarily deployed to staging August 30, 2023 04:32 — with GitHub Actions Inactive
@dcshzj
Copy link
Contributor Author

dcshzj commented Aug 30, 2023

fyi - didn't run manual tests, will do so tmrw. pls tell me that you did actually run the manual tests on local :monkas:

Yup!

@dcshzj dcshzj temporarily deployed to staging August 30, 2023 04:45 — with GitHub Actions Inactive
@dcshzj
Copy link
Contributor Author

dcshzj commented Aug 30, 2023

  1. the changes in EditContactUs are q big and it isn't immediately obvious why it changed so idk if functionality is still preserved :monkas:

The changes can be summarised into 2 key changes:

  1. Styling changes (these are the changes within the hasLoaded condition) - this is definitely necessary since it is the main premise of the issue/PR
  2. onDragEnd enhancements - this is needed to support the added functionality provided by the nested drag-and-drop within the locations section
  1. not entirely sure if the cast is safe - this might lead to breakage. i'm ok w the cast itself, just that because fields can be undefined, the cast needs to prove that the required fields always exist

I removed most of the unnecessary casts after shifting to use the EditableContext. The ones remaining are safe:

  1. Casting to either LocationCardFrontMatter or ContactCardFrontMatter is ok since it is only narrowing from the parent type, which is the union of both types
  2. Casting to PhonePrefix is ok since the event.target.value provided is obtained from the value of the dropdown options, which is generated from PhonePrefix.

@seaerchin
Copy link
Contributor

from offline discussion

onDragEnd enhancements - this is needed to support the added functionality provided by the nested drag-and-drop within the locations section

we are implicitly passing the parentIndex using the id of the element for now. this is safe because the changes are mostly copied over from existing code + an additional indexing step to get the correct parent index.

the draggableId for locationCards is set only in 1 file LocationCard so this is also limited in scope for now.

having said that, i think a possible enhancement for maintainability would be to pass the index explicitly via a wrapper - this would make things clearer and reduce mental load + correctness checking

Copy link
Contributor

@seaerchin seaerchin left a comment

Choose a reason for hiding this comment

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

lgtm

@dcshzj dcshzj temporarily deployed to staging August 30, 2023 05:26 — with GitHub Actions Inactive
@dcshzj dcshzj temporarily deployed to staging August 30, 2023 05:40 — with GitHub Actions Inactive
@seaerchin seaerchin merged commit 4f03e6f into develop Aug 30, 2023
@seaerchin seaerchin deleted the IS-474-contact-us-styling branch August 30, 2023 06:15
seaerchin added a commit that referenced this pull request Aug 31, 2023
* docs(editable): add docs for drag drop stuf (#1445)

Co-authored-by: seaerchin <[email protected]>

* fix(editable): shift out contxt to allow nested dnd (#1448)

Co-authored-by: seaerchin <[email protected]>

* feat: introduce new version of NotFoundPage (#1435)

* Add submarine image for NotFoundPage

* Add new version of the NotFoundPage

* Add storybook stories for new NotFoundPage

* Fix unit test for RouteSelector

* fix(ui): changes based on design feedback

* IS-322 Setup GrowthBook for FE (#1449)

* feat: add growthbook as dep

* feat: add growthbook to app

* feat: inject user attributes

* feat: add default dev mode to be false

* feat: inject site name as attribute

* feat: add types and featur flag list

* chore: minor fixes

* feat: add type and conditional siteName attribute

* fix: enable dev mode only for local dev

* chore: remove duplicate comment

* IS-417 - Fixing Selector Issues in E2E tests (#1453)

* feat: update text assertion

* fix: resources text assertion

* fix: method to remove other collaborators

* fix: uncomment code

* feat: extract constant

* feat: swap removeFirstCollaborator with removeOtherCollaborators

* fix: use removeOtherCollaborators

* chore: remove unused import and function

* chore(edithomepage): shift constants out (#1416)

* refactor(edithomepage): use new constants

* refactor(edithomepage): shift to new folder

* refactor(edithomepage): shift preview out into own section

---------

Co-authored-by: seaerchin <[email protected]>

* IS-508: Introduce Interface for GrowthBook (#1455)

* feat: introduce interface, remove constants file

* fix: comment out sample flags

* ref(contactus): stylings for contact us page editor (#1458)

* Enhance AddSectionButton to allow adjusting button text

* Add various sections of contact us page

* Adjust Editable to allow new droppable zones

* Update validators to match Figma messages

* Introduce feature-flagged contact us page

* Remove unneeded comment

* Switch to use editable contexts instead and use modal

* Fix validation condition

* Fix name for FeatureFlaggedContactUs

* Remove some unnecessary casts

* Fix RouteSelector unit test

* chore: set pointerEvents to none for draggable icon button (#1456)

* Feat/is 443 nav bar styling (#1457)

* chore: update editable types to allow nav

* feat: add pageMenuBody

* feat: add resourceMenuBody

* feat: add folderMenuBody

* feat: add GroupMenuBody

* feat: swap new components into editNavBar

* chore: fix text for components

* Fix: addSectionButton button text prop

* chore: pass props to button instead of box

* chore: add feature flag for new nav bar (#1459)

* chore: add feature flag for new nav bar

* fix: tests

* feat(feature-flag): add feature flag from gb (#1462)

* feat(feature-flag): add feature flag from gb

* refactor(navbar): use gb for ff

* refactor(feature-flag): add types

---------

Co-authored-by: seaerchin <[email protected]>

* fix(edithomepage): remove optional tags (#1450)

Co-authored-by: seaerchin <[email protected]>

* Feat/is 494 smooth scroll (#1439)

* refactor(edithomepage): smooth scroll

* fix: only scroll after first load

* chore: fix rebase errors

* Revert "fix: only scroll after first load"

This reverts commit 158a4df.

* Revert "refactor(edithomepage): smooth scroll"

This reverts commit e555c2f.

* fix: firstLoad condition

* chore: move first load check to separate method

* fix: smooth scroll

---------

Co-authored-by: seaerchin <[email protected]>
Co-authored-by: Alexander Lee <[email protected]>

* Fix/homepage images on private repos (#1461)

* chore: add util method to retrieve image path

* fix: replace image retrieval in homepage template components with updated v2 endpoint

* fix: change return of util method to handle nested

* Update src/utils/images.ts

Co-authored-by: Qilu Xie <[email protected]>

* Update src/utils/images.ts

Co-authored-by: Qilu Xie <[email protected]>

* chore: fix styling

* refactor: move image fetching to separate hook

---------

Co-authored-by: Qilu Xie <[email protected]>

* 0.41.0

---------

Co-authored-by: seaerchin <[email protected]>
Co-authored-by: seaerchin <[email protected]>
Co-authored-by: Harish <[email protected]>
Co-authored-by: Hsu Zhong Jun <[email protected]>
Co-authored-by: Alexander Lee <[email protected]>
Co-authored-by: Qilu Xie <[email protected]>
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.

2 participants