feat: forum rich-text editor, emoji picker, mentions, discover nav, feed, uploads, profile
Forum: - TipTap WYSIWYG editor with full toolbar - @emoji-mart/react emoji picker (consistent with tweets) - @mention autocomplete with user search API - Fix PHP 8.4 parse errors in Blade templates - Fix thread data display (paginator items) - Align forum page widths to max-w-5xl Discover: - Extract shared _nav.blade.php partial - Add missing nav links to for-you page - Add Following link for authenticated users Feed/Posts: - Post model, controllers, policies, migrations - Feed page components (PostComposer, FeedCard, etc) - Post reactions, comments, saves, reports, sharing - Scheduled publishing support - Link preview controller Profile: - Profile page components (ProfileHero, ProfileTabs) - Profile API controller Uploads: - Upload wizard enhancements - Scheduled publish picker - Studio status bar and readiness checklist
This commit is contained in:
71
resources/js/lib/uploadNotices.js
Normal file
71
resources/js/lib/uploadNotices.js
Normal file
@@ -0,0 +1,71 @@
|
||||
const REASON_MAP = {
|
||||
duplicate_hash: {
|
||||
type: 'error',
|
||||
message: 'This file already exists in Skinbase. Please upload a different file.',
|
||||
},
|
||||
validation_failed: {
|
||||
type: 'error',
|
||||
message: 'Upload validation failed. Please check the file and try again.',
|
||||
},
|
||||
scan_failed: {
|
||||
type: 'error',
|
||||
message: 'Upload scan failed. Please try another file.',
|
||||
},
|
||||
quota_exceeded: {
|
||||
type: 'warning',
|
||||
message: 'Upload limit reached. Please wait before uploading again.',
|
||||
},
|
||||
}
|
||||
|
||||
function normalizeType(value, fallback = 'error') {
|
||||
const normalized = String(value || '').toLowerCase()
|
||||
if (normalized === 'success' || normalized === 'warning' || normalized === 'error') return normalized
|
||||
return fallback
|
||||
}
|
||||
|
||||
export function mapUploadErrorNotice(error, fallback = 'Upload failed.') {
|
||||
const status = Number(error?.response?.status || 0)
|
||||
const payload = error?.response?.data || {}
|
||||
const reason = String(payload?.reason || '').toLowerCase()
|
||||
const mapped = REASON_MAP[reason]
|
||||
|
||||
const type = mapped?.type
|
||||
? mapped.type
|
||||
: normalizeType(payload?.type || payload?.level, status >= 500 ? 'error' : 'warning')
|
||||
|
||||
const message =
|
||||
mapped?.message ||
|
||||
(typeof payload?.message === 'string' && payload.message.trim()) ||
|
||||
(typeof error?.message === 'string' && error.message.trim()) ||
|
||||
fallback
|
||||
|
||||
return {
|
||||
type,
|
||||
message,
|
||||
reason,
|
||||
status,
|
||||
}
|
||||
}
|
||||
|
||||
export function mapUploadResultNotice(payload, options = {}) {
|
||||
const {
|
||||
fallbackType = 'success',
|
||||
fallbackMessage = 'Operation completed successfully.',
|
||||
} = options
|
||||
|
||||
const reason = String(payload?.reason || '').toLowerCase()
|
||||
const mapped = REASON_MAP[reason]
|
||||
|
||||
const type = mapped?.type || normalizeType(payload?.type || payload?.level, fallbackType)
|
||||
const message =
|
||||
mapped?.message ||
|
||||
(typeof payload?.message === 'string' && payload.message.trim()) ||
|
||||
fallbackMessage
|
||||
|
||||
return {
|
||||
type,
|
||||
message,
|
||||
reason,
|
||||
status: Number(payload?.status_code || 0),
|
||||
}
|
||||
}
|
||||
40
resources/js/lib/uploadNotices.test.js
Normal file
40
resources/js/lib/uploadNotices.test.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { mapUploadErrorNotice, mapUploadResultNotice } from './uploadNotices'
|
||||
|
||||
describe('uploadNotices mapping', () => {
|
||||
it('maps duplicate_hash reason to a clear error message', () => {
|
||||
const notice = mapUploadErrorNotice({
|
||||
response: {
|
||||
status: 409,
|
||||
data: {
|
||||
reason: 'duplicate_hash',
|
||||
message: 'Duplicate upload is not allowed. This file already exists.',
|
||||
},
|
||||
},
|
||||
}, 'Upload failed.')
|
||||
|
||||
expect(notice.type).toBe('error')
|
||||
expect(notice.reason).toBe('duplicate_hash')
|
||||
expect(notice.message).toBe('This file already exists in Skinbase. Please upload a different file.')
|
||||
})
|
||||
|
||||
it('keeps success messages as success', () => {
|
||||
const notice = mapUploadResultNotice({
|
||||
type: 'success',
|
||||
message: 'Artwork published successfully.',
|
||||
})
|
||||
|
||||
expect(notice.type).toBe('success')
|
||||
expect(notice.message).toBe('Artwork published successfully.')
|
||||
})
|
||||
|
||||
it('normalizes warning messages for queued processing', () => {
|
||||
const notice = mapUploadResultNotice({
|
||||
level: 'warning',
|
||||
message: 'Upload received. Processing is queued.',
|
||||
})
|
||||
|
||||
expect(notice.type).toBe('warning')
|
||||
expect(notice.message).toBe('Upload received. Processing is queued.')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user