Skip to content

Commit

Permalink
Add dynamic imports for room configs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Nov 18, 2024
1 parent 6571b9f commit b4ca8f8
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 25 deletions.
30 changes: 11 additions & 19 deletions web/components/RoomConfigView.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { useState } from "preact/hooks"
import { lazy, Suspense } from "preact/compat"
import { useEffect, useState } from "preact/hooks"

Check failure on line 2 in web/components/RoomConfigView.tsx

View workflow job for this annotation

GitHub Actions / lint-node

'useEffect' is defined but never used
import { BridgeConfig, EmbedType } from "../BridgeAPI";
import style from "./RoomConfigView.module.scss";
import { ConnectionCard } from "./ConnectionCard";
import { FeedsConfig } from "./roomConfig/FeedsConfig";
import { GenericWebhookConfig } from "./roomConfig/GenericWebhookConfig";
import { OutboundWebhookConfig } from "./roomConfig/OutboundWebhookConfig";
import { GithubRepoConfig } from "./roomConfig/GithubRepoConfig";
import { GitlabRepoConfig } from "./roomConfig/GitlabRepoConfig";
import { JiraProjectConfig } from "./roomConfig/JiraProjectConfig";

import FeedsIcon from "../icons/feeds.png";
import GitHubIcon from "../icons/github.png";
import GitLabIcon from "../icons/gitlab.png";
Expand Down Expand Up @@ -45,40 +39,40 @@ const connections: Record<ConnectionType, IConnectionProps> = {
displayName: "RSS/Atom Feeds",
description: "Subscribe to an RSS/Atom feed",
icon: FeedsIcon,
component: FeedsConfig,
component: lazy(() => import("./roomConfig/FeedsConfig")),
},
[ConnectionType.Github]: {
displayName: 'Github',
description: "Connect the room to a GitHub project",
icon: GitHubIcon,
darkIcon: true,
component: GithubRepoConfig,
component: lazy(() => import("./roomConfig/GithubRepoConfig")),
},
[ConnectionType.Gitlab]: {
displayName: 'Gitlab',
description: "Connect the room to a GitLab project",
icon: GitLabIcon,
component: GitlabRepoConfig,
component: lazy(() => import("./roomConfig/GitlabRepoConfig")),
},
[ConnectionType.Jira]: {
displayName: 'JIRA',
description: "Connect the room to a JIRA project",
icon: JiraIcon,
component: JiraProjectConfig,
component: lazy(() => import("./roomConfig/JiraProjectConfig")),
},
[ConnectionType.Generic]: {
displayName: 'Inbound (Generic) Webhook',
description: "Create a webhook which can be used to connect any service to Matrix",
icon: WebhookIcon,
darkIcon: true,
component: GenericWebhookConfig,
component: lazy(() => import("./roomConfig/GenericWebhookConfig")),
},
[ConnectionType.GenericOutbound]: {
displayName: 'Outbound Webhook',
description: "Create a webhook which can be used to connect any service to Matrix",
icon: WebhookIcon,
darkIcon: true,
component: OutboundWebhookConfig,
component: lazy(() => import("./roomConfig/OutboundWebhookConfig")),
},
};

