Skip to content

Commit

Permalink
refactor(main): change plugin settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mjancarik committed Nov 13, 2019
1 parent 89991a5 commit bb21b23
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 26 deletions.
6 changes: 3 additions & 3 deletions src/__tests__/mountSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('UIAtoms mount rendering', () => {
describe('should render atoms without noscript tag - disabled by $Settings: ', () => {
let mountOptions = getComponentOptions({
plugin: {
imaUiAtoms: {
uiAtoms: {
useIntersectionObserver: {
iframes: true,
images: true,
Expand Down Expand Up @@ -185,7 +185,7 @@ describe('UIAtoms mount rendering', () => {
describe('should render atoms with noscript tag - disabled by $Settings, overriden by props: ', () => {
let mountOptions = getComponentOptions({
plugin: {
imaUiAtoms: {
uiAtoms: {
useIntersectionObserver: {
iframes: true,
images: true,
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('UIAtoms mount rendering', () => {
describe('should render atoms without noscript tag - enabled by $Settings, overriden by props: ', () => {
let mountOptions = getComponentOptions({
plugin: {
imaUiAtoms: {
uiAtoms: {
useIntersectionObserver: {
iframes: true,
images: true,
Expand Down
9 changes: 2 additions & 7 deletions src/iframe/HtmlIframe.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,13 @@ export default class HtmlIframe extends React.PureComponent {
get useIntersectionObserver() {
return this.props.useIntersectionObserver !== undefined
? this.props.useIntersectionObserver
: this._settings.plugin.imaUiAtoms.useIntersectionObserver.iframes !==
undefined
? this._settings.plugin.imaUiAtoms.useIntersectionObserver.iframes
: this._settings.plugin.imaUiAtoms.useIntersectionObserver;
: this._settings.plugin.uiAtoms.useIntersectionObserver.iframes;
}

get disableNoScript() {
return this.props.disableNoScript !== undefined
? this.props.disableNoScript
: this._settings.plugin.imaUiAtoms.disableNoScript.iframes !== undefined
? this._settings.plugin.imaUiAtoms.disableNoScript.iframes
: this._settings.plugin.imaUiAtoms.disableNoScript;
: this._settings.plugin.uiAtoms.disableNoScript.iframes;
}

componentDidMount() {
Expand Down
9 changes: 2 additions & 7 deletions src/image/HtmlImage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,13 @@ export default class HtmlImage extends React.PureComponent {
get useIntersectionObserver() {
return this.props.useIntersectionObserver !== undefined
? this.props.useIntersectionObserver
: this._settings.plugin.imaUiAtoms.useIntersectionObserver.images !==
undefined
? this._settings.plugin.imaUiAtoms.useIntersectionObserver.images
: this._settings.plugin.imaUiAtoms.useIntersectionObserver;
: this._settings.plugin.uiAtoms.useIntersectionObserver.images;
}

get disableNoScript() {
return this.props.disableNoScript !== undefined
? this.props.disableNoScript
: this._settings.plugin.imaUiAtoms.disableNoScript.images !== undefined
? this._settings.plugin.imaUiAtoms.disableNoScript.images
: this._settings.plugin.imaUiAtoms.disableNoScript;
: this._settings.plugin.uiAtoms.disableNoScript.images;
}

componentDidMount() {
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const initSettings = () => {
return {
prod: {
plugin: {
imaUiAtoms: {
uiAtoms: {
useIntersectionObserver: {
iframes: true,
images: true,
Expand Down
2 changes: 1 addition & 1 deletion src/mocks/settings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const settings = {
plugin: {
imaUiAtoms: {
uiAtoms: {
useIntersectionObserver: {
iframes: true,
images: true,
Expand Down
9 changes: 2 additions & 7 deletions src/video/HtmlVideo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,13 @@ export default class HtmlVideo extends React.PureComponent {
get useIntersectionObserver() {
return this.props.useIntersectionObserver !== undefined
? this.props.useIntersectionObserver
: this._settings.plugin.imaUiAtoms.useIntersectionObserver.videos !==
undefined
? this._settings.plugin.imaUiAtoms.useIntersectionObserver.videos
: this._settings.plugin.imaUiAtoms.useIntersectionObserver;
: this._settings.plugin.uiAtoms.useIntersectionObserver.videos;
}

get disableNoScript() {
return this.props.disableNoScript !== undefined
? this.props.disableNoScript
: this._settings.plugin.imaUiAtoms.disableNoScript.videos !== undefined
? this._settings.plugin.imaUiAtoms.disableNoScript.videos
: this._settings.plugin.imaUiAtoms.disableNoScript;
: this._settings.plugin.uiAtoms.disableNoScript.videos;
}

render() {
Expand Down

0 comments on commit bb21b23

Please sign in to comment.