Skip to content

Commit

Permalink
SITES-19836 Ghost component in container is displayed on publish and …
Browse files Browse the repository at this point in the history
…preview instances (#2838)
  • Loading branch information
spopescu authored Aug 13, 2024
1 parent 5fe3b41 commit 37aee59
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import javax.annotation.PostConstruct;

import com.day.cq.wcm.api.WCMMode;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
Expand All @@ -44,6 +45,7 @@ public class LayoutContainerImpl extends AbstractContainerImpl implements Layout
* The resource type.
*/
protected static final String RESOURCE_TYPE_V1 = "core/wcm/components/container/v1/container";
protected static final String GHOST_COMPONENT_RESOURCE_TYPE = "wcm/msm/components/ghost";

/**
* The layout type.
Expand Down Expand Up @@ -103,7 +105,10 @@ protected final List<ResourceListItemImpl> readItems() {
@Override
public final List<ContainerItem> getChildren() {
if (this.items == null) {
WCMMode wcmMode = WCMMode.fromRequest(this.request);
boolean showGhostComponent = wcmMode == WCMMode.EDIT;
this.items = ComponentUtils.getChildComponents(this.resource, this.request).stream()
.filter(item -> showGhostComponent || !GHOST_COMPONENT_RESOURCE_TYPE.equals(item.getResourceType()))
.map(ContainerItemImpl::new)
.collect(Collectors.toList());
}
Expand Down
6 changes: 6 additions & 0 deletions bundles/core/src/test/resources/container/test-content.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
"jcr:description" : "Teaser 2 description",
"sling:resourceType": "core/wcm/components/teaser/v1/teaser"
},
"item_ghost": {
"jcr:primaryType" : "nt:unstructured",
"jcr:title" : "Ghost",
"jcr:description" : "Ghost component",
"sling:resourceType": "wcm/msm/components/ghost"
},
"item_3": {}
},
"container-2" : {
Expand Down

0 comments on commit 37aee59

Please sign in to comment.