mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-06-28 18:42:16 +00:00
DEV: Update sidebar grouping date labels (#1290)
- Add `Today` label - Make some minor UX changes - Add specs
This commit is contained in:
parent
81ef532268
commit
b6630b670f
@ -87,6 +87,7 @@ export default {
|
|||||||
@tracked links = new TrackedArray();
|
@tracked links = new TrackedArray();
|
||||||
@tracked topics = [];
|
@tracked topics = [];
|
||||||
@tracked hasMore = [];
|
@tracked hasMore = [];
|
||||||
|
@tracked loadedTodayLabel = false;
|
||||||
@tracked loadedSevenDayLabel = false;
|
@tracked loadedSevenDayLabel = false;
|
||||||
@tracked loadedThirtyDayLabel = false;
|
@tracked loadedThirtyDayLabel = false;
|
||||||
@tracked loadedMonthLabels = new Set();
|
@tracked loadedMonthLabels = new Set();
|
||||||
@ -133,6 +134,7 @@ export default {
|
|||||||
|
|
||||||
addNewPMToSidebar(topic) {
|
addNewPMToSidebar(topic) {
|
||||||
// Reset category labels since we're adding a new topic
|
// Reset category labels since we're adding a new topic
|
||||||
|
this.loadedTodayLabel = false;
|
||||||
this.loadedSevenDayLabel = false;
|
this.loadedSevenDayLabel = false;
|
||||||
this.loadedThirtyDayLabel = false;
|
this.loadedThirtyDayLabel = false;
|
||||||
this.loadedMonthLabels.clear();
|
this.loadedMonthLabels.clear();
|
||||||
@ -225,8 +227,18 @@ export default {
|
|||||||
(now - lastPostedAt) / (1000 * 60 * 60 * 24)
|
(now - lastPostedAt) / (1000 * 60 * 60 * 24)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (daysDiff <= 1 || !topic.last_posted_at) {
|
||||||
|
if (!this.loadedTodayLabel) {
|
||||||
|
this.loadedTodayLabel = true;
|
||||||
|
return {
|
||||||
|
text: i18n("discourse_ai.ai_bot.conversations.today"),
|
||||||
|
classNames: "date-heading",
|
||||||
|
name: "date-heading-today",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
// Last 7 days group
|
// Last 7 days group
|
||||||
if (daysDiff <= 7) {
|
else if (daysDiff <= 7) {
|
||||||
if (!this.loadedSevenDayLabel) {
|
if (!this.loadedSevenDayLabel) {
|
||||||
this.loadedSevenDayLabel = true;
|
this.loadedSevenDayLabel = true;
|
||||||
return {
|
return {
|
||||||
@ -273,6 +285,7 @@ export default {
|
|||||||
|
|
||||||
buildSidebarLinks() {
|
buildSidebarLinks() {
|
||||||
// Reset date header tracking
|
// Reset date header tracking
|
||||||
|
this.loadedTodayLabel = false;
|
||||||
this.loadedSevenDayLabel = false;
|
this.loadedSevenDayLabel = false;
|
||||||
this.loadedThirtyDayLabel = false;
|
this.loadedThirtyDayLabel = false;
|
||||||
this.loadedMonthLabels.clear();
|
this.loadedMonthLabels.clear();
|
||||||
|
@ -33,10 +33,7 @@ body.has-ai-conversations-sidebar {
|
|||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
|
font-size: var(--font-down-2);
|
||||||
&[data-link-name="date-heading-last-7-days"] {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-section-link {
|
.sidebar-section-link {
|
||||||
@ -236,12 +233,6 @@ body.has-ai-conversations-sidebar {
|
|||||||
max-height: 2.5em;
|
max-height: 2.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.spinner {
|
|
||||||
margin: 0;
|
|
||||||
width: 2em;
|
|
||||||
height: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ai-bot-conversations-input {
|
#ai-bot-conversations-input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
@ -727,6 +727,7 @@ en:
|
|||||||
new: "New Question"
|
new: "New Question"
|
||||||
min_input_length_message: "Message must be longer than 10 characters"
|
min_input_length_message: "Message must be longer than 10 characters"
|
||||||
messages_sidebar_title: "Conversations"
|
messages_sidebar_title: "Conversations"
|
||||||
|
today: "Today"
|
||||||
last_7_days: "Last 7 days"
|
last_7_days: "Last 7 days"
|
||||||
last_30_days: "Last 30 days"
|
last_30_days: "Last 30 days"
|
||||||
sentiments:
|
sentiments:
|
||||||
|
@ -151,11 +151,20 @@ RSpec.describe "AI Bot - Homepage", type: :system do
|
|||||||
|
|
||||||
expect(ai_pm_homepage).to have_homepage
|
expect(ai_pm_homepage).to have_homepage
|
||||||
expect(sidebar).to have_section("ai-conversations-history")
|
expect(sidebar).to have_section("ai-conversations-history")
|
||||||
expect(sidebar).to have_section_link("Last 7 days")
|
expect(sidebar).to have_section_link("Today")
|
||||||
expect(sidebar).to have_section_link(pm.title)
|
expect(sidebar).to have_section_link(pm.title)
|
||||||
expect(sidebar).to have_no_css("button.ai-new-question-button")
|
expect(sidebar).to have_no_css("button.ai-new-question-button")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "displays last_7_days label in the sidebar" do
|
||||||
|
pm.update!(last_posted_at: Time.zone.now - 5.days)
|
||||||
|
visit "/"
|
||||||
|
header.click_bot_button
|
||||||
|
|
||||||
|
expect(ai_pm_homepage).to have_homepage
|
||||||
|
expect(sidebar).to have_section_link("Last 7 days")
|
||||||
|
end
|
||||||
|
|
||||||
it "displays last_30_days label in the sidebar" do
|
it "displays last_30_days label in the sidebar" do
|
||||||
pm.update!(last_posted_at: Time.zone.now - 28.days)
|
pm.update!(last_posted_at: Time.zone.now - 28.days)
|
||||||
visit "/"
|
visit "/"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user