Remove inbox notes exceeding characters warning (#37392)

* Removed inbox notes warning

* Changelog

* Removed dompurify dependency from data package

* Remove dompurify types
This commit is contained in:
Ilyas Foo 2023-04-03 19:13:36 +08:00 committed by GitHub
parent 5528c762f1
commit 502279dff1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 44 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Removed old inbox notes warning

View File

@ -39,7 +39,6 @@
"@wordpress/hooks": "wp-6.0",
"@wordpress/i18n": "wp-6.0",
"@wordpress/url": "wp-6.0",
"dompurify": "^2.3.6",
"md5": "^2.3.0",
"qs": "^6.10.3",
"rememo": "^4.0.0"
@ -53,7 +52,6 @@
"@babel/runtime": "^7.17.2",
"@testing-library/react": "^12.1.3",
"@testing-library/react-hooks": "^7.0.2",
"@types/dompurify": "^2.3.3",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.182",
"@types/md5": "^2.3.2",

View File

@ -1,10 +1,8 @@
/**
* External dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import { addQueryArgs } from '@wordpress/url';
import { apiFetch } from '@wordpress/data-controls';
import { sanitize } from 'dompurify';
/**
* Internal dependencies
@ -13,8 +11,6 @@ import { NAMESPACE } from '../constants';
import { setNotes, setNotesQuery, setError } from './actions';
import { NoteQuery, Note } from './types';
let notesExceededWarningShown = false;
export function* getNotes( query: NoteQuery = {} ) {
const url = addQueryArgs( `${ NAMESPACE }/admin/notes`, query );
@ -23,40 +19,6 @@ export function* getNotes( query: NoteQuery = {} ) {
path: url,
} );
if ( ! notesExceededWarningShown ) {
const noteNames = notes.reduce< string[] >( ( filtered, note ) => {
const content = sanitize( note.content, {
ALLOWED_TAGS: [],
} );
if ( content.length > 320 ) {
filtered.push( note.name );
}
return filtered;
}, [] );
if ( noteNames.length ) {
/* eslint-disable no-console */
console.warn(
sprintf(
/* translators: %s = link to developer blog */
__(
'WooCommerce Admin will soon limit inbox note contents to 320 characters. For more information, please visit %s. The following notes currently exceeds that limit:',
'woocommerce'
),
'https://developer.woocommerce.com/?p=10749'
) +
'\n' +
noteNames
.map( ( name, idx ) => {
return ` ${ idx + 1 }. ${ name }`;
} )
.join( '\n' )
);
/* eslint-enable no-console */
notesExceededWarningShown = true;
}
}
yield setNotes( notes );
yield setNotesQuery(
query,

View File

@ -613,7 +613,6 @@ importers:
'@babel/runtime': ^7.17.2
'@testing-library/react': ^12.1.3
'@testing-library/react-hooks': ^7.0.2
'@types/dompurify': ^2.3.3
'@types/jest': ^27.4.1
'@types/lodash': ^4.14.182
'@types/md5': ^2.3.2
@ -640,7 +639,6 @@ importers:
'@wordpress/i18n': wp-6.0
'@wordpress/url': wp-6.0
concurrently: ^7.0.0
dompurify: ^2.3.6
eslint: ^8.32.0
jest: ^27.5.1
jest-cli: ^27.5.1
@ -668,7 +666,6 @@ importers:
'@wordpress/hooks': 3.6.1
'@wordpress/i18n': 4.6.1
'@wordpress/url': 3.7.1
dompurify: 2.3.6
md5: 2.3.0
moment: 2.29.1
qs: 6.10.3
@ -681,7 +678,6 @@ importers:
'@babel/runtime': 7.17.7
'@testing-library/react': 12.1.4_sfoxds7t5ydpegc3knd667wn6m
'@testing-library/react-hooks': 7.0.2_sfoxds7t5ydpegc3knd667wn6m
'@types/dompurify': 2.3.3
'@types/jest': 27.4.1
'@types/lodash': 4.14.182
'@types/md5': 2.3.2