2023-04-07 07:57:57 +00:00
|
|
|
import { useState } from "react";
|
2023-04-05 19:21:15 +00:00
|
|
|
|
2023-03-23 17:57:11 +00:00
|
|
|
import Link from "next/link";
|
|
|
|
import Image from "next/image";
|
2023-04-05 19:21:15 +00:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
|
2023-04-07 07:57:57 +00:00
|
|
|
import useSWR, { mutate } from "swr";
|
2023-04-05 19:21:15 +00:00
|
|
|
|
2023-06-06 16:06:00 +00:00
|
|
|
// hooks
|
|
|
|
import useUserAuth from "hooks/use-user-auth";
|
2023-04-07 07:57:57 +00:00
|
|
|
// services
|
|
|
|
import IntegrationService from "services/integration";
|
2023-03-23 17:57:11 +00:00
|
|
|
// components
|
2023-04-07 07:57:57 +00:00
|
|
|
import {
|
|
|
|
DeleteImportModal,
|
|
|
|
GithubImporterRoot,
|
|
|
|
JiraImporterRoot,
|
|
|
|
SingleImport,
|
|
|
|
} from "components/integration";
|
2023-04-05 19:21:15 +00:00
|
|
|
// ui
|
2023-04-06 10:36:31 +00:00
|
|
|
import { Loader, PrimaryButton } from "components/ui";
|
2023-04-07 07:57:57 +00:00
|
|
|
// icons
|
|
|
|
import { ArrowPathIcon } from "@heroicons/react/24/outline";
|
|
|
|
import { ArrowRightIcon } from "components/icons";
|
2023-03-23 17:57:11 +00:00
|
|
|
// types
|
2023-04-07 07:57:57 +00:00
|
|
|
import { IImporterService } from "types";
|
2023-04-05 19:21:15 +00:00
|
|
|
// fetch-keys
|
|
|
|
import { IMPORTER_SERVICES_LIST } from "constants/fetch-keys";
|
2023-04-07 07:57:57 +00:00
|
|
|
// constants
|
|
|
|
import { IMPORTERS_EXPORTERS_LIST } from "constants/workspace";
|
2023-03-23 17:57:11 +00:00
|
|
|
|
2023-04-07 07:57:57 +00:00
|
|
|
const IntegrationGuide = () => {
|
2023-04-05 19:21:15 +00:00
|
|
|
const [refreshing, setRefreshing] = useState(false);
|
2023-04-06 10:36:31 +00:00
|
|
|
const [deleteImportModal, setDeleteImportModal] = useState(false);
|
|
|
|
const [importToDelete, setImportToDelete] = useState<IImporterService | null>(null);
|
2023-04-05 19:21:15 +00:00
|
|
|
|
|
|
|
const router = useRouter();
|
2023-04-07 07:57:57 +00:00
|
|
|
const { workspaceSlug, provider } = router.query;
|
|
|
|
|
2023-06-06 16:06:00 +00:00
|
|
|
const { user } = useUserAuth();
|
|
|
|
|
2023-04-07 07:57:57 +00:00
|
|
|
const { data: importerServices } = useSWR(
|
|
|
|
workspaceSlug ? IMPORTER_SERVICES_LIST(workspaceSlug as string) : null,
|
|
|
|
workspaceSlug ? () => IntegrationService.getImporterServicesList(workspaceSlug as string) : null
|
|
|
|
);
|
2023-03-23 17:57:11 +00:00
|
|
|
|
2023-04-06 10:36:31 +00:00
|
|
|
const handleDeleteImport = (importService: IImporterService) => {
|
|
|
|
setImportToDelete(importService);
|
|
|
|
setDeleteImportModal(true);
|
|
|
|
};
|
|
|
|
|
2023-04-05 19:21:15 +00:00
|
|
|
return (
|
2023-04-06 10:36:31 +00:00
|
|
|
<>
|
|
|
|
<DeleteImportModal
|
|
|
|
isOpen={deleteImportModal}
|
|
|
|
handleClose={() => setDeleteImportModal(false)}
|
|
|
|
data={importToDelete}
|
2023-06-06 16:06:00 +00:00
|
|
|
user={user}
|
2023-04-06 10:36:31 +00:00
|
|
|
/>
|
2023-04-24 07:50:41 +00:00
|
|
|
<div className="h-full space-y-2">
|
2023-08-14 06:14:17 +00:00
|
|
|
{(!provider || provider === "csv") && (
|
2023-04-06 10:36:31 +00:00
|
|
|
<>
|
2023-04-24 07:50:41 +00:00
|
|
|
<div className="mb-5 flex items-center gap-2">
|
2023-04-06 10:36:31 +00:00
|
|
|
<div className="h-full w-full space-y-1">
|
|
|
|
<div className="text-lg font-medium">Relocation Guide</div>
|
|
|
|
<div className="text-sm">
|
|
|
|
You can now transfer all the issues that you{"'"}ve created in other tracking
|
|
|
|
services. This tool will guide you to relocate the issue to Plane.
|
|
|
|
</div>
|
2023-04-05 19:21:15 +00:00
|
|
|
</div>
|
2023-05-05 10:15:38 +00:00
|
|
|
<a
|
|
|
|
href="https://docs.plane.so/importers/github"
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
>
|
2023-04-07 07:57:57 +00:00
|
|
|
<div className="flex flex-shrink-0 cursor-pointer items-center gap-2 whitespace-nowrap text-sm font-medium text-[#3F76FF] hover:text-opacity-80">
|
|
|
|
Read More
|
2023-04-06 10:36:31 +00:00
|
|
|
<ArrowRightIcon width={"18px"} color={"#3F76FF"} />
|
|
|
|
</div>
|
2023-04-07 07:57:57 +00:00
|
|
|
</a>
|
2023-03-23 17:57:11 +00:00
|
|
|
</div>
|
2023-04-07 07:57:57 +00:00
|
|
|
<div className="space-y-2">
|
|
|
|
{IMPORTERS_EXPORTERS_LIST.map((service) => (
|
2023-04-24 07:50:41 +00:00
|
|
|
<div
|
|
|
|
key={service.provider}
|
2023-07-17 10:58:23 +00:00
|
|
|
className="rounded-[10px] border border-custom-border-200 bg-custom-background-100 p-4"
|
2023-04-24 07:50:41 +00:00
|
|
|
>
|
2023-04-07 07:57:57 +00:00
|
|
|
<div className="flex items-center gap-4 whitespace-nowrap">
|
|
|
|
<div className="relative h-10 w-10 flex-shrink-0">
|
|
|
|
<Image
|
|
|
|
src={service.logo}
|
|
|
|
layout="fill"
|
|
|
|
objectFit="cover"
|
|
|
|
alt={`${service.title} Logo`}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="w-full">
|
|
|
|
<h3>{service.title}</h3>
|
2023-07-10 07:17:00 +00:00
|
|
|
<p className="text-sm text-custom-text-200">{service.description}</p>
|
2023-04-07 07:57:57 +00:00
|
|
|
</div>
|
|
|
|
<div className="flex-shrink-0">
|
|
|
|
<Link
|
2023-08-14 10:49:13 +00:00
|
|
|
href={`/${workspaceSlug}/settings/imports?provider=${service.provider}`}
|
2023-04-07 07:57:57 +00:00
|
|
|
>
|
|
|
|
<a>
|
|
|
|
<PrimaryButton>
|
|
|
|
<span className="capitalize">{service.type}</span> now
|
|
|
|
</PrimaryButton>
|
|
|
|
</a>
|
|
|
|
</Link>
|
2023-04-06 10:36:31 +00:00
|
|
|
</div>
|
2023-04-05 19:21:15 +00:00
|
|
|
</div>
|
2023-04-07 07:57:57 +00:00
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
2023-07-17 10:58:23 +00:00
|
|
|
<div className="rounded-[10px] border border-custom-border-200 bg-custom-background-100 p-4">
|
2023-04-24 07:50:41 +00:00
|
|
|
<h3 className="mb-2 flex gap-2 text-lg font-medium">
|
2023-04-07 07:57:57 +00:00
|
|
|
Previous Imports
|
|
|
|
<button
|
|
|
|
type="button"
|
2023-07-10 07:17:00 +00:00
|
|
|
className="flex flex-shrink-0 items-center gap-1 rounded bg-custom-background-80 py-1 px-1.5 text-xs outline-none"
|
2023-04-07 07:57:57 +00:00
|
|
|
onClick={() => {
|
|
|
|
setRefreshing(true);
|
|
|
|
mutate(IMPORTER_SERVICES_LIST(workspaceSlug as string)).then(() =>
|
|
|
|
setRefreshing(false)
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<ArrowPathIcon className={`h-3 w-3 ${refreshing ? "animate-spin" : ""}`} />{" "}
|
|
|
|
{refreshing ? "Refreshing..." : "Refresh status"}
|
|
|
|
</button>
|
|
|
|
</h3>
|
|
|
|
{importerServices ? (
|
|
|
|
importerServices.length > 0 ? (
|
|
|
|
<div className="space-y-2">
|
2023-07-17 10:58:23 +00:00
|
|
|
<div className="divide-y divide-custom-border-200">
|
2023-04-07 07:57:57 +00:00
|
|
|
{importerServices.map((service) => (
|
|
|
|
<SingleImport
|
|
|
|
key={service.id}
|
|
|
|
service={service}
|
|
|
|
refreshing={refreshing}
|
|
|
|
handleDelete={() => handleDeleteImport(service)}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
) : (
|
2023-07-10 07:17:00 +00:00
|
|
|
<p className="py-2 text-sm text-custom-text-200">
|
2023-04-24 07:50:41 +00:00
|
|
|
No previous imports available.
|
|
|
|
</p>
|
2023-04-06 10:36:31 +00:00
|
|
|
)
|
2023-03-23 17:57:11 +00:00
|
|
|
) : (
|
2023-04-24 07:50:41 +00:00
|
|
|
<Loader className="mt-6 grid grid-cols-1 gap-3">
|
2023-04-07 07:57:57 +00:00
|
|
|
<Loader.Item height="40px" width="100%" />
|
|
|
|
<Loader.Item height="40px" width="100%" />
|
|
|
|
<Loader.Item height="40px" width="100%" />
|
|
|
|
<Loader.Item height="40px" width="100%" />
|
2023-04-06 10:36:31 +00:00
|
|
|
</Loader>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)}
|
2023-03-23 17:57:11 +00:00
|
|
|
|
2023-06-06 16:06:00 +00:00
|
|
|
{provider && provider === "github" && <GithubImporterRoot user={user} />}
|
|
|
|
{provider && provider === "jira" && <JiraImporterRoot user={user} />}
|
2023-04-06 10:36:31 +00:00
|
|
|
</div>
|
|
|
|
</>
|
2023-04-05 19:21:15 +00:00
|
|
|
);
|
|
|
|
};
|
2023-03-23 17:57:11 +00:00
|
|
|
|
|
|
|
export default IntegrationGuide;
|