Files
plane/web/ee/components/integrations/slack/root.tsx
Saurabh Kumar 207e85e3a1 [SILO] : Importer and integrations db migration changes (#2363)
* `silo` refactoring changes  (#2304)

* add sdk and services for workspace connection and import jobs

* rename service

* move worker folder to root + remove controller folder

* remove controller folder

* add external api service in silo

* fix params in service

* fix params in service

* fix services + remove projectid in job endpoints

* chore: added generic config types for job store (#2158)

* chore: made import job as generic

* chore: added generic parameter inside the job service

* chore: added generic parameter inside the job service

* feat: remove projectId from jobs endpoint

* chore: modified job store for new services

* chore: revert go.mod.sum

* chore: spaces

* gitlab auth callback

* github controllers update with plane api

* create api client fix

* base integration importer store

* remove junk store

* silo external api token middleware + plane api to generate user tokens

* add ahmac permission method in apiserver + ahmac sign flow on silo

* remove junk

* getapi client remove unwanted options

* modify api route for silo access + github gitlab and slack controller clean up

* types modify + jira importer cleanup

* fix: nodemon setup

* make getAPIClient as a singleton

* chore: added new definitions in base-import-worker

* chore: modified jira migrator to adhere to the modified types

* feat: modified base migrator to adhere new types

* chore: modified jira-server-migrator to adhere new changes

* chore: modified asana importer to adhere to new types

* fix: migrated importer controllers for new schema

* fix: build

* chore: asana and linear controller

* feat: updated job controller for new schema changes

* chore: added permissions

* integrations api migrations changes (#2193)

* chore: added workspace_slug inside job data

* replaced ahmac with hmac implementation

* add new service base api view for microservices

* fix: apiserver changes and base view

* feat: added changes to services

* feat: modified engine controller for using api services

* feat: modified UI stores for modified jira importer

* remove-log

* resolve hmac issue + silo endpoint url fixes

* add silo target access token rotation in get

* integration ui migration changes

* revert changes in il8n

* fix crud for api

* fix crud for api

* fix: batch lock config

* fix silo bundler issue (#2233)

* chore: combined common dashboard components for silo (#2166)

* chore: added new types to job store

* feat: updated job store dependencies for new params

* feat: created common components for importers dashboard

* feat: modified jira importer to comply with new common components

* feat: modified jira server dashboard to comply with the new component changes

* feat: modified asana to comply with the common dashboard changes

* fix: linear to comply with the new changes

* reset job store

* feat: migrated importers to new schema

* fix: removed unused code

* fix: base job importer model and serializer

* fix-lint-errors

---------

Co-authored-by: Saurabh Kumar <70131915+Saurabhkmr98@users.noreply.github.com>

* fix api serialisers

* fix: stabilized all integrations and jira importer

* fix: linear, asana and jira-server importers

* fix: reinstantiated hmac permission

* chore: removed the db folder for silo

* feat: added types for integration config

* feat: added check for supported integration in silo and web

* feat: added self hosted and cloud message differences

* add en translations for importers and jira importer (#2264)

* feat: Added language support for integrations (#2277)

* feat: added translations for github, slack and gitlab integrations

* fix: slack integration project modal

* fix: gitlab organization disconnect

* fix: silo build fixes

* feat: added more language to integration language support

* fix: review

* feat: modified caddy and compose for silo selfhosted changes (#2276)

* silo - fixes for keys and integrations form reset (#2283)

* fix hardcoded values for integration importer keys

* reset state after integration form submit

* fix missing key integration

* fix gitlab connection update

* fix: added slack images being updated while creating issues (#2288)

Co-authored-by: Saurabh Kumar <70131915+Saurabhkmr98@users.noreply.github.com>

* silo - fix integration lang support (#2291)

* fix hardcoded values for integration importer keys

* reset state after integration form submit

* fix missing translation key integration

* fix gitlab connection update

* fix integration lang support

* fix integration lang support

---------

Co-authored-by: Saurabhkmr98 <saurabhkapur73@gmail.com>
Co-authored-by: Saurabh Kumar <70131915+Saurabhkmr98@users.noreply.github.com>

* [SILO-71] flatfile importer v1 (#2156)

* feat: initialized CSV importer

* feat: added flatfile components

* feat: setup workbook and listener for csv importer

* feat: added store structure for flatfile importer

* chore: translated csv importer to flatfile importer

* feat: setup listener

* fix: event listener for creating agent

* feat: added flatfile importer skeleton

* feat: added flatfile etl logic for pulling and transforming data

* feat: added flatfile controller and migrator

* feat: curated flatfile root store and importer UI

* feat: initialized flatfile migrator

* fix: flatfile

* feat: added transformers for cycles and issues

* feat: added mapping and transformation for flatfile

* feat: added assignee field for fixing migrator bugs

* fix:build

* feat: added metrics inside the data import task'

* fix:workbook

* feat: added validation of email and date for flatfile

* add sdk and services for workspace connection and import jobs

* rename service

* move worker folder to root + remove controller folder

* remove controller folder

* feat: added modules and issue types inside flatfile

* fix: build

* fix:response-handler

* fix:errors

* fix:deleted-file

* fix: readded jobs route

* add external api service in silo

* fix params in service

* fix params in service

* fix services + remove projectid in job endpoints

* chore: added generic config types for job store (#2158)

* chore: made import job as generic

* chore: added generic parameter inside the job service

* chore: added generic parameter inside the job service

* feat: remove projectId from jobs endpoint

* chore: modified job store for new services

* chore: revert go.mod.sum

* chore: spaces

* gitlab auth callback

* github controllers update with plane api

* create api client fix

* base integration importer store

* remove junk store

* silo external api token middleware + plane api to generate user tokens

* add ahmac permission method in apiserver + ahmac sign flow on silo

* remove junk

* getapi client remove unwanted options

* modify api route for silo access + github gitlab and slack controller clean up

* types modify + jira importer cleanup

* fix: nodemon setup

* make getAPIClient as a singleton

* chore: added new definitions in base-import-worker

* chore: modified jira migrator to adhere to the modified types

* feat: modified base migrator to adhere new types

* chore: modified jira-server-migrator to adhere new changes

* chore: modified asana importer to adhere to new types

* fix: migrated importer controllers for new schema

* fix: build

* chore: asana and linear controller

* feat: updated job controller for new schema changes

* chore: added permissions

* integrations api migrations changes (#2193)

* chore: added workspace_slug inside job data

* replaced ahmac with hmac implementation

* add new service base api view for microservices

* fix: apiserver changes and base view

* feat: added changes to services

* feat: modified engine controller for using api services

* feat: modified UI stores for modified jira importer

* remove-log

* resolve hmac issue + silo endpoint url fixes

* add silo target access token rotation in get

* integration ui migration changes

* revert changes in il8n

* fix crud for api

* fix crud for api

* fix: batch lock config

* fix silo bundler issue (#2233)

* chore: combined common dashboard components for silo (#2166)

* chore: added new types to job store

* feat: updated job store dependencies for new params

* feat: created common components for importers dashboard

* feat: modified jira importer to comply with new common components

* feat: modified jira server dashboard to comply with the new component changes

* feat: modified asana to comply with the common dashboard changes

* fix: linear to comply with the new changes

* reset job store

* feat: migrated importers to new schema

* fix: removed unused code

* fix: base job importer model and serializer

* fix-lint-errors

---------

Co-authored-by: Saurabh Kumar <70131915+Saurabhkmr98@users.noreply.github.com>

* fix api serialisers

* fix: stabilized all integrations and jira importer

* fix: linear, asana and jira-server importers

* fix: reinstantiated hmac permission

* chore: removed the db folder for silo

* feat: added types for integration config

* feat: added check for supported integration in silo and web

* feat: added self hosted and cloud message differences

* add en translations for importers and jira importer (#2264)

* feat: Added language support for integrations (#2277)

* feat: added translations for github, slack and gitlab integrations

* fix: slack integration project modal

* fix: gitlab organization disconnect

* fix: silo build fixes

* feat: added more language to integration language support

* fix: review

* feat: modified caddy and compose for silo selfhosted changes (#2276)

* silo - fixes for keys and integrations form reset (#2283)

* fix hardcoded values for integration importer keys

* reset state after integration form submit

* fix missing key integration

* fix gitlab connection update

* fix: added slack images being updated while creating issues (#2288)

Co-authored-by: Saurabh Kumar <70131915+Saurabhkmr98@users.noreply.github.com>

* silo - fix integration lang support (#2291)

* fix hardcoded values for integration importer keys

* reset state after integration form submit

* fix missing translation key integration

* fix gitlab connection update

* fix integration lang support

* fix integration lang support

* feat: added controllers as default exports

* feat: modified flatfile worker and controller to adhere new changes

* feat: modified flatfile importer to ahere silo api migration

* fix: source project and workspace hide props

---------

Co-authored-by: Saurabhkmr98 <saurabhkapur73@gmail.com>
Co-authored-by: Saurabh Kumar <70131915+Saurabhkmr98@users.noreply.github.com>

* add fuzzy find in state and priority mapping (#2310)

Co-authored-by: Saurabhkmr98 <saurabhkapur73@gmail.com>
Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>

* fix: build

* chore: moved flatfile agent to external

* chore:build-fixes

* fix: credential breaking for slack

* fix: credential route for api

* SILO - chore: Importers translation (#2352)

* add en translations for importers and jira importer

* add en translations for all the importers

* add importers language translation changes

* chore silo importer translation

* chore silo importer translation

* fix: env removing trailing slashes

* fix: trailing slashed env

* fix duplicate entity connection issue (#2362)

---------

Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com>
Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2025-01-31 20:18:17 +05:30

124 lines
4.0 KiB
TypeScript

import { observer } from "mobx-react";
// ui
import { useParams } from "next/navigation";
import useSWR from "swr";
import { useTranslation } from "@plane/i18n";
import { TOAST_TYPE, setToast } from "@plane/ui";
// plane web components
import { ConnectedAppCard } from "@/plane-web/components/integrations/slack";
import { InstallationCard, PersonalAccountInstallationCard } from "@/plane-web/components/integrations/ui";
// hooks
import { useSlackIntegration } from "@/plane-web/hooks/store/integrations/use-slack";
// assets
import SlackLogo from "@/public/services/slack.png";
export const SlackIntegrationRoot = observer(() => {
// router
const { workspaceSlug } = useParams();
// store hooks
const {
isAppConnectionLoading,
isUserConnectionLoading,
isAppConnected,
isUserConnected,
appConnectionIds,
getAppByConnectionId,
fetchAppConnections,
fetchUserConnectionStatus,
connectApp,
disconnectApp,
connectUser,
disconnectUser,
} = useSlackIntegration();
const { t } = useTranslation();
// swr
useSWR(
workspaceSlug ? `SLACK_APP_CONNECTIONS_${workspaceSlug?.toString()}` : null,
workspaceSlug ? async () => fetchAppConnections() : null,
{ errorRetryCount: 0, revalidateOnFocus: false, revalidateIfStale: false }
);
useSWR(
workspaceSlug ? `SLACK_USER_CONNECTION_STATUS_${workspaceSlug?.toString()}` : null,
workspaceSlug ? async () => fetchUserConnectionStatus() : null,
{ errorRetryCount: 0, revalidateOnFocus: false, revalidateIfStale: false }
);
const handleAppInstall = async () => {
try {
const response = await connectApp();
if (response) window.open(response, "_self");
} catch (error) {
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: error?.toString() || "Something went wrong while installing Slack app",
});
}
};
const handlePersonalAccountConnect = async () => {
try {
if (isUserConnected) await disconnectUser();
else {
const response = await connectUser();
if (response) window.open(response, "_self");
}
} catch (error) {
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message:
error?.toString() ||
`Something went wrong while ${isUserConnected ? "disconnecting" : "connecting"} personal account`,
});
}
};
const handleAppDisconnect = async (connectionId: string) => {
try {
await disconnectApp(connectionId);
} catch (error) {
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: error?.toString() || "Something went wrong while disconnecting Slack app",
});
}
};
return (
<>
{/* header */}
<InstallationCard
providerName={t("slack_integration.name")}
providerDescription={t("slack_integration.description")}
providerLogo={SlackLogo}
isConnectionLoading={isAppConnectionLoading}
isAppConnected={isAppConnected}
handleInstallation={handleAppInstall}
/>
{isAppConnected && (
<PersonalAccountInstallationCard
providerName="Slack"
isConnectionLoading={isUserConnectionLoading}
isUserConnected={isUserConnected}
handleConnection={handlePersonalAccountConnect}
/>
)}
{/* List of connected workspaces */}
{appConnectionIds && appConnectionIds.length > 0 && (
<div className="flex-shrink-0 relative flex flex-col border-t border-custom-border-100 py-4 px-2">
<div className="font-medium">{t("slack_integration.connected_slack_workspaces")}</div>
<div className="w-full h-full flex flex-col gap-4 py-4">
{appConnectionIds?.map((appId) => {
const app = getAppByConnectionId(appId);
if (!app) return null;
return <ConnectedAppCard key={appId} data={app} handleDisconnect={handleAppDisconnect} />;
})}
</div>
</div>
)}
</>
);
});