@dxos/shell 0.3.11-main.008b7c6 → 0.3.11-main.0ac3ef5

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.
Files changed (79) hide show
  1. package/dist/bundle/shell.mjs +36433 -0
  2. package/dist/bundle/shell.mjs.map +1 -0
  3. package/dist/bundle/shell.umd.js +210 -0
  4. package/dist/bundle/shell.umd.js.map +1 -0
  5. package/dist/bundle/style.css +1 -0
  6. package/dist/lib/browser/meta.json +1 -1
  7. package/dist/lib/browser/react.mjs +344 -282
  8. package/dist/lib/browser/react.mjs.map +4 -4
  9. package/dist/types/src/components/IdentityList/DeviceList.d.ts.map +1 -1
  10. package/dist/types/src/components/IdentityList/DeviceList.js +5 -3
  11. package/dist/types/src/components/IdentityList/DeviceList.js.map +1 -1
  12. package/dist/types/src/composites/Shell/Shell.d.ts.map +1 -1
  13. package/dist/types/src/composites/Shell/Shell.js +10 -4
  14. package/dist/types/src/composites/Shell/Shell.js.map +1 -1
  15. package/dist/types/src/panels/IdentityPanel/IdentityPanel.d.ts.map +1 -1
  16. package/dist/types/src/panels/IdentityPanel/IdentityPanel.js +10 -1
  17. package/dist/types/src/panels/IdentityPanel/IdentityPanel.js.map +1 -1
  18. package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.d.ts +6 -0
  19. package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.d.ts.map +1 -1
  20. package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.js +26 -3
  21. package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.js.map +1 -1
  22. package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts +7 -6
  23. package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts.map +1 -1
  24. package/dist/types/src/panels/IdentityPanel/identityMachine.d.ts.map +1 -1
  25. package/dist/types/src/panels/IdentityPanel/identityMachine.js +2 -1
  26. package/dist/types/src/panels/IdentityPanel/identityMachine.js.map +1 -1
  27. package/dist/types/src/panels/IdentityPanel/steps/DeviceManager.d.ts +10 -0
  28. package/dist/types/src/panels/IdentityPanel/steps/DeviceManager.d.ts.map +1 -0
  29. package/dist/types/src/panels/IdentityPanel/steps/DeviceManager.js +23 -0
  30. package/dist/types/src/panels/IdentityPanel/steps/DeviceManager.js.map +1 -0
  31. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.d.ts.map +1 -1
  32. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js +4 -0
  33. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js.map +1 -1
  34. package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.d.ts +0 -1
  35. package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.d.ts.map +1 -1
  36. package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.js +2 -3
  37. package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.js.map +1 -1
  38. package/dist/types/src/panels/IdentityPanel/steps/index.d.ts +1 -0
  39. package/dist/types/src/panels/IdentityPanel/steps/index.d.ts.map +1 -1
  40. package/dist/types/src/panels/IdentityPanel/steps/index.js +1 -0
  41. package/dist/types/src/panels/IdentityPanel/steps/index.js.map +1 -1
  42. package/dist/types/src/panels/JoinPanel/JoinPanel.js +4 -3
  43. package/dist/types/src/panels/JoinPanel/JoinPanel.js.map +1 -1
  44. package/dist/types/src/panels/JoinPanel/joinMachine.js +1 -1
  45. package/dist/types/src/panels/JoinPanel/joinMachine.js.map +1 -1
  46. package/dist/types/src/panels/SpacePanel/SpacePanel.d.ts.map +1 -1
  47. package/dist/types/src/panels/SpacePanel/SpacePanel.js +5 -3
  48. package/dist/types/src/panels/SpacePanel/SpacePanel.js.map +1 -1
  49. package/dist/types/src/panels/SpacePanel/SpacePanel.stories.d.ts.map +1 -1
  50. package/dist/types/src/panels/SpacePanel/SpacePanel.stories.js +2 -2
  51. package/dist/types/src/panels/SpacePanel/SpacePanel.stories.js.map +1 -1
  52. package/dist/types/src/panels/SpacePanel/SpacePanelProps.d.ts +1 -0
  53. package/dist/types/src/panels/SpacePanel/SpacePanelProps.d.ts.map +1 -1
  54. package/dist/types/src/panels/SpacePanel/steps/SpaceManager.d.ts +1 -0
  55. package/dist/types/src/panels/SpacePanel/steps/SpaceManager.d.ts.map +1 -1
  56. package/dist/types/src/panels/SpacePanel/steps/SpaceManager.js +3 -1
  57. package/dist/types/src/panels/SpacePanel/steps/SpaceManager.js.map +1 -1
  58. package/dist/types/src/translations/locales/en-US.d.ts +1 -0
  59. package/dist/types/src/translations/locales/en-US.d.ts.map +1 -1
  60. package/dist/types/src/translations/locales/en-US.js +2 -1
  61. package/dist/types/src/translations/locales/en-US.js.map +1 -1
  62. package/package.json +17 -17
  63. package/src/components/IdentityList/DeviceList.tsx +7 -5
  64. package/src/composites/Shell/Shell.tsx +9 -2
  65. package/src/panels/IdentityPanel/IdentityPanel.stories.tsx +44 -2
  66. package/src/panels/IdentityPanel/IdentityPanel.tsx +14 -3
  67. package/src/panels/IdentityPanel/IdentityPanelProps.ts +7 -6
  68. package/src/panels/IdentityPanel/identityMachine.ts +2 -1
  69. package/src/panels/IdentityPanel/steps/DeviceManager.tsx +41 -0
  70. package/src/panels/IdentityPanel/steps/IdentityActionChooser.tsx +6 -1
  71. package/src/panels/IdentityPanel/steps/ProfileForm.tsx +1 -1
  72. package/src/panels/IdentityPanel/steps/index.ts +1 -0
  73. package/src/panels/JoinPanel/JoinPanel.tsx +2 -2
  74. package/src/panels/JoinPanel/joinMachine.ts +1 -1
  75. package/src/panels/SpacePanel/SpacePanel.stories.tsx +2 -1
  76. package/src/panels/SpacePanel/SpacePanel.tsx +4 -1
  77. package/src/panels/SpacePanel/SpacePanelProps.ts +1 -0
  78. package/src/panels/SpacePanel/steps/SpaceManager.tsx +4 -1
  79. package/src/translations/locales/en-US.ts +2 -1
