Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix pr comments

Roman Pominov791f2f8e3b45
diff --git a/apps/designer/app/designer/features/sidebar-left/panels/pages/pages.tsx b/apps/designer/app/designer/features/sidebar-left/panels/pages/pages.tsx
index 5d2ac42da0..9768e9e871 100644
--- a/apps/designer/app/designer/features/sidebar-left/panels/pages/pages.tsx
+++ b/apps/designer/app/designer/features/sidebar-left/panels/pages/pages.tsx
@@ -18,7 +18,6 @@ import {
} from "~/designer/shared/nano-states";
import { SettingsPanel } from "./settings-panel";
import { NewPageSettings } from "./settings";
-import { Fetcher } from "@remix-run/react";
type TabContentProps = {
onSetActiveTab: (tabName: TabName) => void;
@@ -138,7 +137,6 @@ export const TabContent = (props: TabContentProps) => {
};
const [newPageOpen, setNewPageOpen] = useState(false);
- const [newPageState, setNewPageState] = useState<Fetcher["state"]>("idle");
if (currentPageId === undefined || project === undefined) {
return null;
@@ -148,26 +146,14 @@ export const TabContent = (props: TabContentProps) => {
<>
<PagesPanel
onClose={() => props.onSetActiveTab("none")}
- onNewPage={() => {
- if (newPageOpen === false) {
- setNewPageOpen(true);
- }
- if (newPageOpen && newPageState === "idle") {
- setNewPageOpen(false);
- }
- }}
+ onNewPage={() => setNewPageOpen((current) => !current)}
onSelect={handleSelect}
selectedPageId={currentPageId}
/>
<SettingsPanel isOpen={newPageOpen}>
<NewPageSettings
projectId={project.id}
- onClose={() => {
- if (newPageState === "idle") {
- setNewPageOpen(false);
- }
- }}
- onFetcherStateChange={setNewPageState}
+ onClose={() => setNewPageOpen(false)}
onSuccess={(page) => {
setNewPageOpen(false);
handleSelect(page.id);
diff --git a/apps/designer/app/designer/features/sidebar-left/panels/pages/settings.tsx b/apps/designer/app/designer/features/sidebar-left/panels/pages/settings.tsx
index fa855bb586..48264464e8 100644
--- a/apps/designer/app/designer/features/sidebar-left/panels/pages/settings.tsx
+++ b/apps/designer/app/designer/features/sidebar-left/panels/pages/settings.tsx
@@ -10,7 +10,7 @@ import {
toast,
InputErrorsTooltip,
} from "@webstudio-is/design-system";
-import { useFetcher, type FetcherWithComponents } from "@remix-run/react";
+import { useFetcher } from "@remix-run/react";
import { ChevronDoubleLeftIcon } from "@webstudio-is/icons";
import type { ZodError } from "zod";
import { BaseHeader } from "../../lib/header";
@@ -30,14 +30,10 @@ export type CreatePageData =
export const NewPageSettings = ({
onClose,
onSuccess,
- onFetcherStateChange,
projectId,
}: {
onClose?: () => void;
onSuccess?: (page: Page) => void;
- onFetcherStateChange?: (
- state: FetcherWithComponents<unknown>["state"]
- ) => void;
projectId: string;
}) => {
const nameFieldId = useId();
@@ -54,7 +50,6 @@ export const NewPageSettings = ({
const prevFetcher = useRef(fetcher);
useEffect(() => {
if (prevFetcher.current.state !== fetcher.state) {
- onFetcherStateChange?.(fetcher.state);
if (fetcher.state === "idle" && fetcher.data !== undefined) {
if ("ok" in fetcher.data) {
onSuccess?.(fetcher.data.page);
@@ -74,7 +69,7 @@ export const NewPageSettings = ({
}
}
prevFetcher.current = fetcher;
- }, [fetcher, onSuccess, onFetcherStateChange]);
+ }, [fetcher, onSuccess]);
return (
<>
@@ -126,7 +121,7 @@ export const NewPageSettings = ({
</Group>
<Group css={{ alignItems: "end" }}>
<Button type="submit" variant="green" disabled={isSubmitting}>
- Create
+ {isSubmitting ? "Creating..." : "Create"}
</Button>
</Group>
</fetcher.Form>
diff --git a/apps/designer/app/routes/rest/pages.$projectId.ts b/apps/designer/app/routes/rest/pages.$projectId.ts
index ab828a39f2..b4ecd6906d 100644
--- a/apps/designer/app/routes/rest/pages.$projectId.ts
+++ b/apps/designer/app/routes/rest/pages.$projectId.ts
@@ -11,8 +11,8 @@ const nonEmptyString = z
invalid_type_error: "Can't be empty",
required_error: "Can't be empty",
})
- .transform((v) => v.trim())
- .refine((val) => val !== "", "Can't be empty");
+ .transform((value) => value.trim())
+ .refine((value) => value !== "", "Can't be empty");
const CreatePageInput = zfd.formData({
name: nonEmptyString,
@@ -30,7 +30,7 @@ const CreatePageInput = zfd.formData({
),
});
-const handlePUT = async (
+const handlePut = async (
projectId: string,
request: Request
): Promise<CreatePageData> => {
@@ -71,8 +71,8 @@ export const action: ActionFunction = async ({ request, params }) => {
throw new Error(`Project ID required`);
}
- if (request.method.toLowerCase() === "put") {
- const result = await handlePUT(params.projectId, request);
+ if (request.method === "PUT") {
+ const result = await handlePut(params.projectId, request);
return result;
}
diff --git a/packages/design-system/src/components/select.stories.tsx b/packages/design-system/src/components/select.stories.tsx
index 598ddbe691..b72262586f 100644
--- a/packages/design-system/src/components/select.stories.tsx
+++ b/packages/design-system/src/components/select.stories.tsx
@@ -64,7 +64,7 @@ export const WithComplexItems: ComponentStory<typeof Select> = () => {
export const Boundaries: ComponentStory<typeof Select> = () => {
const items = Array(100)
.fill(0)
- .map((_, i) => `Item ${i}`);
+ .map((_, index) => `Item ${index}`);
const [value, setValue] = React.useState(items[0]);
return (
<Select name="fruit" options={items} value={value} onChange={setValue} />
diff --git a/packages/design-system/src/components/tooltip.tsx b/packages/design-system/src/components/tooltip.tsx
index 2bcac85c50..5a763d25bb 100644
--- a/packages/design-system/src/components/tooltip.tsx
+++ b/packages/design-system/src/components/tooltip.tsx
@@ -90,9 +90,9 @@ export const InputErrorsTooltip = ({
errors: string[] | undefined;
children: React.ComponentProps<typeof Tooltip>["children"];
}) => {
- const content = errors?.map((error, i) => (
- <React.Fragment key={i}>
- {i > 0 && <br />}
+ const content = errors?.map((error, index) => (
+ <React.Fragment key={index}>
+ {index > 0 && <br />}
{error}
</React.Fragment>
));
diff --git a/packages/design-system/src/components/tree/tree-node.tsx b/packages/design-system/src/components/tree/tree-node.tsx
index 5dcaba5de2..1531ffe7de 100644
--- a/packages/design-system/src/components/tree/tree-node.tsx
+++ b/packages/design-system/src/components/tree/tree-node.tsx
@@ -53,8 +53,8 @@ const NestingLines = ({
}) =>
level > 1 ? (
<>
- {Array.from({ length: level - 1 }, (_, i) => (
- <NestingLine key={i} isSelected={isSelected} />
+ {Array.from({ length: level - 1 }, (_, index) => (
+ <NestingLine key={index} isSelected={isSelected} />
))}
</>
) : null;
diff --git a/packages/design-system/src/components/tree/tree.stories.tsx b/packages/design-system/src/components/tree/tree.stories.tsx
index 88faf15243..65fd9f99f5 100644
--- a/packages/design-system/src/components/tree/tree.stories.tsx
+++ b/packages/design-system/src/components/tree/tree.stories.tsx
@@ -20,31 +20,39 @@ export const StressTest = ({ animate }: { animate: boolean }) => {
canAcceptChildren: true,
children: Array.from(
{ length: 100 },
- (_, i): Item => ({
- id: `box-${i}`,
+ (_, index): Item => ({
+ id: `box-${index}`,
canAcceptChildren: true,
children: [
- { id: `heading-${i}.0`, canAcceptChildren: false, children: [] },
- { id: `paragraph-${i}.0`, canAcceptChildren: false, children: [] },
{
- id: `box-${i}.0`,
+ id: `heading-${index}.0`,
+ canAcceptChildren: false,
+ children: [],
+ },
+ {
+ id: `paragraph-${index}.0`,
+ canAcceptChildren: false,
+ children: [],
+ },
+ {
+ id: `box-${index}.0`,
canAcceptChildren: true,
children: [
{
- id: `box-${i}.0.0`,
+ id: `box-${index}.0.0`,
canAcceptChildren: true,
children: [
{
- id: `box-${i}.0.0.0`,
+ id: `box-${index}.0.0.0`,
canAcceptChildren: true,
children: [
{
- id: `heading-${i}.1`,
+ id: `heading-${index}.1`,
canAcceptChildren: false,
children: [],
},
{
- id: `paragraph-${i}.1`,
+ id: `paragraph-${index}.1`,
canAcceptChildren: false,
children: [],
},
@@ -52,7 +60,11 @@ export const StressTest = ({ animate }: { animate: boolean }) => {
},
],
},
- { id: `box-${i}.0.1`, canAcceptChildren: true, children: [] },
+ {
+ id: `box-${index}.0.1`,
+ canAcceptChildren: true,
+ children: [],
+ },
],
},
],