@dxos/shell 0.3.11-main.690ca41 → 0.3.11-main.6cabbc5
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/bundle/shell.mjs +36655 -0
- package/dist/bundle/shell.mjs.map +1 -0
- package/dist/bundle/shell.umd.js +210 -0
- package/dist/bundle/shell.umd.js.map +1 -0
- package/dist/bundle/style.css +1 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react.mjs +702 -397
- package/dist/lib/browser/react.mjs.map +4 -4
- package/dist/lib/browser/testing/index.mjs.map +1 -1
- package/dist/types/src/components/IdentityList/DeviceList.d.ts.map +1 -1
- package/dist/types/src/components/IdentityList/DeviceList.js +5 -3
- package/dist/types/src/components/IdentityList/DeviceList.js.map +1 -1
- package/dist/types/src/components/Panel/Action.js +1 -1
- package/dist/types/src/components/Panel/Action.js.map +1 -1
- package/dist/types/src/composites/Shell/Shell.d.ts.map +1 -1
- package/dist/types/src/composites/Shell/Shell.js +15 -5
- package/dist/types/src/composites/Shell/Shell.js.map +1 -1
- package/dist/types/src/panels/IdentityPanel/IdentityPanel.d.ts.map +1 -1
- package/dist/types/src/panels/IdentityPanel/IdentityPanel.js +23 -6
- package/dist/types/src/panels/IdentityPanel/IdentityPanel.js.map +1 -1
- package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.d.ts +6 -0
- package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.d.ts.map +1 -1
- package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.js +26 -3
- package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.js.map +1 -1
- package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts +19 -8
- package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts.map +1 -1
- package/dist/types/src/panels/IdentityPanel/identityMachine.d.ts +1 -1
- package/dist/types/src/panels/IdentityPanel/identityMachine.d.ts.map +1 -1
- package/dist/types/src/panels/IdentityPanel/identityMachine.js +12 -3
- package/dist/types/src/panels/IdentityPanel/identityMachine.js.map +1 -1
- package/dist/types/src/panels/IdentityPanel/steps/AgentForm.d.ts +3 -0
- package/dist/types/src/panels/IdentityPanel/steps/AgentForm.d.ts.map +1 -0
- package/dist/types/src/panels/IdentityPanel/steps/AgentForm.js +26 -0
- package/dist/types/src/panels/IdentityPanel/steps/AgentForm.js.map +1 -0
- package/dist/types/src/panels/IdentityPanel/steps/DeviceManager.d.ts +10 -0
- package/dist/types/src/panels/IdentityPanel/steps/DeviceManager.d.ts.map +1 -0
- package/dist/types/src/panels/IdentityPanel/steps/DeviceManager.js +23 -0
- package/dist/types/src/panels/IdentityPanel/steps/DeviceManager.js.map +1 -0
- package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.d.ts.map +1 -1
- package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js +9 -1
- package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js.map +1 -1
- package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.d.ts +0 -1
- package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.d.ts.map +1 -1
- package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.js +2 -3
- package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.js.map +1 -1
- package/dist/types/src/panels/IdentityPanel/steps/SignOutChooser.d.ts +16 -0
- package/dist/types/src/panels/IdentityPanel/steps/SignOutChooser.d.ts.map +1 -0
- package/dist/types/src/panels/IdentityPanel/steps/SignOutChooser.js +40 -0
- package/dist/types/src/panels/IdentityPanel/steps/SignOutChooser.js.map +1 -0
- package/dist/types/src/panels/IdentityPanel/steps/index.d.ts +3 -0
- package/dist/types/src/panels/IdentityPanel/steps/index.d.ts.map +1 -1
- package/dist/types/src/panels/IdentityPanel/steps/index.js +3 -0
- package/dist/types/src/panels/IdentityPanel/steps/index.js.map +1 -1
- package/dist/types/src/panels/IdentityPanel/useAgentHandlers.d.ts +15 -0
- package/dist/types/src/panels/IdentityPanel/useAgentHandlers.d.ts.map +1 -0
- package/dist/types/src/panels/IdentityPanel/useAgentHandlers.js +78 -0
- package/dist/types/src/panels/IdentityPanel/useAgentHandlers.js.map +1 -0
- package/dist/types/src/panels/JoinPanel/JoinPanel.js +4 -3
- package/dist/types/src/panels/JoinPanel/JoinPanel.js.map +1 -1
- package/dist/types/src/panels/JoinPanel/joinMachine.js +1 -1
- package/dist/types/src/panels/JoinPanel/joinMachine.js.map +1 -1
- package/dist/types/src/panels/SpacePanel/SpacePanel.d.ts.map +1 -1
- package/dist/types/src/panels/SpacePanel/SpacePanel.js +5 -3
- package/dist/types/src/panels/SpacePanel/SpacePanel.js.map +1 -1
- package/dist/types/src/panels/SpacePanel/SpacePanel.stories.d.ts.map +1 -1
- package/dist/types/src/panels/SpacePanel/SpacePanel.stories.js +2 -2
- package/dist/types/src/panels/SpacePanel/SpacePanel.stories.js.map +1 -1
- package/dist/types/src/panels/SpacePanel/SpacePanelProps.d.ts +1 -0
- package/dist/types/src/panels/SpacePanel/SpacePanelProps.d.ts.map +1 -1
- package/dist/types/src/panels/SpacePanel/steps/SpaceManager.d.ts +1 -0
- package/dist/types/src/panels/SpacePanel/steps/SpaceManager.d.ts.map +1 -1
- package/dist/types/src/panels/SpacePanel/steps/SpaceManager.js +3 -1
- package/dist/types/src/panels/SpacePanel/steps/SpaceManager.js.map +1 -1
- package/dist/types/src/translations/locales/en-US.d.ts +6 -0
- package/dist/types/src/translations/locales/en-US.d.ts.map +1 -1
- package/dist/types/src/translations/locales/en-US.js +7 -1
- package/dist/types/src/translations/locales/en-US.js.map +1 -1
- package/package.json +20 -19
- package/src/components/IdentityList/DeviceList.tsx +7 -5
- package/src/components/Panel/Action.tsx +1 -1
- package/src/composites/Shell/Shell.tsx +16 -3
- package/src/panels/IdentityPanel/IdentityPanel.stories.tsx +44 -2
- package/src/panels/IdentityPanel/IdentityPanel.tsx +34 -7
- package/src/panels/IdentityPanel/IdentityPanelProps.ts +27 -8
- package/src/panels/IdentityPanel/identityMachine.ts +13 -4
- package/src/panels/IdentityPanel/steps/AgentForm.tsx +61 -0
- package/src/panels/IdentityPanel/steps/DeviceManager.tsx +41 -0
- package/src/panels/IdentityPanel/steps/IdentityActionChooser.tsx +12 -7
- package/src/panels/IdentityPanel/steps/ProfileForm.tsx +1 -1
- package/src/panels/IdentityPanel/steps/SignOutChooser.tsx +82 -0
- package/src/panels/IdentityPanel/steps/index.ts +3 -0
- package/src/panels/IdentityPanel/useAgentHandlers.ts +88 -0
- package/src/panels/JoinPanel/JoinPanel.tsx +2 -2
- package/src/panels/JoinPanel/joinMachine.ts +1 -1
- package/src/panels/SpacePanel/SpacePanel.stories.tsx +2 -1
- package/src/panels/SpacePanel/SpacePanel.tsx +4 -1
- package/src/panels/SpacePanel/SpacePanelProps.ts +1 -0
- package/src/panels/SpacePanel/steps/SpaceManager.tsx +4 -1
- package/src/translations/locales/en-US.ts +7 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { useTranslation } from '@dxos/react-ui';
|
|
8
|
+
|
|
9
|
+
import { Action, Actions, StepHeading, Input } from '../../../components';
|
|
10
|
+
import { type AgentFormProps, type IdentityPanelStepProps } from '../IdentityPanelProps';
|
|
11
|
+
|
|
12
|
+
export const AgentForm = (props: IdentityPanelStepProps & AgentFormProps) => {
|
|
13
|
+
const {
|
|
14
|
+
active,
|
|
15
|
+
onAgentCreate,
|
|
16
|
+
onAgentDestroy,
|
|
17
|
+
send,
|
|
18
|
+
validationMessage,
|
|
19
|
+
agentStatus,
|
|
20
|
+
agentActive,
|
|
21
|
+
agentProviderDisabled,
|
|
22
|
+
} = props;
|
|
23
|
+
const disabled = !active;
|
|
24
|
+
const { t } = useTranslation('os');
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
<div role='none' className='grow flex flex-col justify-center'>
|
|
28
|
+
<Input
|
|
29
|
+
{...{ validationMessage }}
|
|
30
|
+
label={<StepHeading>Agent Status</StepHeading>}
|
|
31
|
+
disabled={disabled}
|
|
32
|
+
data-testid='agent-status'
|
|
33
|
+
value={agentStatus}
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
<Actions>
|
|
37
|
+
<Action
|
|
38
|
+
disabled={agentActive || agentProviderDisabled}
|
|
39
|
+
onClick={() => onAgentCreate?.()}
|
|
40
|
+
data-testid={'create-agent'}
|
|
41
|
+
>
|
|
42
|
+
Create Agent
|
|
43
|
+
</Action>
|
|
44
|
+
<Action
|
|
45
|
+
disabled={!agentActive || agentProviderDisabled}
|
|
46
|
+
onClick={() => onAgentDestroy?.()}
|
|
47
|
+
data-testid={'destroy-agent'}
|
|
48
|
+
>
|
|
49
|
+
Destroy Agent
|
|
50
|
+
</Action>
|
|
51
|
+
<Action
|
|
52
|
+
disabled={disabled}
|
|
53
|
+
onClick={() => send?.({ type: 'unchooseAction' })}
|
|
54
|
+
data-testid={'update-profile-form-back'}
|
|
55
|
+
>
|
|
56
|
+
{t('back label')}
|
|
57
|
+
</Action>
|
|
58
|
+
</Actions>
|
|
59
|
+
</>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { type Event, type SingleOrArray } from 'xstate';
|
|
7
|
+
|
|
8
|
+
import { type Device } from '@dxos/react-client/halo';
|
|
9
|
+
import { useTranslation } from '@dxos/react-ui';
|
|
10
|
+
|
|
11
|
+
import { Action, Actions, DeviceList } from '../../../components';
|
|
12
|
+
import type { IdentityPanelStepProps } from '../IdentityPanelProps';
|
|
13
|
+
import type { IdentityEvent } from '../identityMachine';
|
|
14
|
+
|
|
15
|
+
export interface DeviceManagerProps extends Omit<IdentityPanelStepProps, 'send'> {
|
|
16
|
+
send?: (event: SingleOrArray<Event<IdentityEvent>>) => void;
|
|
17
|
+
devices: Device[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const DeviceManager = ({ devices, active, send }: DeviceManagerProps) => {
|
|
21
|
+
const { t } = useTranslation('os');
|
|
22
|
+
const disabled = !active;
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
<div role='none' className='grow'>
|
|
27
|
+
<DeviceList devices={devices} />
|
|
28
|
+
</div>
|
|
29
|
+
<Actions>
|
|
30
|
+
<Action
|
|
31
|
+
variant='ghost'
|
|
32
|
+
disabled={disabled}
|
|
33
|
+
onClick={() => send?.({ type: 'unchooseAction' })}
|
|
34
|
+
data-testid={'manage-devices-back'}
|
|
35
|
+
>
|
|
36
|
+
{t('back label')}
|
|
37
|
+
</Action>
|
|
38
|
+
</Actions>
|
|
39
|
+
</>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { CaretRight, Plus, Power, UserGear } from '@phosphor-icons/react';
|
|
5
|
+
import { CaretRight, Devices, Plus, Power, UserGear, HardDrive } from '@phosphor-icons/react';
|
|
6
6
|
import React, { useCallback } from 'react';
|
|
7
7
|
|
|
8
8
|
import { useClient } from '@dxos/react-client';
|
|
@@ -63,6 +63,11 @@ export const IdentityActionChooserImpl = ({
|
|
|
63
63
|
<div role='none' className='grow flex flex-col gap-1'>
|
|
64
64
|
<DensityProvider density='coarse'>
|
|
65
65
|
<div className='grow justify-center flex flex-col gap-1'>
|
|
66
|
+
<Action data-testid='manage-agent' onClick={() => send?.({ type: 'chooseAgent' })} classNames='plb-4'>
|
|
67
|
+
<HardDrive className={getSize(6)} />
|
|
68
|
+
<span className='grow mli-3'>Manage Agent</span>
|
|
69
|
+
<CaretRight weight='bold' className={getSize(4)} />
|
|
70
|
+
</Action>
|
|
66
71
|
<Action
|
|
67
72
|
disabled={!active}
|
|
68
73
|
data-testid='devices-panel.create-invitation'
|
|
@@ -70,6 +75,11 @@ export const IdentityActionChooserImpl = ({
|
|
|
70
75
|
classNames='plb-4'
|
|
71
76
|
>
|
|
72
77
|
<Plus className={getSize(6)} />
|
|
78
|
+
<span className='grow mli-3'>{t('choose add device label')}</span>
|
|
79
|
+
<CaretRight weight='bold' className={getSize(4)} />
|
|
80
|
+
</Action>
|
|
81
|
+
<Action data-testid='manage-devices' onClick={() => send?.({ type: 'chooseDevices' })} classNames='plb-4'>
|
|
82
|
+
<Devices className={getSize(6)} />
|
|
73
83
|
<span className='grow mli-3'>{t('choose devices label')}</span>
|
|
74
84
|
<CaretRight weight='bold' className={getSize(4)} />
|
|
75
85
|
</Action>
|
|
@@ -78,12 +88,7 @@ export const IdentityActionChooserImpl = ({
|
|
|
78
88
|
<span className='grow mli-3'>{t('choose profile label')}</span>
|
|
79
89
|
<CaretRight weight='bold' className={getSize(4)} />
|
|
80
90
|
</Action>
|
|
81
|
-
<Action
|
|
82
|
-
disabled
|
|
83
|
-
data-testid='sign-out'
|
|
84
|
-
onClick={() => {} /* send({ type: 'chooseSignOut' }) */}
|
|
85
|
-
classNames='plb-4'
|
|
86
|
-
>
|
|
91
|
+
<Action data-testid='sign-out' onClick={() => send?.({ type: 'chooseSignOut' })} classNames='plb-4'>
|
|
87
92
|
<Power className={getSize(6)} />
|
|
88
93
|
<span className='grow mli-3'>{t('choose sign out label')}</span>
|
|
89
94
|
<CaretRight weight='bold' className={getSize(4)} />
|
|
@@ -37,7 +37,7 @@ export const ProfileForm = (props: ProfileFormProps) => {
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
// TODO(zhenyasav): impl shouldn't need send()
|
|
40
|
-
|
|
40
|
+
const ProfileFormImpl = (props: ProfileFormImplProps) => {
|
|
41
41
|
const { active, profile, send, onUpdateProfile, validationMessage } = props;
|
|
42
42
|
const disabled = !active;
|
|
43
43
|
const { t } = useTranslation('os');
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Warning } from '@phosphor-icons/react';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { type Event, type SingleOrArray } from 'xstate';
|
|
8
|
+
|
|
9
|
+
import { Message, useTranslation } from '@dxos/react-ui';
|
|
10
|
+
import { getSize, mx } from '@dxos/react-ui-theme';
|
|
11
|
+
|
|
12
|
+
import { Action, Actions } from '../../../components';
|
|
13
|
+
import { type IdentityPanelStepProps } from '../IdentityPanelProps';
|
|
14
|
+
import { type IdentityEvent } from '../identityMachine';
|
|
15
|
+
|
|
16
|
+
export interface SignOutChooserProps extends Omit<IdentityPanelStepProps, 'send'> {
|
|
17
|
+
send?: (event: SingleOrArray<Event<IdentityEvent>>) => void;
|
|
18
|
+
onResetDevice?: () => Promise<void>;
|
|
19
|
+
onJoinNewIdentity?: () => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const SignOutChooser = (props: SignOutChooserProps) => {
|
|
23
|
+
const { t } = useTranslation('os');
|
|
24
|
+
const onResetDevice = () => {
|
|
25
|
+
if (window.confirm(t('reset device confirm message'))) {
|
|
26
|
+
void props.onResetDevice?.();
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
return (
|
|
30
|
+
<SignOutChooserImpl
|
|
31
|
+
disabled={!props.active}
|
|
32
|
+
onBack={() => props.send?.({ type: 'unchooseAction' })}
|
|
33
|
+
onResetDevice={onResetDevice}
|
|
34
|
+
onJoinNewIdentity={props.onJoinNewIdentity}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type SignOutChooserImplProps = {
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
onResetDevice?: () => void;
|
|
42
|
+
onJoinNewIdentity?: () => void;
|
|
43
|
+
onBack?: () => void;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const SignOutChooserImpl = ({ disabled, onResetDevice, onJoinNewIdentity, onBack }: SignOutChooserImplProps) => {
|
|
47
|
+
const { t } = useTranslation('os');
|
|
48
|
+
return (
|
|
49
|
+
<>
|
|
50
|
+
<div role='none' className='grow flex flex-col justify-center'>
|
|
51
|
+
<Message.Root valence='error'>
|
|
52
|
+
<Message.Title>
|
|
53
|
+
<Warning className={mx(getSize(6), 'inline mie-2')} />
|
|
54
|
+
{t('sign out chooser title')}
|
|
55
|
+
</Message.Title>
|
|
56
|
+
<Message.Body>{t('sign out chooser message')}</Message.Body>
|
|
57
|
+
</Message.Root>
|
|
58
|
+
</div>
|
|
59
|
+
<Actions>
|
|
60
|
+
<Action disabled={disabled} onClick={onBack}>
|
|
61
|
+
{t('back label')}
|
|
62
|
+
</Action>
|
|
63
|
+
<Action
|
|
64
|
+
variant='primary'
|
|
65
|
+
classNames='!bg-error-500 hover:!bg-error-550'
|
|
66
|
+
disabled={disabled}
|
|
67
|
+
onClick={onJoinNewIdentity}
|
|
68
|
+
>
|
|
69
|
+
{t('join new identity label')}
|
|
70
|
+
</Action>
|
|
71
|
+
<Action
|
|
72
|
+
variant='primary'
|
|
73
|
+
classNames='!bg-error-500 hover:!bg-error-550'
|
|
74
|
+
disabled={disabled}
|
|
75
|
+
onClick={onResetDevice}
|
|
76
|
+
>
|
|
77
|
+
{t('reset device label')}
|
|
78
|
+
</Action>
|
|
79
|
+
</Actions>
|
|
80
|
+
</>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type CancellableInvitation } from '@dxos/client-protocol';
|
|
8
|
+
import { invariant } from '@dxos/invariant';
|
|
9
|
+
import { useAgentHostingProviderClient, type Client } from '@dxos/react-client';
|
|
10
|
+
import { type Identity } from '@dxos/react-client/halo';
|
|
11
|
+
import { Invitation, InvitationEncoder } from '@dxos/react-client/invitations';
|
|
12
|
+
|
|
13
|
+
export const useAgentHandlers = ({
|
|
14
|
+
client,
|
|
15
|
+
invitations,
|
|
16
|
+
identity,
|
|
17
|
+
}: {
|
|
18
|
+
client: Client;
|
|
19
|
+
invitations: CancellableInvitation[];
|
|
20
|
+
identity: Identity | null;
|
|
21
|
+
}) => {
|
|
22
|
+
const [validationMessage, setValidationMessage] = useState('');
|
|
23
|
+
const [agentStatus, setAgentStatus] = useState('');
|
|
24
|
+
const [agentActive, setAgentActive] = useState(false);
|
|
25
|
+
const agentHostingProviderClient = useAgentHostingProviderClient(client.config);
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const fetchAgentStatus = async () => {
|
|
29
|
+
// TODO(nf): if agent exists, subscribe to updates instead of oneshot status
|
|
30
|
+
if (agentHostingProviderClient) {
|
|
31
|
+
const agentStatus = await agentHostingProviderClient?.getAgent(identity?.identityKey.truncate() ?? 'foo');
|
|
32
|
+
if (agentStatus) {
|
|
33
|
+
setAgentActive(true);
|
|
34
|
+
setAgentStatus(agentStatus);
|
|
35
|
+
} else {
|
|
36
|
+
setAgentActive(false);
|
|
37
|
+
setValidationMessage('No agent deployed via provider.');
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
setValidationMessage('No agent provider configured.');
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
void fetchAgentStatus();
|
|
44
|
+
}, []);
|
|
45
|
+
|
|
46
|
+
const handleAgentCreate = useCallback(async (invitation: Invitation) => {
|
|
47
|
+
const invitationCode = InvitationEncoder.encode(invitation);
|
|
48
|
+
if (invitation.state === Invitation.State.CONNECTING) {
|
|
49
|
+
console.log(JSON.stringify({ invitationCode, authCode: invitation.authCode }));
|
|
50
|
+
invariant(identity, 'Identity not found');
|
|
51
|
+
if (agentHostingProviderClient) {
|
|
52
|
+
try {
|
|
53
|
+
const res = await agentHostingProviderClient?.createAgent(invitationCode, identity.identityKey.truncate());
|
|
54
|
+
// TODO(nf): human-consumable response from API
|
|
55
|
+
setAgentStatus(res);
|
|
56
|
+
setAgentActive(true);
|
|
57
|
+
setValidationMessage('');
|
|
58
|
+
} catch (err: any) {
|
|
59
|
+
setValidationMessage(`error creating agent: ${err.message}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
const onAgentCreate = async () => {
|
|
66
|
+
invitations.forEach((invitation) => invitation.cancel());
|
|
67
|
+
|
|
68
|
+
// TODO(nf): do this work in the hosting provider client?
|
|
69
|
+
const invitation = client.halo.share({ type: Invitation.Type.MULTIUSE, authMethod: Invitation.AuthMethod.NONE });
|
|
70
|
+
|
|
71
|
+
invitation.subscribe(handleAgentCreate);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const onAgentDestroy = async () => {
|
|
75
|
+
const identity = client.halo.identity.get();
|
|
76
|
+
invariant(identity, 'Identity not found');
|
|
77
|
+
try {
|
|
78
|
+
await agentHostingProviderClient?.destroyAgent(identity.identityKey.truncate());
|
|
79
|
+
setValidationMessage('No agent deployed via provider.');
|
|
80
|
+
setAgentStatus('');
|
|
81
|
+
setAgentActive(false);
|
|
82
|
+
} catch (err: any) {
|
|
83
|
+
setValidationMessage(`error destroying agent: ${err.message}`);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return { onAgentCreate, onAgentDestroy, validationMessage, agentStatus, agentActive };
|
|
88
|
+
};
|
|
@@ -193,8 +193,6 @@ export const JoinPanel = ({
|
|
|
193
193
|
},
|
|
194
194
|
});
|
|
195
195
|
|
|
196
|
-
console.log('[joinState]', joinState);
|
|
197
|
-
|
|
198
196
|
useEffect(() => {
|
|
199
197
|
const subscription = joinService.subscribe((state) => {
|
|
200
198
|
log('[state]', state);
|
|
@@ -368,6 +366,7 @@ export const JoinPanel = ({
|
|
|
368
366
|
identityKey: joinState.context.halo.invitation?.identityKey ?? null,
|
|
369
367
|
swarmKey: joinState.context.halo.invitation?.swarmKey ?? null,
|
|
370
368
|
spaceKey: joinState.context.halo.invitation?.spaceKey ?? null,
|
|
369
|
+
target: joinState.context.halo.invitation?.target ?? null,
|
|
371
370
|
});
|
|
372
371
|
}, [joinState, propsOnDone]);
|
|
373
372
|
|
|
@@ -376,6 +375,7 @@ export const JoinPanel = ({
|
|
|
376
375
|
identityKey: joinState.context.space.invitation?.identityKey ?? null,
|
|
377
376
|
swarmKey: joinState.context.space.invitation?.swarmKey ?? null,
|
|
378
377
|
spaceKey: joinState.context.space.invitation?.spaceKey ?? null,
|
|
378
|
+
target: joinState.context.space.invitation?.target ?? null,
|
|
379
379
|
});
|
|
380
380
|
}, [joinState, propsOnDone]);
|
|
381
381
|
|
|
@@ -397,7 +397,7 @@ const joinMachine = createMachine<JoinMachineContext, JoinEvent>(
|
|
|
397
397
|
event.type.includes('Space') ? { ...context.space, invitation: event.invitation } : context.space,
|
|
398
398
|
}),
|
|
399
399
|
log: (context, event) => {
|
|
400
|
-
log
|
|
400
|
+
log('[transition]', {
|
|
401
401
|
event,
|
|
402
402
|
haloInvitation: context.halo.invitation,
|
|
403
403
|
spaceInvitation: context.space.invitation,
|
|
@@ -129,6 +129,7 @@ export const SpaceManagerWithEvenMoreInvites = () => {
|
|
|
129
129
|
identityKey = PublicKey.random(),
|
|
130
130
|
swarmKey,
|
|
131
131
|
spaceKey = PublicKey.random(),
|
|
132
|
+
target = null,
|
|
132
133
|
} = invitation;
|
|
133
134
|
return (
|
|
134
135
|
<InvitationListItemImpl
|
|
@@ -140,7 +141,7 @@ export const SpaceManagerWithEvenMoreInvites = () => {
|
|
|
140
141
|
invitationCode: id,
|
|
141
142
|
authCode: state === Invitation.State.READY_FOR_AUTHENTICATION ? '123414' : undefined,
|
|
142
143
|
id,
|
|
143
|
-
result: { identityKey, swarmKey, spaceKey },
|
|
144
|
+
result: { identityKey, swarmKey, spaceKey, target },
|
|
144
145
|
cancel: () => {},
|
|
145
146
|
authenticate: async (authCode: string) => {},
|
|
146
147
|
connect: () => {},
|
|
@@ -39,17 +39,19 @@ export const SpacePanelImpl = (props: SpacePanelImplProps) => {
|
|
|
39
39
|
titleId,
|
|
40
40
|
activeView,
|
|
41
41
|
space,
|
|
42
|
+
target,
|
|
42
43
|
SpaceManager: SpaceManagerComponent = SpaceManager,
|
|
43
44
|
InvitationManager: InvitationManagerComponent = InvitationManager,
|
|
44
45
|
...rest
|
|
45
46
|
} = props;
|
|
47
|
+
|
|
46
48
|
return (
|
|
47
49
|
<DensityProvider density='fine'>
|
|
48
50
|
<SpacePanelHeading {...rest} {...{ titleId, space }} />
|
|
49
51
|
<Viewport.Root activeView={activeView}>
|
|
50
52
|
<Viewport.Views>
|
|
51
53
|
<Viewport.View id='space manager' classNames={stepStyles}>
|
|
52
|
-
<SpaceManagerComponent active={activeView === 'space manager'} space={space} {...rest} />
|
|
54
|
+
<SpaceManagerComponent active={activeView === 'space manager'} space={space} target={target} {...rest} />
|
|
53
55
|
</Viewport.View>
|
|
54
56
|
<Viewport.View id='space invitation manager' classNames={stepStyles}>
|
|
55
57
|
<InvitationManagerComponent
|
|
@@ -115,6 +117,7 @@ export const SpacePanel = ({
|
|
|
115
117
|
};
|
|
116
118
|
|
|
117
119
|
return spaceState.context.invitation ? (
|
|
120
|
+
// TODO(wittjosiah): Unused? Remove?
|
|
118
121
|
<SpacePanelWithInvitationImpl {...implProps} invitation={spaceState.context.invitation} />
|
|
119
122
|
) : (
|
|
120
123
|
<SpacePanelImpl {...implProps} />
|
|
@@ -16,6 +16,7 @@ export type SpacePanelImplProps = {
|
|
|
16
16
|
titleId: string;
|
|
17
17
|
activeView: string;
|
|
18
18
|
send: (event: SingleOrArray<Event<any>>) => void;
|
|
19
|
+
target?: string;
|
|
19
20
|
createInvitationUrl: (invitationCode: string) => string;
|
|
20
21
|
space: ErsatzSpace | Space;
|
|
21
22
|
invitationUrl?: string;
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
import { type SpacePanelStepProps } from '../SpacePanelProps';
|
|
24
24
|
|
|
25
25
|
export type SpaceManagerImplProps = SpacePanelStepProps & {
|
|
26
|
+
target?: string;
|
|
26
27
|
invitations?: CancellableInvitationObservable[];
|
|
27
28
|
showInactiveInvitations?: boolean;
|
|
28
29
|
inviteActions?: Record<string, ActionMenuItem>;
|
|
@@ -35,7 +36,7 @@ const activeActionKey = 'dxos:react-shell/space-manager/active-action';
|
|
|
35
36
|
export type SpaceManagerProps = SpaceManagerImplProps & {};
|
|
36
37
|
|
|
37
38
|
export const SpaceManager = (props: SpaceManagerProps) => {
|
|
38
|
-
const { space } = props;
|
|
39
|
+
const { space, target } = props;
|
|
39
40
|
const { t } = useTranslation('os');
|
|
40
41
|
const config = useConfig();
|
|
41
42
|
|
|
@@ -57,6 +58,7 @@ export const SpaceManager = (props: SpaceManagerProps) => {
|
|
|
57
58
|
const invitation = space.share?.({
|
|
58
59
|
type: Invitation.Type.INTERACTIVE,
|
|
59
60
|
authMethod: Invitation.AuthMethod.SHARED_SECRET,
|
|
61
|
+
target,
|
|
60
62
|
});
|
|
61
63
|
if (invitation && config.values.runtime?.app?.env?.DX_ENVIRONMENT !== 'production') {
|
|
62
64
|
invitation.subscribe(onInvitationEvent);
|
|
@@ -71,6 +73,7 @@ export const SpaceManager = (props: SpaceManagerProps) => {
|
|
|
71
73
|
const invitation = space.share?.({
|
|
72
74
|
type: Invitation.Type.MULTIUSE,
|
|
73
75
|
authMethod: Invitation.AuthMethod.NONE,
|
|
76
|
+
target,
|
|
74
77
|
});
|
|
75
78
|
if (invitation && config.values.runtime?.app?.env?.DX_ENVIRONMENT !== 'production') {
|
|
76
79
|
invitation.subscribe(onInvitationEvent);
|
|
@@ -69,7 +69,8 @@ export const os = {
|
|
|
69
69
|
'selecting identity heading': 'Selecting identity',
|
|
70
70
|
'devices heading': 'Devices',
|
|
71
71
|
'identity heading': 'Profile settings',
|
|
72
|
-
'choose
|
|
72
|
+
'choose add device label': 'Add device',
|
|
73
|
+
'choose devices label': 'Manage devices',
|
|
73
74
|
'choose profile label': 'Edit profile',
|
|
74
75
|
'choose sign out label': 'Sign out',
|
|
75
76
|
'empty space members message': 'There is nobody in this space yet.',
|
|
@@ -98,4 +99,9 @@ export const os = {
|
|
|
98
99
|
'This will clear this device and all associated data. Type {{confirmationValue}} and confirm to continue.',
|
|
99
100
|
'failed to reset identity message': 'Failed to reset identity.',
|
|
100
101
|
'confirmation value': 'CONFIRM',
|
|
102
|
+
'sign out chooser title': 'DANGER ZONE',
|
|
103
|
+
'sign out chooser message': 'Proceeding with either action below will erase all data on this device.',
|
|
104
|
+
'join new identity label': 'Join a new identity',
|
|
105
|
+
'reset device label': 'Reset device',
|
|
106
|
+
'reset device confirm message': 'Are you sure you want to reset your device? All data will be lost.',
|
|
101
107
|
};
|