Skip to content

Commit

Permalink
Set allowLocalEdits on original view
Browse files Browse the repository at this point in the history
  • Loading branch information
pierlon committed Apr 27, 2020
1 parent bf7e6dc commit ac94d2d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
7 changes: 0 additions & 7 deletions assets/src/media-selector/helpers/withUnsplashTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ export default View => {
// TODO - Load selection from the correct state.
const ogState = this.state();

/*
* By default, only the 'insert' library (Media Library) allows for attachment details to be edited.
* Setting `allowLocalEdits` on the state allows for the details to be edited irregardless of the original
* media library being overridden.
*/
ogState.attributes.allowLocalEdits = true;

contentRegion.view = new ImagesBrowser( {
controller: this,
AttachmentView: ImageView,
Expand Down
21 changes: 21 additions & 0 deletions assets/src/media-selector/views/images_browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@ const ImagesBrowser = wp.media.view.AttachmentsBrowser.extend( {
} )
);
},

createSingle() {
wp.media.view.AttachmentsBrowser.prototype.createSingle.apply(
this,
arguments
);

const sidebar = this.sidebar,
single = this.options.selection.single();

sidebar.set(
'details',
new wp.media.view.Attachment.Details( {
controller: this.controller,
model: single,
priority: 80,
allowLocalEdits: true,
} )
);
},

createAttachments() {
const noResults = getConfig( 'noResults' );

Expand Down

0 comments on commit ac94d2d

Please sign in to comment.