@@ -22,10 +22,13 @@ import { __, sprintf } from '@wordpress/i18n';
22
22
const SEARCH_ENDPOINT = '/multisite-shared-blocks/v1/search' ;
23
23
24
24
/**
25
+ * Do search request.
26
+ *
27
+ * Build and send request to the shared blocks search endpoint.
25
28
*
26
29
* @param {Object } params
27
30
* @param {AbortController } controller
28
- * @returns {Promise<*[]> }
31
+ * @return {Promise<*[]> } Search request promise.
29
32
*/
30
33
function makeRequest ( params , controller ) {
31
34
const path = addQueryArgs ( SEARCH_ENDPOINT , {
@@ -102,7 +105,7 @@ export default function SharedBlocksSelector( { onItemSelect } ) {
102
105
/**
103
106
* Update the site id param in the query.
104
107
*
105
- * @param {int } site
108
+ * @param {number } site
106
109
*/
107
110
const setSite = ( site ) => {
108
111
setQuery ( { ...query , site } ) ;
@@ -136,15 +139,15 @@ export default function SharedBlocksSelector( { onItemSelect } ) {
136
139
/**
137
140
* Fetch results for the query.
138
141
*
139
- * @param {object } params
142
+ * @param {Object } params
140
143
* @param {?AbortController } controller
141
144
*/
142
145
const searchBlock = ( params , controller ) => {
143
- let query = {
146
+ const searchQuery = {
144
147
...params ,
145
148
page : currentPage ,
146
149
} ;
147
- makeRequest ( query , controller )
150
+ makeRequest ( searchQuery , controller )
148
151
. then ( ( blocks ) => {
149
152
// Handle case where we don't have results and the request returned no results.
150
153
// In that case we want to display the "No Results" state.
@@ -205,7 +208,7 @@ export default function SharedBlocksSelector( { onItemSelect } ) {
205
208
...availableSitesOptions ,
206
209
] }
207
210
onChange = { ( value ) => {
208
- let site = '0' !== value ? + value : 0 ;
211
+ const site = '0' !== value ? + value : 0 ;
209
212
setSite ( site ) ;
210
213
} }
211
214
/>
@@ -225,7 +228,7 @@ export default function SharedBlocksSelector( { onItemSelect } ) {
225
228
...availablePostTypesOptions ,
226
229
] }
227
230
onChange = { ( value ) => {
228
- let postType = '0' !== value ? value : '' ;
231
+ const postType = '0' !== value ? value : '' ;
229
232
setPostType ( postType ) ;
230
233
} }
231
234
/>
@@ -252,10 +255,14 @@ export default function SharedBlocksSelector( { onItemSelect } ) {
252
255
>
253
256
{ results . map ( ( result ) => {
254
257
return (
255
- < div className = { 'results__item' } >
258
+ < div
259
+ key = { result . id }
260
+ className = { 'results__item' }
261
+ >
256
262
< Button
257
263
variant = { 'link' }
258
264
label = { sprintf (
265
+ //translators: %s shared block title
259
266
__ (
260
267
'Select block "%s"' ,
261
268
'multisite-shared-blocks'
0 commit comments