2024-11-19 09:13:42 +00:00
|
|
|
import { lazy, Suspense } from "preact/compat"
|
2022-04-08 16:16:12 +01:00
|
|
|
import { useState } from "preact/hooks"
|
2024-01-16 09:44:51 +00:00
|
|
|
import { BridgeConfig, EmbedType } from "../BridgeAPI";
|
2022-04-08 16:16:12 +01:00
|
|
|
import style from "./RoomConfigView.module.scss";
|
|
|
|
import { ConnectionCard } from "./ConnectionCard";
|
2022-05-12 13:06:20 +02:00
|
|
|
import FeedsIcon from "../icons/feeds.png";
|
2022-07-29 10:05:21 -04:00
|
|
|
import GitHubIcon from "../icons/github.png";
|
2022-05-06 09:57:18 +01:00
|
|
|
import GitLabIcon from "../icons/gitlab.png";
|
2022-09-30 11:52:31 -04:00
|
|
|
import JiraIcon from "../icons/jira.png";
|
2022-05-06 09:57:18 +01:00
|
|
|
import WebhookIcon from "../icons/webhook.png";
|
2024-11-18 17:08:52 +00:00
|
|
|
import { ChevronLeftIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
2022-05-06 09:57:18 +01:00
|
|
|
|
2022-04-08 16:16:12 +01:00
|
|
|
|
|
|
|
interface IProps {
|
|
|
|
supportedServices: {[service: string]: boolean},
|
2022-08-18 10:47:03 -04:00
|
|
|
serviceScope?: string,
|
2023-03-08 09:20:13 -05:00
|
|
|
embedType: EmbedType,
|
2022-04-08 16:16:12 +01:00
|
|
|
roomId: string,
|
|
|
|
}
|
|
|
|
|
2022-05-12 13:06:20 +02:00
|
|
|
enum ConnectionType {
|
|
|
|
Feeds = "feeds",
|
|
|
|
Generic = "generic",
|
2024-06-19 18:28:00 +01:00
|
|
|
GenericOutbound = "genericOutbound",
|
2022-07-29 10:05:21 -04:00
|
|
|
Github = "github",
|
2022-05-12 13:06:20 +02:00
|
|
|
Gitlab = "gitlab",
|
2022-09-30 11:52:31 -04:00
|
|
|
Jira = "jira",
|
2022-05-12 13:06:20 +02:00
|
|
|
}
|
|
|
|
|
2022-07-29 10:05:21 -04:00
|
|
|
interface IConnectionProps {
|
|
|
|
displayName: string,
|
|
|
|
description: string,
|
|
|
|
icon: string,
|
2023-12-22 15:44:00 +00:00
|
|
|
darkIcon?: true,
|
2022-07-29 10:05:21 -04:00
|
|
|
component: BridgeConfig,
|
|
|
|
}
|
|
|
|
|
|
|
|
const connections: Record<ConnectionType, IConnectionProps> = {
|
2022-05-12 13:06:20 +02:00
|
|
|
[ConnectionType.Feeds]: {
|
|
|
|
displayName: "RSS/Atom Feeds",
|
|
|
|
description: "Subscribe to an RSS/Atom feed",
|
|
|
|
icon: FeedsIcon,
|
2024-11-19 09:13:42 +00:00
|
|
|
component: lazy(() => import("./roomConfig/FeedsConfig")),
|
2022-05-12 13:06:20 +02:00
|
|
|
},
|
2022-07-29 10:05:21 -04:00
|
|
|
[ConnectionType.Github]: {
|
|
|
|
displayName: 'Github',
|
|
|
|
description: "Connect the room to a GitHub project",
|
|
|
|
icon: GitHubIcon,
|
2023-12-22 15:44:00 +00:00
|
|
|
darkIcon: true,
|
2024-11-19 09:13:42 +00:00
|
|
|
component: lazy(() => import("./roomConfig/GithubRepoConfig")),
|
2022-07-29 10:05:21 -04:00
|
|
|
},
|
2022-05-12 13:06:20 +02:00
|
|
|
[ConnectionType.Gitlab]: {
|
|
|
|
displayName: 'Gitlab',
|
|
|
|
description: "Connect the room to a GitLab project",
|
|
|
|
icon: GitLabIcon,
|
2024-11-19 09:13:42 +00:00
|
|
|
component: lazy(() => import("./roomConfig/GitlabRepoConfig")),
|
2022-05-12 13:06:20 +02:00
|
|
|
},
|
2022-09-30 11:52:31 -04:00
|
|
|
[ConnectionType.Jira]: {
|
|
|
|
displayName: 'JIRA',
|
|
|
|
description: "Connect the room to a JIRA project",
|
|
|
|
icon: JiraIcon,
|
2024-11-19 09:13:42 +00:00
|
|
|
component: lazy(() => import("./roomConfig/JiraProjectConfig")),
|
2022-09-30 11:52:31 -04:00
|
|
|
},
|
2022-05-12 13:06:20 +02:00
|
|
|
[ConnectionType.Generic]: {
|
2024-06-19 18:28:00 +01:00
|
|
|
displayName: 'Inbound (Generic) Webhook',
|
2022-05-12 13:06:20 +02:00
|
|
|
description: "Create a webhook which can be used to connect any service to Matrix",
|
|
|
|
icon: WebhookIcon,
|
2023-12-22 15:44:00 +00:00
|
|
|
darkIcon: true,
|
2024-11-19 09:13:42 +00:00
|
|
|
component: lazy(() => import("./roomConfig/GenericWebhookConfig")),
|
2022-05-12 13:06:20 +02:00
|
|
|
},
|
2024-06-19 18:28:00 +01:00
|
|
|
[ConnectionType.GenericOutbound]: {
|
|
|
|
displayName: 'Outbound Webhook',
|
|
|
|
description: "Create a webhook which can be used to connect any service to Matrix",
|
|
|
|
icon: WebhookIcon,
|
|
|
|
darkIcon: true,
|
2024-11-19 09:13:42 +00:00
|
|
|
component: lazy(() => import("./roomConfig/OutboundWebhookConfig")),
|
2024-06-19 18:28:00 +01:00
|
|
|
},
|
2022-05-12 13:06:20 +02:00
|
|
|
};
|
|
|
|
|
2022-04-08 16:16:12 +01:00
|
|
|
export default function RoomConfigView(props: IProps) {
|
2022-08-18 10:47:03 -04:00
|
|
|
const serviceScope = props.serviceScope && props.supportedServices[props.serviceScope] ? props.serviceScope as ConnectionType : null;
|
|
|
|
const [ activeConnectionType, setActiveConnectionType ] = useState<ConnectionType|null>(serviceScope);
|
2022-04-08 16:16:12 +01:00
|
|
|
|
|
|
|
let content;
|
|
|
|
|
|
|
|
if (activeConnectionType) {
|
2022-05-12 13:06:20 +02:00
|
|
|
const ConfigComponent = connections[activeConnectionType].component;
|
2024-11-19 09:13:42 +00:00
|
|
|
content = <Suspense fallback="loading">
|
|
|
|
<ConfigComponent roomId={props.roomId} showHeader={props.embedType !== EmbedType.IntegrationManager} />
|
|
|
|
</Suspense>;
|
2022-04-08 16:16:12 +01:00
|
|
|
} else {
|
|
|
|
content = <>
|
|
|
|
<section>
|
|
|
|
<h2> Integrations </h2>
|
2022-07-29 10:05:21 -04:00
|
|
|
{(Object.keys(connections) as Array<ConnectionType>).filter(service => props.supportedServices[service]).map((connectionType: ConnectionType) => {
|
2022-05-12 13:06:20 +02:00
|
|
|
const connection = connections[connectionType];
|
|
|
|
return <ConnectionCard
|
|
|
|
serviceName={connection.displayName}
|
|
|
|
description={connection.description}
|
|
|
|
key={connectionType}
|
|
|
|
imageSrc={connection.icon}
|
2023-12-22 15:44:00 +00:00
|
|
|
darkImage={connection.darkIcon}
|
2022-05-12 13:06:20 +02:00
|
|
|
onClick={() => setActiveConnectionType(connectionType)}
|
|
|
|
/>
|
|
|
|
})}
|
2022-04-08 16:16:12 +01:00
|
|
|
</section>
|
|
|
|
</>;
|
|
|
|
}
|
|
|
|
|
|
|
|
return <div className={style.root}>
|
2023-03-08 09:20:13 -05:00
|
|
|
{!serviceScope && activeConnectionType &&
|
|
|
|
<header>
|
2022-08-18 10:47:03 -04:00
|
|
|
<span className={style.backButton} onClick={() => setActiveConnectionType(null)}>
|
2024-11-18 17:08:52 +00:00
|
|
|
<ChevronLeftIcon /> Browse integrations
|
2022-08-18 10:47:03 -04:00
|
|
|
</span>
|
2023-03-08 09:20:13 -05:00
|
|
|
</header>
|
|
|
|
}
|
2022-04-08 16:16:12 +01:00
|
|
|
{content}
|
|
|
|
</div>;
|
2022-05-12 13:06:20 +02:00
|
|
|
}
|