FEATURE: Add links to filtered emotion view on emotion dashboard table (#953)

This commit is contained in:
Rafael dos Santos Silva 2024-11-25 15:51:01 -03:00 committed by GitHub
parent 79021252e9
commit 6c25718a7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 45 additions and 14 deletions

View File

@ -6,14 +6,18 @@
</div>
<div class="cell value today-count">
<a href={{this.todayLink}}>
{{number this.model.todayCount}}
</a>
</div>
<div
class="cell value yesterday-count {{this.model.yesterdayTrend}}"
title={{this.model.yesterdayCountTitle}}
>
<a href={{this.yesterdayLink}}>
{{number this.model.yesterdayCount}}
</a>
{{d-icon this.model.yesterdayTrendIcon}}
</div>
@ -21,7 +25,9 @@
class="cell value sevendays-count {{this.model.sevenDaysTrend}}"
title={{this.model.sevenDaysCountTitle}}
>
<a href={{this.lastSevenDaysLink}}>
{{number this.model.lastSevenDaysCount}}
</a>
{{d-icon this.model.sevenDaysTrendIcon}}
</div>
@ -29,7 +35,10 @@
class="cell value thirty-days-count {{this.model.thirtyDaysTrend}}"
title={{this.model.thirtyDaysCountTitle}}
>
<a href={{this.lastThirtyDaysLink}}>
{{number this.model.lastThirtyDaysCount}}
</a>
{{#if this.model.canDisplayTrendIcon}}
{{d-icon this.model.thirtyDaysTrendIcon}}
{{/if}}

View File

@ -5,23 +5,35 @@ import getURL from "discourse-common/lib/get-url";
@classNames("admin-report-counters")
@attributeBindings("model.description:title")
export default class AdminReportEmotion extends Component {
get filterURL() {
return getURL(`/filter?q=`);
get todayLink() {
let date = moment().format("YYYY-MM-DD");
return this._filterURL(date);
}
get today() {
return moment().format("YYYY-MM-DD");
get yesterdayLink() {
let date = moment().subtract(1, "day").format("YYYY-MM-DD");
return this._filterURL(date);
}
get yesterday() {
return moment().subtract(1, "day").format("YYYY-MM-DD");
get lastSevenDaysLink() {
let date = moment().subtract(1, "week").format("YYYY-MM-DD");
return this._filterURL(date);
}
get lastWeek() {
return moment().subtract(1, "week").format("YYYY-MM-DD");
get lastThirtyDaysLink() {
let date = moment().subtract(1, "month").format("YYYY-MM-DD");
return this._filterURL(date);
}
get lastMonth() {
return moment().subtract(1, "month").format("YYYY-MM-DD");
_baseFilter() {
return "/filter?q=activity-after%3A";
}
_model() {
return "%20order%3A" + this.model.type;
}
_filterURL(date) {
return getURL(`${this._baseFilter()}${date}${this._model()}`);
}
}

View File

@ -12,4 +12,14 @@ RSpec.describe "Admin dashboard", type: :system do
expect(page).to have_css(".section.sentiment")
end
xit "displays the emotion table with links" do
SiteSetting.ai_sentiment_enabled = true
sign_in(admin)
visit "/admin"
find(".navigation-item.sentiment").click()
expect(page).to have_css(".admin-report.emotion-love .cell.value.today-count a")
end
end