Skip to content

Commit b7e1c86

Browse files
authored
experimental: generate global system variable with CLI (#4885)
Here added support for generating global system variable with CLI. It's not available yet in builder though. Global system not presented in data but instead can be referenced with `$ws$system` in expression instead of encoded id like `$ws$dataSource$id`. Legacy page system variable will continue to work.
1 parent 5c1c557 commit b7e1c86

Some content is hidden

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

41 files changed

+254
-144
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ $pages.set({
6161
const $selectedPageSystem = computed(
6262
[$selectedPage, $dataSourceVariables],
6363
(selectedPage, dataSourceVariables) => {
64-
if (selectedPage === undefined) {
64+
if (selectedPage?.systemDataSourceId === undefined) {
6565
return {};
6666
}
6767
return dataSourceVariables.get(selectedPage.systemDataSourceId);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const $selectedPagePath = computed([$selectedPage, $pages], (page, pages) => {
6565
const $selectedPagePathParams = computed(
6666
[$selectedPageDefaultSystem, $selectedPage, $dataSourceVariables],
6767
(defaultSystem, selectedPage, dataSourceVariables) => {
68-
if (selectedPage === undefined) {
68+
if (selectedPage?.systemDataSourceId === undefined) {
6969
return defaultSystem.params;
7070
}
7171
const system = dataSourceVariables.get(selectedPage.systemDataSourceId) as

apps/builder/app/builder/features/settings-panel/resource-panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ const $hiddenDataSourceIds = computed(
375375
dataSourceIds.add(dataSource.id);
376376
}
377377
}
378-
if (page && isFeatureEnabled("filters")) {
378+
if (page?.systemDataSourceId && isFeatureEnabled("filters")) {
379379
dataSourceIds.delete(page.systemDataSourceId);
380380
}
381381
return dataSourceIds;

apps/builder/app/canvas/interceptor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const getSelectedPagePathname = () => {
2727
const pages = $pages.get();
2828
const page = $selectedPage.get();
2929
const dataSourceVariables = $dataSourceVariables.get();
30-
if (page && pages) {
30+
if (page?.systemDataSourceId && pages) {
3131
const system = dataSourceVariables.get(page.systemDataSourceId) as
3232
| undefined
3333
| System;

apps/builder/app/shared/nano-states/variables.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ export const mergeSystem = (left: System, right?: System): System => {
6060
};
6161

6262
export const updateSystem = (page: Page, update: Partial<System>) => {
63+
if (page.systemDataSourceId === undefined) {
64+
return;
65+
}
6366
const dataSourceVariables = new Map($dataSourceVariables.get());
6467
const system = dataSourceVariables.get(page.systemDataSourceId) as
6568
| undefined

apps/builder/app/shared/page-utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ export const insertPageCopyMutable = ({
118118
const newRootInstanceId =
119119
newInstanceIds.get(page.rootInstanceId) ?? page.rootInstanceId;
120120
const newSystemDataSourceId =
121-
newDataSourceIds.get(page.systemDataSourceId) ?? page.systemDataSourceId;
121+
newDataSourceIds.get(page.systemDataSourceId ?? "") ??
122+
page.systemDataSourceId;
122123
const newPage: Page = {
123124
...page,
124125
id: newPageId,

fixtures/react-router-docker/app/__generated__/[another-page]._index.tsx

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/react-router-docker/app/__generated__/_index.tsx

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/react-router-netlify/app/__generated__/[another-page]._index.tsx

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/react-router-netlify/app/__generated__/_index.tsx

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)