Skip to:
Content

BuddyPress.org

Changeset 12996


Ignore:
Timestamp:
07/12/2021 11:57:59 PM (4 years ago)
Author:
imath
Message:

Edit existing Blocks to use the newly introduced Component and Assets

  • Stop filtering bp_blocks_editor_settings to transport Activity embed, Member/s and Group/s blocks.
  • Edit JavaScript files to use the new ServerSideRender BP Block Component and the BP Block Assets.
  • Use bright red icons for all BP Blocks.
  • Update JavaScript BP Blocks dependencies.

Fixes #8513

Location:
trunk/src
Files:
22 edited

Legend:

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

    r12747 r12996  
    1212    exit;
    1313}
    14 
    15 /**
    16  * Add BP Activity blocks specific settings to the BP Blocks Editor ones.
    17  *
    18  * @since 7.0.0
    19  *
    20  * @param array $bp_editor_settings BP blocks editor settings.
    21  * @return array BP Activity blocks editor settings.
    22  */
    23 function bp_activity_editor_settings( $bp_editor_settings = array() ) {
    24     return array_merge(
    25         $bp_editor_settings,
    26         array(
    27             'activity' => array(
    28                 'embedScriptURL' => includes_url( 'js/wp-embed.min.js' ),
    29             ),
    30         )
    31     );
    32 }
    33 add_filter( 'bp_blocks_editor_settings', 'bp_activity_editor_settings' );
  • trunk/src/bp-activity/classes/class-bp-activity-component.php

    r12747 r12996  
    498498                        'wp-data',
    499499                        'wp-compose',
     500                        'bp-block-data',
    500501                    ),
    501502                ),
  • trunk/src/bp-activity/js/blocks/embed-activity.js

    r12790 r12996  
    233233    RichText = _wp$blockEditor.RichText,
    234234    BlockControls = _wp$blockEditor.BlockControls;
     235/**
     236 * BuddyPress dependencies.
     237 */
     238
     239var _bp = bp,
     240    embedScriptURL = _bp.blockData.embedScriptURL;
    235241
    236242var EditEmbedActivity = function EditEmbedActivity(_ref) {
     
    238244      setAttributes = _ref.setAttributes,
    239245      isSelected = _ref.isSelected,
    240       bpSettings = _ref.bpSettings,
    241246      preview = _ref.preview,
    242247      fetching = _ref.fetching;
    243248  var url = attributes.url,
    244249      caption = attributes.caption;
    245   var embedScriptURL = bpSettings.embedScriptURL;
    246250
    247251  var label = __('BuddyPress Activity URL', 'buddypress');
     
    346350var editEmbedActivityBlock = compose([withSelect(function (select, ownProps) {
    347351  var url = ownProps.attributes.url;
    348   var editorSettings = select('core/editor').getEditorSettings();
    349352
    350353  var _select = select('core'),
     
    355358  var fetching = !!url && isRequestingEmbedPreview(url);
    356359  return {
    357     bpSettings: editorSettings.bp.activity || {},
    358360    preview: preview,
    359361    fetching: fetching
     
    422424  title: __('Embed an activity', 'buddypress'),
    423425  description: __('Add a block that displays the activity content pulled from this or other community sites.', 'buddypress'),
    424   icon: 'buddicons-activity',
     426  icon: {
     427    background: '#fff',
     428    foreground: '#d84800',
     429    src: 'buddicons-activity'
     430  },
    425431  category: 'buddypress',
    426432  attributes: {
  • trunk/src/bp-groups/bp-groups-blocks.php

    r12791 r12996  
    1212    exit;
    1313}
    14 
    15 /**
    16  * Add BP Groups blocks specific settings to the BP Blocks Editor ones.
    17  *
    18  * @since 6.0.0
    19  *
    20  * @param array $bp_editor_settings BP blocks editor settings.
    21  * @return array BP Groups blocks editor settings.
    22  */
    23 function bp_groups_editor_settings( $bp_editor_settings = array() ) {
    24     $bp = buddypress();
    25 
    26     return array_merge(
    27         $bp_editor_settings,
    28         array(
    29             'groups' => array(
    30                 'isAvatarEnabled'     => $bp->avatar && $bp->avatar->show_avatars && ! bp_disable_group_avatar_uploads(),
    31                 'isCoverImageEnabled' => bp_is_active( 'groups', 'cover_image' ),
    32             ),
    33         )
    34     );
    35 }
    36 add_filter( 'bp_blocks_editor_settings', 'bp_groups_editor_settings' );
    3714
    3815/**
     
    265242                '<div class="item-header-avatar">
    266243                    <a href="%1$s">
    267                         <img class="avatar" alt="%2$s" src="%3$s" />
     244                        <img loading="lazy" src="%2$s" alt="%3$s" class="avatar">
    268245                    </a>
    269246                </div>',
    270247                esc_url( $group_link ),
    271248                /* Translators: %s is the group's name. */
    272                 sprintf( esc_attr__( 'Group Profile photo of %s', 'buddypress' ), $group->display_name ),
     249                sprintf( esc_attr__( 'Group Profile photo of %s', 'buddypress' ), esc_html( $group->name ) ),
    273250                esc_url(
    274251                    bp_core_fetch_avatar(
  • trunk/src/bp-groups/classes/class-bp-groups-component.php

    r12893 r12996  
    979979                        'wp-components',
    980980                        'wp-i18n',
    981                         'wp-editor',
    982                         'wp-compose',
    983                         'wp-data',
    984981                        'wp-block-editor',
    985982                        'bp-block-components',
     983                        'bp-block-data',
    986984                    ),
    987985                    'style'              => 'bp-group-block',
     
    10201018                        'wp-components',
    10211019                        'wp-i18n',
    1022                         'wp-compose',
    1023                         'wp-data',
    10241020                        'wp-api-fetch',
    10251021                        'wp-url',
    10261022                        'wp-block-editor',
    10271023                        'bp-block-components',
     1024                        'bp-block-data',
    10281025                        'lodash',
    10291026                    ),
  • trunk/src/bp-groups/js/blocks/group.js

    r12746 r12996  
    185185    Toolbar = _wp$components.Toolbar,
    186186    ToolbarButton = _wp$components.ToolbarButton,
    187     compose = _wp.compose.compose,
    188     withSelect = _wp.data.withSelect,
    189     ServerSideRender = _wp.editor.ServerSideRender,
    190187    _wp$element = _wp.element,
    191188    Fragment = _wp$element.Fragment,
     
    196193 */
    197194
    198 var AutoCompleter = bp.blockComponents.AutoCompleter;
     195var _bp = bp,
     196    _bp$blockComponents = _bp.blockComponents,
     197    AutoCompleter = _bp$blockComponents.AutoCompleter,
     198    ServerSideRender = _bp$blockComponents.ServerSideRender,
     199    isActive = _bp.blockData.isActive;
    199200/**
    200201 * Internal dependencies.
     
    209210};
    210211
    211 var editGroup = function editGroup(_ref) {
     212var editGroupBlock = function editGroupBlock(_ref) {
    212213  var attributes = _ref.attributes,
    213       setAttributes = _ref.setAttributes,
    214       bpSettings = _ref.bpSettings;
    215   var isAvatarEnabled = bpSettings.isAvatarEnabled,
    216       isCoverImageEnabled = bpSettings.isCoverImageEnabled;
     214      setAttributes = _ref.setAttributes;
     215  var isAvatarEnabled = isActive('groups', 'avatar');
     216  var isCoverImageEnabled = isActive('groups', 'cover');
    217217  var avatarSize = attributes.avatarSize,
    218218      displayDescription = attributes.displayDescription,
     
    238238  }
    239239
    240   return createElement(Fragment, null, createElement(BlockControls, null, createElement(Toolbar, null, createElement(ToolbarButton, {
     240  return createElement(Fragment, null, createElement(BlockControls, null, createElement(Toolbar, {
     241    label: __('Block toolbar', 'buddypress')
     242  }, createElement(ToolbarButton, {
    241243    icon: "edit",
    242244    title: __('Select another group', 'buddypress'),
     
    292294};
    293295
    294 var editGroupBlock = compose([withSelect(function (select) {
    295   var editorSettings = select('core/editor').getEditorSettings();
    296   return {
    297     bpSettings: editorSettings.bp.groups || {}
    298   };
    299 })])(editGroup);
    300296var _default = editGroupBlock;
    301297exports.default = _default;
     
    320316  title: __('Group', 'buddypress'),
    321317  description: __('BuddyPress Group.', 'buddypress'),
    322   icon: 'buddicons-groups',
     318  icon: {
     319    background: '#fff',
     320    foreground: '#d84800',
     321    src: 'buddicons-groups'
     322  },
    323323  category: 'buddypress',
    324324  attributes: {
  • trunk/src/bp-groups/js/blocks/groups.js

    r12749 r12996  
    327327    ToolbarGroup = _wp$components.ToolbarGroup,
    328328    RangeControl = _wp$components.RangeControl,
    329     compose = _wp.compose.compose,
    330     withSelect = _wp.data.withSelect,
    331329    _wp$element = _wp.element,
    332330    createElement = _wp$element.createElement,
     
    343341 */
    344342
    345 var AutoCompleter = bp.blockComponents.AutoCompleter;
     343var _bp = bp,
     344    AutoCompleter = _bp.blockComponents.AutoCompleter,
     345    isActive = _bp.blockData.isActive;
    346346/**
    347347 * Internal dependencies.
     
    364364};
    365365
    366 var editGroups = function editGroups(_ref) {
     366var editGroupsBlock = function editGroupsBlock(_ref) {
    367367  var attributes = _ref.attributes,
    368368      setAttributes = _ref.setAttributes,
    369       isSelected = _ref.isSelected,
    370       bpSettings = _ref.bpSettings;
    371   var isAvatarEnabled = bpSettings.isAvatarEnabled;
     369      isSelected = _ref.isSelected;
     370  var isAvatarEnabled = isActive('groups', 'avatar');
    372371  var itemIDs = attributes.itemIDs,
    373372      avatarSize = attributes.avatarSize,
     
    566565};
    567566
    568 var editGroupsBlock = compose([withSelect(function (select) {
    569   var editorSettings = select('core/editor').getEditorSettings();
    570   return {
    571     bpSettings: editorSettings.bp.groups || {}
    572   };
    573 })])(editGroups);
    574567var _default = editGroupsBlock;
    575568exports.default = _default;
     
    594587  title: __('Groups', 'buddypress'),
    595588  description: __('BuddyPress Groups.', 'buddypress'),
    596   icon: 'buddicons-groups',
     589  icon: {
     590    background: '#fff',
     591    foreground: '#d84800',
     592    src: 'buddicons-groups'
     593  },
    597594  category: 'buddypress',
    598595  attributes: {
  • trunk/src/bp-members/bp-members-blocks.php

    r12791 r12996  
    1212    exit;
    1313}
    14 
    15 /**
    16  * Add BP Members blocks specific settings to the BP Blocks Editor ones.
    17  *
    18  * @since 6.0.0
    19  *
    20  * @param array $bp_editor_settings BP blocks editor settings.
    21  * @return array BP Members blocks editor settings.
    22  */
    23 function bp_members_editor_settings( $bp_editor_settings = array() ) {
    24     $bp = buddypress();
    25 
    26     return array_merge(
    27         $bp_editor_settings,
    28         array(
    29             'members' => array(
    30                 'isMentionEnabled'    => bp_is_active( 'activity' ) && bp_activity_do_mentions(),
    31                 'isAvatarEnabled'     => $bp->avatar && $bp->avatar->show_avatars,
    32                 'isCoverImageEnabled' => bp_is_active( 'members', 'cover_image' ),
    33             ),
    34         )
    35     );
    36 }
    37 add_filter( 'bp_blocks_editor_settings', 'bp_members_editor_settings' );
    3814
    3915/**
     
    261237                '<div class="item-header-avatar">
    262238                    <a href="%1$s">
    263                         <img class="avatar" alt="%2$s" src="%3$s" />
     239                        <img loading="lazy" class="avatar" alt="%2$s" src="%3$s" />
    264240                    </a>
    265241                </div>',
  • trunk/src/bp-members/classes/class-bp-members-component.php

    r12994 r12996  
    738738                        'wp-components',
    739739                        'wp-i18n',
    740                         'wp-editor',
    741                         'wp-compose',
    742                         'wp-data',
    743740                        'wp-block-editor',
    744741                        'bp-block-components',
     742                        'bp-block-data',
    745743                    ),
    746744                    'style'              => 'bp-member-block',
     
    779777                        'wp-components',
    780778                        'wp-i18n',
    781                         'wp-compose',
    782                         'wp-data',
    783779                        'wp-api-fetch',
    784780                        'wp-url',
    785781                        'wp-block-editor',
    786782                        'bp-block-components',
     783                        'bp-block-data',
    787784                        'lodash',
    788785                    ),
  • trunk/src/bp-members/js/blocks/member.js

    r12746 r12996  
    173173    Toolbar = _wp$components.Toolbar,
    174174    ToolbarButton = _wp$components.ToolbarButton,
    175     compose = _wp.compose.compose,
    176     withSelect = _wp.data.withSelect,
    177     ServerSideRender = _wp.editor.ServerSideRender,
    178175    _wp$element = _wp.element,
    179176    Fragment = _wp$element.Fragment,
     
    184181 */
    185182
    186 var AutoCompleter = bp.blockComponents.AutoCompleter;
     183var _bp = bp,
     184    _bp$blockComponents = _bp.blockComponents,
     185    AutoCompleter = _bp$blockComponents.AutoCompleter,
     186    ServerSideRender = _bp$blockComponents.ServerSideRender,
     187    isActive = _bp.blockData.isActive;
    187188/**
    188189 * Internal dependencies.
     
    197198};
    198199
    199 var editMember = function editMember(_ref) {
     200var editMemberBlock = function editMemberBlock(_ref) {
    200201  var attributes = _ref.attributes,
    201       setAttributes = _ref.setAttributes,
    202       bpSettings = _ref.bpSettings;
    203   var isAvatarEnabled = bpSettings.isAvatarEnabled,
    204       isMentionEnabled = bpSettings.isMentionEnabled,
    205       isCoverImageEnabled = bpSettings.isCoverImageEnabled;
     202      setAttributes = _ref.setAttributes;
     203  var isAvatarEnabled = isActive('members', 'avatar');
     204  var isMentionEnabled = isActive('activity', 'mentions');
     205  var isCoverImageEnabled = isActive('members', 'cover');
    206206  var avatarSize = attributes.avatarSize,
    207207      displayMentionSlug = attributes.displayMentionSlug,
     
    224224  }
    225225
    226   return createElement(Fragment, null, createElement(BlockControls, null, createElement(Toolbar, null, createElement(ToolbarButton, {
     226  return createElement(Fragment, null, createElement(BlockControls, null, createElement(Toolbar, {
     227    label: __('Block toolbar', 'buddypress')
     228  }, createElement(ToolbarButton, {
    227229    icon: "edit",
    228230    title: __('Select another member', 'buddypress'),
     
    278280};
    279281
    280 var editMemberBlock = compose([withSelect(function (select) {
    281   var editorSettings = select('core/editor').getEditorSettings();
    282   return {
    283     bpSettings: editorSettings.bp.members || {}
    284   };
    285 })])(editMember);
    286282var _default = editMemberBlock;
    287283exports.default = _default;
     
    306302  title: __('Member', 'buddypress'),
    307303  description: __('BuddyPress Member.', 'buddypress'),
    308   icon: 'admin-users',
     304  icon: {
     305    background: '#fff',
     306    foreground: '#d84800',
     307    src: 'admin-users'
     308  },
    309309  category: 'buddypress',
    310310  attributes: {
  • trunk/src/bp-members/js/blocks/members.js

    r12748 r12996  
    312312    ToolbarGroup = _wp$components.ToolbarGroup,
    313313    RangeControl = _wp$components.RangeControl,
    314     compose = _wp.compose.compose,
    315     withSelect = _wp.data.withSelect,
    316314    _wp$element = _wp.element,
    317315    createElement = _wp$element.createElement,
     
    327325 */
    328326
    329 var AutoCompleter = bp.blockComponents.AutoCompleter;
     327var _bp = bp,
     328    AutoCompleter = _bp.blockComponents.AutoCompleter,
     329    isActive = _bp.blockData.isActive;
    330330/**
    331331 * Internal dependencies.
     
    348348};
    349349
    350 var editMembers = function editMembers(_ref) {
     350var editMembersBlock = function editMembersBlock(_ref) {
    351351  var attributes = _ref.attributes,
    352352      setAttributes = _ref.setAttributes,
    353       isSelected = _ref.isSelected,
    354       bpSettings = _ref.bpSettings;
    355   var isAvatarEnabled = bpSettings.isAvatarEnabled,
    356       isMentionEnabled = bpSettings.isMentionEnabled;
     353      isSelected = _ref.isSelected;
     354  var isAvatarEnabled = isActive('members', 'avatar');
     355  var isMentionEnabled = isActive('activity', 'mentions');
    357356  var itemIDs = attributes.itemIDs,
    358357      avatarSize = attributes.avatarSize,
     
    562561};
    563562
    564 var editMembersBlock = compose([withSelect(function (select) {
    565   var editorSettings = select('core/editor').getEditorSettings();
    566   return {
    567     bpSettings: editorSettings.bp.members || {}
    568   };
    569 })])(editMembers);
    570563var _default = editMembersBlock;
    571564exports.default = _default;
     
    590583  title: __('Members', 'buddypress'),
    591584  description: __('BuddyPress Members.', 'buddypress'),
    592   icon: 'groups',
     585  icon: {
     586    background: '#fff',
     587    foreground: '#d84800',
     588    src: 'groups'
     589  },
    593590  category: 'buddypress',
    594591  attributes: {
  • trunk/src/js/bp-activity/js/blocks/embed-activity.js

    r12747 r12996  
    2020    title: __( 'Embed an activity', 'buddypress' ),
    2121    description: __( 'Add a block that displays the activity content pulled from this or other community sites.', 'buddypress' ),
    22     icon: 'buddicons-activity',
     22    icon: {
     23        background: '#fff',
     24        foreground: '#d84800',
     25        src: 'buddicons-activity',
     26    },
    2327    category: 'buddypress',
    2428    attributes: {
  • trunk/src/js/bp-activity/js/blocks/embed-activity/edit.js

    r12790 r12996  
    3333} = wp;
    3434
     35/**
     36 * BuddyPress dependencies.
     37 */
     38 const {
     39    blockData: {
     40        embedScriptURL,
     41    }
     42} = bp;
     43
    3544const EditEmbedActivity = ( {
    3645    attributes,
    3746    setAttributes,
    3847    isSelected,
    39     bpSettings,
    4048    preview,
    4149    fetching
    4250} ) => {
    4351    const { url, caption } = attributes;
    44     const { embedScriptURL } = bpSettings;
    4552    const label = __( 'BuddyPress Activity URL', 'buddypress' );
    4653    const [ value, setURL ] = useState( url );
     
    164171    withSelect( ( select, ownProps ) => {
    165172        const { url } = ownProps.attributes;
    166         const editorSettings = select( 'core/editor' ).getEditorSettings();
    167173        const {
    168174            getEmbedPreview,
     
    174180
    175181        return {
    176             bpSettings: editorSettings.bp.activity || {},
    177182            preview: preview,
    178183            fetching: fetching,
  • trunk/src/js/bp-activity/js/blocks/embed-activity/save.js

    r12747 r12996  
    1919
    2020    return (
    21         <figure className="wp-block-embed is-type-bp-activity">
    22             <div className="wp-block-embed__wrapper">
    23             {
    24                 `\n${ url }\n` /* URL needs to be on its own line. */
    25             }
    26             </div>
    27             { ! RichText.isEmpty( caption ) && (
    28                 <RichText.Content
    29                     tagName="figcaption"
    30                     value={ caption }
    31                 />
    32             ) }
    33         </figure>
     21    <figure className="wp-block-embed is-type-bp-activity">
     22        <div className="wp-block-embed__wrapper">
     23        {
     24            `\n${ url }\n` /* URL needs to be on its own line. */
     25        }
     26        </div>
     27        { ! RichText.isEmpty( caption ) && (
     28            <RichText.Content
     29                tagName="figcaption"
     30                value={ caption }
     31            />
     32        ) }
     33    </figure>
    3434    );
    3535};
  • trunk/src/js/bp-groups/js/blocks/group.js

    r12746 r12996  
    1919    title: __( 'Group', 'buddypress' ),
    2020    description: __( 'BuddyPress Group.', 'buddypress' ),
    21     icon: 'buddicons-groups',
     21    icon: {
     22        background: '#fff',
     23        foreground: '#d84800',
     24        src: 'buddicons-groups',
     25    },
    2226    category: 'buddypress',
    2327    attributes: {
  • trunk/src/js/bp-groups/js/blocks/group/edit.js

    r12746 r12996  
    1616        ToolbarButton,
    1717    },
    18     compose: {
    19         compose,
    20     },
    21     data: {
    22         withSelect,
    23     },
    24     editor: {
    25         ServerSideRender,
    26     },
    2718    element: {
    2819        Fragment,
     
    3728 * BuddyPress dependencies.
    3829 */
    39 const { AutoCompleter } = bp.blockComponents;
     30const {
     31    blockComponents: {
     32        AutoCompleter,
     33        ServerSideRender,
     34    },
     35    blockData: {
     36        isActive,
     37    }
     38} = bp;
    4039
    4140/**
     
    5251}
    5352
    54 const editGroup = ( { attributes, setAttributes, bpSettings } ) => {
    55     const { isAvatarEnabled, isCoverImageEnabled } = bpSettings;
     53const editGroupBlock = ( { attributes, setAttributes } ) => {
     54    const isAvatarEnabled = isActive( 'groups', 'avatar' );
     55    const isCoverImageEnabled = isActive( 'groups', 'cover' );
    5656    const { avatarSize, displayDescription, displayActionButton, displayCoverImage } = attributes;
    5757
     
    7979        <Fragment>
    8080            <BlockControls>
    81                 <Toolbar>
     81                <Toolbar label={ __( 'Block toolbar', 'buddypress' ) }>
    8282                    <ToolbarButton
    8383                        icon="edit"
     
    152152};
    153153
    154 const editGroupBlock = compose( [
    155     withSelect( ( select ) => {
    156         const editorSettings = select( 'core/editor' ).getEditorSettings();
    157         return {
    158             bpSettings: editorSettings.bp.groups || {},
    159         };
    160     } ),
    161 ] )( editGroup );
    162 
    163154export default editGroupBlock;
  • trunk/src/js/bp-groups/js/blocks/groups.js

    r12749 r12996  
    1919    title: __( 'Groups', 'buddypress' ),
    2020    description: __( 'BuddyPress Groups.', 'buddypress' ),
    21     icon: 'buddicons-groups',
     21    icon: {
     22        background: '#fff',
     23        foreground: '#d84800',
     24        src: 'buddicons-groups',
     25    },
    2226    category: 'buddypress',
    2327    attributes: {
  • trunk/src/js/bp-groups/js/blocks/groups/edit.js

    r12749 r12996  
    1818        RangeControl,
    1919    },
    20     compose: {
    21         compose,
    22     },
    23     data: {
    24         withSelect,
    25     },
    2620    element: {
    2721        createElement,
     
    4337 * BuddyPress dependencies.
    4438 */
    45 const { AutoCompleter } = bp.blockComponents;
     39const {
     40    blockComponents: {
     41        AutoCompleter,
     42    },
     43    blockData: {
     44        isActive,
     45    }
     46} = bp;
    4647
    4748/**
     
    6768}
    6869
    69 const editGroups = ( { attributes, setAttributes, isSelected, bpSettings } ) => {
    70     const {
    71         isAvatarEnabled,
    72     } = bpSettings;
     70const editGroupsBlock = ( { attributes, setAttributes, isSelected } ) => {
     71    const isAvatarEnabled = isActive( 'groups', 'avatar' );
    7372    const {
    7473        itemIDs,
     
    295294};
    296295
    297 const editGroupsBlock = compose( [
    298     withSelect( ( select ) => {
    299         const editorSettings = select( 'core/editor' ).getEditorSettings();
    300 
    301         return {
    302             bpSettings: editorSettings.bp.groups || {},
    303         };
    304     } ),
    305 ] )( editGroups );
    306 
    307296export default editGroupsBlock;
  • trunk/src/js/bp-members/js/blocks/member.js

    r12746 r12996  
    1919    title: __( 'Member', 'buddypress' ),
    2020    description: __( 'BuddyPress Member.', 'buddypress' ),
    21     icon: 'admin-users',
     21    icon: {
     22        background: '#fff',
     23        foreground: '#d84800',
     24        src: 'admin-users',
     25    },
    2226    category: 'buddypress',
    2327    attributes: {
  • trunk/src/js/bp-members/js/blocks/member/edit.js

    r12746 r12996  
    1616        ToolbarButton,
    1717    },
    18     compose: {
    19         compose,
    20     },
    21     data: {
    22         withSelect,
    23     },
    24     editor: {
    25         ServerSideRender,
    26     },
    2718    element: {
    2819        Fragment,
     
    3728 * BuddyPress dependencies.
    3829 */
    39 const { AutoCompleter } = bp.blockComponents;
     30const {
     31    blockComponents: {
     32        AutoCompleter,
     33        ServerSideRender,
     34    },
     35    blockData: {
     36        isActive,
     37    }
     38} = bp;
    4039
    4140/**
     
    5251}
    5352
    54 const editMember = ( { attributes, setAttributes, bpSettings } ) => {
    55     const { isAvatarEnabled, isMentionEnabled, isCoverImageEnabled } = bpSettings;
     53const editMemberBlock = ( { attributes, setAttributes } ) => {
     54    const isAvatarEnabled = isActive( 'members', 'avatar' );
     55    const isMentionEnabled = isActive( 'activity', 'mentions' );
     56    const isCoverImageEnabled = isActive( 'members', 'cover' );
    5657    const { avatarSize, displayMentionSlug, displayActionButton, displayCoverImage } = attributes;
    5758
     
    7879        <Fragment>
    7980            <BlockControls>
    80                 <Toolbar>
     81                <Toolbar label={ __( 'Block toolbar', 'buddypress' ) }>
    8182                    <ToolbarButton
    8283                        icon="edit"
     
    153154};
    154155
    155 const editMemberBlock = compose( [
    156     withSelect( ( select ) => {
    157         const editorSettings = select( 'core/editor' ).getEditorSettings();
    158         return {
    159             bpSettings: editorSettings.bp.members || {},
    160         };
    161     } ),
    162 ] )( editMember );
    163 
    164156export default editMemberBlock;
  • trunk/src/js/bp-members/js/blocks/members.js

    r12748 r12996  
    1919    title: __( 'Members', 'buddypress' ),
    2020    description: __( 'BuddyPress Members.', 'buddypress' ),
    21     icon: 'groups',
     21    icon: {
     22        background: '#fff',
     23        foreground: '#d84800',
     24        src: 'groups',
     25    },
    2226    category: 'buddypress',
    2327    attributes: {
  • trunk/src/js/bp-members/js/blocks/members/edit.js

    r12748 r12996  
    1818        RangeControl,
    1919    },
    20     compose: {
    21         compose,
    22     },
    23     data: {
    24         withSelect,
    25     },
    2620    element: {
    2721        createElement,
     
    4236 * BuddyPress dependencies.
    4337 */
    44 const { AutoCompleter } = bp.blockComponents;
     38const {
     39    blockComponents: {
     40        AutoCompleter,
     41    },
     42    blockData: {
     43        isActive,
     44    }
     45} = bp;
    4546
    4647/**
     
    6667}
    6768
    68 const editMembers = ( { attributes, setAttributes, isSelected, bpSettings } ) => {
    69     const {
    70         isAvatarEnabled,
    71         isMentionEnabled,
    72     } = bpSettings;
     69const editMembersBlock = ( { attributes, setAttributes, isSelected } ) => {
     70    const isAvatarEnabled = isActive( 'members', 'avatar' );
     71    const isMentionEnabled = isActive( 'activity', 'mentions' );
    7372    const {
    7473        itemIDs,
     
    314313};
    315314
    316 const editMembersBlock = compose( [
    317     withSelect( ( select ) => {
    318         const editorSettings = select( 'core/editor' ).getEditorSettings();
    319 
    320         return {
    321             bpSettings: editorSettings.bp.members || {},
    322         };
    323     } ),
    324 ] )( editMembers );
    325 
    326315export default editMembersBlock;
Note: See TracChangeset for help on using the changeset viewer.