InSync
(InSync)
20.Февраль.2022 22:17:22
1
Привет
Я хочу создать компонент (шапку) в теме, который будет виден только определённой группе пользователей.
Я использую этот скрипт:
<script type='text/x-handlebars' data-template-name='/connectors/above-main-container/test'>
{{#if currentUser}}
<h1>Привет, {{currentUser.username}}!</h1>
{{/if}}
</script>
На что мне заменить параметр {{#if currentUser}}, чтобы компонент видели только пользователи из группы “HackOneGroup”?
Я пробовал {{#if group.name === "HackOneGroup"}}, но это не работает.
Пожалуйста, помогите
IAmGav
(Gavin Perch)
20.Февраль.2022 22:52:03
2
Возможно, это вас заинтересует
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…
Alexander
(Alexander Barrios)
20.Февраль.2022 23:01:04
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");
if (currentUser == null) return;
else {
const hasGroup = currentUser.groups.any((g) => g.name === settings.show_to_group);
if (hasGroup == false) return;
}
}
if (settings.show_to_visitors) {
const currentUser = getOwner(this).lookup("current-user:main");
if (currentUser !== null) return;
}
if (settings.show_url) {
Кажется, вот то, что вы ищете:
InSync
(InSync)
20.Февраль.2022 23:43:50
4
Я нашел это {{#if currentUser.staff}}, это работает и показывает контент только для сотрудников, но не работает, если я изменю staff на другое, например: {{#if currentUser.trust_level_0}}