Add number of unreviewed reports to admin dashboard and admin sidebar
closes #7109
This commit is contained in:
parent
c0b9d125fd
commit
327cabe6fe
9 changed files with 78 additions and 17 deletions
|
|
@ -30,6 +30,7 @@
|
|||
* Add OpenGraph video support [#7043](https://github.com/diaspora/diaspora/pull/7043)
|
||||
* You'll now get redirected to the invites page if you follow an invitation but you're already logged in [#7061](https://github.com/diaspora/diaspora/pull/7061)
|
||||
* Add support for setting BOSH access protocol via chat configuration [#7100](https://github.com/diaspora/diaspora/pull/7100)
|
||||
* Add number of unreviewed reports to admin dashboard and admin sidebar [#7109](https://github.com/diaspora/diaspora/pull/7109)
|
||||
|
||||
# 0.6.0.0
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
app.pages.AdminDashboard = Backbone.View.extend({
|
||||
initialize: function() {
|
||||
this.podVersionAlert = $("#pod-status .alert.pod-version");
|
||||
this.updatePodStatus();
|
||||
},
|
||||
|
||||
|
|
@ -38,15 +39,15 @@ app.pages.AdminDashboard = Backbone.View.extend({
|
|||
},
|
||||
|
||||
updatePodStatusSuccess: function() {
|
||||
$("#pod-status .alert").removeClass("alert-info");
|
||||
this.podVersionAlert.removeClass("alert-info");
|
||||
var podStatusMessage = Diaspora.I18n.t("admins.dashboard.up_to_date");
|
||||
if(this.podUpToDate()) {
|
||||
$("#pod-status .alert").addClass("alert-success");
|
||||
this.podVersionAlert.addClass("alert-success");
|
||||
} else {
|
||||
podStatusMessage = Diaspora.I18n.t("admins.dashboard.outdated");
|
||||
$("#pod-status .alert").addClass("alert-danger");
|
||||
this.podVersionAlert.addClass("alert-danger");
|
||||
}
|
||||
$("#pod-status .alert")
|
||||
this.podVersionAlert
|
||||
.html("<strong>" + podStatusMessage + "</strong>")
|
||||
.append(" ")
|
||||
.append(Diaspora.I18n.t("admins.dashboard.compare_versions", {
|
||||
|
|
@ -56,7 +57,7 @@ app.pages.AdminDashboard = Backbone.View.extend({
|
|||
},
|
||||
|
||||
updatePodStatusFail: function() {
|
||||
$("#pod-status .alert")
|
||||
this.podVersionAlert
|
||||
.removeClass("alert-info")
|
||||
.addClass("alert-warning")
|
||||
.text(Diaspora.I18n.t("admins.dashboard.error"));
|
||||
|
|
|
|||
|
|
@ -16,4 +16,8 @@ module ReportHelper
|
|||
raw t("report.not_found")
|
||||
end
|
||||
end
|
||||
|
||||
def unreviewed_reports_count
|
||||
@unreviewed_reports_count ||= Report.where(reviewed: false).size
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,7 +13,11 @@
|
|||
%li{role: "presentation", class: current_page?(pod_stats_path) && "active"}
|
||||
= link_to t(".pod_stats"), pod_stats_path
|
||||
%li{role: "presentation", class: current_page?(report_index_path) && "active"}
|
||||
= link_to t(".report"), report_index_path
|
||||
%a{href: report_index_path}
|
||||
- if unreviewed_reports_count > 0
|
||||
.pull-right.badge
|
||||
= unreviewed_reports_count
|
||||
= t(".report")
|
||||
%li{role: "presentation", class: current_page?(admin_pods_path) && "active"}
|
||||
= link_to t(".pod_network"), admin_pods_path
|
||||
%li{role: "presentation", class: current_page?(sidekiq_path) && "active"}
|
||||
|
|
|
|||
|
|
@ -6,5 +6,8 @@
|
|||
#pod-status
|
||||
%h2
|
||||
= t(".pod_status")
|
||||
.alert.alert-info{role: "alert"}
|
||||
.alert.alert-info.pod-version{role: "alert"}
|
||||
= t(".fetching_diaspora_version")
|
||||
- if unreviewed_reports_count > 0
|
||||
.alert.alert-warning.reports-warning{role: "alert"}
|
||||
= t("report.unreviewed_reports", count: unreviewed_reports_count)
|
||||
|
|
|
|||
|
|
@ -940,6 +940,10 @@ en:
|
|||
status:
|
||||
destroyed: "The post was destroyed"
|
||||
failed: "Something went wrong"
|
||||
unreviewed_reports:
|
||||
zero: "There are no unreviewed reports."
|
||||
one: "There is one unreviewed report."
|
||||
other: "There are %{count} unreviewed reports."
|
||||
|
||||
profiles:
|
||||
edit:
|
||||
|
|
|
|||
|
|
@ -10,6 +10,43 @@ describe AdminsController, :type => :controller do
|
|||
sign_in @user, scope: :user
|
||||
end
|
||||
|
||||
describe "#dashboard" do
|
||||
context "admin not signed in" do
|
||||
it "is behind redirect_unless_admin" do
|
||||
get :dashboard
|
||||
expect(response).to redirect_to stream_path
|
||||
end
|
||||
end
|
||||
|
||||
context "admin signed in" do
|
||||
before do
|
||||
Role.add_admin(@user.person)
|
||||
@post = bob.post(:status_message, text: "hello", to: bob.aspects.first.id)
|
||||
@post_report = alice.reports.create(
|
||||
item_id: @post.id, item_type: "Post",
|
||||
text: "offensive content"
|
||||
)
|
||||
end
|
||||
|
||||
it "succeeds" do
|
||||
get :dashboard
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it "warns the user about unreviewed reports" do
|
||||
get :dashboard
|
||||
expect(response.body).to match("reports-warning")
|
||||
expect(response.body).to include(I18n.t("report.unreviewed_reports", count: 1))
|
||||
end
|
||||
|
||||
it "doesn't show a report warning if there are no unreviewed reports" do
|
||||
@post_report.mark_as_reviewed
|
||||
get :dashboard
|
||||
expect(response.body).not_to match("reports-warning")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#user_search' do
|
||||
context 'admin not signed in' do
|
||||
it 'is behind redirect_unless_admin' do
|
||||
|
|
|
|||
|
|
@ -26,4 +26,11 @@ describe ReportHelper, type: :helper do
|
|||
.to include %(href="#{post_path(@post, anchor: @comment.guid)}")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#unreviewed_reports_count" do
|
||||
it "returns the number of unreviewed reports" do
|
||||
@comment_report.mark_as_reviewed
|
||||
expect(helper.unreviewed_reports_count).to be(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -139,28 +139,28 @@ describe("app.pages.AdminDashboard", function(){
|
|||
spyOn(this.view, "podUpToDate").and.returnValue(true);
|
||||
this.view.latestVersion = [0, 5, 1, 1];
|
||||
this.view.updatePodStatusSuccess();
|
||||
expect($("#pod-status .alert")).toHaveClass("alert-success");
|
||||
expect($("#pod-status .alert").text()).toContain("up to date");
|
||||
expect($("#pod-status .alert").text()).toContain("release is v0.5.1.1");
|
||||
expect($("#pod-status .alert").text()).toContain("pod is running v0.5.1.2");
|
||||
expect($("#pod-status .alert.pod-version")).toHaveClass("alert-success");
|
||||
expect($("#pod-status .alert.pod-version").text()).toContain("up to date");
|
||||
expect($("#pod-status .alert.pod-version").text()).toContain("release is v0.5.1.1");
|
||||
expect($("#pod-status .alert.pod-version").text()).toContain("pod is running v0.5.1.2");
|
||||
});
|
||||
|
||||
it("adds a 'danger' alert if the pod is up to date", function() {
|
||||
spyOn(this.view, "podUpToDate").and.returnValue(false);
|
||||
this.view.latestVersion = [0, 5, 1, 3];
|
||||
this.view.updatePodStatusSuccess();
|
||||
expect($("#pod-status .alert")).toHaveClass("alert-danger");
|
||||
expect($("#pod-status .alert").text()).toContain("outdated");
|
||||
expect($("#pod-status .alert").text()).toContain("release is v0.5.1.3");
|
||||
expect($("#pod-status .alert").text()).toContain("pod is running v0.5.1.2");
|
||||
expect($("#pod-status .alert.pod-version")).toHaveClass("alert-danger");
|
||||
expect($("#pod-status .alert.pod-version").text()).toContain("outdated");
|
||||
expect($("#pod-status .alert.pod-version").text()).toContain("release is v0.5.1.3");
|
||||
expect($("#pod-status .alert.pod-version").text()).toContain("pod is running v0.5.1.2");
|
||||
});
|
||||
});
|
||||
|
||||
describe("updatePodStatusFail", function() {
|
||||
it("adds a 'warning' alert", function() {
|
||||
this.view.updatePodStatusFail();
|
||||
expect($("#pod-status .alert")).toHaveClass("alert-warning");
|
||||
expect($("#pod-status .alert").text()).toContain("Unable to determine");
|
||||
expect($("#pod-status .alert.pod-version")).toHaveClass("alert-warning");
|
||||
expect($("#pod-status .alert.pod-version").text()).toContain("Unable to determine");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue