Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions catalog/app/containers/Admin/Settings/ThemeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,7 @@ export default function ThemeEditor() {
[settings, writeSettings, uploadFile],
)

// FIXME: remove when file upload would be ready
const useThirdPartyDomainForLogo = true
const useThirdPartyDomainForLogo = false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Dead code — constant always false

useThirdPartyDomainForLogo is now permanently false, making the useThirdPartyDomainForLogo ? <URLField> : <InputFile> ternary at line 358 unreachable on the true branch. The whole conditional and the variable can be removed, leaving only the <InputFile> field. This keeps the file clean and avoids confusion for future readers.

Suggested change
const useThirdPartyDomainForLogo = false

(Remove this line and inline the <InputFile> field directly, deleting the ternary around it.)


return (
<>
Expand Down
24 changes: 18 additions & 6 deletions catalog/app/utils/CatalogSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,25 @@ function format(settings: CatalogSettings) {
return JSON.stringify(settings, null, 2)
}

// FIXME: remove if decide to not use file upload for logo
export function useUploadFile() {
return React.useCallback(async (file: File) => {
// eslint-disable-next-line no-console
console.log(file)
throw new Error('This functionality is not ready yet')
}, [])
const s3 = AWS.S3.use()
return React.useCallback(
async (file: File) => {
const ext = file.name.includes('.') ? file.name.split('.').pop() : ''
const key = ext ? `catalog/logo.${ext}` : 'catalog/logo'
const buf = await file.arrayBuffer()
await s3
.putObject({
Bucket: cfg.serviceBucket,
Key: key,
Body: new Uint8Array(buf),
ContentType: file.type || undefined,
})
.promise()
return `s3://${cfg.serviceBucket}/${key}`
},
[s3],
)
}

export function useWriteSettings() {
Expand Down