Skip to content

Commit

Permalink
feat: Allow to force displaying Shared Layout for a Single Page - MEE…
Browse files Browse the repository at this point in the history
…D-8178 - Meeds-io/meeds#2772 (#1033)

This change will allow to select a single page from a standalone Site to
be displayed in the context of Meta Site with the shared layout. In
fact, an option already exists to force hiding shared layout when a page
is displayed in a non-standalone site. This new option will allow the
inverse by allowing to display a page with shared layout when the site
is in standalone mode.
  • Loading branch information
boubaker authored Jan 17, 2025
1 parent 009d367 commit 1295c2c
Show file tree
Hide file tree
Showing 17 changed files with 281 additions and 284 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,22 @@ public class Page extends Container {

private boolean showMaxWindow = false;

/**
* Whether to 'hide' shared layout or not even when the site 'displays' the
* shared layout
*/
@Getter
@Setter
private boolean hideSharedLayout = false;

/**
* Whether to 'show' shared layout or not even when the site 'hides' the
* shared layout layout
*/
@Getter
@Setter
private boolean showSharedLayout = false;

private String type;

private String link;
Expand All @@ -74,6 +86,8 @@ public Page(PageData data) {
this.ownerId = data.getOwnerId();
this.editPermission = data.getEditPermission();
this.showMaxWindow = data.isShowMaxWindow();
this.hideSharedLayout = data.isHideSharedLayout();
this.showSharedLayout = data.isShowSharedLayout();
this.type = data.getType();
this.link = data.getLink();
}
Expand Down Expand Up @@ -180,6 +194,7 @@ public PageData build() {
editPermission,
showMaxWindow,
hideSharedLayout,
showSharedLayout,
type,
link);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public static PageState toPageState(Page page) {
page.getDescription(),
page.isShowMaxWindow(),
page.isHideSharedLayout(),
page.isShowSharedLayout(),
page.getFactoryId(),
page.getProfiles(),
page.getAccessPermissions() != null ? Arrays.asList(page.getAccessPermissions()) : null,
Expand All @@ -91,6 +92,7 @@ public static PageState toPageState(PageData page) {
page.getDescription(),
page.isShowMaxWindow(),
page.isHideSharedLayout(),
page.isShowSharedLayout(),
page.getFactoryId(),
page.getProfiles(),
page.getAccessPermissions(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,83 +10,85 @@
@Data
public class PageContext {

/** . */
final PageKey key;
/** . */
final PageKey key;

/** The new state if any. */
PageState state;
/** The new state if any. */
PageState state;

/** A data snapshot. */
PageData data;
/** A data snapshot. */
PageData data;

PageContext(PageData data) {
this.key = data.key;
this.state = null;
this.data = data;
}
PageContext(PageData data) {
this.key = data.key;
this.state = null;
this.data = data;
}

public PageContext(PageKey key, PageState state) {
this.key = key;
this.state = state;
this.data = null;
}
public PageContext(PageKey key, PageState state) {
this.key = key;
this.state = state;
this.data = null;
}

/**
* Returns the navigation key.
*
* @return the navigation key
*/
public PageKey getKey() {
return key;
}
/**
* Returns the navigation key.
*
* @return the navigation key
*/
public PageKey getKey() {
return key;
}

/**
* Returns the navigation state.
*
* @return the navigation state
*/
public PageState getState() {
if (state != null) {
return state;
} else if (data != null) {
return data.state;
} else {
return null;
}
/**
* Returns the navigation state.
*
* @return the navigation state
*/
public PageState getState() {
if (state != null) {
return state;
} else if (data != null) {
return data.state;
} else {
return null;
}
}

/**
* Updates the page state the behavior is not the same wether or not the page is persistent:
* When the page is persistent, any state is allowed:
* <ul>
* <li>A non null state overrides the current persistent state.</li>
* <li>The null state means to reset the state to the persistent state.</li>
* <li>When the page is transient, only a non null state is allowed as it will be used for creation purpose.</li>
* </ul>
*
* @param state the new state
* @throws IllegalStateException when the state is cleared and the navigation is not persistent
*/
public void setState(PageState state) throws IllegalStateException {
if (data == null && state == null) {
throw new IllegalStateException("Cannot clear state on a transient page");
}
this.state = state;
/**
* Updates the page state the behavior is not the same wether or not the page
* is persistent: When the page is persistent, any state is allowed:
* <ul>
* <li>A non null state overrides the current persistent state.</li>
* <li>The null state means to reset the state to the persistent state.</li>
* <li>When the page is transient, only a non null state is allowed as it will
* be used for creation purpose.</li>
* </ul>
*
* @param state the new state
* @throws IllegalStateException when the state is cleared and the navigation
* is not persistent
*/
public void setState(PageState state) throws IllegalStateException {
if (data == null && state == null) {
throw new IllegalStateException("Cannot clear state on a transient page");
}
this.state = state;
}

public void update(Page page) throws NullPointerException {
if (page == null) {
throw new NullPointerException();
}
PageState s = getState();
page.setTitle(s.displayName);
page.setDescription(s.description);
page.setFactoryId(s.factoryId);
page.setShowMaxWindow(s.showMaxWindow);
page.setHideSharedLayout(s.hideSharedLayout);

List<String> permisssions = s.accessPermissions;
page.setAccessPermissions(permisssions != null ? permisssions.toArray(new String[permisssions.size()]) : null);
page.setEditPermission(getState().editPermission);
public void update(Page page) throws NullPointerException {
if (page == null) {
throw new NullPointerException();
}
PageState s = getState();
page.setTitle(s.getDisplayName());
page.setDescription(s.getDescription());
page.setFactoryId(s.getFactoryId());
page.setShowMaxWindow(s.isShowMaxWindow());
page.setHideSharedLayout(s.isHideSharedLayout());
page.setShowSharedLayout(s.isShowSharedLayout());
List<String> permisssions = s.getAccessPermissions();
page.setAccessPermissions(permisssions == null ? null : permisssions.toArray(new String[permisssions.size()]));
page.setEditPermission(s.getEditPermission());
}
}
Loading

0 comments on commit 1295c2c

Please sign in to comment.