From dcd3962fe7ad4f1e99d4ac3102711c94f9f74831 Mon Sep 17 00:00:00 2001 From: Peter Donker Date: Fri, 6 Nov 2020 10:14:18 +0100 Subject: [PATCH] Implement EnablePopups switch in portal settings PB module --- .../src/components/moreSettings/index.jsx | 73 ++++--- .../src/components/moreSettings/style.less | 183 +++++++++++------- .../UpdateOtherSettingsRequest.cs | 4 +- .../Services/SiteSettingsController.cs | 7 +- .../App_LocalResources/SiteSettings.resx | 9 + 5 files changed, 173 insertions(+), 103 deletions(-) diff --git a/Dnn.AdminExperience/ClientSide/SiteSettings.Web/src/components/moreSettings/index.jsx b/Dnn.AdminExperience/ClientSide/SiteSettings.Web/src/components/moreSettings/index.jsx index 1f4ca809448..f0f3ff12666 100644 --- a/Dnn.AdminExperience/ClientSide/SiteSettings.Web/src/components/moreSettings/index.jsx +++ b/Dnn.AdminExperience/ClientSide/SiteSettings.Web/src/components/moreSettings/index.jsx @@ -8,7 +8,8 @@ import { GridSystem, InputGroup, Label, - MultiLineInputWithError + MultiLineInputWithError, + Switch, } from "@dnnsoftware/dnn-react-common"; import "./style.less"; import util from "../../utils"; @@ -17,7 +18,7 @@ import styles from "./style.less"; function getError(errors) { let hasError = false; - Object.keys(errors).forEach(key => { + Object.keys(errors).forEach((key) => { if (errors[key] === true) { hasError = true; } @@ -34,7 +35,7 @@ class MoreSettingsPanelBody extends Component { otherSettings: undefined, siteBehaviorExtrasRendered: true, errorInSave: false, - whitelistOption: 0 + whitelistOption: 0, }; isHost = util.settings.isHost; } @@ -42,7 +43,7 @@ class MoreSettingsPanelBody extends Component { loadData() { const { props } = this; props.dispatch( - SiteBehaviorActions.getOtherSettings(props.portalId, data => { + SiteBehaviorActions.getOtherSettings(props.portalId, (data) => { var whitelistOption = 1; if ( data.Settings.AllowedExtensionsWhitelist == @@ -50,13 +51,14 @@ class MoreSettingsPanelBody extends Component { ) { whitelistOption = 0; } else if ( - data.Settings.AllowedExtensionsWhitelist == data.Settings.ImageExtensionsList + data.Settings.AllowedExtensionsWhitelist == + data.Settings.ImageExtensionsList ) { whitelistOption = 2; } this.setState({ otherSettings: Object.assign({}, data.Settings), - whitelistOption: whitelistOption + whitelistOption: whitelistOption, }); }) ); @@ -66,13 +68,13 @@ class MoreSettingsPanelBody extends Component { const { props } = this; if (props.otherSettings) { this.setState({ - otherSettings: props.otherSettings + otherSettings: props.otherSettings, }); return; } this.setState({ siteBehaviorExtrasRendered: true, - whitelistOption: 0 + whitelistOption: 0, }); this.loadData(); } @@ -112,7 +114,7 @@ class MoreSettingsPanelBody extends Component { otherSettings[key] = typeof event === "object" ? event.target.value : event; this.setState({ - otherSettings: otherSettings + otherSettings: otherSettings, }); props.dispatch( @@ -132,7 +134,7 @@ class MoreSettingsPanelBody extends Component { () => {}, () => { this.setState({ - errorInSave: true + errorInSave: true, }); } ) @@ -147,19 +149,19 @@ class MoreSettingsPanelBody extends Component { resx.get("No"), () => { props.dispatch( - SiteBehaviorActions.getOtherSettings(data => { + SiteBehaviorActions.getOtherSettings((data) => { this.setState({ - otherSettings: Object.assign({}, data.Settings) + otherSettings: Object.assign({}, data.Settings), }); }) ); this.setState( { - siteBehaviorExtrasRendered: false + siteBehaviorExtrasRendered: false, }, () => { this.setState({ - siteBehaviorExtrasRendered: true + siteBehaviorExtrasRendered: true, }); } ); @@ -173,11 +175,11 @@ class MoreSettingsPanelBody extends Component { if (!SiteBehaviorExtras || SiteBehaviorExtras.length === 0) { return; } - return SiteBehaviorExtras.sort(function(a, b) { + return SiteBehaviorExtras.sort(function (a, b) { if (a.RenderOrder < b.RenderOrder) return -1; if (a.RenderOrder > b.RenderOrder) return 1; return 0; - }).map(data => { + }).map((data) => { return data.Component; }); } @@ -189,7 +191,7 @@ class MoreSettingsPanelBody extends Component { if (SiteBehaviorExtras && SiteBehaviorExtras.length > 0) { //First, loop through and check there are no errors. - SiteBehaviorExtras.forEach(extra => { + SiteBehaviorExtras.forEach((extra) => { const currentReducer = this.props[extra.ReducerKey]; if (currentReducer.errors && getError(currentReducer.errors)) { @@ -204,7 +206,7 @@ class MoreSettingsPanelBody extends Component { //Only go through the save if none of them have an error. if (!_errorInSave) { - SiteBehaviorExtras.forEach(extra => { + SiteBehaviorExtras.forEach((extra) => { if (typeof extra.SaveMethod === "function") { const currentReducer = this.props[extra.ReducerKey]; @@ -236,7 +238,7 @@ class MoreSettingsPanelBody extends Component { if (this.state.errorInSave) { util.utilities.notifyError(resx.get("SettingsError")); this.setState({ - errorInSave: false + errorInSave: false, }); } else { util.utilities.notify(resx.get("SettingsUpdateSuccess")); @@ -248,7 +250,7 @@ class MoreSettingsPanelBody extends Component { const SiteBehaviorExtras = window.dnn.SiteSettings && window.dnn.SiteSettings.SiteBehaviorExtras; if (SiteBehaviorExtras && SiteBehaviorExtras.length > 0) { - SiteBehaviorExtras.forEach(extra => { + SiteBehaviorExtras.forEach((extra) => { if ( this.props[extra.ReducerKey] && this.props[extra.ReducerKey].formDirty @@ -267,7 +269,7 @@ class MoreSettingsPanelBody extends Component { return [ { label: resx.get("Default"), value: 0 }, { label: resx.get("Custom"), value: 1 }, - { label: resx.get("OnlyImages"), value: 2 } + { label: resx.get("OnlyImages"), value: 2 }, ]; } @@ -317,9 +319,28 @@ class MoreSettingsPanelBody extends Component { {state.siteBehaviorExtrasRendered && this.renderSiteBehaviorExtensions()} {htmlEditor} -
{resx.get("WhitelistSettings")}
+
{resx.get("MoreSettings")}
+ + +
+
+
+
{resx.get("WhitelistSettings")}
+ +
-
+