Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PROD-8291] [PROD-8327] Profile popup cards #4570

Open
wants to merge 48 commits into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
ac1b7f4
[PROD-8291] Profile popup cards
annrra Dec 3, 2024
83d711f
[PROD-8291] Retrieve necessary data and improve logic to hide/show pr…
annrra Dec 3, 2024
761ce8d
[PROD-8291] Updated profile card template
annrra Dec 6, 2024
055fc4f
[PROD-8291] Refactor profilePopupCard to use REST API
annrra Dec 9, 2024
cf901cd
[PROD-8291] Add localized site_rest_url parameter for profile popup card
annrra Dec 10, 2024
74d0304
[PROD-8291] Update profile card template and populate with dynamic da…
annrra Dec 10, 2024
8c3658a
[PROD-8291] Update profile card template and populate with dynamic data
annrra Dec 10, 2024
e737a50
[PROD-8291] Refactor code and update card popup data
annrra Dec 10, 2024
4269b0b
[PROD-8291] Add data-bp-profile-card attribute to be used for activit…
annrra Dec 10, 2024
395a133
[PROD-8291] Update profile card footer template and action buttons
annrra Dec 11, 2024
0d8169c
[PROD-8291] Updates in follow/unfollow button
annrra Dec 11, 2024
4eeea21
[PROD-8291] Update event delegation for action buttons within profile…
annrra Dec 11, 2024
210fcc9
[PROD-8291] code cleanup
annrra Dec 12, 2024
b0697c8
[PROD-8291] code cleanup
annrra Dec 12, 2024
f48d9af
[PROD-8291] Updates in profile card friendship button
annrra Dec 12, 2024
0c5c4f9
[PROD-8291] code cleanup
annrra Dec 12, 2024
7830aaa
[PROD-8291] Prevent card popup data reload and improve hover transition
annrra Dec 12, 2024
78b9634
PROD-8291: Added nonce for rest endpoint to fix the current user session
surajkrsingh Dec 13, 2024
613c691
[PROD-8291] Updated connect/follow buttons and UI improvements for ac…
annrra Dec 13, 2024
2878048
[PROD-8291] Group popup cards
annrra Dec 16, 2024
7766c34
[PROD-8291] Add group members data
annrra Dec 17, 2024
83fd0ab
[PROD-8291] Cancel ongoing AJAX requests when switching quick between…
annrra Dec 17, 2024
6cb23c2
[PROD-8291] uglify buddypress-nouveau
annrra Dec 17, 2024
40d2db5
[PROD-8291] Update group cards template and populate with data
annrra Dec 18, 2024
852b371
[PROD-8291] Overall UI updates - updates in group action buttons
annrra Dec 19, 2024
1f2adfa
[PROD-8291] Cache fetched profile/group data to reduce unnecessary re…
annrra Dec 20, 2024
f877568
[PROD-8291] Update action buttons icons and clear part of profile/gro…
annrra Dec 23, 2024
363a0cc
[PROD-8291] Position card popups above media modal container
annrra Dec 23, 2024
ac7335f
[PROD-8291] Use custom colors for member type labels
annrra Dec 23, 2024
63a5dc6
[PROD-8291] Reset custom colors for member type labels
annrra Dec 23, 2024
73b2d3f
[PROD-8291] Implemented additional breakpoints for screen widths
annrra Dec 26, 2024
fe7ffc2
[PROD-8291] Group/author cards + updated logic to show/hide popups
annrra Dec 26, 2024
5f19782
[PROD-8291] Temporarily remove author avatar selector from event binding
annrra Dec 26, 2024
03a029e
[PROD-8291] Improved logic to switch between group/profile popup
annrra Dec 27, 2024
e831851
[PROD-8291] Style profile card action buttons for smaller screens
annrra Dec 27, 2024
7ffe63e
[PROD-8291] Refactor code for consistency, security and clarity
annrra Jan 7, 2025
a762152
[PROD-8291] grunt uglify
annrra Jan 7, 2025
ac31974
[PROD-8291] Pass profile card attributes in activity entry template a…
annrra Jan 7, 2025
a2702f6
[PROD-8291] Code cleanup
annrra Jan 7, 2025
24c7bf1
PROD-8291 - Optimize code to display profile/group card
jitendrabanjara1991 Jan 9, 2025
e8b8e7f
PROD-8291 - Code alignment fix
jitendrabanjara1991 Jan 9, 2025
c7f96ee
PROD-8291 - Formatting js
jitendrabanjara1991 Jan 9, 2025
dcaafac
PROD-8291 - Prevent to call API if not found group id and user id and…
jitendrabanjara1991 Jan 9, 2025
7843205
[PROD-8291] Skip showing profile card for currently logged in user
annrra Jan 9, 2025
c255f99
[PROD-8291] Avoid duplicate requests for same member/group id
annrra Jan 13, 2025
c062ac6
[PROD-8291] Display popup only if mouse is over the avatar or popup
annrra Jan 13, 2025
bfb67ca
Merge branch 'release' into PROD-8291
annrra Jan 13, 2025
e9c3eeb
[PROD-8291] grunt
annrra Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/bp-activity/bp-activity-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@
add_action( 'bp_after_directory_activity_list', 'bb_activity_add_modal_template' );
add_action( 'bp_after_group_activity_content', 'bb_activity_add_modal_template' );
add_action( 'bp_after_member_activity_content', 'bb_activity_add_modal_template' );
add_action( 'bp_after_directory_activity_list', 'bb_activity_add_profile_card_template' );
add_action( 'bp_after_group_activity_content', 'bb_activity_add_profile_card_template' );
add_action( 'bp_after_member_activity_content', 'bb_activity_add_profile_card_template' );
add_action( 'bp_after_directory_activity_list', 'bb_activity_add_group_card_template' );
add_action( 'bp_after_group_activity_content', 'bb_activity_add_group_card_template' );
add_action( 'bp_after_member_activity_content', 'bb_activity_add_group_card_template' );
add_action( 'bp_after_directory_activity_list', 'bb_gifpicker_add_popup_template' );
add_action( 'bp_after_group_activity_content', 'bb_gifpicker_add_popup_template' );
add_action( 'bp_after_member_activity_content', 'bb_gifpicker_add_popup_template' );
Expand Down Expand Up @@ -3760,6 +3766,24 @@ function bb_activity_add_modal_template() {
bp_get_template_part( 'activity/activity-modal' );
}

