diff --git a/app/assets/stylesheets/chat.scss b/app/assets/stylesheets/chat.scss
index 719df0d4b..b103b6a84 100644
--- a/app/assets/stylesheets/chat.scss
+++ b/app/assets/stylesheets/chat.scss
@@ -531,7 +531,8 @@
}
}
-.chat__channelinvitationsindicator a {
+.chat__channelinvitationsindicator a,
+.chat__channelinvitationsindicator button {
background: linear-gradient(10deg, darken($green, 25%), darken($green, 15%));
text-align: center;
padding: 30px 0px;
@@ -1265,3 +1266,11 @@
border-radius: '500px';
background-color: '#f5f6f7';
}
+.request-card {
+ display: grid;
+ grid-template-columns: 200px 1fr;
+}
+
+.action button:nth-child(2n) {
+ margin-left: 10px;
+}
diff --git a/app/controllers/chat_channel_memberships_controller.rb b/app/controllers/chat_channel_memberships_controller.rb
index 66c6647e6..e89865227 100644
--- a/app/controllers/chat_channel_memberships_controller.rb
+++ b/app/controllers/chat_channel_memberships_controller.rb
@@ -60,6 +60,7 @@ class ChatChannelMembershipsController < ApplicationController
@chat_channel = ChatChannel.find(params[:chat_channel_id])
authorize @chat_channel, :update?
@chat_channel_membership = @chat_channel.chat_channel_memberships.find(params[:membership_id])
+ membership = ChatChannelMembership.find_by!(chat_channel_id: params[:chat_channel_id], user: current_user)
if params[:status] == "pending"
@chat_channel_membership.destroy
flash[:settings_notice] = "Invitation removed."
@@ -67,8 +68,11 @@ class ChatChannelMembershipsController < ApplicationController
send_chat_action_message("@#{current_user.username} removed @#{@chat_channel_membership.user.username} from #{@chat_channel_membership.channel_name}", current_user, @chat_channel_membership.chat_channel_id, "removed_from_channel")
@chat_channel_membership.update(status: "removed_from_channel")
flash[:settings_notice] = "Removed #{@chat_channel_membership.user.name}"
+ respond_to do |format|
+ format.html { redirect_to edit_chat_channel_membership_path(membership) }
+ format.json { render json: { status: "success", message: "Membership removed" } }
+ end && return
end
- membership = ChatChannelMembership.find_by!(chat_channel_id: params[:chat_channel_id], user: current_user)
redirect_to edit_chat_channel_membership_path(membership)
end
@@ -120,7 +124,10 @@ class ChatChannelMembershipsController < ApplicationController
NotifyMailer.channel_invite_email(@chat_channel_membership, @chat_channel_membership.user).deliver_later
flash[:settings_notice] = "Accepted request of #{@chat_channel_membership.user.username} to join #{channel_name}."
membership = ChatChannelMembership.find_by!(chat_channel_id: @chat_channel_membership.chat_channel.id, user: current_user)
- redirect_to(edit_chat_channel_membership_path(membership)) && return
+ respond_to do |format|
+ format.html { redirect_to(edit_chat_channel_membership_path(membership)) }
+ format.json { render json: { status: "success", message: "Accepted Request" } }
+ end && return
end
else
@chat_channel_membership.update(status: "rejected")
diff --git a/app/controllers/chat_channels_controller.rb b/app/controllers/chat_channels_controller.rb
index 78e7ad65c..bfdb0ca49 100644
--- a/app/controllers/chat_channels_controller.rb
+++ b/app/controllers/chat_channels_controller.rb
@@ -147,7 +147,7 @@ class ChatChannelsController < ApplicationController
def render_unopened_json_response
@chat_channels_memberships = if session_current_user_id
- ChatChannelMembership.where(user_id: session_current_user_id).includes(:chat_channel).
+ ChatChannelMembership.where(user_id: session_current_user_id).includes(%i[chat_channel user]).
where(has_unopened_messages: true).
where(show_global_badge_notification: true).
where.not(status: %w[removed_from_channel left_channel]).
@@ -177,9 +177,11 @@ class ChatChannelsController < ApplicationController
end
def render_joining_request_json_response
- requested_memberships = current_user.chat_channel_memberships.includes(:chat_channel).
- where(chat_channels: { discoverable: true }, role: "mod").pluck(:chat_channel_id).map { |membership_id| ChatChannel.find_by(id: membership_id).requested_memberships }
- render json: { joining_requests: requested_memberships.flatten }
+ requested_memberships_id = current_user.chat_channel_memberships.includes(:chat_channel).
+ where(chat_channels: { discoverable: true }, role: "mod").pluck(:chat_channel_id).map { |membership_id| ChatChannel.find_by(id: membership_id).requested_memberships }.flatten.map(&:id)
+ @chat_channels_memberships = ChatChannelMembership.includes(%i[user chat_channel]).where(id: requested_memberships_id)
+
+ render "index.json"
end
def render_channels_html
diff --git a/app/javascript/chat/__tests__/__snapshots__/content.test.jsx.snap b/app/javascript/chat/__tests__/__snapshots__/content.test.jsx.snap
index 84bea0c2a..1bdfd86c5 100644
--- a/app/javascript/chat/__tests__/__snapshots__/content.test.jsx.snap
+++ b/app/javascript/chat/__tests__/__snapshots__/content.test.jsx.snap
@@ -1,10 +1,67 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`