feat(tasker): localize NODE.DC workspace seed

This commit is contained in:
DCCONSTRUCTIONS
2026-05-10 19:59:03 +03:00
parent e49840341b
commit d55d182648
30 changed files with 196 additions and 123 deletions
@@ -17,6 +17,9 @@ import { useFileSize } from "@/plane-web/hooks/use-file-size";
import { FileService } from "@/services/file.service";
const fileService = new FileService();
const isHttpUrl = (path?: string) => !!path && /^https?:\/\//i.test(path);
const isPublicPath = (path?: string) => !!path && path.startsWith("/") && !path.startsWith("//");
type TArgs = {
projectId?: string;
uploadFile: TFileHandler["upload"];
@@ -44,7 +47,10 @@ export const useEditorConfig = () => {
return res?.exists ?? false;
},
delete: async (src: string) => {
if (src?.startsWith("http")) {
if (isPublicPath(src)) {
return;
}
if (isHttpUrl(src)) {
await fileService.deleteOldWorkspaceAsset(workspaceId, src);
} else {
await fileService.deleteNewAsset(
@@ -58,7 +64,7 @@ export const useEditorConfig = () => {
},
getAssetDownloadSrc: async (path) => {
if (!path) return "";
if (path?.startsWith("http")) {
if (isHttpUrl(path) || isPublicPath(path)) {
return path;
} else {
return (
@@ -72,7 +78,7 @@ export const useEditorConfig = () => {
},
getAssetSrc: async (path) => {
if (!path) return "";
if (path?.startsWith("http")) {
if (isHttpUrl(path) || isPublicPath(path)) {
return path;
} else {
return (
@@ -85,14 +91,17 @@ export const useEditorConfig = () => {
}
},
restore: async (src: string) => {
if (src?.startsWith("http")) {
if (isPublicPath(src)) {
return;
}
if (isHttpUrl(src)) {
await fileService.restoreOldEditorAsset(workspaceId, src);
} else {
await fileService.restoreNewAsset(workspaceSlug, src);
}
},
upload: uploadFile,
duplicate: duplicateFile,
duplicate: async (assetId: string) => (isPublicPath(assetId) ? assetId : duplicateFile(assetId)),
validation: {
maxFileSize,
},