Skip to content

Commit 7d36c8f

Browse files
authored
Refactor file upload and toast notifications (#472)
* Refactor file upload and toast notifications Replaces react-hot-toast with a custom toast system using @radix-ui/react-toast, updating all usages and adding new UI components for toast and dialog. Refactors file upload to use a two-step process: first generating an S3 upload URL, then adding the file to the database, and adds file deletion support with confirmation dialog and S3 cleanup. Updates Prisma schema, removes unused fields, and cleans up navigation and admin settings page. * Enforce file upload limit and update dependencies on opensaas-sh Added a check to restrict users to 2 file uploads in the demo, with a new helper function and error handling. Updated navigation items, improved landing page content, and removed unused dependencies (react-hot-toast). Added @radix-ui/react-toast, updated testimonials, and made minor content and code improvements. * update tests * Improve file deletion error handling and cleanup Refactors file deletion to delete the database record before attempting S3 deletion, ensuring the file is removed from the app even if S3 deletion fails. Adds error logging for failed S3 deletions to aid in manual cleanup. Also simplifies error handling in the file upload page and removes unused imports in the demo app page. * Add credit check and S3 file existence validation Added logic to decrement user credits or throw an error if out of credits in the AI demo app. Updated file upload operations to validate file existence in S3 before adding to the database, and implemented S3 file existence check utility. Minor UI and code improvements included. * Update s3Utils.ts * update app_diff * fix diff * Update deletions * Improve toast UI, error handling, and credit messaging Updated toast action hover style and icon spacing for better UI consistency. Enhanced error handling in file deletion to display specific error messages. Refined credit/subscription error message in GPT response operation for clarity and removed redundant credit decrement logic. * Refactor file upload validation and error handling Replaces error state management with toast notifications for file upload errors and success. Refactors file type validation to use a new ALLOWED_FILE_TYPES_CONST and type AllowedFileTypes. Updates validation logic to throw errors instead of returning error objects, and simplifies type handling across file upload modules. * Refactor file upload to use s3Key and add cleanup job Replaces the 'key' field with 's3Key' for file storage references throughout the codebase and database schema. Updates all related logic, types, and API contracts to use 's3Key'. Adds a scheduled job to delete old files from S3 and the database. Cleans up file type validation constants and improves consistency in file upload and download operations. * add orphaned file clean up * remove s3 cleanup job from template removed but added suggestion to docs. * Update SettingsPage.tsx * prettier format * Update UI, remove unused files Updated README with deployment and demo details. Removed unused App.tsx and package-lock.json files. Modified Main.css, NavBar constants, file uploading logic, file upload operations, and landing page content sections for improved UI and functionality. * remove pricing page from isMarketingPage
1 parent 57ae0bf commit 7d36c8f

File tree

35 files changed

+2592
-1357
lines changed

35 files changed

+2592
-1357
lines changed

opensaas-sh/app_diff/README.md.diff

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
--- template/app/README.md
22
+++ opensaas-sh/app/README.md
3-
@@ -1,6 +1,8 @@
3+
@@ -1,16 +1,31 @@
44
-# <YOUR_APP_NAME>
55
+# opensaas.sh (demo) app
66

77
-Built with [Wasp](https://wasp.sh), based on the [Open Saas](https://opensaas.sh) template.
88
+This is a Wasp app based on Open Saas template with minimal modifications that make it into a demo app that showcases Open Saas's abilities.
9-
+
10-
+It is deployed to https://opensaas.sh and serves both as a landing page for Open Saas and as a demo app.
119

10+
+It is deployed to https://opensaas.sh and serves both as a landing page for Open Saas and as a demo app.
11+
+
1212
## UI Components
1313

14-
@@ -8,9 +10,22 @@
14+
This template includes [ShadCN UI](https://ui.shadcn.com/) v2 for beautiful, accessible React components. See [SHADCN_SETUP.md](./SHADCN_SETUP.md) for details on how to use ShadCN components in your app.
1515

1616
## Development
1717

opensaas-sh/app_diff/deletions

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
src/client/static/open-saas-banner-dark.svg
22
src/client/static/open-saas-banner-light.svg
33
src/landing-page/components/Hero.tsx
4-
src/landing-page/contentSections.ts
54
src/payment/lemonSqueezy/checkoutUtils.ts
65
src/payment/lemonSqueezy/paymentDetails.ts
76
src/payment/lemonSqueezy/paymentProcessor.ts

opensaas-sh/app_diff/main.wasp.diff

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,25 @@
119119
httpRoute: (POST, "/payments-webhook")
120120
}
121121
//#endregion
122-
@@ -281,7 +279,6 @@
122+
@@ -245,6 +243,17 @@
123+
fn: import { deleteFile } from "@src/file-upload/operations",
124+
entities: [User, File]
125+
}
126+
+
127+
+job deleteFilesJob {
128+
+ executor: PgBoss,
129+
+ perform: {
130+
+ fn: import { deleteFilesJob } from "@src/file-upload/workers"
131+
+ },
132+
+ schedule: {
133+
+ cron: "0 5 * * *" // every day at 5am
134+
+ },
135+
+ entities: [File]
136+
+}
137+
//#endregion
138+
139+
//#region Analytics
140+
@@ -291,7 +300,6 @@
123141
component: import AdminCalendar from "@src/admin/elements/calendar/CalendarPage"
124142
}
125143

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- template/app/migrations/20250731133938_drop_upload_url_from_file/migration.sql
2+
+++ opensaas-sh/app/migrations/20250731133938_drop_upload_url_from_file/migration.sql
3+
@@ -0,0 +1,8 @@
4+
+/*
5+
+ Warnings:
6+
+
7+
+ - You are about to drop the column `uploadUrl` on the `File` table. All the data in the column will be lost.
8+
+
9+
+*/
10+
+-- AlterTable
11+
+ALTER TABLE "File" DROP COLUMN "uploadUrl";
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--- template/app/migrations/20250806121259_add_s3_key_file/migration.sql
2+
+++ opensaas-sh/app/migrations/20250806121259_add_s3_key_file/migration.sql
3+
@@ -0,0 +1,11 @@
4+
+/*
5+
+ Warnings:
6+
+
7+
+ - You are about to drop the column `key` on the `File` table. All the data in the column will be lost.
8+
+ - Added the required column `s3Key` to the `File` table without a default value. This is not possible if the table is not empty.
9+
+
10+
+*/
11+
+-- AlterTable
12+
+DELETE FROM "File";
13+
+ALTER TABLE "File" DROP COLUMN "key",
14+
+ADD COLUMN "s3Key" TEXT NOT NULL;

0 commit comments

Comments
 (0)