/**
* Add profile hover card template.
*
* @since BuddyBoss 2.5.80
annrra marked this conversation as resolved.
Show resolved Hide resolved
*/
function bb_activity_add_profile_card_template() {
bp_get_template_part( 'activity/profile-card' );
}

/**
* Add group hover card template.
*
* @since BuddyBoss 2.5.80
annrra marked this conversation as resolved.
Show resolved Hide resolved
*/
function bb_activity_add_group_card_template() {
bp_get_template_part( 'activity/group-card' );
}

/**
* Add class to recent activity comment.
*
Expand Down
110 changes: 110 additions & 0 deletions src/bp-activity/bp-activity-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5569,6 +5569,63 @@ function bp_activity_get_edit_data( $activity_id = 0 ) {
);
}

/**
* Get the profile card data.
*
* @since BuddyBoss 1.5.1
annrra marked this conversation as resolved.
Show resolved Hide resolved
*
* @param int $activity_id Activity ID.
*
* @return array|bool The profile card data or false otherwise.
*/
function bp_profile_card_get_edit_data( $activity_id = 0 ) {
annrra marked this conversation as resolved.
Show resolved Hide resolved
global $activities_template;

// check activity empty or not.
if ( empty( $activity_id ) && empty( $activities_template ) ) {
return false;
}

// get activity.
if ( ! empty( $activities_template->activity ) ) {
$activity = $activities_template->activity;
} else {
$activity = new BP_Activity_Activity( $activity_id );
}

// check activity exists.
if ( empty( $activity->id ) ) {
return false;
}

$edit_data = wp_cache_get( $activity->id, 'profile_card_data' );
if ( false === $edit_data ) {
$activity_user_id = bp_get_activity_user_id();
$group_id = bp_is_active( 'groups' ) && buddypress()->groups->id === $activity->component ? $activity->item_id : 0;
annrra marked this conversation as resolved.
Show resolved Hide resolved

$edit_data = array(
'user_id' => $activity_user_id,
'current_user_id' => get_current_user_id(),
'group_id' => $group_id,
annrra marked this conversation as resolved.
Show resolved Hide resolved
);

// Set meta data to cache.
wp_cache_set( $activity->id, $edit_data, 'profile_card_data' );
}

/**
* Filter here to edit the activity edit data.
*
* @since BuddyBoss 1.5.1
annrra marked this conversation as resolved.
Show resolved Hide resolved
*
* @param string $activity_data The Activity edit data.
*/
return apply_filters(
'bp_profile_card_get_edit_data',
annrra marked this conversation as resolved.
Show resolved Hide resolved
$edit_data
);
}

/**
* Return the link to report activity
*
Expand Down Expand Up @@ -6387,6 +6444,59 @@ function bb_activity_comment_get_edit_data( $activity_comment_id = 0 ) {
);
}

/**
* Get the profile card edit data.
*
* @since BuddyBoss 2.4.40
annrra marked this conversation as resolved.
Show resolved Hide resolved
*
* @param int $activity_comment_id Activity comment ID.
*
* @return array|bool The profile card edit data or false otherwise.
*/
function bb_profile_card_get_edit_data( $activity_comment_id = 0 ) {
global $activities_template;

// check activity comment empty or not.
if ( empty( $activity_comment_id ) && empty( $activities_template ) ) {
return false;
}

$activity_comment = new stdClass();
// get activity comment.
if ( ! empty( $activity_comment_id ) ) {
$activity_comment = new BP_Activity_Activity( $activity_comment_id );
} elseif ( ! empty( $activities_template->activity->current_comment ) ) {
$activity_comment = $activities_template->activity->current_comment;
}

// check activity comment exists.
if ( empty( $activity_comment->id ) ) {
return false;
}

$edit_data = wp_cache_get( $activity_comment_id, 'activity_edit_data' );
if ( false === $edit_data ) {
$activity_comment_user_id = bp_get_activity_comment_user_id();
annrra marked this conversation as resolved.
Show resolved Hide resolved

$edit_data = array(
'user_id' => $activity_comment_user_id,
'current_user_id' => get_current_user_id(),
annrra marked this conversation as resolved.
Show resolved Hide resolved
);
}

/**
* Filter here to edit the activity comment edit data.
*
* @since BuddyBoss 2.4.40
annrra marked this conversation as resolved.
Show resolved Hide resolved
*
* @param array $activity_comment_data The Activity comment edit data.
*/
return apply_filters(
'bb_profile_card_get_edit_data',
annrra marked this conversation as resolved.
Show resolved Hide resolved
$edit_data
);
}

