-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV: Add compatibility with the Glimmer post menu (#310)
This commit adds compatibility with the Glimmer post menu, updating the code to use the latest proposed API while maintaining compatibility with the legacy widget-based system.
- Loading branch information
Showing
4 changed files
with
150 additions
and
52 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
assets/javascripts/discourse/components/discourse-reactions-actions-button.gjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { hash } from "@ember/helper"; | ||
import MountWidget from "discourse/components/mount-widget"; | ||
|
||
const ReactionsActionButton = <template> | ||
{{! template-lint-disable no-capital-arguments }} | ||
<MountWidget | ||
@widget="discourse-reactions-actions" | ||
@args={{hash post=@post}} | ||
/> | ||
</template>; | ||
|
||
export default ReactionsActionButton; |
34 changes: 34 additions & 0 deletions
34
assets/javascripts/discourse/components/discourse-reactions-actions-summary.gjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Component from "@glimmer/component"; | ||
import { hash } from "@ember/helper"; | ||
import MountWidget from "discourse/components/mount-widget"; | ||
|
||
export default class ReactionsActionSummary extends Component { | ||
static extraControls = true; | ||
|
||
static shouldRender(args, context, owner) { | ||
const site = owner.lookup("service:site"); | ||
|
||
if (site.mobileView || args.post.deleted) { | ||
return false; | ||
} | ||
|
||
const siteSettings = owner.lookup("service:site-settings"); | ||
const mainReaction = siteSettings.discourse_reactions_reaction_for_like; | ||
|
||
return !( | ||
args.post.reactions && | ||
args.post.reactions.length === 1 && | ||
args.post.reactions[0].id === mainReaction | ||
); | ||
} | ||
|
||
<template> | ||
{{#if @shouldRender}} | ||
{{! template-lint-disable no-capital-arguments }} | ||
<MountWidget | ||
@widget="discourse-reactions-actions" | ||
@args={{hash post=@post position="left"}} | ||
/> | ||
{{/if}} | ||
</template> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters