Skip to content

Commit 9ea5f70

Browse files
authored
chore: Pages.staging (#5736)
## Description 1. What is this PR about (link the issue and add a short description) ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
1 parent a2cfcbb commit 9ea5f70

94 files changed

Lines changed: 2748 additions & 1723 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/vercel/action.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ inputs:
2020
environment:
2121
description: "Sha"
2222
required: true
23+
PUBLIC_COLLAB_RELAY_URL:
24+
description: "Public collaboration relay URL injected into the builder bundle"
25+
required: false
26+
default: ""
2327

2428
outputs:
2529
domain:
@@ -75,6 +79,7 @@ runs:
7579
run: |
7680
export GITHUB_SHA=${{ inputs.sha }}
7781
export GITHUB_REF_NAME=${{ inputs.ref-name }}
82+
export PUBLIC_COLLAB_RELAY_URL=${{ inputs.PUBLIC_COLLAB_RELAY_URL }}
7883
7984
pnpx vercel build
8085
shell: bash

.github/workflows/fixtures-test.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ name: Fixtures tests
33
on:
44
workflow_call:
55
inputs:
6-
builder-url:
7-
required: true
8-
type: string
96
builder-host:
107
required: true
118
type: string
@@ -35,7 +32,6 @@ jobs:
3532
env:
3633
DATABASE_URL: postgres://
3734
AUTH_SECRET: test
38-
BUILDER_URL_DEPRECATED: ${{ inputs.builder-url }}
3935
BUILDER_HOST: ${{ inputs.builder-host }}
4036

4137
steps:

.github/workflows/vercel-deploy-staging.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
if: |
4040
github.event_name == 'push' ||
4141
(github.event_name == 'pull_request_target' && github.event.action == 'labeled' && github.event.label.name == 'safe-to-deploy')
42-
42+
4343
# Execute development and staging on staging branches
4444
# Execute only development on all other branches
4545
strategy:
@@ -86,6 +86,7 @@ jobs:
8686
ref-name: ${{ github.event_name == 'pull_request_target' && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}
8787
sha: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}
8888
environment: ${{ matrix.environment }}
89+
PUBLIC_COLLAB_RELAY_URL: ${{ vars.PUBLIC_COLLAB_RELAY_URL }}
8990

9091
- name: Debug Vercel Outputs
9192
run: |
@@ -119,14 +120,12 @@ jobs:
119120
});
120121
121122
outputs:
122-
builder-url: "https://${{ steps.vercel.outputs.alias }}.${{ matrix.environment }}.webstudio.is"
123123
builder-host: "${{ steps.vercel.outputs.alias }}.${{ matrix.environment }}.webstudio.is"
124124

125125
fixtures-test:
126126
needs: deployment
127127
uses: ./.github/workflows/fixtures-test.yml
128128
with:
129-
builder-url: ${{ needs.deployment.outputs.builder-url }}
130129
builder-host: ${{ needs.deployment.outputs.builder-host }}
131130
environment: development
132131
secrets:

apps/builder/app/builder/builder.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import type { TokenPermissions } from "@webstudio-is/authorization-token";
5858
import { useToastErrors } from "~/shared/error/toast-error";
5959
import { initBuilderApi } from "~/shared/builder-api";
6060
import { updateWebstudioData } from "~/shared/instance-utils";
61-
import { migrateWebstudioDataMutable } from "~/shared/webstudio-data-migrator";
61+
import { migrateWebstudioDataMutable } from "@webstudio-is/sdk/migrations/webstudio-data";
6262
import { Loading, LoadingBackground } from "./shared/loading";
6363
import { mergeRefs } from "@react-aria/utils";
6464
import { CommandPanel } from "./features/command-panel";

apps/builder/app/builder/features/address-bar.stories.tsx

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,43 @@ registerContainers();
1616
$dataSources.set(new Map());
1717

1818
$pages.set({
19-
folders: [
20-
{
21-
id: "rootId",
22-
name: "",
23-
slug: "",
24-
children: ["homeId", "dynamicId"],
25-
},
26-
],
27-
homePage: {
28-
id: "homeId",
29-
path: "",
30-
name: "",
31-
title: "",
32-
meta: {},
33-
rootInstanceId: "",
34-
},
35-
pages: [
36-
{
37-
id: "dynamicId",
38-
path: "/blog/:date/post/:slug",
39-
name: "",
40-
title: "",
41-
meta: {},
42-
rootInstanceId: "rootInstanceId",
43-
},
44-
],
19+
homePageId: "homeId",
20+
rootFolderId: "rootId",
21+
folders: new Map([
22+
[
23+
"rootId",
24+
{
25+
id: "rootId",
26+
name: "",
27+
slug: "",
28+
children: ["homeId", "dynamicId"],
29+
},
30+
],
31+
]),
32+
pages: new Map([
33+
[
34+
"homeId",
35+
{
36+
id: "homeId",
37+
path: "",
38+
name: "",
39+
title: "",
40+
meta: {},
41+
rootInstanceId: "",
42+
},
43+
],
44+
[
45+
"dynamicId",
46+
{
47+
id: "dynamicId",
48+
path: "/blog/:date/post/:slug",
49+
name: "",
50+
title: "",
51+
meta: {},
52+
rootInstanceId: "rootInstanceId",
53+
},
54+
],
55+
]),
4556
});
4657

