Skip to content

Commit c3ca454

Browse files
authored
feat: Add Content Editor share permission (#4421)
## Description Part 2 Of #3994 Hidden under flag <img width="360" alt="image" src="https://github.com/user-attachments/assets/59cf859a-3325-425b-b06e-31b74bd93df4"> <img width="350" alt="image" src="https://github.com/user-attachments/assets/dca8521c-5e2b-4e4f-893f-df416cea0481"> Links with `?mode=content` from free plan should not work <img width="626" alt="image" src="https://github.com/user-attachments/assets/d737474d-8110-42a1-98fd-2ab94ed24cde"> Content edit shared links have no design mode <img width="421" alt="image" src="https://github.com/user-attachments/assets/42ee3d4b-7aab-4e2c-9e28-b5b0fe6c58af"> ## 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: 5de6) - [ ] 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 c4eea57 commit c3ca454

File tree

21 files changed

+232
-84
lines changed

21 files changed

+232
-84
lines changed

apps/builder/app/builder/builder.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
$textEditingInstanceSelector,
3232
$isDesignMode,
3333
$isContentMode,
34+
$userPlanFeatures,
3435
} from "~/shared/nano-states";
3536
import { $settings, type Settings } from "./shared/client-settings";
3637
import { builderUrl, getCanvasUrl } from "~/shared/router-utils";
@@ -46,7 +47,6 @@ import {
4647
$dataLoadingState,
4748
$isCloneDialogOpen,
4849
$loadingState,
49-
$userPlanFeatures,
5050
type SidebarPanelName,
5151
} from "./shared/nano-states";
5252
import { CloneProjectDialog } from "~/shared/clone-project";

