InSync
(InSync)
20 Febbraio 2022, 10:17pm
1
Ehi
Voglio creare un componente (header) in un tema che sarĂ visibile solo a un certo gruppo di utenti.
Sto usando questo script:
<script type='text/x-handlebars' data-template-name='/connectors/above-main-container/test'>
{{#if currentUser}}
<h1>Ciao, {{currentUser.username}}!</h1>
{{/if}}
</script>
Con cosa dovrei sostituire questo parametro {{#if currentUser}} in modo che solo gli utenti del gruppo “HackOneGroup” possano vedere il componente?
Ho provato questo {{#if group.name === "HackOneGroup"}} ma non funziona.
Per favore, aiutami
IAmGav
(Gavin Perch)
20 Febbraio 2022, 10:52pm
2
forse questo ti interesserĂ
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 Mi Piace
Alexander
(Alexander Barrios)
20 Febbraio 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");
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) {
Penso che potrebbe essere simile a quello che stai cercando
3 Mi Piace
InSync
(InSync)
20 Febbraio 2022, 11:43pm
4
Ho trovato questo {{#if currentUser.staff}} funziona e mostra il contenuto solo per lo staff, ma non funziona se cambio staff con altro, ad esempio: {{#if currentUser.trust_level_0}}
Il componente del tema CSS Classes for Current User's Groups potrebbe aiutare?
2 Mi Piace