-
Notifications
You must be signed in to change notification settings - Fork 381
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
Add AMP plugin editor sidebar #5589
Changes from 23 commits
127a7fa
b3e3058
3a69c9a
cedf6f5
ee94295
e4613b4
43ed5b2
a52d018
c827669
987ab40
15337e7
5ef519d
eea577c
df4ba1c
68f0e1d
55d3577
710df98
71106ec
f5040f4
88060a9
4096fff
9a056bf
28cd8a3
3dd14fa
28f4deb
865fb27
3a0d353
7dd5e89
384106f
d44d874
a4b1230
cc1e81b
d3f71ea
0f5754c
21ae619
cf7fb1f
27c37a7
69db14e
e11cbfa
63ae231
cfe19d7
631eb12
9f10715
8093216
b2b5fa7
f1740df
7c7ad4d
0c232e8
5270e5f
5719556
7f3e8ab
7187026
5b9455b
470e6bc
7a87941
27241b8
554ebf7
6ef589c
07bb502
d5631a1
eeaa4c7
46a204e
7792450
1b7d244
b142dcf
9be8ba8
7460281
03f7a61
4bd0905
eed3458
e486756
c2d61b7
ad71b5e
228cb81
e705a01
cdad327
88b2b5f
8c6d326
ccda9e3
781ccec
d829e71
3581512
8647ad0
a58c3bd
b90f387
4d66cff
aebeadc
cbf1e51
6785cf5
a5aa07c
d643177
fc84d51
998f1d1
69dd546
81fa246
5d52612
6e801ca
e562eb9
08bc3ee
db11545
b146882
514182c
cdb0bd2
a96ba65
ff49b62
59bcd96
b9d332b
8b36b10
d32fe9d
2480c14
d5eff39
47d9c0d
6e54b50
eb8ef36
fcbf25a
0003d78
8aa1809
bbb0e49
cd68eff
cbc69c8
7617125
62d413d
f47f7d7
f4f9132
b50fdcd
94311fe
564d45a
0398731
7929bd1
5c641a4
cec5fbf
c8cb413
8ff3949
eece73a
9d8ad14
6a3df3f
af1dc4d
e3721ec
473f6ab
31278f2
b1a6a11
1d6a0a3
29cf878
66666f0
ec509b8
8f5fbb8
c1b5b86
96c1a96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,2 @@ | ||
// See \AMP_Validation_Error_Taxonomy class in PHP. | ||
export const VALIDATION_ERROR_NEW_REJECTED_STATUS = 0; | ||
export const VALIDATION_ERROR_NEW_ACCEPTED_STATUS = 1; | ||
export const VALIDATION_ERROR_ACK_REJECTED_STATUS = 2; | ||
export const VALIDATION_ERROR_ACK_ACCEPTED_STATUS = 3; | ||
|
||
// See \AMP_Validation_Manager::VALIDITY_REST_FIELD_NAME in PHP. | ||
export const AMP_VALIDITY_REST_FIELD_NAME = 'amp_validity'; | ||
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,6 +2,7 @@ | |||||
* External dependencies | ||||||
*/ | ||||||
import PropTypes from 'prop-types'; | ||||||
import { VALIDATION_ERROR_ACK_REJECTED_STATUS, VALIDATION_ERROR_NEW_REJECTED_STATUS } from 'amp-block-validation'; | ||||||
|
||||||
/** | ||||||
* WordPress dependencies | ||||||
|
@@ -13,11 +14,6 @@ import { __ } from '@wordpress/i18n'; | |||||
* Internal dependencies | ||||||
*/ | ||||||
import AMPAlert from '../../../images/amp-alert.svg'; | ||||||
|
||||||
/** | ||||||
* Internal dependencies | ||||||
*/ | ||||||
import { VALIDATION_ERROR_ACK_REJECTED_STATUS, VALIDATION_ERROR_NEW_REJECTED_STATUS } from '../constants'; | ||||||
import { ErrorTypeIcon } from './error-type-icon'; | ||||||
|
||||||
/** | ||||||
|
@@ -38,9 +34,11 @@ export function ErrorPanelTitle( { blockType, title, error: { type }, status } ) | |||||
return ( | ||||||
<> | ||||||
<div className="amp-error__icons"> | ||||||
<div className={ `amp-error__error-type-icon amp-error__error-type-icon--${ type.replace( /_/g, '-' ) }` }> | ||||||
{ type && ( | ||||||
<div className={ `amp-error__error-type-icon amp-error__error-type-icon--${ type?.replace( /_/g, '-' ) }` }> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional chaining is unnecessary here since
Suggested change
|
||||||
<ErrorTypeIcon type={ type } /> | ||||||
</div> | ||||||
) } | ||||||
{ blockType?.icon && ( | ||||||
<div className="amp-error__block-type-icon"> | ||||||
<BlockIcon icon={ blockType.icon } /> | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,23 +2,22 @@ | |
* External dependencies | ||
*/ | ||
import PropTypes from 'prop-types'; | ||
import { | ||
VALIDATION_ERROR_ACK_ACCEPTED_STATUS, | ||
VALIDATION_ERROR_ACK_REJECTED_STATUS, | ||
} from 'amp-block-validation'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useSelect, useDispatch } from '@wordpress/data'; | ||
import { PanelBody, Button } from '@wordpress/components'; | ||
import { PanelBody, Button, ExternalLink } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { | ||
AMP_VALIDITY_REST_FIELD_NAME, | ||
VALIDATION_ERROR_ACK_ACCEPTED_STATUS, | ||
VALIDATION_ERROR_ACK_REJECTED_STATUS, | ||
} from '../constants'; | ||
import { NewTabIcon } from '../icon'; | ||
import { AMP_VALIDITY_REST_FIELD_NAME } from '../constants'; | ||
import { ErrorPanelTitle } from './error-panel-title'; | ||
import { ErrorContent } from './error-content'; | ||
|
||
|
@@ -50,7 +49,7 @@ export function Error( { clientId, status, term_id: termId, ...props } ) { | |
return ( | ||
<li className="amp-error-container"> | ||
<PanelBody | ||
className={ `amp-error amp-error--${ reviewed ? 'reviewed' : 'new' }` } | ||
className={ `amp-error amp-error--${ reviewed ? 'reviewed' : 'new' }${ clientId ? ` error-${ clientId }` : '' }` } | ||
title={ | ||
<ErrorPanelTitle { ...props } blockType={ blockType } status={ status } /> | ||
} | ||
|
@@ -70,15 +69,14 @@ export function Error( { clientId, status, term_id: termId, ...props } ) { | |
{ __( 'Select block', 'amp' ) } | ||
</Button> | ||
) } | ||
<a | ||
<ExternalLink | ||
href={ detailsUrl.href } | ||
target="_blank" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of |
||
rel="noreferrer" | ||
className="amp-error__details-link" | ||
> | ||
{ __( 'View details', 'amp' ) } | ||
<NewTabIcon /> | ||
</a> | ||
</ExternalLink> | ||
</div> | ||
|
||
</PanelBody> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { ToggleControl, PanelBody } from '@wordpress/components'; | ||
import { ToggleControl, PanelBody, ExternalLink } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { useEffect } from '@wordpress/element'; | ||
|
@@ -14,7 +14,6 @@ import AMPValidationErrorsIcon from '../../images/amp-validation-errors.svg'; | |
import AMPValidationErrorsKeptIcon from '../../images/amp-validation-errors-kept.svg'; | ||
import { Error } from './error'; | ||
import { BLOCK_VALIDATION_STORE_KEY } from './store'; | ||
import { NewTabIcon } from './icon'; | ||
import { AMP_VALIDITY_REST_FIELD_NAME } from './constants'; | ||
|
||
/** | ||
|
@@ -100,10 +99,9 @@ export function Sidebar() { | |
|
||
<p> | ||
{ reviewLink && ( | ||
<a href={ reviewLink } className="amp-sidebar__review-link" target="_blank" rel="noreferrer"> | ||
<ExternalLink href={ reviewLink } className="amp-sidebar__review-link"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{ __( 'View technical details', 'amp' ) } | ||
<NewTabIcon /> | ||
</a> | ||
</ExternalLink> | ||
) } | ||
</p> | ||
</div> | ||
|
@@ -122,7 +120,7 @@ export function Sidebar() { | |
) } | ||
|
||
{ | ||
! saved && ( | ||
! saved && 0 === validationErrors.length && ( | ||
<PanelBody opened={ true }> | ||
<p> | ||
{ __( 'The permalink will be checked for validation issues when the post is saved.', 'amp' ) } | ||
westonruter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
@@ -138,7 +136,7 @@ export function Sidebar() { | |
</PanelBody> | ||
) } | ||
|
||
{ saved && 0 < validationErrors.length && ( | ||
{ 0 < validationErrors.length && ( | ||
0 < displayedErrors.length ? ( | ||
<ul> | ||
{ displayedErrors.map( ( validationError, index ) => ( | ||
|
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.
I'm wondering if these constants should instead be supplied via
amp-block-validation
. That would lessen the burden of maintaining them if one of the values were to change in the future.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.
Done in 94311fe, except
amp_validity
, which is going to be removed in #5741.