Move components from root to elements

This commit is contained in:
Half-Shot 2022-05-05 16:28:24 +01:00
parent f3b6b939ce
commit ff117ee5de
17 changed files with 24 additions and 23 deletions

View File

@ -3,7 +3,7 @@ import { h, Component } from 'preact';
import WA from 'matrix-widget-api';
import BridgeAPI, { BridgeAPIError } from './BridgeAPI';
import { BridgeRoomState } from '../src/Widgets/BridgeWidgetInterface';
import ErrorPane from './components/ErrorPane';
import ErrorPane from './components/elements';
import AdminSettings from './components/AdminSettings';
import RoomConfigView from './components/RoomConfigView';

View File

@ -29,6 +29,12 @@ export default function RoomConfigView(props: IProps) {
content = <>
<section>
<h2> Integrations </h2>
{props.supportedServices["generic"] && <ConnectionCard
imageSrc="./icons/webhook.png"
serviceName="Generic Webhook"
description="Create a webhook which can be used to connect any service to Matrix"
onClick={() => setActiveConnectionType("generic")}
/>}
{props.supportedServices["gitlab"] && <ConnectionCard
imageSrc="./icons/gitlab.png"
serviceName="GitLab"

View File

@ -1,5 +1,5 @@
import { h } from "preact";
import { Button } from "../Button";
import { Button } from "../elements";
export default function GeneralConfig() {
return <div>

View File

@ -1,7 +1,7 @@
import { h } from "preact";
import { FunctionComponent, h } from "preact";
import style from "./Button.module.scss";
export function Button(props: { [key: string]: unknown, intent?: string}) {
export const Button: FunctionComponent = (props: { [key: string]: unknown, intent?: string}) => {
let className = style.button;
if (props.intent === "remove") {
className += ` ${ style.remove}`;

View File

@ -1,9 +1,8 @@
import { FunctionComponent, h } from "preact";
import style from "./ButtonSet.module.scss";
const ButtonSet: FunctionComponent = (props) => {
export const ButtonSet: FunctionComponent = (props) => {
return <div className={style.buttonSet}>
{props.children}
</div>;
}
export default ButtonSet;
}

View File

@ -1,11 +1,9 @@
import { h, FunctionComponent } from "preact";
import "./ErrorPane.css";
const ErrorPane: FunctionComponent<{header?: string}> = ({ children, header }) => {
export const ErrorPane: FunctionComponent<{header?: string}> = ({ children, header }) => {
return <div class="card error error-pane">
<h3>{ header || "Error occured during widget load" }</h3>
<p>{children}</p>
</div>;
};
export default ErrorPane;
};

View File

@ -7,11 +7,9 @@ interface Props {
noPadding: boolean;
}
const InputField: FunctionComponent<Props> = ({ children, visible = true, label, noPadding }) => {
export const InputField: FunctionComponent<Props> = ({ children, visible = true, label, noPadding }) => {
return visible && <div className={style.inputField}>
{label && <label className={noPadding ? style.nopad : ""}>{label}</label>}
{children}
</div>;
};
export default InputField;
};

View File

@ -0,0 +1,5 @@
export * from "./Button";
export * from "./ButtonSet";
export * from "./ErrorPane";
export * from "./InputField";
export * from "./ListItem";

View File

@ -2,12 +2,10 @@ import { h, FunctionComponent, createRef } from "preact";
import { useCallback, useState } from "preact/hooks"
import CodeMirror from '@uiw/react-codemirror';
import { javascript } from '@codemirror/lang-javascript';
import { Button } from "../Button";
import BridgeAPI from "../../BridgeAPI";
import { GenericHookConnectionState, GenericHookResponseItem } from "../../../src/Connections/GenericHook";
import { ConnectionConfigurationProps, RoomConfig } from "./RoomConfig";
import InputField from "../InputField";
import ButtonSet from "../ButtonSet";
import { InputField, ButtonSet, Button } from "../elements";
const EXAMPLE_SCRIPT = `if (data.counter === undefined) {
result = {

View File

@ -3,10 +3,7 @@ import { useState, useCallback, useEffect, useMemo } from "preact/hooks";
import BridgeAPI from "../../BridgeAPI";
import { ConnectionConfigurationProps, RoomConfig } from "./RoomConfig";
import { GitLabRepoConnectionState, GitLabRepoResponseItem, GitLabTargetFilter, GitLabRepoConnectionTarget, GitLabRepoConnectionProjectTarget, GitLabRepoConnectionInstanceTarget } from "../../../src/Connections/GitlabRepo";
import InputField from "../InputField";
import ButtonSet from "../ButtonSet";
import { Button } from "../Button";
import ErrorPane from "../ErrorPane";
import { InputField, ButtonSet, Button, ErrorPane } from "../elements";
const EventType = "uk.half-shot.matrix-hookshot.gitlab.repository";

View File

@ -2,7 +2,7 @@ import { h, FunctionComponent } from "preact";
import { useCallback, useEffect, useReducer, useState } from "preact/hooks"
import { ListItem } from "../ListItem";
import BridgeAPI from "../../BridgeAPI";
import ErrorPane from "../ErrorPane";
import { ErrorPane } from "../elements";
import style from "./RoomConfig.module.scss";
import { GetConnectionsResponseItem } from "../../../src/provisioning/api";