diff --git a/app/controllers/collections/publications_controller.rb b/app/controllers/collections/publications_controller.rb
new file mode 100644
index 000000000..feb5ae4b7
--- /dev/null
+++ b/app/controllers/collections/publications_controller.rb
@@ -0,0 +1,13 @@
+class Collections::PublicationsController < ApplicationController
+ include CollectionScoped
+
+ def create
+ @collection.publish
+ redirect_to edit_collection_path(@collection)
+ end
+
+ def destroy
+ @collection.unpublish
+ redirect_to edit_collection_path(@collection)
+ end
+end
diff --git a/app/views/collections/edit.html.erb b/app/views/collections/edit.html.erb
index aa592630b..d10da28db 100644
--- a/app/views/collections/edit.html.erb
+++ b/app/views/collections/edit.html.erb
@@ -33,14 +33,10 @@
<%= render "collections/edit/workflows", collection: @collection %>
<%= render "collections/edit/auto_close", collection: @collection %>
+ <%= render "collections/edit/publication", collection: @collection %>
- <%= form_with model: @collection, class: "txt-align-center", method: :delete do |form| %>
- <%= form.button class: "btn txt-negative borderless txt-small", data: { turbo_confirm: "Are you sure you want to permanently delete this Collection?" } do %>
- <%= icon_tag "trash" %>
- Delete this Collection
- <% end %>
- <% end %>
+ <%= render "collections/edit/delete", collection: @collection %>
diff --git a/app/views/collections/edit/_delete.html.erb b/app/views/collections/edit/_delete.html.erb
new file mode 100644
index 000000000..a0c34232d
--- /dev/null
+++ b/app/views/collections/edit/_delete.html.erb
@@ -0,0 +1,6 @@
+<%= form_with model: collection, class: "txt-align-center", method: :delete do |form| %>
+ <%= form.button class: "btn txt-negative borderless txt-small", data: { turbo_confirm: "Are you sure you want to permanently delete this Collection?" } do %>
+ <%= icon_tag "trash" %>
+ Delete this Collection
+ <% end %>
+<% end %>
diff --git a/app/views/collections/edit/_publication.html.erb b/app/views/collections/edit/_publication.html.erb
new file mode 100644
index 000000000..70a6b7a09
--- /dev/null
+++ b/app/views/collections/edit/_publication.html.erb
@@ -0,0 +1,15 @@
+Publish this collection
+
+<% if collection.published? %>
+ This collection is public.
+ <%= button_to "Unpublish", collection_publication_path(collection), method: :delete, class: "btn btn--negative" %>
+ <%= text_field_tag :publication_url, published_collection_url(collection), disabled: true %>
+ <%= button_to_copy_to_clipboard(published_collection_url(collection)) do %>
+ <%= icon_tag "copy-paste" %>
+ Copy join link
+ <% end %>
+<% else %>
+ Make this collection public.
+ <%= button_to "Publish", collection_publication_path(collection), method: :post, class: "btn" %>
+<% end %>
+
diff --git a/config/routes.rb b/config/routes.rb
index e1efdc834..37682f33e 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -19,6 +19,7 @@ Rails.application.routes.draw do
resource :subscriptions
resource :workflow, only: :update
resource :involvement
+ resource :publication
end
resources :cards
@@ -102,6 +103,13 @@ Rails.application.routes.draw do
resources :pins
end
+ namespace :public do
+ resources :collections
+ end
+
+ direct :published_collection do |collection, options|
+ route_for :public_collection, collection.publication.key
+ end
resolve "Card" do |card, options|
route_for :collection_card, card.collection, card, options