2020-11-26 09:22:30 -05: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 03:52:58 -04:00
|
|
|
name: newName,
|
|
|
|
},
|
2020-11-26 09:22:30 -05: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 03:52:58 -04:00
|
|
|
folder_id: toFolderId,
|
|
|
|
},
|
2020-11-26 09:22:30 -05:00
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function syncCreateEntity(projectId, parentFolderId, newEntityData) {
|
|
|
|
const { endpoint, ...newEntity } = newEntityData
|
|
|
|
return postJSON(`/project/${projectId}/${endpoint}`, {
|
|
|
|
body: {
|
|
|
|
parent_folder_id: parentFolderId,
|
2021-04-27 03:52:58 -04:00
|
|
|
...newEntity,
|
|
|
|
},
|
2020-11-26 09:22:30 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function getEntityPathName(entityType) {
|
|
|
|
return entityType === 'fileRef' ? 'file' : entityType
|
|
|
|
}
|