/**
* Check CPT comment global settings.
*
Expand Down
4 changes: 4 additions & 0 deletions src/bp-templates/bp-nouveau/buddypress-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,10 @@ public function localize_scripts() {
),
'wpTime' => current_time( 'Y-m-d H:i:s' ),
'wpTimezone' => bp_get_option( 'timezone_string' ),
'rest_url' => home_url( 'wp-json/buddyboss/v1' ),
'rest_nonce' => wp_create_nonce('wp_rest'),
annrra marked this conversation as resolved.
Show resolved Hide resolved
'member_label' => __( 'member', 'buddyboss' ),
'members_label' => __( 'members', 'buddyboss' ),
);

// If the Object/Item nav are in the sidebar.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
$activity_comment_id = bp_get_activity_comment_id();
?>

<li id="acomment-<?php echo esc_attr( $activity_comment_id ); ?>" class="<?php bp_activity_comment_css_class(); ?>" data-bp-activity-comment-id="<?php echo esc_attr( $activity_comment_id ); ?>" data-bp-timestamp="<?php bb_nouveau_activity_comment_timestamp(); ?>" data-bp-activity-comment="<?php bb_nouveau_edit_activity_comment_data(); ?>">
<li id="acomment-<?php echo esc_attr( $activity_comment_id ); ?>" class="<?php bp_activity_comment_css_class(); ?>" data-bp-activity-comment-id="<?php echo esc_attr( $activity_comment_id ); ?>" data-bp-timestamp="<?php bb_nouveau_activity_comment_timestamp(); ?>" data-bp-activity-comment="<?php bb_nouveau_edit_activity_comment_data(); ?>" data-bp-profile-card="<?php bb_nouveau_edit_profile_card_data(); ?>">
annrra marked this conversation as resolved.
Show resolved Hide resolved

<div id="acomment-display-<?php echo esc_attr( $activity_comment_id ); ?>" class="acomment-display">

Expand Down
2 changes: 1 addition & 1 deletion src/bp-templates/bp-nouveau/buddypress/activity/entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

?>

<li class="<?php bp_activity_css_class(); ?>" id="activity-<?php echo esc_attr( $activity_id ); ?>" data-bp-activity-id="<?php echo esc_attr( $activity_id ); ?>" data-bp-timestamp="<?php bp_nouveau_activity_timestamp(); ?>" data-bp-activity="<?php bp_nouveau_edit_activity_data(); ?>" data-link-preview='<?php echo $link_preview_string; ?>' data-link-url='<?php echo empty( $link_url ) ? '' : esc_url( $link_url ); ?>' data-activity-popup-title='<?php echo empty( $activity_popup_title ) ? '' : esc_html( $activity_popup_title ); ?>'>
<li class="<?php bp_activity_css_class(); ?>" id="activity-<?php echo esc_attr( $activity_id ); ?>" data-bp-activity-id="<?php echo esc_attr( $activity_id ); ?>" data-bp-timestamp="<?php bp_nouveau_activity_timestamp(); ?>" data-bp-activity="<?php bp_nouveau_edit_activity_data(); ?>" data-bp-profile-card="<?php bp_nouveau_profile_card_data(); ?>" data-link-preview='<?php echo $link_preview_string; ?>' data-link-url='<?php echo empty( $link_url ) ? '' : esc_url( $link_url ); ?>' data-activity-popup-title='<?php echo empty( $activity_popup_title ) ? '' : esc_html( $activity_popup_title ); ?>'>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<li class="<?php bp_activity_css_class(); ?>" id="activity-<?php echo esc_attr( $activity_id ); ?>" data-bp-activity-id="<?php echo esc_attr( $activity_id ); ?>" data-bp-timestamp="<?php bp_nouveau_activity_timestamp(); ?>" data-bp-activity="<?php bp_nouveau_edit_activity_data(); ?>" data-bp-profile-card="<?php bp_nouveau_profile_card_data(); ?>" data-link-preview='<?php echo $link_preview_string; ?>' data-link-url='<?php echo empty( $link_url ) ? '' : esc_url( $link_url ); ?>' data-activity-popup-title='<?php echo empty( $activity_popup_title ) ? '' : esc_html( $activity_popup_title ); ?>'>
<li class="<?php bp_activity_css_class(); ?>" id="activity-<?php echo esc_attr( $activity_id ); ?>" data-bp-activity-id="<?php echo esc_attr( $activity_id ); ?>" data-bp-timestamp="<?php bp_nouveau_activity_timestamp(); ?>" data-bp-activity="<?php bp_nouveau_edit_activity_data(); ?>" data-bb-profile-card="<?php bb_nouveau_profile_card_data(); ?>" data-link-preview='<?php echo $link_preview_string; ?>' data-link-url='<?php echo empty( $link_url ) ? '' : esc_url( $link_url ); ?>' data-activity-popup-title='<?php echo empty( $activity_popup_title ) ? '' : esc_html( $activity_popup_title ); ?>'>

Copy link
Collaborator

Choose a reason for hiding this comment

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

@annrra @surajkrsingh
Can we remove this function and simply pass required attributes like
data-bb-profile-card="<?php echo bp_get_activity_user_id(); ?>" - for user id
<?php echo ! empty( $group_id ) ? "data-bb-group-card=" . $group_id : ''; ?> - for group id


<?php bb_nouveau_activity_entry_bubble_buttons(); ?>

Expand Down
57 changes: 57 additions & 0 deletions src/bp-templates/bp-nouveau/buddypress/activity/group-card.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* The template for groups card.
*
* This template can be overridden by copying it to yourtheme/buddypress/activity/group-card.php.
*
* @since BuddyBoss 2.5.80
annrra marked this conversation as resolved.
Show resolved Hide resolved
* @version 1.0.0
*/
?>
<div id="group-card" class="bb-group-card bb-popup-card" data-bp-item-id="" data-bp-item-component="groups">

<div class="skeleton-card">
<div class="skeleton-card-body">
<div class="skeleton-card-avatar bb-loading-bg"></div>
<div class="skeleton-card-entity">
<div class="skeleton-card-heading bb-loading-bg"></div>
<div class="skeleton-card-meta bb-loading-bg"></div>
</div>
</div>
<?php $plain_class = !is_user_logged_in() ? 'skeleton-footer-plain' : ''; ?>
annrra marked this conversation as resolved.
Show resolved Hide resolved
<div class="skeleton-card-footer <?php echo $plain_class; ?>">
annrra marked this conversation as resolved.
Show resolved Hide resolved
<div class="skeleton-card-button bb-loading-bg"></div>
<div class="skeleton-card-button bb-loading-bg"></div>
</div>
</div>

<div class="bb-card-content">
<div class="bb-card-body">
<div class="bb-card-avatar">
<img src="" alt="">
</div>
<div class="bb-card-entity">
<h4 class="bb-card-heading"></h4>
<div class="bb-card-meta">
<span class="card-meta-item card-meta-status"></span>
<span class="card-meta-item card-meta-type"></span>
<span class="card-meta-item card-meta-last-active"></span>
</div>
<div class="card-group-members">
<span class="bs-group-members"></span>
</div>
</div>
</div>
<div class="bb-card-footer">
<?php if ( is_user_logged_in() ) : ?>
<?php if ( bp_is_active( 'groups' ) ) : ?>
<div class="bb-card-action bb-card-action-join bb-card-action-primary"></div>
<?php endif; ?>
<?php endif; ?>
<div class="bb-card-action bb-card-action-outline">
<a href="" class="card-button card-button-group"><?php esc_html_e( 'View Group', 'buddyboss' ); ?></a>
</div>
</div>
</div>

</div>
68 changes: 68 additions & 0 deletions src/bp-templates/bp-nouveau/buddypress/activity/profile-card.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* The template for pofile card.
annrra marked this conversation as resolved.
Show resolved Hide resolved
*
* This template can be overridden by copying it to yourtheme/buddypress/activity/profile-card.php.
*
* @since BuddyBoss 2.5.80
annrra marked this conversation as resolved.
Show resolved Hide resolved
* @version 1.0.0
*/
?>
<div id="profile-card" class="bb-profile-card bb-popup-card" data-bp-item-id="" data-bp-item-component="members">

<div class="skeleton-card">
<div class="skeleton-card-body">
<div class="skeleton-card-avatar bb-loading-bg"></div>
<div class="skeleton-card-entity">
<div class="skeleton-card-type bb-loading-bg"></div>
<div class="skeleton-card-heading bb-loading-bg"></div>
<div class="skeleton-card-meta bb-loading-bg"></div>
</div>
</div>
<?php $plain_class = !is_user_logged_in() ? 'skeleton-footer-plain' : ''; ?>
annrra marked this conversation as resolved.
Show resolved Hide resolved
<div class="skeleton-card-footer <?php echo $plain_class; ?>">
annrra marked this conversation as resolved.
Show resolved Hide resolved
<div class="skeleton-card-button bb-loading-bg"></div>
<div class="skeleton-card-button bb-loading-bg"></div>
<div class="skeleton-card-button bb-loading-bg"></div>
</div>
</div>

<div class="bb-card-content">
<div class="bb-card-body">
<div class="bb-card-avatar">
<span class="card-profile-status"></span>
<img src="" alt="">
</div>
<div class="bb-card-entity">
<div class="bb-card-profile-type"></div>
<h4 class="bb-card-heading"></h4>
<div class="bb-card-meta">
<span class="card-meta-item card-meta-joined"><?php esc_html_e( 'Joined', 'buddyboss' ); ?> <span></span></span>
<span class="card-meta-item card-meta-last-active"></span>
<span class="card-meta-item card-meta-followers"></span>
</div>
</div>
</div>
<div class="bb-card-footer">
<?php if ( is_user_logged_in() ) : ?>
<?php if ( bp_is_active( 'messages' ) ) : ?>
<div class="bb-card-action bb-card-action-primary">
<a href="" class="card-button send-message">
<i class="bb-icon-l bb-icon-comment"></i>
<?php esc_html_e( 'Message', 'buddyboss' ); ?>
</a>
</div>
<?php else : ?>
<?php if ( bp_is_active( 'friends' ) ) : ?>
<div class="bb-card-action bb-card-action-connect bb-card-action-primary"></div>
<?php endif; ?>
<?php endif; ?>
<div class="bb-card-action bb-card-action-follow bb-card-action-secondary"></div>
<?php endif; ?>
<div class="bb-card-action bb-card-action-outline">
<a href="" class="card-button card-button-profile"><?php esc_html_e( 'View Profile', 'buddyboss' ); ?></a>
</div>
</div>
</div>

</div>
53 changes: 29 additions & 24 deletions src/bp-templates/bp-nouveau/common-styles/_bp_lists.scss
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,34 @@

}

.footer-button-wrap {

@include dis-flex;

.action {
width: 100%;

.generic-button {
float: left;
}

}

}

@media screen and (max-width: 375px) {

> li {
min-width: 280px;
}

}

}

.buddypress-wrap ul.bp-list.groups-dir-list,
.bb-group-card {

.bs-group-members {

@include dis-flex;
Expand All @@ -506,6 +534,7 @@
margin-right: 5px;

.bs-group-member {
display: block;
max-width: 28px;
float: left;
margin-right: -9px;
Expand Down Expand Up @@ -555,30 +584,6 @@
.group-footer-wrap:not(.group-join-button-hidden) .bs-group-members {
margin-left: -4px;
}

.footer-button-wrap {

@include dis-flex;

.action {
width: 100%;

.generic-button {
float: left;
}

}

}

@media screen and (max-width: 375px) {

> li {
min-width: 280px;
}

}

}

// Ensure there's space between parent act list wrapper and filters bar
Expand Down
Loading