apps/builder/app/builder/features/pages/page-settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import {
7575
$dataSourceVariables,
7676
$publishedOrigin,
7777
$project,
78+
$userPlanFeatures,
7879
} from "~/shared/nano-states";
7980
import {
8081
BindingControl,
@@ -103,7 +104,6 @@ import {
103104
isPathAvailable,
104105
} from "./page-utils";
105106
import { Form } from "./form";
106-
import { $userPlanFeatures } from "~/builder/shared/nano-states";
107107
import type { UserPlanFeatures } from "~/shared/db/user-plan-features.server";
108108
import { useUnmount } from "~/shared/hook-utils/use-mount";
109109
import { Card } from "../marketplace/card";

apps/builder/app/builder/features/project-settings/section-general.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ import { InfoCircleIcon } from "@webstudio-is/icons";
2020
import { ImageControl } from "./image-control";
2121
import { Image } from "@webstudio-is/image";
2222
import type { ProjectMeta } from "@webstudio-is/sdk";
23-
import { $assets, $imageLoader, $pages } from "~/shared/nano-states";
23+
import {
24+
$assets,
25+
$imageLoader,
26+
$pages,
27+
$userPlanFeatures,
28+
} from "~/shared/nano-states";
2429
import { serverSyncStore } from "~/shared/sync";
2530
import { sectionSpacing } from "./utils";
2631
import { CodeEditor } from "~/builder/shared/code-editor";
27-
import { $userPlanFeatures } from "~/builder/shared/nano-states";
2832

2933
const imgStyle = css({
3034
objectFit: "contain",

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ import {
1313
} from "@webstudio-is/design-system";
1414
import { UpgradeIcon } from "@webstudio-is/icons";
1515
import { useStore } from "@nanostores/react";
16-
import { $userPlanFeatures } from "~/builder/shared/nano-states";
1716
import cmsUpgradeBanner from "./cms-upgrade-banner.svg?url";
18-
import { $isDesignMode } from "~/shared/nano-states";
17+
import { $isDesignMode, $userPlanFeatures } from "~/shared/nano-states";
1918

2019
export const SettingsPanelContainer = ({
2120
selectedInstance,

apps/builder/app/builder/features/settings-panel/variable-popover.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ import {
5454
$areResourcesLoading,
5555
invalidateResource,
5656
getComputedResource,
57+
$userPlanFeatures,
5758
} from "~/shared/nano-states";
5859
import { serverSyncStore } from "~/shared/sync";
59-
import { $userPlanFeatures } from "~/builder/shared/nano-states";
60+
6061
import { BindingPopoverProvider } from "~/builder/shared/binding-popover";
6162
import { useSideOffset } from "~/builder/shared/floating-panel";
6263
import {

apps/builder/app/builder/features/settings-panel/variables-section.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import type { Meta, StoryObj } from "@storybook/react";
22
import { Box } from "@webstudio-is/design-system";
33
import { createDefaultPages } from "@webstudio-is/project-build";
4-
import { $pages, $instances } from "~/shared/nano-states";
4+
import { $pages, $instances, $userPlanFeatures } from "~/shared/nano-states";
55
import { registerContainers } from "~/shared/sync";
6-
import { $userPlanFeatures } from "~/builder/shared/nano-states";
76
import { $awareness } from "~/shared/awareness";
87
import { VariablesSection as VariablesSectionComponent } from "./variables-section";
98

apps/builder/app/builder/features/topbar/domain-checkbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {
88
buttonStyle,
99
Checkbox,
1010
} from "@webstudio-is/design-system";
11-
import { $userPlanFeatures } from "~/builder/shared/nano-states";
12-
import { $project } from "~/shared/nano-states";
11+
12+
import { $project, $userPlanFeatures } from "~/shared/nano-states";
1313

1414
export const domainToPublishName = "domainToPublish[]";
1515

apps/builder/app/builder/features/topbar/menu/menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
menuItemCss,
1717
} from "@webstudio-is/design-system";
1818
import {
19-
$userPlanFeatures,
2019
$isCloneDialogOpen,
2120
$isShareDialogOpen,
2221
$isPublishDialogOpen,
@@ -26,6 +25,7 @@ import {
2625
$authPermit,
2726
$authToken,
2827
$authTokenPermissions,
28+
$userPlanFeatures,
2929
} from "~/shared/nano-states";
3030
import { emitCommand } from "~/builder/shared/commands";
3131
import { MenuButton } from "./menu-button";

apps/builder/app/builder/features/topbar/publish.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ import {
3535
RadioGroup,
3636
} from "@webstudio-is/design-system";
3737
import stripIndent from "strip-indent";
38+
import { $isPublishDialogOpen } from "../../shared/nano-states";
39+
import { validateProjectDomain, type Project } from "@webstudio-is/project";
3840
import {
39-
$isPublishDialogOpen,
41+
$authPermit,
42+
$project,
43+
$publishedOrigin,
4044
$userPlanFeatures,
41-
} from "../../shared/nano-states";
42-
import { validateProjectDomain, type Project } from "@webstudio-is/project";
43-
import { $authPermit, $project, $publishedOrigin } from "~/shared/nano-states";
45+
} from "~/shared/nano-states";
4446
import { Domains, PENDING_TIMEOUT, getPublishStatusAndText } from "./domains";
4547
import { CollapsibleDomainSection } from "./collapsible-domain-section";
4648
import {

apps/builder/app/builder/shared/commands.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
$textEditingInstanceSelector,
77
$builderMode,
88
$isDesignMode,
9+
$isDesignModeAllowed,
10+
setBuilderMode,
911
} from "~/shared/nano-states";
1012
import {
1113
$breakpointsMenuView,
@@ -131,10 +133,15 @@ export const { emitCommand, subscribeCommands } = createCommandsEmitter({
131133
handler: () => {
132134
setActiveSidebarPanel("auto");
133135

136+
// @todo: This is temporary until we have a combo to switch modes
134137
if ($builderMode.get() === "preview") {
135-
$builderMode.set("design");
138+
if ($isDesignModeAllowed.get()) {
139+
setBuilderMode("design");
140+
} else {
141+
setBuilderMode("content");
142+
}
136143
} else {
137-
$builderMode.set("preview");
144+
setBuilderMode("preview");
138145
}
139146
},
140147
},
@@ -144,10 +151,15 @@ export const { emitCommand, subscribeCommands } = createCommandsEmitter({
144151
handler: () => {
145152
setActiveSidebarPanel("auto");
146153

154+
// @todo: This is temporary until we have a combo to switch modes
147155
if ($builderMode.get() === "content") {
148-
$builderMode.set("design");
156+
if ($isDesignModeAllowed.get()) {
157+
setBuilderMode("design");
158+
} else {
159+
setBuilderMode("preview");
160+
}
149161
} else {
150-
$builderMode.set("content");
162+
setBuilderMode("content");
151163
}
152164
},
153165
},

0 commit comments

Comments
 (0)