DEV: Use the new controller/period component for the dashboard (#435)

This commit is contained in:
Jarek Radosz 2024-01-19 13:27:33 +01:00 committed by GitHub
parent 5802cd1a0c
commit 4b4aedb50f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 30 additions and 53 deletions

View File

@ -1,3 +1,4 @@
< 3.2.0.beta5-dev: c70f43f130fb98e4a1adb1afd9b621aaa49088e3
< 3.2.0.beta4-dev: 493b48477a9288f2f1b6f021954088705a6673d6 < 3.2.0.beta4-dev: 493b48477a9288f2f1b6f021954088705a6673d6
< 3.2.0.beta2-dev: 3bced1c6f525553fe2b5b79d29bd66c1cf2a47d5 < 3.2.0.beta2-dev: 3bced1c6f525553fe2b5b79d29bd66c1cf2a47d5
3.1.999: c0415bb7eb878b1b7abf112d65cba981030df8df 3.1.999: c0415bb7eb878b1b7abf112d65cba981030df8df

View File

@ -1,38 +1,9 @@
import Controller from "@ember/controller"; import { computed } from "@ember/object";
import { action } from "@ember/object"; import AdminDashboardTabController from "admin/controllers/admin-dashboard-tab";
import { inject as service } from "@ember/service";
import getURL from "discourse-common/lib/get-url";
import discourseComputed from "discourse-common/utils/decorators";
import CustomDateRangeModal from "admin/components/modal/custom-date-range";
import PeriodComputationMixin from "admin/mixins/period-computation";
export default class AdminDashboardSentiment extends Controller.extend( export default class AdminDashboardSentiment extends AdminDashboardTabController {
PeriodComputationMixin @computed("startDate", "endDate")
) { get filters() {
@service modal; return { startDate: this.startDate, endDate: this.endDate };
@discourseComputed("startDate", "endDate")
filters(startDate, endDate) {
return { startDate, endDate };
}
_reportsForPeriodURL(period) {
return getURL(`/admin/dashboard/sentiment?period=${period}`);
}
@action
setCustomDateRange(startDate, endDate) {
this.setProperties({ startDate, endDate });
}
@action
openCustomDateRangeModal() {
this.modal.show(CustomDateRangeModal, {
model: {
startDate: this.startDate,
endDate: this.endDate,
setCustomDateRange: this.setCustomDateRange,
},
});
} }
} }

View File

@ -4,20 +4,14 @@
<h2> <h2>
{{i18n "discourse_ai.sentiments.dashboard.title"}} {{i18n "discourse_ai.sentiments.dashboard.title"}}
</h2> </h2>
<span>
<PeriodChooser <DashboardPeriodSelector
@period={{this.period}} @period={{this.period}}
@action={{action "changePeriod"}} @setPeriod={{this.setPeriod}}
@content={{this.availablePeriods}} @startDate={{this.startDate}}
@fullDay={{false}} @endDate={{this.endDate}}
/> @setCustomDateRange={{this.setCustomDateRange}}
<DButton />
@icon="cog"
class="custom-date-range-button"
@action={{this.openCustomDateRangeModal}}
@title="admin.dashboard.custom_date_range"
/>
</span>
</div> </div>
</div> </div>

View File

@ -1,8 +1,4 @@
.dashboard.dashboard-sentiment { .dashboard.dashboard-sentiment {
.sentiment {
margin-bottom: 1em;
}
.navigation-item.sentiment { .navigation-item.sentiment {
border-bottom: 0.4em solid var(--tertiary); border-bottom: 0.4em solid var(--tertiary);
} }

View File

@ -0,0 +1,15 @@
# frozen_string_literal: true
RSpec.describe "Admin dashboard", type: :system do
fab!(:admin)
it "displays the sentiment dashboard" do
SiteSetting.ai_sentiment_enabled = true
sign_in(admin)
visit "/admin"
find(".navigation-item.sentiment").click()
expect(page).to have_css(".section.sentiment")
end
end