Skip to content

A platform for community discussion. Free, open, simple.

DEV: rename staff_logins report to admin_logins (#39840)

Sam89019983ca2b
diff --git a/app/models/concerns/reports/staff_logins.rb b/app/models/concerns/reports/admin_logins.rb
similarity index 86%
rename from app/models/concerns/reports/staff_logins.rb
rename to app/models/concerns/reports/admin_logins.rb
index bba58aeee24..115292d35a6 100644
--- a/app/models/concerns/reports/staff_logins.rb
+++ b/app/models/concerns/reports/admin_logins.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-module Reports::StaffLogins
+module Reports::AdminLogins
extend ActiveSupport::Concern
class_methods do
- def report_staff_logins(report)
+ def report_admin_logins(report)
report.modes = [Report::MODES[:table]]
report.data = []
@@ -17,13 +17,13 @@ module Reports::StaffLogins
id: :user_id,
avatar: :avatar_template,
},
- title: I18n.t("reports.staff_logins.labels.user"),
+ title: I18n.t("reports.admin_logins.labels.user"),
},
- { property: :location, title: I18n.t("reports.staff_logins.labels.location") },
+ { property: :location, title: I18n.t("reports.admin_logins.labels.location") },
{
property: :created_at,
type: :precise_date,
- title: I18n.t("reports.staff_logins.labels.login_at"),
+ title: I18n.t("reports.admin_logins.labels.login_at"),
},
]
diff --git a/app/models/report.rb b/app/models/report.rb
index e44e3b1f868..dc2d8dd832e 100644
--- a/app/models/report.rb
+++ b/app/models/report.rb
@@ -36,7 +36,7 @@ class Report
page_view_logged_in_reqs
]
- ADMIN_ONLY_REPORTS = %w[top_uploads]
+ ADMIN_ONLY_REPORTS = %w[admin_logins top_uploads]
def self.hidden?(type, admin:)
return true if !admin && ADMIN_ONLY_REPORTS.include?(type)
@@ -101,7 +101,7 @@ class Report
include Reports::Posts
include Reports::ProfileViews
include Reports::Signups
- include Reports::StaffLogins
+ include Reports::AdminLogins
include Reports::StorageStats
include Reports::SuspiciousLogins
include Reports::SystemPrivateMessages
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 0b8378cbb12..95828bd1c69 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -1671,7 +1671,7 @@ en:
os: Operating System
login_time: Login Time
description: "Details of new logins that differ suspiciously from previous logins."
- staff_logins:
+ admin_logins:
title: "Admin Logins"
labels:
user: User
diff --git a/frontend/discourse/admin/components/admin-reports.gjs b/frontend/discourse/admin/components/admin-reports.gjs
index f08752384b7..d76f9d6a863 100644
--- a/frontend/discourse/admin/components/admin-reports.gjs
+++ b/frontend/discourse/admin/components/admin-reports.gjs
@@ -51,13 +51,13 @@ const REPORT_GROUPS = {
"user_to_user_private_messages_with_replies",
],
moderation_and_security: [
+ "admin_logins",
"associated_accounts_by_provider",
"consolidated_api_requests",
"emails",
"flags",
"flags_status",
"moderators_activity",
- "staff_logins",
"suspicious_logins",
"user_flagging_ratio",
"web_crawlers",
diff --git a/frontend/discourse/admin/templates/admin/dashboard-security.gjs b/frontend/discourse/admin/templates/admin/dashboard-security.gjs
index 3589978e107..45c6a6e99fd 100644
--- a/frontend/discourse/admin/templates/admin/dashboard-security.gjs
+++ b/frontend/discourse/admin/templates/admin/dashboard-security.gjs
@@ -14,10 +14,12 @@ export default <template>
@filters={{@controller.lastWeekFilters}}
/>
- <AdminReport
- @dataSourceName="staff_logins"
- @filters={{@controller.lastWeekFilters}}
- />
+ {{#if @controller.currentUser.admin}}
+ <AdminReport
+ @dataSourceName="admin_logins"
+ @filters={{@controller.lastWeekFilters}}
+ />
+ {{/if}}
<PluginOutlet
@name="admin-dashboard-security-bottom"
diff --git a/frontend/discourse/tests/acceptance/reports-test.js b/frontend/discourse/tests/acceptance/reports-test.js
index bd710c64d16..125175d0608 100644
--- a/frontend/discourse/tests/acceptance/reports-test.js
+++ b/frontend/discourse/tests/acceptance/reports-test.js
@@ -26,7 +26,7 @@ acceptance("Reports", function (needs) {
});
test("Visit report page", async function (assert) {
- await visit("/admin/reports/staff_logins");
+ await visit("/admin/reports/admin_logins");
assert.dom(".export-csv-btn").exists();
});
diff --git a/frontend/discourse/tests/fixtures/admin-search-fixtures.js b/frontend/discourse/tests/fixtures/admin-search-fixtures.js
index e004e558b06..302a1f2af55 100644
--- a/frontend/discourse/tests/fixtures/admin-search-fixtures.js
+++ b/frontend/discourse/tests/fixtures/admin-search-fixtures.js
@@ -32,7 +32,7 @@ const adminSearchFixtures = {
],
reports: [
{
- type: "staff_logins",
+ type: "admin_logins",
title: "Admin Logins",
description: "List of admin login times with locations.",
description_link: null,
diff --git a/frontend/discourse/tests/fixtures/reports-bulk.js b/frontend/discourse/tests/fixtures/reports-bulk.js
index aaeda990e1b..52b00f3d0a0 100644
--- a/frontend/discourse/tests/fixtures/reports-bulk.js
+++ b/frontend/discourse/tests/fixtures/reports-bulk.js
@@ -154,10 +154,10 @@ const page_view_total_reqs = {
total: 921672,
};
-const staff_logins = JSON.parse(JSON.stringify(page_view_total_reqs));
-staff_logins.type = "staff_logins";
-staff_logins.modes = ["table"];
-staff_logins.report_key = `reports:staff_logins:start:end:[:prev_period]:50:${SCHEMA_VERSION}`;
+const admin_logins = JSON.parse(JSON.stringify(page_view_total_reqs));
+admin_logins.type = "admin_logins";
+admin_logins.modes = ["table"];
+admin_logins.report_key = `reports:admin_logins:start:end:[:prev_period]:50:${SCHEMA_VERSION}`;
const reportsBulkFixtures = {
"/admin/reports/bulk": {
@@ -168,7 +168,7 @@ const reportsBulkFixtures = {
signups_exception,
signups_timeout,
page_view_total_reqs,
- staff_logins,
+ admin_logins,
],
},
};
diff --git a/spec/jobs/export_csv_file_spec.rb b/spec/jobs/export_csv_file_spec.rb
index d9e150c1516..a113464902c 100644
--- a/spec/jobs/export_csv_file_spec.rb
+++ b/spec/jobs/export_csv_file_spec.rb
@@ -218,7 +218,7 @@ RSpec.describe Jobs::ExportCsvFile do
client_ip: "1.1.1.1",
created_at: "2010-01-01",
)
- exporter.extra["name"] = "staff_logins"
+ exporter.extra["name"] = "admin_logins"
report = export_report
diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb
index 52930301831..30488861ecd 100644
--- a/spec/models/report_spec.rb
+++ b/spec/models/report_spec.rb
@@ -1352,7 +1352,7 @@ RSpec.describe Report do
end
end
- describe "report_staff_logins" do
+ describe "report_admin_logins" do
let(:joffrey) { Fabricate(:admin, username: "joffrey") }
let(:robin) { Fabricate(:admin, username: "robin") }
let(:james) { Fabricate(:user, username: "james") }
@@ -1385,7 +1385,7 @@ RSpec.describe Report do
)
UserAuthToken.log(action: "generate", user_id: james.id)
- report = Report.find("staff_logins")
+ report = Report.find("admin_logins")
expect(report.data.length).to eq(3)
expect(report.data[0][:username]).to eq("joffrey")
diff --git a/spec/queries/reports/list_query_spec.rb b/spec/queries/reports/list_query_spec.rb
index 7b9c3af1675..fc6b9e7d619 100644
--- a/spec/queries/reports/list_query_spec.rb
+++ b/spec/queries/reports/list_query_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe Reports::ListQuery do
it "sorts reports by title" do
expect(result.map { |r| r[:title] }[0..5]).to eq(
[
- I18n.t("reports.staff_logins.title"),
+ I18n.t("reports.admin_logins.title"),
I18n.t("reports.page_view_anon_browser_reqs.title"),
I18n.t("reports.associated_accounts_by_provider.title"),
I18n.t("reports.bookmarks.title"),
@@ -107,7 +107,7 @@ RSpec.describe Reports::ListQuery do
it "sorts reports by title" do
expect(result.map { |r| r[:title] }[0..4]).to eq(
[
- I18n.t("reports.staff_logins.title"),
+ I18n.t("reports.admin_logins.title"),
I18n.t("reports.page_view_anon_browser_reqs.title"),
I18n.t("reports.dau_by_mau.title"),
I18n.t("reports.daily_engaged_users.title"),
diff --git a/spec/requests/admin/reports_controller_spec.rb b/spec/requests/admin/reports_controller_spec.rb
index 9f4c115dd50..bc045f0f361 100644
--- a/spec/requests/admin/reports_controller_spec.rb
+++ b/spec/requests/admin/reports_controller_spec.rb
@@ -221,6 +221,9 @@ RSpec.describe Admin::ReportsController do
topics: {
limit: 10,
},
+ admin_logins: {
+ limit: 10,
+ },
top_uploads: {
limit: 10,
},
@@ -228,9 +231,10 @@ RSpec.describe Admin::ReportsController do
}
expect(response.status).to eq(200)
- expect(response.parsed_body["reports"].count).to eq(2)
+ expect(response.parsed_body["reports"].count).to eq(3)
expect(response.parsed_body["reports"][0]["type"]).to eq("topics")
expect(response.parsed_body["reports"][1]).to include("error" => "not_found", "data" => nil)
+ expect(response.parsed_body["reports"][2]).to include("error" => "not_found", "data" => nil)
end
end
@@ -422,10 +426,12 @@ RSpec.describe Admin::ReportsController do
end
it "does not allow accessing admin-only reports" do
- get "/admin/reports/top_uploads.json"
+ Report::ADMIN_ONLY_REPORTS.each do |report_type|
+ get "/admin/reports/#{report_type}.json"
- expect(response.status).to eq(404)
- expect(response.parsed_body["errors"]).to include(I18n.t("not_found"))
+ expect(response.status).to eq(404)
+ expect(response.parsed_body["errors"]).to include(I18n.t("not_found"))
+ end
end
end