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 ts

Sara Vieirac8112d7e8ab6
diff --git a/apps/designer/app/designer/features/sidebar-left/panels/asset-manager.tsx b/apps/designer/app/designer/features/sidebar-left/panels/asset-manager.tsx
index 5d726af86f..0a1b836f2a 100644
--- a/apps/designer/app/designer/features/sidebar-left/panels/asset-manager.tsx
+++ b/apps/designer/app/designer/features/sidebar-left/panels/asset-manager.tsx
@@ -25,6 +25,7 @@ export const TabContent = ({
]);
}
}, [newImages]);
+
return (
<Flex gap="3" direction="column" css={{ padding: "$1" }}>
<Flex justify="between">
@@ -41,7 +42,7 @@ export const TabContent = ({
key={asset.id}
path={asset.path}
alt={asset.alt || asset.name}
- uploading={"uploading" in asset && asset.uploading}
+ status={asset.status}
/>
))}
</Grid>
diff --git a/apps/designer/app/designer/features/sidebar-left/panels/components/add-an-asset-form.tsx b/apps/designer/app/designer/features/sidebar-left/panels/components/add-an-asset-form.tsx
index a5f191a378..a19c673c17 100644
--- a/apps/designer/app/designer/features/sidebar-left/panels/components/add-an-asset-form.tsx
+++ b/apps/designer/app/designer/features/sidebar-left/panels/components/add-an-asset-form.tsx
@@ -1,4 +1,5 @@
import { Form, useSubmit } from "@remix-run/react";
+import { Asset } from "@webstudio-is/prisma-client";
import ObjectID from "bson-objectid";
import { ChangeEvent, useRef } from "react";
import { Button } from "~/shared/design-system";
@@ -21,7 +22,7 @@ const readImages = async (fileList: FileList) => {
path: path as string,
name: file.name,
id: ObjectID().toString(),
- uploading: true,
+ status: "uploading" as Asset["status"],
alt: file.name,
});
}
diff --git a/apps/designer/app/designer/features/sidebar-left/panels/components/image.tsx b/apps/designer/app/designer/features/sidebar-left/panels/components/image.tsx
index 29c4b4e21e..70c2fd6c7a 100644
--- a/apps/designer/app/designer/features/sidebar-left/panels/components/image.tsx
+++ b/apps/designer/app/designer/features/sidebar-left/panels/components/image.tsx
@@ -3,6 +3,7 @@ import { Box, ProgressBar } from "~/shared/design-system";
import { useInterval } from "react-use";
import placeholderImage from "~/shared/images/image-placeholder.svg";
import brokenImage from "~/shared/images/broken-image-placeholder.svg";
+import { Asset } from "@webstudio-is/prisma-client";
const useImageWithFallback = ({ path }: { path: string }) => {
const [src, setSrc] = useState(placeholderImage);
@@ -20,12 +21,13 @@ const useImageWithFallback = ({ path }: { path: string }) => {
export const AssetManagerImage = ({
path,
alt,
- uploading,
+ status,
}: {
path: string;
alt?: string;
- uploading?: boolean;
+ status?: Asset["status"];
}) => {
+ const uploading = status === "uploading";
const src = useImageWithFallback({ path });
const [progressBarPercentage, setProgressBarPercentage] = useState(0);
diff --git a/apps/designer/app/designer/features/sidebar-left/types.ts b/apps/designer/app/designer/features/sidebar-left/types.ts
index b5c95c5310..31e75cb3e1 100644
--- a/apps/designer/app/designer/features/sidebar-left/types.ts
+++ b/apps/designer/app/designer/features/sidebar-left/types.ts
@@ -1,11 +1,12 @@
+import { Asset } from "@webstudio-is/prisma-client";
import { panels } from "./panels";
export type TabName = keyof typeof panels | "none";
export type UploadingAsset = {
- id: string;
- uploading: boolean;
- name: string;
- path: string;
- alt: string;
+ id: Asset["id"];
+ status: Asset["status"];
+ name: Asset["name"];
+ path: Asset["path"];
+ alt: Asset["alt"];
};
diff --git a/apps/designer/app/routes/designer/$id.tsx b/apps/designer/app/routes/designer/$id.tsx
index 4ad2ae362e..322389f433 100644
--- a/apps/designer/app/routes/designer/$id.tsx
+++ b/apps/designer/app/routes/designer/$id.tsx
@@ -42,7 +42,10 @@ export const action: ActionFunction = async ({ request, params }) => {
projectId: params.id,
dirname: __dirname,
});
- return assets;
+ return assets.map((asset: Asset) => ({
+ ...asset,
+ status: "uploaded",
+ }));
} catch (error) {
if (error instanceof Error) {
return {
diff --git a/packages/prisma-client/src/types.ts b/packages/prisma-client/src/types.ts
index 6fe42524f1..31a1a8dcc8 100644
--- a/packages/prisma-client/src/types.ts
+++ b/packages/prisma-client/src/types.ts
@@ -2,5 +2,8 @@ import type { Asset as DbAsset } from "@prisma/client";
export { Location } from "@prisma/client";
export type { InstanceProps, Project, User, Breakpoints } from "@prisma/client";
-export type Asset = DbAsset & { path: string };
+export type Asset = DbAsset & {
+ path: string;
+ status: "uploading" | "uploaded";
+};
export type { DbAsset };