forked from External/greenlight
		
	Improve can't create room view (#723)
* Improve cant create room view * Translate role names in the promoted/demoted emails
This commit is contained in:
		
				
					committed by
					
						 Jesus Federico
						Jesus Federico
					
				
			
			
				
	
			
			
			
						parent
						
							402de8189e
						
					
				
				
					commit
					46e0595e3a
				
			| @@ -74,3 +74,12 @@ | |||||||
|   align-items: center; |   align-items: center; | ||||||
|   justify-content: center; |   justify-content: center; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | .avatar-xxxl{ | ||||||
|  |   width: 8rem; | ||||||
|  |   height: 8rem; | ||||||
|  |   line-height: 8rem; | ||||||
|  |   max-width: 8rem; | ||||||
|  |   margin-top: -6rem; | ||||||
|  |   font-size: 5rem; | ||||||
|  | } | ||||||
|   | |||||||
| @@ -66,6 +66,7 @@ class RoomsController < ApplicationController | |||||||
|  |  | ||||||
|         @pagy, @recordings = pagy_array(recs) |         @pagy, @recordings = pagy_array(recs) | ||||||
|       else |       else | ||||||
|  |         @recent_rooms = Room.where(id: cookies.encrypted["#{current_user.uid}_recently_joined_rooms"]) | ||||||
|         render :cant_create_rooms |         render :cant_create_rooms | ||||||
|       end |       end | ||||||
|     else |     else | ||||||
| @@ -130,6 +131,13 @@ class RoomsController < ApplicationController | |||||||
|     # create or update cookie with join name |     # create or update cookie with join name | ||||||
|     cookies.encrypted[:greenlight_name] = @join_name unless cookies.encrypted[:greenlight_name] == @join_name |     cookies.encrypted[:greenlight_name] = @join_name unless cookies.encrypted[:greenlight_name] == @join_name | ||||||
|  |  | ||||||
|  |     if current_user | ||||||
|  |       # create or update cookie to track the three most recent rooms a user joined | ||||||
|  |       recently_joined_rooms = cookies.encrypted["#{current_user.uid}_recently_joined_rooms"].to_a | ||||||
|  |       cookies.encrypted["#{current_user.uid}_recently_joined_rooms"] = recently_joined_rooms.prepend(@room.id) | ||||||
|  |                                                                                             .uniq[0..2] | ||||||
|  |     end | ||||||
|  |  | ||||||
|     join_room(opts) |     join_room(opts) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -303,8 +303,8 @@ class UsersController < ApplicationController | |||||||
|       end |       end | ||||||
|  |  | ||||||
|       # Send promoted/demoted emails |       # Send promoted/demoted emails | ||||||
|       added_roles.each { |role| send_user_promoted_email(@user, role.name) if role.send_promoted_email } |       added_roles.each { |role| send_user_promoted_email(@user, role) if role.send_promoted_email } | ||||||
|       removed_roles.each { |role| send_user_demoted_email(@user, role.name) if role.send_demoted_email } |       removed_roles.each { |role| send_user_demoted_email(@user, role) if role.send_demoted_email } | ||||||
|  |  | ||||||
|       # Update the roles |       # Update the roles | ||||||
|       @user.roles.delete(removed_roles) |       @user.roles.delete(removed_roles) | ||||||
|   | |||||||
| @@ -17,6 +17,8 @@ | |||||||
| # with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. | # with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. | ||||||
|  |  | ||||||
| class UserMailer < ApplicationMailer | class UserMailer < ApplicationMailer | ||||||
|  |   include ApplicationHelper | ||||||
|  |  | ||||||
|   default from: Rails.configuration.smtp_sender |   default from: Rails.configuration.smtp_sender | ||||||
|  |  | ||||||
|   def verify_email(user, url, image, color) |   def verify_email(user, url, image, color) | ||||||
| @@ -40,8 +42,8 @@ class UserMailer < ApplicationMailer | |||||||
|     @admin_url = url + "admins" |     @admin_url = url + "admins" | ||||||
|     @image = image |     @image = image | ||||||
|     @color = color |     @color = color | ||||||
|     @role = role |     @role = role.name | ||||||
|     mail to: user.email, subject: t('mailer.user.promoted.subtitle', role: role) |     mail to: user.email, subject: t('mailer.user.promoted.subtitle', role: translated_role_name(role)) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   def user_demoted(user, role, url, image, color) |   def user_demoted(user, role, url, image, color) | ||||||
| @@ -49,8 +51,8 @@ class UserMailer < ApplicationMailer | |||||||
|     @root_url = url |     @root_url = url | ||||||
|     @image = image |     @image = image | ||||||
|     @color = color |     @color = color | ||||||
|     @role = role |     @role = role.name | ||||||
|     mail to: user.email, subject: t('mailer.user.demoted.subtitle', role: role) |     mail to: user.email, subject: t('mailer.user.demoted.subtitle', role: translated_role_name(role)) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   def invite_email(name, email, url, image, color) |   def invite_email(name, email, url, image, color) | ||||||
|   | |||||||
| @@ -18,25 +18,59 @@ | |||||||
| <div id="cant-create-room-wrapper" class="background h-100 cant-create-room-wrapper"> | <div id="cant-create-room-wrapper" class="background h-100 cant-create-room-wrapper"> | ||||||
|     <div class="container h-100"> |     <div class="container h-100"> | ||||||
|         <div class="row h-100 align-items-center"> |         <div class="row h-100 align-items-center"> | ||||||
|             <div class="offset-3 col-6 offset-3"> |             <div class="col-12"> | ||||||
|                 <div class="card"> |                 <div class="row"> | ||||||
|                     <div class="card-status bg-primary"></div> |                     <div class="col-5"> | ||||||
|                     <div class="card-header cant-create-rooms-title"> |                         <div class="card card-profile h-100"> | ||||||
|                         <h3 class="card-title"><%= t("room.no_room.title") %></h3> |                             <div class="card-header bg-primary h-50"></div> | ||||||
|  |                             <div class="card-body text-center"> | ||||||
|  |                                 <% if current_user.image.blank? %> | ||||||
|  |                                     <span class="avatar avatar-xxxl card-profile-img bg-primary"><%= current_user.name.first %></span> | ||||||
|  |                                 <% else %> | ||||||
|  |                                     <%= image_tag(current_user.image, class: "avatar avatar-xxxl card-profile-img") %> | ||||||
|  |                                 <% end %> | ||||||
|  |                                 <h2 class="mb-3"><%= current_user.name %></h2> | ||||||
|  |                                 <%= link_to edit_user_path(current_user), class: "btn btn-outline-primary mt-2" do %> | ||||||
|  |                                     <i class="dropdown-icon fas fa-id-card mr-3"></i><%= t("room.no_room.edit_profile") %> | ||||||
|  |                                 <% end %> | ||||||
|  |                             </div> | ||||||
|  |                         </div> | ||||||
|                     </div> |                     </div> | ||||||
|                     <div class="card-body"> |                     <div class="col-7"> | ||||||
|                         <p><%= t("room.no_room.description") %></p> |                         <div class="card h-100"> | ||||||
|                         <%= form_for(:join_room, url: join_room_path) do |f| %> |                             <div class="card-status bg-primary"></div> | ||||||
|                             <div class="input-icon mb-2"> |                             <div class="card-header cant-create-rooms-title"> | ||||||
|                                 <span class="input-icon-addon"> |                                 <h3 class="card-title"><%= t("room.no_room.title") %></h3> | ||||||
|                                     <i class="fas fa-link"></i> |  | ||||||
|                                 </span> |  | ||||||
|                                 <%= f.text_field :url, class: "form-control", value: "", placeholder: t("room.no_room.placeholder"), required: "" %> |  | ||||||
|                             </div> |                             </div> | ||||||
|                             <div class="mt-4"> |                             <div class="card-body d-flex flex-column justify-content-center align-items-center"> | ||||||
|                                 <%= f.submit t("room.join"), class:"btn btn-primary btn-block" %> |                                 <p class="w-75"><%= t("room.no_room.description") %></p> | ||||||
|  |                                 <%= form_for(:join_room, url: join_room_path, html: {class: "w-75"}) do |f| %> | ||||||
|  |                                     <div class="input-icon mb-2"> | ||||||
|  |                                         <span class="input-icon-addon"> | ||||||
|  |                                             <i class="fas fa-link"></i> | ||||||
|  |                                         </span> | ||||||
|  |                                         <%= f.text_field :url, class: "form-control", value: "", placeholder: t("room.no_room.placeholder"), required: "" %> | ||||||
|  |                                     </div> | ||||||
|  |                                     <div class="mt-4"> | ||||||
|  |                                         <%= f.submit t("room.no_room.go_to"), class:"btn btn-primary btn-block" %> | ||||||
|  |                                     </div> | ||||||
|  |                                 <% end %> | ||||||
|                             </div> |                             </div> | ||||||
|                         <% end %> |                             <hr class="mt-0 mb-0"> | ||||||
|  |                             <div class="card-body d-flex flex-column justify-content-center align-items-center"> | ||||||
|  |                             <ul class="list-group w-75 text-center"> | ||||||
|  |                                 <li class="list-group-item active"><%= t("room.no_room.recent_rooms") %></li> | ||||||
|  |                                 <% @recent_rooms.each do |room| %> | ||||||
|  |                                     <%= link_to room_path(room), class: "list-group-item list-group-item-action dropdown-item"  do %> | ||||||
|  |                                         <%= room.owner.name + " " + room.name %> | ||||||
|  |                                     <% end %> | ||||||
|  |                                 <% end %> | ||||||
|  |                                 <% if @recent_rooms.count == 0 %> | ||||||
|  |                                     <li class="list-group-item"><%= t("room.no_room.no_recent_rooms") %></li> | ||||||
|  |                                 <% end %> | ||||||
|  |                             </ul> | ||||||
|  |                             </div> | ||||||
|  |                         </div> | ||||||
|                     </div> |                     </div> | ||||||
|                 </div> |                 </div> | ||||||
|             </div> |             </div> | ||||||
|   | |||||||
| @@ -412,10 +412,14 @@ en: | |||||||
|     login: Enter |     login: Enter | ||||||
|     owner: Owner |     owner: Owner | ||||||
|     no_room: |     no_room: | ||||||
|       title: Join a Room |  | ||||||
|       description: Enter the room url or the room id for the room you want to join. |       description: Enter the room url or the room id for the room you want to join. | ||||||
|  |       edit_profile: Edit User Profile | ||||||
|  |       go_to: Go to the Room | ||||||
|       invalid_room_uid: The room url/uid you entered was invalid. |       invalid_room_uid: The room url/uid you entered was invalid. | ||||||
|       placeholder: Room url/uid |       placeholder: Room url/uid | ||||||
|  |       no_recent_rooms: You don't have any recently joined rooms | ||||||
|  |       recent_rooms: Go To a Recently Joined Room | ||||||
|  |       title: Join a Room | ||||||
|     no_sessions: This room has no sessions, yet! |     no_sessions: This room has no sessions, yet! | ||||||
|     recordings: Room Recordings |     recordings: Room Recordings | ||||||
|     room_limit: You have reached the maximum number of rooms allowed |     room_limit: You have reached the maximum number of rooms allowed | ||||||
|   | |||||||
| @@ -53,7 +53,7 @@ class UserMailerPreview < ActionMailer::Preview | |||||||
|   # http://localhost:3000/rails/mailers/user_mailer/user_promoted |   # http://localhost:3000/rails/mailers/user_mailer/user_promoted | ||||||
|   def user_promoted |   def user_promoted | ||||||
|     user = User.first |     user = User.first | ||||||
|     role = Role.first.name |     role = Role.first | ||||||
|     url = "http://example.com" |     url = "http://example.com" | ||||||
|     logo_image = "https://raw.githubusercontent.com/bigbluebutton/greenlight/master/app/assets/images/logo_with_text.png" |     logo_image = "https://raw.githubusercontent.com/bigbluebutton/greenlight/master/app/assets/images/logo_with_text.png" | ||||||
|     user_color = "#467fcf" |     user_color = "#467fcf" | ||||||
| @@ -64,7 +64,7 @@ class UserMailerPreview < ActionMailer::Preview | |||||||
|   # http://localhost:3000/rails/mailers/user_mailer/user_demoted |   # http://localhost:3000/rails/mailers/user_mailer/user_demoted | ||||||
|   def user_demoted |   def user_demoted | ||||||
|     user = User.first |     user = User.first | ||||||
|     role = Role.first.name |     role = Role.first | ||||||
|     url = "http://example.com" |     url = "http://example.com" | ||||||
|     logo_image = "https://raw.githubusercontent.com/bigbluebutton/greenlight/master/app/assets/images/logo_with_text.png" |     logo_image = "https://raw.githubusercontent.com/bigbluebutton/greenlight/master/app/assets/images/logo_with_text.png" | ||||||
|     user_color = "#467fcf" |     user_color = "#467fcf" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user