InSync
(InSync)
February 20, 2022, 10:17pm
1
Hey
I want to create a component (header) in a theme that will only be visible to a certain group of users.
I’m use this script:
<script type='text/x-handlebars' data-template-name='/connectors/above-main-container/test'>
{{#if currentUser}}
<h1>Hello, {{currentUser.username}}!</h1>
{{/if}}
</script>
What should I replace this parameter {{#if currentUser}}
with so that only users from group “HackOneGroup” can see the component?
I try this {{#if group.name === "HackOneGroup"}}
but it’s wot work.
Please help
IAmGav
(Gavin Perch)
February 20, 2022, 10:52pm
2
maybe this will interest you
This component lets you render any topic as a banner on custom url paths.
The default look is pretty basic. The screenshot shows the default Welcome topic as a banner on the Latest list:
[Screenshot from 2022-01-27 14-42-15]
But banners will render various content that is supported on topics, e.g. emojis, animations, video links… So you could use (and abuse) this in many ways
In Settings, you select views by their relative url and topics by their id. You can also position the …
3 Likes
Alexander
(Alexander Barrios)
February 20, 2022, 11:01pm
3
const setups = parseSetups(settings.topic_banners);
createWidget("topic-banners", {
tagName: "div.topic-banner-container",
html() {
const router = getOwner(this).lookup("router:main");
const url = router.currentURL;
if(settings.show_to_group) {
const currentUser = getOwner(this).lookup("current-user:main");
const hasGroup = currentUser.groups.any(g => g.name === settings.show_to_group);
if (hasGroup == false) return;
}
if (settings.show_url) {
console.log("Current URL: ", url);
}
if (url && setups[url]) {
return createTopicBanner.call(this, url);
}
I think it might be similar to this what you are looking for
3 Likes
InSync
(InSync)
February 20, 2022, 11:43pm
4
I found this {{#if currentUser.staff}}
it’s work and show content only for the staff, but it’s didn’t work if I change staff to other, example: {{#if currentUser.trust_level_0}}