FEATURE: Create New Topic button on embed with params (#8280)

* FEATURE: Create New Topic button on embed with params
This commit is contained in:
Mark VanLandingham 2019-11-01 14:19:10 -05:00 committed by GitHub
parent 0e2261c414
commit 66e0bdc053
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 0 deletions

View File

@ -3,6 +3,7 @@
@import "./common/foundation/variables";
@import "./common/foundation/colors";
@import "./common/foundation/mixins";
@import "./common/components/buttons";
article.post {
border-bottom: 1px solid #ddd;
@ -176,6 +177,32 @@ div.lightbox-wrapper {
margin-bottom: 20px;
}
.new-topic-btn {
margin: 0.5rem;
&:hover {
background: #006da3;
}
span {
display: inline-block;
vertical-align: middle;
padding-bottom: 2px;
}
.new-topic-btn__icon {
width: 16px;
height: 16px;
margin-right: 2px;
background-image: svg-uri(
'<svg xmlns="http://www.w3.org/2000/svg" width="32px" height="32px" viewBox="0 0 448 512" fill="white"><path d="M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path></svg>'
);
background-repeat: no-repeat;
background-size: 100%;
background-position: top center;
}
}
.topics-list {
width: 100%;

View File

@ -42,6 +42,15 @@ class EmbedController < ApplicationController
list_options = build_topic_list_options
list_options[:per_page] = params[:per_page].to_i if params.has_key?(:per_page)
if params[:allow_create]
@allow_create = true
create_url_params = {}
create_url_params[:category_id] = params[:category] if params[:category].present?
create_url_params[:tags] = params[:tags] if params[:tags].present?
@create_url = "#{Discourse.base_url}/new-topic?#{create_url_params.to_query}"
end
topic_query = TopicQuery.new(current_user, list_options)
@list = topic_query.list_latest
end

View File

@ -1,4 +1,12 @@
<%- if @list && @list.topics.present? %>
<%- if @allow_create %>
<%= link_to @create_url, target: "_blank" do |link| %>
<button class="new-topic-btn btn btn-primary">
<span class="new-topic-btn__icon"></span>
<span class="new-topic-btn__text"><%= I18n.t('embed.new_topic') %></span>
</button>
<%- end %>
<%- end %>
<div class='topics-list' data-embed-state='loaded' <%- if @embed_id %>data-embed-id="<%= @embed_id %>"<%- end %>>
<%- @list.topics.each do |t| %>
<div class='topic-list-item'>

View File

@ -296,6 +296,7 @@ en:
other: "%{count} likes"
last_reply: "Last reply"
created: "Created"
new_topic: "Create new topic"
no_mentions_allowed: "Sorry, you can't mention other users."
too_many_mentions: