diff --git a/src/components/feed-sources/feed-source-form.jsx b/src/components/feed-sources/feed-source-form.jsx index 2cce65ae..10414974 100644 --- a/src/components/feed-sources/feed-source-form.jsx +++ b/src/components/feed-sources/feed-source-form.jsx @@ -1,5 +1,5 @@ import { React } from "react"; -import { Button } from "react-bootstrap"; +import { Alert, Button } from "react-bootstrap"; import { useTranslation } from "react-i18next"; import { useNavigate } from "react-router-dom"; import PropTypes from "prop-types"; @@ -13,6 +13,7 @@ import FormInput from "../util/forms/form-input"; import CalendarApiFeedType from "./templates/calendar-api-feed-type"; import NotifiedFeedType from "./templates/notified-feed-type"; import EventDatabaseApiFeedType from "./templates/event-database-feed-type"; +import ColiboFeedType from "./templates/colibo-feed-type.jsx"; /** * The feed-source form component. @@ -47,6 +48,10 @@ function FeedSourceForm({ const { t } = useTranslation("common", { keyPrefix: "feed-source-form" }); const navigate = useNavigate(); + const typeInOptions = + !feedSource?.feedType || + feedSourceTypeOptions.find((el) => el.value === feedSource.feedType); + return ( <>
@@ -72,17 +77,36 @@ function FeedSourceForm({ value={feedSource.description} onChange={handleInput} /> - + {typeInOptions && ( + + )} + {!typeInOptions && ( + <> + {}} + /> + + {t("feed-type-not-supported")} + + + )} - {feedSource?.feedType === "App\\Feed\\CalendarApiFeedType" && ( + {feedSource?.feedType === + "App\\Feed\\SourceType\\Calendar\\CalendarApiFeedType" && ( )} - {feedSource?.feedType === "App\\Feed\\EventDatabaseApiFeedType" && ( + {feedSource?.feedType === + "App\\Feed\\SourceType\\Colibo\\ColiboFeedType" && ( + + )} + {feedSource?.feedType === + "App\\Feed\\SourceType\\EventDatabase\\EventDatabaseApiFeedType" && ( )} - {feedSource?.feedType === "App\\Feed\\NotifiedFeedType" && ( + {feedSource?.feedType === + "App\\Feed\\SourceType\\Notified\\NotifiedFeedType" && ( { + const { t } = useTranslation("common", { + keyPrefix: "colibo-feed-type", + }); + + const [optionsEndpoint, setOptionsEndpoint] = useState(null); + + useEffect(() => { + if (feedSourceId && feedSourceId !== "") { + ConfigLoader.loadConfig().then((config) => { + let endpoint = config.api; + endpoint = endpoint.replace(/\/$/, ""); + endpoint += feedSourceId; + endpoint += "/config/FeedEntryRecipients"; + + setOptionsEndpoint(endpoint); + }); + } + }, [feedSourceId]); + + return ( + <> + {!feedSourceId && ( + + {t("save-before-recipients-can-be-set")} + + )} + + + + + + + + + {t("values-info")} + + + {optionsEndpoint && ( + + )} + + ); +}; + +ColiboFeedType.propTypes = { + handleInput: PropTypes.func, + formStateObject: PropTypes.shape({ + api_base_uri: PropTypes.string, + client_id: PropTypes.string, + client_secret: PropTypes.string, + recipients: PropTypes.arrayOf(PropTypes.string), + }), + feedSourceId: PropTypes.string, + mode: PropTypes.string, +}; + +export default ColiboFeedType; diff --git a/src/components/slide/content/content-form.jsx b/src/components/slide/content/content-form.jsx index 254e2051..435c1f9e 100644 --- a/src/components/slide/content/content-form.jsx +++ b/src/components/slide/content/content-form.jsx @@ -72,7 +72,7 @@ function ContentForm({ } returnElement = ( -
+
{formData?.label && (