From 0ba17b4ba436ba785e83a32c3f8d0b0c4bc3b96b Mon Sep 17 00:00:00 2001 From: Piyush Chauhan <42397980+pyshx@users.noreply.github.com> Date: Thu, 2 Nov 2023 13:13:33 +0530 Subject: [PATCH] chore(server): add layers in pageJSON of published story (#785) --- server/e2e/gql_storytelling_test.go | 2 +- server/pkg/scene/builder/story.go | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/server/e2e/gql_storytelling_test.go b/server/e2e/gql_storytelling_test.go index 34564ac800..a6fab1d602 100644 --- a/server/e2e/gql_storytelling_test.go +++ b/server/e2e/gql_storytelling_test.go @@ -1037,7 +1037,7 @@ func TestStoryPublishing(t *testing.T) { _, err = buf.ReadFrom(rc) assert.NoError(t, err) - pub := regexp.MustCompile(fmt.Sprintf(`{"schemaVersion":1,"id":"%s","publishedAt":".*","property":{"tiles":\[{"id":".*"}]},"plugins":{},"layers":null,"widgets":\[],"widgetAlignSystem":null,"tags":\[],"clusters":\[],"story":{"id":"%s","property":{},"pages":\[{"id":"%s","property":{},"blocks":\[{"id":"%s","property":{"default":{"text":"test value"},"panel":{"padding":{"top":2,"bottom":3,"left":0,"right":1}}},"plugins":null,"extensionId":"%s","pluginId":"%s"}]}]},"nlsLayers":null,"layerStyles":null,"coreSupport":true}`, sID, storyID, pageID, blockID, extensionId, pluginId)) + pub := regexp.MustCompile(fmt.Sprintf(`{"schemaVersion":1,"id":"%s","publishedAt":".*","property":{"tiles":\[{"id":".*"}]},"plugins":{},"layers":null,"widgets":\[],"widgetAlignSystem":null,"tags":\[],"clusters":\[],"story":{"id":"%s","property":{},"pages":\[{"id":"%s","property":{},"blocks":\[{"id":"%s","property":{"default":{"text":"test value"},"panel":{"padding":{"top":2,"bottom":3,"left":0,"right":1}}},"plugins":null,"extensionId":"%s","pluginId":"%s"}],"swipeable":true,"swipeableLayers":\[],"layers":\[]}]},"nlsLayers":null,"layerStyles":null,"coreSupport":true}`, sID, storyID, pageID, blockID, extensionId, pluginId)) assert.Regexp(t, pub, buf.String()) resString := e.GET("/p/test-alias/data.json"). diff --git a/server/pkg/scene/builder/story.go b/server/pkg/scene/builder/story.go index d1c1f493a5..77fcf4f72f 100644 --- a/server/pkg/scene/builder/story.go +++ b/server/pkg/scene/builder/story.go @@ -15,9 +15,12 @@ type storyJSON struct { } type pageJSON struct { - ID string `json:"id"` - Property propertyJSON `json:"property"` - Blocks []blockJSON `json:"blocks"` + ID string `json:"id"` + Property propertyJSON `json:"property"` + Blocks []blockJSON `json:"blocks"` + Swipeable bool `json:"swipeable"` + SwipeableLayers []string `json:"swipeableLayers"` + Layers []string `json:"layers"` } type blockJSON struct { @@ -55,6 +58,9 @@ func (b *Builder) pageJSON(ctx context.Context, page storytelling.Page, p []*pro } return b.blockJSON(ctx, *block, p), true }), + Swipeable: page.Swipeable(), + SwipeableLayers: page.SwipeableLayers().Strings(), + Layers: page.Layers().Strings(), } }