PluginProbe
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more / 3.7.2
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more v3.7.2
3.7.2 3.7.1 3.7.0 3.6.0 3.6.1 3.5.2 trunk 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.6.0 2.6.1 All 73 releases
← All changes | assets/js/stockpack-browser.js +53 -5 2.5.1 → 3.7.2 View file →
@@ -1,7 +1,8 @@
1 1 import StockpackImages from './stockpack-images';
2 2 import StockpackToolbar from './stockpack-toolbar';
3 3 import StockpackSearch from './filters/stockpack-search';
4 +import StockpackGenerate, { AI_PROVIDER } from './stockpack-generate';
4 5 import StockpackDetails from './stockpack-details';
5 6 import StockpackSidebar from './stockpack-sidebar';
6 7 import StockpackEmpty from './stockpack-empty';
7 8 // import StockpackDialog from './stockpack-dialog';
@@ -67,8 +68,25 @@
67 68 this.views.add( this.images );
68 69 this.images.hide();
69 70 },
70 71
72 + placeAttribution() {
73 + const attribution = this.toolbar ? this.toolbar.get( 'attribution' ) : null;
74 +
75 + if ( ! attribution || ! this.sidebar ) {
76 + return;
77 + }
78 +
79 + const generating = AI_PROVIDER === this.collection.props.get( 'provider' );
80 +
81 + attribution.$el.addClass( 'in-sidebar' );
82 + this.sidebar.$el.prepend( attribution.$el );
83 +
84 + if ( generating ) {
85 + attribution.updateProvider( 'magnific' );
86 + }
87 + },
88 +
71 89 createSidebar() {
72 90 const options = this.options,
73 91 selection = options.selection,
74 92 sidebar = this.sidebar = new StockpackSidebar( {
@@ -177,11 +195,15 @@
177 195 controller: this.controller,
178 196 priority: -70,
179 197 } ).render() );
180 198
199 + this.collection.props.on( 'change:provider', this.placeAttribution, this );
200 + _.defer( () => this.placeAttribution() );
201 +
181 202 // Search is an input, screen reader text needs to be rendered before
182 203 this.toolbar.set( 'searchLabel', new wp.media.view.Label( {
183 204 value: wp.media.view.l10n.stockpack.search,
205 + className: 'screen-reader-text',
184 206 attributes: {
185 207 for: 'media-search-input',
186 208 },
187 209 priority: 60,
@@ -190,14 +212,16 @@
190 212 controller: this.controller,
191 213 model: this.collection.props,
192 214 priority: 60,
193 215 } ).render() );
194 -
195 - this.toolbar.set( 'provider', new StockpackProviderFilters( {
216 + this.toolbar.set( 'generate', new StockpackGenerate( {
196 217 controller: this.controller,
197 218 model: this.collection.props,
198 - priority: 70,
219 + collection: this.collection,
220 + selection: this.options.selection,
221 + priority: 65,
199 222 } ).render() );
223 + this.createProviderFilter();
200 224
201 225 // this.advancedFilters.set('advanced-link', new StockpackAdvancedLink({
202 226 // controller: this.controller,
203 227 // model: this.collection.props,
@@ -269,8 +293,20 @@
269 293 // text: ' ',
270 294 // }));
271 295 },
272 296
297 + createProviderFilter() {
298 + this.toolbar.set( 'provider', new StockpackProviderFilters( {
299 + controller: this.controller,
300 + model: this.collection.props,
301 + priority: 70,
302 + } ).render() );
303 +
304 + if ( this.toolbar.get( 'provider' ).hidden ) {
305 + this.toolbar.$el.addClass( 'provider-hidden' );
306 + }
307 + },
308 +
273 309 createStatus() {
274 310 const statusOptions = {
275 311 controller: this.controller,
276 312 message: wp.media.view.l10n.stockpack.noMedia,
@@ -337,15 +373,27 @@
337 373 },
338 374
339 375 displayError( error ) {
340 376 this.displayEmpty( true );
341 - this.status.model.set( 'message', wp.media.view.l10n.stockpack.error );
377 + this.controller.trigger( 'generation:failed', error );
378 + if(wp.media.view.l10n.stockpack.error[error.code]){
379 + this.status.model.set( 'message', wp.media.view.l10n.stockpack.error[error.code] );
380 + }else{
381 + this.status.model.set( 'message', wp.media.view.l10n.stockpack.error.default );
382 + }
342 383 this.status.model.set( 'error', error.message );
343 - if ( error.code === 2 ) {
384 + if ( error.link ) {
344 385 this.status.model.set( 'link', {
386 + url: error.link,
387 + text: error.link_text || error.link,
388 + } );
389 + } else if ( error.code === 2 ) {
390 + this.status.model.set( 'link', {
345 391 url: wp.media.view.settings.stockpack.settings_url,
346 392 text: wp.media.view.l10n.stockpack.link,
347 393 } );
394 + } else {
395 + this.status.model.set( 'link', false );
348 396 }
349 397 },
350 398
351 399 clearErrors() {