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/display collection in nav bar #362

Merged
merged 9 commits into from
Mar 3, 2021

Conversation

kwajiehao
Copy link
Contributor

@kwajiehao kwajiehao commented Mar 1, 2021

Note: this PR is to be reviewed with PR #117 on the backend

Overview

This PR builds on #358, and makes modifications to the EditNavBar layout so that it stores a foldersDropdown state variable, which it passes to the TemplateNavBar component so that the dropdown elements for a collections/folder entry in the nav bar are rendered.

Before

Screenshot 2021-03-01 at 4 28 53 PM

After

Screenshot 2021-03-01 at 4 20 47 PM

@kwajiehao kwajiehao linked an issue Mar 1, 2021 that may be closed by this pull request
@kwajiehao kwajiehao force-pushed the feat/display-collections-nav-bar branch from b861d0a to 8672b5c Compare March 2, 2021 06:28
Base automatically changed from feat/display-collections-nav-bar to staging March 2, 2021 06:29
This commit refactors the `EditNavBar` component to use react-query
to retrieve nav bar data from the backend. This includes moving the
API call into a callback function defined in the api.js file.
Previously, we used the GET /v1/sites/:siteName/collections endpoint
to retrieve data on collections. However, this endpoint is outdated -
it retrieves data on collections based on the _config.yml file. This
won't work with our Jekyll 4.2 repos going forward, since information
on collection data will be stored in each individual collection directory.

This commit updates the GET request to retrieve from the GET
v1/sites/:siteName/folders/all endpoint instead. This endpoint returns
not just information on what collections exist in the repo, but also
returns information on the order of pages within each collection, which
we need for rendering the collection page dropdown in the NavBar template.
This commit adds a util function which parses the folder order for
each folder/collection and returns them in an array of deslugified
elements in accordance with the nav bar dropdown requirements.
This commit updates the EditNavBar layout with a new folderDropdowns
state variable, which is passed to the TemplateNavBar as the
collectionsInfo prop. This gives the TemplateNavBar component the
necessary information to render the dropdown items for collections/folders
@kwajiehao kwajiehao force-pushed the feat/display-collection-in-nav-bar branch from 9b95f7d to b25e6a1 Compare March 2, 2021 06:55
Copy link
Contributor

@alexanderleegs alexanderleegs left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@gweiying gweiying left a comment

Choose a reason for hiding this comment

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

Observed buggy behavior with files in subfolders, see below

Screenshot 2021-03-03 at 2 58 23 PM

}

if (pathArr.length === 2 && pathArr[0] !== acc[acc.length - 1]) {
acc.push(deslugifyDirectory(pathArr[0]))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should check if deslugifyDirectory(pathArr[0]) already exists or use Set()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, fixed with 5a34a49

@kwajiehao kwajiehao requested a review from gweiying March 3, 2021 07:37
Copy link
Contributor

@gweiying gweiying left a comment

Choose a reason for hiding this comment

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

lgtm

@kwajiehao kwajiehao merged commit 87e712a into staging Mar 3, 2021
@kwajiehao kwajiehao deleted the feat/display-collection-in-nav-bar branch March 3, 2021 16:23
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.

Add collection display into EditNavBar
4 participants