mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-06-27 01:52:18 +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 topics = [];
|
||||
@tracked hasMore = [];
|
||||
@tracked loadedTodayLabel = false;
|
||||
@tracked loadedSevenDayLabel = false;
|
||||
@tracked loadedThirtyDayLabel = false;
|
||||
@tracked loadedMonthLabels = new Set();
|
||||
@ -133,6 +134,7 @@ export default {
|
||||
|
||||
addNewPMToSidebar(topic) {
|
||||
// Reset category labels since we're adding a new topic
|
||||
this.loadedTodayLabel = false;
|
||||
this.loadedSevenDayLabel = false;
|
||||
this.loadedThirtyDayLabel = false;
|
||||
this.loadedMonthLabels.clear();
|
||||
@ -225,8 +227,18 @@ export default {
|
||||
(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
|
||||
if (daysDiff <= 7) {
|
||||
else if (daysDiff <= 7) {
|
||||
if (!this.loadedSevenDayLabel) {
|
||||
this.loadedSevenDayLabel = true;
|
||||
return {
|
||||
@ -273,6 +285,7 @@ export default {
|
||||
|
||||
buildSidebarLinks() {
|
||||
// Reset date header tracking
|
||||
this.loadedTodayLabel = false;
|
||||
this.loadedSevenDayLabel = false;
|
||||
this.loadedThirtyDayLabel = false;
|
||||
this.loadedMonthLabels.clear();
|
||||
|
@ -33,10 +33,7 @@ body.has-ai-conversations-sidebar {
|
||||
opacity: 0.8;
|
||||
font-weight: 700;
|
||||
margin-top: 1em;
|
||||
|
||||
&[data-link-name="date-heading-last-7-days"] {
|
||||
margin-top: 0;
|
||||
}
|
||||
font-size: var(--font-down-2);
|
||||
}
|
||||
|
||||
.sidebar-section-link {
|
||||
@ -236,12 +233,6 @@ body.has-ai-conversations-sidebar {
|
||||
max-height: 2.5em;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
margin: 0;
|
||||
width: 2em;
|
||||
height: 2em;
|
||||
}
|
||||
|
||||
#ai-bot-conversations-input {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
|
@ -727,6 +727,7 @@ en:
|
||||
new: "New Question"
|
||||
min_input_length_message: "Message must be longer than 10 characters"
|
||||
messages_sidebar_title: "Conversations"
|
||||
today: "Today"
|
||||
last_7_days: "Last 7 days"
|
||||
last_30_days: "Last 30 days"
|
||||
sentiments:
|
||||
|
@ -151,11 +151,20 @@ RSpec.describe "AI Bot - Homepage", type: :system do
|
||||
|
||||
expect(ai_pm_homepage).to have_homepage
|
||||
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_no_css("button.ai-new-question-button")
|
||||
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
|
||||
pm.update!(last_posted_at: Time.zone.now - 28.days)
|
||||
visit "/"
|
||||
|
Loading…
x
Reference in New Issue
Block a user