Skip to content

Commit

Permalink
a couple of random FE2 fixes reported on Discord (#1943)
Browse files Browse the repository at this point in the history
* fix(fe2): clearer error msg on failed upload

* fix(fe2): missing project.commentThreads access w/ admin override
  • Loading branch information
fabis94 authored Jan 8, 2024
1 parent 36f749b commit a563fa2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
v-if="errorMessage"
class="text-danger inline-flex space-x-1 items-center text-center"
>
<ExclamationTriangleIcon class="h-4 w-4" />
<ExclamationTriangleIcon class="h-4 w-4 shrink-0" />
<span>{{ errorMessage }}</span>
</span>
<div
Expand Down
10 changes: 10 additions & 0 deletions packages/frontend-2/lib/core/api/fileImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ export function importFile(
})

request.addEventListener('load', () => {
if (!request.response) {
return rejectResponse(
new Error(
`Upload failed${
request.status ? ' with code ' + request.status : ''
} - no response`
)
)
}

const uploadResults =
(request.response as Optional<PostBlobResponse>)?.uploadResults || []
const result = uploadResults.find((r) => r.formKey === formKey)
Expand Down
2 changes: 2 additions & 0 deletions packages/server/modules/comments/services/management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
formatSerializedViewerState,
inputToDataStruct
} from '@/modules/comments/services/data'
import { adminOverrideEnabled } from '@/modules/shared/helpers/envHelper'

export async function authorizeProjectCommentsAccess(params: {
projectId: string
Expand All @@ -60,6 +61,7 @@ export async function authorizeProjectCommentsAccess(params: {
if (!project.isPublic && !project.role) success = false
if (requireProjectRole && !project.role && !project.allowPublicComments)
success = false
if (adminOverrideEnabled() && authCtx.role === Roles.Server.Admin) success = true

if (!success) {
throw new StreamInvalidAccessError('You are not authorized')
Expand Down

0 comments on commit a563fa2

Please sign in to comment.