moi-computer 0.12.1-next.2 → 0.12.1-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/app/app-router.tsx +2 -0
- package/client/app/routes/settings-route.tsx +10 -0
- package/client/app/shell/sidebar-layout.tsx +34 -53
- package/client/features/account/account-menu.tsx +96 -0
- package/client/features/account/account-provider.tsx +142 -0
- package/client/features/account/account-test-utils.tsx +293 -0
- package/client/features/account/api.ts +142 -0
- package/client/features/account/identity.ts +23 -0
- package/client/features/collab/applet-api.ts +15 -14
- package/client/features/collab/components/cursors.tsx +61 -24
- package/client/features/collab/components/presence-avatars.tsx +25 -12
- package/client/features/collab/components/presence-frame.tsx +20 -24
- package/client/features/collab/components/presence-group.tsx +15 -7
- package/client/features/collab/components/user-avatar-group.tsx +21 -8
- package/client/features/collab/components/user-avatar.tsx +38 -7
- package/client/features/collab/components/user.tsx +31 -12
- package/client/features/collab/users.ts +0 -5
- package/client/features/collab/workspace-users-menu.tsx +3 -3
- package/client/features/dev/collab/collab-playground.tsx +7 -7
- package/client/features/dev/collab/local-user-settings.tsx +7 -53
- package/client/features/settings/connectors-settings.tsx +3 -3
- package/client/features/settings/environment-settings.tsx +3 -3
- package/client/features/settings/general-settings.tsx +1 -1
- package/client/features/settings/profile-settings.tsx +95 -0
- package/client/features/settings/settings-page.tsx +44 -0
- package/client/features/settings/settings-section.tsx +26 -0
- package/client/features/settings/users-settings.tsx +195 -0
- package/client/features/update/update-control.tsx +1 -1
- package/client/features/workspace/add/create-workspace-dialog.tsx +5 -2
- package/client/lib/user-display-name.ts +6 -0
- package/client/main.tsx +4 -1
- package/dist/{chunk-vt6zybej.js → chunk-20ynagd4.js} +2 -2
- package/dist/chunk-42tde9a6.js +1 -0
- package/dist/{chunk-hmka9rt5.js → chunk-9w543s0r.js} +2 -2
- package/dist/{chunk-y8nbwp21.js → chunk-a5372n61.js} +2 -2
- package/dist/chunk-aja9y1vn.js +68 -0
- package/dist/chunk-fvcvrh3d.css +1 -0
- package/dist/{chunk-ysfdcew7.js → chunk-gtfjw3nx.js} +1 -1
- package/dist/{chunk-hvh9f5h0.js → chunk-j39y2aky.js} +1 -1
- package/dist/chunk-pja30km3.js +1 -0
- package/dist/{chunk-d7cbm65e.js → chunk-rm894bc2.js} +1 -1
- package/dist/chunk-tevvtfbk.js +10 -0
- package/dist/{chunk-am4agx6v.js → chunk-tgt9zd0r.js} +1 -1
- package/dist/chunk-tv5k5z00.js +1 -0
- package/dist/chunk-zq2ae5dx.js +2 -0
- package/dist/index.html +1 -1
- package/lib/types.ts +1 -1
- package/package.json +1 -1
- package/server/api/index.ts +2 -6
- package/server/app-config.ts +7 -0
- package/server/web.ts +1 -0
- package/server/workspaces/init.ts +0 -10
- package/server/workspaces/registry.ts +31 -9
- package/dist/chunk-00rh9df4.js +0 -2
- package/dist/chunk-4nh7y1hq.css +0 -1
- package/dist/chunk-hbpdv7vd.js +0 -1
- package/dist/chunk-mjjregkn.js +0 -10
- package/dist/chunk-rt30jbcm.js +0 -1
- package/dist/chunk-wbkwf6cc.js +0 -68
- package/dist/chunk-xjyfyz64.js +0 -1
|
@@ -1,12 +1,42 @@
|
|
|
1
|
-
import type { UserAvatarProps } from 'moi/collab'
|
|
1
|
+
import type { UserAvatarProps as UserAvatarContainerProps } from 'moi/collab'
|
|
2
|
+
import type { UserProfile } from '@/lib/collab/types'
|
|
2
3
|
import { IconUser } from '@tabler/icons-react'
|
|
3
4
|
import { Blobatar } from '@blobatar/react'
|
|
4
5
|
import { Avatar, AvatarBadge, AvatarFallback, AvatarImage } from '@/ui-components/avatar'
|
|
6
|
+
import { cn } from '@/client/lib/cn'
|
|
7
|
+
import { userDisplayName } from '@/client/lib/user-display-name'
|
|
5
8
|
import { useUser } from '../hooks'
|
|
6
|
-
import { userDisplayName } from '../users'
|
|
7
9
|
|
|
8
|
-
export function
|
|
10
|
+
export function UserAvatarContainer({
|
|
11
|
+
id,
|
|
12
|
+
size,
|
|
13
|
+
showStatusBadge,
|
|
14
|
+
className
|
|
15
|
+
}: UserAvatarContainerProps) {
|
|
9
16
|
const user = useUser(id)
|
|
17
|
+
return (
|
|
18
|
+
<UserAvatar
|
|
19
|
+
profile={user}
|
|
20
|
+
size={size}
|
|
21
|
+
active={showStatusBadge && user?.status === 'active'}
|
|
22
|
+
className={className}
|
|
23
|
+
/>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type UserAvatarProps = {
|
|
28
|
+
profile?: UserProfile
|
|
29
|
+
size?: 'xs' | 'sm' | 'default' | 'lg'
|
|
30
|
+
className?: string
|
|
31
|
+
active?: boolean
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function UserAvatar({
|
|
35
|
+
profile: user,
|
|
36
|
+
size = 'default',
|
|
37
|
+
className,
|
|
38
|
+
active
|
|
39
|
+
}: UserAvatarProps) {
|
|
10
40
|
const name = user ? userDisplayName(user) : 'Unknown user'
|
|
11
41
|
|
|
12
42
|
return (
|
|
@@ -14,16 +44,17 @@ export function UserAvatar({ id, size = 'default', showStatusBadge, className }:
|
|
|
14
44
|
size={size}
|
|
15
45
|
aria-label={name}
|
|
16
46
|
data-collab-color={user?.color ?? 'unknown'}
|
|
17
|
-
className={className}
|
|
47
|
+
className={cn('after:border-0', className)}
|
|
18
48
|
>
|
|
19
49
|
{user?.avatar && <AvatarImage src={user.avatar} alt="" />}
|
|
20
50
|
<AvatarFallback>
|
|
21
51
|
{user ? (
|
|
22
52
|
<Blobatar
|
|
23
|
-
|
|
53
|
+
className="scale-150"
|
|
54
|
+
name={user.id}
|
|
24
55
|
animate="hover"
|
|
25
56
|
background="circle"
|
|
26
|
-
traits={{
|
|
57
|
+
traits={{ 'eye.rx': 1 }}
|
|
27
58
|
palette={{
|
|
28
59
|
bg: 'var(--collab)',
|
|
29
60
|
head: 'var(--collab)',
|
|
@@ -34,7 +65,7 @@ export function UserAvatar({ id, size = 'default', showStatusBadge, className }:
|
|
|
34
65
|
<IconUser size={size === 'xs' || size === 'sm' ? 12 : 16} stroke={1.75} />
|
|
35
66
|
)}
|
|
36
67
|
</AvatarFallback>
|
|
37
|
-
{
|
|
68
|
+
{active && <AvatarBadge className="bg-success" />}
|
|
38
69
|
</Avatar>
|
|
39
70
|
)
|
|
40
71
|
}
|
|
@@ -1,33 +1,52 @@
|
|
|
1
|
-
import type { UserProps } from 'moi/collab'
|
|
1
|
+
import type { UserProps as UserContainerProps } from 'moi/collab'
|
|
2
|
+
import type { ReactNode } from 'react'
|
|
3
|
+
import type { UserProfile } from '@/lib/collab/types'
|
|
2
4
|
import { cn } from '@/client/lib/cn'
|
|
3
5
|
import { UserAvatar } from './user-avatar'
|
|
6
|
+
import { userDisplayName } from '@/client/lib/user-display-name'
|
|
4
7
|
import { useMe, useUser } from '../hooks'
|
|
5
|
-
import { userDisplayName } from '../users'
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
export function UserContainer({ id, showStatusBadge, showYouLabel, ...props }: UserContainerProps) {
|
|
10
|
+
const user = useUser(id)
|
|
11
|
+
const me = useMe()
|
|
12
|
+
return (
|
|
13
|
+
<User
|
|
14
|
+
{...props}
|
|
15
|
+
profile={user}
|
|
16
|
+
active={showStatusBadge && user?.status === 'active'}
|
|
17
|
+
showYouLabel={showYouLabel && user !== undefined && user.id === me?.id}
|
|
18
|
+
/>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type UserProps = {
|
|
23
|
+
profile?: UserProfile
|
|
24
|
+
size?: 'xs' | 'sm' | 'default'
|
|
25
|
+
active?: boolean
|
|
26
|
+
showYouLabel?: boolean
|
|
27
|
+
description?: ReactNode
|
|
28
|
+
className?: string
|
|
29
|
+
}
|
|
8
30
|
|
|
9
31
|
export function User({
|
|
10
|
-
|
|
32
|
+
profile: user,
|
|
11
33
|
size = 'default',
|
|
12
|
-
|
|
34
|
+
active,
|
|
13
35
|
showYouLabel,
|
|
14
36
|
description,
|
|
15
37
|
className
|
|
16
38
|
}: UserProps) {
|
|
17
|
-
const
|
|
18
|
-
const me = useMe()
|
|
19
|
-
const name = user ? userDisplayName(user) : UNKNOWN_NAME
|
|
20
|
-
const isSelf = user !== undefined && user.id === me?.id
|
|
39
|
+
const name = user ? userDisplayName(user) : 'Unknown user'
|
|
21
40
|
|
|
22
41
|
return (
|
|
23
|
-
<span className={cn('
|
|
24
|
-
<UserAvatar
|
|
42
|
+
<span className={cn('flex min-w-0 items-center gap-2', className)}>
|
|
43
|
+
<UserAvatar profile={user} size={size} active={active} />
|
|
25
44
|
<span
|
|
26
45
|
className={cn('flex min-w-0 flex-1 text-sm', size === 'xs' ? 'items-baseline' : 'flex-col')}
|
|
27
46
|
>
|
|
28
47
|
<span className="flex min-w-0 items-baseline gap-1">
|
|
29
48
|
<span className={cn('truncate', !user && 'text-muted-foreground')}>{name}</span>
|
|
30
|
-
{showYouLabel &&
|
|
49
|
+
{showYouLabel && <span className="shrink-0 text-muted-foreground">(You)</span>}
|
|
31
50
|
</span>
|
|
32
51
|
{description && (
|
|
33
52
|
<span
|
|
@@ -13,11 +13,6 @@ export type UsersSource = {
|
|
|
13
13
|
users: readonly UserProfile[]
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
// Presentation only: keep the supplied profile unchanged in applet APIs.
|
|
17
|
-
export function userDisplayName(user: UserProfile): string {
|
|
18
|
-
return user.name?.trim() || user.email?.trim() || user.id
|
|
19
|
-
}
|
|
20
|
-
|
|
21
16
|
export function userStatus(connections: readonly Connection[], id: string): UserStatus {
|
|
22
17
|
const userConnections = connections.filter(connection => connection.userId === id)
|
|
23
18
|
return userConnections.some(connection => connection.location?.status === 'active')
|
|
@@ -16,8 +16,8 @@ import { cn } from '@/client/lib/cn'
|
|
|
16
16
|
import type { WorkspaceTabId } from '@/lib/types'
|
|
17
17
|
import { tabFromPath } from '@/lib/workspace-tabs'
|
|
18
18
|
|
|
19
|
-
import {
|
|
20
|
-
import { UserAvatarGroup } from './components/user-avatar-group'
|
|
19
|
+
import { UserContainer } from './components/user'
|
|
20
|
+
import { UserAvatarGroupContainer as UserAvatarGroup } from './components/user-avatar-group'
|
|
21
21
|
import { pageFromPath, useCollabEnabled, useCollabEngine } from './provider'
|
|
22
22
|
import { useConnectionState, useWorkspaceUsers } from './hooks'
|
|
23
23
|
import { summarizeWorkspaceUsers } from './users'
|
|
@@ -153,7 +153,7 @@ function UserRow({ user, page, describeTab, onOpenTab }: UserRowProps) {
|
|
|
153
153
|
: labels || 'Another tab'
|
|
154
154
|
const Icon = user.status === 'offline' ? undefined : tabs[0]?.info?.Icon
|
|
155
155
|
const content = (
|
|
156
|
-
<
|
|
156
|
+
<UserContainer
|
|
157
157
|
id={user.profile.id}
|
|
158
158
|
className="flex-1"
|
|
159
159
|
size="sm"
|
|
@@ -28,13 +28,13 @@ import {
|
|
|
28
28
|
} from '@/ui-components/select'
|
|
29
29
|
import type { UserProfile, Connection } from '@/lib/collab/types'
|
|
30
30
|
|
|
31
|
-
import { PresenceFrame } from '@/client/features/collab/components/presence-frame'
|
|
32
|
-
import { PresenceGroup } from '@/client/features/collab/components/presence-group'
|
|
33
|
-
import { PresenceAvatars } from '@/client/features/collab/components/presence-avatars'
|
|
34
|
-
import { Cursors } from '@/client/features/collab/components/cursors'
|
|
35
|
-
import { UserAvatarGroup } from '@/client/features/collab/components/user-avatar-group'
|
|
36
|
-
import { User } from '@/client/features/collab/components/user'
|
|
37
|
-
import { UserAvatar } from '@/client/features/collab/components/user-avatar'
|
|
31
|
+
import { PresenceFrameContainer as PresenceFrame } from '@/client/features/collab/components/presence-frame'
|
|
32
|
+
import { PresenceGroupContainer as PresenceGroup } from '@/client/features/collab/components/presence-group'
|
|
33
|
+
import { PresenceAvatarsContainer as PresenceAvatars } from '@/client/features/collab/components/presence-avatars'
|
|
34
|
+
import { CursorsContainer as Cursors } from '@/client/features/collab/components/cursors'
|
|
35
|
+
import { UserAvatarGroupContainer as UserAvatarGroup } from '@/client/features/collab/components/user-avatar-group'
|
|
36
|
+
import { UserContainer as User } from '@/client/features/collab/components/user'
|
|
37
|
+
import { UserAvatarContainer as UserAvatar } from '@/client/features/collab/components/user-avatar'
|
|
38
38
|
import { createFakeEngine } from '@/client/features/collab/testing/fake-engine'
|
|
39
39
|
import type { FakeEngine } from '@/client/features/collab/testing/fake-engine'
|
|
40
40
|
import {
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useSyncExternalStore } from 'react'
|
|
2
2
|
|
|
3
|
-
import { IconArrowsShuffle } from '@tabler/icons-react'
|
|
4
|
-
|
|
5
|
-
import { Button } from '@/client/components/ui/button'
|
|
6
|
-
import { Input } from '@/client/components/ui/input'
|
|
7
|
-
import { useAppConfig } from '@/client/api/app-config'
|
|
8
3
|
import { USER_COLORS } from '@/lib/collab/colors'
|
|
9
4
|
import type { UserProfile } from '@/lib/collab/types'
|
|
10
5
|
import { User } from '@/client/features/collab/components/user'
|
|
11
6
|
import { UserAvatar } from '@/client/features/collab/components/user-avatar'
|
|
12
|
-
import { randomLocalUser } from '@/client/features/collab/local-user'
|
|
13
7
|
import {
|
|
14
8
|
getCurrentUser,
|
|
15
9
|
getCurrentUserSource,
|
|
@@ -18,7 +12,6 @@ import {
|
|
|
18
12
|
} from '@/client/features/collab/host-state'
|
|
19
13
|
|
|
20
14
|
export function LocalUserSettings() {
|
|
21
|
-
const { experimental } = useAppConfig()
|
|
22
15
|
const source = useSyncExternalStore(
|
|
23
16
|
subscribeCurrentUserStore,
|
|
24
17
|
getCurrentUserSource,
|
|
@@ -34,14 +27,7 @@ export function LocalUserSettings() {
|
|
|
34
27
|
Local user
|
|
35
28
|
</h2>
|
|
36
29
|
<p className="text-sm text-muted-foreground">
|
|
37
|
-
|
|
38
|
-
'Couldn’t resolve your user identity. Reload Moi to try again.'
|
|
39
|
-
) : (
|
|
40
|
-
<>
|
|
41
|
-
Start Moi with <code className="font-mono">--experimental-collab</code> to create a
|
|
42
|
-
local user automatically. The playground below uses its own sample users.
|
|
43
|
-
</>
|
|
44
|
-
)}
|
|
30
|
+
Couldn’t resolve your user identity. Reload Moi to try again.
|
|
45
31
|
</p>
|
|
46
32
|
</section>
|
|
47
33
|
)
|
|
@@ -64,7 +50,7 @@ function AccessUser({ profile }: AccessUserProps) {
|
|
|
64
50
|
: 'This server uses Cloudflare Access, but this page wasn’t opened through it. Open Moi at its Cloudflare Access address to appear in workspaces.'}
|
|
65
51
|
</p>
|
|
66
52
|
</header>
|
|
67
|
-
{profile && <User
|
|
53
|
+
{profile && <User profile={profile} />}
|
|
68
54
|
</section>
|
|
69
55
|
)
|
|
70
56
|
}
|
|
@@ -72,9 +58,6 @@ function AccessUser({ profile }: AccessUserProps) {
|
|
|
72
58
|
type LocalUserEditorProps = { profile: UserProfile }
|
|
73
59
|
|
|
74
60
|
function LocalUserEditor({ profile }: LocalUserEditorProps) {
|
|
75
|
-
// Keep raw input so normalization doesn't eat spaces while a name is being typed.
|
|
76
|
-
const [name, setName] = useState(profile.name ?? '')
|
|
77
|
-
|
|
78
61
|
return (
|
|
79
62
|
<section aria-labelledby="local-user-title" className="flex flex-col gap-5">
|
|
80
63
|
<header>
|
|
@@ -82,8 +65,7 @@ function LocalUserEditor({ profile }: LocalUserEditorProps) {
|
|
|
82
65
|
Local user
|
|
83
66
|
</h2>
|
|
84
67
|
<p className="mt-1 text-sm text-muted-foreground">
|
|
85
|
-
|
|
86
|
-
users, open Moi in another browser tab.
|
|
68
|
+
Change your avatar color here. Edit your name in Settings.
|
|
87
69
|
</p>
|
|
88
70
|
</header>
|
|
89
71
|
<div className="flex flex-col gap-5">
|
|
@@ -94,23 +76,9 @@ function LocalUserEditor({ profile }: LocalUserEditorProps) {
|
|
|
94
76
|
aria-label="Local user preview"
|
|
95
77
|
className="size-16 shrink-0 overflow-hidden rounded-full"
|
|
96
78
|
>
|
|
97
|
-
<UserAvatar
|
|
79
|
+
<UserAvatar profile={profile} className="data-[size=default]:size-full" />
|
|
98
80
|
</div>
|
|
99
81
|
<div className="flex w-full max-w-sm min-w-0 flex-col gap-4">
|
|
100
|
-
<label className="flex flex-col gap-1.5 text-sm">
|
|
101
|
-
Name (optional)
|
|
102
|
-
<Input
|
|
103
|
-
value={name}
|
|
104
|
-
maxLength={80}
|
|
105
|
-
placeholder="Type a name"
|
|
106
|
-
autoComplete="off"
|
|
107
|
-
spellCheck={false}
|
|
108
|
-
onChange={event => {
|
|
109
|
-
setName(event.target.value)
|
|
110
|
-
setLocalUser({ ...profile, name: event.target.value })
|
|
111
|
-
}}
|
|
112
|
-
/>
|
|
113
|
-
</label>
|
|
114
82
|
<div className="flex flex-col gap-1.5 text-sm">
|
|
115
83
|
<span id="collab-color-label">Color</span>
|
|
116
84
|
<div
|
|
@@ -140,25 +108,11 @@ function LocalUserEditor({ profile }: LocalUserEditorProps) {
|
|
|
140
108
|
))}
|
|
141
109
|
</div>
|
|
142
110
|
</div>
|
|
143
|
-
<div className="flex flex-wrap gap-2">
|
|
144
|
-
<Button
|
|
145
|
-
type="button"
|
|
146
|
-
variant="secondary"
|
|
147
|
-
size="sm"
|
|
148
|
-
onClick={() => {
|
|
149
|
-
const next = randomLocalUser({ name, color: profile.color })
|
|
150
|
-
setName(next.name)
|
|
151
|
-
setLocalUser({ ...profile, ...next })
|
|
152
|
-
}}
|
|
153
|
-
>
|
|
154
|
-
<IconArrowsShuffle stroke={1.75} />
|
|
155
|
-
Randomize
|
|
156
|
-
</Button>
|
|
157
|
-
</div>
|
|
158
111
|
</div>
|
|
159
112
|
</div>
|
|
160
113
|
<p className="text-sm text-muted-foreground">
|
|
161
|
-
Your user is saved in this browser
|
|
114
|
+
Your user is saved in this browser and shared across tabs. The playground below uses its
|
|
115
|
+
own sample users.
|
|
162
116
|
</p>
|
|
163
117
|
</div>
|
|
164
118
|
</section>
|
|
@@ -36,7 +36,7 @@ function ConnectorsContent({ connectors }: ConnectorsContentProps) {
|
|
|
36
36
|
if (connectors.isError) {
|
|
37
37
|
return (
|
|
38
38
|
<ConnectorsState>
|
|
39
|
-
<p className="text-sm text-muted-foreground">Could not load connectors
|
|
39
|
+
<p className="text-sm text-muted-foreground">Could not load connectors</p>
|
|
40
40
|
<Button variant="outline" size="sm" onClick={() => connectors.refetch()}>
|
|
41
41
|
Retry
|
|
42
42
|
</Button>
|
|
@@ -48,7 +48,7 @@ function ConnectorsContent({ connectors }: ConnectorsContentProps) {
|
|
|
48
48
|
return (
|
|
49
49
|
<ConnectorsState>
|
|
50
50
|
<IconPlugConnected size={24} stroke={1.5} className="text-muted-foreground" />
|
|
51
|
-
<p className="text-sm text-foreground">No connectors configured
|
|
51
|
+
<p className="text-sm text-foreground">No connectors configured</p>
|
|
52
52
|
</ConnectorsState>
|
|
53
53
|
)
|
|
54
54
|
}
|
|
@@ -81,7 +81,7 @@ export function ConnectorsSettings() {
|
|
|
81
81
|
return (
|
|
82
82
|
<SettingsPage
|
|
83
83
|
title="Connectors"
|
|
84
|
-
description="Connectors available to the agent in this workspace
|
|
84
|
+
description="Connectors available to the agent in this workspace"
|
|
85
85
|
>
|
|
86
86
|
<ConnectorsContent connectors={connectors} />
|
|
87
87
|
</SettingsPage>
|
|
@@ -57,7 +57,7 @@ export function EnvironmentSettings() {
|
|
|
57
57
|
<IconLoader2 className="size-4 animate-spin" stroke={1.75} />
|
|
58
58
|
</div>
|
|
59
59
|
) : variables.length === 0 ? (
|
|
60
|
-
<p className="px-3.5 py-4 text-sm text-muted-foreground">No variables yet
|
|
60
|
+
<p className="px-3.5 py-4 text-sm text-muted-foreground">No variables yet</p>
|
|
61
61
|
) : (
|
|
62
62
|
variables.map(variable => {
|
|
63
63
|
const editable = variable.source !== 'dotenv'
|
|
@@ -132,8 +132,8 @@ export function EnvironmentSettings() {
|
|
|
132
132
|
title="Inherit .env files"
|
|
133
133
|
description={
|
|
134
134
|
dotenvFiles > 0
|
|
135
|
-
? `Discovered ${fileCount} ${fileCount === 1 ? 'key' : 'keys'} across ${dotenvFiles} ${dotenvFiles === 1 ? 'file' : 'files'} in this space
|
|
136
|
-
: 'No .env files found in this space
|
|
135
|
+
? `Discovered ${fileCount} ${fileCount === 1 ? 'key' : 'keys'} across ${dotenvFiles} ${dotenvFiles === 1 ? 'file' : 'files'} in this space`
|
|
136
|
+
: 'No .env files found in this space'
|
|
137
137
|
}
|
|
138
138
|
control={
|
|
139
139
|
<Switch
|
|
@@ -32,7 +32,7 @@ export function GeneralSettings() {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
return (
|
|
35
|
-
<SettingsPage title="General" description="Basic details for this space
|
|
35
|
+
<SettingsPage title="General" description="Basic details for this space">
|
|
36
36
|
<SettingsSection>
|
|
37
37
|
<SettingsRow
|
|
38
38
|
title="Path"
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useId, useRef, useState } from 'react'
|
|
2
|
+
import { useMutation } from '@tanstack/react-query'
|
|
3
|
+
import { Field, FieldGroup, FieldLabel } from '@/ui-components/field'
|
|
4
|
+
import { Input } from '@/client/components/ui/input'
|
|
5
|
+
import { toast } from '@/client/components/ui/toast'
|
|
6
|
+
import { useAccount } from '../account/account-provider'
|
|
7
|
+
import { SettingsSection } from './settings-section'
|
|
8
|
+
|
|
9
|
+
export function ProfileSettings() {
|
|
10
|
+
const account = useAccount()
|
|
11
|
+
if (!account.profile) return null
|
|
12
|
+
return (
|
|
13
|
+
<SettingsSection title="Profile">
|
|
14
|
+
<FieldGroup>
|
|
15
|
+
<NameField
|
|
16
|
+
key={account.profile.id}
|
|
17
|
+
name={account.profile.name ?? ''}
|
|
18
|
+
readOnly={!account.canEdit}
|
|
19
|
+
onSave={account.saveName}
|
|
20
|
+
/>
|
|
21
|
+
{account.email && (
|
|
22
|
+
<Field>
|
|
23
|
+
<FieldLabel htmlFor="profile-email">Email</FieldLabel>
|
|
24
|
+
<Input id="profile-email" value={account.email} readOnly type="email" />
|
|
25
|
+
</Field>
|
|
26
|
+
)}
|
|
27
|
+
</FieldGroup>
|
|
28
|
+
</SettingsSection>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type NameFieldProps = {
|
|
33
|
+
name: string
|
|
34
|
+
readOnly?: boolean
|
|
35
|
+
onSave: (name: string) => Promise<string>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function NameField({ name, readOnly, onSave }: NameFieldProps) {
|
|
39
|
+
const id = useId()
|
|
40
|
+
const [draft, setDraft] = useState<string>()
|
|
41
|
+
const save = useMutation({
|
|
42
|
+
mutationFn: onSave,
|
|
43
|
+
onSuccess: () => setDraft(undefined),
|
|
44
|
+
onError: error =>
|
|
45
|
+
toast.add({ title: 'Couldn’t save name', description: error.message, type: 'error' })
|
|
46
|
+
})
|
|
47
|
+
const pending = save.isPending
|
|
48
|
+
const skipBlur = useRef(false)
|
|
49
|
+
|
|
50
|
+
function commit() {
|
|
51
|
+
if (readOnly || pending) return
|
|
52
|
+
const next = (draft ?? name).trim()
|
|
53
|
+
if (!next || next.length > 80 || next === name) {
|
|
54
|
+
setDraft(undefined)
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
setDraft(next)
|
|
58
|
+
save.mutate(next)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Field>
|
|
63
|
+
<FieldLabel htmlFor={id}>Name</FieldLabel>
|
|
64
|
+
<Input
|
|
65
|
+
id={id}
|
|
66
|
+
value={draft ?? name}
|
|
67
|
+
autoComplete="name"
|
|
68
|
+
maxLength={80}
|
|
69
|
+
readOnly={readOnly}
|
|
70
|
+
disabled={pending}
|
|
71
|
+
onChange={event => setDraft(event.target.value)}
|
|
72
|
+
onBlur={() => {
|
|
73
|
+
if (skipBlur.current) {
|
|
74
|
+
skipBlur.current = false
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
void commit()
|
|
78
|
+
}}
|
|
79
|
+
onKeyDown={event => {
|
|
80
|
+
if (event.nativeEvent.isComposing) return
|
|
81
|
+
if (event.key === 'Enter') {
|
|
82
|
+
event.preventDefault()
|
|
83
|
+
event.currentTarget.blur()
|
|
84
|
+
}
|
|
85
|
+
if (event.key === 'Escape') {
|
|
86
|
+
event.preventDefault()
|
|
87
|
+
skipBlur.current = true
|
|
88
|
+
setDraft(undefined)
|
|
89
|
+
event.currentTarget.blur()
|
|
90
|
+
}
|
|
91
|
+
}}
|
|
92
|
+
/>
|
|
93
|
+
</Field>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
import { Redirect } from 'wouter'
|
|
3
|
+
import { Button } from '@/client/components/ui/button'
|
|
4
|
+
import { Skeleton } from '@/client/components/ui/skeleton'
|
|
5
|
+
import { useAccount } from '../account/account-provider'
|
|
6
|
+
import { ProfileSettings } from './profile-settings'
|
|
7
|
+
import { UsersSettings } from './users-settings'
|
|
8
|
+
|
|
9
|
+
export function SettingsPage() {
|
|
10
|
+
const account = useAccount()
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (account.cloud && !account.demo && account.status === 'signed-out') {
|
|
13
|
+
window.location.replace('/cloud/login')
|
|
14
|
+
}
|
|
15
|
+
}, [account.cloud, account.demo, account.status, account.registered])
|
|
16
|
+
if (account.demo) return <Redirect to="/" replace />
|
|
17
|
+
if (account.status === 'signed-out') return null
|
|
18
|
+
return (
|
|
19
|
+
<div className="min-h-0 flex-1 overflow-y-auto">
|
|
20
|
+
<div className="mx-auto flex w-full max-w-3xl flex-col gap-6 px-6 py-8 sm:px-10 sm:py-12">
|
|
21
|
+
<h1 className="text-xl font-medium">Settings</h1>
|
|
22
|
+
{account.status === 'loading' ? (
|
|
23
|
+
<div className="flex flex-col gap-4" aria-label="Loading settings">
|
|
24
|
+
<Skeleton className="h-7 w-32" />
|
|
25
|
+
<Skeleton className="h-10 w-full max-w-md" />
|
|
26
|
+
<Skeleton className="h-10 w-full max-w-md" />
|
|
27
|
+
</div>
|
|
28
|
+
) : account.status === 'error' ? (
|
|
29
|
+
<div className="flex flex-col items-start gap-3">
|
|
30
|
+
<p role="alert">Couldn’t load your account</p>
|
|
31
|
+
<Button variant="outline" onClick={account.retry}>
|
|
32
|
+
Try again
|
|
33
|
+
</Button>
|
|
34
|
+
</div>
|
|
35
|
+
) : (
|
|
36
|
+
<div className="flex w-full max-w-xl min-w-0 flex-col gap-4">
|
|
37
|
+
<ProfileSettings />
|
|
38
|
+
{account.registered && <UsersSettings />}
|
|
39
|
+
</div>
|
|
40
|
+
)}
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useId } from 'react'
|
|
2
|
+
import type { ReactNode } from 'react'
|
|
3
|
+
|
|
4
|
+
type SettingsSectionProps = {
|
|
5
|
+
title: string
|
|
6
|
+
description?: ReactNode
|
|
7
|
+
children: ReactNode
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function SettingsSection({ title, description, children }: SettingsSectionProps) {
|
|
11
|
+
const headingId = useId()
|
|
12
|
+
return (
|
|
13
|
+
<section
|
|
14
|
+
aria-labelledby={headingId}
|
|
15
|
+
className="-mx-6 flex min-w-0 flex-col rounded-2xl bg-background p-6 shadow-xs"
|
|
16
|
+
>
|
|
17
|
+
<header className="mb-6 flex flex-col gap-1">
|
|
18
|
+
<h2 id={headingId} className="text-lg font-medium">
|
|
19
|
+
{title}
|
|
20
|
+
</h2>
|
|
21
|
+
{description && <p className="text-sm text-muted-foreground">{description}</p>}
|
|
22
|
+
</header>
|
|
23
|
+
<div className="flex min-w-0 flex-col gap-6">{children}</div>
|
|
24
|
+
</section>
|
|
25
|
+
)
|
|
26
|
+
}
|