A platform for community discussion. Free, open, simple.
FEATURE: Create New Topic button on embed with params (#8280)
Mark VanLandingham66e0bdc053f3
diff --git a/app/assets/stylesheets/embed.scss b/app/assets/stylesheets/embed.scssindex c4c7046463d..d0acdb1e6fc 100644--- a/app/assets/stylesheets/embed.scss+++ b/app/assets/stylesheets/embed.scss@@ -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%;diff --git a/app/controllers/embed_controller.rb b/app/controllers/embed_controller.rbindex 0d8f53eed2c..04e6a2ec89f 100644--- a/app/controllers/embed_controller.rb+++ b/app/controllers/embed_controller.rb@@ -42,6 +42,15 @@ class EmbedController < ApplicationControllerlist_options = build_topic_list_optionslist_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_latestenddiff --git a/app/views/embed/topics.html.erb b/app/views/embed/topics.html.erbindex 2aaf3267969..10b825f7273 100644--- a/app/views/embed/topics.html.erb+++ b/app/views/embed/topics.html.erb@@ -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'>diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex c7e926513aa..bc323fbb774 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -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: