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/announcement block #1497

Merged
merged 52 commits into from
Sep 22, 2023
Merged

Feat/announcement block #1497

merged 52 commits into from
Sep 22, 2023

Conversation

kishore03109
Copy link
Contributor

@kishore03109 kishore03109 commented Sep 14, 2023

Problem

Announcement block editing in homepage according to figma.

Solution

In the interest of consistency, similar approach to key_highlights in the hero banner.

Breaking Changes

  • Yes - this PR contains breaking changes
    • Details ...
  • No - this PR is backwards compatible
Screen.Recording.2023-09-15.at.7.10.16.PM.mov

Tests

  • Go into edit homepage
  • Click on add new announcement
  • Ensure that when new announcements are created, they are created from the top
  • Ensure that save button is not available when errors are present
  • Ensure that when there are errors in the announcement item there is a red outline in both
    1. The annoucemnet item
    2. The entire announcement block
  • You can drag and drop announcements
  • When one announcement block is clicked, you cannot add more announcement blocks (only allowed <= 1 announcement block)
  • You can only add up to 5 announcement items (only allowed <= 5 announcement items)
  • When save is clicked + page is refreshed, the announcement persists -> suggests that the changes were sucessfully published to gh.

Known limitations

  • Announcement does not open up on create. (I attempted to use displayAnnouncements for this but somehow it is not working as intended. Filing a ticket here.)
  • Implementing unique keys in AnnouncementBody.tsx. Since we are rendering components over a map, each element would require a unique key. However, when I did do it the re-renders were visible + triggered an off-focus 😱. Have anyone solved this problem before?
    Screenshot 2023-09-15 at 2 53 03 PM.
    This key was removed in 1556850

Blockers

I think it is difficult for design to iterate give a green check here since we don't have storybook. I tried (a timeboxed) attempt it b5b41cc but the paddings and all were off so this attempt does not yield the benefits that I was hoping for. Since this to be shipped soon, for now Ill document the flows in video form to get Design's [@sehyunidaaa] approval first.

Note to reviewers

This PR is too bulky for my taste, I am seeking feedback on how I could have split this PR up (or if this PR size is actually ok).

@kishore03109 kishore03109 temporarily deployed to staging September 14, 2023 09:13 — with GitHub Actions Inactive
@kishore03109 kishore03109 temporarily deployed to staging September 14, 2023 09:15 — with GitHub Actions Inactive
@kishore03109 kishore03109 temporarily deployed to staging September 15, 2023 06:39 — with GitHub Actions Inactive
@kishore03109 kishore03109 temporarily deployed to staging September 15, 2023 07:07 — with GitHub Actions Inactive
@kishore03109 kishore03109 temporarily deployed to staging September 15, 2023 08:30 — with GitHub Actions Inactive
@kishore03109 kishore03109 marked this pull request as ready for review September 15, 2023 11:15
@kishore03109 kishore03109 requested a review from a team September 15, 2023 11:16
@kishore03109 kishore03109 temporarily deployed to staging September 15, 2023 11:20 — with GitHub Actions Inactive
@@ -803,13 +915,6 @@ const validateDayOfMonth = (month, day) => {
}
}

const validateNonFutureDate = (dateStr) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: this is not removed, but shifted up + renamed to group similar functions tgt

Copy link
Contributor

@dcshzj dcshzj left a comment

Choose a reason for hiding this comment

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

Not a complete review yet, left EditHomepage.jsx but have some concerns regarding frontmatter

src/utils/validators.js Outdated Show resolved Hide resolved
src/utils/validators.js Outdated Show resolved Hide resolved
src/utils/validators.js Outdated Show resolved Hide resolved
src/types/homepage.ts Outdated Show resolved Hide resolved
src/layouts/EditHomepage/EditHomepage.jsx Outdated Show resolved Hide resolved
src/layouts/components/Homepage/AnnouncementBody.tsx Outdated Show resolved Hide resolved
src/layouts/components/Homepage/AnnouncementBody.tsx Outdated Show resolved Hide resolved
src/layouts/components/Homepage/AnnouncementBody.tsx Outdated Show resolved Hide resolved
Comment on lines +62 to +96
{
title: announcementTitle,
date: announcementDate,
announcement: announcementContent,
link_text: announcementLinkText,
link_url: announcementLinkUrl,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a functional comment but just wondering if it would be better to just have announcement object here, then call things like announcement.title below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hey i rather destructure at the top bah.
i didnt want to do announcement.announcement for clarity

src/layouts/components/Homepage/AnnouncementBody.tsx Outdated Show resolved Hide resolved
@kishore03109 kishore03109 temporarily deployed to staging September 18, 2023 10:32 — with GitHub Actions Inactive
@kishore03109 kishore03109 temporarily deployed to staging September 19, 2023 04:51 — with GitHub Actions Inactive
@kishore03109 kishore03109 requested a review from dcshzj September 19, 2023 07:38
@kishore03109 kishore03109 temporarily deployed to staging September 19, 2023 07:57 — with GitHub Actions Inactive
@dcshzj dcshzj force-pushed the IS-517-announcements-previews branch from 7601bf0 to 94e3af7 Compare September 19, 2023 12:13
@kishore03109 kishore03109 temporarily deployed to staging September 20, 2023 05:24 — with GitHub Actions Inactive
src/hooks/useDrag.tsx Outdated Show resolved Hide resolved
src/hooks/useDrag.tsx Show resolved Hide resolved
src/layouts/EditHomepage/EditHomepage.jsx Outdated Show resolved Hide resolved
src/layouts/EditHomepage/EditHomepage.jsx Outdated Show resolved Hide resolved
src/layouts/EditHomepage/EditHomepage.jsx Outdated Show resolved Hide resolved
id={`announcements-${announcementIndex}-date`}
inputValue={announcementDate}
onInputValueChange={(value) => {
onChange({
Copy link
Contributor

Choose a reason for hiding this comment

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

feels like i shuold've wrapped the onChange ._.

Copy link
Contributor

Choose a reason for hiding this comment

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

skimmed - seems to be ok

Comment on lines 116 to 118
{moment(announcement.date, "DD/MM/YYYY").format(
"DD MMMM YYYY"
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

noted that this will reconcile the diff in view but it still feels weird to have it here (as a view level thing) rather than just doing it at the data level. this offloads responsibility to the dev next time to know this @__@

Copy link
Contributor Author

Choose a reason for hiding this comment

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

src/utils/validators.js Outdated Show resolved Hide resolved
@@ -218,6 +240,57 @@ const validateHighlights = (highlightError, field, value) => {
return newHighlightError
}

const validateAnnouncementItems = (announcementError, field, value) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

could we separate out the validation from the set? this makes it easier to reuse in the future, which was 1 blocker i faced when trying to use the existing validators

Copy link
Contributor Author

Choose a reason for hiding this comment

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

validation from the set? May I get your help to expand more on this/direct me to the part of the codebase that uses the pattern you are trying to explain?

Copy link
Contributor

Choose a reason for hiding this comment

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

abit unclear wording on my end, but validateAnnouncementItems sets the corresponding index. in this case, it does not simply validate (ie, return bool + msg) but also does a side effect (setting the corresponding index). this isn't particularly important to fix now because it follows the existing style of code but when we want to do simple validation that is unaware of the structure of the error, will be an issue

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 ok, am inclined to keep it as is for consistency with the rest of the local code, will modify if future pain points warrant it?

@kishore03109 kishore03109 temporarily deployed to staging September 20, 2023 10:28 — with GitHub Actions Inactive
@kishore03109 kishore03109 temporarily deployed to staging September 20, 2023 10:45 — with GitHub Actions Inactive
@kishore03109 kishore03109 temporarily deployed to staging September 21, 2023 01:35 — with GitHub Actions Inactive
@kishore03109 kishore03109 changed the base branch from IS-517-announcements-previews to develop September 21, 2023 03:29
@kishore03109 kishore03109 temporarily deployed to staging September 21, 2023 03:54 — with GitHub Actions Inactive
@kishore03109 kishore03109 temporarily deployed to staging September 21, 2023 04:11 — 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.

mostly sanity checks

Comment on lines +233 to +239
let {
content: { frontMatter },
sha,
} = homepageData
const { sha } = homepageData
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this change appears to have different semantics; content now appears to be writable now whereas previously it was only readable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey yes this is the case. There was a bug when the key was undefined, but its still valid frontmatter state. As such, I just refine an empty array so that our FE does not throw any error.

src/layouts/EditHomepage/EditHomepage.jsx Outdated Show resolved Hide resolved
src/layouts/EditHomepage/EditHomepage.jsx Show resolved Hide resolved
src/layouts/EditHomepage/constants.ts Show resolved Hide resolved
src/layouts/components/Homepage/AnnouncementBody.tsx Outdated Show resolved Hide resolved
src/types/homepage.ts Show resolved Hide resolved
@kishore03109 kishore03109 temporarily deployed to staging September 21, 2023 07:17 — with GitHub Actions Inactive
@kishore03109
Copy link
Contributor Author

@seaerchin ps need to your look at small additional commit (the others shd be trivial)
8c46a2c

@kishore03109 kishore03109 temporarily deployed to staging September 22, 2023 04:01 — with GitHub Actions Inactive
@kishore03109 kishore03109 merged commit c9294c7 into develop Sep 22, 2023
6 checks passed
@mergify mergify bot deleted the feat/announcementBlock branch September 22, 2023 08:40
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