A platform for community discussion. Free, open, simple.
FEATURE: Archiving boards (#43506)
Martin Brennanfa89635bd92f
diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 86308134e38..f4c9b38397d 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -410,6 +410,7 @@ en:tooltip: "Notification level: %{level}"back_button: "Back"+ confirm_button: "Confirm"welcome_banner:header:diff --git a/db/structure.sql b/db/structure.sqlindex 172e576eec5..02e8c9a362b 100644--- a/db/structure.sql+++ b/db/structure.sql@@ -4330,7 +4330,11 @@ CREATE TABLE public.discourse_kanban_boards (created_at timestamp(6) without time zone NOT NULL,updated_at timestamp(6) without time zone NOT NULL,category_ids integer[] DEFAULT '{}'::integer[] NOT NULL,- tag_ids integer[] DEFAULT '{}'::integer[] NOT NULL+ tag_ids integer[] DEFAULT '{}'::integer[] NOT NULL,+ archived boolean DEFAULT false NOT NULL,+ archived_at timestamp(6) without time zone,+ archived_by_id bigint,+ original_slug character varying);@@ -25068,6 +25072,7 @@ ALTER TABLE ONLY public.ad_plugin_house_ads_groupsSET search_path TO "$user", public;INSERT INTO "schema_migrations" (version) VALUES+('20260910033302'),('20260908160656'),('20260908153158'),('20260908112615'),diff --git a/plugins/boards/app/controllers/boards/api/boards_controller.rb b/plugins/boards/app/controllers/boards/api/boards_controller.rbindex b407207be8e..3f1b456f4e8 100644--- a/plugins/boards/app/controllers/boards/api/boards_controller.rb+++ b/plugins/boards/app/controllers/boards/api/boards_controller.rb@@ -6,7 +6,7 @@ module BoardsDEFAULT_INDEX_PERMISSIONS = %w[view edit manage].freezebefore_action :ensure_logged_in,- only: %i[create update destroy move_column constraint_preview]+ only: %i[create update destroy move_column constraint_preview archive unarchive]before_action :find_board!, only: %i[show]before_action :ensure_board_read!, only: %i[show]@@ -28,10 +28,21 @@ module Boards.with_any_acl_permissions(guardian, allowed_permissions).order(:name).to_a+ used_slugs =+ Boards::Board+ .where(slug: boards.select(&:archived?).map(&:original_slug))+ .pluck(:slug)+ .to_settag_name_map = build_tag_name_map(*boards)render json: {boards:- serialize_data(boards, Boards::BoardSerializer, root: false, tag_name_map:),+ serialize_data(+ boards,+ Boards::BoardSerializer,+ root: false,+ tag_name_map:,+ used_slugs:,+ ),}end@@ -49,6 +60,7 @@ module Boardsboards =Boards::Board+ .open.includes(:columns, :created_by).with_any_acl_permissions(guardian, allowed_permissions).order(:name)@@ -119,7 +131,7 @@ module Boardsserialize_board(@board,tag_name_map:,- include_acl: guardian.can_manage_boards_board?(@board),+ include_acl: guardian.can_manage_board?(@board),),columns: columns,}@@ -149,7 +161,7 @@ module Boards) doon_success do |board:, cards_removed_count:|response = {- board: serialize_board(board, include_acl: guardian.can_manage_boards_board?(board)),+ board: serialize_board(board, include_acl: guardian.can_manage_board?(board)),}response[:cards_removed_count] = cards_removed_count if cards_removed_count.to_i > 0render json: response@@ -229,6 +241,82 @@ module Boardsrender json: { cards_to_remove: count }end+ def archive+ Boards::Archive.call(+ service_params.deep_merge(+ params: {+ board_id: params[:id],+ client_id: params[:client_id],+ },+ ),+ ) do+ on_success do |board:|+ render json: {+ board:+ Boards::BoardSerializer.new(+ board,+ scope: guardian,+ root: false,+ tag_name_map: build_tag_name_map(board),+ ).as_json,+ }+ end+ on_model_not_found(:board) { raise Discourse::NotFound }+ on_failed_policy(:can_archive) { raise Discourse::InvalidAccess }+ on_failed_contract do |contract|+ render json: failed_json.merge(errors: contract.errors.full_messages),+ status: :bad_request+ end+ on_exceptions(ActiveRecord::RecordInvalid) do |exception|+ render json: failed_json.merge(errors: exception.record.errors.full_messages),+ status: :unprocessable_entity+ end+ on_exceptions(ActiveRecord::RecordNotUnique) do+ render json: failed_json.merge(errors: [I18n.t("boards.errors.slug_unavailable")]),+ status: :unprocessable_entity+ end+ on_failure { render json: failed_json, status: :unprocessable_entity }+ end+ end++ def unarchive+ Boards::Unarchive.call(+ service_params.deep_merge(+ params: {+ board_id: params[:id],+ client_id: params[:client_id],+ },+ ),+ ) do+ on_success do |board:|+ render json: {+ board:+ Boards::BoardSerializer.new(+ board,+ scope: guardian,+ root: false,+ tag_name_map: build_tag_name_map(board),+ ).as_json,+ }+ end+ on_model_not_found(:board) { raise Discourse::NotFound }+ on_failed_policy(:can_unarchive) { raise Discourse::InvalidAccess }+ on_failed_contract do |contract|+ render json: failed_json.merge(errors: contract.errors.full_messages),+ status: :bad_request+ end+ on_exceptions(ActiveRecord::RecordInvalid) do |exception|+ render json: failed_json.merge(errors: exception.record.errors.full_messages),+ status: :unprocessable_entity+ end+ on_exceptions(ActiveRecord::RecordNotUnique) do+ render json: failed_json.merge(errors: [I18n.t("boards.errors.slug_unavailable")]),+ status: :unprocessable_entity+ end+ on_failure { render json: failed_json, status: :unprocessable_entity }+ end+ end+def destroyBoards::DestroyBoard.call(service_params) doon_success { head :no_content }diff --git a/plugins/boards/app/controllers/boards/base_controller.rb b/plugins/boards/app/controllers/boards/base_controller.rbindex dd2522e453f..296c5025632 100644--- a/plugins/boards/app/controllers/boards/base_controller.rb+++ b/plugins/boards/app/controllers/boards/base_controller.rb@@ -19,7 +19,7 @@ module Boardsenddef ensure_board_read!- unless guardian.can_read_boards_board?(@board)+ unless guardian.can_read_board?(@board)raise Discourse::InvalidAccess.new(I18n.t("boards.errors.board_read_forbidden"))endenddiff --git a/plugins/boards/app/jobs/regular/boards/card_post_process.rb b/plugins/boards/app/jobs/regular/boards/card_post_process.rbindex 207d1b5751b..909b67ac368 100644--- a/plugins/boards/app/jobs/regular/boards/card_post_process.rb+++ b/plugins/boards/app/jobs/regular/boards/card_post_process.rb@@ -12,6 +12,7 @@ module Jobscard = ::Boards::Card.find_by(id: card_id)return unless current_floater?(card, title)+ return if card.board.archived?inline_onebox_data = ::Boards::Action::CardInlineOnebox.call(title:)return if card.inline_onebox_data == inline_onebox_datadiff --git a/plugins/boards/app/models/boards/board.rb b/plugins/boards/app/models/boards/board.rbindex de1187a7619..b13b9af926b 100644--- a/plugins/boards/app/models/boards/board.rb+++ b/plugins/boards/app/models/boards/board.rb@@ -24,9 +24,12 @@ module Boards-> { order(created_at: :asc) },class_name: "Boards::BoardHistory",inverse_of: :board+ belongs_to :archived_by, class_name: "User", optional: truebelongs_to :created_by, class_name: "User"belongs_to :updated_by, class_name: "User", optional: true+ scope :open, -> { where(archived: false) }+enum :card_style, { detailed: 0, simple: 1 }, default: :detailedvalidates :name, :slug, presence: true@@ -64,6 +67,21 @@ module Boards[ACL_PERMISSIONS.manage]end+ def archive_slug(date)+ base = "#{slug}-archived-#{date.strftime("%Y%m%d")}"+ candidate = base+ suffix = 1+ while self.class.where.not(id: id).exists?(slug: candidate)+ suffix += 1+ candidate = "#{base}-#{suffix}"+ end+ candidate+ end++ def old_slug_used?+ archived? && self.class.where.not(id: id).exists?(slug: original_slug)+ end+def url"#{Discourse.base_url}/boards/#{slug}/#{id}"end@@ -193,6 +211,8 @@ module Boardsprivatedef normalize_slug+ return if archived? || (will_save_change_to_archived? && slug == original_slug_in_database)+source = slug.presence || nameself.slug = Slug.for(source) if source.present?end@@ -235,9 +255,12 @@ end# Table name: discourse_kanban_boards## id :bigint not null, primary key+# archived :boolean default(FALSE), not null+# archived_at :datetime# card_style :integer default("detailed"), not null# category_ids :integer default([]), not null, is an Array# name :string not null+# original_slug :string# require_confirmation :boolean default(TRUE), not null# show_tags :boolean default(FALSE), not null# show_topic_thumbnail :boolean default(FALSE), not null@@ -245,6 +268,7 @@ end# tag_ids :integer default([]), not null, is an Array# created_at :datetime not null# updated_at :datetime not null+# archived_by_id :bigint# created_by_id :bigint# updated_by_id :bigint#diff --git a/plugins/boards/app/models/boards/board_history.rb b/plugins/boards/app/models/boards/board_history.rbindex f8b3f5bd47e..8c4842221b7 100644--- a/plugins/boards/app/models/boards/board_history.rb+++ b/plugins/boards/app/models/boards/board_history.rb@@ -25,6 +25,8 @@ module Boardscolumn_renamed: 9,column_edited: 10,column_deleted: 11,+ board_archived: 12,+ board_unarchived: 13,}endenddiff --git a/plugins/boards/app/serializers/boards/board_serializer.rb b/plugins/boards/app/serializers/boards/board_serializer.rbindex 9e1483a1861..a8522b3c3f7 100644--- a/plugins/boards/app/serializers/boards/board_serializer.rb+++ b/plugins/boards/app/serializers/boards/board_serializer.rb@@ -14,6 +14,10 @@ module Boards:show_tags,:card_style,:show_topic_thumbnail,+ :archived,+ :old_slug_used,+ :can_archive,+ :can_unarchive,:can_write,:can_manage,:created_by,@@ -32,12 +36,29 @@ module Boardsobject.anonymous_can_read?end+ def old_slug_used+ return false unless object.archived?+ if @options.key?(:used_slugs)+ @options[:used_slugs].include?(object.original_slug)+ else+ object.old_slug_used?+ end+ end++ def can_archive+ scope.can_archive_board?(object)+ end++ def can_unarchive+ scope.can_unarchive_board?(object)+ end+def can_write- scope.can_write_boards_board?(object)+ scope.can_write_board?(object)enddef can_manage- scope.can_manage_boards_board?(object)+ scope.can_manage_board?(object)enddef created_bydiff --git a/plugins/boards/app/services/boards/archive.rb b/plugins/boards/app/services/boards/archive.rbnew file mode 100644index 00000000000..88dff1a0018--- /dev/null+++ b/plugins/boards/app/services/boards/archive.rb@@ -0,0 +1,61 @@+# frozen_string_literal: true++module Boards+ class Archive+ include Service::Base++ params do+ attribute :board_id, :integer+ attribute :client_id, :string++ validates :board_id, presence: true+ end++ try ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique do+ transaction do+ model :board+ policy :can_archive+ step :archive_board+ step :record_history+ end++ step :publish_board_archived_event+ end++ private++ def fetch_board(params:)+ Board.lock.find_by(id: params.board_id)+ end++ def can_archive(guardian:, board:)+ guardian.can_archive_board?(board)+ end++ def archive_board(board:, guardian:)+ archived_at = Time.current+ board.update!(+ original_slug: board.slug,+ slug: board.archive_slug(archived_at.to_date),+ archived: true,+ archived_at:,+ archived_by: guardian.user,+ )+ end++ def record_history(board:, guardian:)+ board.history.create!(+ acting_user: guardian.user,+ action: :board_archived,+ details: {+ previous_value: board.slug_before_last_save,+ new_value: board.slug,+ },+ )+ end++ def publish_board_archived_event(board:, guardian:, params:)+ Boards::Publisher.publish_board_archived!(board, client_id: params.client_id)+ end+ end+enddiff --git a/plugins/boards/app/services/boards/check_board_topic_constraint_mismatches.rb b/plugins/boards/app/services/boards/check_board_topic_constraint_mismatches.rbindex 9053f83291a..3710d7bdb64 100644--- a/plugins/boards/app/services/boards/check_board_topic_constraint_mismatches.rb+++ b/plugins/boards/app/services/boards/check_board_topic_constraint_mismatches.rb@@ -29,7 +29,7 @@ module Boardsenddef can_edit_board(board:, guardian:)- guardian.can_write_boards_board?(board)+ guardian.can_write_board?(board)enddef fetch_topic(params:)diff --git a/plugins/boards/app/services/boards/clear_column.rb b/plugins/boards/app/services/boards/clear_column.rbindex 28d224a46c2..286fe5d2ce7 100644--- a/plugins/boards/app/services/boards/clear_column.rb+++ b/plugins/boards/app/services/boards/clear_column.rb@@ -24,7 +24,7 @@ module Boardsenddef can_write(board:, guardian:)- guardian.can_write_boards_board?(board)+ guardian.can_write_board?(board)enddef fetch_column(board:, params:)diff --git a/plugins/boards/app/services/boards/create_board.rb b/plugins/boards/app/services/boards/create_board.rbindex 1a995d1a501..fb252aa98af 100644--- a/plugins/boards/app/services/boards/create_board.rb+++ b/plugins/boards/app/services/boards/create_board.rb@@ -22,7 +22,7 @@ module Boardsprivatedef can_manage(guardian:)- guardian.can_create_boards_board?+ guardian.can_create_board?enddef create_board(guardian:)diff --git a/plugins/boards/app/services/boards/create_card.rb b/plugins/boards/app/services/boards/create_card.rbindex e085f0f7611..1f20a3bebf8 100644--- a/plugins/boards/app/services/boards/create_card.rb+++ b/plugins/boards/app/services/boards/create_card.rb@@ -37,7 +37,7 @@ module Boardsenddef can_write(board:, guardian:)- guardian.can_write_boards_board?(board)+ guardian.can_write_board?(board)enddef fetch_column(board:, params:)diff --git a/plugins/boards/app/services/boards/create_column.rb b/plugins/boards/app/services/boards/create_column.rbindex 346e18387a3..9c8ea484fb3 100644--- a/plugins/boards/app/services/boards/create_column.rb+++ b/plugins/boards/app/services/boards/create_column.rb@@ -38,7 +38,7 @@ module Boardsenddef can_manage(guardian:, board:)- guardian.can_manage_boards_board?(board)+ guardian.can_manage_board?(board)enddef create_column(board:, params:, guardian:)diff --git a/plugins/boards/app/services/boards/destroy_board.rb b/plugins/boards/app/services/boards/destroy_board.rbindex 8d7e6c06936..728d894770d 100644--- a/plugins/boards/app/services/boards/destroy_board.rb+++ b/plugins/boards/app/services/boards/destroy_board.rb@@ -27,7 +27,7 @@ module Boardsenddef can_destroy(guardian:, board:)- guardian.can_destroy_boards_board?(board)+ guardian.can_destroy_board?(board)enddef publish_update(board:, params:)diff --git a/plugins/boards/app/services/boards/destroy_card.rb b/plugins/boards/app/services/boards/destroy_card.rbindex 4bb47ac5cd4..12e3c76c40e 100644--- a/plugins/boards/app/services/boards/destroy_card.rb+++ b/plugins/boards/app/services/boards/destroy_card.rb@@ -26,7 +26,7 @@ module Boardsenddef can_write(board:, guardian:)- guardian.can_write_boards_board?(board)+ guardian.can_write_board?(board)enddef fetch_card(board:, params:)diff --git a/plugins/boards/app/services/boards/destroy_column.rb b/plugins/boards/app/services/boards/destroy_column.rbindex d55cd4a9779..cea045f633c 100644--- a/plugins/boards/app/services/boards/destroy_column.rb+++ b/plugins/boards/app/services/boards/destroy_column.rb@@ -31,7 +31,7 @@ module Boardsenddef can_manage(guardian:, board:)- guardian.can_manage_boards_board?(board)+ guardian.can_manage_board?(board)enddef fetch_column(board:, params:)diff --git a/plugins/boards/app/services/boards/move_column.rb b/plugins/boards/app/services/boards/move_column.rbindex 0382fad33dd..aee89ba4b91 100644--- a/plugins/boards/app/services/boards/move_column.rb+++ b/plugins/boards/app/services/boards/move_column.rb@@ -30,7 +30,7 @@ module Boardsenddef can_manage(guardian:, board:)- guardian.can_manage_boards_board?(board)+ guardian.can_manage_board?(board)enddef fetch_column(board:, params:)diff --git a/plugins/boards/app/services/boards/move_topic_to_column.rb b/plugins/boards/app/services/boards/move_topic_to_column.rbindex 684dee65bf8..96722ec004d 100644--- a/plugins/boards/app/services/boards/move_topic_to_column.rb+++ b/plugins/boards/app/services/boards/move_topic_to_column.rb@@ -39,7 +39,7 @@ module Boardsenddef can_write(board:, guardian:)- guardian.can_write_boards_board?(board)+ guardian.can_write_board?(board)enddef fetch_topic(params:)diff --git a/plugins/boards/app/services/boards/publisher.rb b/plugins/boards/app/services/boards/publisher.rbindex 33ab3c79287..d57698dd8b9 100644--- a/plugins/boards/app/services/boards/publisher.rb+++ b/plugins/boards/app/services/boards/publisher.rb@@ -35,6 +35,14 @@ module Boards)end+ def self.publish_board_archived!(board, client_id:)+ publish!(board, { type: "board_archived", client_id: client_id })+ end++ def self.publish_board_unarchived!(board, client_id:)+ publish!(board, { type: "board_unarchived", client_id: client_id })+ end+def self.publish_topic_memberships_changed!(topic, client_id:, refresh_stream: false)data = { reload_topic: true, client_id: }data[:refresh_stream] = true if refresh_stream@@ -53,6 +61,11 @@ module Boardsprivate_class_method :publish_card_event!def self.publish!(board, data)+ if data[:type] != "board_archived" &&+ (board.archived? || Boards::Board.where(id: board.id, archived: true).exists?)+ return+ end+group_ids = board.permission_acl.group_ids_with_any_permission(%w[view edit manage])opts = {}# Anonymous viewers belong to no group, so a board readable by anonymousdiff --git a/plugins/boards/app/services/boards/topic_sync.rb b/plugins/boards/app/services/boards/topic_sync.rbindex 9082e9d7ecf..1266aa09c44 100644--- a/plugins/boards/app/services/boards/topic_sync.rb+++ b/plugins/boards/app/services/boards/topic_sync.rb@@ -8,6 +8,8 @@ module Boardsreturn unless SiteSetting.boards_enabled?board = Board.includes(:columns).find(board.id) unless board.association(:columns).loaded?+ return if board.archived?+columns = board.columns.to_a# 1. Build topic-to-columns mapping via simple queries@@ -107,7 +109,7 @@ module BoardsAND acl.target_type = 'Boards::Board'AND acl.permission IN ('view', 'edit', 'manage')LEFT JOIN LATERAL UNNEST(acl.allowed_group_ids) AS acl_groups(acl_group_id) ON TRUE- WHERE c.topic_id = :topic_id+ WHERE c.topic_id = :topic_id AND NOT b.archivedGROUP BY c.id, c.board_idSQL@@ -120,7 +122,7 @@ module Boardsboard_groups[row.board_id] ||= row.allowed_group_ids || []end- Card.where(topic_id: topic_id).delete_all+ Card.where(id: rows.map(&:card_id)).delete_allpublish_sync_changes(board_groups:, deleted_by_board:, created_cards: [])end@@ -137,7 +139,7 @@ module BoardsSELECT b.id AS board_id, c.id AS column_id, c.tag_id AS column_tag_idFROM discourse_kanban_boards bJOIN discourse_kanban_columns c ON c.board_id = b.id- WHERE (b.category_ids != '{}' OR b.tag_ids != '{}')+ WHERE NOT b.archived AND (b.category_ids != '{}' OR b.tag_ids != '{}')AND (b.category_ids = '{}' OR :topic_category_id = ANY(b.category_ids))AND (b.tag_ids = '{}' OR b.tag_ids && :topic_tag_ids)AND (c.tag_id IS NULL OR c.tag_id = ANY(:topic_tag_ids))@@ -160,7 +162,7 @@ module BoardsAND acl.target_type = 'Boards::Board'AND acl.permission IN ('view', 'edit', 'manage')LEFT JOIN LATERAL UNNEST(acl.allowed_group_ids) AS acl_groups(acl_group_id) ON TRUE- WHERE b.id IN (+ WHERE NOT b.archived AND b.id IN (SELECT board_id FROM matchingUNION ALLSELECT board_id FROM discourse_kanban_cards WHERE topic_id = :topic_id@@ -174,7 +176,7 @@ module BoardsSELECT c.id AS card_id, c.board_id, c.column_idFROM discourse_kanban_cards cJOIN discourse_kanban_boards b ON b.id = c.board_id- WHERE c.topic_id = :topic_id+ WHERE c.topic_id = :topic_id AND NOT b.archivedAND (b.category_ids != '{}' OR b.tag_ids != '{}')FOR UPDATE OF c) ec@@ -354,6 +356,9 @@ module Boardsprivate_class_method :trim_excess_cardsdef self.publish_sync_changes(board_groups:, deleted_by_board:, created_cards:)+ archived_ids = Board.where(id: board_groups.keys, archived: true).pluck(:id)+ board_groups = board_groups.except(*archived_ids)+deleted_by_board.each do |board_id, card_ids|card_ids.each do |card_id|publish_to_board(board_groups, board_id, type: "card_deleted", card_id: card_id)diff --git a/plugins/boards/app/services/boards/unarchive.rb b/plugins/boards/app/services/boards/unarchive.rbnew file mode 100644index 00000000000..70a30a4d8a0--- /dev/null+++ b/plugins/boards/app/services/boards/unarchive.rb@@ -0,0 +1,61 @@+# frozen_string_literal: true++module Boards+ class Unarchive+ include Service::Base++ params do+ attribute :board_id, :integer+ attribute :slug, :string+ attribute :client_id, :string++ validates :board_id, presence: true+ end++ try ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique do+ transaction do+ model :board+ policy :can_unarchive+ step :unarchive_board+ step :record_history+ end+ end++ step :publish_board_unarchived_event++ private++ def fetch_board(params:)+ Board.lock.find_by(id: params.board_id)+ end++ def can_unarchive(guardian:, board:)+ guardian.can_unarchive_board?(board)+ end++ def unarchive_board(board:, params:)+ board.update!(+ slug: params.slug.presence || board.original_slug,+ archived: false,+ archived_at: nil,+ archived_by_id: nil,+ original_slug: nil,+ )+ end++ def record_history(board:, guardian:)+ board.history.create!(+ acting_user: guardian.user,+ action: :board_unarchived,+ details: {+ previous_value: board.slug_before_last_save,+ new_value: board.slug,+ },+ )+ end++ def publish_board_unarchived_event(board:, guardian:, params:)+ Boards::Publisher.publish_board_unarchived!(board, client_id: params.client_id)+ end+ end+enddiff --git a/plugins/boards/app/services/boards/update_board.rb b/plugins/boards/app/services/boards/update_board.rbindex e082967897a..387d853281a 100644--- a/plugins/boards/app/services/boards/update_board.rb+++ b/plugins/boards/app/services/boards/update_board.rb@@ -30,7 +30,7 @@ module Boardsenddef can_manage(guardian:, board:)- guardian.can_manage_boards_board?(board)+ guardian.can_manage_board?(board)enddef update_acl(board:, guardian:)diff --git a/plugins/boards/app/services/boards/update_card.rb b/plugins/boards/app/services/boards/update_card.rbindex bbff3e5bfa3..85e9da22a4b 100644--- a/plugins/boards/app/services/boards/update_card.rb+++ b/plugins/boards/app/services/boards/update_card.rb@@ -44,7 +44,7 @@ module Boardsenddef can_write(board:, guardian:)- guardian.can_write_boards_board?(board)+ guardian.can_write_board?(board)enddef fetch_card(board:, params:)diff --git a/plugins/boards/app/services/boards/update_column.rb b/plugins/boards/app/services/boards/update_column.rbindex 1c1cf94a06f..1b538ccdce2 100644--- a/plugins/boards/app/services/boards/update_column.rb+++ b/plugins/boards/app/services/boards/update_column.rb@@ -41,7 +41,7 @@ module Boardsenddef can_manage(guardian:, board:)- guardian.can_manage_boards_board?(board)+ guardian.can_manage_board?(board)enddef fetch_column(board:, params:)diff --git a/plugins/boards/app/services/boards/view_board.rb b/plugins/boards/app/services/boards/view_board.rbindex 63d6299b3b8..a729b253a31 100644--- a/plugins/boards/app/services/boards/view_board.rb+++ b/plugins/boards/app/services/boards/view_board.rb@@ -22,7 +22,7 @@ module Boardsenddef can_read_board(guardian:, board:)- guardian.can_read_boards_board?(board)+ guardian.can_read_board?(board)enddef create_view_history(guardian:, board:)diff --git a/plugins/boards/app/services/boards/view_card.rb b/plugins/boards/app/services/boards/view_card.rbindex 6b23d77967a..42e262a52f2 100644--- a/plugins/boards/app/services/boards/view_card.rb+++ b/plugins/boards/app/services/boards/view_card.rb@@ -22,7 +22,7 @@ module Boardsenddef can_view_card(guardian:, card:)- guardian.can_view_boards_card?(card)+ guardian.can_view_card?(card)enddef create_view_history(guardian:, card:)diff --git a/plugins/boards/assets/javascripts/discourse/components/boards-board-viewer.gjs b/plugins/boards/assets/javascripts/discourse/components/boards-board-viewer.gjsindex 7c4dc3d170a..b7aa4e55ab2 100644--- a/plugins/boards/assets/javascripts/discourse/components/boards-board-viewer.gjs+++ b/plugins/boards/assets/javascripts/discourse/components/boards-board-viewer.gjs@@ -22,6 +22,7 @@ import discourseLater from "discourse/lib/later";import DiscourseURL from "discourse/lib/url";import { prefersReducedMotion } from "discourse/lib/utilities";import Category from "discourse/models/category";+import { or } from "discourse/truth-helpers";import DButton from "discourse/ui-kit/d-button";import DDropdownMenu from "discourse/ui-kit/d-dropdown-menu";import dBoundCategoryLink from "discourse/ui-kit/helpers/d-bound-category-link";@@ -41,6 +42,7 @@ import Board from "../models/board";import Card from "../models/card";import Column from "../models/column";import BoardsColumn from "./boards-column";+import BoardsArchive from "./modal/boards-archive";import BoardsBoardSettings from "./modal/boards-board-settings";import BoardsCardDetailModal from "./modal/boards-card-detail";import BoardsColumnSettings from "./modal/boards-column-settings";@@ -186,7 +188,7 @@ export default class BoardsBoardViewer extends Component {});}- if (this.args.openBoardSettings && this.canManage) {+ if (this.args.openBoardSettings && this.board.canManage) {schedule("afterRender", () => {if (this.isDestroying) {return;@@ -203,14 +205,6 @@ export default class BoardsBoardViewer extends Component {this.#stopHorizontalAutoScroll();}- get canWrite() {- return this.board.can_write;- }-- get canManage() {- return this.board.can_manage;- }-get boardCategories() {return (this.board.category_ids || []).map((id) => Category.findById(id))@@ -250,6 +244,10 @@ export default class BoardsBoardViewer extends Component {}switch (data.type) {+ case "board_archived":+ case "board_unarchived":+ reload();+ break;case "card_created":this.#handleCardCreated(data.card);break;@@ -329,7 +327,7 @@ export default class BoardsBoardViewer extends Component {@actionasync onDrop(cardId, toColumnId, afterCardId, fromColumnId) {- if (!fromColumnId) {+ if (!this.board.canWrite || !fromColumnId) {return;}@@ -798,6 +796,29 @@ export default class BoardsBoardViewer extends Component {// Board settings actions+ @action+ openArchiveModal(closeMenu) {+ closeMenu();+ this.modal.show(BoardsArchive, {+ model: {+ board: this.board,+ onSuccess: async (board) => {+ this.toasts.success({+ data: {+ message: board.archived+ ? i18n("boards.board.archived_successfully")+ : i18n("boards.board.unarchived_successfully"),+ },+ duration: "short",+ });+ Object.assign(this.board, board);+ await this.#handleBoardUpdated();+ DiscourseURL.replaceState(boardsBoardUrl(this.board));+ },+ },+ });+ }+@actionopenBoardSettings(closeMenu) {closeMenu();@@ -1246,7 +1267,7 @@ export default class BoardsBoardViewer extends Component {DiscourseURL.routeTo(url);},}- : { card, canWrite: this.canWrite, onUpdateCard: this.onUpdateCard };+ : { card, board: this.board, onUpdateCard: this.onUpdateCard };this.modal.show(ModalComponent, { model }).finally(() => {if (!navigatedAway && !this.isDestroying) {@@ -1388,9 +1409,19 @@ export default class BoardsBoardViewer extends Component {<div class="discourse-boards-board-viewer__header"><div class="discourse-boards-board-viewer__title-wrapper"><BackButton @label="boards.board.all_boards" @route="boards" />- <h2- class="discourse-boards-board-viewer__title"- >{{this.board.fancyTitle}}</h2>+ <h2 class="discourse-boards-board-viewer__title">+ {{#if this.board.archived}}+ <DTooltip>+ <:trigger>+ {{dIcon "box-archive"}}+ </:trigger>+ <:content>+ <span>{{i18n "boards.board.archived_tooltip"}}</span>+ </:content>+ </DTooltip>+ {{/if}}+ {{this.board.fancyTitle}}+ </h2><div class="discourse-boards-board-viewer__metadata">{{#if this.hasBoardFilters}}@@ -1417,43 +1448,67 @@ export default class BoardsBoardViewer extends Component {</div><div class="discourse-boards-board-viewer__controls">- <DMenu- @icon="ellipsis"- @identifier="boards-board-controls"- @title="boards.board.controls"- @triggerClass="btn-flat"- >- <:content as |args|>- <DDropdownMenu as |dropdown|>- {{#if this.canManage}}- <dropdown.item data-identifier="add-column">- <DButton- class="btn-transparent"- @action={{fn this.openAddColumnModal args.close}}- @icon="plus"- @label="boards.board.add_column"- />- </dropdown.item>- <dropdown.item data-identifier="board-settings">- <DButton- class="btn-transparent"- @action={{fn this.openBoardSettings args.close}}- @icon="gear"- @label="boards.board.board_settings"- />- </dropdown.item>- <dropdown.item data-identifier="delete-board">- <DButton- class="btn-transparent btn-danger"- @action={{fn this.deleteBoard args.close}}- @icon="trash-can"- @label="boards.board.delete_board"- />- </dropdown.item>- {{/if}}- </DDropdownMenu>- </:content>- </DMenu>+ {{#if+ (or+ this.board.canManage+ this.board.can_archive+ this.board.can_unarchive+ )+ }}+ <DMenu+ @icon="ellipsis"+ @identifier="boards-board-controls"+ @title="boards.board.controls"+ @triggerClass="btn-flat"+ >+ <:content as |args|>+ <DDropdownMenu as |dropdown|>+ {{#if this.board.canManage}}+ <dropdown.item data-identifier="add-column">+ <DButton+ class="btn-transparent"+ @action={{fn this.openAddColumnModal args.close}}+ @icon="plus"+ @label="boards.board.add_column"+ />+ </dropdown.item>+ <dropdown.item data-identifier="board-settings">+ <DButton+ class="btn-transparent"+ @action={{fn this.openBoardSettings args.close}}+ @icon="gear"+ @label="boards.board.board_settings"+ />+ </dropdown.item>+ {{/if}}+ {{#if (or this.board.can_archive this.board.can_unarchive)}}+ <dropdown.item data-identifier="archive-board">+ <DButton+ class="btn-transparent"+ @action={{fn this.openArchiveModal args.close}}+ @icon="box-archive"+ @label={{if+ this.board.archived+ "boards.board.unarchive_board_menu"+ "boards.board.archive_board"+ }}+ />+ </dropdown.item>+ {{/if}}+ {{#if this.board.canManage}}+ <dropdown.item data-identifier="delete-board">+ <DButton+ class="btn-transparent btn-danger"+ @action={{fn this.deleteBoard args.close}}+ @icon="trash-can"+ @label="boards.board.delete_board"+ />+ </dropdown.item>+ {{/if}}+ </DDropdownMenu>+ </:content>+ </DMenu>+ {{/if}}{{#if this.fullscreen}}<DButtonclass="btn-flat discourse-boards-board-viewer__exit-fullscreen"@@ -1485,8 +1540,6 @@ export default class BoardsBoardViewer extends Component {@allColumns={{this.columns}}@allSameCategory={{this.allSameCategory}}@board={{this.board}}- @canManage={{this.canManage}}- @canWrite={{this.canWrite}}@column={{column}}@dragData={{this.dragData}}@dropHighlightCardId={{this.dropHighlightCardId}}@@ -1506,7 +1559,7 @@ export default class BoardsBoardViewer extends Component {@onUpdateCard={{this.onUpdateCard}}/>{{/each}}- {{#if this.canManage}}+ {{#if this.board.canManage}}<buttonclass="discourse-boards-board-container__add-column"title={{i18n "boards.board.add_column"}}@@ -1523,8 +1576,8 @@ export default class BoardsBoardViewer extends Component {<div class="discourse-boards-board-viewer__empty-column">{{dIcon "table-columns"}}<h3>{{i18n "boards.board.empty_board"}}</h3>- <p>{{i18n "boards.board.empty_board_cta"}}</p>- {{#if this.canManage}}+ {{#if this.board.canManage}}+ <p>{{i18n "boards.board.empty_board_cta"}}</p><DButtonclass="btn-primary"@action={{this.openAddColumnModal}}diff --git a/plugins/boards/assets/javascripts/discourse/components/boards-card.gjs b/plugins/boards/assets/javascripts/discourse/components/boards-card.gjsindex 6132d2c8ba9..cf66419cd4f 100644--- a/plugins/boards/assets/javascripts/discourse/components/boards-card.gjs+++ b/plugins/boards/assets/javascripts/discourse/components/boards-card.gjs@@ -199,7 +199,7 @@ export default class BoardsCard extends Component {}get canShowActions() {- return this.args.canWrite;+ return this.args.board.canWrite;}get showAssignButton() {@@ -212,9 +212,10 @@ export default class BoardsCard extends Component {get canAssign() {return (+ !this.args.board.archived &&this.siteSettings.assign_enabled &&this.currentUser?.can_assign &&- (this.isTopicCard || this.args.canWrite)+ (this.isTopicCard || this.args.board.canWrite));}@@ -264,7 +265,7 @@ export default class BoardsCard extends Component {.show(BoardsCardDetailModal, {model: {card: this.args.card,- canWrite: this.args.canWrite,+ board: this.args.board,onUpdateCard: this.args.onUpdateCard,},})@@ -388,7 +389,7 @@ export default class BoardsCard extends Component {@actiondragStart(event) {- if (!this.args.canWrite) {+ if (!this.args.board.canWrite) {event.preventDefault();return;}@@ -522,7 +523,7 @@ export default class BoardsCard extends Component {}}data-card-id={{@card.id}}data-topic-id={{@card.topic_id}}- draggable={{if @canWrite "true" "false"}}+ draggable={{@board.canWrite}}role="button"tabindex="0"{{on "dragstart" this.dragStart}}diff --git a/plugins/boards/assets/javascripts/discourse/components/boards-column.gjs b/plugins/boards/assets/javascripts/discourse/components/boards-column.gjsindex 3c11e18bebf..22b12c15bfa 100644--- a/plugins/boards/assets/javascripts/discourse/components/boards-column.gjs+++ b/plugins/boards/assets/javascripts/discourse/components/boards-column.gjs@@ -121,7 +121,7 @@ export default class BoardsColumn extends Component {model: {card: {},isNew: true,- canWrite: true,+ board: this.args.board,onCreateCard: (data) =>this.args.onAddCard({ ...data, columnId: this.args.column.id }),},@@ -492,7 +492,7 @@ export default class BoardsColumn extends Component {{{this.cardCount}}</span></span>- {{#if @canManage}}+ {{#if @board.canManage}}<DMenu@icon="ellipsis"@identifier="boards-column-controls"@@ -556,7 +556,6 @@ export default class BoardsColumn extends Component {<BoardsCard@allSameCategory={{@allSameCategory}}@board={{@board}}- @canWrite={{@canWrite}}@card={{card}}@columnColor={{@column.color}}@columnIcon={{@column.icon}}@@ -589,7 +588,7 @@ export default class BoardsColumn extends Component {{{/if}}</div>- {{#if @canWrite}}+ {{#if @board.canWrite}}<div class="discourse-boards-column__footer"><DMenu@icon="plus"diff --git a/plugins/boards/assets/javascripts/discourse/components/boards-page.gjs b/plugins/boards/assets/javascripts/discourse/components/boards-page.gjsindex 43931a618c5..cd763c91c58 100644--- a/plugins/boards/assets/javascripts/discourse/components/boards-page.gjs+++ b/plugins/boards/assets/javascripts/discourse/components/boards-page.gjs@@ -1,5 +1,5 @@import Component from "@glimmer/component";-import { array } from "@ember/helper";+import { array, hash } from "@ember/helper";import { action } from "@ember/object";import { LinkTo } from "@ember/routing";import { service } from "@ember/service";@@ -28,6 +28,24 @@ export default class BoardsPage extends Component {@service router;@service toasts;+ get statusOptions() {+ return {+ status: [+ { value: "all", label: i18n("boards.status.all") },+ {+ value: "open",+ label: i18n("boards.status.open"),+ filterFn: (board) => !board.archived,+ },+ {+ value: "archived",+ label: i18n("boards.status.archived"),+ filterFn: (board) => board.archived,+ },+ ],+ };+ }+@actionopenNewBoardModal() {this.modal.show(BoardsBoardSettings, {@@ -84,12 +102,17 @@ export default class BoardsPage extends Component {</DPageHeader><DFilterControls+ @additionalFiltersActive={{true}}@array={{@boards}}+ @defaultDropdownValue={{hash status="open"}}+ @dropdownFilterQueryParams={{hash status="status"}}+ @dropdownOptions={{this.statusOptions}}@inputPlaceholder={{i18n "boards.filter_boards"}}@minItemsForFilter={{1}}@noResultsMessage={{i18n "boards.filter_boards_no_results"}}@searchableProps={{array "name"}}@showCustomEmptyState={{true}}+ @showResetButton={{false}}@textFilterQueryParam="filter"><:content as |filteredBoards|>diff --git a/plugins/boards/assets/javascripts/discourse/components/modal/boards-archive.gjs b/plugins/boards/assets/javascripts/discourse/components/modal/boards-archive.gjsnew file mode 100644index 00000000000..10e17e64560--- /dev/null+++ b/plugins/boards/assets/javascripts/discourse/components/modal/boards-archive.gjs@@ -0,0 +1,104 @@+import Component from "@glimmer/component";+import { action } from "@ember/object";+import { service } from "@ember/service";+import { trustHTML } from "@ember/template";+import Form from "discourse/components/form";+import { ajax } from "discourse/lib/ajax";+import { popupAjaxError } from "discourse/lib/ajax-error";+import getURL from "discourse/lib/get-url";+import DModal from "discourse/ui-kit/d-modal";+import { i18n } from "discourse-i18n";++export default class BoardsArchive extends Component {+ @service messageBus;++ formData = { slug: "" };+ currentlyArchived = this.args.model.board.archived;++ get isUnarchive() {+ return this.currentlyArchived;+ }++ get title() {+ return i18n(+ this.isUnarchive+ ? "boards.board.unarchive_board"+ : "boards.board.archive_board"+ );+ }++ get message() {+ if (this.isUnarchive) {+ return i18n(+ this.args.model.board.old_slug_used+ ? "boards.board.unarchive_slug_required"+ : "boards.board.confirm_unarchive"+ );+ }+ return trustHTML(+ i18n("boards.board.confirm_archive", { boards_url: getURL("/boards") })+ );+ }++ @action+ async submit(data) {+ const board = this.args.model.board;+ const actionName = this.isUnarchive ? "unarchive" : "archive";+ try {+ const result = await ajax(+ `/boards/api/boards/${board.id}/${actionName}`,+ {+ type: "POST",+ data: {+ client_id: this.messageBus.clientId,+ ...(this.isUnarchive ? { slug: data.slug } : {}),+ },+ }+ );+ await this.args.model.onSuccess(result.board);+ this.args.closeModal();+ } catch (error) {+ if (this.isUnarchive) {+ const result = await ajax(`/boards/api/boards/${board.id}.json`).catch(+ () => null+ );+ if (result?.board) {+ Object.assign(board, result.board);+ }+ }+ popupAjaxError(error);+ }+ }++ <template>+ <DModal+ class="discourse-boards-archive-modal"+ @closeModal={{@closeModal}}+ @inline={{@inline}}+ @title={{this.title}}+ >+ <:body>+ <Form @data={{this.formData}} @onSubmit={{this.submit}} as |form|>+ <p>{{this.message}}</p>+ {{#if this.isUnarchive}}+ {{#if @model.board.old_slug_used}}+ <form.Field+ @name="slug"+ @required={{true}}+ @title={{i18n "boards.manage.slug"}}+ @type="input"+ as |field|+ >+ <field.Control />+ </form.Field>+ {{/if}}+ {{/if}}+ <form.Actions>+ <form.Submit @label="confirm_button" />+ <form.Button @action={{@closeModal}} @label="cancel" />+ </form.Actions>+ </Form>+ </:body>+ </DModal>+ </template>+}diff --git a/plugins/boards/assets/javascripts/discourse/components/modal/boards-card-detail.gjs b/plugins/boards/assets/javascripts/discourse/components/modal/boards-card-detail.gjsindex e0698489b4a..91debc6eab5 100644--- a/plugins/boards/assets/javascripts/discourse/components/modal/boards-card-detail.gjs+++ b/plugins/boards/assets/javascripts/discourse/components/modal/boards-card-detail.gjs@@ -17,10 +17,6 @@ export default class BoardsCardDetail extends Component {@service siteSettings;@service currentUser;- get canWrite() {- return this.args.model.canWrite;- }-get formData() {const card = this.args.model.card;const assignedTo = card.assigned_to;@@ -97,13 +93,14 @@ export default class BoardsCardDetail extends Component {class="discourse-boards-card-detail-modal"@closeModal={{@closeModal}}@hideHeader={{true}}+ @inline={{@inline}}@submitOnEnter={{false}}{{didInsert this.viewCard}}><:body><Form @data={{this.formData}} @onSubmit={{this.save}} as |form data|><BoardsEditableTitle- @disabled={{not this.canWrite}}+ @disabled={{not @model.board.canWrite}}@form={{form}}@name="title"@placeholder={{i18n "boards.board.title_placeholder"}}@@ -112,7 +109,7 @@ export default class BoardsCardDetail extends Component {/><form.Section><form.Field- @disabled={{not this.canWrite}}+ @disabled={{not @model.board.canWrite}}@format="max"@name="notes"@title={{i18n "boards.board.notes"}}@@ -125,7 +122,7 @@ export default class BoardsCardDetail extends Component {/></form.Field><form.Field- @disabled={{not this.canWrite}}+ @disabled={{not @model.board.canWrite}}@format="max"@name="tags"@title={{i18n "boards.board.tags"}}@@ -140,7 +137,7 @@ export default class BoardsCardDetail extends Component {{{#if this.siteSettings.assign_enabled}}<form.Field- @disabled={{not this.canWrite}}+ @disabled={{not @model.board.canWrite}}@format="max"@name="assigned_to"@title={{i18n "boards.board.assigned_to"}}@@ -149,9 +146,12 @@ export default class BoardsCardDetail extends Component {><field.Control><EmailGroupUserChooser- @disabled={{not this.canWrite}}@onChange={{fn this.onAssignedChanged field}}- @options={{hash maximum=1 excludeCurrentUser=false}}+ @options={{hash+ disabled=(not @model.board.canWrite)+ maximum=1+ excludeCurrentUser=false+ }}@value={{data.assigned_to}}/></field.Control>@@ -160,7 +160,7 @@ export default class BoardsCardDetail extends Component {</form.Section><form.Actions>- {{#if this.canWrite}}+ {{#if @model.board.canWrite}}<form.Submit />{{/if}}<form.Buttondiff --git a/plugins/boards/assets/javascripts/discourse/models/board.js b/plugins/boards/assets/javascripts/discourse/models/board.jsindex abb01c37918..2260f9027cd 100644--- a/plugins/boards/assets/javascripts/discourse/models/board.js+++ b/plugins/boards/assets/javascripts/discourse/models/board.js@@ -18,13 +18,17 @@ export default class Board {}@tracked anonymous_can_read;+ @tracked archived;+ @tracked can_archive;@tracked can_manage;+ @tracked can_unarchive;@tracked can_write;@tracked card_style;@tracked category_ids;@tracked columns;@tracked id;@tracked name;+ @tracked old_slug_used;@tracked require_confirmation;@tracked show_tags;@tracked show_topic_thumbnail;@@ -38,6 +42,14 @@ export default class Board {this.columns = (args.columns || []).map((column) => Column.create(column));}+ get canManage() {+ return !this.archived && this.can_manage;+ }++ get canWrite() {+ return !this.archived && this.can_write;+ }+get fancyTitle() {return this.unicode_name || this.name;}diff --git a/plugins/boards/assets/javascripts/discourse/routes/boards-board-configure.js b/plugins/boards/assets/javascripts/discourse/routes/boards-board-configure.jsindex 15bcbd367dc..9b41db1fa08 100644--- a/plugins/boards/assets/javascripts/discourse/routes/boards-board-configure.js+++ b/plugins/boards/assets/javascripts/discourse/routes/boards-board-configure.js@@ -19,7 +19,7 @@ export default class BoardsBoardConfigureRoute extends DiscourseRoute {afterModel(model, transition) {const board = model.board;- if (board && !board.can_manage) {+ if (board && !board.canManage) {this.router.replaceWith("boardsBoard", board.slug, board.id);return;}diff --git a/plugins/boards/assets/stylesheets/boards-board.scss b/plugins/boards/assets/stylesheets/boards-board.scssindex 13cba3331a4..318ecee5a7a 100644--- a/plugins/boards/assets/stylesheets/boards-board.scss+++ b/plugins/boards/assets/stylesheets/boards-board.scss@@ -503,7 +503,7 @@ body.discourse-boards-fullscreen .fk-d-menu[data-identifier^="boards-"] {}&[draggable="false"] {- cursor: default;+ cursor: not-allowed;}&--dragging {diff --git a/plugins/boards/config/locales/client.en.yml b/plugins/boards/config/locales/client.en.ymlindex 6f304f3d7b0..0b021b9c065 100644--- a/plugins/boards/config/locales/client.en.yml+++ b/plugins/boards/config/locales/client.en.yml@@ -3,6 +3,10 @@ en:boards:filter_boards: "Filter boards"filter_boards_no_results: "No boards match your search"+ status:+ all: "All"+ open: "Open"+ archived: "Archived"topic_footer:add_to_board: "Add to board"already_added: "Already added"@@ -48,6 +52,15 @@ en:column_settings_title: "Column settings"new_column_title: "New column"new_board: "New board"+ archive_board: "Archive board"+ unarchive_board: "Unarchive board"+ unarchive_board_menu: "Unarchive board..."+ confirm_archive: 'Are you sure you want to archive this board? You can see archived boards on <a href="%{boards_url}">the boards list</a> by choosing "Archived" from the filter dropdown.'+ confirm_unarchive: "Are you sure you want to unarchive this board?"+ archived_successfully: "Board archived successfully"+ unarchived_successfully: "Board unarchived successfully"+ unarchive_slug_required: "The original board slug is now in use. Choose a new slug to unarchive this board."+ archived_tooltip: "This board is archived. Cards and columns can no longer be changed."delete_board: "Delete board"remove_card: "Remove"new_topic: "New topic..."diff --git a/plugins/boards/config/locales/server.en.yml b/plugins/boards/config/locales/server.en.ymlindex b2c31d4472f..7f1a1ee89d3 100644--- a/plugins/boards/config/locales/server.en.yml+++ b/plugins/boards/config/locales/server.en.yml@@ -12,6 +12,7 @@ en:acl_update_failed: "Failed to update board permissions."acl_create_failed: "Failed to create board permissions."errors:+ slug_unavailable: "That board slug is already in use. Please choose another slug."board_not_found: "Board not found"board_read_forbidden: "You do not have permission to view this board"board_write_forbidden: "You do not have permission to modify this board"@@ -36,6 +37,7 @@ en:cannot_reorder_recency_column: "Cards in recency-sorted columns cannot be reordered."invalid_column_sort: "Invalid column sort: %{sort}"onebox:+ archived: "Archived board"inline_to_card: "Card '%{card_name}' on board '%{board_name}'"inline_to_board: "Board '%{board_name}'"created_by: "Created by %{username}"diff --git a/plugins/boards/config/routes.rb b/plugins/boards/config/routes.rbindex 6106985781b..57eb3074c11 100644--- a/plugins/boards/config/routes.rb+++ b/plugins/boards/config/routes.rb@@ -7,6 +7,8 @@ Boards::Engine.routes.draw doget "/boards/:id" => "boards#show"post "/boards" => "boards#create"put "/boards/:id" => "boards#update"+ post "/boards/:id/archive" => "boards#archive"+ post "/boards/:id/unarchive" => "boards#unarchive"delete "/boards/:id" => "boards#destroy"post "/boards/:id/move-column" => "boards#move_column"post "/boards/:id/constraint-preview" => "boards#constraint_preview"diff --git a/plugins/boards/db/migrate/20260910033302_add_archive_to_boards.rb b/plugins/boards/db/migrate/20260910033302_add_archive_to_boards.rbnew file mode 100644index 00000000000..72c19235642--- /dev/null+++ b/plugins/boards/db/migrate/20260910033302_add_archive_to_boards.rb@@ -0,0 +1,10 @@+# frozen_string_literal: true++class AddArchiveToBoards < ActiveRecord::Migration[8.0]+ def change+ add_column :discourse_kanban_boards, :archived, :boolean, default: false, null: false+ add_column :discourse_kanban_boards, :archived_at, :datetime+ add_column :discourse_kanban_boards, :archived_by_id, :bigint+ add_column :discourse_kanban_boards, :original_slug, :string+ end+enddiff --git a/plugins/boards/lib/boards/guardian_extensions.rb b/plugins/boards/lib/boards/guardian_extensions.rbindex 42d570fa59c..79bd338feac 100644--- a/plugins/boards/lib/boards/guardian_extensions.rb+++ b/plugins/boards/lib/boards/guardian_extensions.rb@@ -6,31 +6,38 @@ module Boardsin_any_groups?(SiteSetting.boards_manage_board_allowed_groups_map)end- def can_create_boards_board?+ def can_create_board?can_manage_boards?end- def can_destroy_boards_board?(board)- can_manage_boards? && has_acl_permission?(board, "manage")+ def can_destroy_board?(board)+ !board.archived? && can_manage_boards? && has_acl_permission?(board, "manage")end- def can_manage_boards_board?(board)- can_manage_boards? && has_acl_permission?(board, "manage")+ def can_manage_board?(board)+ !board.archived? && can_manage_boards? && has_acl_permission?(board, "manage")end- def can_read_boards_board?(board)+ def can_read_board?(board)return true if board.anonymous_can_read?- return true if can_write_boards_board?(board)- has_acl_permission?(board, "view")+ has_any_acl_permission?(board, %w[view edit manage])end- def can_write_boards_board?(board)- has_any_acl_permission?(board, %w[edit manage])+ def can_write_board?(board)+ !board.archived? && has_any_acl_permission?(board, %w[edit manage])end- def can_view_boards_card?(card)- can_read_boards_board?(card.board)+ def can_archive_board?(board)+ authenticated? && !board.archived? && has_acl_permission?(board, "manage")+ end++ def can_unarchive_board?(board)+ authenticated? && board.archived? && has_acl_permission?(board, "manage")+ end++ def can_view_card?(card)+ can_read_board?(card.board)endendenddiff --git a/plugins/boards/lib/boards/onebox_handler.rb b/plugins/boards/lib/boards/onebox_handler.rbindex 8b0865bbcdb..0a71eac5b7f 100644--- a/plugins/boards/lib/boards/onebox_handler.rb+++ b/plugins/boards/lib/boards/onebox_handler.rb@@ -40,6 +40,8 @@ module Boardsargs = {board_url: card.board.url,board_name: card.board.unicode_name,+ board_archived: card.board.archived?,+ archived_label: I18n.t("boards.onebox.archived"),card_url: url,card_name: card.unicode_resolved_title,card_tags: tag_html,@@ -88,6 +90,8 @@ module Boardsargs = {board_url: url,board_name: board.unicode_name,+ board_archived: board.archived?,+ archived_label: I18n.t("boards.onebox.archived"),board_tags: tag_html,board_categories: category_html,board_columns:diff --git a/plugins/boards/lib/onebox/templates/boards_board.mustache b/plugins/boards/lib/onebox/templates/boards_board.mustacheindex cdca628f78b..e1b051b819e 100644--- a/plugins/boards/lib/onebox/templates/boards_board.mustache+++ b/plugins/boards/lib/onebox/templates/boards_board.mustache@@ -6,7 +6,18 @@xmlns="http://www.w3.org/2000/svg"><use href="#table-columns"></use>- </svg> {{board_name}}+ </svg> {{#board_archived}}+ <svg+ class="fa d-icon d-icon-box-archive svg-icon svg-string"+ xmlns="http://www.w3.org/2000/svg"+ role="img"+ aria-label="{{archived_label}}"+ >+ <title>{{archived_label}}</title>+ <use href="#box-archive"></use>+ </svg>+ {{/board_archived}}+ {{board_name}}</a></div>diff --git a/plugins/boards/lib/onebox/templates/boards_card.mustache b/plugins/boards/lib/onebox/templates/boards_card.mustacheindex dcce318b585..a7c2e14cd47 100644--- a/plugins/boards/lib/onebox/templates/boards_card.mustache+++ b/plugins/boards/lib/onebox/templates/boards_card.mustache@@ -19,7 +19,18 @@xmlns="http://www.w3.org/2000/svg"><use href="#table-columns"></use>- </svg>{{board_name}}</a>+ </svg>{{#board_archived}}+ <svg+ class="fa d-icon d-icon-box-archive svg-icon svg-string"+ xmlns="http://www.w3.org/2000/svg"+ role="img"+ aria-label="{{archived_label}}"+ >+ <title>{{archived_label}}</title>+ <use href="#box-archive"></use>+ </svg>+ {{/board_archived}}+ {{board_name}}</a><span class="discourse-boards-column-pill">{{#card_column_icon}}<svgdiff --git a/plugins/boards/plugin.rb b/plugins/boards/plugin.rbindex 5c510206b02..d6232b97081 100644--- a/plugins/boards/plugin.rb+++ b/plugins/boards/plugin.rb@@ -17,6 +17,7 @@ register_asset "stylesheets/boards-topic-pill.scss"register_asset "stylesheets/boards-add-from-topic-menu.scss"register_svg_icon "table-columns"register_svg_icon "boards"+register_svg_icon "box-archive"module ::BoardsPLUGIN_NAME = "boards"@@ -52,7 +53,7 @@ after_initialize doadd_to_serializer(:current_user, :can_manage_boards) { scope.can_manage_boards? }add_to_serializer(:current_user, :can_edit_any_boards) do- scope.target_ids_with_any_acl_permissions(Boards::Board, %w[edit manage]).any?+ Boards::Board.open.with_any_acl_permissions(scope, %w[edit manage]).exists?endadd_to_class(:topic, :board_cards_map) { @board_cards_map }diff --git a/plugins/boards/spec/jobs/regular/boards/card_post_process_spec.rb b/plugins/boards/spec/jobs/regular/boards/card_post_process_spec.rbindex c64e9f959f6..467bb5b4916 100644--- a/plugins/boards/spec/jobs/regular/boards/card_post_process_spec.rb+++ b/plugins/boards/spec/jobs/regular/boards/card_post_process_spec.rb@@ -31,6 +31,19 @@ RSpec.describe Jobs::Boards::CardPostProcess doenddescribe "#execute" do+ context "when the board is archived" do+ subject(:result) { described_class.new.execute(card_id: card.id, title: card.title) }++ let(:messages) { MessageBus.track_publish("/boards/#{board.id}") { result } }++ it "leaves archived cards untouched without publishing updates" do+ board.update!(archived: true)++ expect(messages).to be_empty+ expect(card.reload.inline_onebox_data).to be_nil+ end+ end+let(:onebox_data) do{"url" => card.title,diff --git a/plugins/boards/spec/lib/boards/onebox_handler_spec.rb b/plugins/boards/spec/lib/boards/onebox_handler_spec.rbindex 8d1b9ff222d..345c620d797 100644--- a/plugins/boards/spec/lib/boards/onebox_handler_spec.rb+++ b/plugins/boards/spec/lib/boards/onebox_handler_spec.rb@@ -50,6 +50,18 @@ RSpec.describe Boards::OneboxHandler doenddescribe "card onebox" do+ it "marks archived boards beside the board name" do+ expect(+ Boards::OneboxHandler.handle(floater_card.url, { id: board.id, card_id: floater_card.id }),+ ).not_to have_tag(".discourse-boards-board-pill .d-icon-box-archive")++ board.update!(archived: true)++ expect(+ Boards::OneboxHandler.handle(floater_card.url, { id: board.id, card_id: floater_card.id }),+ ).to have_tag(".discourse-boards-board-pill .d-icon-box-archive")+ end+it "returns empty string if the card does not exist" dofloater_card.destroy!expect(@@ -210,6 +222,18 @@ RSpec.describe Boards::OneboxHandler doenddescribe "board onebox" do+ it "marks archived boards beside the board name" do+ expect(Boards::OneboxHandler.handle(board.url, { id: board.id })).not_to have_tag(+ ".discourse-boards-board-card__name .d-icon-box-archive",+ )++ board.update!(archived: true)++ expect(Boards::OneboxHandler.handle(board.url, { id: board.id })).to have_tag(+ ".discourse-boards-board-card__name .d-icon-box-archive",+ )+ end+it "returns empty string if the board does not exist" doboard.destroy!expect(Boards::OneboxHandler.handle(board.url, { id: board.id })).to eq("")diff --git a/plugins/boards/spec/lib/guardian_extensions_spec.rb b/plugins/boards/spec/lib/guardian_extensions_spec.rbindex d033e92a810..643bf7b2391 100644--- a/plugins/boards/spec/lib/guardian_extensions_spec.rb+++ b/plugins/boards/spec/lib/guardian_extensions_spec.rb@@ -18,13 +18,13 @@ RSpec.describe Boards::GuardianExtensions dowrite_group.add(writer)end- describe "#can_read_boards_board?" do+ describe "#can_read_board?" doit "denies read to non-editors when no read or write groups are set" doboard = Boards::Board.create!(name: "Roadmap", slug: "roadmap")- expect(reader.guardian.can_read_boards_board?(board)).to be_falsey- expect(outsider.guardian.can_read_boards_board?(board)).to be_falsey- expect(anonymous_guardian.can_read_boards_board?(board)).to be_falsey+ expect(reader.guardian.can_read_board?(board)).to be_falsey+ expect(outsider.guardian.can_read_board?(board)).to be_falsey+ expect(anonymous_guardian.can_read_board?(board)).to be_falseyendit "does not allow anonymous users to read when read_group_ids are set" do@@ -35,7 +35,7 @@ RSpec.describe Boards::GuardianExtensions dopermission: "view",groups: [read_group],)- expect(anonymous_guardian.can_read_boards_board?(board)).to be_falsey+ expect(anonymous_guardian.can_read_board?(board)).to be_falseyendit "grants read through read groups" do@@ -47,8 +47,8 @@ RSpec.describe Boards::GuardianExtensions dogroups: [read_group],)- expect(reader.guardian.can_read_boards_board?(board)).to be_truthy- expect(outsider.guardian.can_read_boards_board?(board)).to be_falsey+ expect(reader.guardian.can_read_board?(board)).to be_truthy+ expect(outsider.guardian.can_read_board?(board)).to be_falseyendit "returns true when the user can write" do@@ -60,7 +60,7 @@ RSpec.describe Boards::GuardianExtensions dogroups: [write_group],)- expect(writer.guardian.can_read_boards_board?(board)).to be_truthy+ expect(writer.guardian.can_read_board?(board)).to be_truthyendit "grants public read to anonymous and logged in users via the anonymous and trust level 0 groups" do@@ -75,8 +75,8 @@ RSpec.describe Boards::GuardianExtensions do],)- expect(anonymous_guardian.can_read_boards_board?(board)).to be_truthy- expect(member.guardian.can_read_boards_board?(board)).to be_truthy+ expect(anonymous_guardian.can_read_board?(board)).to be_truthy+ expect(member.guardian.can_read_board?(board)).to be_truthyendit "grants members-only read via logged in users while excluding anonymous users" do@@ -88,12 +88,12 @@ RSpec.describe Boards::GuardianExtensions doallowed_group_ids: [Group::AUTO_GROUPS[:logged_in_users]],)- expect(member.guardian.can_read_boards_board?(board)).to be_truthy- expect(anonymous_guardian.can_read_boards_board?(board)).to be_falsey+ expect(member.guardian.can_read_board?(board)).to be_truthy+ expect(anonymous_guardian.can_read_board?(board)).to be_falseyendend- describe "#can_write_boards_board?" do+ describe "#can_write_board?" doit "grants write through write groups" doboard = Boards::Board.create!(name: "Operations", slug: "operations")Fabricate(@@ -103,14 +103,14 @@ RSpec.describe Boards::GuardianExtensions dogroups: [write_group],)- expect(writer.guardian.can_write_boards_board?(board)).to eq(true)- expect(outsider.guardian.can_write_boards_board?(board)).to eq(false)+ expect(writer.guardian.can_write_board?(board)).to eq(true)+ expect(outsider.guardian.can_write_board?(board)).to eq(false)endit "does not grant write to admins without an edit or manage ACL" doboard = Boards::Board.create!(name: "Engineering", slug: "engineering")- expect(admin.guardian.can_write_boards_board?(board)).to eq(false)+ expect(admin.guardian.can_write_board?(board)).to eq(false)endit "does not allow creator special priveleges to write if they are not in a write group" do@@ -122,12 +122,38 @@ RSpec.describe Boards::GuardianExtensions dogroups: [write_group],)- expect(creator.guardian.can_write_boards_board?(board)).to eq(false)+ expect(creator.guardian.can_write_board?(board)).to eq(false)write_group.add(creator)creator.reload- expect(creator.guardian.can_write_boards_board?(board)).to eq(true)+ expect(creator.guardian.can_write_board?(board)).to eq(true)+ end+ end++ describe "archived board permissions" do+ fab!(:board) { Fabricate(:boards_board, slug: "archived-board", archived: true) }++ it "preserves read access granted by View, Edit, or Manage ACL permissions" do+ AccessControlList.where(target: board).delete_all++ %w[view edit manage].each do |permission|+ group = Fabricate(:group)+ user = Fabricate(:user, groups: [group])+ Fabricate(:access_control_list_with_groups, target: board, permission:, groups: [group])++ expect(user.guardian.can_read_board?(board)).to eq(true)+ expect(user.guardian.can_write_board?(board)).to eq(false)+ expect(user.guardian.can_manage_board?(board)).to eq(false)+ expect(user.guardian.can_destroy_board?(board)).to eq(false)+ expect(user.guardian.can_unarchive_board?(board)).to eq(permission == "manage")+ end+ end++ it "retains private board visibility restrictions" do+ expect(outsider.guardian.can_read_board?(board)).to eq(false)+ expect(anonymous_guardian.can_read_board?(board)).to eq(false)+ expect(anonymous_guardian.can_unarchive_board?(board)).to eq(false)endendenddiff --git a/plugins/boards/spec/models/boards/board_spec.rb b/plugins/boards/spec/models/boards/board_spec.rbindex 07cc8dd7ff9..69e354cea72 100644--- a/plugins/boards/spec/models/boards/board_spec.rb+++ b/plugins/boards/spec/models/boards/board_spec.rb@@ -277,4 +277,35 @@ RSpec.describe Boards::Board doexpect(described_class.acl_is_banned?(acl)).to eq(false)endend++ describe "#archive_slug" do+ fab!(:board) { Fabricate(:boards_board, slug: "roadmap") }++ it "finds the first available dated suffix" do+ Fabricate(:boards_board, slug: "roadmap-archived-20260910")+ Fabricate(:boards_board, slug: "roadmap-archived-20260910-2")++ expect(board.archive_slug(Date.new(2026, 9, 10))).to eq("roadmap-archived-20260910-3")+ end+ end++ describe "#old_slug_used?" do+ fab!(:board) do+ Fabricate(:boards_board, slug: "archived-board", archived: true, original_slug: "roadmap")+ end++ it "reports whether another board has claimed the original slug" do+ expect(board.old_slug_used?).to eq(false)++ Fabricate(:boards_board, slug: board.original_slug)++ expect(board.old_slug_used?).to eq(true)+ end++ it "does not report an open board as having lost its slug" do+ board.update!(archived: false, original_slug: nil)++ expect(board.old_slug_used?).to eq(false)+ end+ endenddiff --git a/plugins/boards/spec/requests/boards/boards_controller_spec.rb b/plugins/boards/spec/requests/boards/boards_controller_spec.rbindex 981b4447ade..0d732aea83f 100644--- a/plugins/boards/spec/requests/boards/boards_controller_spec.rb+++ b/plugins/boards/spec/requests/boards/boards_controller_spec.rb@@ -871,4 +871,152 @@ RSpec.describe Boards::Api::BoardsController doexpect(response.status).to eq(403)endend++ describe "#archive" do+ fab!(:board) { Fabricate(:boards_board, additional_manage_groups: [manage_group]) }++ it "returns archived state for a manager outside the global management group" do+ SiteSetting.boards_manage_board_allowed_groups = Group::AUTO_GROUPS[:staff].to_s+ sign_in(manager)++ post "/boards/api/boards/#{board.id}/archive.json"++ expect(response.status).to eq(200)+ expect(response.parsed_body["board"]).to include(+ "archived" => true,+ "can_unarchive" => true,+ "can_manage" => false,+ )+ end++ it "rejects an authenticated user without Manage permission" do+ sign_in(outsider)++ post "/boards/api/boards/#{board.id}/archive.json"++ expect(response.status).to eq(403)+ expect(board.reload).not_to be_archived+ end++ it "returns not found for an absent board" do+ sign_in(manager)++ post "/boards/api/boards/0/archive.json"++ expect(response.status).to eq(404)+ end+ end++ describe "#unarchive" do+ fab!(:board) do+ Fabricate(+ :boards_board,+ slug: "archived-board",+ archived: true,+ original_slug: "roadmap",+ additional_manage_groups: [manage_group],+ )+ end++ it "returns restored state after accepting a replacement slug" do+ Fabricate(:boards_board, slug: "roadmap")+ sign_in(manager)++ post "/boards/api/boards/#{board.id}/unarchive.json", params: { slug: "restored-roadmap" }++ expect(response.status).to eq(200)+ expect(response.parsed_body["board"]).to include(+ "archived" => false,+ "slug" => "restored-roadmap",+ )+ end++ it "returns validation errors when the old slug has been claimed" do+ Fabricate(:boards_board, slug: "roadmap")+ sign_in(manager)++ post "/boards/api/boards/#{board.id}/unarchive.json"++ expect(response.status).to eq(422)+ expect(response.parsed_body["errors"]).to be_present+ expect(board.reload).to be_archived+ end++ it "rejects unarchiving without Manage permission" do+ sign_in(outsider)++ post "/boards/api/boards/#{board.id}/unarchive.json"++ expect(response.status).to eq(403)+ expect(board.reload).to be_archived+ end+ end++ describe "archive visibility across board listings" do+ fab!(:open_board, :boards_board)+ fab!(:archived_board) { Fabricate(:boards_board, slug: "archived-board", archived: true) }++ it "includes archived boards in the index but excludes them from available boards" do+ sign_in(admin)++ get "/boards/api/boards.json"++ expect(response.status).to eq(200)+ expect(response.parsed_body["boards"].map { |board| board["id"] }).to contain_exactly(+ open_board.id,+ archived_board.id,+ )++ get "/boards/api/boards/available.json"++ expect(response.status).to eq(200)+ expect(response.parsed_body["boards"].map { |board| board["id"] }).to eq([open_board.id])+ end+ end++ describe "archived board mutation protection" do+ fab!(:board) { Fabricate(:boards_board, slug: "archived-board", archived: true) }+ fab!(:column) { Fabricate(:boards_column, board:) }+ fab!(:card) { Fabricate(:boards_card, board:, column:) }++ it "rejects board edits, deletion, and column reordering even for an administrator" do+ sign_in(admin)++ put "/boards/api/boards/#{board.id}.json", params: { board: { name: "Changed" } }+ expect(response.status).to eq(403)++ post "/boards/api/boards/#{board.id}/move-column.json",+ params: {+ column_id: column.id,+ direction: 1,+ }+ expect(response.status).to eq(403)++ delete "/boards/api/boards/#{board.id}.json"+ expect(response.status).to eq(403)+ expect(board.reload).to be_archived+ end+ end++ describe "repeated archival" do+ it "restores the current slug across multiple archive cycles" do+ board = Fabricate(:boards_board, slug: "roadmap")+ sign_in(admin)++ post "/boards/api/boards/#{board.id}/archive.json"+ expect(response.status).to eq(200)+ Fabricate(:boards_board, slug: "roadmap")+ post "/boards/api/boards/#{board.id}/unarchive.json", params: { slug: "new-roadmap" }+ expect(response.status).to eq(200)+ post "/boards/api/boards/#{board.id}/archive.json"+ expect(response.status).to eq(200)+ post "/boards/api/boards/#{board.id}/unarchive.json"+ expect(response.status).to eq(200)++ expect(response.parsed_body["board"]).to include("slug" => "new-roadmap", "archived" => false)+ expect(board.history.order(:id).pluck(:action)).to eq(+ %w[board_archived board_unarchived board_archived board_unarchived],+ )+ end+ endenddiff --git a/plugins/boards/spec/requests/boards/cards_controller_spec.rb b/plugins/boards/spec/requests/boards/cards_controller_spec.rbindex 18d0c9d2798..c6ac0efdafd 100644--- a/plugins/boards/spec/requests/boards/cards_controller_spec.rb+++ b/plugins/boards/spec/requests/boards/cards_controller_spec.rb@@ -1756,4 +1756,40 @@ RSpec.describe Boards::Api::CardsController doexpect(response.body).not_to include(private_topic.title)endend++ describe "archived card mutation protection" do+ fab!(:card) { Fabricate(:boards_card, board:, column: col_todo) }++ before do+ board.update!(archived: true)+ sign_in(admin)+ end++ it "rejects creating, moving, editing, deleting, and clearing cards" do+ post "/boards/api/boards/#{board.id}/cards.json",+ params: {+ card: {+ column_id: col_todo.id,+ title: "New",+ },+ }+ expect(response.status).to eq(403)++ put "/boards/api/boards/#{board.id}/cards/#{card.id}.json",+ params: {+ card: {+ title: "Edited",+ column_id: col_done.id,+ },+ }+ expect(response.status).to eq(403)++ delete "/boards/api/boards/#{board.id}/cards/#{card.id}.json"+ expect(response.status).to eq(403)++ delete "/boards/api/boards/#{board.id}/columns/#{col_todo.id}/cards.json"+ expect(response.status).to eq(403)+ expect(board.cards.pluck(:id)).to eq([card.id])+ end+ endenddiff --git a/plugins/boards/spec/requests/boards/columns_controller_spec.rb b/plugins/boards/spec/requests/boards/columns_controller_spec.rbindex 48876ba39c2..3fce97f9b00 100644--- a/plugins/boards/spec/requests/boards/columns_controller_spec.rb+++ b/plugins/boards/spec/requests/boards/columns_controller_spec.rb@@ -157,4 +157,28 @@ RSpec.describe Boards::Api::ColumnsController doexpect(response.status).to eq(404)endend++ describe "archived column mutation protection" do+ before do+ board.update!(archived: true)+ sign_in(admin)+ end++ it "rejects creating, updating, and deleting columns" do+ post "/boards/api/boards/#{board.id}/columns.json", params: { column: { title: "New" } }+ expect(response.status).to eq(403)++ put "/boards/api/boards/#{board.id}/columns/#{column.id}.json",+ params: {+ column: {+ title: "Changed",+ },+ }+ expect(response.status).to eq(403)++ delete "/boards/api/boards/#{board.id}/columns/#{column.id}.json"+ expect(response.status).to eq(403)+ expect(board.columns.pluck(:id)).to eq([column.id])+ end+ endenddiff --git a/plugins/boards/spec/requests/boards/topic_moves_controller_spec.rb b/plugins/boards/spec/requests/boards/topic_moves_controller_spec.rbindex 8443935f179..35e1c2601d8 100644--- a/plugins/boards/spec/requests/boards/topic_moves_controller_spec.rb+++ b/plugins/boards/spec/requests/boards/topic_moves_controller_spec.rb@@ -71,4 +71,21 @@ RSpec.describe Boards::Api::TopicMovesController do"assignments",)end++ describe "#create" do+ it "rejects moving a topic to an archived board" do+ board = Fabricate(:boards_board, slug: "archived-board", archived: true)+ column = Fabricate(:boards_column, board:)+ sign_in(admin)++ post "/boards/api/boards/#{board.id}/topic-moves.json",+ params: {+ topic_id: topic.id,+ to_column_id: column.id,+ }++ expect(response.status).to eq(403)+ expect(board.cards).to be_empty+ end+ endenddiff --git a/plugins/boards/spec/serializers/boards/board_serializer_spec.rb b/plugins/boards/spec/serializers/boards/board_serializer_spec.rbindex 26be59b1e57..2eadf7b9a91 100644--- a/plugins/boards/spec/serializers/boards/board_serializer_spec.rb+++ b/plugins/boards/spec/serializers/boards/board_serializer_spec.rb@@ -136,4 +136,48 @@ RSpec.describe Boards::BoardSerializer doexpect(default_payload).to include(acl: nil)expect(acl_payload[:acl]).to eq(AccessControlList.where(target: board).flattened_list)end++ it "gives archived board managers only the unarchive capability and reports slug reuse" do+ board =+ Fabricate(+ :boards_board,+ slug: "archived-board",+ archived: true,+ original_slug: "roadmap",+ additional_manage_groups: [manage_group],+ )+ Fabricate(:boards_board, slug: "roadmap")++ payload = described_class.new(board, root: false, scope: manager.guardian).as_json++ expect(payload).to include(+ archived: true,+ old_slug_used: true,+ can_write: false,+ can_manage: false,+ can_archive: false,+ can_unarchive: true,+ )+ end++ it "does not offer unarchiving to a board editor" do+ board =+ Fabricate(:boards_board, slug: "archived-board", archived: true, original_slug: "unused")+ Fabricate(+ :access_control_list_with_groups,+ target: board,+ permission: "edit",+ groups: [write_group],+ )++ payload = described_class.new(board, root: false, scope: writer.guardian).as_json++ expect(payload).to include(+ archived: true,+ old_slug_used: false,+ can_write: false,+ can_manage: false,+ can_unarchive: false,+ )+ endenddiff --git a/plugins/boards/spec/serializers/boards/current_user_serializer_spec.rb b/plugins/boards/spec/serializers/boards/current_user_serializer_spec.rbnew file mode 100644index 00000000000..5bb5f5c2e6e--- /dev/null+++ b/plugins/boards/spec/serializers/boards/current_user_serializer_spec.rb@@ -0,0 +1,31 @@+# frozen_string_literal: true++RSpec.describe CurrentUserSerializer do+ fab!(:user)+ fab!(:edit_group, :group)+ fab!(:board) { Fabricate(:boards_board, slug: "archived-board", archived: true) }++ before do+ enable_current_plugin+ edit_group.add(user)+ Fabricate(+ :access_control_list_with_groups,+ target: board,+ permission: "edit",+ groups: [edit_group],+ )+ end++ describe "#can_edit_any_boards" do+ it "excludes archived boards when determining whether to offer Add to board" do+ payload = described_class.new(user, scope: user.guardian, root: false).as_json++ expect(payload[:can_edit_any_boards]).to eq(false)++ board.update!(archived: false)+ payload = described_class.new(user, scope: user.guardian, root: false).as_json++ expect(payload[:can_edit_any_boards]).to eq(true)+ end+ end+enddiff --git a/plugins/boards/spec/services/boards/archive_spec.rb b/plugins/boards/spec/services/boards/archive_spec.rbnew file mode 100644index 00000000000..315a11fe41c--- /dev/null+++ b/plugins/boards/spec/services/boards/archive_spec.rb@@ -0,0 +1,113 @@+# frozen_string_literal: true++RSpec.describe Boards::Archive do+ describe described_class::Contract, type: :model do+ it { is_expected.to validate_presence_of(:board_id) }+ end++ describe ".call" do+ subject(:result) { described_class.call(params:, **dependencies) }++ fab!(:acting_user, :user)+ fab!(:manage_group, :group)+ fab!(:board) do+ Fabricate(:boards_board, slug: "roadmap", additional_manage_groups: [manage_group])+ end++ let(:params) { { board_id: board.id } }+ let(:dependencies) { { guardian: acting_user.guardian } }+ let(:messages) { MessageBus.track_publish("/boards/#{board.id}") { result } }++ before do+ enable_current_plugin+ freeze_time Time.utc(2026, 9, 10, 12)+ manage_group.add(acting_user)+ SiteSetting.boards_manage_board_allowed_groups = Group::AUTO_GROUPS[:staff].to_s+ end++ context "when the contract is invalid" do+ let(:params) { { board_id: nil } }++ it { is_expected.to fail_a_contract }+ end++ context "when the board is missing" do+ let(:params) { { board_id: 0 } }++ it { is_expected.to fail_to_find_a_model(:board) }+ end++ context "when the actor has no Manage permission" do+ fab!(:acting_user, :user)++ before { manage_group.remove(acting_user) }++ it { is_expected.to fail_a_policy(:can_archive) }+ end++ context "when the board is already archived" do+ before { board.update!(archived: true) }++ it { is_expected.to fail_a_policy(:can_archive) }+ end++ context "when the actor has Manage permission outside the global management groups" do+ it "archives the board and records its previous slug and actor atomically" do+ expect(result).to run_successfully+ expect(board.reload).to have_attributes(+ archived: true,+ archived_at: Time.current,+ archived_by_id: acting_user.id,+ original_slug: "roadmap",+ slug: "roadmap-archived-20260910",+ )+ expect(board.history.sole).to have_attributes(+ action: "board_archived",+ acting_user_id: acting_user.id,+ details: {+ "previous_value" => "roadmap",+ "new_value" => "roadmap-archived-20260910",+ },+ )+ end++ it "publishes the archive event so viewers reload the board" do+ expect(messages.map(&:data)).to eq([{ type: "board_archived", client_id: nil }])+ end+ end++ context "when the original slug is at the normal length limit" do+ before { board.update!(slug: "a" * 255) }++ it "keeps the archive suffix without losing the original slug" do+ expect(result).to run_successfully+ expect(board.reload.slug).to eq("#{"a" * 255}-archived-20260910")+ expect(board.original_slug).to eq("a" * 255)+ end+ end++ context "when the original slug is encoded" do+ before do+ SiteSetting.slug_generation_method = "encoded"+ board.update!(slug: "路線")+ end++ it "preserves the stored encoding when appending the archive suffix" do+ original_slug = board.slug++ expect(result).to run_successfully+ expect(board.reload.slug).to eq("#{original_slug}-archived-20260910")+ expect(board.original_slug).to eq(original_slug)+ end+ end++ context "when the archive slug has already been used" do+ before { Fabricate(:boards_board, slug: "roadmap-archived-20260910") }++ it "uses an available numbered archive slug" do+ expect(result).to run_successfully+ expect(board.reload.slug).to eq("roadmap-archived-20260910-2")+ end+ end+ end+enddiff --git a/plugins/boards/spec/services/boards/publisher_spec.rb b/plugins/boards/spec/services/boards/publisher_spec.rbindex e87e330bc14..d00b15c1c2c 100644--- a/plugins/boards/spec/services/boards/publisher_spec.rb+++ b/plugins/boards/spec/services/boards/publisher_spec.rb@@ -177,4 +177,24 @@ RSpec.describe Boards::Publisher doexpect(messages.first.group_ids).to be_nilendend++ describe "publishing to an archived board" do+ subject(:result) do+ described_class.publish_card_created!(board, card_data, client_id: test_client_id)+ described_class.publish_card_updated!(board, card_data, client_id: test_client_id)+ described_class.publish_card_moved!(board, card_data, client_id: test_client_id)+ described_class.publish_card_deleted!(board, card.id, client_id: test_client_id)+ described_class.publish_column_cleared!(board, column.id, client_id: test_client_id)+ described_class.publish_columns_reordered!(board, [column.id], client_id: test_client_id)+ described_class.publish_board_updated!(board, client_id: test_client_id)+ end++ let(:messages) { MessageBus.track_publish(channel) { result } }++ it "suppresses every board event even when the caller has a stale board instance" do+ Boards::Board.find(board.id).update!(archived: true)++ expect(messages).to be_empty+ end+ endenddiff --git a/plugins/boards/spec/services/boards/topic_sync_spec.rb b/plugins/boards/spec/services/boards/topic_sync_spec.rbindex f1dac24de82..a96fbcfe081 100644--- a/plugins/boards/spec/services/boards/topic_sync_spec.rb+++ b/plugins/boards/spec/services/boards/topic_sync_spec.rb@@ -487,6 +487,30 @@ RSpec.describe Boards::TopicSync doenddescribe ".backfill_board" do+ context "when the board is archived" do+ subject(:result) { described_class.backfill_board(board) }++ fab!(:board) do+ Fabricate(+ :boards_board,+ slug: "archived-board",+ archived: true,+ category_ids: [category.id],+ )+ end+ fab!(:column) { Fabricate(:boards_column, board:, tag_id: tag_a.id) }++ it "preserves archived cards and avoids adding matching topics even with a stale board instance" do+ board.archived = false+ card = Fabricate(:boards_topic_card, board:, column:, topic:)+ Fabricate(:topic, category:, tags: [tag_a])++ result++ expect(board.cards.pluck(:id)).to eq([card.id])+ end+ end+it "creates cards for matching topics in tagged columns" dotagged_topic = Fabricate(:topic, category: category, tags: [tag_a])@@ -737,4 +761,43 @@ RSpec.describe Boards::TopicSync doexpect(post.topic).to be_persistedendend++ describe ".sync_topic" do+ subject(:result) { described_class.sync_topic(topic) }++ fab!(:board) do+ Fabricate(:boards_board, slug: "archived-board", archived: true, category_ids: [category.id])+ end+ fab!(:column) { Fabricate(:boards_column, board:, tag_id: tag_a.id) }++ let(:messages) { MessageBus.track_publish("/boards/#{board.id}") { result } }++ it "skips automatic placement in archived boards" do+ topic.tags = [tag_a]++ expect(messages).to be_empty+ expect(board.cards).to be_empty+ end++ it "preserves existing archived cards when a topic stops matching" do+ card = Fabricate(:boards_topic_card, board:, column:, topic:)++ expect(messages).to be_empty+ expect(board.cards.pluck(:id)).to eq([card.id])+ end+ end++ describe ".remove_topic" do+ subject(:result) { described_class.remove_topic(topic.id) }++ fab!(:board) { Fabricate(:boards_board, slug: "archived-board", archived: true) }+ fab!(:card) { Fabricate(:boards_topic_card, board:, topic:) }++ let(:messages) { MessageBus.track_publish("/boards/#{board.id}") { result } }++ it "preserves the archived card without publishing a removal" do+ expect(messages).to be_empty+ expect(board.cards.pluck(:id)).to eq([card.id])+ end+ endenddiff --git a/plugins/boards/spec/services/boards/unarchive_spec.rb b/plugins/boards/spec/services/boards/unarchive_spec.rbnew file mode 100644index 00000000000..08f4f90ddd2--- /dev/null+++ b/plugins/boards/spec/services/boards/unarchive_spec.rb@@ -0,0 +1,139 @@+# frozen_string_literal: true++RSpec.describe Boards::Unarchive do+ describe described_class::Contract, type: :model do+ it { is_expected.to validate_presence_of(:board_id) }+ end++ describe ".call" do+ subject(:result) { described_class.call(params:, **dependencies) }++ fab!(:acting_user, :user)+ fab!(:manage_group, :group)+ fab!(:board) do+ Fabricate(+ :boards_board,+ slug: "roadmap-archived-20260910",+ original_slug: "roadmap",+ archived: true,+ archived_at: Time.utc(2026, 9, 10),+ archived_by: acting_user,+ additional_manage_groups: [manage_group],+ )+ end++ let(:params) { { board_id: board.id } }+ let(:dependencies) { { guardian: acting_user.guardian } }++ before do+ enable_current_plugin+ manage_group.add(acting_user)+ SiteSetting.boards_manage_board_allowed_groups = Group::AUTO_GROUPS[:staff].to_s+ end++ context "when the contract is invalid" do+ let(:params) { { board_id: nil } }++ it { is_expected.to fail_a_contract }+ end++ context "when the board is missing" do+ let(:params) { { board_id: 0 } }++ it { is_expected.to fail_to_find_a_model(:board) }+ end++ context "when the actor has no Manage permission" do+ before { manage_group.remove(acting_user) }++ it { is_expected.to fail_a_policy(:can_unarchive) }+ end++ context "when the board is open" do+ before { board.update!(archived: false) }++ it { is_expected.to fail_a_policy(:can_unarchive) }+ end++ context "when the original slug is available" do+ it "restores the slug and clears archive metadata for a manager outside global groups" do+ expect(result).to run_successfully+ expect(board.reload).to have_attributes(+ archived: false,+ archived_at: nil,+ archived_by_id: nil,+ original_slug: nil,+ slug: "roadmap",+ )+ expect(board.history.sole).to have_attributes(+ action: "board_unarchived",+ acting_user_id: acting_user.id,+ details: {+ "previous_value" => "roadmap-archived-20260910",+ "new_value" => "roadmap",+ },+ )+ end+ end++ context "when the original slug is at the normal length limit" do+ before { board.update!(original_slug: "a" * 255) }++ it "restores the entire original slug" do+ expect(result).to run_successfully+ expect(board.reload.slug).to eq("a" * 255)+ end+ end++ context "when the original slug is encoded" do+ before do+ SiteSetting.slug_generation_method = "encoded"+ board.update!(original_slug: "%E8%B7%AF%E7%B7%9A")+ end++ it "restores the original encoding unchanged" do+ expect(result).to run_successfully+ expect(board.reload.slug).to eq("%E8%B7%AF%E7%B7%9A")+ end+ end++ context "when the original slug is occupied" do+ before { Fabricate(:boards_board, slug: "roadmap") }++ it "preserves archive metadata and history when no replacement is supplied" do+ expect(result).to fail_with_exception(ActiveRecord::RecordInvalid)+ expect(board.reload).to have_attributes(+ archived: true,+ slug: "roadmap-archived-20260910",+ original_slug: "roadmap",+ archived_by_id: acting_user.id,+ )+ expect(board.history).to be_empty+ end+ end++ context "when a replacement slug is supplied" do+ let(:params) { { board_id: board.id, slug: "New roadmap" } }++ before { Fabricate(:boards_board, slug: "roadmap") }++ it "normalizes the replacement slug and records it in history" do+ expect(result).to run_successfully+ expect(board.reload.slug).to eq("new-roadmap")+ expect(board.history.sole.details["new_value"]).to eq("new-roadmap")+ end+ end++ context "when a replacement slug is also occupied" do+ let(:params) { { board_id: board.id, slug: "other" } }++ before { Fabricate(:boards_board, slug: "other") }++ it "keeps the board archived without recording an unarchive" do+ expect(result).to fail_with_exception(ActiveRecord::RecordInvalid)+ expect(board.reload).to be_archived+ expect(board.history).to be_empty+ end+ end+ end+enddiff --git a/plugins/boards/spec/system/boards_board_viewer_spec.rb b/plugins/boards/spec/system/boards_board_viewer_spec.rbindex b1b75025869..9706eb71390 100644--- a/plugins/boards/spec/system/boards_board_viewer_spec.rb+++ b/plugins/boards/spec/system/boards_board_viewer_spec.rb@@ -703,6 +703,48 @@ describe "Boards Board Viewer" doendend+ context "when archiving a board" do+ it "archives through the menu and restores editing after unarchiving" do+ board =+ Fabricate(+ :boards_board,+ slug: "archive-roundtrip",+ additional_manage_groups: [manage_group],+ )+ column = Fabricate(:boards_column, board:, title: "To Do")+ card = Fabricate(:boards_card, board:, column:)+ sign_in(manager)+ board_viewer.visit_board(board)++ board_viewer.open_controls_menu+ find("[data-content] [data-identifier='archive-board'] button").click+ within(".discourse-boards-archive-modal") do+ expect(page).to have_link("the boards list", href: "/boards")+ find("button[type='submit']").click+ end++ expect(page).to have_no_css(".discourse-boards-archive-modal")+ expect(page).to have_current_path(+ "/boards/archive-roundtrip-archived-#{Time.zone.today.strftime("%Y%m%d")}/#{board.id}",+ )+ expect(board_viewer).to have_no_add_card_button_in_column("To Do")+ expect(page).to have_css("[data-card-id='#{card.id}'][draggable='false']")++ board_viewer.open_controls_menu+ expect(board_viewer).to have_no_board_settings_option+ find("[data-content] [data-identifier='archive-board'] button").click+ within(".discourse-boards-archive-modal") do+ expect(page).to have_no_css("input[name='slug']")+ find("button[type='submit']").click+ end++ expect(page).to have_no_css(".discourse-boards-archive-modal")+ expect(page).to have_current_path("/boards/archive-roundtrip/#{board.id}")+ expect(board_viewer).to have_add_card_button_in_column("To Do")+ expect(page).to have_css("[data-card-id='#{card.id}'][draggable='true']")+ end+ end+context "with controls menu" doit "toggles fullscreen mode" doresult = create_board(with_columns: [{ title: "To Do", position: 0 }])@@ -728,14 +770,13 @@ describe "Boards Board Viewer" doexpect(board_viewer).to have_board_settings_optionend- it "hides board settings option for users not in the manage group" do+ it "hides the controls menu for users without board management actions" doresult = create_board(with_columns: [{ title: "To Do", position: 0 }])sign_in(user)board_viewer.visit_board(result.board)- board_viewer.open_controls_menu- expect(board_viewer).to have_no_board_settings_option+ expect(board_viewer).to have_no_controls_menuendenddiff --git a/plugins/boards/test/javascripts/components/boards-archive-test.gjs b/plugins/boards/test/javascripts/components/boards-archive-test.gjsnew file mode 100644index 00000000000..b78af68d0dc--- /dev/null+++ b/plugins/boards/test/javascripts/components/boards-archive-test.gjs@@ -0,0 +1,146 @@+import { getOwner } from "@ember/owner";+import { render } from "@ember/test-helpers";+import { module, test } from "qunit";+import sinon from "sinon";+import { setupRenderingTest } from "discourse/tests/helpers/component-test";+import pretender, {+ parsePostData,+ response,+} from "discourse/tests/helpers/create-pretender";+import formKit from "discourse/tests/helpers/form-kit-helper";+import BoardsArchive from "discourse/plugins/boards/discourse/components/modal/boards-archive";+import Board from "discourse/plugins/boards/discourse/models/board";++module("Integration | Component | BoardsArchive", function (hooks) {+ setupRenderingTest(hooks);++ hooks.beforeEach(function () {+ this.model = {+ board: Board.create({ id: 1, archived: false, old_slug_used: false }),+ onSuccess: sinon.spy(),+ };+ this.closeModal = sinon.spy();+ });++ test("confirms archiving with a link to the boards list", async function (assert) {+ pretender.post("/boards/api/boards/1/archive", (request) => {+ assert.strictEqual(+ parsePostData(request.requestBody).client_id,+ getOwner(this).lookup("service:message-bus").clientId,+ "the initiating tab can ignore its own archive event"+ );+ return response({ board: { id: 1, archived: true } });+ });+ await render(+ <template>+ <BoardsArchive+ @closeModal={{this.closeModal}}+ @inline={{true}}+ @model={{this.model}}+ />+ </template>+ );+ assert+ .dom(".discourse-boards-archive-modal p")+ .hasText(+ 'Are you sure you want to archive this board? You can see archived boards on the boards list by choosing "Archived" from the filter dropdown.',+ "the full confirmation is shown"+ );+ assert+ .dom(".discourse-boards-archive-modal p a")+ .hasAttribute("href", "/boards", "the list link is usable");+ assert+ .dom('[data-name="slug"]')+ .doesNotExist("archiving needs no slug input");+ await formKit().submit();+ assert.true(+ this.model.onSuccess.calledWith({ id: 1, archived: true }),+ "the updated board is returned to the viewer"+ );+ assert.true(this.closeModal.calledOnce, "the successful modal closes");+ });++ test("unarchives without a slug when the original remains available", async function (assert) {+ this.model.board.archived = true;+ pretender.post("/boards/api/boards/1/unarchive", () =>+ response({ board: { id: 1, archived: false } })+ );+ await render(+ <template>+ <BoardsArchive+ @closeModal={{this.closeModal}}+ @inline={{true}}+ @model={{this.model}}+ />+ </template>+ );+ assert+ .dom('[data-name="slug"]')+ .doesNotExist("an available original slug needs no input");+ await formKit().submit();+ assert.true(+ this.model.onSuccess.calledWith({ id: 1, archived: false }),+ "the board is restored"+ );+ });++ test("requires and submits a replacement slug when the original was reused", async function (assert) {+ Object.assign(this.model.board, { archived: true, old_slug_used: true });+ pretender.post("/boards/api/boards/1/unarchive", (request) => {+ assert.strictEqual(+ parsePostData(request.requestBody).client_id,+ getOwner(this).lookup("service:message-bus").clientId,+ "the initiating tab can ignore its own unarchive event"+ );+ assert.strictEqual(+ parsePostData(request.requestBody).slug,+ "restored-board",+ "the chosen slug is submitted"+ );+ return response({+ board: { id: 1, slug: "restored-board", archived: false },+ });+ });+ await render(+ <template>+ <BoardsArchive+ @closeModal={{this.closeModal}}+ @inline={{true}}+ @model={{this.model}}+ />+ </template>+ );+ assert+ .dom('[data-name="slug"] input')+ .exists("the replacement slug field is shown");+ await formKit().field("slug").fillIn("restored-board");+ await formKit().submit();+ assert.true(this.closeModal.calledOnce, "the successful modal closes");+ });+ test("asks for a replacement if the original slug is claimed while the modal is open", async function (assert) {+ this.model.board.archived = true;+ const dialog = getOwner(this).lookup("service:dialog");+ sinon.stub(dialog, "alert");+ pretender.post("/boards/api/boards/1/unarchive", () =>+ response(422, { errors: ["Slug has already been taken"] })+ );+ pretender.get("/boards/api/boards/1.json", () =>+ response({ board: { id: 1, archived: true, old_slug_used: true } })+ );+ await render(+ <template>+ <BoardsArchive+ @closeModal={{this.closeModal}}+ @inline={{true}}+ @model={{this.model}}+ />+ </template>+ );+ await formKit().submit();+ assert+ .dom('[data-name="slug"] input')+ .exists("updated slug availability enables a replacement");+ assert.false(this.closeModal.called, "the failed modal stays open");+ assert.false(this.model.onSuccess.called, "the board remains archived");+ });+});diff --git a/plugins/boards/test/javascripts/components/boards-board-viewer-test.gjs b/plugins/boards/test/javascripts/components/boards-board-viewer-test.gjsindex d5914d46b87..44407928b94 100644--- a/plugins/boards/test/javascripts/components/boards-board-viewer-test.gjs+++ b/plugins/boards/test/javascripts/components/boards-board-viewer-test.gjs@@ -708,4 +708,59 @@ module("Integration | Component | BoardsBoardViewer", function (hooks) {"it leaves the recency column order unchanged");});+ test("archived boards disable editing and only offer unarchive to managers", async function (assert) {+ const card = this.makeCard({ id: 101, columnId: 11, title: "Read only" });+ await this.renderBoard(+ [this.makeColumn({ id: 11, title: "Done", cards: [card] })],+ {+ archived: true,+ can_manage: false,+ can_write: false,+ can_unarchive: true,+ }+ );+ assert+ .dom(cardSelector(101))+ .hasAttribute("draggable", "false", "archived cards cannot be dragged");+ assert.true(+ this.messageBus.subscribe.calledWith("/boards/1"),+ "archived boards stay subscribed to receive unarchive events"+ );+ await click('[data-identifier="boards-board-controls"]');+ assert+ .dom('[data-identifier="archive-board"]')+ .hasText("Unarchive board...", "managers can restore the board");+ assert+ .dom('[data-identifier="add-column"]')+ .doesNotExist("columns cannot be added");+ assert+ .dom('[data-identifier="board-settings"]')+ .doesNotExist("board options cannot be edited");+ assert+ .dom('[data-identifier="delete-board"]')+ .doesNotExist("archived boards cannot be deleted");+ });++ test("archived viewers have no board settings menu", async function (assert) {+ await this.renderBoard([], {+ archived: true,+ can_manage: false,+ can_write: false,+ can_unarchive: false,+ });+ assert+ .dom('[data-identifier="boards-board-controls"]')+ .doesNotExist("viewers have no settings actions");+ });++ test("offers archive to a Manage ACL holder without ordinary configuration access", async function (assert) {+ await this.renderBoard([], { can_manage: false, can_archive: true });+ await click('[data-identifier="boards-board-controls"]');+ assert+ .dom('[data-identifier="archive-board"]')+ .hasText("Archive board", "Manage ACL permits archiving");+ assert+ .dom('[data-identifier="board-settings"]')+ .doesNotExist("existing configuration permission remains separate");+ });});diff --git a/plugins/boards/test/javascripts/components/boards-card-detail-test.gjs b/plugins/boards/test/javascripts/components/boards-card-detail-test.gjsnew file mode 100644index 00000000000..c0d101a91cd--- /dev/null+++ b/plugins/boards/test/javascripts/components/boards-card-detail-test.gjs@@ -0,0 +1,48 @@+import { render, settled } from "@ember/test-helpers";+import { module, test } from "qunit";+import { setupRenderingTest } from "discourse/tests/helpers/component-test";+import pretender, { response } from "discourse/tests/helpers/create-pretender";+import BoardsCardDetail from "discourse/plugins/boards/discourse/components/modal/boards-card-detail";+import Board from "discourse/plugins/boards/discourse/models/board";++module("Integration | Component | BoardsCardDetail", function (hooks) {+ setupRenderingTest(hooks);++ test("assignment is disabled when the board cannot be written to", async function (assert) {+ this.siteSettings.assign_enabled = true;+ pretender.post("/boards/api/boards/1/cards/2/view", () => response({}));+ this.model = {+ board: Board.create({ archived: true, can_write: true }),+ card: {+ id: 2,+ board_id: 1,+ title: "Test card",+ assigned_to: { username: "martin" },+ },+ };++ await render(+ <template>+ <BoardsCardDetail @inline={{true}} @model={{this.model}} />+ </template>+ );++ assert+ .dom(".email-group-user-chooser")+ .hasClass("is-disabled", "archived card assignment is disabled");++ this.model.board.archived = false;+ await settled();++ assert+ .dom(".email-group-user-chooser")+ .doesNotHaveClass("is-disabled", "writable cards allow assignment");++ this.model.board.can_write = false;+ await settled();++ assert+ .dom(".email-group-user-chooser")+ .hasClass("is-disabled", "view-only card assignment is disabled");+ });+});diff --git a/plugins/boards/test/javascripts/components/boards-card-test.gjs b/plugins/boards/test/javascripts/components/boards-card-test.gjsindex 3a1ef737718..8dc3ee1c886 100644--- a/plugins/boards/test/javascripts/components/boards-card-test.gjs+++ b/plugins/boards/test/javascripts/components/boards-card-test.gjs@@ -167,11 +167,7 @@ module(this.siteSettings.assign_enabled = false;await render(<template>- <BoardsCard- @board={{this.board}}- @canWrite={{this.board.can_write}}- @card={{this.card}}- />+ <BoardsCard @board={{this.board}} @card={{this.card}} /></template>);assert.dom(".discourse-boards-card__assign-btn").doesNotExist();@@ -181,11 +177,7 @@ module(this.card.card_type = "floater";await render(<template>- <BoardsCard- @board={{this.board}}- @canWrite={{this.board.can_write}}- @card={{this.card}}- />+ <BoardsCard @board={{this.board}} @card={{this.card}} /></template>);assert.dom(".discourse-boards-card__assign-btn").exists();@@ -199,16 +191,27 @@ module(await render(<template>- <BoardsCard- @board={{this.board}}- @canWrite={{this.board.can_write}}- @card={{this.card}}- />+ <BoardsCard @board={{this.board}} @card={{this.card}} /></template>);assert.dom(".discourse-boards-card__assign-btn").exists();});+ test("does not offer assignment on an archived board", async function (assert) {+ this.board.archived = true;+ this.card = this.fabricators.card({+ topic: { id: 42, title: "Archived work" },+ });+ await render(+ <template>+ <BoardsCard @board={{this.board}} @card={{this.card}} />+ </template>+ );+ assert+ .dom(".discourse-boards-card__assign-btn")+ .doesNotExist("archived topic cards cannot be assigned");+ });+test("does not render assignment for a closed topic card", async function (assert) {const topic = this.fabricators.coreFabricators.topic();topic.closed = true;@@ -218,11 +221,7 @@ module(topic.closed = true;await render(<template>- <BoardsCard- @board={{this.board}}- @canWrite={{this.board.can_write}}- @card={{this.card}}- />+ <BoardsCard @board={{this.board}} @card={{this.card}} /></template>);assert.dom(".discourse-boards-card__assign-btn").doesNotExist();diff --git a/plugins/boards/test/javascripts/components/boards-column-test.gjs b/plugins/boards/test/javascripts/components/boards-column-test.gjsindex d58e855240b..e4feff96d29 100644--- a/plugins/boards/test/javascripts/components/boards-column-test.gjs+++ b/plugins/boards/test/javascripts/components/boards-column-test.gjs@@ -18,7 +18,11 @@ module("Integration | Component | BoardsColumn", function (hooks) {hooks.beforeEach(function () {this.fabricators = new BoardsFabricators(getOwner(this));- this.board = this.fabricators.board({ id: 1, can_write: false });+ this.board = this.fabricators.board({+ id: 1,+ can_write: false,+ can_manage: false,+ });this.oldCard = this.fabricators.card({id: 101,@@ -43,8 +47,6 @@ module("Integration | Component | BoardsColumn", function (hooks) {<template><BoardsColumn@board={{this.board}}- @canManage={{false}}- @canWrite={{false}}@column={{this.column}}@linkedCardId={{this.linkedCardId}}@linkHighlightCardId={{this.linkHighlightCardId}}diff --git a/plugins/boards/test/javascripts/components/boards-page-test.gjs b/plugins/boards/test/javascripts/components/boards-page-test.gjsnew file mode 100644index 00000000000..8b55e4d445c--- /dev/null+++ b/plugins/boards/test/javascripts/components/boards-page-test.gjs@@ -0,0 +1,65 @@+import { getOwner } from "@ember/owner";+import { fillIn, render } from "@ember/test-helpers";+import { module, test } from "qunit";+import { setupRenderingTest } from "discourse/tests/helpers/component-test";+import BoardsPage from "discourse/plugins/boards/discourse/components/boards-page";+import BoardsFabricators from "discourse/plugins/boards/discourse/lib/fabricators";++module("Integration | Component | BoardsPage", function (hooks) {+ setupRenderingTest(hooks);++ hooks.beforeEach(function () {+ const fabricators = new BoardsFabricators(getOwner(this));+ this.boards = [+ fabricators.board({ id: 1, name: "Current work" }),+ Object.assign(fabricators.board({ id: 2, name: "Past work" }), {+ archived: true,+ }),+ ];+ });++ test("defaults to open and combines archive status with search", async function (assert) {+ await render(<template><BoardsPage @boards={{this.boards}} /></template>);+ assert+ .dom(".d-filter-controls__dropdown")+ .hasValue("open", "Open is selected initially");+ assert+ .dom(".discourse-boards-board-card__name")+ .hasText("Current work", "only open boards appear initially");+ assert+ .dom(".discourse-boards-board-card")+ .exists({ count: 1 }, "archived boards are excluded");++ await fillIn(".d-filter-controls__dropdown", "all");+ assert+ .dom(".discourse-boards-board-card")+ .exists({ count: 2 }, "All includes both states");+ await fillIn(".d-filter-controls__input", "Past");+ assert+ .dom(".discourse-boards-board-card__name")+ .hasText("Past work", "search applies to All");+ await fillIn(".d-filter-controls__dropdown", "open");+ assert+ .dom(".discourse-boards-board-card")+ .doesNotExist("search cannot reveal an archived board under Open");+ assert+ .dom(".d-filter-controls__no-results")+ .exists("empty filtered results have an explanation");+ await fillIn(".d-filter-controls__dropdown", "archived");+ assert+ .dom(".discourse-boards-board-card__name")+ .hasText("Past work", "Archived combines with search");+ });++ test("keeps the status filter available when every board is archived", async function (assert) {+ this.boards = [this.boards[1]];+ await render(<template><BoardsPage @boards={{this.boards}} /></template>);+ assert+ .dom(".d-filter-controls__no-results")+ .exists("Open explains the empty result");+ await fillIn(".d-filter-controls__dropdown", "archived");+ assert+ .dom(".discourse-boards-board-card__name")+ .hasText("Past work", "the archived board is reachable");+ });+});diff --git a/plugins/boards/test/javascripts/unit/routes/boards-board-configure-test.js b/plugins/boards/test/javascripts/unit/routes/boards-board-configure-test.jsindex b909d514c49..861eb7f7c7e 100644--- a/plugins/boards/test/javascripts/unit/routes/boards-board-configure-test.js+++ b/plugins/boards/test/javascripts/unit/routes/boards-board-configure-test.js@@ -1,6 +1,7 @@import { setupTest } from "ember-qunit";import { module, test } from "qunit";import sinon from "sinon";+import Board from "discourse/plugins/boards/discourse/models/board";module("Unit | Route | boards-board-configure", function (hooks) {setupTest(hooks);@@ -11,11 +12,11 @@ module("Unit | Route | boards-board-configure", function (hooks) {route.afterModel({- board: {+ board: Board.create({id: 42,slug: "team-board",can_manage: false,- },+ }),},{ to: { params: { slug: "team-board" } } });@@ -33,15 +34,35 @@ module("Unit | Route | boards-board-configure", function (hooks) {route.afterModel({- board: {+ board: Board.create({id: 42,slug: "team-board",can_manage: true,- },+ }),},{ to: { params: { slug: "team-board" } } });assert.false(replaceWith.called, "no redirect occurs");});+ test("redirects archived managers away from configuration", function (assert) {+ const route = this.owner.lookup("route:boards-board-configure");+ const replaceWith = sinon.stub(route.router, "replaceWith");+ route.afterModel(+ {+ board: Board.create({+ id: 42,+ slug: "archived-board",+ archived: true,+ can_manage: true,+ }),+ },+ { to: { params: { slug: "archived-board" } } }+ );+ assert.deepEqual(+ replaceWith.firstCall.args,+ ["boardsBoard", "archived-board", 42],+ "archived boards use the read-only route"+ );+ });});diff --git a/plugins/chat/spec/services/chat/add_users_to_channel_spec.rb b/plugins/chat/spec/services/chat/add_users_to_channel_spec.rbindex 862e2a2493f..474f661fab3 100644--- a/plugins/chat/spec/services/chat/add_users_to_channel_spec.rb+++ b/plugins/chat/spec/services/chat/add_users_to_channel_spec.rb@@ -142,7 +142,7 @@ RSpec.describe Chat::AddUsersToChannel doendit "only notifies the newly added users" do- expect(result.added_user_ids).to eq users.last(2).map(&:id)+ expect(result.added_user_ids).to contain_exactly(*users.last(2).map(&:id))endit "respects membership settings for existing users" do