-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1918 from brave-intl/staging
Release 2019-05-29
- Loading branch information
Showing
48 changed files
with
1,012 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ | |
|
||
// Admin pages | ||
@import "pages/**/*"; | ||
@import "tooltip"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Taken from https://chrisbracco.com/a-simple-css-tooltip/ | ||
|
||
/* Add this attribute to the element that needs a tooltip */ | ||
[data-tooltip] { | ||
position: relative; | ||
z-index: 2; | ||
cursor: pointer; | ||
} | ||
|
||
/* Hide the tooltip content by default */ | ||
[data-tooltip]:before, | ||
[data-tooltip]:after { | ||
visibility: hidden; | ||
opacity: 0; | ||
pointer-events: none; | ||
} | ||
|
||
/* Position tooltip above the element */ | ||
[data-tooltip]:before { | ||
position: absolute; | ||
bottom: 150%; | ||
left: 50%; | ||
margin-bottom: 5px; | ||
margin-left: -80px; | ||
padding: 7px; | ||
width: 180px; | ||
border-radius: 3px; | ||
background-color: hsla(0, 0%, 20%, 0.9); | ||
color: #fff; | ||
content: attr(data-tooltip); | ||
text-align: center; | ||
font-size: 14px; | ||
line-height: 1.2; | ||
} | ||
|
||
/* Triangle hack to make tooltip look like a speech bubble */ | ||
[data-tooltip]:after { | ||
position: absolute; | ||
bottom: 150%; | ||
left: 50%; | ||
margin-left: -5px; | ||
width: 0; | ||
border-top: 5px solid hsla(0, 0%, 20%, 0.9); | ||
border-right: 5px solid transparent; | ||
border-left: 5px solid transparent; | ||
content: " "; | ||
font-size: 0; | ||
line-height: 0; | ||
} | ||
|
||
/* Show tooltip content on hover */ | ||
[data-tooltip]:hover:before, | ||
[data-tooltip]:hover:after { | ||
visibility: visible; | ||
opacity: 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# frozen_string_literal: true | ||
|
||
module Admin | ||
class PublisherNotesController < AdminController | ||
before_action :authorize, except: :create | ||
|
||
EMAIL = "@brave.com" | ||
|
||
def create | ||
publisher = Publisher.find(params[:publisher_id]) | ||
|
||
note = PublisherNote.new( | ||
publisher: publisher, | ||
created_by: current_user, | ||
note: note_params[:note], | ||
) | ||
note.thread_id = note_params[:thread_id] if note_params[:thread_id].present? | ||
|
||
if note.save | ||
email_tagged_users(note) | ||
|
||
if note_params[:thread_id].present? | ||
created_by = note.thread.created_by | ||
if current_user != created_by && note.note.exclude?("@" + created_by.email.sub(EMAIL, '')) | ||
InternalMailer.tagged_in_note( | ||
tagged_user: note.thread.created_by, | ||
note: note | ||
).deliver_later | ||
end | ||
end | ||
|
||
redirect_to(admin_publisher_path(publisher.id)) | ||
else | ||
redirect_to admin_publisher_path(publisher.id), flash: { alert: note.errors.full_messages.join(',') } | ||
end | ||
end | ||
|
||
def update | ||
if @note.update(note_params) | ||
email_tagged_users(@note) | ||
|
||
redirect_to admin_publisher_path(id: params[:publisher_id]), flash: { success: "Successfully updated comment" } | ||
else | ||
redirect_to admin_publisher_path(id: params[:publisher_id]), flash: { alert: @note.errors.full_messages.join(',') } | ||
end | ||
end | ||
|
||
def destroy | ||
publisher = @note.publisher | ||
if @note.comments.any? | ||
redirect_to admin_publisher_path(publisher), flash: { alert: "Can't delete a note that has comments." } | ||
else | ||
@note.destroy | ||
|
||
redirect_to admin_publisher_path(publisher) | ||
end | ||
end | ||
|
||
private | ||
|
||
def email_tagged_users(publisher_note) | ||
publisher_note.note.scan(/\@(\w*)/).uniq.each do |mention| | ||
# Some reason the regex likes to put an array inside array | ||
mention = mention[0] | ||
publisher = Publisher.where("email LIKE ?", mention + EMAIL).first | ||
InternalMailer.tagged_in_note(tagged_user: publisher, note: publisher_note).deliver_later if publisher.present? | ||
end | ||
end | ||
|
||
def authorize | ||
@note = PublisherNote.find(params[:id]) | ||
raise unless @note.created_by == current_user | ||
end | ||
|
||
def note_params | ||
params.require(:publisher_note).permit(:note, :thread_id) | ||
end | ||
end | ||
end |
8 changes: 3 additions & 5 deletions
8
app/controllers/admin/publishers/publisher_status_updates_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.