@dxos/react-ui 0.1.28 → 0.1.30-next.7c60cd3
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/dist/lib/browser/index.mjs +161 -18
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/composites/Shell/Shell.d.ts.map +1 -1
- package/dist/types/src/composites/Shell/Shell.stories.d.ts +10 -0
- package/dist/types/src/composites/Shell/Shell.stories.d.ts.map +1 -0
- package/dist/types/src/composites/Shell/ShellContext.d.ts +21 -0
- package/dist/types/src/composites/Shell/ShellContext.d.ts.map +1 -0
- package/dist/types/src/composites/Shell/index.d.ts +1 -0
- package/dist/types/src/composites/Shell/index.d.ts.map +1 -1
- package/dist/types/src/panels/JoinPanel/JoinHeading.d.ts.map +1 -1
- package/dist/types/src/panels/SpacePanel/SpacePanel.d.ts +1 -1
- package/dist/types/src/panels/SpacePanel/SpacePanel.d.ts.map +1 -1
- package/dist/types/src/panels/SpacePanel/SpacePanel.stories.d.ts +1 -2
- package/dist/types/src/panels/SpacePanel/SpacePanel.stories.d.ts.map +1 -1
- package/dist/types/src/playwright/invitations-manager.d.ts +33 -0
- package/dist/types/src/playwright/invitations-manager.d.ts.map +1 -0
- package/dist/types/src/playwright/invitations.spec.d.ts +2 -0
- package/dist/types/src/playwright/invitations.spec.d.ts.map +1 -0
- package/dist/types/src/playwright/playwright.config.d.ts +3 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
- package/dist/types/src/stories/Invitations.stories.d.ts +14 -0
- package/dist/types/src/stories/Invitations.stories.d.ts.map +1 -0
- package/dist/types/src/translations/locales/en-US.d.ts +5 -0
- package/dist/types/src/translations/locales/en-US.d.ts.map +1 -1
- package/package.json +14 -12
- package/src/components/InvitationList/InvitationList.stories.tsx +1 -1
- package/src/components/SpaceList/SpaceListItem.tsx +1 -1
- package/src/composites/JoinDialog/JoinDialog.stories.tsx +1 -1
- package/src/composites/Shell/Shell.stories.tsx +76 -0
- package/src/composites/Shell/Shell.tsx +16 -2
- package/src/composites/Shell/ShellContext.tsx +175 -0
- package/src/composites/Shell/index.ts +1 -0
- package/src/panels/DevicesPanel/DevicesPanel.tsx +2 -2
- package/src/panels/JoinPanel/JoinHeading.tsx +4 -3
- package/src/panels/JoinPanel/JoinPanel.tsx +1 -1
- package/src/panels/JoinPanel/view-states/InvitationAuthenticator.tsx +2 -2
- package/src/panels/JoinPanel/view-states/InvitationInput.tsx +1 -1
- package/src/panels/SpacePanel/SpacePanel.stories.tsx +2 -40
- package/src/panels/SpacePanel/SpacePanel.tsx +5 -5
- package/src/playwright/invitations-manager.ts +210 -0
- package/src/playwright/invitations.spec.ts +363 -0
- package/src/playwright/playwright.config.ts +7 -0
- package/src/stories/Invitations.stories.tsx +165 -0
- package/src/translations/locales/en-US.ts +6 -1
- package/dist/types/src/testing/ClientProvider.d.ts +0 -3
- package/dist/types/src/testing/ClientProvider.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -2
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/src/testing/ClientProvider.tsx +0 -18
- package/src/testing/index.ts +0 -5
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxosTheme';
|
|
6
|
+
import { faker } from '@faker-js/faker';
|
|
7
|
+
import { Intersect, Laptop, Planet, Plus, PlusCircle, QrCode } from 'phosphor-react';
|
|
8
|
+
import React, { useMemo, useState } from 'react';
|
|
9
|
+
|
|
10
|
+
import { Space, SpaceProxy, useClient, useIdentity, useSpaces } from '@dxos/react-client';
|
|
11
|
+
import { ClientDecorator } from '@dxos/react-client/testing';
|
|
12
|
+
import { Button, ButtonGroup, getSize, Group } from '@dxos/react-components';
|
|
13
|
+
|
|
14
|
+
import { IdentityListItem, SpaceListItem } from '../components';
|
|
15
|
+
import { DevicesPanel, JoinPanel, SpacePanel } from '../panels';
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
title: 'Invitations'
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type PanelType = Space | 'identity' | 'devices' | 'join';
|
|
22
|
+
|
|
23
|
+
const createInvitationUrl = (invitation: string) => invitation;
|
|
24
|
+
|
|
25
|
+
const Panel = ({ id, panel, setPanel }: { id: number; panel?: PanelType; setPanel: (panel?: PanelType) => void }) => {
|
|
26
|
+
const client = useClient();
|
|
27
|
+
const spaces = useSpaces();
|
|
28
|
+
|
|
29
|
+
useMemo(() => {
|
|
30
|
+
if (panel instanceof SpaceProxy) {
|
|
31
|
+
(window as any)[`peer${id}space`] = panel;
|
|
32
|
+
}
|
|
33
|
+
}, [panel]);
|
|
34
|
+
|
|
35
|
+
if (panel instanceof SpaceProxy) {
|
|
36
|
+
return <SpacePanel space={panel} createInvitationUrl={createInvitationUrl} />;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
switch (panel) {
|
|
40
|
+
case 'identity': {
|
|
41
|
+
return <JoinPanel mode='halo-only' onDone={() => setPanel(undefined)} onExit={() => setPanel(undefined)} />;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
case 'devices': {
|
|
45
|
+
return <DevicesPanel createInvitationUrl={createInvitationUrl} onDone={() => setPanel(undefined)} />;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
case 'join': {
|
|
49
|
+
return <JoinPanel onDone={() => setPanel(undefined)} onExit={() => setPanel(undefined)} />;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
default: {
|
|
53
|
+
// TODO(wittjosiah): Tooltips make playwright (webkit) flakier.
|
|
54
|
+
const controls = (
|
|
55
|
+
<ButtonGroup className='mbe-4'>
|
|
56
|
+
{/* <Tooltip content='Create Space'> */}
|
|
57
|
+
<Button
|
|
58
|
+
onClick={() => client.echo.createSpace({ name: faker.animal.bird() })}
|
|
59
|
+
data-testid='invitations.create-space'
|
|
60
|
+
>
|
|
61
|
+
<PlusCircle className={getSize(6)} />
|
|
62
|
+
</Button>
|
|
63
|
+
{/* </Tooltip>
|
|
64
|
+
<Tooltip content='Join Space'> */}
|
|
65
|
+
<Button onClick={() => setPanel('join')} data-testid='invitations.open-join-space'>
|
|
66
|
+
<Intersect weight='fill' className={getSize(6)} />
|
|
67
|
+
</Button>
|
|
68
|
+
{/* </Tooltip> */}
|
|
69
|
+
</ButtonGroup>
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const header = (
|
|
73
|
+
<div className='flex'>
|
|
74
|
+
Spaces
|
|
75
|
+
<span className='grow' />
|
|
76
|
+
{controls}
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Group label={{ children: header }}>
|
|
82
|
+
<ul>
|
|
83
|
+
{spaces.length > 0 ? (
|
|
84
|
+
spaces.map((space) => (
|
|
85
|
+
<SpaceListItem key={space.key.toHex()} space={space} onClick={() => setPanel(space)} />
|
|
86
|
+
))
|
|
87
|
+
) : (
|
|
88
|
+
<div className='text-center'>No spaces</div>
|
|
89
|
+
)}
|
|
90
|
+
</ul>
|
|
91
|
+
</Group>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const render = ({ id }: { id: number }) => {
|
|
98
|
+
const client = useClient();
|
|
99
|
+
const identity = useIdentity();
|
|
100
|
+
const [panel, setPanel] = useState<PanelType>();
|
|
101
|
+
|
|
102
|
+
useMemo(() => {
|
|
103
|
+
(window as any)[`peer${id}client`] = client;
|
|
104
|
+
}, [client]);
|
|
105
|
+
|
|
106
|
+
// TODO(wittjosiah): Tooltips make playwright (webkit) flakier.
|
|
107
|
+
const controls = (
|
|
108
|
+
<ButtonGroup className='mbe-4'>
|
|
109
|
+
{/* <Tooltip content='Create Identity'> */}
|
|
110
|
+
<Button
|
|
111
|
+
onClick={() => client.halo.createIdentity({ displayName: faker.name.firstName() })}
|
|
112
|
+
disabled={Boolean(identity)}
|
|
113
|
+
data-testid='invitations.create-identity'
|
|
114
|
+
>
|
|
115
|
+
<Plus className={getSize(6)} />
|
|
116
|
+
</Button>
|
|
117
|
+
{/* </Tooltip>
|
|
118
|
+
<Tooltip content='Join Existing Identity'> */}
|
|
119
|
+
<Button
|
|
120
|
+
onClick={() => setPanel('identity')}
|
|
121
|
+
disabled={panel === 'identity'}
|
|
122
|
+
data-testid='invitations.open-join-identity'
|
|
123
|
+
>
|
|
124
|
+
<QrCode weight='fill' className={getSize(6)} />
|
|
125
|
+
</Button>
|
|
126
|
+
{/* </Tooltip>
|
|
127
|
+
<Tooltip content='Devices'> */}
|
|
128
|
+
<Button
|
|
129
|
+
onClick={() => setPanel('devices')}
|
|
130
|
+
disabled={!identity || panel === 'devices'}
|
|
131
|
+
data-testid='invitations.open-devices'
|
|
132
|
+
>
|
|
133
|
+
<Laptop weight='fill' className={getSize(6)} />
|
|
134
|
+
</Button>
|
|
135
|
+
{/* </Tooltip>
|
|
136
|
+
<Tooltip content='List Spaces'> */}
|
|
137
|
+
<Button onClick={() => setPanel(undefined)} disabled={!panel} data-testid='invitations.list-spaces'>
|
|
138
|
+
<Planet weight='fill' className={getSize(6)} />
|
|
139
|
+
</Button>
|
|
140
|
+
{/* </Tooltip> */}
|
|
141
|
+
</ButtonGroup>
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
const header = (
|
|
145
|
+
<div className='flex' data-testid='invitations.identity-header'>
|
|
146
|
+
Identity
|
|
147
|
+
<span className='grow' />
|
|
148
|
+
{controls}
|
|
149
|
+
</div>
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<div className='flex flex-col p-4 flex-1 min-w-0' data-testid={`peer-${id}`}>
|
|
154
|
+
<Group label={{ children: header }} className='mbe-2'>
|
|
155
|
+
{identity ? <IdentityListItem identity={identity} /> : <div className='text-center'>No identity</div>}
|
|
156
|
+
</Group>
|
|
157
|
+
{identity || panel ? <Panel id={id} panel={panel} setPanel={setPanel} /> : null}
|
|
158
|
+
</div>
|
|
159
|
+
);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export const Default = {
|
|
163
|
+
render,
|
|
164
|
+
decorators: [ClientDecorator({ count: 3 })]
|
|
165
|
+
};
|
|
@@ -50,6 +50,7 @@ export const os = {
|
|
|
50
50
|
'reset label': 'Start over',
|
|
51
51
|
'auth code input label': 'Auth code provided by the invitation sender',
|
|
52
52
|
'invitation input label': 'Paste an invitation code or URL',
|
|
53
|
+
'create device invitation label': 'Invite',
|
|
53
54
|
'create space invitation label': 'Invite',
|
|
54
55
|
'qr label': 'Scan to accept invitation',
|
|
55
56
|
'empty invitations message': 'No pending invitations',
|
|
@@ -57,5 +58,9 @@ export const os = {
|
|
|
57
58
|
'all spaces label': 'All spaces',
|
|
58
59
|
'create space label': 'Create a new space',
|
|
59
60
|
'join space label': 'Join a space',
|
|
60
|
-
'show current space label': 'Current space'
|
|
61
|
+
'show current space label': 'Current space',
|
|
62
|
+
'view space invitations label': 'View space invitations',
|
|
63
|
+
'toggle sidebar label': 'Open/close sidebar',
|
|
64
|
+
'open sidebar label': 'Open sidebar',
|
|
65
|
+
'close sidebar label': 'Close sidebar'
|
|
61
66
|
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../../../src/testing/ClientProvider.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAOjD,eAAO,MAAM,cAAc,iBAAkB,kBAAkB,EAAE,CAAC,gBAMjE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2022 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { PropsWithChildren } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Config, Defaults, Dynamics } from '@dxos/config';
|
|
8
|
-
import { ClientProvider as NaturalClientProvider } from '@dxos/react-client';
|
|
9
|
-
|
|
10
|
-
const configProvider = async () => new Config(await Dynamics(), Defaults());
|
|
11
|
-
|
|
12
|
-
export const ClientProvider = ({ children }: PropsWithChildren<{}>) => {
|
|
13
|
-
return (
|
|
14
|
-
<NaturalClientProvider config={configProvider} fallback={() => <span>Starting client…</span>}>
|
|
15
|
-
{children}
|
|
16
|
-
</NaturalClientProvider>
|
|
17
|
-
);
|
|
18
|
-
};
|