From 1ada015de32dff1d3a87b27f6459a77d36c5bb9e Mon Sep 17 00:00:00 2001 From: Mia Wong Date: Thu, 19 Jan 2023 08:39:03 -0800 Subject: [PATCH] Miawong/sc 59049/auto expand and collapse the the config nav (#3555) --- .../components/config_render/ConfigGroup.jsx | 183 +++++++++--------- .../AppConfig/components/AppConfig.tsx | 44 +++++ .../scss/components/watches/WatchConfig.scss | 9 +- 3 files changed, 140 insertions(+), 96 deletions(-) diff --git a/web/src/components/config_render/ConfigGroup.jsx b/web/src/components/config_render/ConfigGroup.jsx index 03600de22d..25dd2381b7 100644 --- a/web/src/components/config_render/ConfigGroup.jsx +++ b/web/src/components/config_render/ConfigGroup.jsx @@ -15,31 +15,28 @@ import { setOrder } from "./ConfigUtil"; import { ConfigWrapper, ConfigItems } from "./ConfigComponents"; import Icon from "../Icon"; -export default class ConfigGroup extends React.Component { - constructor() { - super(); - this.markdownNode = React.createRef(); - } +const ConfigGroup = (props) => { + const markdownNode = React.createRef(); - handleItemChange = (itemName, value, data) => { - if (this.props.handleChange) { - this.props.handleChange(itemName, value, data); + const handleItemChange = (itemName, value, data) => { + if (props.handleChange) { + props.handleChange(itemName, value, data); } }; - handleAddItem = (itemName) => { - if (this.props.handleAddItem) { - this.props.handleAddItem(itemName); + const handleAddItem = (itemName) => { + if (props.handleAddItem) { + props.handleAddItem(itemName); } }; - handleRemoveItem = (itemName, itemToRemove) => { - if (this.props.handleRemoveItem) { - this.props.handleRemoveItem(itemName, itemToRemove); + const handleRemoveItem = (itemName, itemToRemove) => { + if (props.handleRemoveItem) { + props.handleRemoveItem(itemName, itemToRemove); } }; - renderConfigItems = (items, readonly) => { + const renderConfigItems = (items, readonly) => { if (!items) { return null; } @@ -51,11 +48,11 @@ export default class ConfigGroup extends React.Component { return (