From 71c0e56964e4131953f788eee743b67446019991 Mon Sep 17 00:00:00 2001
From: Dorian Goepp <dorian.goepp@gmail.com>
Date: Tue, 7 May 2019 12:25:48 +0200
Subject: [PATCH] remove legacy code from modeHandler

---
 src/utils/modeHandler.js | 110 ---------------------------------------
 1 file changed, 110 deletions(-)

diff --git a/src/utils/modeHandler.js b/src/utils/modeHandler.js
index 898f635..9507bba 100644
--- a/src/utils/modeHandler.js
+++ b/src/utils/modeHandler.js
@@ -2,116 +2,6 @@ import React, {Component} from 'react';
 import Form from 'react-jsonschema-form';
 import { merge } from 'lodash/object';
 
-export class modeHandler {
-    constructor(object, configGetter, configSetter) {
-        this.target = object
-        this.configGetter = configGetter;
-        this.configSetter = configSetter;
-
-        // get the current config; if it does not exist yet, create it
-        let config = this.configGetter() || {};
-        
-        merge(config, this.announceCapabilities(config));
-        if (config.configurable) {
-            merge(config, this.defaultConfigFromSchema(config));
-        }
-        this.configSetter(config);
-    }
-
-    /**
-     * Search for the 'settingsSchema' and 'readme' properties of the managed component. A corresponding field in the
-     * configuration is set accordingly. This is used to display or not the UI buttons to show the Readme or the
-     * configuration for of a component.
-     * @param {Object} config current configuration of the object
-     * @return the new configuration object (possibly unmodified)
-     */
-    announceCapabilities(config) {
-        if (this.target.settingsSchema) {
-            config.configurable = true;
-        }
-        else {
-            config.configurable = false;
-        }
-        if (this.target.readme) {
-            config.hasReadme = true;
-        }
-        else {
-            config.hasReadme = false;
-        }
-        return config;
-    }
-
-    /**
-     * Search for properties in a JSON Schema. If they are here, use the default value of each JsonSchema property for
-     * the configuration. This means that if a property is already defined in the configuration, it will not be
-     * altered.
-     * @param {Object} config current configuration of the object
-     * @return the new configuration object (possibly unmodified)
-     */
-    defaultConfigFromSchema(config) {
-        const schema = this.target.settingsSchema;
-        if (!schema) {
-            return config;
-        }
-        else if (!('properties' in schema)) {
-            console.warn("no properties in the schema");
-            return config;
-        }
-        else {
-            for (let [key, value] of Object.entries(schema.properties)) {
-                if (!(key in config)) {
-                    let message = "The key '" + key + "' is missing in the configuration.";
-                    if ('default' in value) {
-                        config[key] = value.default;
-                        message += " Using default value '" + value.default + "'.";
-                    }
-                    console.debug(message);
-                }
-            }
-            return config;
-        }
-    }
-
-    /**
-     * Return either the value of the normal parameter, in normal mode, or the content for the `readme` and `settings`
-     * modes.
-     * 
-     * The display mode is defined by the 'displayMode' attribute of the component's configuration.
-     * @param {Jsx} normal The content to return in the normal mode (neither settings nor readme)
-     */
-    modalDisplay(normal) {
-        const config = this.configGetter();
-        if (config && 'displayMode' in config) {
-            if (config.configurable && config.displayMode === "settings") {
-                return (
-                <Form
-                    schema={this.target.settingsSchema}
-                    onSubmit={this.handleSettingsChange.bind(this)}
-                    formData={config} />);
-            }
-            if (config.hasReadme && config.displayMode === "readme") {
-                return this.target.readme;
-            }
-        }
-        return normal;
-    }
-
-    /**
-     * Given a new configuration object (from the form), update the configuration of the component (in FlexLayout).
-     *
-     * The update is done through Lodash's merge function.
-     * @param {Object} value update for the configuration of the component (we take the field formData)
-     * @return Also return the updated configuration.
-     */
-    handleSettingsChange({ formData }) {
-        let config = this.configGetter();
-        merge(config, formData);
-        this.configSetter(config);
-        return config;
-    }
-    
-}
-
 export class Modal extends Component {
     constructor(props) {
         super(props);
-- 
GitLab