refr(enso-org/cloud-v2#1088): Make Project fields camelCase (#9653)

This commit is contained in:
Nikita Pekin 2024-04-12 03:02:29 +07:00 committed by GitHub
parent 3ecc3aebd0
commit f80e0052cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 32 additions and 48 deletions

View File

@ -111,8 +111,7 @@ export async function mockApi({ page }: MockParams) {
id: backend.ProjectId('project-' + uniqueString.uniqueString()),
projectState: {
type: backend.ProjectState.opened,
// eslint-disable-next-line @typescript-eslint/naming-convention
volume_id: '',
volumeId: '',
},
title,
modifiedAt: dateTime.toRfc3339(new Date()),
@ -350,23 +349,23 @@ export async function mockApi({ page }: MockParams) {
const projectId = request.url().match(/[/]projects[/](.+?)[/]copy/)?.[1] ?? ''
await route.fulfill({
json: {
/* eslint-disable @typescript-eslint/naming-convention */
organizationId: defaultOrganizationId,
projectId: backend.ProjectId(projectId),
name: 'example project name',
state: {
type: backend.ProjectState.opened,
volume_id: '',
opened_by: defaultEmail,
volumeId: '',
openedBy: defaultEmail,
},
packageName: 'Project_root',
// eslint-disable-next-line @typescript-eslint/naming-convention
ide_version: null,
// eslint-disable-next-line @typescript-eslint/naming-convention
engine_version: {
value: '2023.2.1-nightly.2023.9.29',
lifecycle: backend.VersionLifecycle.development,
},
address: backend.Address('ws://example.com/'),
/* eslint-enable @typescript-eslint/naming-convention */
} satisfies backend.ProjectRaw,
})
}
@ -626,8 +625,7 @@ export async function mockApi({ page }: MockParams) {
organizationId: defaultOrganizationId,
packageName: 'Project_root',
projectId: id,
// eslint-disable-next-line @typescript-eslint/naming-convention
state: { type: backend.ProjectState.opened, volume_id: '' },
state: { type: backend.ProjectState.opened, volumeId: '' },
}
addProject(title, {
description: null,

View File

@ -103,13 +103,10 @@ export default function ProjectIcon(props: ProjectIconProps) {
type: newState,
})
if (!backendModule.IS_OPENING_OR_OPENED[newState]) {
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unused-vars
const { opened_by, ...newProjectState2 } = newProjectState
newProjectState = newProjectState2
newProjectState = object.omit(newProjectState, 'openedBy')
} else if (user != null) {
newProjectState = object.merge(newProjectState, {
// eslint-disable-next-line @typescript-eslint/naming-convention
opened_by: user.email,
openedBy: user.email,
})
}
return object.merge(oldItem, { projectState: newProjectState })
@ -123,7 +120,7 @@ export default function ProjectIcon(props: ProjectIconProps) {
>(null)
const [shouldOpenWhenReady, setShouldOpenWhenReady] = React.useState(false)
const [isRunningInBackground, setIsRunningInBackground] = React.useState(
item.projectState.execute_async ?? false
item.projectState.executeAsync ?? false
)
const [shouldSwitchPage, setShouldSwitchPage] = React.useState(false)
const [toastId, setToastId] = React.useState<toast.Id | null>(null)
@ -132,7 +129,7 @@ export default function ProjectIcon(props: ProjectIconProps) {
const [closeProjectAbortController, setCloseProjectAbortController] =
React.useState<AbortController | null>(null)
const isOtherUserUsingProject =
backend.type !== backendModule.BackendType.local && item.projectState.opened_by !== user?.email
backend.type !== backendModule.BackendType.local && item.projectState.openedBy !== user?.email
const openProject = React.useCallback(
async (shouldRunInBackground: boolean) => {

View File

@ -73,8 +73,8 @@ export default function ProjectNameColumn(props: ProjectNameColumnProps) {
permissions.PERMISSION_ACTION_CAN_EXECUTE[ownPermission.permission]))
const isOtherUserUsingProject =
backend.type !== backendModule.BackendType.local &&
projectState.opened_by != null &&
projectState.opened_by !== user?.email
projectState.openedBy != null &&
projectState.openedBy !== user?.email
const setIsEditing = (isEditingName: boolean) => {
if (isEditable) {

View File

@ -96,8 +96,8 @@ export default function AssetContextMenu(props: AssetContextMenuProps) {
const isOtherUserUsingProject =
backend.type !== backendModule.BackendType.local &&
backendModule.assetIsProject(asset) &&
asset.projectState.opened_by != null &&
asset.projectState.opened_by !== user?.email
asset.projectState.openedBy != null &&
asset.projectState.openedBy !== user?.email
const setAsset = setAssetHooks.useSetAsset(asset, setItem)
return category === Category.trash ? (

View File

@ -1498,10 +1498,8 @@ export default function AssetsTable(props: AssetsTableProps) {
permissions: permissions.tryGetSingletonOwnerPermission(user),
projectState: {
type: backendModule.ProjectState.placeholder,
// eslint-disable-next-line @typescript-eslint/naming-convention
volume_id: '',
// eslint-disable-next-line @typescript-eslint/naming-convention
...(user != null ? { opened_by: user.email } : {}),
volumeId: '',
...(user != null ? { openedBy: user.email } : {}),
...(path != null ? { path } : {}),
},
labels: [],

View File

@ -160,19 +160,17 @@ export enum ProjectState {
/** Wrapper around a project state value. */
export interface ProjectStateType {
readonly type: ProjectState
/* eslint-disable @typescript-eslint/naming-convention */
readonly volume_id: string
readonly instance_id?: string
readonly execute_async?: boolean
readonly volumeId: string
readonly instanceId?: string
readonly executeAsync?: boolean
readonly address?: string
readonly security_group_id?: string
readonly ec2_id?: string
readonly ec2_public_ip_address?: string
readonly current_session_id?: string
readonly opened_by?: EmailAddress
readonly securityGroupId?: string
readonly ec2Id?: string
readonly ec2PublicIpAddress?: string
readonly currentSessionId?: string
readonly openedBy?: EmailAddress
/** Only present on the Local backend. */
readonly path?: Path
/* eslint-enable @typescript-eslint/naming-convention */
}
export const IS_OPENING: Readonly<Record<ProjectState, boolean>> = {
@ -711,10 +709,8 @@ export function createPlaceholderProjectAsset(
modifiedAt: dateTime.toRfc3339(new Date()),
projectState: {
type: ProjectState.new,
// eslint-disable-next-line @typescript-eslint/naming-convention
volume_id: '',
// eslint-disable-next-line @typescript-eslint/naming-convention
...(organization != null ? { opened_by: organization.email } : {}),
volumeId: '',
...(organization != null ? { openedBy: organization.email } : {}),
...(path != null ? { path } : {}),
},
labels: [],

View File

@ -152,8 +152,7 @@ export default class LocalBackend extends Backend {
type:
this.projectManager.projects.get(entry.metadata.id)?.state ??
backend.ProjectState.closed,
// eslint-disable-next-line @typescript-eslint/naming-convention
volume_id: '',
volumeId: '',
path: entry.path,
},
labels: [],
@ -189,8 +188,7 @@ export default class LocalBackend extends Backend {
packageName: project.name,
state: {
type: backend.ProjectState.closed,
// eslint-disable-next-line @typescript-eslint/naming-convention
volume_id: '',
volumeId: '',
},
jsonAddress: null,
binaryAddress: null,
@ -221,8 +219,7 @@ export default class LocalBackend extends Backend {
packageName: project.projectName,
state: {
type: backend.ProjectState.closed,
// eslint-disable-next-line @typescript-eslint/naming-convention
volume_id: '',
volumeId: '',
path,
},
}
@ -284,8 +281,7 @@ export default class LocalBackend extends Backend {
projectId,
state: {
type: this.projectManager.projects.get(id)?.state ?? backend.ProjectState.closed,
// eslint-disable-next-line @typescript-eslint/naming-convention
volume_id: '',
volumeId: '',
},
}
}
@ -308,8 +304,7 @@ export default class LocalBackend extends Backend {
projectId,
state: {
type: backend.ProjectState.opened,
// eslint-disable-next-line @typescript-eslint/naming-convention
volume_id: '',
volumeId: '',
},
}
}

View File

@ -91,7 +91,7 @@ export function singletonObjectOrNull(value: unknown): [] | [object] {
// === omit ===
// ============
/** UNSAFE when `Ks` contains strings that are not in the runtie array. */
/** UNSAFE when `Ks` contains strings that are not in the runtime array. */
export function omit<T, Ks extends readonly (string & keyof T)[] | []>(
object: T,
...keys: Ks