[WIKI-181] chore: asset check endpoint added #7140
This commit is contained in:
parent
0f828fd5e0
commit
151fc8389e
7 changed files with 38 additions and 0 deletions
|
|
@ -29,6 +29,10 @@ export const useEditorConfig = () => {
|
|||
const { projectId, workspaceId, workspaceSlug } = args;
|
||||
|
||||
return {
|
||||
checkIfAssetExists: async (assetId: string) => {
|
||||
const res = await fileService.checkIfAssetExists(workspaceSlug, assetId);
|
||||
return res?.exists ?? false;
|
||||
},
|
||||
getAssetSrc: async (path) => {
|
||||
if (!path) return "";
|
||||
if (path?.startsWith("http")) {
|
||||
|
|
|
|||
|
|
@ -236,6 +236,19 @@ export class FileService extends APIService {
|
|||
});
|
||||
}
|
||||
|
||||
async checkIfAssetExists(
|
||||
workspaceSlug: string,
|
||||
assetId: string
|
||||
): Promise<{
|
||||
exists: boolean;
|
||||
}> {
|
||||
return this.get(`/api/assets/v2/workspaces/${workspaceSlug}/check/${assetId}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async restoreOldEditorAsset(workspaceId: string, src: string): Promise<void> {
|
||||
const assetKey = getAssetIdFromUrl(src);
|
||||
return this.post(`/api/workspaces/file-assets/${workspaceId}/${assetKey}/restore/`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue