-
Notifications
You must be signed in to change notification settings - Fork 10
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/contact us page #260
Feat/contact us page #260
Conversation
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.
Left a few comments. In addition, there were some other things we could possibly consider modifying:
- Editing a field automatically shifts the editor view back to the start of a section (e.g. editing a location will bring you to the very first location), which is problematic for long sections - the viewer should only snap back to the item being edited
- We might want to provide a way to add and delete sections - there's no way to remove or add a new section entirely currently
- We could implement a check for any edited data and give a warning if the user is navigating away with unsaved changes, similar to editHomepage
- One other thing is that on a site with no contact-us to begin with, there's no way to add a contact-us page. We could possible consider giving the option to create a new contact-us page, which gives default values? This could also be used in the case that the contact-us page is empty. Am open to suggestions on this
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.
Left a couple of comments - other comments to be discussed offline
setCollections(collectionsResp.data?.collections) | ||
const fetchData = async () => { | ||
try { | ||
await axios.get(`${BACKEND_URL}/sites/${siteName}/pages/contact-us.md`); |
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.
For this part, you might want to rebase to the latest staging branch. To avoid memory leaks with this API call (refer to #242), we use a local variable _isMounted
and only update state when _isMounted === true
, so in this case it would be
if (_isMounted) setContactUsCard(true)
default: { // others | ||
return ( | ||
/* TODO: CSP validation should be done on html elements before rendering */ | ||
<div dangerouslySetInnerHTML={{__html: d[key]}} key={i}/> |
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 forgot what the use case was here - why is this not also a <p>
like the others? Reference from the customs website for this portion:
<p class="margin--top--none margin--bottom--none">For queries and appeals pertaining to a Notice of Customs Offence by Singapore Customs Special Investigation Branch</p>
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.
We support html tags here, such for A-star NRP raw file:
- title: Feedback
content:
- other: We would love to hear what you have to say! Fill in a feedback form <a href="https://form.gov.sg/#!/5fab84f4ec6c950011f3e8ba">here</a>!
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 forgot what the conclusion was here - the problem is that in practice the html tags are wrapped inside the <p>
tag, but we're unable to dangerously set inner html for p tags right?
@alexanderleegs RE: the last point on no Contact Us page, Alexis and I had discussed this separately and since most repositories have a Contact Us page, we'll first go off the assumption that repos have a contact us page, and if they don't, then just don't display the Contact Us card for now. |
^ Deleted @kwajiehao's comment accidentally, comment was about multi-line form field validation vs single-line form field validation (can't find option to undo delete) |
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.
Left comments
src/utils/validators.js
Outdated
const URL_REGEX_PART_2 = '.com/)([a-zA-Z0-9_-]+(/)?)+$'; | ||
const PHONE_REGEX = '^\\+65(6|8|9)[0-9]{7}$' | ||
const TOLLFREE_PHONE_REGEX = '^1800[0-9]{7}$' | ||
const EMAIL_REGEX = '^[a-z0-9-_\.]+@[a-z0-9-]+\.[a-z]{2,4}$'; |
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.
Can we consider using a more established email regex (like https://emailregex.com/)
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.
good idea, will change this
default: { // others | ||
return ( | ||
/* TODO: CSP validation should be done on html elements before rendering */ | ||
<div dangerouslySetInnerHTML={{__html: d[key]}} key={i}/> |
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 forgot what the conclusion was here - the problem is that in practice the html tags are wrapped inside the <p>
tag, but we're unable to dangerously set inner html for p tags right?
src/layouts/EditContactUs.jsx
Outdated
break; | ||
} | ||
case 'location': { | ||
const { locations } = state.frontMatter; |
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.
Unused line of code
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.
this has been fixed in the latest branch of code https://github.com/isomerpages/isomercms-frontend/tree/feat/contact-us-page-2
src/utils/validators.js
Outdated
if (value && !alphanumericRegexTest.test(value)) { | ||
errorMessage += `Field should only contain alphanumeric characters. ` | ||
} | ||
if (value && !value.length < LOCATION_OPERATING_HOURS_MIN_LENGTH) { |
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.
There is a bug here, it should be value.length < LOCATION_OPERATING_HOURS_MIN_LENGTH
instead of !value.length < LOCATION_OPERATING_HOURS_MIN_LENGTH
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.
this has been fixed in the latest branch of code https://github.com/isomerpages/isomercms-frontend/tree/feat/contact-us-page-2
src/utils/validators.js
Outdated
if (value && !value.length < LOCATION_OPERATING_HOURS_MIN_LENGTH) { | ||
errorMessage += `Field should be longer than ${LOCATION_OPERATING_HOURS_MIN_LENGTH} characters.` | ||
} | ||
if (value && !value.length > LOCATION_OPERATING_HOURS_MAX_LENGTH) { |
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.
Same bug as above
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.
this has been fixed in the latest branch of code https://github.com/isomerpages/isomercms-frontend/tree/feat/contact-us-page-2
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.
lgtm, remaining changes will be reviewed in #266
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.
lgtm
… Feedback Sections)
…tact-us template page, renames old Breadcrumb as PageHeader and updates Breadcrumb references in LeftNavPage and SimplePage as well as isomer-template.scss
… isHomepage and isCollection to a single page type string as there are 4 different page types to consider now, updates references to isHomepage and isCollection in Workspace, FolderCard and Resources, adds contact-us route to App
…lly intended for reuse in contact contents; updates NewSectionCreator to use Dropdown component
…used as a series of fields without each having a title such as the address fields in Contact Us
…ctCards, Section, Fields)
…act-us.md file exists
…epage templates structure
* fix: suppresses dropdown for Contact Us Folder Card dropdown options * fix: removes hardcoded sectionId, passing sectionId as argument * fix: updates displaySections to use locations, contacts as key values, simplifies indexing updates for OnDragEnd, createHandler, deleteHandler, displayHandler * fix: adds check if frontMatter.contacts or frontMatter.locations array is empty, if empty the key-value pair is removed and not saved * fix: updates templates to use forwarded react references * fix: updates scrollRefs to use React.createRef() and forward references to templates, also updates scroll behavior for onFieldChange, onDragEnd, deleteHandler, createHandler and displayHandler * fix: fixes error in operatingHours validation, adds case for validating map links * fix: clean up comments, whitespace * fix: checks whether content has been edited and shows navigate away warning accordingly * fix: uses deep cloning to sanitise frontMatter * fix: sets background color for contactUs edit preview * fix: buffs up email validation * fix: add packages for DOMPurify * fix: uses DOMPurify to prevent XSS scripts from rendering on Contacts descriptions * fix: fixes paragraph stylistic formatting on Contacts description * fix: fixes form field width for operating hours to not resize with error length * fix: resolves stylistic differences in links and span text * fix: adds parent style around links in ContactSection Templates * fix: cleans up scrollIntoView * fix: adds key to dropdown options to resolve unique id warning * install: adds packages for react-input-mask * feat: creates InputMaskFormField using react-input-mask for FormFields that can use masked input styling, for example dates, phone numbers and so on * feat: adds state hook to Contact Fields to support masked input styling for the Phone Number field, uses Dropdown to set state * fix: simplifies validation for Contact Fields phone number as masked input provides user cues for length of phone number already * fix: rectifies relative imports * fix: cleans up warning errors in validation * fix: fix initialized state in state hook * fix: filters dropdown before mapping to remove arrow function warning * fix: sets font size for error and info messages since span has been set by default to inherit parent font-size * fix: uses info message style for notes * fix: removes extraneous terms from automated url generation and sets View Map link to open in a new page * fix: adds Delete modal for each Location and Contact * feat: add styling for error cards * feat: uses red border to highlight sections and cards that contain errors, border is only highlighted when section/card is minimized * fix: fix title overflow bug * fix: removes default value if user does not select phone number field * fix: clean up dataSanitisers and add initial values for maps_links and titles * fix: removes min length for title * fix: sets min length of titles to 1 * fix: change Add button to singular form instead of plural as in Contact and Location not contacts and locations
c432942
to
9548a83
Compare
Addresses #217. PR is continued in #266.
This PR is still a work in progress, but seeking feedback for the stuff here so far. The remaining tasks are more modular/ cleanup-focused, and is unlikely to affect functionality significantly. Please have a look and give your feedback, especially if it's not covered in the scope of the tasks mentioned below or it's a bug I've not discovered:
Remaining tasks:
Initialize contact-us.md if file does not exist (P1)Hide/ Show Contact Us card on Workspace depending on whether contact-us.md exists (P1)- [ ] Add CSP checking on Contact Description field as html elements are accepted (P1), either through validation orthrough filtering (P2)- [ ] Contact Us image ? (see link)- [ ] Data sanitiser should return indicator for whether values are removed e.g. Customs has more Address fields than we support, so we automatically truncate it to the first 3 fields. Warning should be returned when fields are removed. (to be discussed){ contact: [], location: [], sectionsDisplay: {} }
as this should simplify displayHandler, createHandler, deleteHandler (P3)Additional tasks (updated 11/26/2020):
- [ ] Fix memory leaks with API call on WorkspaceAdditional tasks (updated 12/1/2020):
For FUTURE PR (updated 12/1/2020):
Fix memory leaks with API call on WorkspaceConsiderations to discuss with Lisa/ designers - Updated summary of discussion on 12/1 linked here