-
Notifications
You must be signed in to change notification settings - Fork 501
Project logo upload #817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Project logo upload #817
Changes from all commits
Commits
Show all changes
117 commits
Select commit
Hold shift + click to select a range
0f9b372
add tenancy crud
fomalhautb a9ceab2
remove old config
fomalhautb 6390832
fix validateRedirectUrl
fomalhautb 1f02532
fix tenancy config
fomalhautb 588019d
fix
fomalhautb 86466a9
better error handling
fomalhautb 3d38936
fix
fomalhautb 506ff7d
fix
fomalhautb 5d7bcc0
fix
fomalhautb 3626c5c
fix
fomalhautb 76f593a
fix
fomalhautb 0b00d8c
remove environment-config
fomalhautb 62b7775
Update apps/backend/src/app/api/latest/integrations/neon/oauth-provid…
fomalhautb 0bcafcd
Update apps/backend/src/app/api/latest/auth/otp/send-sign-in-code/rou…
fomalhautb 15f73de
Update apps/backend/prisma/seed.ts
fomalhautb 8c18c7f
Merge branch 'dev' into remove-old-config
fomalhautb 073ab15
fix
fomalhautb bc069b0
fix tests
fomalhautb 9ceb0ac
added config override crud
fomalhautb 1afbf06
rename
fomalhautb c18cae3
Refactor updateConfigOverrides to handle legacy config structure and …
fomalhautb 0387792
fix bugs
fomalhautb 6458c54
add use config
fomalhautb 408e387
added todos
fomalhautb 41d8a4c
tests
fomalhautb e2cb2ab
tests
fomalhautb dabc619
tests
fomalhautb 32afeb2
more tests
fomalhautb 4e25c86
init
fomalhautb 13bb68e
s3 image
fomalhautb 0a3e088
fix size
fomalhautb 1b9d1b0
updated image profile url
fomalhautb 3a6c548
Merge branch 'dev' into s3
fomalhautb 431a3a4
env vars
fomalhautb f61670a
fix package.json
fomalhautb cb7d262
fix tests
fomalhautb 7a648b2
fix tests
fomalhautb 1fd77f6
add to emulator
fomalhautb f5d6656
Merge branch 'dev' into s3
fomalhautb b2722a4
dynamic import
fomalhautb e4a6b04
Merge branch 's3' of github.com:stackframe-projects/stack into s3
fomalhautb 73d90ca
Merge branch 'dev' into s3
fomalhautb c883965
make s3 optional
fomalhautb e929f74
docs
fomalhautb 48debe3
remove test route
fomalhautb 814b66d
Update apps/backend/.env
fomalhautb 517b4dd
improve error handling
fomalhautb 0d4fd41
Merge branch 's3' of github.com:stackframe-projects/stack into s3
fomalhautb 3a2def7
comments
fomalhautb c856d00
Update S3 configuration checks and regex for base64 image validation
fomalhautb 64b34b1
fix import error
fomalhautb 3369c3a
fix import
fomalhautb af5fbd0
fix syntax error
fomalhautb 6d83076
fix types
fomalhautb 4ed5fe9
Merge branch 'config-json-crud' into s3
fomalhautb 6f658fd
add logo
fomalhautb 6172952
fix
fomalhautb d2413f3
fix types
fomalhautb 7f78755
fix types
fomalhautb 7ed74d0
Merge branch 's3' into project-logo
fomalhautb 405a63f
Merge branch 'dev' into remove-old-config
fomalhautb 1904feb
Merge branch 'dev' into remove-old-config
fomalhautb 079df58
fix types
fomalhautb 9fa42c7
Improve error handling for missing provider type in OAuth configuration
fomalhautb 577eaf3
fix tests
fomalhautb ae04ae2
fix tests
fomalhautb 40a6c7a
Merge branch 'remove-old-config' into project-config-to-json
fomalhautb 60ced05
Merge branch 'dev' into project-config-to-json
fomalhautb 5a05e01
fix
fomalhautb 9e5a049
Update apps/e2e/tests/backend/endpoints/api/v1/internal/config-overri…
fomalhautb c76d55f
fix
fomalhautb 40db4e2
Merge branch 'project-config-to-json' of github.com:stackframe-projec…
fomalhautb 7862a3e
Refactor config overrides CRUD handlers by simplifying paramsSchema a…
fomalhautb ee330cb
Refactor config CRUD handlers to standardize naming conventions for c…
fomalhautb b3b581c
fix tests
fomalhautb 5d45170
Merge branch 'dev' into project-config-to-json
fomalhautb 1d52910
fix
fomalhautb 677de8a
fix
fomalhautb 44eecf6
Merge branch 'dev' into project-config-to-json
fomalhautb db50e41
fix
fomalhautb 48bb875
add tests
fomalhautb eb5a173
Merge branch 'dev' into project-config-to-json
fomalhautb 8e581f6
remove logging
fomalhautb dee426f
remove word
fomalhautb 3d20abc
rename endpoints
fomalhautb 31d8c37
Merge branch 'project-config-to-json' into s3
fomalhautb 52cfaf8
fix
fomalhautb a205566
removed unused
fomalhautb a6c69bb
Merge branch 'dev' into s3
fomalhautb f103ce8
Merge branch 's3' of github.com:stackframe-projects/stack into s3
fomalhautb c324aa2
remove unused
fomalhautb c480271
fix import
fomalhautb 95db583
8120 -> 8121
fomalhautb f7b1d20
fix test
fomalhautb 6cfc7b7
improve auto-migration test
fomalhautb d518eb0
refactor auto-migration test to simplify success count validation
fomalhautb 901f0b5
fix
fomalhautb 7914568
Merge branch 's3' into project-logo
fomalhautb cada633
Merge branch 'dev' into project-logo
fomalhautb 317529b
add logo
fomalhautb e6d2839
fix
fomalhautb 3e314cd
logo uploader
fomalhautb 1610f90
Merge branch 'dev' into project-logo
fomalhautb 72379f5
fix bug
fomalhautb c0f963a
Update apps/dashboard/src/components/logo-upload.tsx
fomalhautb 76a4a1e
Update apps/dashboard/src/components/logo-upload.tsx
fomalhautb 51d4060
Update packages/stack-shared/src/schema-fields.ts
fomalhautb 533d5fb
fix tests
fomalhautb 1b0cdbf
fix tests
fomalhautb 986f02f
Merge dev into project-logo
N2D4 b41c1ec
Merge dev into project-logo
N2D4 6de0da8
Merge dev into project-logo
N2D4 835e151
Merge dev into project-logo
N2D4 8a0c8a7
Merge dev into project-logo
N2D4 9d7656b
Merge dev into project-logo
N2D4 f7f6c38
Update apps/dashboard/src/app/(main)/(protected)/projects/[projectId]…
fomalhautb d950e13
Merge branch 'dev' into project-logo
fomalhautb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
apps/backend/prisma/migrations/20250801204029_logo_url/migration.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| -- AlterTable | ||
| ALTER TABLE "Project" ADD COLUMN "logoUrl" TEXT; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "Project" ADD COLUMN "fullLogoUrl" TEXT; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| "use client"; | ||
|
|
||
| import { fileToBase64 } from '@stackframe/stack-shared/dist/utils/base64'; | ||
| import { runAsynchronouslyWithAlert } from '@stackframe/stack-shared/dist/utils/promises'; | ||
| import { Button, cn, Typography } from '@stackframe/stack-ui'; | ||
| import imageCompression from 'browser-image-compression'; | ||
| import { Upload, X } from 'lucide-react'; | ||
| import { useState } from 'react'; | ||
|
|
||
| export async function checkImageUrl(url: string) { | ||
| try { | ||
| const res = await fetch(url, { method: 'HEAD' }); | ||
| const buff = await res.blob(); | ||
| return buff.type.startsWith('image/'); | ||
| } catch (e) { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| export function LogoUpload(props: { | ||
| label: string, | ||
| value?: string | null, | ||
| onValueChange: (value: string | null) => void | Promise<void>, | ||
| description?: string, | ||
| acceptedTypes?: string[], | ||
| type: 'logo' | 'full-logo', | ||
| }) { | ||
| const [uploading, setUploading] = useState(false); | ||
| const [error, setError] = useState<string | null>(null); | ||
|
|
||
| function upload() { | ||
| const input = document.createElement('input'); | ||
| input.type = 'file'; | ||
| input.accept = props.acceptedTypes?.join(',') || 'image/*'; | ||
|
|
||
| input.onchange = (e) => { | ||
| const file = (e.target as HTMLInputElement).files?.[0]; | ||
| if (!file) return; | ||
|
|
||
| setUploading(true); | ||
| setError(null); | ||
|
|
||
| runAsynchronouslyWithAlert(async () => { | ||
| try { | ||
| // Compress the image first | ||
| const compressedFile = await imageCompression(file, { | ||
| maxSizeMB: 1, | ||
| maxWidthOrHeight: 800, | ||
| useWebWorker: true, | ||
| fileType: file.type.startsWith('image/svg') ? file.type : 'image/jpeg', | ||
| }); | ||
|
|
||
| const base64Url = await fileToBase64(compressedFile); | ||
|
|
||
| if (await checkImageUrl(base64Url)) { | ||
| await props.onValueChange(base64Url); | ||
| setError(null); | ||
| } else { | ||
| setError('Invalid image format'); | ||
| } | ||
| } catch (err) { | ||
| setError('Failed to process image'); | ||
| console.error('Logo upload error:', err); | ||
| } finally { | ||
| setUploading(false); | ||
| input.remove(); | ||
| } | ||
| }); | ||
| }; | ||
|
|
||
| input.click(); | ||
| } | ||
|
|
||
| async function remove() { | ||
| setError(null); | ||
| await props.onValueChange(null); | ||
| } | ||
|
|
||
| const logoContainerClasses = props.type === 'full-logo' | ||
| ? "relative h-16 w-48 rounded border overflow-hidden bg-muted" | ||
| : "relative h-16 w-16 rounded border overflow-hidden bg-muted"; | ||
|
|
||
| const placeholderContainerClasses = props.type === 'full-logo' | ||
| ? "h-16 w-48 rounded border-2 border-dashed border-muted-foreground/25 flex items-center justify-center bg-muted/50" | ||
| : "h-16 w-16 rounded border-2 border-dashed border-muted-foreground/25 flex items-center justify-center bg-muted/50"; | ||
|
|
||
| return ( | ||
| <div className="flex flex-col gap-2"> | ||
| <Typography variant="secondary" type="label"> | ||
| {props.label} | ||
| </Typography> | ||
|
|
||
| <div className="flex items-center gap-3"> | ||
| {props.value ? ( | ||
| <div className="flex items-center gap-3"> | ||
| <div className={logoContainerClasses}> | ||
| {/* eslint-disable-next-line @next/next/no-img-element */} | ||
| <img | ||
| src={props.value} | ||
| alt={props.label} | ||
| className="h-full w-full object-contain" | ||
| /> | ||
| </div> | ||
| <Button | ||
| variant="outline" | ||
| size="sm" | ||
| onClick={remove} | ||
| disabled={uploading} | ||
| > | ||
| <X className="h-4 w-4 mr-2" /> | ||
| Remove | ||
| </Button> | ||
| </div> | ||
| ) : ( | ||
| <div className="flex flex-col items-center gap-4"> | ||
| <div className={cn(placeholderContainerClasses, "cursor-pointer", uploading && "opacity-50 pointer-events-none")} onClick={uploading ? undefined : upload}> | ||
| <Upload className="h-6 w-6 text-muted-foreground" /> | ||
| </div> | ||
| {props.description && ( | ||
| <Typography variant="secondary" type="footnote" className="mt-2"> | ||
| {props.description} | ||
| </Typography> | ||
| )} | ||
| </div> | ||
| )} | ||
| </div> | ||
|
|
||
| {error && ( | ||
| <Typography variant="destructive" type="footnote"> | ||
| {error} | ||
| </Typography> | ||
| )} | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.