mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-04 23:05:56 -05:00
1be43911b4
Set Prettier's "trailingComma" setting to "es5" GitOrigin-RevId: 9f14150511929a855b27467ad17be6ab262fe5d5
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import { postJSON, deleteJSON } from '../../../infrastructure/fetch-json'
|
|
|
|
export function syncRename(projectId, entityType, entityId, newName) {
|
|
return postJSON(
|
|
`/project/${projectId}/${getEntityPathName(entityType)}/${entityId}/rename`,
|
|
{
|
|
body: {
|
|
name: newName,
|
|
},
|
|
}
|
|
)
|
|
}
|
|
|
|
export function syncDelete(projectId, entityType, entityId) {
|
|
return deleteJSON(
|
|
`/project/${projectId}/${getEntityPathName(entityType)}/${entityId}`
|
|
)
|
|
}
|
|
|
|
export function syncMove(projectId, entityType, entityId, toFolderId) {
|
|
return postJSON(
|
|
`/project/${projectId}/${getEntityPathName(entityType)}/${entityId}/move`,
|
|
{
|
|
body: {
|
|
folder_id: toFolderId,
|
|
},
|
|
}
|
|
)
|
|
}
|
|
|
|
export function syncCreateEntity(projectId, parentFolderId, newEntityData) {
|
|
const { endpoint, ...newEntity } = newEntityData
|
|
return postJSON(`/project/${projectId}/${endpoint}`, {
|
|
body: {
|
|
parent_folder_id: parentFolderId,
|
|
...newEntity,
|
|
},
|
|
})
|
|
}
|
|
|
|
function getEntityPathName(entityType) {
|
|
return entityType === 'fileRef' ? 'file' : entityType
|
|
}
|