Skip to content

Sketch collections #1164

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

Conversation

andrewn
Copy link
Member

@andrewn andrewn commented Sep 20, 2019

Implementing features in #1115.

Editor API for Collections

Route Purpose Restrictions
GET /collections Fetch current user's collections Logged in user
GET /:username/collections Fetch a specific user's collections
POST /collections Create a new collection Logged in user
PATCH /collections/:id Update collection metadata Logged in user must own collection
DELETE /collections/:id Delete collection Logged in user must own collection
POST /collections/:id/:projectId Add a project to a collection Logged in user must own collection
DELETE /collections/:id/:projectId Remove a project from a collection Logged in user must own collection

Features

  • Editor API to CRUD collections
  • Lists of your own and other user's collections (/:username/collections)
  • View any user's collection (/:username/collections/:collectionId)
  • Create your own collections (/:username/collections/create)
  • Edit your collection's name and description (Click name and description on collection page)
  • Easily get a shareable URL for the collection ("Share" link on collection page)
  • See and edit the collection slug
  • Delete your own collections (via dropdown on collection list)
  • Add any sketch to one of your collections (via File → Add to collection)
  • Add your own sketches to one of your collections (/:username/collections/:collectionId
    "Add more sketches")

Checks

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

* Converts import script to use public API endpoints

The endpoints don't exist yet, but this is a good way to see how
the implementation of the data structures differ.

* Exposes public API endpoint to fetch user's sketches

* Implements public API delete endpoint

* Adds helper to create custom ApplicationError classes

* Adds create project endpoint that understand API's data structure

This transforms the nested tree of file data into a mongoose
Project model

* Returns '201 Created' to match API spec

* Removes 'CustomError' variable assignment as it shows up in test output

* transformFiles will return file validation errors

* Tests API project controller

* Tests toModel()

* Creates default files if no root-level .html file is provided

* Do not auto-generate a slug if it is provided

Fixes a bug where the slug was auto-generated using the sketch name,
even if a slug property had been provided.

* Validates uniqueness of slugs for projects created by the public API

* Adds tests for slug uniqueness

* Configures node's Promise implementation for mongoose (fixes warnings)

* Moves createProject tests to match controller location

* Adds support for code to ApplicationErrors

* deleteProject controller tests

* getProjectsForUser controller tests

- implements tests
- update apiKey tests to use new User mocks

* Ensure error objects have consistent property names

`message` is used as a high-level description of the errors
`detail` is optional and has an plain language explanation of the
individual errors
`errors` is an array of each individual problem from `detail` in a
machine-readable format

* Assert environment variables are provided at script start

* Version public API

* Expect "files" property to always be provided

* Fixes linting error

* Converts import script to use public API endpoints

The endpoints don't exist yet, but this is a good way to see how
the implementation of the data structures differ.

* Exposes public API endpoint to fetch user's sketches

* Implements public API delete endpoint

* Adds helper to create custom ApplicationError classes

* Adds create project endpoint that understand API's data structure

This transforms the nested tree of file data into a mongoose
Project model

* Returns '201 Created' to match API spec

* Removes 'CustomError' variable assignment as it shows up in test output

* transformFiles will return file validation errors

* Tests API project controller

* Tests toModel()

* Creates default files if no root-level .html file is provided

* Do not auto-generate a slug if it is provided

Fixes a bug where the slug was auto-generated using the sketch name,
even if a slug property had been provided.

* Validates uniqueness of slugs for projects created by the public API

* Adds tests for slug uniqueness

* Configures node's Promise implementation for mongoose (fixes warnings)

* Moves createProject tests to match controller location

* deleteProject controller tests

* Adds support for code to ApplicationErrors

* getProjectsForUser controller tests

- implements tests
- update apiKey tests to use new User mocks

* Ensure error objects have consistent property names

`message` is used as a high-level description of the errors
`detail` is optional and has an plain language explanation of the
individual errors
`errors` is an array of each individual problem from `detail` in a
machine-readable format

* Assert environment variables are provided at script start

* Version public API

* Expect "files" property to always be provided

* Fixes linting error

* Checks that authenticated user has permission to create under this namespace

Previously, the project was always created under the authenticated user's
namespace, but this not obvious behaviour.
* Converts import script to use public API endpoints

The endpoints don't exist yet, but this is a good way to see how
the implementation of the data structures differ.

* Exposes public API endpoint to fetch user's sketches

* Implements public API delete endpoint

* Adds helper to create custom ApplicationError classes

* Adds create project endpoint that understand API's data structure

This transforms the nested tree of file data into a mongoose
Project model

* Returns '201 Created' to match API spec

* Removes 'CustomError' variable assignment as it shows up in test output

* transformFiles will return file validation errors

* Tests API project controller

* Tests toModel()

* Creates default files if no root-level .html file is provided

* Do not auto-generate a slug if it is provided

Fixes a bug where the slug was auto-generated using the sketch name,
even if a slug property had been provided.

* Validates uniqueness of slugs for projects created by the public API

* Adds tests for slug uniqueness

* Configures node's Promise implementation for mongoose (fixes warnings)

* Moves createProject tests to match controller location

* Adds support for code to ApplicationErrors

* deleteProject controller tests

* getProjectsForUser controller tests

- implements tests
- update apiKey tests to use new User mocks

* Ensure error objects have consistent property names

`message` is used as a high-level description of the errors
`detail` is optional and has an plain language explanation of the
individual errors
`errors` is an array of each individual problem from `detail` in a
machine-readable format

