2023-04-05 19:21:15 +00:00
|
|
|
import React from "react";
|
2023-02-22 14:10:57 +00:00
|
|
|
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
|
2023-02-23 12:42:07 +00:00
|
|
|
import useSWR from "swr";
|
2023-02-22 14:10:57 +00:00
|
|
|
|
|
|
|
// layouts
|
2023-04-08 08:16:46 +00:00
|
|
|
import { ProjectAuthorizationWrapper } from "layouts/auth-layout";
|
2023-02-22 14:10:57 +00:00
|
|
|
// services
|
2023-04-05 19:21:15 +00:00
|
|
|
import IntegrationService from "services/integration";
|
2023-02-22 14:10:57 +00:00
|
|
|
import projectService from "services/project.service";
|
2023-04-05 19:21:15 +00:00
|
|
|
// components
|
2023-05-05 11:37:29 +00:00
|
|
|
import { SettingsHeader, SingleIntegration } from "components/project";
|
2023-02-23 12:42:07 +00:00
|
|
|
// ui
|
2023-07-12 06:15:45 +00:00
|
|
|
import { EmptyState, IntegrationAndImportExportBanner, Loader } from "components/ui";
|
2023-02-22 14:10:57 +00:00
|
|
|
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
2023-02-23 12:42:07 +00:00
|
|
|
// icons
|
|
|
|
import { PlusIcon, PuzzlePieceIcon } from "@heroicons/react/24/outline";
|
2023-07-12 06:15:45 +00:00
|
|
|
// images
|
|
|
|
import emptyIntegration from "public/empty-state/integration.svg";
|
2023-02-22 14:10:57 +00:00
|
|
|
// types
|
2023-04-08 08:16:46 +00:00
|
|
|
import { IProject } from "types";
|
|
|
|
import type { NextPage } from "next";
|
2023-02-22 14:10:57 +00:00
|
|
|
// fetch-keys
|
|
|
|
import { PROJECT_DETAILS, WORKSPACE_INTEGRATIONS } from "constants/fetch-keys";
|
|
|
|
|
2023-04-08 08:16:46 +00:00
|
|
|
const ProjectIntegrations: NextPage = () => {
|
2023-02-23 12:42:07 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug, projectId } = router.query;
|
2023-02-22 14:10:57 +00:00
|
|
|
|
|
|
|
const { data: projectDetails } = useSWR<IProject>(
|
|
|
|
workspaceSlug && projectId ? PROJECT_DETAILS(projectId as string) : null,
|
|
|
|
workspaceSlug && projectId
|
|
|
|
? () => projectService.getProject(workspaceSlug as string, projectId as string)
|
|
|
|
: null
|
|
|
|
);
|
|
|
|
|
2023-02-23 12:42:07 +00:00
|
|
|
const { data: workspaceIntegrations } = useSWR(
|
2023-02-22 14:10:57 +00:00
|
|
|
workspaceSlug ? WORKSPACE_INTEGRATIONS(workspaceSlug as string) : null,
|
|
|
|
() =>
|
2023-04-05 19:21:15 +00:00
|
|
|
workspaceSlug
|
|
|
|
? IntegrationService.getWorkspaceIntegrationsList(workspaceSlug as string)
|
|
|
|
: null
|
2023-02-22 14:10:57 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
2023-04-08 08:16:46 +00:00
|
|
|
<ProjectAuthorizationWrapper
|
2023-02-22 14:10:57 +00:00
|
|
|
breadcrumbs={
|
|
|
|
<Breadcrumbs>
|
|
|
|
<BreadcrumbItem
|
|
|
|
title={`${projectDetails?.name ?? "Project"}`}
|
|
|
|
link={`/${workspaceSlug}/projects/${projectId}/issues`}
|
|
|
|
/>
|
|
|
|
<BreadcrumbItem title="Integrations" />
|
|
|
|
</Breadcrumbs>
|
|
|
|
}
|
|
|
|
>
|
2023-07-11 09:48:47 +00:00
|
|
|
<div className="h-full flex flex-col p-8 overflow-hidden">
|
2023-05-05 11:37:29 +00:00
|
|
|
<SettingsHeader />
|
|
|
|
{workspaceIntegrations ? (
|
|
|
|
workspaceIntegrations.length > 0 ? (
|
2023-07-11 09:48:47 +00:00
|
|
|
<section className="space-y-8 overflow-y-auto">
|
2023-05-18 13:37:01 +00:00
|
|
|
<IntegrationAndImportExportBanner bannerName="Integrations" />
|
2023-05-05 11:37:29 +00:00
|
|
|
<div className="space-y-5">
|
|
|
|
{workspaceIntegrations.map((integration) => (
|
|
|
|
<SingleIntegration
|
|
|
|
key={integration.integration_detail.id}
|
|
|
|
integration={integration}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
) : (
|
2023-07-12 06:15:45 +00:00
|
|
|
<EmptyState
|
|
|
|
title="You haven't configured integrations"
|
|
|
|
description="Configure GitHub and other integrations to sync your project issues."
|
|
|
|
image={emptyIntegration}
|
|
|
|
buttonText="Configure now"
|
|
|
|
onClick={() => router.push(`/${workspaceSlug}/settings/integrations`)}
|
|
|
|
/>
|
2023-05-05 11:37:29 +00:00
|
|
|
)
|
2023-02-23 12:42:07 +00:00
|
|
|
) : (
|
2023-05-05 11:37:29 +00:00
|
|
|
<Loader className="space-y-5">
|
|
|
|
<Loader.Item height="40px" />
|
|
|
|
<Loader.Item height="40px" />
|
|
|
|
<Loader.Item height="40px" />
|
|
|
|
<Loader.Item height="40px" />
|
|
|
|
</Loader>
|
|
|
|
)}
|
|
|
|
</div>
|
2023-04-08 08:16:46 +00:00
|
|
|
</ProjectAuthorizationWrapper>
|
2023-02-22 14:10:57 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ProjectIntegrations;
|