@dxos/plugin-client 0.8.1-staging.391c573 → 0.8.1-staging.97aedb1
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/app-graph-builder-WAS4YZNA.mjs +119 -0
- package/dist/lib/browser/app-graph-builder-WAS4YZNA.mjs.map +7 -0
- package/dist/lib/browser/{chunk-OLUST5AO.mjs → chunk-4PLF3BEB.mjs} +2 -2
- package/dist/lib/browser/{chunk-7DPLXOMO.mjs → chunk-AN7FJKIJ.mjs} +21 -4
- package/dist/lib/browser/{chunk-7DPLXOMO.mjs.map → chunk-AN7FJKIJ.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-XK4HM5M7.mjs → chunk-BGY6BSUC.mjs} +3 -2
- package/dist/lib/browser/{chunk-XK4HM5M7.mjs.map → chunk-BGY6BSUC.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-NHIL4T3L.mjs → chunk-MCEXD5XH.mjs} +1 -1
- package/dist/lib/browser/{chunk-NHIL4T3L.mjs.map → chunk-MCEXD5XH.mjs.map} +2 -2
- package/dist/lib/browser/chunk-XZ4TQC56.mjs +619 -0
- package/dist/lib/browser/chunk-XZ4TQC56.mjs.map +7 -0
- package/dist/lib/browser/{client-UUGITHCW.mjs → client-LV67Q3R7.mjs} +5 -5
- package/dist/lib/browser/{client-UUGITHCW.mjs.map → client-LV67Q3R7.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +51 -22
- package/dist/lib/browser/index.mjs.map +2 -2
- package/dist/lib/browser/{intent-resolver-AIUHL34E.mjs → intent-resolver-NCISOZW4.mjs} +65 -27
- package/dist/lib/browser/intent-resolver-NCISOZW4.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{migrations-XODC625X.mjs → migrations-3DWFOL5Q.mjs} +3 -3
- package/dist/lib/browser/{react-context-JBD7Y3SN.mjs → react-context-WEH7SL4I.mjs} +3 -3
- package/dist/lib/browser/react-surface-J7SZR2J6.mjs +66 -0
- package/dist/lib/browser/react-surface-J7SZR2J6.mjs.map +7 -0
- package/dist/lib/browser/{schema-Y7ZNXYSL.mjs → schema-JQAT6Q7S.mjs} +3 -3
- package/dist/lib/browser/types.mjs +4 -2
- package/dist/lib/node/app-graph-builder-PXOJZJO5.cjs +130 -0
- package/dist/lib/node/app-graph-builder-PXOJZJO5.cjs.map +7 -0
- package/dist/lib/node/chunk-3JE5BFCT.cjs +644 -0
- package/dist/lib/node/chunk-3JE5BFCT.cjs.map +7 -0
- package/dist/lib/node/{chunk-OIFPM5ZW.cjs → chunk-DJKWB5L6.cjs} +4 -4
- package/dist/lib/node/{chunk-OIFPM5ZW.cjs.map → chunk-DJKWB5L6.cjs.map} +2 -2
- package/dist/lib/node/{chunk-TREVKZCJ.cjs → chunk-FROKBEVH.cjs} +25 -7
- package/dist/lib/node/chunk-FROKBEVH.cjs.map +7 -0
- package/dist/lib/node/{chunk-FR2K56EV.cjs → chunk-W64EOF2B.cjs} +10 -10
- package/dist/lib/node/{chunk-T4K27K2F.cjs → chunk-ZVQIICEN.cjs} +9 -8
- package/dist/lib/node/{chunk-T4K27K2F.cjs.map → chunk-ZVQIICEN.cjs.map} +3 -3
- package/dist/lib/node/{client-5BHSU35T.cjs → client-BKTGRBYM.cjs} +9 -9
- package/dist/lib/node/{client-5BHSU35T.cjs.map → client-BKTGRBYM.cjs.map} +3 -3
- package/dist/lib/node/index.cjs +70 -41
- package/dist/lib/node/index.cjs.map +2 -2
- package/dist/lib/node/{intent-resolver-PWCHHNV3.cjs → intent-resolver-U2576ALY.cjs} +81 -44
- package/dist/lib/node/intent-resolver-U2576ALY.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{migrations-YCBZUPWO.cjs → migrations-TGNI4FVL.cjs} +8 -8
- package/dist/lib/node/{react-context-MPHNGZHT.cjs → react-context-SF3M3YLR.cjs} +8 -8
- package/dist/lib/node/{react-surface-TPISDIHR.cjs → react-surface-BSTIXMER.cjs} +34 -26
- package/dist/lib/node/react-surface-BSTIXMER.cjs.map +7 -0
- package/dist/lib/node/{schema-NMMCMK64.cjs → schema-INQ72F54.cjs} +8 -8
- package/dist/lib/node/types.cjs +5 -3
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/app-graph-builder-KIN6NWFI.mjs +120 -0
- package/dist/lib/node-esm/app-graph-builder-KIN6NWFI.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-QJMF2MWP.mjs → chunk-AD5W5QCQ.mjs} +21 -4
- package/dist/lib/node-esm/{chunk-QJMF2MWP.mjs.map → chunk-AD5W5QCQ.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-XLLNVLWU.mjs → chunk-BP56BGZR.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-HO7WDE7C.mjs → chunk-HM7VB4ZV.mjs} +1 -1
- package/dist/lib/node-esm/{chunk-HO7WDE7C.mjs.map → chunk-HM7VB4ZV.mjs.map} +2 -2
- package/dist/lib/node-esm/{chunk-3OU2ZXLK.mjs → chunk-K3KGGSJZ.mjs} +3 -2
- package/dist/lib/node-esm/{chunk-3OU2ZXLK.mjs.map → chunk-K3KGGSJZ.mjs.map} +3 -3
- package/dist/lib/node-esm/chunk-LZN2UNN7.mjs +620 -0
- package/dist/lib/node-esm/chunk-LZN2UNN7.mjs.map +7 -0
- package/dist/lib/node-esm/{client-ZDGFGLX4.mjs → client-QQD6WFOB.mjs} +5 -5
- package/dist/lib/node-esm/{client-ZDGFGLX4.mjs.map → client-QQD6WFOB.mjs.map} +3 -3
- package/dist/lib/node-esm/index.mjs +51 -22
- package/dist/lib/node-esm/index.mjs.map +2 -2
- package/dist/lib/node-esm/{intent-resolver-FIXGPH7C.mjs → intent-resolver-G25U4UGI.mjs} +65 -27
- package/dist/lib/node-esm/intent-resolver-G25U4UGI.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{migrations-VIEIPYJW.mjs → migrations-IVGATGZR.mjs} +3 -3
- package/dist/lib/node-esm/{react-context-KUEOXWWK.mjs → react-context-EAKKTE5A.mjs} +3 -3
- package/dist/lib/node-esm/react-surface-ZPI7T4EM.mjs +67 -0
- package/dist/lib/node-esm/react-surface-ZPI7T4EM.mjs.map +7 -0
- package/dist/lib/node-esm/{schema-NE5IYLMD.mjs → schema-OK7HY3JJ.mjs} +3 -3
- package/dist/lib/node-esm/types.mjs +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +4 -4
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +2 -3
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/DevicesContainer.d.ts +5 -0
- package/dist/types/src/components/DevicesContainer.d.ts.map +1 -0
- package/dist/types/src/components/DevicesContainer.stories.d.ts +8 -0
- package/dist/types/src/components/DevicesContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/ProfileContainer.d.ts +3 -0
- package/dist/types/src/components/ProfileContainer.d.ts.map +1 -0
- package/dist/types/src/components/ProfileContainer.stories.d.ts +8 -0
- package/dist/types/src/components/ProfileContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/RecoveryCodeDialog.d.ts +1 -1
- package/dist/types/src/components/RecoveryCodeDialog.d.ts.map +1 -1
- package/dist/types/src/components/RecoveryCredentialsContainer.d.ts +4 -0
- package/dist/types/src/components/RecoveryCredentialsContainer.d.ts.map +1 -0
- package/dist/types/src/components/RecoveryCredentialsContainer.stories.d.ts +8 -0
- package/dist/types/src/components/RecoveryCredentialsContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/ResetDialog.d.ts +7 -0
- package/dist/types/src/components/ResetDialog.d.ts.map +1 -0
- package/dist/types/src/components/ResetDialog.stories.d.ts +10 -0
- package/dist/types/src/components/ResetDialog.stories.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +4 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +28 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +17 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +26 -19
- package/src/ClientPlugin.ts +2 -2
- package/src/capabilities/app-graph-builder.ts +62 -6
- package/src/capabilities/capabilities.ts +1 -0
- package/src/capabilities/client.ts +1 -1
- package/src/capabilities/intent-resolver.ts +68 -23
- package/src/capabilities/react-surface.tsx +32 -24
- package/src/components/DevicesContainer.stories.tsx +45 -0
- package/src/components/DevicesContainer.tsx +270 -0
- package/src/components/ProfileContainer.stories.tsx +29 -0
- package/src/components/ProfileContainer.tsx +163 -0
- package/src/components/RecoveryCodeDialog.stories.tsx +2 -2
- package/src/components/RecoveryCodeDialog.tsx +1 -2
- package/src/components/{ManageCredentialsDialog.stories.tsx → RecoveryCredentialsContainer.stories.tsx} +4 -17
- package/src/components/RecoveryCredentialsContainer.tsx +74 -0
- package/src/components/ResetDialog.stories.tsx +47 -0
- package/src/components/ResetDialog.tsx +49 -0
- package/src/components/index.ts +4 -2
- package/src/meta.ts +2 -2
- package/src/translations.ts +45 -9
- package/src/types.ts +20 -1
- package/dist/lib/browser/app-graph-builder-ON64R7SO.mjs +0 -44
- package/dist/lib/browser/app-graph-builder-ON64R7SO.mjs.map +0 -7
- package/dist/lib/browser/chunk-HNJZ74DZ.mjs +0 -281
- package/dist/lib/browser/chunk-HNJZ74DZ.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-AIUHL34E.mjs.map +0 -7
- package/dist/lib/browser/react-surface-QGPWIUFR.mjs +0 -57
- package/dist/lib/browser/react-surface-QGPWIUFR.mjs.map +0 -7
- package/dist/lib/node/app-graph-builder-RW7ESEX3.cjs +0 -58
- package/dist/lib/node/app-graph-builder-RW7ESEX3.cjs.map +0 -7
- package/dist/lib/node/chunk-TREVKZCJ.cjs.map +0 -7
- package/dist/lib/node/chunk-UTG3UR3N.cjs +0 -309
- package/dist/lib/node/chunk-UTG3UR3N.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-PWCHHNV3.cjs.map +0 -7
- package/dist/lib/node/react-surface-TPISDIHR.cjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-TDYRWNI7.mjs +0 -45
- package/dist/lib/node-esm/app-graph-builder-TDYRWNI7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SHJBU4QR.mjs +0 -282
- package/dist/lib/node-esm/chunk-SHJBU4QR.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-FIXGPH7C.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-KBROL4VH.mjs +0 -58
- package/dist/lib/node-esm/react-surface-KBROL4VH.mjs.map +0 -7
- package/dist/types/src/components/IdentityDialog.d.ts +0 -5
- package/dist/types/src/components/IdentityDialog.d.ts.map +0 -1
- package/dist/types/src/components/ManageCredentialsDialog.d.ts +0 -4
- package/dist/types/src/components/ManageCredentialsDialog.d.ts.map +0 -1
- package/dist/types/src/components/ManageCredentialsDialog.stories.d.ts +0 -8
- package/dist/types/src/components/ManageCredentialsDialog.stories.d.ts.map +0 -1
- package/dist/types/src/components/RecoverySetupDialog.d.ts +0 -4
- package/dist/types/src/components/RecoverySetupDialog.d.ts.map +0 -1
- package/dist/types/src/components/RecoverySetupDialog.stories.d.ts +0 -8
- package/dist/types/src/components/RecoverySetupDialog.stories.d.ts.map +0 -1
- package/src/components/IdentityDialog.tsx +0 -75
- package/src/components/ManageCredentialsDialog.tsx +0 -64
- package/src/components/RecoverySetupDialog.stories.tsx +0 -77
- package/src/components/RecoverySetupDialog.tsx +0 -52
- /package/dist/lib/browser/{chunk-OLUST5AO.mjs.map → chunk-4PLF3BEB.mjs.map} +0 -0
- /package/dist/lib/browser/{migrations-XODC625X.mjs.map → migrations-3DWFOL5Q.mjs.map} +0 -0
- /package/dist/lib/browser/{react-context-JBD7Y3SN.mjs.map → react-context-WEH7SL4I.mjs.map} +0 -0
- /package/dist/lib/browser/{schema-Y7ZNXYSL.mjs.map → schema-JQAT6Q7S.mjs.map} +0 -0
- /package/dist/lib/node/{chunk-FR2K56EV.cjs.map → chunk-W64EOF2B.cjs.map} +0 -0
- /package/dist/lib/node/{migrations-YCBZUPWO.cjs.map → migrations-TGNI4FVL.cjs.map} +0 -0
- /package/dist/lib/node/{react-context-MPHNGZHT.cjs.map → react-context-SF3M3YLR.cjs.map} +0 -0
- /package/dist/lib/node/{schema-NMMCMK64.cjs.map → schema-INQ72F54.cjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-XLLNVLWU.mjs.map → chunk-BP56BGZR.mjs.map} +0 -0
- /package/dist/lib/node-esm/{migrations-VIEIPYJW.mjs.map → migrations-IVGATGZR.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-context-KUEOXWWK.mjs.map → react-context-EAKKTE5A.mjs.map} +0 -0
- /package/dist/lib/node-esm/{schema-NE5IYLMD.mjs.map → schema-OK7HY3JJ.mjs.map} +0 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Check, X } from '@phosphor-icons/react';
|
|
6
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
7
|
+
import { QR } from 'react-qr-rounded';
|
|
8
|
+
|
|
9
|
+
import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
10
|
+
import { log } from '@dxos/log';
|
|
11
|
+
import { useClient, useMulticastObservable } from '@dxos/react-client';
|
|
12
|
+
import { type Device, useDevices } from '@dxos/react-client/halo';
|
|
13
|
+
import { type CancellableInvitationObservable, Invitation, InvitationEncoder } from '@dxos/react-client/invitations';
|
|
14
|
+
import { useNetworkStatus } from '@dxos/react-client/mesh';
|
|
15
|
+
import { Button, Clipboard, IconButton, List, useId, useTranslation } from '@dxos/react-ui';
|
|
16
|
+
import { ControlFrame, ControlFrameItem, ControlGroup, ControlItem, ControlSection } from '@dxos/react-ui-form';
|
|
17
|
+
import { StackItem } from '@dxos/react-ui-stack';
|
|
18
|
+
import { getSize, mx } from '@dxos/react-ui-theme';
|
|
19
|
+
import { AuthCode, Centered, DeviceListItem, Emoji, Viewport } from '@dxos/shell/react';
|
|
20
|
+
import { hexToEmoji } from '@dxos/util';
|
|
21
|
+
|
|
22
|
+
import { CLIENT_PLUGIN } from '../meta';
|
|
23
|
+
import { ClientAction } from '../types';
|
|
24
|
+
|
|
25
|
+
export const DevicesContainer = ({
|
|
26
|
+
createInvitationUrl,
|
|
27
|
+
}: {
|
|
28
|
+
createInvitationUrl: (invitationCode: string) => string;
|
|
29
|
+
}) => {
|
|
30
|
+
const { t } = useTranslation('os');
|
|
31
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
32
|
+
const devices = useDevices();
|
|
33
|
+
const { swarm: connectionState } = useNetworkStatus();
|
|
34
|
+
|
|
35
|
+
const handleResetStorage = useCallback(() => dispatch(createIntent(ClientAction.ResetStorage)), [dispatch]);
|
|
36
|
+
|
|
37
|
+
const handleRecover = useCallback(
|
|
38
|
+
() => dispatch(createIntent(ClientAction.ResetStorage, { mode: 'recover' })),
|
|
39
|
+
[dispatch],
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const handleJoinNewIdentity = useCallback(
|
|
43
|
+
() => dispatch(createIntent(ClientAction.ResetStorage, { mode: 'join new identity' })),
|
|
44
|
+
[dispatch],
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Clipboard.Provider>
|
|
49
|
+
<StackItem.Content classNames='p-2 block overflow-y-auto'>
|
|
50
|
+
<ControlSection
|
|
51
|
+
title={t('devices verbose label', { ns: CLIENT_PLUGIN })}
|
|
52
|
+
description={t('devices description', { ns: CLIENT_PLUGIN })}
|
|
53
|
+
>
|
|
54
|
+
<ControlFrame>
|
|
55
|
+
<ControlFrameItem title={t('devices label', { ns: CLIENT_PLUGIN })}>
|
|
56
|
+
<List>
|
|
57
|
+
{devices.map((device: Device) => {
|
|
58
|
+
return (
|
|
59
|
+
<DeviceListItem key={device.deviceKey.toHex()} device={device} connectionState={connectionState} />
|
|
60
|
+
);
|
|
61
|
+
})}
|
|
62
|
+
</List>
|
|
63
|
+
</ControlFrameItem>
|
|
64
|
+
<ControlFrameItem title='Add device'>
|
|
65
|
+
<DeviceInvitation createInvitationUrl={createInvitationUrl} />
|
|
66
|
+
</ControlFrameItem>
|
|
67
|
+
</ControlFrame>
|
|
68
|
+
</ControlSection>
|
|
69
|
+
<ControlSection
|
|
70
|
+
title={t('danger zone title', { ns: CLIENT_PLUGIN })}
|
|
71
|
+
description={t('danger zone description', { ns: CLIENT_PLUGIN })}
|
|
72
|
+
>
|
|
73
|
+
<ControlGroup>
|
|
74
|
+
<ControlItem
|
|
75
|
+
title={t('reset device label')}
|
|
76
|
+
description={t('reset device description', { ns: CLIENT_PLUGIN })}
|
|
77
|
+
>
|
|
78
|
+
<Button variant='destructive' onClick={handleResetStorage} data-testid='devicesContainer.reset'>
|
|
79
|
+
{t('reset device label')}
|
|
80
|
+
</Button>
|
|
81
|
+
</ControlItem>
|
|
82
|
+
<ControlItem
|
|
83
|
+
title={t('recover identity label')}
|
|
84
|
+
description={t('recover identity description', { ns: CLIENT_PLUGIN })}
|
|
85
|
+
>
|
|
86
|
+
<Button variant='destructive' onClick={handleRecover} data-testid='devicesContainer.recover'>
|
|
87
|
+
{t('recover identity label')}
|
|
88
|
+
</Button>
|
|
89
|
+
</ControlItem>
|
|
90
|
+
<ControlItem
|
|
91
|
+
title={t('join new identity label')}
|
|
92
|
+
description={t('join new identity description', { ns: CLIENT_PLUGIN })}
|
|
93
|
+
>
|
|
94
|
+
<Button variant='destructive' onClick={handleJoinNewIdentity} data-testid='devicesContainer.joinExisting'>
|
|
95
|
+
{t('join new identity label')}
|
|
96
|
+
</Button>
|
|
97
|
+
</ControlItem>
|
|
98
|
+
</ControlGroup>
|
|
99
|
+
</ControlSection>
|
|
100
|
+
</StackItem.Content>
|
|
101
|
+
</Clipboard.Provider>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
type DeviceInvitationProps = {
|
|
106
|
+
invitation?: CancellableInvitationObservable;
|
|
107
|
+
createInvitationUrl: (invitationCode: string) => string;
|
|
108
|
+
onInvitationDone: () => void;
|
|
109
|
+
onInvitationCreate: () => void;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const DeviceInvitation = (props: Pick<DeviceInvitationProps, 'createInvitationUrl'>) => {
|
|
113
|
+
const client = useClient();
|
|
114
|
+
const [invitation, setInvitation] = useState<CancellableInvitationObservable>();
|
|
115
|
+
|
|
116
|
+
const onInvitationCreate = useCallback(() => {
|
|
117
|
+
const invitation = client.halo.share();
|
|
118
|
+
if (client.config.values.runtime?.app?.env?.DX_ENVIRONMENT !== 'production') {
|
|
119
|
+
const subscription = invitation.subscribe((invitation: Invitation) => {
|
|
120
|
+
const invitationCode = InvitationEncoder.encode(invitation);
|
|
121
|
+
if (invitation.state === Invitation.State.CONNECTING) {
|
|
122
|
+
log.info(JSON.stringify({ invitationCode, authCode: invitation.authCode }));
|
|
123
|
+
subscription.unsubscribe();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
setInvitation(invitation);
|
|
128
|
+
}, [client]);
|
|
129
|
+
|
|
130
|
+
const onInvitationDone = useCallback(() => {
|
|
131
|
+
setInvitation(undefined);
|
|
132
|
+
}, []);
|
|
133
|
+
|
|
134
|
+
if (invitation) {
|
|
135
|
+
return <DeviceInvitationImpl {...props} {...{ invitation, onInvitationCreate, onInvitationDone }} />;
|
|
136
|
+
} else {
|
|
137
|
+
return <InvitationSection {...props} {...{ onInvitationCreate, onInvitationDone }} />;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const DeviceInvitationImpl = ({
|
|
142
|
+
invitation: invitationObservable,
|
|
143
|
+
createInvitationUrl,
|
|
144
|
+
onInvitationDone,
|
|
145
|
+
onInvitationCreate,
|
|
146
|
+
}: DeviceInvitationProps) => {
|
|
147
|
+
const invitation = useMulticastObservable(invitationObservable!);
|
|
148
|
+
const url = createInvitationUrl(InvitationEncoder.encode(invitation));
|
|
149
|
+
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
if (invitation.state >= Invitation.State.SUCCESS) {
|
|
152
|
+
onInvitationDone();
|
|
153
|
+
}
|
|
154
|
+
}, [invitation.state]);
|
|
155
|
+
|
|
156
|
+
return <InvitationSection {...invitation} {...{ url, onInvitationDone, onInvitationCreate }} />;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
type InvitationComponentProps = Partial<
|
|
160
|
+
Pick<Invitation, 'authCode' | 'invitationId'> &
|
|
161
|
+
Pick<DeviceInvitationProps, 'onInvitationDone' | 'onInvitationCreate'> & {
|
|
162
|
+
state: number;
|
|
163
|
+
url: string;
|
|
164
|
+
}
|
|
165
|
+
>;
|
|
166
|
+
|
|
167
|
+
const InvitationSection = ({
|
|
168
|
+
state = -1,
|
|
169
|
+
authCode,
|
|
170
|
+
invitationId = 'never',
|
|
171
|
+
url = 'never',
|
|
172
|
+
onInvitationDone = () => {},
|
|
173
|
+
onInvitationCreate = () => {},
|
|
174
|
+
}: InvitationComponentProps) => {
|
|
175
|
+
const { t } = useTranslation(CLIENT_PLUGIN);
|
|
176
|
+
const activeView =
|
|
177
|
+
state < 0
|
|
178
|
+
? 'init'
|
|
179
|
+
: state >= Invitation.State.CANCELLED
|
|
180
|
+
? 'complete'
|
|
181
|
+
: state >= Invitation.State.READY_FOR_AUTHENTICATION && authCode
|
|
182
|
+
? 'auth-code'
|
|
183
|
+
: 'qr-code';
|
|
184
|
+
return activeView === 'init' ? (
|
|
185
|
+
<>
|
|
186
|
+
<p className='text-description mbe-2'>{t('add device description')}</p>
|
|
187
|
+
<IconButton
|
|
188
|
+
icon='ph--plus--regular'
|
|
189
|
+
label={t('create device invitation label')}
|
|
190
|
+
disabled={state >= 0}
|
|
191
|
+
classNames='is-full'
|
|
192
|
+
data-testid='devicesContainer.createInvitation'
|
|
193
|
+
onClick={onInvitationCreate}
|
|
194
|
+
/>
|
|
195
|
+
</>
|
|
196
|
+
) : (
|
|
197
|
+
<Viewport.Root activeView={activeView}>
|
|
198
|
+
<Viewport.Views>
|
|
199
|
+
<Viewport.View id='init'>
|
|
200
|
+
{/* This view intentionally left blank while conditionally rendering the viewport. */}
|
|
201
|
+
</Viewport.View>
|
|
202
|
+
<Viewport.View id='complete'>
|
|
203
|
+
<InvitationComplete statusValue={state} />
|
|
204
|
+
</Viewport.View>
|
|
205
|
+
<Viewport.View id='auth-code'>
|
|
206
|
+
<InvitationAuthCode id={invitationId} code={authCode ?? 'never'} onCancel={onInvitationDone} />
|
|
207
|
+
</Viewport.View>
|
|
208
|
+
<Viewport.View id='qr-code'>
|
|
209
|
+
<InvitationQR id={invitationId} url={url} onCancel={onInvitationDone} />
|
|
210
|
+
</Viewport.View>
|
|
211
|
+
</Viewport.Views>
|
|
212
|
+
</Viewport.Root>
|
|
213
|
+
);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const InvitationQR = ({ id, url, onCancel }: { id: string; url: string; onCancel: () => void }) => {
|
|
217
|
+
const { t } = useTranslation('os');
|
|
218
|
+
const qrLabel = useId('devices-container__qr-code');
|
|
219
|
+
const emoji = hexToEmoji(id);
|
|
220
|
+
return (
|
|
221
|
+
<>
|
|
222
|
+
<p className='text-description'>{t('qr code description', { ns: CLIENT_PLUGIN })}</p>
|
|
223
|
+
<div role='group' className='grid grid-cols-[1fr_min-content] mlb-2 gap-2'>
|
|
224
|
+
<div role='none' className='is-full aspect-square relative text-description'>
|
|
225
|
+
<QR
|
|
226
|
+
rounding={100}
|
|
227
|
+
backgroundColor='transparent'
|
|
228
|
+
color='currentColor'
|
|
229
|
+
aria-labelledby={qrLabel}
|
|
230
|
+
errorCorrectionLevel='Q'
|
|
231
|
+
cutout={true}
|
|
232
|
+
>
|
|
233
|
+
{url ?? 'never'}
|
|
234
|
+
</QR>
|
|
235
|
+
<Centered>
|
|
236
|
+
<Emoji text={emoji} />
|
|
237
|
+
</Centered>
|
|
238
|
+
</div>
|
|
239
|
+
<span id={qrLabel} className='sr-only'>
|
|
240
|
+
{t('qr label')}
|
|
241
|
+
</span>
|
|
242
|
+
<Clipboard.Button value={url ?? 'never'} />
|
|
243
|
+
</div>
|
|
244
|
+
<Button variant='ghost' onClick={onCancel}>
|
|
245
|
+
{t('cancel label')}
|
|
246
|
+
</Button>
|
|
247
|
+
</>
|
|
248
|
+
);
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const InvitationAuthCode = ({ id, code, onCancel }: { id: string; code: string; onCancel: () => void }) => {
|
|
252
|
+
const { t } = useTranslation('os');
|
|
253
|
+
const emoji = hexToEmoji(id);
|
|
254
|
+
|
|
255
|
+
return (
|
|
256
|
+
<>
|
|
257
|
+
<p className='text-description'>{t('auth other device emoji message')}</p>
|
|
258
|
+
{emoji && <Emoji text={emoji} className='mli-auto mlb-2 text-center' />}
|
|
259
|
+
<p className='text-description'>{t('auth code message')}</p>
|
|
260
|
+
<AuthCode code={code} large classNames='mli-auto mlb-2 text-center grow' />
|
|
261
|
+
<Button variant='ghost' onClick={onCancel}>
|
|
262
|
+
{t('cancel label')}
|
|
263
|
+
</Button>
|
|
264
|
+
</>
|
|
265
|
+
);
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
const InvitationComplete = ({ statusValue }: { statusValue: number }) => {
|
|
269
|
+
return statusValue > 0 ? <Check className={mx('m-1.5', getSize(6))} /> : <X className={mx('m-1.5', getSize(6))} />;
|
|
270
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
|
+
|
|
9
|
+
import { withClientProvider } from '@dxos/react-client/testing';
|
|
10
|
+
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
11
|
+
|
|
12
|
+
import { ProfileContainer } from './ProfileContainer';
|
|
13
|
+
import translations from '../translations';
|
|
14
|
+
|
|
15
|
+
const meta: Meta = {
|
|
16
|
+
title: 'plugins/plugin-client/ProfileContainer',
|
|
17
|
+
component: ProfileContainer,
|
|
18
|
+
decorators: [withClientProvider({ createIdentity: true }), withTheme, withLayout({ tooltips: true })],
|
|
19
|
+
parameters: {
|
|
20
|
+
layout: 'fullscreen',
|
|
21
|
+
translations,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default meta;
|
|
26
|
+
|
|
27
|
+
type Story = StoryObj<typeof ProfileContainer>;
|
|
28
|
+
|
|
29
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Schema as S } from 'effect';
|
|
6
|
+
import React, { type ChangeEvent, useCallback, useMemo, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { debounce } from '@dxos/async';
|
|
9
|
+
import { useClient } from '@dxos/react-client';
|
|
10
|
+
import { type Identity, useIdentity } from '@dxos/react-client/halo';
|
|
11
|
+
import { ButtonGroup, Clipboard, Input, useTranslation } from '@dxos/react-ui';
|
|
12
|
+
import { Form, type InputComponent, ControlItem, ControlItemInput, ControlSection } from '@dxos/react-ui-form';
|
|
13
|
+
import { EmojiPickerBlock, HuePicker } from '@dxos/react-ui-pickers';
|
|
14
|
+
import { StackItem } from '@dxos/react-ui-stack';
|
|
15
|
+
import { hexToHue, hexToEmoji } from '@dxos/util';
|
|
16
|
+
|
|
17
|
+
import { CLIENT_PLUGIN } from '../meta';
|
|
18
|
+
|
|
19
|
+
// TODO(thure): Factor out?
|
|
20
|
+
const getDefaultHueValue = (identity: Identity | null) => hexToHue(identity?.identityKey.toHex() ?? '0');
|
|
21
|
+
const getDefaultEmojiValue = (identity: Identity | null) => hexToEmoji(identity?.identityKey.toHex() ?? '0');
|
|
22
|
+
const getHueValue = (identity: Identity | null) => identity?.profile?.data?.hue || getDefaultHueValue(identity);
|
|
23
|
+
const getEmojiValue = (identity: Identity | null) => identity?.profile?.data?.emoji || getDefaultEmojiValue(identity);
|
|
24
|
+
|
|
25
|
+
export const ProfileContainer = () => {
|
|
26
|
+
const { t } = useTranslation(CLIENT_PLUGIN);
|
|
27
|
+
const client = useClient();
|
|
28
|
+
const identity = useIdentity();
|
|
29
|
+
const [displayName, setDisplayNameDirectly] = useState(identity?.profile?.displayName ?? '');
|
|
30
|
+
const [emoji, setEmojiDirectly] = useState<string>(getEmojiValue(identity));
|
|
31
|
+
const [hue, setHueDirectly] = useState<string>(getHueValue(identity));
|
|
32
|
+
|
|
33
|
+
const updateProfile = useMemo(
|
|
34
|
+
() =>
|
|
35
|
+
debounce(
|
|
36
|
+
(profile: Partial<Profile>) =>
|
|
37
|
+
client.halo.updateProfile({
|
|
38
|
+
displayName: profile.displayName,
|
|
39
|
+
data: {
|
|
40
|
+
emoji: profile.emoji,
|
|
41
|
+
hue: profile.hue,
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
2_000,
|
|
45
|
+
),
|
|
46
|
+
[],
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const handleSave = useCallback(
|
|
50
|
+
(profile: Profile) => {
|
|
51
|
+
setDisplayNameDirectly(profile.displayName);
|
|
52
|
+
setEmojiDirectly(profile.emoji);
|
|
53
|
+
setHueDirectly(profile.hue);
|
|
54
|
+
updateProfile(profile);
|
|
55
|
+
},
|
|
56
|
+
[identity],
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const values = useMemo(
|
|
60
|
+
() => ({
|
|
61
|
+
displayName,
|
|
62
|
+
emoji,
|
|
63
|
+
hue,
|
|
64
|
+
did: identity?.did,
|
|
65
|
+
}),
|
|
66
|
+
[identity, displayName, emoji, hue],
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
// TODO(wittjosiah): Integrate descriptions with the form schema.
|
|
70
|
+
const customElements: Partial<Record<string, InputComponent>> = useMemo(
|
|
71
|
+
() => ({
|
|
72
|
+
displayName: ({ type, label, getValue, onValueChange }) => {
|
|
73
|
+
const handleChange = useCallback(
|
|
74
|
+
({ target: { value } }: ChangeEvent<HTMLInputElement>) => onValueChange(type, value),
|
|
75
|
+
[onValueChange, type],
|
|
76
|
+
);
|
|
77
|
+
return (
|
|
78
|
+
<ControlItemInput title={label} description={t('display name description')}>
|
|
79
|
+
<Input.TextInput
|
|
80
|
+
value={getValue()}
|
|
81
|
+
onChange={handleChange}
|
|
82
|
+
placeholder={t('display name input placeholder')}
|
|
83
|
+
classNames='min-is-64'
|
|
84
|
+
/>
|
|
85
|
+
</ControlItemInput>
|
|
86
|
+
);
|
|
87
|
+
},
|
|
88
|
+
emoji: ({ type, label, getValue, onValueChange }) => {
|
|
89
|
+
const handleChange = useCallback((nextEmoji: string) => onValueChange(type, nextEmoji), [onValueChange, type]);
|
|
90
|
+
const handleEmojiReset = useCallback(
|
|
91
|
+
() => onValueChange(type, getDefaultEmojiValue(identity)),
|
|
92
|
+
[onValueChange, type],
|
|
93
|
+
);
|
|
94
|
+
return (
|
|
95
|
+
<ControlItem title={label} description={t('icon description')}>
|
|
96
|
+
<EmojiPickerBlock
|
|
97
|
+
triggerVariant='default'
|
|
98
|
+
emoji={getValue()}
|
|
99
|
+
onChangeEmoji={handleChange}
|
|
100
|
+
onClickClear={handleEmojiReset}
|
|
101
|
+
classNames='justify-self-end'
|
|
102
|
+
/>
|
|
103
|
+
</ControlItem>
|
|
104
|
+
);
|
|
105
|
+
},
|
|
106
|
+
hue: ({ type, label, getValue, onValueChange }) => {
|
|
107
|
+
const handleChange = useCallback((nextHue: string) => onValueChange(type, nextHue), [onValueChange, type]);
|
|
108
|
+
const handleHueReset = useCallback(
|
|
109
|
+
() => onValueChange(type, getDefaultHueValue(identity)),
|
|
110
|
+
[onValueChange, type],
|
|
111
|
+
);
|
|
112
|
+
return (
|
|
113
|
+
<ControlItem title={label} description={t('hue description')}>
|
|
114
|
+
<HuePicker
|
|
115
|
+
value={getValue()}
|
|
116
|
+
onChange={handleChange}
|
|
117
|
+
onReset={handleHueReset}
|
|
118
|
+
classNames='[--hue-preview-size:1.5rem] justify-self-end'
|
|
119
|
+
/>
|
|
120
|
+
</ControlItem>
|
|
121
|
+
);
|
|
122
|
+
},
|
|
123
|
+
// TODO(wittjosiah): We need text input annotations for disabled and copyable.
|
|
124
|
+
did: ({ label, getValue }) => {
|
|
125
|
+
return (
|
|
126
|
+
<ControlItemInput title={label} description={t('did description')}>
|
|
127
|
+
<ButtonGroup>
|
|
128
|
+
<Input.TextInput value={getValue()} disabled classNames='min-is-64' />
|
|
129
|
+
<Clipboard.IconButton value={getValue() ?? ''} />
|
|
130
|
+
</ButtonGroup>
|
|
131
|
+
</ControlItemInput>
|
|
132
|
+
);
|
|
133
|
+
},
|
|
134
|
+
}),
|
|
135
|
+
[t],
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<StackItem.Content classNames='p-2 block overflow-y-auto'>
|
|
140
|
+
<Clipboard.Provider>
|
|
141
|
+
<ControlSection title={t('profile label')} description={t('profile description')}>
|
|
142
|
+
<Form
|
|
143
|
+
schema={ProfileSchema}
|
|
144
|
+
values={values}
|
|
145
|
+
autoSave
|
|
146
|
+
onSave={handleSave}
|
|
147
|
+
Custom={customElements}
|
|
148
|
+
classNames='p-0 container-max-width [&_[role="form"]]:grid [&_[role="form"]]:grid-cols-1 md:[&_[role="form"]]:grid-cols-[1fr_min-content] [&_[role="form"]]:gap-4'
|
|
149
|
+
/>
|
|
150
|
+
</ControlSection>
|
|
151
|
+
</Clipboard.Provider>
|
|
152
|
+
</StackItem.Content>
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// TODO(wittjosiah): Integrate annotations with translations.
|
|
157
|
+
const ProfileSchema = S.Struct({
|
|
158
|
+
displayName: S.String.annotations({ title: 'Display name' }),
|
|
159
|
+
emoji: S.String.annotations({ title: 'Avatar' }),
|
|
160
|
+
hue: S.String.annotations({ title: 'Color' }),
|
|
161
|
+
did: S.String.annotations({ title: 'DID' }),
|
|
162
|
+
});
|
|
163
|
+
type Profile = S.Schema.Type<typeof ProfileSchema>;
|
|
@@ -15,7 +15,7 @@ import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
|
15
15
|
import { RecoveryCodeDialog, type RecoveryCodeDialogProps } from './RecoveryCodeDialog';
|
|
16
16
|
import translations from '../translations';
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const DefaultStory = () => {
|
|
19
19
|
const client = useClient();
|
|
20
20
|
const [recoveryCode, setRecoveryCode] = useState<string>();
|
|
21
21
|
useAsyncEffect(async () => {
|
|
@@ -35,7 +35,7 @@ const Render = () => {
|
|
|
35
35
|
const meta: Meta<RecoveryCodeDialogProps> = {
|
|
36
36
|
title: 'plugins/plugin-client/RecoveryCodeDialog',
|
|
37
37
|
component: RecoveryCodeDialog,
|
|
38
|
-
render:
|
|
38
|
+
render: DefaultStory,
|
|
39
39
|
decorators: [withClientProvider({ createIdentity: true }), withTheme, withLayout({ tooltips: true })],
|
|
40
40
|
parameters: {
|
|
41
41
|
layout: 'fullscreen',
|
|
@@ -8,13 +8,12 @@ import { AlertDialog, Button, Clipboard, Input, useTranslation } from '@dxos/rea
|
|
|
8
8
|
|
|
9
9
|
import { CLIENT_PLUGIN } from '../meta';
|
|
10
10
|
|
|
11
|
-
export const
|
|
11
|
+
export const RECOVERY_CODE_DIALOG = `${CLIENT_PLUGIN}/RecoveryCodeDialog`;
|
|
12
12
|
|
|
13
13
|
export type RecoveryCodeDialogProps = {
|
|
14
14
|
code: string;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
// TODO(wittjosiah): Factor panel out to @dxos/shell.
|
|
18
17
|
export const RecoveryCodeDialog = ({ code }: RecoveryCodeDialogProps) => {
|
|
19
18
|
const { t } = useTranslation(CLIENT_PLUGIN);
|
|
20
19
|
const [confirmation, setConfirmation] = useState(false);
|
|
@@ -5,31 +5,18 @@
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
7
|
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
|
-
import React from 'react';
|
|
9
8
|
|
|
10
9
|
import { IntentPlugin } from '@dxos/app-framework';
|
|
11
10
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
|
-
import { AlertDialog } from '@dxos/react-ui';
|
|
13
11
|
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
14
12
|
|
|
15
|
-
import {
|
|
13
|
+
import { RecoveryCredentialsContainer } from './RecoveryCredentialsContainer';
|
|
16
14
|
import { ClientPlugin } from '../ClientPlugin';
|
|
17
15
|
import translations from '../translations';
|
|
18
16
|
|
|
19
|
-
const Render = () => {
|
|
20
|
-
return (
|
|
21
|
-
<AlertDialog.Root open>
|
|
22
|
-
<AlertDialog.Overlay>
|
|
23
|
-
<ManageCredentialsDialog />
|
|
24
|
-
</AlertDialog.Overlay>
|
|
25
|
-
</AlertDialog.Root>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
17
|
const meta: Meta = {
|
|
30
|
-
title: 'plugins/plugin-client/
|
|
31
|
-
component:
|
|
32
|
-
render: Render,
|
|
18
|
+
title: 'plugins/plugin-client/RecoveryCredentialsContainer',
|
|
19
|
+
component: RecoveryCredentialsContainer,
|
|
33
20
|
decorators: [
|
|
34
21
|
withPluginManager({
|
|
35
22
|
plugins: [
|
|
@@ -52,6 +39,6 @@ const meta: Meta = {
|
|
|
52
39
|
|
|
53
40
|
export default meta;
|
|
54
41
|
|
|
55
|
-
type Story = StoryObj<typeof
|
|
42
|
+
type Story = StoryObj<typeof RecoveryCredentialsContainer>;
|
|
56
43
|
|
|
57
44
|
export const Default: Story = {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
|
+
import { useCredentials } from '@dxos/react-client/halo';
|
|
9
|
+
import { Icon, IconButton, List, ListItem, useTranslation, Message } from '@dxos/react-ui';
|
|
10
|
+
import { ControlGroup, ControlItem, ControlSection } from '@dxos/react-ui-form';
|
|
11
|
+
import { StackItem } from '@dxos/react-ui-stack';
|
|
12
|
+
|
|
13
|
+
import { CLIENT_PLUGIN } from '../meta';
|
|
14
|
+
import { ClientAction } from '../types';
|
|
15
|
+
|
|
16
|
+
export const MANAGE_CREDENTIALS_DIALOG = `${CLIENT_PLUGIN}/ManageCredentialsDialog`;
|
|
17
|
+
|
|
18
|
+
export const RecoveryCredentialsContainer = () => {
|
|
19
|
+
const { t } = useTranslation(CLIENT_PLUGIN);
|
|
20
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
21
|
+
const credentials = useCredentials();
|
|
22
|
+
const recoveryCredentials = credentials.filter(
|
|
23
|
+
(credential) => credential.subject.assertion['@type'] === 'dxos.halo.credentials.IdentityRecovery',
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<StackItem.Content classNames='p-2 block overflow-y-auto'>
|
|
28
|
+
<ControlSection title={t('recovery setup dialog title')} description={t('recovery setup dialog description')}>
|
|
29
|
+
<ControlGroup>
|
|
30
|
+
<ControlItem title={t('create passkey label')} description={t('create passkey description')}>
|
|
31
|
+
<IconButton
|
|
32
|
+
label={t('create passkey label')}
|
|
33
|
+
icon='ph--key--duotone'
|
|
34
|
+
variant='primary'
|
|
35
|
+
size={5}
|
|
36
|
+
onClick={() => dispatch(createIntent(ClientAction.CreatePasskey))}
|
|
37
|
+
/>
|
|
38
|
+
</ControlItem>
|
|
39
|
+
<ControlItem title={t('create recovery code label')} description={t('create recovery code description')}>
|
|
40
|
+
<IconButton
|
|
41
|
+
label={t('create recovery code label')}
|
|
42
|
+
icon='ph--receipt--duotone'
|
|
43
|
+
variant='default'
|
|
44
|
+
size={5}
|
|
45
|
+
onClick={() => dispatch(createIntent(ClientAction.CreateRecoveryCode))}
|
|
46
|
+
/>
|
|
47
|
+
</ControlItem>
|
|
48
|
+
</ControlGroup>
|
|
49
|
+
</ControlSection>
|
|
50
|
+
<ControlSection title={t('credentials list label')}>
|
|
51
|
+
{recoveryCredentials.length < 1 ? (
|
|
52
|
+
<Message.Root valence='error' className='container-max-width'>
|
|
53
|
+
<Message.Title>
|
|
54
|
+
<Icon icon='ph--shield-warning--duotone' size={5} classNames='inline-block align-top mbs-px mie-1' />
|
|
55
|
+
{t('no credentials title')}
|
|
56
|
+
</Message.Title>
|
|
57
|
+
<Message.Body>{t('no credentials message')}</Message.Body>
|
|
58
|
+
</Message.Root>
|
|
59
|
+
) : (
|
|
60
|
+
<List classNames='container-max-width pli-2'>
|
|
61
|
+
{recoveryCredentials.map((credential) => (
|
|
62
|
+
<ListItem.Root key={credential.id?.toHex()}>
|
|
63
|
+
<ListItem.Endcap>
|
|
64
|
+
<Icon icon='ph--key--regular' size={5} />
|
|
65
|
+
</ListItem.Endcap>
|
|
66
|
+
<ListItem.Heading>{credential.issuanceDate.toLocaleString()}</ListItem.Heading>
|
|
67
|
+
</ListItem.Root>
|
|
68
|
+
))}
|
|
69
|
+
</List>
|
|
70
|
+
)}
|
|
71
|
+
</ControlSection>
|
|
72
|
+
</StackItem.Content>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
import { IntentPlugin } from '@dxos/app-framework';
|
|
11
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
|
+
import { Dialog } from '@dxos/react-ui';
|
|
13
|
+
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
14
|
+
|
|
15
|
+
import { ResetDialog, type ResetDialogProps } from './ResetDialog';
|
|
16
|
+
import translations from '../translations';
|
|
17
|
+
|
|
18
|
+
const Render = (props: ResetDialogProps) => {
|
|
19
|
+
return (
|
|
20
|
+
<Dialog.Root open>
|
|
21
|
+
<Dialog.Overlay>
|
|
22
|
+
<ResetDialog onReset={() => console.log('reset')} {...props} />
|
|
23
|
+
</Dialog.Overlay>
|
|
24
|
+
</Dialog.Root>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const meta: Meta<ResetDialogProps> = {
|
|
29
|
+
title: 'plugins/plugin-client/ResetDialog',
|
|
30
|
+
component: ResetDialog,
|
|
31
|
+
render: Render,
|
|
32
|
+
decorators: [withPluginManager({ plugins: [IntentPlugin()] }), withTheme, withLayout({ tooltips: true })],
|
|
33
|
+
parameters: {
|
|
34
|
+
layout: 'fullscreen',
|
|
35
|
+
translations,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default meta;
|
|
40
|
+
|
|
41
|
+
type Story = StoryObj<ResetDialogProps>;
|
|
42
|
+
|
|
43
|
+
export const Default: Story = { args: { mode: 'reset storage' } };
|
|
44
|
+
|
|
45
|
+
export const JoinNewIdentity: Story = { args: { mode: 'join new identity' } };
|
|
46
|
+
|
|
47
|
+
export const Recover: Story = { args: { mode: 'recover' } };
|