Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Otter options infinite loading #1845

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 78 additions & 69 deletions src/blocks/plugins/options/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ const Options = () => {
setAPILoaded( true );
});
}
} else {
setCanUser( false );
setAPILoaded( true );
}
};

Expand Down Expand Up @@ -301,75 +304,81 @@ const Options = () => {
</PanelRow>
</PanelBody>

<PanelBody
title={__( 'Block Tools Defaults', 'otter-blocks' )}
initialOpen={true}
>
<p>
{
__( 'Make those features to be shown by default in Block Tools.', 'otter-blocks' )
}
</p>

{
'loading' === status && (
<p>
<Spinner />
{ __( 'Checking optional module...', 'otter-blocks' ) }
</p>
)
}

{
enabledModules?.css && (
<PanelRow>
<ToggleControl
className="o-sidebar-toggle"
label={__( 'Custom CSS', 'otter-blocks' )}
checked={get?.( 'themeisle/otter-blocks', 'show-custom-css' )}
disabled={'loading' === preferenceStatus}
onChange={( value ) => updatedWithStatus( dispatch( 'core/preferences' )?.set( 'themeisle/otter-blocks', 'show-custom-css', value ) )}
/>
</PanelRow>
)
}

{
enabledModules?.animation && (
<PanelRow>
<ToggleControl
className="o-sidebar-toggle"
label={__( 'Animation', 'otter-blocks' )}
checked={get?.( 'themeisle/otter-blocks', 'show-animations' ) ?? false}
disabled={'loading' === preferenceStatus}
onChange={( value ) => updatedWithStatus( dispatch( 'core/preferences' )?.set( 'themeisle/otter-blocks', 'show-animations', value ) )}
/>
</PanelRow>
)
}

{
enabledModules?.condition && (
<PanelRow>
<ToggleControl
className="o-sidebar-toggle"
label={__( 'Visibility Condition', 'otter-blocks' )}
checked={get?.( 'themeisle/otter-blocks', 'show-block-conditions' ) ?? false }
disabled={'loading' === preferenceStatus}
onChange={( value ) => updatedWithStatus( dispatch( 'core/preferences' )?.set( 'themeisle/otter-blocks', 'show-block-conditions', value ) )}
/>
</PanelRow>
)
}
</PanelBody>

<NavigatorButton
path="/block-settings"
icon={ chevronRightSmall }
className="o-navi-button"
>
{ __( 'Block Settings', 'otter-blocks' ) }
</NavigatorButton>
{
canUser && (
<Fragment>
<PanelBody
title={__( 'Block Tools Defaults', 'otter-blocks' )}
initialOpen={true}
>
<p>
{
__( 'Make those features to be shown by default in Block Tools.', 'otter-blocks' )
}
</p>

{
'loading' === status && (
<p>
<Spinner />
{ __( 'Checking optional module...', 'otter-blocks' ) }
</p>
)
}

{
enabledModules?.css && (
<PanelRow>
<ToggleControl
className="o-sidebar-toggle"
label={__( 'Custom CSS', 'otter-blocks' )}
checked={get?.( 'themeisle/otter-blocks', 'show-custom-css' )}
disabled={'loading' === preferenceStatus}
onChange={( value ) => updatedWithStatus( dispatch( 'core/preferences' )?.set( 'themeisle/otter-blocks', 'show-custom-css', value ) )}
/>
</PanelRow>
)
}

{
enabledModules?.animation && (
<PanelRow>
<ToggleControl
className="o-sidebar-toggle"
label={__( 'Animation', 'otter-blocks' )}
checked={get?.( 'themeisle/otter-blocks', 'show-animations' ) ?? false}
disabled={'loading' === preferenceStatus}
onChange={( value ) => updatedWithStatus( dispatch( 'core/preferences' )?.set( 'themeisle/otter-blocks', 'show-animations', value ) )}
/>
</PanelRow>
)
}

{
enabledModules?.condition && (
<PanelRow>
<ToggleControl
className="o-sidebar-toggle"
label={__( 'Visibility Condition', 'otter-blocks' )}
checked={get?.( 'themeisle/otter-blocks', 'show-block-conditions' ) ?? false }
disabled={'loading' === preferenceStatus}
onChange={( value ) => updatedWithStatus( dispatch( 'core/preferences' )?.set( 'themeisle/otter-blocks', 'show-block-conditions', value ) )}
/>
</PanelRow>
)
}
</PanelBody>

<NavigatorButton
path="/block-settings"
icon={ chevronRightSmall }
className="o-navi-button"
>
{ __( 'Block Settings', 'otter-blocks' ) }
</NavigatorButton>
</Fragment>
)
}

{ applyFilters( 'otter.feedback', '', 'otter-menu-editor', __( 'Help us improve Otter Blocks', 'otter-blocks' ) ) }
</NavigatorScreen>
Expand Down
Loading