DEV: Remove topic-entrance from the glimmer topic list (#28942)

the (anecdotal) low usage of this component might no longer justify the continued maintenance (and perf impact)
This commit is contained in:
Jarek Radosz 2024-09-17 14:15:54 +02:00 committed by GitHub
parent 62d00722e1
commit 3eada7b572
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 126 deletions

View File

@ -1,6 +1,5 @@
import { on } from "@ember/modifier";
import { htmlSafe } from "@ember/template";
import TopicEntrance from "discourse/components/topic-list/topic-entrance";
import TopicPostBadges from "discourse/components/topic-post-badges";
import TopicStatus from "discourse/components/topic-status";
import formatAge from "discourse/helpers/format-age";
@ -30,13 +29,11 @@ const FeaturedTopic = <template>
@url={{@topic.lastUnreadUrl}}
/>
<TopicEntrance @topic={{@topic}}>
<a
{{on "click" onTimestampClick}}
href={{@topic.lastPostUrl}}
class="last-posted-at"
>{{formatAge @topic.last_posted_at}}</a>
</TopicEntrance>
<a
{{on "click" onTimestampClick}}
href={{@topic.lastPostUrl}}
class="last-posted-at"
>{{formatAge @topic.last_posted_at}}</a>
</div>
</template>;

View File

@ -2,7 +2,6 @@ import Component from "@glimmer/component";
import { hash } from "@ember/helper";
import { service } from "@ember/service";
import PluginOutlet from "discourse/components/plugin-outlet";
import TopicEntrance from "discourse/components/topic-list/topic-entrance";
import element from "discourse/helpers/element";
import number from "discourse/helpers/number";
import I18n from "discourse-i18n";
@ -55,17 +54,13 @@ export default class PostsCountColumn extends Component {
<this.wrapperElement
class="num posts-map posts {{this.likesHeat}} topic-list-data"
>
<TopicEntrance
@topic={{@topic}}
@title={{this.title}}
@triggerClass="btn-link posts-map badge-posts {{this.likesHeat}}"
>
<a href={{@topic.firstPostUrl}} class="badge-posts">
<PluginOutlet
@name="topic-list-before-reply-count"
@outletArgs={{hash topic=@topic}}
/>
{{number @topic.replyCount noTitle="true"}}
</TopicEntrance>
</a>
</this.wrapperElement>
</template>
}

View File

@ -1,111 +0,0 @@
import Component from "@glimmer/component";
import { fn } from "@ember/helper";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import { service } from "@ember/service";
import { htmlSafe } from "@ember/template";
import DiscourseURL from "discourse/lib/url";
import icon from "discourse-common/helpers/d-icon";
import i18n from "discourse-common/helpers/i18n";
import I18n from "discourse-i18n";
import DMenu from "float-kit/components/d-menu";
function entranceDate(dt, showTime) {
const today = new Date();
if (dt.toDateString() === today.toDateString()) {
return moment(dt).format(I18n.t("dates.time"));
}
if (dt.getYear() === today.getYear()) {
// No year
return moment(dt).format(
showTime
? I18n.t("dates.long_date_without_year_with_linebreak")
: I18n.t("dates.long_no_year_no_time")
);
}
return moment(dt).format(
showTime
? I18n.t("dates.long_date_with_year_with_linebreak")
: I18n.t("dates.long_date_with_year_without_time")
);
}
export default class TopicEntrance extends Component {
@service historyStore;
get createdDate() {
return new Date(this.args.topic.created_at);
}
get bumpedDate() {
return new Date(this.args.topic.bumped_at);
}
get showTime() {
return (
this.bumpedDate.getTime() - this.createdDate.getTime() <
1000 * 60 * 60 * 24 * 2
);
}
get topDate() {
return entranceDate(this.createdDate, this.showTime);
}
get bottomDate() {
return entranceDate(this.bumpedDate, this.showTime);
}
@action
jumpTo(destination) {
this.historyStore.set("lastTopicIdViewed", this.args.topic.id);
DiscourseURL.routeTo(destination);
}
<template>
<DMenu
@title={{@title}}
@ariaLabel={{@title}}
@placement="center"
@autofocus={{true}}
@triggerClass={{@triggerClass}}
>
<:trigger>
{{yield}}
</:trigger>
<:content>
<div id="topic-entrance" class="--glimmer">
<button
{{on "click" (fn this.jumpTo @topic.url)}}
aria-label={{i18n
"topic_entrance.sr_jump_top_button"
date=this.topDate
}}
title={{i18n "topic_entrance.jump_top_button_title"}}
class="btn btn-default full jump-top"
>
{{icon "backward-step"}}
{{htmlSafe this.topDate}}
</button>
<button
{{on "click" (fn this.jumpTo @topic.lastPostUrl)}}
aria-label={{i18n
"topic_entrance.sr_jump_bottom_button"
date=this.bottomDate
}}
title={{i18n "topic_entrance.jump_bottom_button_title"}}
class="btn btn-default full jump-bottom"
>
{{htmlSafe this.bottomDate}}
{{icon "forward-step"}}
</button>
</div>
</:content>
</DMenu>
</template>
}

View File

@ -329,6 +329,7 @@
.badge-posts {
font-weight: 700;
color: inherit;
display: inline-block;
padding: 15px 5px;
}
}