@@ -6,7 +6,7 @@ import React, { useEffect, useMemo } from 'react';
6
6
  import { generateName } from '@dxos/display-name';
7
7
  import { log } from '@dxos/log';
8
8
  import { useClient } from '@dxos/react-client';
9
- import { type Identity, useIdentity } from '@dxos/react-client/halo';
9
+ import { type Identity, useIdentity, useDevices } from '@dxos/react-client/halo';
10
10
  import { useInvitationStatus } from '@dxos/react-client/invitations';
11
11
  import type { CancellableInvitationObservable } from '@dxos/react-client/invitations';
12
12
  import { Avatar, DensityProvider, useId, useJdenticonHref, useTranslation } from '@dxos/react-ui';
@@ -17,7 +17,7 @@ import {
17
17
  type IdentityPanelProps,
18
18
  } from './IdentityPanelProps';
19
19
  import { useIdentityMachine } from './identityMachine';
20
- import { IdentityActionChooser, ProfileForm } from './steps';
20
+ import { DeviceManager, IdentityActionChooser, ProfileForm } from './steps';
21
21
  import { Viewport, Heading, CloseButton } from '../../components';
22
22
  import { InvitationManager } from '../../steps';
23
23
 
@@ -54,12 +54,14 @@ export const IdentityPanelImpl = (props: IdentityPanelImplProps) => {
54
54
  const title = useMemo(() => {
55
55
  switch (activeView) {
56
56
  case 'device manager':
57
- case 'device invitation manager':
58
57
  return t('choose devices label');
58
+ case 'device invitation manager':
59
+ return t('choose add device label');
59
60
  default:
60
61
  return t('identity heading');
61
62
  }
62
63
  }, [activeView, t]);
64
+ console.log('[IdentityPanelImpl]', { activeView });
63
65
  return (
64
66
  <DensityProvider density='fine'>
65
67
  <IdentityHeading {...{ identity, titleId, title, onDone }} />
@@ -75,6 +77,9 @@ export const IdentityPanelImpl = (props: IdentityPanelImplProps) => {
75
77
  invitationUrl={rest.createInvitationUrl(rest.invitationCode!)}
76
78
  />
77
79
  </Viewport.View>
80
+ <Viewport.View id='device manager' classNames={viewStyles}>
81
+ <DeviceManager active={activeView === 'device manager'} {...rest} />
82
+ </Viewport.View>
78
83
  <Viewport.View classNames={viewStyles} id='update profile form'>
79
84
  <ProfileForm
80
85
  send={rest.send}
@@ -105,6 +110,7 @@ export const IdentityPanel = ({
105
110
  }: IdentityPanelProps) => {
106
111
  const titleId = useId('identityPanel__heading', propsTitleId);
107
112
  const client = useClient();
113
+ const devices = useDevices();
108
114
  const identity = useIdentity();
109
115
  if (!identity) {
110
116
  console.error('IdentityPanel rendered with no active identity.');
@@ -126,6 +132,8 @@ export const IdentityPanel = ({
126
132
  return 'identity action chooser';
127
133
  case identityState.matches('managingDeviceInvitation'):
128
134
  return 'device invitation manager';
135
+ case identityState.matches('managingDevices'):
136
+ return 'device manager';
129
137
  case [{ managingProfile: 'idle' }, { managingProfile: 'pending' }].some(identityState.matches):
130
138
  return 'update profile form';
131
139
  // case identityState.matches('signingOut'):
@@ -135,6 +143,8 @@ export const IdentityPanel = ({
135
143
  }
136
144
  }, [identityState]);
137
145
 
146
+ console.log({ activeView, identityState });
147
+
138
148
  const onUpdateProfile = async (profile: NonNullable<Identity['profile']>) => {
139
149
  identitySend({ type: 'updateProfile' });
140
150
  await client.halo.updateProfile(profile);
@@ -143,6 +153,7 @@ export const IdentityPanel = ({
143
153
  const implProps = {
144
154
  ...props,
145
155
  identity,
156
+ devices,
146
157
  activeView,
147
158
  send: identitySend,
148
159
  titleId,
@@ -2,19 +2,20 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type cloneElement } from 'react';
6
- import { type Event, type SingleOrArray } from 'xstate';
5
+ import type { cloneElement } from 'react';
6
+ import type { Event, SingleOrArray } from 'xstate';
7
7
 
8
- import type { Identity } from '@dxos/react-client/halo';
9
- import { type InvitationStatus } from '@dxos/react-client/invitations';
8
+ import type { Device, Identity } from '@dxos/react-client/halo';
9
+ import type { InvitationStatus } from '@dxos/react-client/invitations';
10
10
 
11
- import { type IdentityEvent } from './identityMachine';
12
- import { type InvitationManagerProps } from '../../steps';
11
+ import type { IdentityEvent } from './identityMachine';
12
+ import type { InvitationManagerProps } from '../../steps';
13
13
 
14
14
  export type IdentityPanelImplProps = {
15
15
  titleId: string;
16
16
  activeView: 'device manager' | 'update profile form' | 'device invitation manager' | 'identity action chooser';
17
17
  identity: Identity;
18
+ devices: Device[];
18
19
  onUpdateProfile?: (profile: NonNullable<Identity['profile']>) => Promise<void>;
19
20
  createInvitationUrl: (invitationCode: string) => string;
20
21
  send?: (event: SingleOrArray<Event<IdentityEvent>>) => void;
@@ -58,6 +58,7 @@ const identityMachine = createMachine<IdentityMachineContext, IdentityEvent>(
58
58
  states: {
59
59
  choosingAction: {},
60
60
  managingDeviceInvitation: {},
61
+ managingDevices: {},
61
62
  managingProfile: {
62
63
  initial: 'idle',
63
64
  states: {
@@ -73,9 +74,9 @@ const identityMachine = createMachine<IdentityMachineContext, IdentityEvent>(
73
74
  },
74
75
  on: {
75
76
  unchooseAction: { target: '.choosingAction', actions: ['unsetInvitation', 'log'] },
76
- chooseDevices: { target: '.managingDeviceInvitation', actions: ['unsetInvitation', 'log'] },
77
77
  deselectInvitation: { target: '.choosingAction', actions: ['unsetInvitation', 'log'] },
78
78
  selectInvitation: { target: '.managingDeviceInvitation', actions: ['setInvitation', 'log'] },
79
+ chooseDevices: { target: '.managingDevices', actions: 'log' },
79
80
  chooseProfile: { target: '.managingProfile', actions: 'log' },
80
81
  // chooseSignOut: { target: '.signingOut', actions: 'log' },
81
82
  },
@@ -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 } from '@phosphor-icons/react';
6
6
  import React, { useCallback } from 'react';
7
7
 
8
8
  import { useClient } from '@dxos/react-client';
@@ -70,6 +70,11 @@ export const IdentityActionChooserImpl = ({
70
70
  classNames='plb-4'
71
71
  >
72
72
  <Plus className={getSize(6)} />
73
+ <span className='grow mli-3'>{t('choose add device label')}</span>
74
+ <CaretRight weight='bold' className={getSize(4)} />
75
+ </Action>
76
+ <Action data-testid='manage-devices' onClick={() => send?.({ type: 'chooseDevices' })} classNames='plb-4'>
77
+ <Devices className={getSize(6)} />
73
78
  <span className='grow mli-3'>{t('choose devices label')}</span>
74
79
  <CaretRight weight='bold' className={getSize(4)} />
75
80
  </Action>
@@ -37,7 +37,7 @@ export const ProfileForm = (props: ProfileFormProps) => {
37
37
  };
38
38
 
39
39
  // TODO(zhenyasav): impl shouldn't need send()
40
- export const ProfileFormImpl = (props: ProfileFormImplProps) => {
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');
@@ -2,5 +2,6 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ export * from './DeviceManager';
5
6
  export * from './IdentityActionChooser';
6
7
  export * from './ProfileForm';
@@ -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.info('[transition]', {
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 devices label': 'Add device',
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.',