diff --git a/CHANGELOG.md b/CHANGELOG.md index a13b329f1..d3453aa0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +- [#276](https://github.com/os2display/display-admin-client/pull/276) + - Added Colibo feed type form. + - Fixed feed type selector when unsupported type. + ## [2.4.0] - 2025-03-31 - [#281](https://github.com/os2display/display-admin-client/pull/281) diff --git a/src/components/feed-sources/feed-source-form.jsx b/src/components/feed-sources/feed-source-form.jsx index 82410fd18..31b7d2d8f 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, Row, Col } from "react-bootstrap"; +import { Alert, Button, Row, Col } from "react-bootstrap"; import { useTranslation } from "react-i18next"; import { useNavigate } from "react-router-dom"; import PropTypes from "prop-types"; @@ -12,6 +12,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"; import StickyFooter from "../util/sticky-footer"; import EventDatabaseApiV2FeedType from "./templates/event-database-v2-feed-type"; @@ -22,7 +23,6 @@ import EventDatabaseApiV2FeedType from "./templates/event-database-v2-feed-type" * @param {object} props.feedSource The feed-source object to modify in the form. * @param {Function} props.handleInput Handles form input. * @param {Function} props.handleSubmit Handles form submit. - * @param {Function} props.handleSaveNoClose Handles form submit with close. * @param {string} props.headerText Headline text. * @param {boolean} [props.isLoading] Indicator of whether the form is loading. * Default is `false` @@ -32,6 +32,7 @@ import EventDatabaseApiV2FeedType from "./templates/event-database-v2-feed-type" * @param {string} props.mode The mode * @param {Function} props.onFeedTypeChange Callback on feed type change. * @param {Function} props.handleSecretInput Callback on secret input change. + * @param {Function} props.handleSaveNoClose Handles save but stays on page. * @returns {object} The feed-source form. */ function FeedSourceForm({ @@ -50,6 +51,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 ( <>
@@ -77,15 +82,33 @@ function FeedSourceForm({ value={feedSource.description} onChange={handleInput} /> - + {typeInOptions && ( + + )} + {!typeInOptions && ( + <> + {}} + /> + + {t("feed-type-not-supported")} + + + )} {feedSource?.feedType === "App\\Feed\\CalendarApiFeedType" && ( )} + {feedSource?.feedType === "App\\Feed\\ColiboFeedType" && ( + + )} {feedSource?.feedType === "App\\Feed\\EventDatabaseApiFeedType" && ( { + 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/recipients"; + + 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, + allowed_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 254e2051e..bc5536436 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 && (