From 683e149eebbc9a3b02dcc7b39c08dd5793d0c0a1 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Sun, 14 Jan 2024 17:41:52 +0100 Subject: [PATCH 1/2] #369: Changed how theme logo is loaded --- src/components/themes/theme-form.jsx | 2 +- src/components/themes/theme-manager.jsx | 24 ++---------------------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/src/components/themes/theme-form.jsx b/src/components/themes/theme-form.jsx index a58f4b40..b5368216 100644 --- a/src/components/themes/theme-form.jsx +++ b/src/components/themes/theme-form.jsx @@ -113,7 +113,7 @@ ThemeForm.defaultProps = { ThemeForm.propTypes = { theme: PropTypes.shape({ cssStyles: PropTypes.string, - logo: PropTypes.string, + logo: PropTypes.shape({}), description: PropTypes.string, title: PropTypes.string, }), diff --git a/src/components/themes/theme-manager.jsx b/src/components/themes/theme-manager.jsx index bff4d3a1..b6ddd2d9 100644 --- a/src/components/themes/theme-manager.jsx +++ b/src/components/themes/theme-manager.jsx @@ -2,11 +2,8 @@ import { React, useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import PropTypes from "prop-types"; import { useNavigate } from "react-router-dom"; -import { useDispatch } from "react-redux"; import ThemeForm from "./theme-form"; -import idFromUrl from "../util/helpers/id-from-url"; import { - api, usePostV1ThemesMutation, usePutV1ThemesByIdMutation, usePostMediaCollectionMutation, @@ -37,7 +34,6 @@ function ThemeManager({ // Hooks const { t } = useTranslation("common", { keyPrefix: "theme-manager" }); const navigate = useNavigate(); - const dispatch = useDispatch(); // State const [headerText] = useState( @@ -76,23 +72,7 @@ function ThemeManager({ /** Set loaded data into form state. */ useEffect(() => { - if (initialState) { - if (initialState.logo) { - dispatch( - api.endpoints.getV1MediaById.initiate({ - id: idFromUrl(initialState.logo), - }) - ) - .then(({ data }) => { - setFormStateObject({ ...initialState, logo: data }); - }) - .catch((err) => { - displayError(t("error-messages.save-media-error"), err); - }); - } else { - setFormStateObject(initialState); - } - } + setFormStateObject(initialState); }, [initialState]); /** @@ -242,7 +222,7 @@ ThemeManager.defaultProps = { ThemeManager.propTypes = { initialState: PropTypes.shape({ - logo: PropTypes.string, + logo: PropTypes.shape({}), }), saveMethod: PropTypes.string.isRequired, id: PropTypes.string, From ee683ad0211bdcc4a531222912022eacfa854299 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Sun, 14 Jan 2024 17:46:26 +0100 Subject: [PATCH 2/2] #369: Updated changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 570a3adf..769dd70d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +- [#227](https://github.com/os2display/display-admin-client/pull/227) + - Changed how theme is loaded following change to API - Added fetch all to avoid removing slides when saving playlist and all slides have not been fetched. - [#223](https://github.com/os2display/display-admin-client/pull/223) - Updated to API Platform 3