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: nested collections #3716

Merged
merged 73 commits into from
Jun 18, 2020
Merged

Feat: nested collections #3716

merged 73 commits into from
Jun 18, 2020

Conversation

erezrokah
Copy link
Contributor

@erezrokah erezrokah commented May 7, 2020

Fixes #3227
Initial support for having a folder structure in the CMS and moving entries.

Used GitLab handbook as a reference.

Example config:

backend:
  name: gitlab
  repo: erezrokah/www-gitlab-com

publish_mode: editorial_workflow
media_folder: static/media
public_folder: /media
collections:
  - name: pages
    label: Pages
    label_singular: 'Page'
    folder: source/handbook
    create: true
    nested: { depth: 100 } # accepts an optional summary template
    fields:
      - label: Title
        name: title
        widget: string
      - label: Body
        name: body
        widget: markdown
    meta: { path: { widget: string, label: 'Path', index_file: 'index' } }

Example UI:
image
image

Assumptions

  • Each entry is designated by a folder with an index file specified by index_file
  • The Path input controls the directory of the entry (filename cannot be modified)
  • Changing an entry's directory, moves the entry's children to the new location.

Notes

  • Moved the code that handles unpublished entries to backend.js from the individual backends, so we can identify which content file to read based on the extension. This should also make it easier to handle multiple content files (e.g. multi language files).

TODO

  • Write docs
  • Add validation (e.g. path is a valid directory, error when overwriting an existing path)
  • Fix e2e tests
  • Test search functionality

@erezrokah erezrokah requested a review from a team May 7, 2020 16:39
@erezrokah erezrokah added the type: feature code contributing to the implementation of a feature and/or user facing functionality label May 7, 2020
@erezrokah erezrokah force-pushed the feat/nested_collections branch 3 times, most recently from 3b66511 to 47fed70 Compare May 13, 2020 12:24
@erquhart
Copy link
Contributor

erquhart commented May 13, 2020

This is looking great Erez, just some quick feedback:

  • Each entry should only show in one place, probably only when its parent is selected in the collection pane. Currently an entry with children shows when that entry is selected in the collection pane, and also when its parent is selected in the collection pane.

  • Changing the path field isn't causing the path to actually change in the deploy preview - I'm guessing this just hasn't been added to the test backend, but wanted to raise it in case there was any gap in requirements.

@erezrokah
Copy link
Contributor Author

The preview was an oversight on my behalf and it is now fixed.
As for the first bullet, I made the relevant changes so it would only show an entry when a parent is selected, expect when selecting the collection itself where it still shows the root entry.

dispatch(entryPersisted(collection, serializedEntry, slug));
if (serializedEntry.get('newRecord')) return dispatch(loadEntry(collection, slug));
dispatch(entryPersisted(collection, serializedEntry, newSlug));
if (collection.has('nested')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

similar to editorial workflow, we need to re-load all entries after publish and navigate to the new slug if it had changed

@erezrokah erezrokah merged commit af7bbbd into master Jun 18, 2020
@erezrokah erezrokah deleted the feat/nested_collections branch June 18, 2020 07:11
willwade added a commit to AceCentre/pasco that referenced this pull request Jun 18, 2020
Now that decaporg/decap-cms#3716 is merged - seeing if this works
@reimertz
Copy link

Congrats on merging this @erezrokah, Amazing work!

fbuireu added a commit to fbuireu/biancafiore that referenced this pull request Dec 29, 2020
fbuireu added a commit to fbuireu/biancafiore that referenced this pull request Dec 29, 2020
fbuireu added a commit to fbuireu/biancafiore that referenced this pull request Dec 29, 2020
vladdu pushed a commit to vladdu/netlify-cms that referenced this pull request Jan 26, 2021
@simrspersahabatan
Copy link

I just tested with docusaurus v2 ... but i'm failed to show nested file. I do like your direction. I have no idea.

@simrspersahabatan
Copy link

Okay,this my detail

backend:
  name: github
  branch: main # Branch to update (optional; defaults to master)
  repo: organization/repo
  base_url: vercel.app
  auth_endpoint: api/auth

media_folder: "static/img"
collections:
  - name: docs
    label: Docs
    label_singular: 'Doc'
    folder: 'docs'
    path: '{{title}}/{{id}}'
    slug: '{{id}}'
    create: true
    nested: { depth: 100 } # accepts an optional summary template
    fields:
      - { label: "Judul", name: "title", widget: "string" }
      - {
          label: "Posisi",
          name: "sidebar_position",
          widget: "string",
          required: false,
        }
      - { label: "Keterangan", name: "body", widget: "markdown" }
    allow_nesting: true
    meta: { path: { widget: string, label: 'Path', index_file: 'index' } }

26-11-2021 14-43-10

@erezrokah
Copy link
Contributor Author

Hi @simrspersahabatan, can you open a new issue for this and use the issue template.

That will make it easier to collect all the relevant information regarding the problem you're experiencing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Draft: Nested collections
4 participants