InSync
(InSync)
Février 20, 2022, 10:17
1
Salut
Je veux créer un composant (en-tête) dans un thème qui ne sera visible que par un certain groupe d’utilisateurs.
J’utilise ce script :
<script type='text/x-handlebars' data-template-name='/connectors/above-main-container/test'>
{{#if currentUser}}
<h1>Bonjour, {{currentUser.username}} !</h1>
{{/if}}
</script>
Par quoi dois-je remplacer ce paramètre {{#if currentUser}} afin que seuls les utilisateurs du groupe « HackOneGroup » puissent voir le composant ?
J’ai essayé ceci {{#if group.name === \"HackOneGroup\"}} mais ça ne fonctionne pas.
Aidez-moi svp
IAmGav
(Gavin Perch)
Février 20, 2022, 10:52
2
peut-être que cela vous intéressera
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 « J'aime »
Alexander
(Alexander Barrios)
Février 20, 2022, 11:01
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) {
Je pense que cela pourrait être similaire à ce que vous recherchez
3 « J'aime »
InSync
(InSync)
Février 20, 2022, 11:43
4
J’ai trouvé ceci {{#if currentUser.staff}}, cela fonctionne et affiche le contenu uniquement pour le personnel, mais cela ne fonctionne pas si je change staff en autre chose, par exemple : {{#if currentUser.trust_level_0}}
Le composant de thème CSS Classes for Current User's Groups pourrait-il aider ?
2 « J'aime »