@dxos/shell 0.4.10-main.fa5a270 → 0.4.10-main.fe71b4c

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 (220) hide show
  1. package/dist/bundle/index-BjPIerZ_.mjs +110 -0
  2. package/dist/bundle/index-BjPIerZ_.mjs.map +1 -0
  3. package/dist/bundle/index-BnojJ-lm.mjs +96615 -0
  4. package/dist/bundle/index-BnojJ-lm.mjs.map +1 -0
  5. package/dist/bundle/shell.mjs +9 -80814
  6. package/dist/bundle/shell.mjs.map +1 -1
  7. package/dist/bundle/shell.umd.js +156 -85
  8. package/dist/bundle/shell.umd.js.map +1 -1
  9. package/dist/bundle/style.css +1 -1
  10. package/dist/lib/browser/meta.json +1 -1
  11. package/dist/lib/browser/react.mjs +1177 -1034
  12. package/dist/lib/browser/react.mjs.map +4 -4
  13. package/dist/lib/browser/testing/index.mjs +8 -8
  14. package/dist/lib/browser/testing/index.mjs.map +3 -3
  15. package/dist/types/src/components/AgentConfig.d.ts +3 -0
  16. package/dist/types/src/components/AgentConfig.d.ts.map +1 -0
  17. package/dist/types/src/components/AgentConfig.js +37 -0
  18. package/dist/types/src/components/AgentConfig.js.map +1 -0
  19. package/dist/types/src/components/DeviceList/DeviceList.d.ts +3 -0
  20. package/dist/types/src/components/DeviceList/DeviceList.d.ts.map +1 -0
  21. package/dist/types/src/components/DeviceList/DeviceList.js +29 -0
  22. package/dist/types/src/components/DeviceList/DeviceList.js.map +1 -0
  23. package/dist/types/src/components/DeviceList/DeviceListItem.d.ts +6 -0
  24. package/dist/types/src/components/DeviceList/DeviceListItem.d.ts.map +1 -0
  25. package/dist/types/src/components/DeviceList/DeviceListItem.js +72 -0
  26. package/dist/types/src/components/DeviceList/DeviceListItem.js.map +1 -0
  27. package/dist/types/src/components/DeviceList/DeviceListProps.d.ts +27 -0
  28. package/dist/types/src/components/DeviceList/DeviceListProps.d.ts.map +1 -0
  29. package/dist/types/src/components/DeviceList/DeviceListProps.js +6 -0
  30. package/dist/types/src/components/DeviceList/DeviceListProps.js.map +1 -0
  31. package/dist/types/src/components/DeviceList/index.d.ts +3 -0
  32. package/dist/types/src/components/DeviceList/index.d.ts.map +1 -0
  33. package/dist/types/src/components/DeviceList/index.js +22 -0
  34. package/dist/types/src/components/DeviceList/index.js.map +1 -0
  35. package/dist/types/src/components/EmojiPicker.d.ts +9 -2
  36. package/dist/types/src/components/EmojiPicker.d.ts.map +1 -1
  37. package/dist/types/src/components/EmojiPicker.js +59 -4
  38. package/dist/types/src/components/EmojiPicker.js.map +1 -1
  39. package/dist/types/src/components/HuePicker.d.ts +9 -2
  40. package/dist/types/src/components/HuePicker.d.ts.map +1 -1
  41. package/dist/types/src/components/HuePicker.js +75 -6
  42. package/dist/types/src/components/HuePicker.js.map +1 -1
  43. package/dist/types/src/components/IdentityList/index.d.ts +0 -1
  44. package/dist/types/src/components/IdentityList/index.d.ts.map +1 -1
  45. package/dist/types/src/components/IdentityList/index.js +0 -1
  46. package/dist/types/src/components/IdentityList/index.js.map +1 -1
  47. package/dist/types/src/components/InvitationList/InvitationListItem.js +5 -5
  48. package/dist/types/src/components/InvitationList/InvitationListItem.js.map +1 -1
  49. package/dist/types/src/components/Panel/Action.d.ts +2 -2
  50. package/dist/types/src/components/Viewport/Viewport.d.ts +1 -1
  51. package/dist/types/src/components/index.d.ts +2 -0
  52. package/dist/types/src/components/index.d.ts.map +1 -1
  53. package/dist/types/src/components/index.js +2 -0
  54. package/dist/types/src/components/index.js.map +1 -1
  55. package/dist/types/src/composites/IdentityDialog/IdentityDialog.js +1 -1
  56. package/dist/types/src/composites/IdentityDialog/IdentityDialog.js.map +1 -1
  57. package/dist/types/src/composites/Shell/Shell.d.ts.map +1 -1
  58. package/dist/types/src/composites/Shell/Shell.js +14 -6
  59. package/dist/types/src/composites/Shell/Shell.js.map +1 -1
  60. package/dist/types/src/composites/StatusDialog/StatusDialog.d.ts +2 -0
  61. package/dist/types/src/composites/StatusDialog/StatusDialog.d.ts.map +1 -0
  62. package/dist/types/src/composites/StatusDialog/StatusDialog.js +22 -0
  63. package/dist/types/src/composites/StatusDialog/StatusDialog.js.map +1 -0
  64. package/dist/types/src/composites/StatusDialog/index.d.ts +2 -0
  65. package/dist/types/src/composites/StatusDialog/index.d.ts.map +1 -0
  66. package/dist/types/src/composites/StatusDialog/index.js +21 -0
  67. package/dist/types/src/composites/StatusDialog/index.js.map +1 -0
  68. package/dist/types/src/panels/IdentityPanel/IdentityPanel.d.ts +1 -1
  69. package/dist/types/src/panels/IdentityPanel/IdentityPanel.d.ts.map +1 -1
  70. package/dist/types/src/panels/IdentityPanel/IdentityPanel.js +89 -42
  71. package/dist/types/src/panels/IdentityPanel/IdentityPanel.js.map +1 -1
  72. package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.d.ts +0 -3
  73. package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.d.ts.map +1 -1
  74. package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.js +1 -43
  75. package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.js.map +1 -1
  76. package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts +11 -12
  77. package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts.map +1 -1
  78. package/dist/types/src/panels/IdentityPanel/identityMachine.d.ts +3 -1
  79. package/dist/types/src/panels/IdentityPanel/identityMachine.d.ts.map +1 -1
  80. package/dist/types/src/panels/IdentityPanel/identityMachine.js +13 -24
  81. package/dist/types/src/panels/IdentityPanel/identityMachine.js.map +1 -1
  82. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.d.ts +4 -4
  83. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.d.ts.map +1 -1
  84. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js +9 -39
  85. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js.map +1 -1
  86. package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.d.ts +1 -1
  87. package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.d.ts.map +1 -1
  88. package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.js +6 -3
  89. package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.js.map +1 -1
  90. package/dist/types/src/panels/IdentityPanel/steps/index.d.ts +0 -3
  91. package/dist/types/src/panels/IdentityPanel/steps/index.d.ts.map +1 -1
  92. package/dist/types/src/panels/IdentityPanel/steps/index.js +0 -3
  93. package/dist/types/src/panels/IdentityPanel/steps/index.js.map +1 -1
  94. package/dist/types/src/panels/IdentityPanel/useAgentHandlers.d.ts.map +1 -1
  95. package/dist/types/src/panels/IdentityPanel/useAgentHandlers.js +5 -1
  96. package/dist/types/src/panels/IdentityPanel/useAgentHandlers.js.map +1 -1
  97. package/dist/types/src/panels/JoinPanel/JoinPanel.d.ts +1 -1
  98. package/dist/types/src/panels/JoinPanel/JoinPanel.d.ts.map +1 -1
  99. package/dist/types/src/panels/JoinPanel/JoinPanel.js +12 -5
  100. package/dist/types/src/panels/JoinPanel/JoinPanel.js.map +1 -1
  101. package/dist/types/src/panels/JoinPanel/JoinPanel.stories.d.ts +1 -1
  102. package/dist/types/src/panels/JoinPanel/JoinPanel.stories.d.ts.map +1 -1
  103. package/dist/types/src/panels/JoinPanel/JoinPanel.stories.js +2 -1
  104. package/dist/types/src/panels/JoinPanel/JoinPanel.stories.js.map +1 -1
  105. package/dist/types/src/panels/JoinPanel/JoinPanelProps.d.ts +8 -3
  106. package/dist/types/src/panels/JoinPanel/JoinPanelProps.d.ts.map +1 -1
  107. package/dist/types/src/panels/JoinPanel/joinMachine.d.ts +3 -2
  108. package/dist/types/src/panels/JoinPanel/joinMachine.d.ts.map +1 -1
  109. package/dist/types/src/panels/JoinPanel/joinMachine.js +7 -0
  110. package/dist/types/src/panels/JoinPanel/joinMachine.js.map +1 -1
  111. package/dist/types/src/panels/JoinPanel/steps/index.d.ts +0 -1
  112. package/dist/types/src/panels/JoinPanel/steps/index.d.ts.map +1 -1
  113. package/dist/types/src/panels/JoinPanel/steps/index.js +0 -1
  114. package/dist/types/src/panels/JoinPanel/steps/index.js.map +1 -1
  115. package/dist/types/src/panels/SpacePanel/steps/SpaceManager.d.ts.map +1 -1
  116. package/dist/types/src/panels/SpacePanel/steps/SpaceManager.js +3 -1
  117. package/dist/types/src/panels/SpacePanel/steps/SpaceManager.js.map +1 -1
  118. package/dist/types/src/panels/StatusPanel/StatusPanel.d.ts +4 -0
  119. package/dist/types/src/panels/StatusPanel/StatusPanel.d.ts.map +1 -0
  120. package/dist/types/src/panels/StatusPanel/StatusPanel.js +19 -0
  121. package/dist/types/src/panels/StatusPanel/StatusPanel.js.map +1 -0
  122. package/dist/types/src/panels/StatusPanel/index.d.ts +2 -0
  123. package/dist/types/src/panels/StatusPanel/index.d.ts.map +1 -0
  124. package/dist/types/src/panels/StatusPanel/index.js +21 -0
  125. package/dist/types/src/panels/StatusPanel/index.js.map +1 -0
  126. package/dist/types/src/panels/index.d.ts +1 -0
  127. package/dist/types/src/panels/index.d.ts.map +1 -1
  128. package/dist/types/src/panels/index.js +1 -0
  129. package/dist/types/src/panels/index.js.map +1 -1
  130. package/dist/types/src/steps/ConfirmReset.d.ts +16 -0
  131. package/dist/types/src/steps/ConfirmReset.d.ts.map +1 -0
  132. package/dist/types/src/steps/ConfirmReset.js +71 -0
  133. package/dist/types/src/steps/ConfirmReset.js.map +1 -0
  134. package/dist/types/src/steps/InvitationManager.d.ts +1 -1
  135. package/dist/types/src/steps/InvitationManager.d.ts.map +1 -1
  136. package/dist/types/src/steps/InvitationManager.js +3 -4
  137. package/dist/types/src/steps/InvitationManager.js.map +1 -1
  138. package/dist/types/src/steps/StepProps.d.ts +4 -1
  139. package/dist/types/src/steps/StepProps.d.ts.map +1 -1
  140. package/dist/types/src/steps/index.d.ts +1 -0
  141. package/dist/types/src/steps/index.d.ts.map +1 -1
  142. package/dist/types/src/steps/index.js +1 -0
  143. package/dist/types/src/steps/index.js.map +1 -1
  144. package/dist/types/src/stories/Invitations.e2e-stories.d.ts.map +1 -1
  145. package/dist/types/src/stories/Invitations.e2e-stories.js +2 -2
  146. package/dist/types/src/stories/Invitations.e2e-stories.js.map +1 -1
  147. package/dist/types/src/testing/shell-manager.d.ts.map +1 -1
  148. package/dist/types/src/testing/shell-manager.js +8 -8
  149. package/dist/types/src/testing/shell-manager.js.map +1 -1
  150. package/dist/types/src/translations/locales/en-US.d.ts +16 -3
  151. package/dist/types/src/translations/locales/en-US.d.ts.map +1 -1
  152. package/dist/types/src/translations/locales/en-US.js +20 -7
  153. package/dist/types/src/translations/locales/en-US.js.map +1 -1
  154. package/dist/types/src/types/index.js +1 -0
  155. package/dist/types/src/types/index.js.map +1 -1
  156. package/package.json +22 -21
  157. package/src/components/AgentConfig.tsx +66 -0
  158. package/src/components/DeviceList/DeviceList.tsx +54 -0
  159. package/src/components/DeviceList/DeviceListItem.tsx +120 -0
  160. package/src/components/DeviceList/DeviceListProps.ts +33 -0
  161. package/src/components/DeviceList/index.ts +6 -0
  162. package/src/components/EmojiPicker.tsx +103 -4
  163. package/src/components/HuePicker.tsx +99 -5
  164. package/src/components/IdentityList/index.ts +0 -1
  165. package/src/components/InvitationList/InvitationListItem.tsx +5 -5
  166. package/src/components/index.ts +2 -0
  167. package/src/composites/IdentityDialog/IdentityDialog.tsx +1 -1
  168. package/src/composites/Shell/Shell.tsx +17 -4
  169. package/src/composites/StatusDialog/StatusDialog.tsx +24 -0
  170. package/src/composites/StatusDialog/index.ts +5 -0
  171. package/src/panels/IdentityPanel/IdentityPanel.stories.tsx +0 -63
  172. package/src/panels/IdentityPanel/IdentityPanel.tsx +149 -43
  173. package/src/panels/IdentityPanel/IdentityPanelProps.ts +15 -15
  174. package/src/panels/IdentityPanel/identityMachine.ts +17 -25
  175. package/src/panels/IdentityPanel/steps/IdentityActionChooser.tsx +23 -67
  176. package/src/panels/IdentityPanel/steps/ProfileForm.tsx +18 -5
  177. package/src/panels/IdentityPanel/steps/index.ts +0 -3
  178. package/src/panels/IdentityPanel/useAgentHandlers.ts +5 -1
  179. package/src/panels/JoinPanel/JoinPanel.stories.tsx +3 -2
  180. package/src/panels/JoinPanel/JoinPanel.tsx +21 -5
  181. package/src/panels/JoinPanel/JoinPanelProps.ts +9 -3
  182. package/src/panels/JoinPanel/joinMachine.ts +12 -2
  183. package/src/panels/JoinPanel/steps/index.ts +0 -1
  184. package/src/panels/SpacePanel/steps/SpaceManager.tsx +3 -1
  185. package/src/panels/StatusPanel/StatusPanel.tsx +19 -0
  186. package/src/panels/StatusPanel/index.ts +5 -0
  187. package/src/panels/index.ts +1 -0
  188. package/src/steps/ConfirmReset.tsx +112 -0
  189. package/src/steps/InvitationManager.tsx +4 -4
  190. package/src/steps/StepProps.ts +2 -1
  191. package/src/steps/index.ts +1 -0
  192. package/src/stories/Invitations.e2e-stories.tsx +3 -3
  193. package/src/testing/shell-manager.ts +8 -8
  194. package/src/translations/locales/en-US.ts +22 -7
  195. package/src/types/index.ts +2 -0
  196. package/dist/types/src/components/IdentityList/DeviceList.d.ts +0 -7
  197. package/dist/types/src/components/IdentityList/DeviceList.d.ts.map +0 -1
  198. package/dist/types/src/components/IdentityList/DeviceList.js +0 -34
  199. package/dist/types/src/components/IdentityList/DeviceList.js.map +0 -1
  200. package/dist/types/src/panels/IdentityPanel/steps/AgentForm.d.ts +0 -3
  201. package/dist/types/src/panels/IdentityPanel/steps/AgentForm.d.ts.map +0 -1
  202. package/dist/types/src/panels/IdentityPanel/steps/AgentForm.js +0 -26
  203. package/dist/types/src/panels/IdentityPanel/steps/AgentForm.js.map +0 -1
  204. package/dist/types/src/panels/IdentityPanel/steps/DeviceManager.d.ts +0 -10
  205. package/dist/types/src/panels/IdentityPanel/steps/DeviceManager.d.ts.map +0 -1
  206. package/dist/types/src/panels/IdentityPanel/steps/DeviceManager.js +0 -23
  207. package/dist/types/src/panels/IdentityPanel/steps/DeviceManager.js.map +0 -1
  208. package/dist/types/src/panels/IdentityPanel/steps/SignOutChooser.d.ts +0 -16
  209. package/dist/types/src/panels/IdentityPanel/steps/SignOutChooser.d.ts.map +0 -1
  210. package/dist/types/src/panels/IdentityPanel/steps/SignOutChooser.js +0 -40
  211. package/dist/types/src/panels/IdentityPanel/steps/SignOutChooser.js.map +0 -1
  212. package/dist/types/src/panels/JoinPanel/steps/ResetIdentity.d.ts +0 -13
  213. package/dist/types/src/panels/JoinPanel/steps/ResetIdentity.d.ts.map +0 -1
  214. package/dist/types/src/panels/JoinPanel/steps/ResetIdentity.js +0 -66
  215. package/dist/types/src/panels/JoinPanel/steps/ResetIdentity.js.map +0 -1
  216. package/src/components/IdentityList/DeviceList.tsx +0 -49
  217. package/src/panels/IdentityPanel/steps/AgentForm.tsx +0 -61
  218. package/src/panels/IdentityPanel/steps/DeviceManager.tsx +0 -41
  219. package/src/panels/IdentityPanel/steps/SignOutChooser.tsx +0 -84
  220. package/src/panels/JoinPanel/steps/ResetIdentity.tsx +0 -80
