mirror of
https://github.com/discourse/discourse.git
synced 2026-08-07 13:19:19 +08:00
Adds the frontend for the Reports section on the redesigned admin dashboard. Admins can choose which reports appear on their dashboard, reorder them, and add/remove cards via a "Manage reports" modal. A plugin API lets plugins ship their own report providers and custom card renderers — used by Data Explorer to surface DE queries alongside core reports. Follow-up to backend PR: https://github.com/discourse/discourse/pull/40017
38 lines
1.1 KiB
Ruby
Vendored
38 lines
1.1 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
RSpec.describe AdminDashboard::Reports::SourceProvider do
|
|
describe ".accessible_ids" do
|
|
let(:provider) do
|
|
Class.new(described_class) do
|
|
def self.source_name = "test"
|
|
|
|
def self.label = "Test"
|
|
|
|
def self.resolve_many(identifiers, guardian:)
|
|
identifiers
|
|
.select { |id| %w[a b].include?(id) }
|
|
.each_with_object({}) do |id, hash|
|
|
hash[id] = AdminDashboard::Reports::ResolvedReport.new(
|
|
source: source_name,
|
|
identifier: id,
|
|
title: id,
|
|
description: nil,
|
|
label: label,
|
|
url: nil,
|
|
)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
it "returns the set of identifiers that resolve_many returned" do
|
|
result = provider.accessible_ids(%w[a b c], guardian: nil)
|
|
expect(result).to eq(Set.new(%w[a b]))
|
|
end
|
|
|
|
it "returns an empty set when nothing resolves" do
|
|
result = provider.accessible_ids(%w[x y z], guardian: nil)
|
|
expect(result).to be_empty
|
|
end
|
|
end
|
|
end
|