Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update styles for public private toggle, remove pms from post and top…
…ic reports
  • Loading branch information
awesomerobot committed Dec 12, 2025
commit 43936eff06b35ff86e53d2abc74a9897b5cf9f0b
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ def call
return FakeData if should_use_fake_data?
best_posts =
Post
.joins(:topic)
.where(user_id: user.id)
.where(created_at: date)
.where(deleted_at: nil)
.where(posts: { created_at: date, deleted_at: nil })
.where("post_number > 1")
.order("like_count DESC NULLS LAST, created_at ASC")
.where.not(topics: { archetype: Archetype.private_message })
.order("like_count DESC NULLS LAST, posts.created_at ASC")
.limit(3)
.select(:post_number, :topic_id, :like_count, :reply_count, :raw, :cooked)
.map do |post|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def call
.includes(:topic)
.references(:topic)
.where(topic: { deleted_at: nil, created_at: date, user_id: user.id })
.where.not(topic: { archetype: Archetype.private_message })
.order("yearly_score DESC NULLS LAST")
.limit(3)
.pluck(:topic_id, :title, :excerpt, :yearly_score)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const SCROLL_THRESHOLD = 0.7;

export default class Rewind extends Component {
@service dialog;
@service site;
@service currentUser;
@service toasts;

Expand Down Expand Up @@ -202,8 +201,10 @@ export default class Rewind extends Component {
return;
}

await this.dialog.yesNoConfirm({
await this.dialog.confirm({
message: i18n("discourse_rewind.share.confirm"),
confirmButtonLabel: "discourse_rewind.share.confirm_button.enable",
cancelButtonLabel: "discourse_rewind.share.confirm_button.disable",
didConfirm: async () => {
try {
const response = await ajax("/rewinds/toggle-share", {
Expand Down Expand Up @@ -311,17 +312,16 @@ export default class Rewind extends Component {
{{else}}
<div class="rewind__header-buttons">
{{#if this.canShare}}
{{#unless this.site.mobileView}}
<div class="rewind__share-toggle-wrapper">
<DToggleSwitch
@state={{this.currentUser.user_option.discourse_rewind_share_publicly}}
class="rewind__share-toggle"
{{on "click" this.toggleShareRewind}}
/>
{{i18n "discourse_rewind.share.toggle_label"}}
</div>

{{/unless}}
<div class="rewind__share-toggle-wrapper">
{{i18n "discourse_rewind.share.toggle_label.private"}}

<DToggleSwitch
@state={{this.currentUser.user_option.discourse_rewind_share_publicly}}
class="rewind__share-toggle"
{{on "click" this.toggleShareRewind}}
/>
{{i18n "discourse_rewind.share.toggle_label.public"}}
</div>

{{#if
this.currentUser.user_option.discourse_rewind_share_publicly
Expand All @@ -343,18 +343,9 @@ export default class Rewind extends Component {
}}
@action={{this.toggleFullScreen}}
/>

</div>
{{#if this.site.mobileView}}
<div class="rewind__share-toggle-wrapper">
<DToggleSwitch
@state={{this.currentUser.user_option.discourse_rewind_share_publicly}}
class="rewind__share-toggle"
{{on "click" this.toggleShareRewind}}
/>
{{i18n "discourse_rewind.share.toggle_label"}}
</div>

{{/if}}
<div
class="rewind__scroll-wrapper"
{{didInsert this.registerScrollWrapper}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
position: sticky;
z-index: 3;
color: var(--rewind-black);
display: flex;

.rewind-logo {
margin-bottom: 5px;
Expand Down
73 changes: 58 additions & 15 deletions plugins/discourse-rewind/assets/stylesheets/common/rewind.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,30 +147,73 @@
display: flex;
flex-direction: row;
position: absolute;
top: 16px;
top: 0;
right: 0;
z-index: 3;
right: 16px;
padding: 1em;

.rewind__share-toggle-wrapper {
.d-toggle-switch__checkbox-slider {
margin-right: 0.5em;
}
margin-left: auto;
display: flex;
align-items: center;
@media (width <= 650px) {
display: grid;
grid-template-columns: 1fr auto auto;
grid-template-rows: auto auto;
}
}

@include viewport.until(sm) {
.rewind__share-toggle-wrapper {
margin-left: auto;
display: flex;
padding: 0.5em;
align-items: center;
background-color: var(--rewind-beige);
z-index: 3;
position: absolute;
padding: var(--space-2) var(--space-4);
border-radius: 4px;
font-family: var(--pixel-text);
color: #5b5848;

@media (width <= 650px) {
border-radius: 0 0 4px 4px;
grid-column-start: 1;
grid-column-end: 3;
margin-top: 1.15em;
}

.d-toggle-switch__label {
&:hover {
.d-toggle-switch__checkbox-slider {
background: #b0a68a !important; // override core specificity
}
}
}

.d-toggle-switch__checkbox-slider {
margin-right: 0.5em;
margin-inline: var(--space-2);
border-radius: 2px;
background: #c5bfa0;

&:hover {
background: #b0a68a !important; // override core specificity
}

.d-icon-check {
display: none;
}

&::before {
height: 17px;
border-radius: 2px;
color: #d7d1b0;
box-shadow: -1px 1px 0 2px #afa88d;
background: #ede9d4;
}
}
}

@media (width <= 650px) {
.btn.no-text.--special-kbd {
grid-row-start: 1;
justify-self: end;

&:last-child {
margin-right: 1em;
}
}
}
}
Expand Down
13 changes: 9 additions & 4 deletions plugins/discourse-rewind/config/locales/client.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ en:
share_publicly: "Share Discourse Rewind summary with other forum members. Any forum member will be able to view your Discourse Rewind summary."
profile_link: "View your %{rewindYear} Discourse Rewind"
share:
toggle_label: "Share Discourse Rewind with other members"
confirm: "Are you sure you want to share your Discourse Rewind summary? This will make it visible to all members of this forum. Note that the report may contain private data like personal message excerpts. You can unshare at any time by clicking the share button again."
enabled_success: "Your Discourse Rewind summary is now shared with other forum members."
disabled_success: "Your Discourse Rewind summary is no longer shared with other forum members."
toggle_label:
private: "Private"
public: "Public"
confirm: "Be sure to review your Rewind before sharing, as it may include data from personal messages. You can make it private again at any time."
confirm_button:
enable: "Make public"
disable: "Keep private"
enabled_success: "Your Rewind is now sharable with other forum members."
disabled_success: "Your Rewind is now private."
reports:
activity_calendar:
title: Activity Calendar
Expand Down
18 changes: 18 additions & 0 deletions plugins/discourse-rewind/spec/actions/best_posts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,23 @@
expect(call_report[:data].map { |d| d[:post_number] }).not_to include(post_1.post_number)
end
end

context "when a post is in a private message" do
fab!(:pm_topic) { Fabricate(:private_message_topic, user: user) }
fab!(:pm_post) do
Fabricate(
:post,
created_at: random_datetime,
user: user,
post_number: 2,
topic: pm_topic,
like_count: 99,
)
end

it "is not included" do
expect(call_report[:data].map { |d| d[:topic_id] }).not_to include(pm_topic.id)
end
end
end
end
13 changes: 13 additions & 0 deletions plugins/discourse-rewind/spec/actions/best_topics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,18 @@
expect(call_report[:data].map { |d| d[:topic_id] }).not_to include(topic_1.id)
end
end

context "when a topic is a private message" do
fab!(:pm_topic) { Fabricate(:private_message_topic, user: user, created_at: random_datetime) }

before do
TopTopic.refresh!
TopTopic.find_by(topic_id: pm_topic.id)&.update!(yearly_score: 99)
end

it "is not included" do
expect(call_report[:data].map { |d| d[:topic_id] }).not_to include(pm_topic.id)
end
end
end
end