diff --git a/server/spaces.ts b/server/spaces.ts index 759f245..583abee 100644 --- a/server/spaces.ts +++ b/server/spaces.ts @@ -631,6 +631,7 @@ spaces.get("/:slug", async (c) => { slug: data.meta.slug, name: data.meta.name, visibility: data.meta.visibility, + description: data.meta.description || "", createdAt: data.meta.createdAt, ownerDID: data.meta.ownerDID, memberCount: Object.keys(data.members || {}).length, diff --git a/shared/components/rstack-space-settings.ts b/shared/components/rstack-space-settings.ts index 2bc9a2f..f54dd3d 100644 --- a/shared/components/rstack-space-settings.ts +++ b/shared/components/rstack-space-settings.ts @@ -60,6 +60,11 @@ export class RStackSpaceSettings extends HTMLElement { private _moduleSettingsValues: Record = {}; private _moduleSaveError = ""; private _moduleSaving = false; + private _visibility: "public" | "permissioned" | "private" = "public"; + private _description = ""; + private _spaceName = ""; + private _spaceSaving = false; + private _spaceSaveMsg = ""; static define() { if (!customElements.get("rstack-space-settings")) { @@ -210,6 +215,21 @@ export class RStackSpaceSettings extends HTMLElement { this._myRole = this._isOwner ? "admin" : (myMember?.role || "viewer"); } + // Load space metadata (visibility, description) + if (this._isAdmin && token) { + try { + const res = await fetch(`/api/spaces/${encodeURIComponent(this._space)}`, { + headers: { "Authorization": `Bearer ${token}` }, + }); + if (res.ok) { + const info = await res.json(); + this._visibility = info.visibility || "public"; + this._description = info.description || ""; + this._spaceName = info.name || this._space; + } + } catch {} + } + // Load invites (admin only) if (this._isAdmin && token) { try { @@ -408,6 +428,22 @@ export class RStackSpaceSettings extends HTMLElement {
${moduleSettingsHTML} + ${this._isAdmin ? ` +
+

Space Settings

+ + + + + + ${this._spaceSaveMsg ? `${this._esc(this._spaceSaveMsg)}` : ""} +
+ ` : ""} +

Members ${this._members.length}

${membersHTML}
@@ -560,6 +596,46 @@ export class RStackSpaceSettings extends HTMLElement { }); sr.getElementById("mod-cfg-save")?.addEventListener("click", () => this._saveModuleSettings()); + + // Space settings save + sr.getElementById("space-save")?.addEventListener("click", () => this._saveSpaceSettings()); + } + + private async _saveSpaceSettings() { + const sr = this.shadowRoot!; + const vis = (sr.getElementById("space-visibility") as HTMLSelectElement)?.value; + const desc = (sr.getElementById("space-description") as HTMLTextAreaElement)?.value; + const token = getToken(); + if (!token) return; + + this._spaceSaving = true; + this._spaceSaveMsg = ""; + this._render(); + + try { + const res = await fetch(`/api/spaces/${encodeURIComponent(this._space)}`, { + method: "PATCH", + headers: { + "Content-Type": "application/json", + "Authorization": `Bearer ${token}`, + }, + body: JSON.stringify({ visibility: vis, description: desc }), + }); + if (res.ok) { + const data = await res.json(); + this._visibility = data.visibility || vis; + this._description = data.description ?? desc; + this._spaceSaveMsg = "Saved"; + } else { + const err = await res.json().catch(() => ({})) as { error?: string }; + this._spaceSaveMsg = (err as any).error || "Failed to save"; + } + } catch { + this._spaceSaveMsg = "Network error"; + } + this._spaceSaving = false; + this._render(); + setTimeout(() => { this._spaceSaveMsg = ""; this._render(); }, 3000); } private async _lookupUser(username: string) { @@ -952,6 +1028,19 @@ const PANEL_CSS = ` .input:focus { outline: none; border-color: #14b8a6; } .input::placeholder { color: var(--rs-text-muted); } +.field-label { + display: block; + font-size: 0.75rem; + color: var(--rs-text-secondary); + margin-bottom: 4px; +} + +.space-save-msg { + font-size: 0.78rem; + color: #14b8a6; + margin-left: 8px; +} + .add-row { display: flex; gap: 8px;