hololake-system-architecture/product-source/hololake-platform/src/utils/viewTargetVault.ts

22 lines
625 B
TypeScript
Raw Normal View History

interface ViewCreationVaultPathOptions {
editingRootPath?: string
fallbackVaultPath: string
graphDefaultWorkspacePath: string
multiWorkspaceEnabled: boolean
}
function usablePath(path: string | null | undefined): string | null {
const trimmed = path?.trim()
return trimmed ? trimmed : null
}
export function viewCreationVaultPath({
editingRootPath,
fallbackVaultPath,
graphDefaultWorkspacePath,
multiWorkspaceEnabled,
}: ViewCreationVaultPathOptions): string {
return usablePath(editingRootPath)
?? (multiWorkspaceEnabled ? usablePath(graphDefaultWorkspacePath) : null)
?? fallbackVaultPath
}