Skip to content

The open-source AI receptionist for businesses. Answers every call, books the appointment and hands over to a person when needed. You own the code and the data.

Settings overview: Assistants, Workspace and You groups (PR 1918)

Janik33a531399f69
diff --git a/apps/web/src/settings/SettingsHome.tsx b/apps/web/src/settings/SettingsHome.tsx
index a98bb886..26a7dbba 100644
--- a/apps/web/src/settings/SettingsHome.tsx
+++ b/apps/web/src/settings/SettingsHome.tsx
@@ -1,11 +1,11 @@
-// Settings (#settings, G S): the one place every setting starts from. One list of three entries: the assistant
-// (what callers hear; one entry per assistant when the workspace has several), the workspace (everyone in it) and
-// you (only you). Each entry is one line on what is in there and opens its first page; the sub-pages are in that
+// Settings (#settings, G S): the one place every setting starts from, in three groups. Assistants: one row per
+// assistant of the workspace (its number, whether it answers calls) and New assistant for who may create one.
+// Workspace: what everyone shares. You: only you. Each row opens that area's first page; the sub-pages are in the
// area's own navigation (Assistant › General, Workspace settings › General, User settings › Profile).
// Server admin stays its own entry in the navigation.
import type { Assistant, PhoneNumber } from '@linedesk/db/types'
import { useT } from '@linedesk/i18n/react'
-import type { ReactNode } from 'react'
+import { type ReactNode, useEffect, useState } from 'react'
import { auth } from '../auth.ts'
import { notAnsweringWhy } from '../inbox/goLive.ts'
import { formatNumber } from '../onboarding/flow.ts'
@@ -13,43 +13,70 @@ import { usePresence } from '../shell/presence.ts'
import { pages } from '../shell/pages.tsx'
import { WorkspaceMark, workspaceIconOf } from '../shell/WorkspaceMark.tsx'
import { useWorkspaces } from '../shell/WorkspaceSwitcher.tsx'
-import { useAssistants, useRows } from '../store.tsx'
+import { useAssistants, useRows, useRun } from '../store.tsx'
import { tabWorkspace } from '../tabWorkspace.ts'
import { memberAvatar, useMember } from '../team/members.ts'
+import { LineGroup } from '../ui/FeatureLine.tsx'
import { Card } from '../ui/form.tsx'
import { Avatar, Icon } from '../ui/kit.tsx'
import { Loading, Skeleton, useLoadState } from '../ui/LoadStates.tsx'
+import { SettingRow, SettingRows } from '../ui/SettingRow.tsx'
import { sectionHash } from '../ui/SettingsLayout.tsx'
import { StatusMark } from '../ui/StatusMark.tsx'
import './settings-home.css'
-/** The global keys that open the (first) assistant; shown in its entry's tooltip, never as chips (rule 4). */
+/** The global keys that open the (first) assistant; shown in its row's tooltip, never as chips (rule 4). */
const ASSISTANT_KEYS = ['G', 'A']
type Props = {
billing: boolean
workspaceName: string
isInstanceAdmin: boolean
+ /** Owners and admins: New assistant (the same permission as the assistant switcher's New). */
+ canEdit: boolean
+ toast: (text: string) => void
}
-export function SettingsHome({ billing, workspaceName, isInstanceAdmin }: Props) {
+export function SettingsHome({ billing, workspaceName, isInstanceAdmin, canEdit, toast }: Props) {
const t = useT()
const assistants = useAssistants()
const loadState = useLoadState('assistants')
return (
<div className="page">
<div className="page-in sh-page">
- <Card className="sh-list">
- <Loading
- what={t('settings.assistant.load')}
- loading={!assistants.length && loadState !== 'ready'}
- skeleton={<EntrySkeleton />}
- >
- <AssistantEntries assistants={assistants} isInstanceAdmin={isInstanceAdmin} />
- </Loading>
- <WorkspaceEntry name={workspaceName} billing={billing} />
- <YouEntry />
- </Card>
+ <section className="sh-group" aria-labelledby="sh-assistants">
+ <LineGroup as="h2">
+ <span id="sh-assistants">{t('settings.home.group.assistants')}</span>
+ </LineGroup>
+ <Card className="sh-card">
+ <SettingRows>
+ <Loading
+ what={t('settings.assistant.load')}
+ loading={!assistants.length && loadState !== 'ready'}
+ skeleton={<RowSkeleton />}
+ >
+ <AssistantRows assistants={assistants} isInstanceAdmin={isInstanceAdmin} />
+ </Loading>
+ {canEdit && <NewAssistantRow assistants={assistants} toast={toast} />}
+ </SettingRows>
+ </Card>
+ </section>
+ <section className="sh-group" aria-labelledby="sh-workspace">
+ <LineGroup as="h2">
+ <span id="sh-workspace">{t('settings.home.group.workspace')}</span>
+ </LineGroup>
+ <Card className="sh-card">
+ <WorkspaceRow name={workspaceName} billing={billing} />
+ </Card>
+ </section>
+ <section className="sh-group" aria-labelledby="sh-you">
+ <LineGroup as="h2">
+ <span id="sh-you">{t('settings.home.group.you')}</span>
+ </LineGroup>
+ <Card className="sh-card">
+ <YouRow />
+ </Card>
+ </section>
</div>
</div>
)
@@ -59,16 +86,15 @@ export function SettingsHome({ billing, workspaceName, isInstanceAdmin }: Props)
const numbersOf = (assistant: Assistant, isDefault: boolean, numbers: PhoneNumber[]) =>
numbers.filter(n => n.assistant_id === assistant.id || (!n.assistant_id && isDefault))
-function AssistantEntries({ assistants, isInstanceAdmin }: { assistants: Assistant[]; isInstanceAdmin: boolean }) {
+function AssistantRows({ assistants, isInstanceAdmin }: { assistants: Assistant[]; isInstanceAdmin: boolean }) {
const t = useT()
const numbers = useRows('phone_numbers').sort((a, b) => a.created_at.localeCompare(b.created_at))
if (!assistants.length)
return (
- <Entry
+ <Row
href="#assistant"
- mark={<AssistantMark />}
+ lead={<AssistantMark />}
title={pages.assistant.title}
- line={t('settings.home.assistant.lineNone')}
tip={`${pages.assistant.title} (${ASSISTANT_KEYS.join(' ')})`}
/>
)
@@ -76,13 +102,12 @@ function AssistantEntries({ assistants, isInstanceAdmin }: { assistants: Assista
const name = a.name.trim() || t('settings.assistant.name.fallback')
const own = numbersOf(a, i === 0, numbers)
return (
- <Entry
+ <Row
key={a.id}
href={`#assistant/${a.id}/general`}
- mark={<AssistantMark />}
+ lead={<AssistantMark />}
title={name}
- meta={own[0] ? formatNumber(own[0].e164) : undefined}
- line={t('settings.home.assistant.line', { name })}
+ aside={own[0] ? formatNumber(own[0].e164) : undefined}
status={<AnswerState assistant={name} hasNumber={own.length > 0} isInstanceAdmin={isInstanceAdmin} />}
tip={i === 0 ? `${name} (${ASSISTANT_KEYS.join(' ')})` : undefined}
/>
@@ -112,35 +137,73 @@ function AnswerState({
: [null, null]
if (!state) return null
return (
- <>
+ <span className="sh-state">
<StatusMark state={state} label={words} />
- <span className="sh-entry-state">{words}</span>
- </>
+ <span>{words}</span>
+ </span>
)
}
-function WorkspaceEntry({ name, billing }: { name: string; billing: boolean }) {
+/**
+ * New assistant, as in the assistant switcher (AssistantHeader): creates one, and opens it as soon as it arrives by
+ * sync.
+ */
+function NewAssistantRow({ assistants, toast }: { assistants: Assistant[]; toast: (text: string) => void }) {
+ const t = useT()
+ const run = useRun()
+ const [awaiting, setAwaiting] = useState<Set<string> | null>(null)
+ useEffect(() => {
+ if (!awaiting) return
+ const added = assistants.find(a => !awaiting.has(a.id))
+ if (!added) return
+ setAwaiting(null)
+ window.location.hash = `#assistant/${added.id}/general`
+ toast(t('settings.assistantHeader.added', { name: added.name }))
+ }, [assistants, awaiting, toast, t])
+ return (
+ <button
+ type="button"
+ className="sh-row sh-add"
+ disabled={!!awaiting}
+ onClick={() => {
+ setAwaiting(new Set(assistants.map(a => a.id)))
+ void run('assistant.create', {})
+ }}
+ >
+ <SettingRow
+ lead={
+ <span className="sh-lead">
+ <Icon name="plus" size={16} />
+ </span>
+ }
+ title={t('settings.assistantHeader.new')}
+ />
+ </button>
+ )
+}
+
+function WorkspaceRow({ name, billing }: { name: string; billing: boolean }) {
const t = useT()
const iconUrl = workspaceIconOf(useWorkspaces(), tabWorkspace() ?? '')
return (
- <Entry
+ <Row
href={sectionHash('workspace', 'general')}
- mark={<WorkspaceMark name={name} iconUrl={iconUrl} size="lg" />}
+ lead={<WorkspaceMark name={name} iconUrl={iconUrl} size="lg" />}
title={name}
line={t(billing ? 'settings.home.workspace.line' : 'settings.home.workspace.lineNoBilling')}
/>
)
}
-function YouEntry() {
+function YouRow() {
const t = useT()
const user = auth.useSession().data?.user
const me = useMember(user?.id ?? null)
const name = user?.name || user?.email || pages.account.title
return (
- <Entry
+ <Row
href={sectionHash('account', 'profile')}
- mark={<Avatar name={name} src={me ? memberAvatar(me) : null} size={40} />}
+ lead={<Avatar name={name} src={me ? memberAvatar(me) : null} size={32} />}
title={name}
line={t('settings.home.account.line')}
/>
@@ -151,60 +214,62 @@ function YouEntry() {
function AssistantMark() {
return (
<span className="sh-mark" aria-hidden="true">
- <Icon name="waveform" size={20} />
+ <Icon name="waveform" size={16} />
</span>
)
}
-/** One entry: mark, title (with a quiet detail), one line on what is in there, a status, the chevron. All of it opens. */
-function Entry({
+/**
+ * One row: a SettingRow (mark, title with a quiet detail, at most one grey line, the state at the right end) and the
+ * chevron. All of it is one link to the area's page; SettingRow has no link of its own, so the row wraps it.
+ */
+function Row({
href,
- mark,
+ lead,
title,
- meta,
+ aside,
line,
status,
tip,
}: {
href: string
- mark: ReactNode
+ lead: ReactNode
title: string
- meta?: string
- line: string
+ aside?: string
+ line?: string
status?: ReactNode
tip?: string
}) {
return (
- <a className="sh-entry" href={href} title={tip}>
- <span className="sh-entry-lead">{mark}</span>
- <span className="sh-entry-text">
- <span className="sh-entry-title">
- <b>{title}</b>
- {meta && <span className="sh-entry-meta">{meta}</span>}
- </span>
- <span className="sh-entry-line">{line}</span>
- </span>
- {status && <span className="sh-entry-status">{status}</span>}
- <Icon name="right" size={16} className="sh-entry-go" />
+ <a className="sh-row" href={href} title={tip}>
+ <SettingRow
+ lead={<span className="sh-lead">{lead}</span>}
+ title={<span className="sh-title">{title}</span>}
+ aside={aside}
+ description={line}
+ control={status}
+ />
+ <Icon name="right" size={16} className="sh-go" />
</a>
)
}
-/** The assistant's entry while it loads: the same row with its mark, title and line as grey shapes. */
-function EntrySkeleton() {
+/** An assistant's row while the assistants load: the same row with its mark, name and state as grey shapes. */
+function RowSkeleton() {
return (
- <div className="sh-entry" aria-hidden="true">
- <span className="sh-entry-lead">
- <Skeleton width={40} height={40} className="sh-mark-sk" />
- </span>
- <span className="sh-entry-text">
- <span className="sh-entry-title">
- <Skeleton shape="text" width={72} />
+ <div className="sh-row" aria-hidden="true">
+ <div className="k-setrow has-lead">
+ <span className="sh-lead">
+ <Skeleton width={32} height={32} className="sh-mark-sk" />
</span>
- <span className="sh-entry-line">
- <Skeleton shape="text" width={260} />
- </span>
- </span>
+ <div className="k-setrow-text">
+ <Skeleton shape="text" width={140} />
+ </div>
+ <div className="k-setrow-end">
+ <Skeleton shape="text" width={110} />
+ </div>
+ </div>
+ <span className="sh-go-sk" />
</div>
)
}
diff --git a/apps/web/src/settings/settings-home.css b/apps/web/src/settings/settings-home.css
index 385412ff..41d69c10 100644
--- a/apps/web/src/settings/settings-home.css
+++ b/apps/web/src/settings/settings-home.css
@@ -1,53 +1,102 @@
-/* Settings (SettingsHome.tsx): one raised card with three entries (the assistant, the workspace, you), divided by
- hairlines. Each entry is a link: mark, title, one line, a quiet status, the chevron. */
+/* Settings (SettingsHome.tsx): three groups (Assistants, Workspace, You), each a LineGroup label over a raised card of
+ rows. A row is a SettingRow wrapped in a link (or New assistant's button) with the chevron, so the whole row opens
+ and its hover reaches the card's edges: the card has no padding of its own, the row carries it. */
.page-in.sh-page {
max-width: 680px;
+ gap: 24px;
}
-.sh-list {
+.sh-group {
+ display: grid;
+ gap: 8px;
+ min-width: 0;
+}
+.sh-group > .k-line-group {
+ margin: 0 2px;
+}
+.sh-card {
gap: 0;
padding: 0;
overflow: hidden;
}
+.sh-card .k-setrows {
+ gap: 0;
+}
-.sh-entry {
+.sh-row {
box-sizing: border-box;
display: flex;
align-items: center;
- gap: 14px;
- min-height: 72px;
- padding: 14px 16px;
+ gap: 12px;
+ width: 100%;
+ min-height: 56px;
+ padding: 10px 16px;
color: var(--ink);
text-decoration: none;
+ text-align: left;
+ font: inherit;
+ background: none;
+ border: 0;
border-top: 1px solid var(--line);
transition: background-color 120ms;
}
-.sh-list > .sh-entry:first-child,
-.sh-list > :first-child > .sh-entry:first-child {
+.sh-row:first-child {
border-top: 0;
}
-a.sh-entry:hover {
+a.sh-row:hover,
+button.sh-row:hover:not(:disabled) {
background: var(--surface-hover);
}
-a.sh-entry:focus-visible {
+.sh-row:focus-visible {
outline: 2px solid var(--focus);
outline-offset: -2px;
}
+button.sh-row {
+ cursor: pointer;
+}
+button.sh-row:disabled {
+ cursor: progress;
+}
+/* The SettingRow inside: the row around it draws the line and the padding. */
+.sh-row > .k-setrow {
+ flex: 1;
+ padding-top: 0;
+ border-top: 0;
+}
+.sh-row .k-setrow-title {
+ font-size: 14px;
+ line-height: 20px;
+}
+.sh-row .k-setrow-aside {
+ margin-left: 6px;
+ font-size: 13px;
+ font-variant-numeric: tabular-nums;
+}
+.sh-title {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
-.sh-entry-lead {
+/* One 32px mark for all: the assistant's square, the workspace's square, your round picture, New's plus. */
+.sh-lead {
display: inline-flex;
+ align-items: center;
+ justify-content: center;
flex: none;
+ width: 32px;
+ height: 32px;
}
-/* One mark size for all three: the assistant's square, the workspace's square, your round picture. */
-.sh-entry-lead .ws-initial.is-lg {
- width: 40px;
- height: 40px;
- font-size: 16px;
+.sh-lead .ws-initial.is-lg {
+ width: 32px;
+ height: 32px;
+ font-size: 14px;
}
.sh-mark {
display: grid;
place-items: center;
- width: 40px;
- height: 40px;
+ width: 32px;
+ height: 32px;
border-radius: var(--radius-md);
background: var(--signal);
color: var(--on-signal);
@@ -55,66 +104,42 @@ a.sh-entry:focus-visible {
.sh-mark-sk {
border-radius: var(--radius-md);
}
-
-.sh-entry-text {
- display: grid;
- gap: 2px;
- flex: 1;
- min-width: 0;
-}
-.sh-entry-title {
- display: flex;
- align-items: baseline;
- gap: 10px;
- min-width: 0;
- font-size: 15px;
- line-height: 22px;
-}
-.sh-entry-title b {
- font-weight: 600;
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-.sh-entry-meta {
- flex: none;
- font-size: 13px;
- color: var(--ink-muted);
- font-variant-numeric: tabular-nums;
-}
-.sh-entry-line {
- font-size: 13px;
- line-height: 18px;
+.sh-add .sh-lead,
+.sh-add .k-setrow-title {
color: var(--ink-muted);
+ font-weight: 500;
}
-.sh-entry-status {
+.sh-state {
display: inline-flex;
align-items: center;
gap: 6px;
- flex: none;
font-size: 13px;
color: var(--ink-muted);
}
-.sh-entry-go {
+.sh-go {
flex: none;
color: var(--ink-muted);
}
+.sh-go-sk {
+ flex: none;
+ width: 16px;
+}
-/* Phone: the status goes under the line, so the title and its line keep the width. */
+/* Phone: the state goes under the name, so the name and its number keep the width. */
@media (max-width: 560px) {
- .sh-entry {
+ .sh-row {
+ padding: 10px 14px;
+ }
+ .sh-row > .k-setrow {
flex-wrap: wrap;
- row-gap: 6px;
- padding: 14px;
+ row-gap: 4px;
}
- .sh-entry-text {
- flex-basis: calc(100% - 40px - 14px - 16px - 28px);
+ .sh-row > .k-setrow > .k-setrow-text {
+ flex-basis: calc(100% - 44px);
}
- .sh-entry-status {
- order: 3;
+ .sh-row > .k-setrow > .k-setrow-end {
flex-basis: 100%;
- padding-left: 54px;
+ padding-left: 44px;
}
}
diff --git a/apps/web/src/shell/pages.tsx b/apps/web/src/shell/pages.tsx
index e6bb6867..1903ce82 100644
--- a/apps/web/src/shell/pages.tsx
+++ b/apps/web/src/shell/pages.tsx
@@ -71,13 +71,19 @@ export const pages = {
},
render: p => <Insights canEdit={p.canEditSettings} toast={p.toast} />,
},
- // Every setting starts here: three entries, the assistant, the workspace and you (G S).
+ // Every setting starts here: three groups, the assistants, the workspace and you (G S).
settings: {
get title() {
return i18n().t('shell.page.settings')
},
render: p => (
- <SettingsHome billing={!!p.billing} workspaceName={p.workspaceName} isInstanceAdmin={p.isInstanceAdmin} />
+ <SettingsHome
+ billing={!!p.billing}
+ workspaceName={p.workspaceName}
+ isInstanceAdmin={p.isInstanceAdmin}
+ canEdit={p.canEditSettings}
+ toast={p.toast}
+ />
),
},
assistant: {
diff --git a/packages/i18n/locales/en/settings.json b/packages/i18n/locales/en/settings.json
index f90a87b5..aa3a3651 100644
--- a/packages/i18n/locales/en/settings.json
+++ b/packages/i18n/locales/en/settings.json
@@ -899,13 +899,14 @@
"holidays.vacation.turnOn": "Turn on",
"holidays.vacation.until": "Last day closed",
"holidays.yourDay": "Your day",
- "home.account.line": "Your profile, notifications, sign-in and API keys.",
+ "home.account.line": "Profile, notifications, sign-in and API keys.",
"home.assistant.answering": "Answering calls",
- "home.assistant.line": "How {name} answers calls and what happens after.",
- "home.assistant.lineNone": "How your assistant answers calls and what happens after.",
"home.assistant.noNumber": "No number yet",
- "home.workspace.line": "Team, phone numbers and billing, shared by everyone.",
- "home.workspace.lineNoBilling": "Team and phone numbers, shared by everyone.",
+ "home.group.assistants": "Assistants",
+ "home.group.workspace": "Workspace",
+ "home.group.you": "You",
+ "home.workspace.line": "Shared by everyone: team, phone numbers, billing.",
+ "home.workspace.lineNoBilling": "Shared by everyone: team and phone numbers.",
"hours.byDay": "Opening hours by day",
"hours.changeTip": "Change your business hours",
"hours.closed": "Closed",