headwirecom / peregrine-cms

an api first, head optional cms with based on vuejs and apache sling
Apache License 2.0
52 stars 31 forks source link

Newly-created site shows wrong label on folders #42

Closed devintuffy closed 5 years ago

devintuffy commented 5 years ago

To reproduce:

Result:

While the breadcrumbing shows the "correct" name of the folder or item, the explorer shows the site name for every sub-item in the site:

Screen Shot 2019-03-18 at 1 06 11 PM Screen Shot 2019-03-18 at 1 06 20 PM
devintuffy commented 5 years ago

Oh nooooo

Screen Shot 2019-03-18 at 1 10 31 PM

devintuffy commented 5 years ago

Looking at the response from http://localhost:8080/perapi/admin/nodes.json/content/sites/test%20area/Sample%20Sites/site%202/child%201, I can see that this 'title' value is coming from the server:

Screen Shot 2019-03-18 at 2 04 16 PM

devintuffy commented 5 years ago

Composum confirms this is persisted:

Screen Shot 2019-03-18 at 2 19 03 PM
devintuffy commented 5 years ago

This is happening in the createSite api call:

When creating a new site from a template, we call com.peregrine.admin.resource.AdminResourceHandlerService#copySite, with the new site name as "targetName". This targetName is passed into com.peregrine.admin.resource.AdminResourceHandlerService#copyChildResources, which copies each page and then updates the title -- so in this case, updating every page's title to the same thing.

Luckily, copySite is the only thing that calls copyChildResources, so fixing shouldn't be difficult.