* Assert environment variables are provided at script start

* Version public API

* Expect "files" property to always be provided

* Fixes linting error

* Converts import script to use public API endpoints

The endpoints don't exist yet, but this is a good way to see how
the implementation of the data structures differ.

* Exposes public API endpoint to fetch user's sketches

* Implements public API delete endpoint

* Adds helper to create custom ApplicationError classes

* Adds create project endpoint that understand API's data structure

This transforms the nested tree of file data into a mongoose
Project model

* Returns '201 Created' to match API spec

* Removes 'CustomError' variable assignment as it shows up in test output

* transformFiles will return file validation errors

* Tests API project controller

* Tests toModel()

* Creates default files if no root-level .html file is provided

* Do not auto-generate a slug if it is provided

Fixes a bug where the slug was auto-generated using the sketch name,
even if a slug property had been provided.

* Validates uniqueness of slugs for projects created by the public API

* Adds tests for slug uniqueness

* Configures node's Promise implementation for mongoose (fixes warnings)

* Moves createProject tests to match controller location

* deleteProject controller tests

* Adds support for code to ApplicationErrors

* getProjectsForUser controller tests

- implements tests
- update apiKey tests to use new User mocks

* Ensure error objects have consistent property names

`message` is used as a high-level description of the errors
`detail` is optional and has an plain language explanation of the
individual errors
`errors` is an array of each individual problem from `detail` in a
machine-readable format

* Assert environment variables are provided at script start

* Version public API

* Expect "files" property to always be provided

* Fixes linting error

* Checks that authenticated user has permission to create under this namespace

Previously, the project was always created under the authenticated user's
namespace, but this not obvious behaviour.

* Splits private and public APIs

The private API is under /editor and the public API under /api
- List any user's collections
- Create new collection
- Modify collection metadata
- Delete collection
- Add/remove any project to/from a collection
- List all collections for a given user
- View an individual collection
- Link to a sketch from a collection
@andrewn andrewn requested a review from catarak September 20, 2019 12:32
@andrewn
Copy link
Member Author

andrewn commented Sep 20, 2019

@catarak As discussed, this branch is "feature-complete" so I'd really love your feedback on the UI flow. Does it makes sense? Are any flows missing.

I'm going to work on tidying up the code as there are prop-types to be added and some components to refactor.

I'll also work on finessing the UI details once you're happy with the overall shape of the UI.

@andrewn andrewn mentioned this pull request Sep 20, 2019
10 tasks
- List any user's collections
- Create new collection
- Modify collection metadata
- Delete collection
- Add/remove any project to/from a collection
@catarak
Copy link
Member

catarak commented Dec 10, 2019

just pushed a potential option for the collection sharing, see 001a30f

@andrewn
Copy link
Member Author

andrewn commented Dec 11, 2019

I've been working on some nav-bar ideas so that it's easier to get back to the Collection List from an individual Collection page.

A. Always show Sketches and Collections links on Dashboard and Collection page?

Option 1: Show the owner of the collection's username is in the link text as you're on their dashboard page...

Screenshot 2019-12-11 14 37 11

Option 2. No owner in the link name, but in both instances you get these awkward situations where the links appear twice...

Screenshot 2019-12-11 14 39 01

B. Show "< Collections" as a link on the individual collection?

On the dashboard, the p5 logo takes you to the editor:

Screenshot 2019-12-11 14 42 22

On the collection page, you see a back to collections link:

Screenshot 2019-12-11 14 42 27

@andrewn
Copy link
Member Author

andrewn commented Dec 11, 2019

On the add sketch/add collection overlay, should this overlay have a fixed height?

Done

@andrewn
Copy link
Member Author

andrewn commented Dec 11, 2019

On collection list page, maybe the item dropdown should include "add sketch"?

Done

@andrewn
Copy link
Member Author

andrewn commented Dec 11, 2019

@catarak I think I've addressed all the changes, apart from the Nav/Getting back to collections issue... see comment above.

@catarak
Copy link
Member

catarak commented Jan 13, 2020

Only small stuff left:

  • Description should be inactive color if a collection doesn't have one
  • Description pencil is misaligned
  • username should link to that user's sketches (maybe?)

Screen Shot 2020-01-13 at 2 32 57 PM

  • i think the contrast between the inactive check and active check is pretty subtle—there's not really another color in the theme and maybe one should be added, i'm thinking the blue that's in the code syntax or a green

Screen Shot 2020-01-13 at 2 42 35 PM

  • On the collection list view, the dropdown says "add sketches". On the single collection view, there's a button that says "add sketch". The overlay that appears says "add sketches." The copy should all match, probably, right?

  • Navigating from single collection back to tabbed dashboard view - I think having "Back to Editor" is more important than "Back to Collections", esp since people are going to be used to navigating from the Editor view.

@andrewn
Copy link
Member Author

andrewn commented Jan 15, 2020

@catarak I've made all the changes in the list, apart from the nav bar which we can chat about later.

Here are the new icon contrasts:

Screenshot 2020-01-15 12 19 17

Screenshot 2020-01-15 12 21 04

Screenshot 2020-01-15 12 22 03

@andrewn
Copy link
Member Author

andrewn commented Jan 15, 2020

Reverted the top-level nav to "Back to Editor"

@catarak All done!

@catarak catarak merged commit 1a3a1aa into processing:feature/public-api Jan 28, 2020
@catarak
Copy link
Member

catarak commented Jan 28, 2020

🎉 🎉 🎉 i'm going to doing a bunch of testing on staging!!

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