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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -91,7 +91,7 @@ export function singletonObjectOrNull(value: unknown): [] | [object] {
// === omit === // === 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)[] | []>( export function omit<T, Ks extends readonly (string & keyof T)[] | []>(
object: T, object: T,
...keys: Ks ...keys: Ks