Skip to content

Order files alphabetically in sidebar and nested folders. #1530

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

Merged
merged 6 commits into from
Aug 5, 2020
Merged

Order files alphabetically in sidebar and nested folders. #1530

merged 6 commits into from
Aug 5, 2020

Conversation

neelesh7singh
Copy link
Contributor

This PR solves issue #704. I added a function to get sorted children of the parent file whenever a file is created or renamed. This function is only called on the parent of the file that is created or renamed.

Fixes #704

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • is from a uniquely-named feature branch and has been rebased on top of the latest master. (If I was asked to make more changes, I have made sure to rebase onto master then too)
  • is descriptively named and links to an issue number, i.e. Fixes #123

This commit solves issue #704. I added a function to get sorted children of the parent file when ever a file is created of renamed. This function is only called on the parent of the file that is create or renamed.
@welcome
Copy link

welcome bot commented Aug 3, 2020

🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already.

@@ -138,33 +144,48 @@ const files = (state, action) => {
return initialState();
case ActionTypes.CREATE_FILE: // eslint-disable-line
{
const newState = state.map((file) => {
let newState = state.map((file) => {
Copy link
Member

Choose a reason for hiding this comment

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

The body of this case statement is pretty long, and I wonder if it could be refactored into smaller functions. I know this is also true in other case statements in this file that you didn't work on, but I think this is an opportunity to do a little cleaning up 😄

@catarak
Copy link
Member

catarak commented Aug 3, 2020

This is working for me! My only suggestion is breaking up the code into some smaller functions so that the code is easier to read.

@neelesh7singh
Copy link
Contributor Author

Is this fine??

@neelesh7singh neelesh7singh requested a review from catarak August 4, 2020 05:26
@@ -116,6 +116,26 @@ function sortedChildrenId(state, children) {
return childrenArray.map(child => child.id);
}

function udpateParent(state, action) {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for doing the refactor! One small thing—I think you meant "update" here rather than "udpate".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh sorry wait just updating

Copy link
Member

Choose a reason for hiding this comment

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

no worries!!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!!

@catarak
Copy link
Member

catarak commented Aug 4, 2020

Testing this again, I also noticed that the sorting works for new sketches, or while editing a sketch, but not when opening an existing sketch (e.g. when you load http://localhost:8000/p5/sketches/Hello_P5:_song, you'll need to run npm run fetch-examples to load the examples locally.

@neelesh7singh
Copy link
Contributor Author

Thanks for pointing it out! This commit will fix the problem

@catarak
Copy link
Member

catarak commented Aug 5, 2020

Working great—thanks for working on this!

@catarak catarak merged commit 2948412 into processing:develop Aug 5, 2020
@neelesh7singh
Copy link
Contributor Author

No problem, it really feels great after your first open-source contribution!!

@catarak
Copy link
Member

catarak commented Aug 5, 2020

No problem, it really feels great after your first open-source contribution!!

Welcome to contributing to open source and to p5.js!

@neelesh7singh neelesh7singh deleted the sort-sidebar-folders branch August 8, 2020 16:20
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.

Order files alphabetically in sidebar and nested folders
2 participants