diff --git a/components/admin_console/custom_plugin_settings/custom_plugin_settings.jsx b/components/admin_console/custom_plugin_settings/custom_plugin_settings.jsx
index 8e4e43a0b78e..1681a800b841 100644
--- a/components/admin_console/custom_plugin_settings/custom_plugin_settings.jsx
+++ b/components/admin_console/custom_plugin_settings/custom_plugin_settings.jsx
@@ -4,13 +4,18 @@
import SchemaAdminSettings from 'components/admin_console/schema_admin_settings.jsx';
export default class CustomPluginSettings extends SchemaAdminSettings {
- componentWillReceiveProps = (nextProps) => {
- if (nextProps.schema !== this.props.schema) {
+ constructor(props) {
+ super(props);
+ this.isPlugin = true;
+ }
+
+ componentWillReceiveProps(nextProps) {
+ if (!this.props.schema && nextProps.schema) {
this.setState(this.getStateFromConfig(nextProps.config, nextProps.schema));
}
}
- getConfigFromState = (config) => {
+ getConfigFromState(config) {
const schema = this.props.schema;
if (schema) {
@@ -23,14 +28,19 @@ export default class CustomPluginSettings extends SchemaAdminSettings {
const settings = schema.settings || [];
settings.forEach((setting) => {
const lowerKey = setting.key.toLowerCase();
- configSettings[lowerKey] = this.state[lowerKey];
+ const value = this.state[lowerKey] || setting.default;
+ if (value == null) {
+ Reflect.deleteProperty(configSettings, lowerKey);
+ } else {
+ configSettings[lowerKey] = value;
+ }
});
}
return config;
}
- getStateFromConfig = (config, schema = this.props.schema) => {
+ getStateFromConfig(config, schema = this.props.schema) {
const state = {};
if (schema) {
diff --git a/components/admin_console/schema_admin_settings.jsx b/components/admin_console/schema_admin_settings.jsx
index 86b25d07dec0..65c85cc58e45 100644
--- a/components/admin_console/schema_admin_settings.jsx
+++ b/components/admin_console/schema_admin_settings.jsx
@@ -459,7 +459,12 @@ export default class SchemaAdminSettings extends AdminSettings {
if (schema.settings) {
schema.settings.forEach((setting) => {
if (this.buildSettingFunctions[setting.type] && !this.isHidden(setting)) {
- settingsList.push(this.buildSettingFunctions[setting.type](setting));
+ // This is a hack required as plugin settings are case insensitive
+ let s = setting;
+ if (this.isPlugin) {
+ s = {...setting, key: setting.key.toLowerCase()};
+ }
+ settingsList.push(this.buildSettingFunctions[setting.type](s));
}
});
}
@@ -496,7 +501,7 @@ export default class SchemaAdminSettings extends AdminSettings {
render = () => {
const schema = this.props.schema;
- if (schema.component) {
+ if (schema && schema.component) {
const CustomComponent = schema.component;
return (