Skip to:
Content

BuddyPress.org

Changeset 12763


Ignore:
Timestamp:
10/20/2020 06:25:43 PM (6 years ago)
Author:
imath
Message:

BP Blocks: make sure the Activity Embed block renders the activity

The Activity permalink URL was wrongly reset to an empty string the first time the embed request was made. As a result the error state of the block was rendered.

This commit fixes this issue and brings some complementary improvements:

  • Stop using the deprecated Toolbar Block component in favor of the ToolbarGroup one.
  • Use the Disabled Block component to disable links inside the rendered activity.

Fixes #8377

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/js/blocks/embed-activity.js

    r12747 r12763  
    221221    _wp$components = _wp.components,
    222222    Placeholder = _wp$components.Placeholder,
     223    Disabled = _wp$components.Disabled,
    223224    SandBox = _wp$components.SandBox,
    224225    Button = _wp$components.Button,
    225226    ExternalLink = _wp$components.ExternalLink,
    226227    Spinner = _wp$components.Spinner,
    227     Toolbar = _wp$components.Toolbar,
     228    ToolbarGroup = _wp$components.ToolbarGroup,
    228229    ToolbarButton = _wp$components.ToolbarButton,
    229230    compose = _wp.compose.compose,
     
    275276  };
    276277
    277   var editToolbar = createElement(BlockControls, null, createElement(Toolbar, null, createElement(ToolbarButton, {
     278  var editToolbar = createElement(BlockControls, null, createElement(ToolbarGroup, null, createElement(ToolbarButton, {
    278279    icon: "edit",
    279280    title: __('Edit URL', 'buddypress'),
     
    315316
    316317  if (!preview || !preview['x_buddypress'] || 'activity' !== preview['x_buddypress']) {
    317     // Reset the URL.
    318     setAttributes({
    319       url: ''
    320     });
    321318    return createElement(Fragment, null, editToolbar, createElement(Placeholder, {
    322319      icon: "buddicons-activity",
     
    331328  }, createElement("div", {
    332329    className: "wp-block-embed__wrapper"
    333   }, createElement(SandBox, {
     330  }, createElement(Disabled, null, createElement(SandBox, {
    334331    html: preview && preview.html ? preview.html : '',
    335332    scripts: [embedScriptURL]
    336   })), (!RichText.isEmpty(caption) || isSelected) && createElement(RichText, {
     333  }))), (!RichText.isEmpty(caption) || isSelected) && createElement(RichText, {
    337334    tagName: "figcaption",
    338335    placeholder: __('Write caption…', 'buddypress'),
     
    355352      isRequestingEmbedPreview = _select.isRequestingEmbedPreview;
    356353
    357   var preview = undefined !== url && getEmbedPreview(url);
    358   var fetching = undefined !== url && isRequestingEmbedPreview(url);
     354  var preview = !!url && getEmbedPreview(url);
     355  var fetching = !!url && isRequestingEmbedPreview(url);
    359356  return {
    360357    bpSettings: editorSettings.bp.activity || {},
  • trunk/src/js/bp-activity/js/blocks/embed-activity/edit.js

    r12747 r12763  
    1313        components: {
    1414                Placeholder,
     15                Disabled,
    1516                SandBox,
    1617                Button,
    1718                ExternalLink,
    1819                Spinner,
    19                 Toolbar,
     20                ToolbarGroup,
    2021                ToolbarButton,
    2122        },
     
    6566        const editToolbar = (
    6667                <BlockControls>
    67                         <Toolbar>
     68                        <ToolbarGroup>
    6869                                <ToolbarButton
    6970                                        icon="edit"
     
    7172                                        onClick={ switchBackToURLInput }
    7273                                />
    73                         </Toolbar>
     74                        </ToolbarGroup>
    7475                </BlockControls>
    7576        );
     
    119120
    120121        if ( ! preview || ! preview['x_buddypress'] || 'activity' !== preview['x_buddypress'] ) {
    121                 // Reset the URL.
    122                 setAttributes( { url: '' } );
    123 
    124122                return (
    125123                        <Fragment>
     
    142140                        <figure className="wp-block-embed is-type-bp-activity">
    143141                                <div className="wp-block-embed__wrapper">
    144                                         <SandBox
    145                                                 html={ preview && preview.html ? preview.html : '' }
    146                                                 scripts={ [ embedScriptURL ] }
    147                                         />
     142                                        <Disabled>
     143                                                <SandBox
     144                                                        html={ preview && preview.html ? preview.html : '' }
     145                                                        scripts={ [ embedScriptURL ] }
     146                                                />
     147                                        </Disabled>
    148148                                </div>
    149149                                { ( ! RichText.isEmpty( caption ) || isSelected ) && (
     
    170170                } = select( 'core' );
    171171
    172                 const preview = undefined !== url && getEmbedPreview( url );
    173                 const fetching = undefined !== url && isRequestingEmbedPreview( url );
     172                const preview = !! url && getEmbedPreview( url );
     173                const fetching = !! url && isRequestingEmbedPreview( url );
    174174
    175175                return {
Note: See TracChangeset for help on using the changeset viewer.