| 1 | import type { EnvironmentId } from "@t3tools/contracts"; |
| 2 | |
| 3 | export function folderDropTarget(input: { |
| 4 | localEnvironmentDisabled: boolean; |
| 5 | environmentId: EnvironmentId; |
| 6 | primaryEnvironmentId: EnvironmentId | null; |
| 7 | }): "local" | "remote" { |
| 8 | if ( |
| 9 | input.localEnvironmentDisabled || |
| 10 | input.primaryEnvironmentId === null || |
| 11 | input.environmentId !== input.primaryEnvironmentId |
| 12 | ) { |
| 13 | return "remote"; |
| 14 | } |
| 15 | return "local"; |
| 16 | } |
| 17 | |
| 18 | export function resolveDroppedFolderPath( |
| 19 | folder: File, |
| 20 | getPathForFile: ((file: File) => string) | undefined, |
| 21 | ): string | null { |
| 22 | const path = getPathForFile?.(folder); |
| 23 | return typeof path === "string" && path.length > 0 ? path : null; |
| 24 | } |