Skip to content

Commit

Permalink
chore(server): add layers in pageJSON of published story (#785)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyshx committed Nov 2, 2023
1 parent 930fce4 commit 0ba17b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/e2e/gql_storytelling_test.go
Expand Up @@ -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").
Expand Down
12 changes: 9 additions & 3 deletions server/pkg/scene/builder/story.go
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(),
}
}

Expand Down

0 comments on commit 0ba17b4

Please sign in to comment.