-
Notifications
You must be signed in to change notification settings - Fork 384
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
Replace amp_experimental_sandboxing_enabled
filter with Sandboxing experiment toggle
#6757
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a7b46ce
Eliminate sandboxing experiment filter in favor of option
westonruter 7d4cae5
Move Sandboxing level settings drawer after Analytics
westonruter 1d0776f
Improve translation strings
westonruter 35c3b7a
Add missing import for createInterpolateElement
westonruter 8ae8bff
Merge branch 'develop' of github.com:ampproject/amp-wp into remove/sa…
westonruter 4d75dc2
Run ergebnis/composer-normalize
westonruter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import PropTypes from 'prop-types'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useContext } from '@wordpress/element'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { CheckboxControl } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { Options } from '../components/options-context-provider'; | ||
import { AMPDrawer } from '../components/amp-drawer'; | ||
import { STANDARD } from '../common/constants'; | ||
|
||
/** | ||
* Component rendering the Sandboxing experiment. | ||
* | ||
* @param {Object} props Component props. | ||
* @param {string} props.focusedSection Focused section. | ||
*/ | ||
export function Sandboxing( { focusedSection } ) { | ||
const { updateOptions, editedOptions: { | ||
sandboxing_enabled: sandboxingEnabled, | ||
sandboxing_level: sandboxingLevel, | ||
theme_support: themeSupport, | ||
} } = useContext( Options ); | ||
|
||
if ( STANDARD !== themeSupport ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<AMPDrawer | ||
heading={ ( | ||
<h3> | ||
{ __( 'Sandboxing (Experimental)', 'amp' ) } | ||
</h3> | ||
) } | ||
hiddenTitle={ __( 'Sandboxing (Experimental)', 'amp' ) } | ||
id="sandboxing" | ||
initialOpen={ 'sandboxing' === focusedSection } | ||
> | ||
<p> | ||
{ __( 'Try out a more flexible AMP by generating pages that use AMP components without requiring AMP validity! By selecting a sandboxing level, you are indicating the minimum degree of sanitization. For example, if you selected the loose leve but have a page without any POST form and no custom scripts, it will still be served as valid AMP—the same as if you had selected the strict level.', 'amp' ) } | ||
westonruter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</p> | ||
|
||
<CheckboxControl | ||
className="sandboxing-enabled" | ||
checked={ sandboxingEnabled } | ||
label={ __( 'Enable sandboxing experiment', 'amp' ) } | ||
onChange={ | ||
( newChecked ) => { | ||
updateOptions( { sandboxing_enabled: newChecked } ); | ||
} | ||
} | ||
/> | ||
|
||
{ sandboxingEnabled && ( | ||
<ol> | ||
<li> | ||
<input | ||
type="radio" | ||
id="sandboxing-level-1" | ||
checked={ 1 === sandboxingLevel } | ||
onChange={ () => { | ||
updateOptions( { sandboxing_level: 1 } ); | ||
} } | ||
/> | ||
<label htmlFor="sandboxing-level-1"> | ||
<strong> | ||
{ __( 'Loose:', 'amp' ) } | ||
</strong> | ||
{ ' ' + __( 'Do not remove any AMP-invalid markup by default, including custom scripts. CSS processing is disabled.', 'amp' ) } | ||
westonruter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</label> | ||
</li> | ||
<li> | ||
<input | ||
type="radio" | ||
id="sandboxing-level-2" | ||
checked={ 2 === sandboxingLevel } | ||
onChange={ () => { | ||
updateOptions( { sandboxing_level: 2 } ); | ||
} } | ||
/> | ||
<label htmlFor="sandboxing-level-2"> | ||
<strong> | ||
{ __( 'Moderate:', 'amp' ) } | ||
</strong> | ||
{ ' ' + __( 'Remove anything invalid AMP except for POST forms, excessive CSS, and other PX-verified markup.', 'amp' ) } | ||
westonruter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</label> | ||
</li> | ||
<li> | ||
<input | ||
type="radio" | ||
id="sandboxing-level-3" | ||
checked={ 3 === sandboxingLevel } | ||
onChange={ () => { | ||
updateOptions( { sandboxing_level: 3 } ); | ||
} } | ||
/> | ||
<label htmlFor="sandboxing-level-3"> | ||
<strong> | ||
{ __( 'Strict:', 'amp' ) } | ||
</strong> | ||
{ ' ' + __( 'Require valid AMP, removing all markup that causes validation errors (except for excessive CSS).', 'amp' ) } | ||
westonruter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</label> | ||
</li> | ||
</ol> | ||
) } | ||
</AMPDrawer> | ||
); | ||
} | ||
Sandboxing.propTypes = { | ||
focusedSection: PropTypes.string, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is an experimental feature, should it be available to technical users only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question. I think that it should be available to non-technical users too, as this feature is intended to be the most benefit to users who are not technical in the first place, since it avoids the need to fix validation errors.