⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
import type { ImportConnectValues } from "@/components/import/connect-values";
import type { ImportSourceId } from "@/components/import/import-source-definitions";
import type { ImportConnection } from "@/fetchers/import/list-import-source-projects";
type BuildConnectionOptions = {
serverHasTrelloKey: boolean;
};
export function buildConnection(
source: ImportSourceId,
values: ImportConnectValues,
{ serverHasTrelloKey }: BuildConnectionOptions,
): ImportConnection | null {
const url = values.url.trim();
const apiKey = values.apiKey.trim();
const token = values.token.trim();
const username = values.username.trim();
const email = values.email.trim();
switch (source) {
case "linear":
return apiKey ? { source, apiKey } : null;
case "jira":
if (!url || !token) return null;
return email
? { source, url, email, apiToken: token }
: { source, url, apiToken: token };
case "trello":
if (!token) return null;
if (serverHasTrelloKey) return { source, token };
return apiKey ? { source, token, apiKey } : null;
case "plane":
return url && apiKey ? { source, url, apiKey } : null;
case "planka":
if (!url) return null;
if (values.plankaSignIn === "apiKey") {
return apiKey ? { source, url, apiKey } : null;
}
return username && values.password
? { source, url, username, password: values.password }
: null;
case "kaneo":
return url && apiKey ? { source, url, apiKey } : null;
default:
return null;
}
}