Expand All @@ -90,10 +84,9 @@ export default function RoomConfigView(props: IProps) {

if (activeConnectionType) {
const ConfigComponent = connections[activeConnectionType].component;
content = <ConfigComponent
roomId={props.roomId}
showHeader={props.embedType !== EmbedType.IntegrationManager}
/>;
content = <Suspense fallback="loading">
<ConfigComponent roomId={props.roomId} showHeader={props.embedType !== EmbedType.IntegrationManager} />
</Suspense>;
} else {
content = <>
<section>
Expand All @@ -114,7 +107,6 @@ export default function RoomConfigView(props: IProps) {
}

return <div className={style.root}>

{!serviceScope && activeConnectionType &&
<header>
<span className={style.backButton} onClick={() => setActiveConnectionType(null)}>
Expand Down
5 changes: 3 additions & 2 deletions web/components/roomConfig/FeedsConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ const roomConfigText: IRoomConfigText = {

const RoomConfigListItemFunc = (c: FeedResponseItem) => c.config.label || c.config.url;

export const FeedsConfig: BridgeConfig = ({ roomId, showHeader }) => {

const FeedsConfig: BridgeConfig = ({ roomId, showHeader }) => {
return <RoomConfig<ServiceConfig, FeedResponseItem, FeedConnectionState>
headerImg={FeedsIcon}
showHeader={showHeader}
Expand All @@ -105,3 +104,5 @@ export const FeedsConfig: BridgeConfig = ({ roomId, showHeader }) => {
connectionConfigComponent={ConnectionConfiguration}
/>;
};

export default FeedsConfig;
2 changes: 2 additions & 0 deletions web/components/roomConfig/GenericWebhookConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,5 @@ export const GenericWebhookConfig: BridgeConfig = ({ roomId, showHeader }) => {
connectionConfigComponent={ConnectionConfiguration}
/>;
};

export default GenericWebhookConfig;
4 changes: 3 additions & 1 deletion web/components/roomConfig/GithubRepoConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const roomConfigText: IRoomConfigText = {

const RoomConfigListItemFunc = (c: GitHubRepoResponseItem) => getRepoFullName(c.config);

export const GithubRepoConfig: BridgeConfig = ({ roomId, showHeader }) => {
const GithubRepoConfig: BridgeConfig = ({ roomId, showHeader }) => {
return <RoomConfig<never, GitHubRepoResponseItem, GitHubRepoConnectionState>
headerImg={GitHubIcon}
darkHeaderImg={true}
Expand All @@ -191,3 +191,5 @@ export const GithubRepoConfig: BridgeConfig = ({ roomId, showHeader }) => {
connectionConfigComponent={ConnectionConfiguration}
/>;
};

export default GithubRepoConfig;
4 changes: 3 additions & 1 deletion web/components/roomConfig/GitlabRepoConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const RoomConfigText = {

const RoomConfigListItemFunc = (c: GitLabRepoResponseItem) => c.config.path;

export const GitlabRepoConfig: BridgeConfig = ({ roomId, showHeader }) => {
const GitlabRepoConfig: BridgeConfig = ({ roomId, showHeader }) => {
return <RoomConfig<never, GitLabRepoResponseItem, GitLabRepoConnectionState>
headerImg={GitLabIcon}
showHeader={showHeader}
Expand All @@ -138,3 +138,5 @@ export const GitlabRepoConfig: BridgeConfig = ({ roomId, showHeader }) => {
connectionConfigComponent={ConnectionConfiguration}
/>;
};

export default GitlabRepoConfig;
4 changes: 3 additions & 1 deletion web/components/roomConfig/JiraProjectConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const RoomConfigText = {

const RoomConfigListItemFunc = (c: JiraProjectResponseItem) => c.config.url;

export const JiraProjectConfig: BridgeConfig = ({ roomId, showHeader }) => {
const JiraProjectConfig: BridgeConfig = ({ roomId, showHeader }) => {
return <RoomConfig<never, JiraProjectResponseItem, JiraProjectConnectionState>
headerImg={JiraIcon}
showHeader={showHeader}
Expand All @@ -122,3 +122,5 @@ export const JiraProjectConfig: BridgeConfig = ({ roomId, showHeader }) => {
connectionConfigComponent={ConnectionConfiguration}
/>;
};

export default JiraProjectConfig;
4 changes: 3 additions & 1 deletion web/components/roomConfig/OutboundWebhookConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const RoomConfigText = {

const RoomConfigListItemFunc = (c: OutboundHookResponseItem) => c.config.name;

export const OutboundWebhookConfig: BridgeConfig = ({ roomId, showHeader }) => {
const OutboundWebhookConfig: BridgeConfig = ({ roomId, showHeader }) => {
return <RoomConfig<ServiceConfig, OutboundHookResponseItem, OutboundHookConnectionState>
headerImg={WebhookIcon}
darkHeaderImg={true}
Expand All @@ -83,3 +83,5 @@ export const OutboundWebhookConfig: BridgeConfig = ({ roomId, showHeader }) => {
connectionConfigComponent={ConnectionConfiguration}
/>;
};

export default OutboundWebhookConfig;

0 comments on commit b4ca8f8

Please sign in to comment.