@@ -1,49 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { generateName } from '@dxos/display-name';
8
- import { type Device, DeviceType } from '@dxos/react-client/halo';
9
- import { List, useTranslation } from '@dxos/react-ui';
10
- import { descriptionText, mx } from '@dxos/react-ui-theme';
11
-
12
- import { IdentityListItem } from './IdentityListItem';
13
-
14
- export interface DeviceListProps {
15
- devices: Device[];
16
- onSelect?: (device: Device) => void;
17
- }
18
-
19
- export const DeviceList = ({ devices, onSelect }: DeviceListProps) => {
20
- const { t } = useTranslation('os');
21
- return devices.length > 0 ? (
22
- <List classNames='flex flex-col gap-2'>
23
- {devices.map((device) => {
24
- // TODO(wittjosiah): Render this better. Consider communicating these as apps rather than devices.
25
- const deviceType = device.profile?.type || DeviceType.UNKNOWN;
26
- const displayName = device.profile?.label
27
- ? `${device.profile.label} (${DeviceType[deviceType]})`
28
- : generateName(device.deviceKey.toHex());
29
-
30
- const identity = {
31
- identityKey: device.deviceKey,
32
- profile: { displayName },
33
- };
34
- return (
35
- <IdentityListItem
36
- key={device.deviceKey.toHex()}
37
- identity={identity}
38
- presence={device.presence}
39
- onClick={onSelect && (() => onSelect(device))}
40
- />
41
- );
42
- })}
43
- </List>
44
- ) : (
45
- <div role='none' className='grow flex items-center p-2'>
46
- <p className={mx(descriptionText, 'text-center is-full')}>{t('empty device list message')}</p>
47
- </div>
48
- );
49
- };
@@ -1,61 +0,0 @@
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
- };
@@ -1,41 +0,0 @@
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
- };
@@ -1,84 +0,0 @@
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
- data-testid='sign-out.join-new-identity'
66
- classNames='!bg-error-500 hover:!bg-error-550'
67
- disabled={disabled}
68
- onClick={onJoinNewIdentity}
69
- >
70
- {t('join new identity label')}
71
- </Action>
72
- <Action
73
- variant='primary'
74
- data-testid='sign-out.reset-device'
75
- classNames='!bg-error-500 hover:!bg-error-550'
76
- disabled={disabled}
77
- onClick={onResetDevice}
78
- >
79
- {t('reset device label')}
80
- </Action>
81
- </Actions>
82
- </>
83
- );
84
- };
@@ -1,80 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { useState } from 'react';
6
-
7
- import { log } from '@dxos/log';
8
- import { useClient } from '@dxos/react-client';
9
- import { useTranslation } from '@dxos/react-ui';
10
-
11
- import { Action, Actions, StepHeading, Input } from '../../../components';
12
- import { type JoinStepProps } from '../JoinPanelProps';
13
-
14
- export type ResetIdentityProps = JoinStepProps & {
15
- method: 'reset identity';
16
- };
17
-
18
- export type ResetIdentityImplProps = {
19
- disabled?: boolean;
20
- pending?: boolean;
21
- validationMessage?: string;
22
- onConfirm?: () => void;
23
- };
24
-
25
- export const ResetIdentity = ({ send, active }: ResetIdentityProps) => {
26
- const client = useClient();
27
- const { t } = useTranslation('os');
28
- const [validationMessage, setValidationMessage] = useState('');
29
- const [pending, setPending] = useState(false);
30
- const resetIdentity = () => {
31
- setPending(true);
32
- void client.reset().then(
33
- () => send?.({ type: 'resetIdentity' }),
34
- (error) => {
35
- log.catch(error);
36
- setValidationMessage(t('failed to reset identity message'));
37
- setPending(false);
38
- },
39
- );
40
- };
41
- return (
42
- <ResetIdentityImpl
43
- disabled={!active}
44
- pending={pending}
45
- validationMessage={validationMessage}
46
- onConfirm={() => resetIdentity()}
47
- />
48
- );
49
- };
50
-
51
- export const ResetIdentityImpl = ({ disabled, pending, validationMessage, onConfirm }: ResetIdentityImplProps) => {
52
- const { t } = useTranslation('os');
53
- const confirmationValue = t('confirmation value');
54
- const [inputValue, setInputValue] = useState('');
55
- return (
56
- <>
57
- <div role='none' className='grow flex flex-col justify-center'>
58
- <Input
59
- {...{ validationMessage }}
60
- label={<StepHeading>{t('reset identity input label', { confirmationValue })}</StepHeading>}
61
- disabled={disabled}
62
- data-testid='reset-identity-input'
63
- placeholder={confirmationValue}
64
- onChange={({ target: { value } }) => setInputValue(value)}
65
- />
66
- </div>
67
- <Actions>
68
- <Action
69
- // TODO(wittjosiah): Probably make this red?
70
- variant='primary'
71
- disabled={disabled || pending || inputValue !== confirmationValue}
72
- onClick={() => onConfirm?.()}
73
- data-testid='reset-identity-input-confirm'
74
- >
75
- {pending ? t('reset in progress label') : t('confirm label')}
76
- </Action>
77
- </Actions>
78
- </>
79
- );
80
- };