- User management: local accounts (Argon2) and OpenID Connect, admin/user roles, per-user folders plus admin-shared folders, read-only session sharing, event filtering per user - File manager with CodeMirror editor and git client (status, diff, stage, commit, branches, fetch/pull/push, log, clone/init) - Image generation via fal.ai: generate_image tool and image page - Budgets: monthly limits per provider, provider balances/costs (OpenRouter, Anthropic admin cost report, fal.ai), price discovery - Subagents on other models, background tasks, concurrency limits per host/model/subagent - MCP tools loaded on demand (mcp_search/mcp_call), read-only hints - Permission mode "auto", safe read-only commands always allowed - Persistent message queue with attachments, deletable - Live reasoning incl. <think> tags, activity animations, CSS themes, mobile layout, statistics per user, upload size handling - Docker: named volume for state, localhost-bound port Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
2.5 KiB
TypeScript
73 lines
2.5 KiB
TypeScript
import { useEffect, useState } from "react";
|
|
import { get, put } from "../api";
|
|
import { useT } from "../i18n";
|
|
import { useStore } from "../store";
|
|
|
|
interface DirUser {
|
|
id: string;
|
|
username: string;
|
|
display_name: string;
|
|
}
|
|
|
|
/** Choose users a session is shared with (read-only for them). */
|
|
export function ShareDialog({ sessionId, onClose }: { sessionId: string; onClose: () => void }) {
|
|
const t = useT();
|
|
const me = useStore((s) => s.me);
|
|
const owner = useStore((s) => s.sessionById[sessionId]?.owner_id);
|
|
const [users, setUsers] = useState<DirUser[]>([]);
|
|
const [selected, setSelected] = useState<Set<string>>(new Set());
|
|
const [error, setError] = useState<string>();
|
|
|
|
useEffect(() => {
|
|
Promise.all([get<DirUser[]>("/users/directory"), get<string[]>(`/sessions/${sessionId}/shares`)])
|
|
.then(([u, s]) => {
|
|
setUsers(u.filter((x) => x.id !== owner && x.id !== me?.id));
|
|
setSelected(new Set(s));
|
|
})
|
|
.catch((e) => setError(e.message));
|
|
}, [sessionId, owner, me?.id]);
|
|
|
|
const save = async () => {
|
|
try {
|
|
await put(`/sessions/${sessionId}/shares`, { users: [...selected] });
|
|
onClose();
|
|
} catch (e: any) {
|
|
setError(e.message);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className="modal-backdrop" onClick={onClose}>
|
|
<div className="modal" role="dialog" aria-label={t("share.title")} onClick={(e) => e.stopPropagation()}>
|
|
<h3>{t("share.title")}</h3>
|
|
<div style={{ fontSize: 13, color: "var(--muted)", marginBottom: 8 }}>{t("share.hint")}</div>
|
|
<div className="check-list">
|
|
{users.length === 0 && <div className="empty">{t("share.noUsers")}</div>}
|
|
{users.map((u) => (
|
|
<label key={u.id}>
|
|
<input
|
|
type="checkbox"
|
|
checked={selected.has(u.id)}
|
|
onChange={(e) => {
|
|
const next = new Set(selected);
|
|
if (e.target.checked) next.add(u.id);
|
|
else next.delete(u.id);
|
|
setSelected(next);
|
|
}}
|
|
/>
|
|
{u.display_name || u.username} <span style={{ color: "var(--muted)" }}>@{u.username}</span>
|
|
</label>
|
|
))}
|
|
</div>
|
|
{error && <div className="notice err">{error}</div>}
|
|
<div className="row" style={{ marginTop: 12, justifyContent: "flex-end" }}>
|
|
<button onClick={onClose}>{t("common.cancel")}</button>
|
|
<button className="primary" onClick={save}>
|
|
{t("common.save")}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|