Add ability to configure guest spaces in settings (#10770)

* Configure guest channels in the settings

Signed-off-by: Artem Savchenko <armisav@gmail.com>

* Update space classes

Signed-off-by: Artem Savchenko <armisav@gmail.com>

---------

Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
Artyom Savchenko
2026-04-16 15:02:44 +07:00
committed by GitHub
parent 3e415cb0d2
commit 596e2705a8
20 changed files with 242 additions and 33 deletions
@@ -593,7 +593,7 @@ export interface ModulePermissionGroup extends Doc {
role: AccountRole
permissions: Ref<Permission>[]
disabledPermissions?: Ref<Permission>[]
spaceClass: Ref<Class<Space>>
spaceClass?: Ref<Class<Space>>
enabled: boolean
order?: number
}
+2 -2
View File
@@ -76,7 +76,7 @@ export function createModel (builder: Builder): void {
application: chunter.app.Chunter,
role: AccountRole.Guest,
permissions: [],
spaceClass: chunter.class.ChunterSpace,
spaceClass: chunter.class.Channel,
enabled: true,
order: 30
},
@@ -90,7 +90,7 @@ export function createModel (builder: Builder): void {
application: chunter.app.Chunter,
role: AccountRole.ReadOnlyGuest,
permissions: [],
spaceClass: chunter.class.ChunterSpace,
spaceClass: chunter.class.Channel,
enabled: true,
order: 15
},
-2
View File
@@ -273,7 +273,6 @@ export function createModel (builder: Builder): void {
application: love.app.Love,
role: AccountRole.Guest,
permissions: [],
spaceClass: love.class.Office,
enabled: true,
order: 50
},
@@ -287,7 +286,6 @@ export function createModel (builder: Builder): void {
application: love.app.Love,
role: AccountRole.ReadOnlyGuest,
permissions: [],
spaceClass: love.class.Office,
enabled: false,
order: 50
},
+2 -2
View File
@@ -220,7 +220,7 @@ export function createModel (builder: Builder): void {
application: time.app.Me,
role: AccountRole.Guest,
permissions: [],
spaceClass: core.class.TypedSpace,
spaceClass: tracker.class.Project,
enabled: true,
order: 55
},
@@ -234,7 +234,7 @@ export function createModel (builder: Builder): void {
application: time.app.Me,
role: AccountRole.ReadOnlyGuest,
permissions: [],
spaceClass: core.class.TypedSpace,
spaceClass: tracker.class.Project,
enabled: false,
order: 55
},
-2
View File
@@ -917,7 +917,6 @@ function defineSettings (builder: Builder): void {
application: training.app.Training,
role: AccountRole.Guest,
permissions: [training.ids.GuestTrainingAttemptClassPermission],
spaceClass: core.class.TypedSpace,
enabled: true,
order: 25
},
@@ -931,7 +930,6 @@ function defineSettings (builder: Builder): void {
application: training.app.Training,
role: AccountRole.ReadOnlyGuest,
permissions: [],
spaceClass: core.class.TypedSpace,
enabled: false,
order: 25
},
+2
View File
@@ -174,6 +174,8 @@
"GuestSignUpDescription": "Umožňuje anonymním uživatelům připojit se k vašemu pracovnímu prostoru jako hosté s omezenými editačními právy",
"GuestChannelsDescription": "Kanály, kde hosté mohou psát zprávy po připojení",
"GuestChannelsArrayLabel": "Vybrat kanály",
"GuestAutoJoinAvailableSpaces": "Dostupné prostory",
"GuestAutoJoinAvailableSpacesHint": "Každá karta aplikace má vlastní řádek „Dostupné prostory“ pro automatické připojení hostů; změny se projeví okamžitě.",
"ManageIdentities": "Spravovat identity",
"Release": "Uvolnění",
"ReleaseSocialId": "Uvolnit sociální ID",
+2
View File
@@ -174,6 +174,8 @@
"GuestSignUpDescription": "Ermöglicht anonymen Benutzern den Beitritt zu Ihrem Arbeitsbereich als Gäste mit eingeschränkten Bearbeitungsrechten",
"GuestChannelsDescription": "Kanäle, in denen Gäste nach dem Beitritt Nachrichten schreiben können",
"GuestChannelsArrayLabel": "Kanäle auswählen",
"GuestAutoJoinAvailableSpaces": "Verfügbare Bereiche",
"GuestAutoJoinAvailableSpacesHint": "Jede Anwendungskarte hat eine eigene Zeile „Verfügbare Bereiche“ für den automatischen Gästebeitritt; Änderungen gelten sofort.",
"ManageIdentities": "Identitäten verwalten",
"Release": "Freigeben",
"ReleaseSocialId": "Social ID freigeben",
+2
View File
@@ -174,6 +174,8 @@
"GuestSignUpDescription": "Allows anonymous users to join your workspace as guests with limited editing rights",
"GuestChannelsDescription": "Channels where guests can write messages after joining",
"GuestChannelsArrayLabel": "Select channels",
"GuestAutoJoinAvailableSpaces": "Available spaces",
"GuestAutoJoinAvailableSpacesHint": "Each application card has its own “Available spaces” row to pick where workspace guests are added on activation. Changes apply immediately.",
"ManageIdentities": "Manage identities",
"Release": "Release",
"ReleaseSocialId": "Release social ID",
+2
View File
@@ -165,6 +165,8 @@
"GuestSignUpDescription": "Permite a usuarios anónimos unirse a su espacio de trabajo como invitados con derechos de edición limitados",
"GuestChannelsDescription": "Canales donde los invitados pueden escribir mensajes después de unirse",
"GuestChannelsArrayLabel": "Seleccionar canales",
"GuestAutoJoinAvailableSpaces": "Espacios disponibles",
"GuestAutoJoinAvailableSpacesHint": "Cada tarjeta de aplicación tiene su propia fila « Espacios disponibles » para la adhesión automática de invitados; los cambios son inmediatos.",
"ManageIdentities": "Gestionar identidades",
"Release": "Liberar",
"ReleaseSocialId": "Liberar ID social",
+2
View File
@@ -174,6 +174,8 @@
"GuestSignUpDescription": "Permet aux utilisateurs anonymes de rejoindre votre espace de travail en tant qu'invités avec des droits d'édition limités",
"GuestChannelsDescription": "Canaux où les invités peuvent écrire des messages après leur adhésion",
"GuestChannelsArrayLabel": "Sélectionner des canaux",
"GuestAutoJoinAvailableSpaces": "Espaces disponibles",
"GuestAutoJoinAvailableSpacesHint": "Chaque carte dapplication a sa propre ligne « Espaces disponibles » pour ladhésion automatique des invités ; les changements sont immédiats.",
"ManageIdentities": "Gérer les identités",
"Release": "Libération",
"ReleaseSocialId": "Libérer l'ID social",
+2
View File
@@ -174,6 +174,8 @@
"GuestSignUpDescription": "Consente agli utenti anonimi di unirsi al tuo spazio di lavoro come ospiti con diritti di modifica limitati",
"GuestChannelsDescription": "Canali in cui gli ospiti possono scrivere messaggi dopo essersi uniti",
"GuestChannelsArrayLabel": "Seleziona canali",
"GuestAutoJoinAvailableSpaces": "Spazi disponibili",
"GuestAutoJoinAvailableSpacesHint": "Ogni scheda applicazione ha la propria riga « Spazi disponibili » per lingresso automatico degli ospiti; le modifiche sono immediate.",
"ManageIdentities": "Gestisci identità",
"Release": "Rilascio",
"ReleaseSocialId": "Rilascia ID social",
+2
View File
@@ -174,6 +174,8 @@
"GuestSignUpDescription": "匿名ユーザーがゲストとしてワークスペースに参加し、制限された編集権限を得られるようにします",
"GuestChannelsDescription": "参加後、ゲストがメッセージを書き込めるチャンネル",
"GuestChannelsArrayLabel": "チャンネルを選択",
"GuestAutoJoinAvailableSpaces": "利用可能なスペース",
"GuestAutoJoinAvailableSpacesHint": "各アプリのカードにゲスト自動参加用の「利用可能なスペース」行があります。変更はすぐに反映されます。",
"ManageIdentities": "IDを管理",
"Release": "リリース",
"ReleaseSocialId": "ソーシャルIDをリリース",
+2
View File
@@ -165,6 +165,8 @@
"GuestSignUpDescription": "Permite que usuários anônimos entrem em seu espaço de trabalho como convidados com direitos de edição limitados",
"GuestChannelsDescription": "Canais onde convidados podem escrever mensagens após entrar",
"GuestChannelsArrayLabel": "Selecionar canais",
"GuestAutoJoinAvailableSpaces": "Espaços disponíveis",
"GuestAutoJoinAvailableSpacesHint": "Cada cartão de app tem sua própria linha « Espaços disponíveis » para adesão automática de convidados; as alterações são aplicadas na hora.",
"ManageIdentities": "Gerenciar identidades",
"Release": "Liberação",
"ReleaseSocialId": "Liberar ID social",
+2
View File
@@ -165,6 +165,8 @@
"GuestSignUpDescription": "Permite que usuários anônimos entrem em seu espaço de trabalho como convidados com direitos de edição limitados",
"GuestChannelsDescription": "Canais onde convidados podem escrever mensagens após ingressar",
"GuestChannelsArrayLabel": "Selecionar canais",
"GuestAutoJoinAvailableSpaces": "Espaços disponíveis",
"GuestAutoJoinAvailableSpacesHint": "Cada cartão de aplicação tem a sua própria linha « Espaços disponíveis » para adesão automática de convidados; as alterações aplicam-se de imediato.",
"ManageIdentities": "Gerenciar identidades",
"Release": "Libertação",
"ReleaseSocialId": "Liberar ID social",
+2
View File
@@ -179,6 +179,8 @@
"GuestSignUpDescription": "Позволяет анонимным пользователям присоединяться к вашему рабочему пространству в качестве гостей с ограниченными правами редактирования",
"GuestChannelsDescription": "Каналы, в которых гости могут писать сообщения после присоединения",
"GuestChannelsArrayLabel": "Выбрать каналы",
"GuestAutoJoinAvailableSpaces": "Доступные пространства",
"GuestAutoJoinAvailableSpacesHint": "У каждого приложения ниже своя строка «Доступные пространства»: выберите, куда при активации добавлять гостей воркспейса. Изменения применяются сразу.",
"ManageIdentities": "Управление идентификаторами",
"Release": "Освободить",
"ReleaseSocialId": "Освободить социальный ID",
+2
View File
@@ -174,6 +174,8 @@
"GuestSignUpDescription": "Anonim kullanıcıların çalışma alanınıza sınırlı düzenleme haklarıyla misafir olarak katılmasına izin verir",
"GuestChannelsDescription": "Misafirlerin katıldıktan sonra mesaj yazabileceği kanallar",
"GuestChannelsArrayLabel": "Kanalları seç",
"GuestAutoJoinAvailableSpaces": "Kullanılabilir alanlar",
"GuestAutoJoinAvailableSpacesHint": "Her uygulama kartının misafir otomatik katılımı için kendi « Kullanılabilir alanlar » satırı vardır; değişiklikler hemen uygulanır.",
"ManageIdentities": "Kimlikleri yönet",
"Release": "Serbest bırak",
"ReleaseSocialId": "Sosyal ID'yi serbest bırak",
+2
View File
@@ -174,6 +174,8 @@
"GuestSignUpDescription": "允许匿名用户以访客身份加入您的工作区,获得有限的编辑权限",
"GuestChannelsDescription": "访客加入后可以发送消息的频道",
"GuestChannelsArrayLabel": "选择频道",
"GuestAutoJoinAvailableSpaces": "可用空间",
"GuestAutoJoinAvailableSpacesHint": "每个应用卡片都有各自的「可用空间」行,用于选择在激活时添加工作区访客的位置;更改会立即生效。",
"ManageIdentities": "管理身份",
"Release": "释放",
"ReleaseSocialId": "释放社交ID",
@@ -0,0 +1,143 @@
<!--
// Copyright © 2026 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import { Analytics } from '@hcengineering/analytics'
import {
AccountRole,
setWorkspaceGuestAutoJoinRoles,
type ModulePermissionGroup,
type Space
} from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import { DropdownLabels, type DropdownTextItem } from '@hcengineering/ui'
import settingsRes from '../plugin'
export let group: ModulePermissionGroup
export let disabled = false
const client = getClient()
let loading = true
let saving = false
let loadedGroupId: string | undefined
let dropdownItems: DropdownTextItem[] = []
let selectedKeys: string[] = []
let persistedSelectedKeys: string[] = []
let docById: Map<string, Space> = new Map<string, Space>()
function normalizeAutoJoinForRoles (roles: AccountRole[]): AccountRole[] | undefined {
return roles.length > 0 ? [...roles] : undefined
}
async function loadSpaces (): Promise<void> {
if (group.spaceClass === undefined) {
dropdownItems = []
selectedKeys = []
persistedSelectedKeys = []
docById = new Map<string, Space>()
loading = false
return
}
loading = true
try {
const res = await client.findAll(group.spaceClass, { archived: false })
docById = new Map(res.map((d) => [d._id, d as Space]))
const docs = [...docById.values()]
dropdownItems = docs.map((d) => ({ id: d._id, label: d.name })).sort((a, b) => a.label.localeCompare(b.label))
selectedKeys = docs
.filter((d) => d.autoJoinForRoles?.includes(AccountRole.Guest) === true)
.map((d) => d._id)
.sort()
persistedSelectedKeys = [...selectedKeys]
} catch (err) {
Analytics.handleError(err as Error)
dropdownItems = []
selectedKeys = []
persistedSelectedKeys = []
docById = new Map<string, Space>()
} finally {
loading = false
}
}
async function handleSelected (e: CustomEvent<string[]>): Promise<void> {
const nextKeys = new Set(e.detail)
const prevKeys = new Set(persistedSelectedKeys)
const toEnable = [...nextKeys].filter((k) => !prevKeys.has(k))
const toDisable = [...prevKeys].filter((k) => !nextKeys.has(k))
if (toEnable.length === 0 && toDisable.length === 0) {
return
}
saving = true
try {
const ops: Array<Promise<unknown>> = []
for (const key of toEnable) {
const doc = docById.get(key)
if (doc === undefined) continue
const roles = setWorkspaceGuestAutoJoinRoles(doc.autoJoinForRoles, true)
const autoJoinForRoles = normalizeAutoJoinForRoles(roles)
if (autoJoinForRoles === undefined) {
ops.push(client.update(doc, { $unset: { autoJoinForRoles: true } } as any))
} else {
ops.push(client.diffUpdate(doc, { autoJoinForRoles }))
}
}
for (const key of toDisable) {
const doc = docById.get(key)
if (doc === undefined) continue
const roles = setWorkspaceGuestAutoJoinRoles(doc.autoJoinForRoles, false)
const autoJoinForRoles = normalizeAutoJoinForRoles(roles)
if (autoJoinForRoles === undefined) {
ops.push(client.update(doc, { $unset: { autoJoinForRoles: true } } as any))
} else {
ops.push(client.diffUpdate(doc, { autoJoinForRoles }))
}
}
await Promise.all(ops)
selectedKeys = [...nextKeys].sort()
persistedSelectedKeys = [...selectedKeys]
} catch (err) {
Analytics.handleError(err as Error)
selectedKeys = [...persistedSelectedKeys]
await loadSpaces()
} finally {
saving = false
}
}
$: if (group._id !== loadedGroupId) {
loadedGroupId = group._id
void loadSpaces()
}
</script>
<DropdownLabels
multiselect
autoSelect={false}
items={dropdownItems}
selected={[...(selectedKeys ?? [])]}
label={settingsRes.string.GuestAutoJoinAvailableSpaces}
showDropdownIcon
kind={'no-border'}
size={'large'}
width={'min(18rem, 100%)'}
disabled={disabled || loading || saving || dropdownItems.length === 0}
loading={saving}
on:selected={handleSelected}
/>
@@ -48,6 +48,7 @@
} from '@hcengineering/ui'
import setting from '@hcengineering/setting'
import { onMount } from 'svelte'
import AvailableSpacesInput from './AvailableSpacesInput.svelte'
import settingsRes from '../plugin'
let loadingSettings = true
@@ -244,6 +245,14 @@
allowGuestSignUp = e.detail
}
function onReadonlyGuestsToggle (e: CustomEvent<boolean>): void {
void handleToggleReadonlyAccess(e)
}
function onGuestSignUpToggle (e: CustomEvent<boolean>): void {
void handleToggleGuestSignUp(e)
}
async function onAllowedCardsChange (value: Ref<Card>[]): Promise<void> {
if (existingGuestChatSettings === undefined) {
await client.createDoc(communication.class.GuestCommunicationSettings, core.space.Workspace, {
@@ -317,12 +326,7 @@
<Label label={settingsRes.string.GuestAccessDescription} />
</div>
<div class="guestAccessRow-toggleCell">
<Toggle
on={allowReadOnlyGuests}
on:change={(e) => {
void handleToggleReadonlyAccess(e)
}}
/>
<Toggle on={allowReadOnlyGuests} on:change={onReadonlyGuestsToggle} />
</div>
</div>
<div class="guestAccessRow">
@@ -330,13 +334,7 @@
<Label label={settingsRes.string.GuestSignUpDescription} />
</div>
<div class="guestAccessRow-toggleCell">
<Toggle
disabled={!allowReadOnlyGuests}
on={allowGuestSignUp}
on:change={(e) => {
void handleToggleGuestSignUp(e)
}}
/>
<Toggle disabled={!allowReadOnlyGuests} on={allowGuestSignUp} on:change={onGuestSignUpToggle} />
</div>
</div>
{#if communicationApiEnabled}
@@ -376,6 +374,14 @@
<Label label={setting.string.GuestPermissionsApplicationPermissionsHint} />
{/if}
</div>
{#if guestPermissionsTab === 'guest'}
<div class="sectionHint">
<Label label={core.string.AutoJoinGuestsDescr} />
</div>
<div class="sectionHint">
<Label label={settingsRes.string.GuestAutoJoinAvailableSpacesHint} />
</div>
{/if}
</div>
<div class="cardStack" class:cardStack-readonly={anonymousModulePermissionsReadOnly}>
@@ -383,10 +389,15 @@
{@const app = getApplication(group.application)}
{@const moduleOn = isModuleEnabled(group)}
{@const permissionCount = (group.permissions ?? []).length}
{@const hasGuestAutoJoinRow =
guestPermissionsTab === 'guest' &&
group.role === AccountRole.Guest &&
group.spaceClass !== undefined}
{@const hasPermissionRowsBlock = permissionCount > 0 || hasGuestAutoJoinRow}
<div class="permissionModuleCard" class:permissionModuleCard-off={!moduleOn}>
<div
class="permissionModuleCard-header"
class:permissionModuleCard-headerOnly={permissionCount === 0}
class:permissionModuleCard-headerOnly={!hasPermissionRowsBlock}
>
<div class="permissionModuleCard-headerMain">
{#if app}
@@ -411,8 +422,9 @@
</div>
</div>
{#if permissionCount > 0}
{#if hasPermissionRowsBlock}
<div class="permissionRows">
{#if permissionCount > 0}
{#each group.permissions ?? [] as permissionId}
<div class="permissionRow">
<div class="permissionRow-label">
@@ -427,6 +439,20 @@
</div>
</div>
{/each}
{/if}
{#if hasGuestAutoJoinRow}
<div class="permissionRow permissionRow--guestSpaces">
<div class="permissionRow-label">
<Label label={settingsRes.string.GuestAutoJoinAvailableSpaces} />
</div>
<div class="permissionRow-editorCell">
<AvailableSpacesInput
{group}
disabled={!moduleOn || anonymousModulePermissionsReadOnly}
/>
</div>
</div>
{/if}
</div>
{/if}
</div>
@@ -644,6 +670,24 @@
color: var(--theme-content-color);
}
.permissionRow--guestSpaces {
align-items: start;
min-height: auto;
padding-top: 0.75rem;
padding-bottom: 0.75rem;
grid-template-columns: minmax(0, 1fr) minmax(8rem, max-content);
}
.permissionRow--guestSpaces .permissionRow-editorCell {
grid-column: 2;
justify-self: end;
align-self: start;
width: max-content;
max-width: min(18rem, calc(100vw - 4rem));
min-width: 0;
overflow: visible;
}
.emptyState {
font-size: 0.875rem;
color: var(--theme-halfcontent-color);
+2
View File
@@ -137,6 +137,8 @@ export default mergeIds(settingId, setting, {
GuestSignUpDescription: '' as IntlString,
GuestChannelsDescription: '' as IntlString,
GuestChannelsArrayLabel: '' as IntlString,
GuestAutoJoinAvailableSpaces: '' as IntlString,
GuestAutoJoinAvailableSpacesHint: '' as IntlString,
ApiAccess: '' as IntlString,
ApiToken: '' as IntlString,
GenerateApiToken: '' as IntlString,