4758
const SystemInspect = () => {

apps/builder/app/builder/features/command-panel/command-panel.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ $breakpoints.set(
3838
);
3939

4040
const pages = createDefaultPages({ rootInstanceId: "" });
41-
pages.pages.push({
41+
pages.pages.set("page2", {
4242
id: "page2",
4343
path: "",
4444
name: "Second Page",
4545
rootInstanceId: "",
4646
title: "",
4747
meta: {},
4848
});
49-
pages.pages.push({
49+
pages.pages.set("page3", {
5050
id: "page3",
5151
path: "",
5252
name: "Thrid Page",
@@ -55,7 +55,7 @@ pages.pages.push({
5555
meta: {},
5656
});
5757
$pages.set(pages);
58-
$selectedPageId.set(pages.homePage.id);
58+
$selectedPageId.set(pages.homePageId);
5959

6060
export const CommandPanel: StoryFn = () => {
6161
useEffect(() => {

apps/builder/app/builder/features/command-panel/groups/pages-group.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
useSelectedAction,
77
} from "@webstudio-is/design-system";
88
import { computed } from "nanostores";
9-
import type { Page } from "@webstudio-is/sdk";
9+
import { getAllPages, type Page } from "@webstudio-is/sdk";
1010
import { $pages } from "~/shared/sync/data-stores";
1111
import { $editingPageId } from "~/shared/nano-states";
1212
import { $selectedPage } from "~/shared/nano-states";
@@ -28,7 +28,7 @@ export const $pageOptions = computed(
2828
}
2929
const pageOptions: PageOption[] = [];
3030
if (pages) {
31-
for (const page of [pages.homePage, ...pages.pages]) {
31+
for (const page of getAllPages(pages)) {
3232
if (page.id === selectedPage?.id) {
3333
continue;
3434
}

apps/builder/app/builder/features/command-panel/shared/instance-list.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
useSelectedAction,
1414
useCommandState,
1515
} from "@webstudio-is/design-system";
16-
import type { Instance } from "@webstudio-is/sdk";
16+
import { getPageById, type Instance } from "@webstudio-is/sdk";
1717
import { $instances, $pages } from "~/shared/sync/data-stores";
1818
import { getInstanceLabel } from "~/builder/shared/instance-label";
1919
import { buildInstancePath } from "~/shared/instance-utils";
@@ -61,7 +61,7 @@ export const InstanceList = ({
6161
instances,
6262
instanceId
6363
);
64-
const page = pages.pages.find((p) => p.id === awareness.pageId);
64+
const page = getPageById(pages, awareness.pageId);
6565
usedInInstances.push({
6666
label: getInstanceLabel(instance),
6767
id: instance.id,

apps/builder/app/builder/features/marketplace/templates.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
import { ChevronLeftIcon, ExternalLinkIcon } from "@webstudio-is/icons";
1414
import {
1515
elementComponent,
16+
getAllPages,
1617
Instance,
1718
ROOT_FOLDER_ID,
1819
type Asset,
@@ -116,7 +117,7 @@ const getTemplatesDataByCategory = (
116117
if (data === undefined) {
117118
return new Map();
118119
}
119-
const pages = [data.pages.homePage, ...data.pages.pages]
120+
const pages = getAllPages(data.pages)
120121
.filter((page) => page.marketplace?.include)
121122
.map((page) => {
122123
// category can be empty string

apps/builder/app/builder/features/marketplace/utils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import {
22
getStyleDeclKey,
3+
migratePages,
34
type Asset,
5+
type SerializedPages,
46
type WebstudioData,
57
} from "@webstudio-is/sdk";
68
import type { CompactBuild } from "@webstudio-is/project-build";
@@ -9,14 +11,17 @@ const getPair = <Item extends { id: string }>(item: Item) =>
911
[item.id, item] as const;
1012

1113
export const toWebstudioData = (
12-
data: CompactBuild & { assets: Asset[] }
14+
data: Omit<CompactBuild, "pages"> & {
15+
assets: Asset[];
16+
pages: SerializedPages;
17+
}
1318
): WebstudioData => ({
1419
assets: new Map(data.assets.map(getPair)),
1520
instances: new Map(data.instances.map(getPair)),
1621
dataSources: new Map(data.dataSources.map(getPair)),
1722
resources: new Map(data.resources.map(getPair)),
1823
props: new Map(data.props.map(getPair)),
19-
pages: data.pages,
24+
pages: migratePages(data.pages),
2025
breakpoints: new Map(data.breakpoints.map(getPair)),
2126
styleSources: new Map(data.styleSources.map(getPair)),
2227
styleSourceSelections: new Map(

0 commit comments

Comments
 (0)