Fix "opened by" being missing for new projects (#7684)

Fixes the project icon for new projects being disabled, because `opened_by` is missing, making the frontend think the current user was not the one that opened the project.

# Important Notes
None
This commit is contained in:
somebody1234 2023-08-29 20:07:13 +10:00 committed by GitHub
parent e0ef0a258d
commit 78c36ddfc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 13 deletions

View File

@ -156,7 +156,7 @@ export interface ProjectStateType {
ec2_id?: string
ec2_public_ip_address?: string
current_session_id?: string
opened_by?: string
opened_by?: EmailAddress
/* eslint-enable @typescript-eslint/naming-convention */
}

View File

@ -598,8 +598,13 @@ export default function AssetsTable(props: AssetsTableProps) {
modifiedAt: dateTime.toRfc3339(new Date()),
parentId: event.parentId ?? backend.rootDirectoryId(organization),
permissions: permissions.tryGetSingletonOwnerPermission(organization, user),
projectState: {
type: backendModule.ProjectState.placeholder,
// eslint-disable-next-line @typescript-eslint/naming-convention
projectState: { type: backendModule.ProjectState.placeholder, volume_id: '' },
volume_id: '',
// eslint-disable-next-line @typescript-eslint/naming-convention
...(organization != null ? { opened_by: organization.email } : {}),
},
type: backendModule.AssetType.project,
}
if (
@ -629,9 +634,8 @@ export default function AssetsTable(props: AssetsTableProps) {
case assetListEventModule.AssetListEventType.uploadFiles: {
const reversedFiles = Array.from(event.files).reverse()
const parentId = event.parentId ?? backend.rootDirectoryId(organization)
const placeholderFiles: backendModule.FileAsset[] = reversedFiles
.filter(backendModule.fileIsNotProject)
.map(file => ({
const placeholderFiles = reversedFiles.filter(backendModule.fileIsNotProject).map(
(file): backendModule.FileAsset => ({
type: backendModule.AssetType.file,
id: backendModule.FileId(uniqueString.uniqueString()),
title: file.name,
@ -639,19 +643,25 @@ export default function AssetsTable(props: AssetsTableProps) {
permissions: permissions.tryGetSingletonOwnerPermission(organization, user),
modifiedAt: dateTime.toRfc3339(new Date()),
projectState: null,
}))
const placeholderProjects: backendModule.ProjectAsset[] = reversedFiles
.filter(backendModule.fileIsProject)
.map(file => ({
})
)
const placeholderProjects = reversedFiles.filter(backendModule.fileIsProject).map(
(file): backendModule.ProjectAsset => ({
type: backendModule.AssetType.project,
id: backendModule.ProjectId(uniqueString.uniqueString()),
title: file.name,
parentId,
permissions: permissions.tryGetSingletonOwnerPermission(organization, user),
modifiedAt: dateTime.toRfc3339(new Date()),
projectState: {
type: backendModule.ProjectState.new,
// eslint-disable-next-line @typescript-eslint/naming-convention
projectState: { type: backendModule.ProjectState.new, volume_id: '' },
}))
volume_id: '',
// eslint-disable-next-line @typescript-eslint/naming-convention
...(organization != null ? { opened_by: organization.email } : {}),
},
})
)
if (
event.parentId != null &&
event.parentKey != null &&