Skip to content

Commit

Permalink
Fix uploading background images in stylebook view. (#68159)
Browse files Browse the repository at this point in the history
Co-authored-by: tellthemachines <[email protected]>
Co-authored-by: ramonjd <[email protected]>
  • Loading branch information
3 people authored Dec 20, 2024
1 parent 6dfea11 commit 8ad85f9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/edit-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@wordpress/icons": "*",
"@wordpress/keyboard-shortcuts": "*",
"@wordpress/keycodes": "*",
"@wordpress/media-utils": "5.14.0",
"@wordpress/notices": "*",
"@wordpress/patterns": "*",
"@wordpress/plugins": "*",
Expand Down
18 changes: 16 additions & 2 deletions packages/edit-site/src/components/style-book/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import {
useEffect,
} from '@wordpress/element';
import { ENTER, SPACE } from '@wordpress/keycodes';
import { uploadMedia } from '@wordpress/media-utils';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
Expand Down Expand Up @@ -361,10 +363,22 @@ export const StyleBookPreview = ( { userConfig = {}, isStatic = false } ) => {
[]
);

const canUserUploadMedia = useSelect(
( select ) =>
select( coreStore ).canUser( 'create', {
kind: 'root',
name: 'media',
} ),
[]
);

// Update block editor settings because useMultipleOriginColorsAndGradients fetch colours from there.
useEffect( () => {
dispatch( blockEditorStore ).updateSettings( siteEditorSettings );
}, [ siteEditorSettings ] );
dispatch( blockEditorStore ).updateSettings( {
...siteEditorSettings,
mediaUpload: canUserUploadMedia ? uploadMedia : undefined,
} );
}, [ siteEditorSettings, canUserUploadMedia ] );

const [ section, onChangeSection ] = useSection();

Expand Down

1 comment on commit 8ad85f9

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 8ad85f9.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12425719827
📝 Reported issues:

Please sign in to comment.