Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invited users skip gates #6118

Merged
merged 11 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/app/src/components/home/CurrentChatMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
color={membersSelected ? "var(--icon-selected)" : "var(--icon-txt)"} />
</HoverIcon>
</span>
{#if client.canInviteUsers(selectedChatSummary.id)}
{#if selectedChatSummary.public || client.canInviteUsers(selectedChatSummary.id)}
hpeebles marked this conversation as resolved.
Show resolved Hide resolved
<span on:click={showInviteGroupUsers}>
<HoverIcon
title={interpolate(
Expand Down
14 changes: 5 additions & 9 deletions frontend/app/src/components/home/GroupPermissionsEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

$: {
if (!editing) {
permissions.mentionAllMembers = isPublic && isCommunityPublic
? "admin"
: "member";
permissions.mentionAllMembers = isPublic && isCommunityPublic ? "admin" : "member";
}
}

Expand Down Expand Up @@ -47,12 +45,10 @@
{roles}
label={i18nKey("permissions.updateGroup")}
bind:rolePermission={permissions.updateGroup} />
{#if !isPublic}
<SelectPermissionRole
{roles}
label={i18nKey("permissions.inviteUsers")}
bind:rolePermission={permissions.inviteUsers} />
{/if}
<SelectPermissionRole
{roles}
label={i18nKey("permissions.inviteUsers")}
bind:rolePermission={permissions.inviteUsers} />
<SelectPermissionRole
{roles}
label={i18nKey("permissions.removeMembers")}
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/src/components/home/Home.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@
/**
* When we try to join a group we need to first scrutinise the access gates and
* see whether any of them require client side action before we can proceed with the
* call to the back end. I there are gates which require action, we need to perform
* call to the back end. If there are gates which require action, we need to perform
* those actions one by one until they are all done and then feed their results
* back into this function.
*/
Expand All @@ -857,7 +857,7 @@
const credentials = gateCheck?.credentials ?? [];

if (gateCheck === undefined) {
const gates = client.accessGatesForChat(group);
const gates = client.accessGatesForChat(group, true);
const passed = client.doesUserMeetAccessGates(gates);

if (!passed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import { fade } from "svelte/transition";
import AccessGateSummary from "./AccessGateSummary.svelte";
import type { AccessGate, Level } from "openchat-client";
import ErrorMessage from "../../ErrorMessage.svelte";
import Translatable from "../../Translatable.svelte";
import { i18nKey } from "../../../i18n/i18n";

export let gate: AccessGate;
export let level: Level;
Expand All @@ -20,6 +23,12 @@
<div class="choose-gate">
<AccessGateSummary showNoGate={true} bind:valid {level} editable bind:gate />
</div>
{#if gate.kind !== "no_gate"}
<ErrorMessage>
<Translatable
resourceKey={i18nKey("access.bypassWarning", undefined, level, true)} />
</ErrorMessage>
{/if}
</div>
</div>

Expand Down Expand Up @@ -51,6 +60,6 @@
}

.choose-gate {
margin-bottom: $sp3;
margin-bottom: $sp4;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
};

if (gateCheck === undefined) {
if ($selectedCommunity.gate.kind !== "no_gate") {
if ($selectedCommunity.gate.kind !== "no_gate" && !$selectedCommunity.isInvited) {
const gates = [$selectedCommunity.gate];
const passed = client.doesUserMeetAccessGates(gates);
if (!passed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,7 @@
</div>
<div use:menuCloser class="permissions" class:visible={step === 3}>
{#if canEditPermissions}
<PermissionsEditor
isPublic={candidate.public}
bind:permissions={candidate.permissions} />
<PermissionsEditor bind:permissions={candidate.permissions} />
{:else}
<PermissionsViewer
isPublic={candidate.public}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
import { i18nKey } from "../../../../i18n/i18n";

export let permissions: CommunityPermissions;
export let isPublic: boolean;

const selectors = Object.keys(permissions)
.filter((p) => !isPublic || p !== "inviteUsers")
.map<[keyof CommunityPermissions, string]>((p) => [
p as keyof CommunityPermissions,
`permissions.${p}`,
]);
const selectors = Object.keys(permissions).map<[keyof CommunityPermissions, string]>((p) => [
p as keyof CommunityPermissions,
`permissions.${p}`,
]);
</script>

{#each selectors as [key, resourceKey]}
Expand Down
56 changes: 28 additions & 28 deletions frontend/app/src/components/home/groupdetails/InviteUsers.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
export let level: Level;
export let container: MultiUserChat | CommunitySummary;

$: canInvite =
client.canInviteUsers(container.id) &&
(container.kind !== "channel" || !client.isChatPrivate(container));
$: canInvite = client.canInviteUsers(container.id);

const dispatch = createEventDispatcher();
let usersToInvite: UserSummary[] = [];
Expand Down Expand Up @@ -68,38 +66,40 @@

{#if !busy}
<div class="find-user">
<CollapsibleCard open headerText={i18nKey("searchForUsername")}>
<SelectUsers
{userLookup}
mode={"edit"}
on:selectUser={selectUser}
on:deleteUser={deleteUser}
selectedUsers={usersToInvite} />
</CollapsibleCard>
{#if canInvite}
<CollapsibleCard
open
headerText={i18nKey("invite.inviteWithLink", undefined, container.level, true)}>
<InviteUsersWithLink {container} />
<CollapsibleCard open headerText={i18nKey("searchForUsername")}>
<SelectUsers
{userLookup}
mode={"edit"}
on:selectUser={selectUser}
on:deleteUser={deleteUser}
selectedUsers={usersToInvite} />
</CollapsibleCard>
{/if}
<CollapsibleCard
open
headerText={i18nKey("invite.inviteWithLink", undefined, container.level, true)}>
<InviteUsersWithLink {container} />
</CollapsibleCard>
</div>
{/if}

{#if busy}
<Loading />
{/if}
{#if canInvite}
{#if busy}
<Loading />
{/if}

<div class="cta">
<Button
disabled={busy || usersToInvite.length === 0}
loading={busy}
square
on:click={inviteUsers}
fill
><Translatable
resourceKey={i18nKey("group.inviteUsers", undefined, level, true)} /></Button>
</div>
<div class="cta">
<Button
disabled={busy || usersToInvite.length === 0}
loading={busy}
square
on:click={inviteUsers}
fill
><Translatable
resourceKey={i18nKey("group.inviteUsers", undefined, level, true)} /></Button>
</div>
{/if}

<style lang="scss">
:global(.find-user .find-user .search-form) {
Expand Down
52 changes: 29 additions & 23 deletions frontend/app/src/components/home/groupdetails/Members.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import Translatable from "../../Translatable.svelte";
import { i18nKey } from "../../../i18n/i18n";
import { trimLeadingAtSymbol } from "../../../utils/user";
import ButtonGroup from "../../ButtonGroup.svelte";

const MAX_SEARCH_RESULTS = 255; // irritatingly this is a nat8 in the candid
const client = getContext<OpenChat>("client");
Expand Down Expand Up @@ -54,9 +55,8 @@
$: invitedUsers = Array.from(invited)
.map((userId) => $userStore[userId])
.filter((u) => matchesSearch(searchTermLower, u) && u.userId !== userId);
$: publicCollection = collection.public;
$: showBlocked = publicCollection && blockedUsers.length > 0;
$: showInvited = !publicCollection && invitedUsers.length > 0;
$: showBlocked = blockedUsers.length > 0;
$: showInvited = invitedUsers.length > 0;
$: canInvite = client.canInviteUsers(collection.id);
//$: platformModerator = client.platformModerator;
//$: canPromoteMyselfToOwner = me !== undefined && me.role !== "owner" && $platformModerator;
Expand Down Expand Up @@ -206,22 +206,25 @@
</div>

{#if showBlocked || showInvited}
<div class="section-selector">
<SelectionButton
title={$_("members")}
on:click={() => setView("members")}
selected={memberView === "members"} />
{#if showBlocked}
<div class="member-section-selector">
<ButtonGroup align="fill">
<SelectionButton
title={$_("blocked")}
on:click={() => setView("blocked")}
selected={memberView === "blocked"} />
{:else}
<SelectionButton
title={$_("invited")}
on:click={() => setView("invited")}
selected={memberView === "invited"} />
{/if}
title={$_("members")}
on:click={() => setView("members")}
selected={memberView === "members"} />
{#if showInvited}
<SelectionButton
title={$_("invited")}
on:click={() => setView("invited")}
selected={memberView === "invited"} />
{/if}
{#if showBlocked}
<SelectionButton
title={$_("blocked")}
on:click={() => setView("blocked")}
selected={memberView === "blocked"} />
{/if}
</ButtonGroup>
</div>
{/if}

Expand Down Expand Up @@ -285,13 +288,16 @@
{/if}

<style lang="scss">
.section-selector {
display: flex;
justify-content: flex-start;
:global(.member-section-selector .button-group.fill) {
flex-wrap: nowrap;
}
:global(.member-section-selector button) {
padding: $sp2 0 !important;
}

.member-section-selector {
margin: 0 $sp4 $sp4 $sp4;
gap: $sp3;
@include mobile() {
justify-content: space-evenly;
margin: 0 $sp3 $sp3 $sp3;
}
}
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/i18n/cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"amountN": "{n} 代币数量",
"and": "要求所有门",
"approvePaymentTitle": "批准付款",
"bypassWarning": "⚠️ 任何明确受邀参加此 {level} 的用户都无需通过访问门",
"cannotMakePublic": "您不能将私有的 {level} 设为公开,因为这会危及现有成员的隐私。",
"chooseGate": "选择一个门禁",
"chooseNervousSystem": "选择神经系统",
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"amountN": "Anzahl {n} Token",
"and": "Alle Tore anfordern",
"approvePaymentTitle": "Zahlung genehmigen",
"bypassWarning": "⚠️ Benutzer, die ausdrücklich zu diesem {level} eingeladen sind, müssen die Zugangstore nicht passieren.",
"cannotMakePublic": "Sie können ein privates {level} nicht öffentlich machen, da dies die Privatsphäre der bestehenden Mitglieder gefährden würde.",
"chooseGate": "Wählen Sie ein Zugangstor",
"chooseNervousSystem": "Wählen Sie das Nervensystem",
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"amountN": "Amount {n} tokens",
"and": "Require all gates",
"approvePaymentTitle": "Approve payment",
"bypassWarning": "⚠️ Any users who are explicitly invited to this {level} will not be required to pass the access gates",
"cannotMakePublic": "You cannot make a private {level} public as that would risk the privacy of the existing members.",
"chooseGate": "Access gate type",
"chooseNervousSystem": "Choose nervous system",
Expand Down Expand Up @@ -543,7 +544,7 @@
"errorGettingLink": "Unable to get link",
"errorResettingLink": "Unable to reset link",
"invite": "Invite",
"inviteWithLink": "Invite to {level} via link",
"inviteWithLink": "Share {level} via link",
"reset": "reset",
"resetLink": "Reset link",
"shareMessage": "Anyone with this link can preview and join the {level}. As a Diamond member you can also earn [referral rewards](?faq=referral_rewards).",
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"amountN": "Cantidad de tokens {n}",
"and": "Requerir todas las puertas",
"approvePaymentTitle": "Aprobar pago",
"bypassWarning": "⚠️ Cualquier usuario que esté invitado explícitamente a este {level} no tendrá que pasar las puertas de acceso.",
"cannotMakePublic": "No puede hacer público un {level} privado, ya que eso pondría en riesgo la privacidad de los miembros existentes.",
"chooseGate": "Elige una puerta de acceso",
"chooseNervousSystem": "Elige sistema nervioso",
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"amountN": "Montant {n} jetons",
"and": "Exiger toutes les portes",
"approvePaymentTitle": "Approuver le paiement",
"bypassWarning": "⚠️ Les utilisateurs explicitement invités à ce {level} ne seront pas tenus de franchir les portes d'accès.",
"cannotMakePublic": "Vous ne pouvez pas rendre public un {level} privé car cela mettrait en danger la vie privée des membres existants.",
"chooseGate": "Choisissez une porte d'accès",
"chooseNervousSystem": "Choisissez le système nerveux",
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/i18n/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"amountN": "राशि {n} टोकन",
"and": "सभी द्वारों की आवश्यकता",
"approvePaymentTitle": "भुगतान स्वीकृत करें",
"bypassWarning": "⚠️ इस {level} में स्पष्ट रूप से आमंत्रित किए गए किसी भी उपयोगकर्ता को प्रवेश द्वार से गुजरने की आवश्यकता नहीं होगी",
"cannotMakePublic": "आप किसी निजी {level} को सार्वजनिक नहीं कर सकते क्योंकि इससे मौजूदा सदस्यों की गोपनीयता खतरे में पड़ जाएगी।",
"chooseGate": "एक प्रवेश द्वार चुनें",
"chooseNervousSystem": "तंत्रिका तंत्र चुनें",
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"amountN": "Importo {n} token",
"and": "Richiedono tutti i cancelli",
"approvePaymentTitle": "Approva il pagamento",
"bypassWarning": "⚠️ Eventuali utenti esplicitamente invitati a questo {level} non saranno tenuti a oltrepassare i varchi di accesso",
"cannotMakePublic": "Non puoi rendere pubblico un {level} privato in quanto ciò metterebbe a rischio la privacy dei membri esistenti.",
"chooseGate": "Scegli un varco di accesso",
"chooseNervousSystem": "Scegli il sistema nervoso",
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/i18n/iw.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"amountN": "כמות {n} אסימונים",
"and": "דורשים את כל השערים",
"approvePaymentTitle": "אשר תשלום",
"bypassWarning": "⚠️ כל המשתמשים שיוזמנו במפורש ל-{level} הזה לא יידרשו לעבור את שערי הגישה",
"cannotMakePublic": "אינך יכול להפוך {level} פרטי לציבורי מכיוון שזה יסכן את הפרטיות של החברים הקיימים.",
"chooseGate": "בחר שער גישה",
"chooseNervousSystem": "בחר מערכת עצבים",
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/i18n/jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"amountN": "量 {n} トークン",
"and": "すべてのゲートが必要",
"approvePaymentTitle": "支払いの承認",
"bypassWarning": "⚠️ この{level}に明示的に招待されたユーザーは、アクセスゲートを通過する必要はありません。",
"cannotMakePublic": "既存のメンバーのプライバシーが危険にさらされるため、非公開の {level} を公開することはできません。",
"chooseGate": "アクセスゲートを選択してください",
"chooseNervousSystem": "神経系を選択する",
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"amountN": "Ilość tokenów {n}",
"and": "Wymagaj wszystkich bram",
"approvePaymentTitle": "Zatwierdź płatność",
"bypassWarning": "⚠️ Użytkownicy wyraźnie zaproszeni do tego {level} nie będą musieli przechodzić przez bramki dostępu",
"cannotMakePublic": "Nie możesz ustawić prywatnego {level} jako publicznego, ponieważ zagroziłoby to prywatności istniejących członków.",
"chooseGate": "Wybierz bramę dostępową",
"chooseNervousSystem": "Wybierz układ nerwowy",
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"amountN": "Количество токенов {n}",
"and": "Требуются все ворота",
"approvePaymentTitle": "Подтвердить платеж",
"bypassWarning": "⚠️ Любым пользователям, явно приглашенным в этот {level}, не потребуется проходить шлюзы доступа.",
"cannotMakePublic": "Вы не можете сделать закрытый {level} общедоступным, так как это поставит под угрозу конфиденциальность существующих участников.",
"chooseGate": "Выберите входные ворота",
"chooseNervousSystem": "Выбери нервную систему",
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/i18n/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"amountN": "Кількість токенів {n}",
"and": "Вимагати всіх воріт",
"approvePaymentTitle": "Підтвердити платіж",
"bypassWarning": "⚠️ Будь-які користувачі, яких явно запрошено на цей {level}, не повинні будуть проходити через ворота доступу",
"cannotMakePublic": "Ви не можете зробити приватний {level} загальнодоступним, оскільки це загрожує конфіденційності існуючих учасників.",
"chooseGate": "Виберіть під'їзні ворота",
"chooseNervousSystem": "Виберіть нервову систему",
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/i18n/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"amountN": "Số lượng mã thông báo {n}",
"and": "Yêu cầu tất cả các cổng",
"approvePaymentTitle": "Phê duyệt thanh toán",
"bypassWarning": "⚠️ Bất kỳ người dùng nào được mời rõ ràng vào {level} này sẽ không phải vượt qua cổng truy cập",
"cannotMakePublic": "Bạn không thể công khai {level} riêng tư vì điều đó sẽ gây rủi ro cho quyền riêng tư của các thành viên hiện có.",
"chooseGate": "Chọn một cổng truy cập",
"chooseNervousSystem": "Chọn hệ thần kinh",
Expand Down
Loading
Loading