Skip to:
Content

BuddyPress.org

Opened 10 years ago

Closed 10 years ago

#5934 closed enhancement (fixed)

Enabling suggestions for @-mentions in groups component

Reported by: mrk's profile m@… Owned by: djpaul's profile djpaul
Milestone: 2.2 Priority: normal
Severity: normal Version:
Component: Groups Keywords: has-patch commit
Cc:

Description

Everybody loves the new suggestions for @-mentions! - Is there any reason why they currently (BP 2.1.1) aren’t enabled for the groups component?

Looks like suggestions would work properly also for groups by just adding a condition bp_is_groups_component() in bp-activity/bp-activity-functions.php:62 – changing it to:

function bp_activity_maybe_load_mentions_scripts() {
	$retval =
		bp_activity_do_mentions() &&
		bp_is_user_active() &&
		( bp_is_activity_component() || bp_is_groups_component() || bp_is_blog_page() && is_singular() && comments_open() || is_admin() );

	return (bool) apply_filters( 'bp_activity_maybe_load_mentions_scripts', $retval );
}

This loads the required script for groups component as well as for group forums.

Then, to enable suggestions specifically for group forums, .bp-suggestions needs to be added in

bp-templates/bp-legacy/buddypress/groups/single/forum/topic.php:141

and in

bp-themes/bp-default/groups/single/forum/topic.php:141

changing it to:

<textarea name="reply_text" id="reply_text" class="bp-suggestions"></textarea>

For bp-default I'll create a pull request in advance.

Wouldn’t that mean a nice improvement?

Attachments (3)

5934.patch (1.5 KB) - added by m@… 10 years ago.
5934.02.patch (3.0 KB) - added by imath 10 years ago.
5934.03.patch (3.8 KB) - added by DJPaul 10 years ago.

Download all attachments as: .zip

Change History (27)

#1 @boonebgorges
10 years ago

  • Keywords needs-patch added; has-patch dev-feedback removed

Wouldn’t that mean a nice improvement?

Yeah, and in fact I'd say it was an oversight not to include it in the first place. Can you create a patch?

#2 @m@…
10 years ago

  • Keywords has-patch dev-feedback added; needs-patch removed

For bp-default I created a pull request: https://github.com/buddypress/BP-Default/pull/3

Last edited 10 years ago by m@… (previous) (diff)

#3 @m@…
10 years ago

  • Keywords needs-patch added; has-patch dev-feedback removed

@m@…
10 years ago

#4 @m@…
10 years ago

  • Keywords has-patch added; needs-patch removed

Pull request for bp-default created. Patch added. Thank you.

#5 @DJPaul
10 years ago

why they currently (BP 2.1.1) aren’t enabled for the groups component?

Where precisely within a Group? Do you mean on a Group's activity stream, or legacy bbPress forums, or bbPress 2.x forums?

#6 @DJPaul
10 years ago

  • Milestone changed from Awaiting Review to 2.2

#7 @m@…
10 years ago

Adding the condition bp_is_groups_component() in bp-activity-functions.php results in performing bp_activity_maybe_load_mentions_scripts() for a Group's activity stream.

Corresponding script also get loaded for Group Forums with that. Specifically for forums, in addition, class="bp-suggestions" needs to be assigned to the textarea in groups/single/forum/topic.php, as target for the mentions script.

With that, suggestions work for legacy bbPress Group forums.

I assume BuddyPress' groups/single/forum/topic.php template is also used for bbPress 2.x forums? If so, suggestions should work for that variant in a similar way.

Please correct me if I'm wrong, thanks.

#8 @DJPaul
10 years ago

The legacy groups forums are kind of deprecated, I don't know if it's worth supporting it with nice-to-have features like this.

#9 @m@…
10 years ago

I see. But up to now, without the patch for bp-activity/bp-activity-functions.php, suggestions for @-mentions aren't enabled even for a Group's activity stream - besides Group forums.

#10 follow-up: @DJPaul
10 years ago

I didn't say that I thought it was a bad idea to add support for the Group Activity Stream, only the legacy Group Forums. I think I thought the bp_is_activity_component check would also work on the Group Activity screen.

At any rate, the checks in bp_activity_maybe_load_mentions_scripts are meant to be as specific as possible as this function is called on every page load. There's a lot of screens in Groups that have nothing to do with composing a new activity item, so instead of using bp_is_groups_component, I'd suggest using bp_is_group_activity and (if we have to) also bp_is_group_forum_topic_edit.

#11 in reply to: ↑ 10 @m@…
10 years ago

Replying to DJPaul:

There's a lot of screens in Groups that have nothing to do with composing a new activity item, so instead of using bp_is_groups_component, I'd suggest using bp_is_group_activity and (if we have to) also bp_is_group_forum_topic_edit.

Thank you for carving this out, I totally agree.

#12 @DJPaul
10 years ago

  • Keywords needs-refresh good-first-bug added; has-patch removed

Easy patch for someone to change per the previous comments, so we can get this in for 2.2. :)

#13 @imath
10 years ago

  • Keywords has-patch added; needs-refresh removed

I think we should make sure to only fetch members of the group there. If a group is != public and the user mentioned is not a member of the group...

So i'm suggesting something more like 5934.02.patch

@imath
10 years ago

#14 @djpaul
10 years ago

In 9242:

Core, Suggestions: use bp_parse_args to pre-filter $args for bp_core_get_suggestions.

See #5934

#15 @djpaul
10 years ago

In 9243:

Suggestions: move the blog checks in bp_activity_maybe_load_mentions_scripts to a filter in the core component.

This reorganisation keeps the component-specific mentions checks in those specific components, rather than bundling everything into the Activity component as it had been.

See #5934

#16 @djpaul
10 years ago

In 9244:

Templates: add class to bp-legacy's single forum reply template (legacy bbPress) to enable @mentions.

Further core changes are required before this will work. See #5934

@DJPaul
10 years ago

#17 @djpaul
10 years ago

In 9245:

Revert r9244: "Templates: add class to bp-legacy's single forum reply template (legacy bbPress) to enable @mentions."

Further consideration is needed before adding features to the legacy Group Forums support. See #5934

#18 follow-up: @DJPaul
10 years ago

I have done some poking, as you can see from the commits. I have added a new patch, 5934.03.patch.

I didn't like the idea of pre-filtering the AJAX response to get the Group ID (I'm not sure that would have worked, anyway), plus we needed some refactoring to let each component filter whether the mentions scripts should load or not, to better match what we try to do elsewhere in BP. I came up with an approach of storing the Group ID in the textarea as a data attribute.

I do not believe we should add support to the legacy Group Forums unless someone has an extremely convincing argument otherwise.

I also think that pre-caching the user's friends, even in a group, generally makes sense most of the time. Since mentions in groups will be new for 2.2, how about we leave this pre-cache as it currently is, and revisit for a future release (and see if we get any user feedback)?

#19 in reply to: ↑ 18 @imath
10 years ago

Replying to DJPaul:

I also think that pre-caching the user's friends, even in a group, generally makes sense most of the time. Since mentions in groups will be new for 2.2, how about we leave this pre-cache as it currently is, and revisit for a future release (and see if we get any user feedback)?

I'd say, as long as the "not a friend" user suggestion in a group is a member of the group, i think it's ok.
Ideally, if pre-catched friends were members of the current group, it would be great.

#20 @DJPaul
10 years ago

If there isn't a match in the pre-cached results, then we query the DB for anyone in the users table. I think this is simple and it might confuse users who can't find "Person X" on the Groups Activity, but they can on the Activity Directory (for example).

#21 @imath
10 years ago

I understand your point. Personally for my community i will change this behavior, as i know my "corporate" members will be afraid to see people that are not member of a private or hidden group listed in the suggestions.

#22 @DJPaul
10 years ago

  • Keywords good-first-bug removed

Sure, that's fair, and I can appreciate the use case. I am not against changing how it works by default in the future if we get feedback like this.

Do you have any feedback about the latest patch specifically? If not, I'd like to commit it. :)

#23 @imath
10 years ago

  • Keywords commit added

Patch looks good :)

#24 @djpaul
10 years ago

  • Owner set to djpaul
  • Resolution set to fixed
  • Status changed from new to closed

In 9276:

Groups, Suggestions: add support for @mentions UI in Group Activity screens.

This is achieved by adding support for a new data-suggestions-group-id property to the relevant textarea/input element.
See also r9242:9245 for incremental changes that support this new functionality.

Fixes #5934. Props m@rk, imath, DJPaul.

Note: See TracTickets for help on using tickets.