2020-11-26 14:22:30 +00:00
|
|
|
import { postJSON, deleteJSON } from '../../../infrastructure/fetch-json'
|
|
|
|
|
|
|
|
export function syncRename(projectId, entityType, entityId, newName) {
|
|
|
|
return postJSON(
|
|
|
|
`/project/${projectId}/${getEntityPathName(entityType)}/${entityId}/rename`,
|
|
|
|
{
|
|
|
|
body: {
|
2021-04-27 07:52:58 +00:00
|
|
|
name: newName,
|
|
|
|
},
|
2020-11-26 14:22:30 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
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: {
|
2021-04-27 07:52:58 +00:00
|
|
|
folder_id: toFolderId,
|
|
|
|
},
|
2020-11-26 14:22:30 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function syncCreateEntity(projectId, parentFolderId, newEntityData) {
|
|
|
|
const { endpoint, ...newEntity } = newEntityData
|
|
|
|
return postJSON(`/project/${projectId}/${endpoint}`, {
|
|
|
|
body: {
|
|
|
|
parent_folder_id: parentFolderId,
|
2021-04-27 07:52:58 +00:00
|
|
|
...newEntity,
|
|
|
|
},
|
2020-11-26 14:22:30 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function getEntityPathName(entityType) {
|
|
|
|
return entityType === 'fileRef' ? 'file' : entityType
|
|
|
|
}
|