@dxos/plugin-space 0.8.2-main.fbd8ed0 → 0.8.2-staging.4d6ad0f
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-7X3SIPCD.mjs → app-graph-builder-DCWUULKX.mjs} +5 -5
- package/dist/lib/browser/{app-graph-serializer-VRU57AEZ.mjs → app-graph-serializer-MLU7XI2P.mjs} +4 -4
- package/dist/lib/browser/{chunk-KVRYWFZU.mjs → chunk-3LN4LJN6.mjs} +3 -8
- package/dist/lib/{node-esm/chunk-PIYAWT5N.mjs.map → browser/chunk-3LN4LJN6.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-AR5R2F6B.mjs → chunk-7Y4M7GXO.mjs} +37 -31
- package/dist/lib/browser/{chunk-AR5R2F6B.mjs.map → chunk-7Y4M7GXO.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-IQFFOAWD.mjs → chunk-N5QMRLKI.mjs} +2 -2
- package/dist/lib/browser/chunk-Q4BTFH2P.mjs +1900 -0
- package/dist/lib/{node-esm/chunk-FI3WV22Y.mjs.map → browser/chunk-Q4BTFH2P.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-UBSVH2NQ.mjs → chunk-VEBKN45O.mjs} +2 -2
- package/dist/lib/browser/chunk-W46VVHFM.mjs +288 -0
- package/dist/lib/browser/chunk-W46VVHFM.mjs.map +7 -0
- package/dist/lib/browser/{identity-created-ANRJHNMQ.mjs → identity-created-O63SIYOF.mjs} +2 -2
- package/dist/lib/browser/index.mjs +9 -12
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/{intent-resolver-KRINV5QI.mjs → intent-resolver-KBF3YU6I.mjs} +25 -9
- package/dist/lib/browser/intent-resolver-KBF3YU6I.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-root-J3SP2HVW.mjs → react-root-PVKJE4EZ.mjs} +6 -6
- package/dist/lib/browser/{react-surface-J7T2IMH4.mjs → react-surface-252P4NCK.mjs} +6 -6
- package/dist/lib/browser/{schema-defs-OCBY7APN.mjs → schema-defs-JMN74RNK.mjs} +2 -2
- package/dist/lib/browser/{schema-tools-MYC4LTQD.mjs → schema-tools-JIEMHUXV.mjs} +9 -9
- package/dist/lib/browser/schema-tools-JIEMHUXV.mjs.map +7 -0
- package/dist/lib/browser/{settings-G24447B7.mjs → settings-2IN2WLUK.mjs} +2 -2
- package/dist/lib/browser/{spaces-ready-5I3RKYTT.mjs → spaces-ready-L4QAGTDE.mjs} +5 -5
- package/dist/lib/browser/{spaces-ready-5I3RKYTT.mjs.map → spaces-ready-L4QAGTDE.mjs.map} +1 -1
- package/dist/lib/browser/{state-SI4B5GHC.mjs → state-6HOSHLIN.mjs} +2 -2
- package/dist/lib/browser/types/index.mjs +1 -7
- package/dist/lib/node/{app-graph-builder-C2ISDMSL.cjs → app-graph-builder-WC445X77.cjs} +40 -40
- package/dist/lib/node/{app-graph-serializer-VLBCR3IX.cjs → app-graph-serializer-UPQOQVMJ.cjs} +20 -20
- package/dist/lib/node/{chunk-DQN4ZQDW.cjs → chunk-5WLAXYE3.cjs} +40 -34
- package/dist/lib/node/{chunk-DQN4ZQDW.cjs.map → chunk-5WLAXYE3.cjs.map} +1 -1
- package/dist/lib/node/{chunk-IKIDS6XF.cjs → chunk-7GQGM4ZF.cjs} +7 -13
- package/dist/lib/node/{chunk-IKIDS6XF.cjs.map → chunk-7GQGM4ZF.cjs.map} +3 -3
- package/dist/lib/node/{chunk-SCATWJKX.cjs → chunk-COQYISES.cjs} +27 -27
- package/dist/lib/node/{chunk-5YHUQJVB.cjs → chunk-DXL5TDFP.cjs} +6 -6
- package/dist/lib/node/{chunk-K6ZO4WDJ.cjs → chunk-FXHI7JNY.cjs} +121 -130
- package/dist/lib/node/chunk-FXHI7JNY.cjs.map +7 -0
- package/dist/lib/node/chunk-Q3YZEYZT.cjs +1904 -0
- package/dist/lib/node/{chunk-MXBE2VET.cjs.map → chunk-Q3YZEYZT.cjs.map} +3 -3
- package/dist/lib/node/{identity-created-NIPYGVG3.cjs → identity-created-UXEAUGC7.cjs} +6 -6
- package/dist/lib/node/index.cjs +68 -72
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/{intent-resolver-MJVRY6YE.cjs → intent-resolver-SVFJKUH7.cjs} +75 -59
- package/dist/lib/node/intent-resolver-SVFJKUH7.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-root-M4BZ6VXB.cjs → react-root-DDPDUMCG.cjs} +11 -11
- package/dist/lib/node/{react-surface-RYKSYYKM.cjs → react-surface-JUIU37BX.cjs} +44 -44
- package/dist/lib/node/{schema-defs-2HJLXSNK.cjs → schema-defs-XLFBG3XK.cjs} +6 -6
- package/dist/lib/node/{schema-tools-OE3MFYYH.cjs → schema-tools-ZG6Z2QRC.cjs} +16 -16
- package/dist/lib/node/schema-tools-ZG6Z2QRC.cjs.map +7 -0
- package/dist/lib/node/{settings-AFWO4AWK.cjs → settings-FOH7EB5C.cjs} +6 -6
- package/dist/lib/node/{spaces-ready-BMPXSFHF.cjs → spaces-ready-VXQYCBII.cjs} +14 -14
- package/dist/lib/node/{spaces-ready-BMPXSFHF.cjs.map → spaces-ready-VXQYCBII.cjs.map} +1 -1
- package/dist/lib/node/{state-L2ZSDKLS.cjs → state-ZT3MTZXB.cjs} +6 -6
- package/dist/lib/node/types/index.cjs +12 -18
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/{app-graph-builder-WVCQZ324.mjs → app-graph-builder-E7CCGPQJ.mjs} +5 -5
- package/dist/lib/node-esm/{app-graph-serializer-GEUYYXKD.mjs → app-graph-serializer-UCMSLPIA.mjs} +4 -4
- package/dist/lib/node-esm/{chunk-PIYAWT5N.mjs → chunk-4X4Y63ND.mjs} +3 -8
- package/dist/lib/{browser/chunk-KVRYWFZU.mjs.map → node-esm/chunk-4X4Y63ND.mjs.map} +3 -3
- package/dist/lib/node-esm/chunk-FTELJGEG.mjs +289 -0
- package/dist/lib/node-esm/chunk-FTELJGEG.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HNKAG5CX.mjs → chunk-GH2FGJXH.mjs} +37 -31
- package/dist/lib/node-esm/{chunk-HNKAG5CX.mjs.map → chunk-GH2FGJXH.mjs.map} +1 -1
- package/dist/lib/node-esm/chunk-HL2Z2GNW.mjs +1901 -0
- package/dist/lib/{browser/chunk-43UQWMD3.mjs.map → node-esm/chunk-HL2Z2GNW.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-5NIBYPVF.mjs → chunk-OSPEGYX3.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-S2W6HS4A.mjs → chunk-XAZNQ3QN.mjs} +2 -2
- package/dist/lib/node-esm/{identity-created-O5X2FFWU.mjs → identity-created-ZECO4NH3.mjs} +2 -2
- package/dist/lib/node-esm/index.mjs +9 -12
- package/dist/lib/node-esm/index.mjs.map +1 -1
- package/dist/lib/node-esm/{intent-resolver-JT6EB47M.mjs → intent-resolver-K2UDBF2R.mjs} +25 -9
- package/dist/lib/node-esm/intent-resolver-K2UDBF2R.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-root-S2LW4FS7.mjs → react-root-6F7B3OVO.mjs} +6 -6
- package/dist/lib/node-esm/{react-surface-ZNNMO7QQ.mjs → react-surface-NP3Y6BNZ.mjs} +6 -6
- package/dist/lib/node-esm/{schema-defs-B74N3GQ5.mjs → schema-defs-QZJS6UXN.mjs} +2 -2
- package/dist/lib/node-esm/{schema-tools-YTJLA3NQ.mjs → schema-tools-2Y4D42PD.mjs} +9 -9
- package/dist/lib/node-esm/schema-tools-2Y4D42PD.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-MJVSCOI4.mjs → settings-Q4XDFSYD.mjs} +2 -2
- package/dist/lib/node-esm/{spaces-ready-XKG57SL5.mjs → spaces-ready-JHKPD4PH.mjs} +5 -5
- package/dist/lib/node-esm/{spaces-ready-XKG57SL5.mjs.map → spaces-ready-JHKPD4PH.mjs.map} +1 -1
- package/dist/lib/node-esm/{state-QUDYGEU6.mjs → state-4ATRHSKA.mjs} +2 -2
- package/dist/lib/node-esm/types/index.mjs +1 -7
- package/dist/types/src/capabilities/capabilities.d.ts +0 -8
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/schema-tools.d.ts +1 -1
- package/dist/types/src/capabilities/schema-tools.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +0 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +17 -1
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/package.json +48 -48
- package/src/capabilities/capabilities.ts +0 -9
- package/src/capabilities/intent-resolver.ts +13 -1
- package/src/capabilities/schema-tools.ts +8 -8
- package/src/capabilities/spaces-ready.ts +1 -1
- package/src/components/ObjectSettings/AdvancedObjectSettings.tsx +2 -2
- package/src/components/PopoverRenameObject.tsx +1 -1
- package/src/components/PopoverRenameSpace.tsx +1 -1
- package/src/index.ts +2 -2
- package/src/types/index.ts +0 -1
- package/src/types/types.ts +16 -1
- package/dist/lib/browser/chunk-43UQWMD3.mjs +0 -1731
- package/dist/lib/browser/chunk-CY35NLWL.mjs +0 -296
- package/dist/lib/browser/chunk-CY35NLWL.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-KRINV5QI.mjs.map +0 -7
- package/dist/lib/browser/schema-tools-MYC4LTQD.mjs.map +0 -7
- package/dist/lib/node/chunk-K6ZO4WDJ.cjs.map +0 -7
- package/dist/lib/node/chunk-MXBE2VET.cjs +0 -1735
- package/dist/lib/node/intent-resolver-MJVRY6YE.cjs.map +0 -7
- package/dist/lib/node/schema-tools-OE3MFYYH.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-CLRCW6PU.mjs +0 -297
- package/dist/lib/node-esm/chunk-CLRCW6PU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-FI3WV22Y.mjs +0 -1732
- package/dist/lib/node-esm/intent-resolver-JT6EB47M.mjs.map +0 -7
- package/dist/lib/node-esm/schema-tools-YTJLA3NQ.mjs.map +0 -7
- package/dist/types/src/types/thread.d.ts +0 -223
- package/dist/types/src/types/thread.d.ts.map +0 -1
- package/src/types/thread.ts +0 -30
- /package/dist/lib/browser/{app-graph-builder-7X3SIPCD.mjs.map → app-graph-builder-DCWUULKX.mjs.map} +0 -0
- /package/dist/lib/browser/{app-graph-serializer-VRU57AEZ.mjs.map → app-graph-serializer-MLU7XI2P.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-IQFFOAWD.mjs.map → chunk-N5QMRLKI.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-UBSVH2NQ.mjs.map → chunk-VEBKN45O.mjs.map} +0 -0
- /package/dist/lib/browser/{identity-created-ANRJHNMQ.mjs.map → identity-created-O63SIYOF.mjs.map} +0 -0
- /package/dist/lib/browser/{react-root-J3SP2HVW.mjs.map → react-root-PVKJE4EZ.mjs.map} +0 -0
- /package/dist/lib/browser/{react-surface-J7T2IMH4.mjs.map → react-surface-252P4NCK.mjs.map} +0 -0
- /package/dist/lib/browser/{schema-defs-OCBY7APN.mjs.map → schema-defs-JMN74RNK.mjs.map} +0 -0
- /package/dist/lib/browser/{settings-G24447B7.mjs.map → settings-2IN2WLUK.mjs.map} +0 -0
- /package/dist/lib/browser/{state-SI4B5GHC.mjs.map → state-6HOSHLIN.mjs.map} +0 -0
- /package/dist/lib/node/{app-graph-builder-C2ISDMSL.cjs.map → app-graph-builder-WC445X77.cjs.map} +0 -0
- /package/dist/lib/node/{app-graph-serializer-VLBCR3IX.cjs.map → app-graph-serializer-UPQOQVMJ.cjs.map} +0 -0
- /package/dist/lib/node/{chunk-SCATWJKX.cjs.map → chunk-COQYISES.cjs.map} +0 -0
- /package/dist/lib/node/{chunk-5YHUQJVB.cjs.map → chunk-DXL5TDFP.cjs.map} +0 -0
- /package/dist/lib/node/{identity-created-NIPYGVG3.cjs.map → identity-created-UXEAUGC7.cjs.map} +0 -0
- /package/dist/lib/node/{react-root-M4BZ6VXB.cjs.map → react-root-DDPDUMCG.cjs.map} +0 -0
- /package/dist/lib/node/{react-surface-RYKSYYKM.cjs.map → react-surface-JUIU37BX.cjs.map} +0 -0
- /package/dist/lib/node/{schema-defs-2HJLXSNK.cjs.map → schema-defs-XLFBG3XK.cjs.map} +0 -0
- /package/dist/lib/node/{settings-AFWO4AWK.cjs.map → settings-FOH7EB5C.cjs.map} +0 -0
- /package/dist/lib/node/{state-L2ZSDKLS.cjs.map → state-ZT3MTZXB.cjs.map} +0 -0
- /package/dist/lib/node-esm/{app-graph-builder-WVCQZ324.mjs.map → app-graph-builder-E7CCGPQJ.mjs.map} +0 -0
- /package/dist/lib/node-esm/{app-graph-serializer-GEUYYXKD.mjs.map → app-graph-serializer-UCMSLPIA.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-5NIBYPVF.mjs.map → chunk-OSPEGYX3.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-S2W6HS4A.mjs.map → chunk-XAZNQ3QN.mjs.map} +0 -0
- /package/dist/lib/node-esm/{identity-created-O5X2FFWU.mjs.map → identity-created-ZECO4NH3.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-root-S2LW4FS7.mjs.map → react-root-6F7B3OVO.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-surface-ZNNMO7QQ.mjs.map → react-surface-NP3Y6BNZ.mjs.map} +0 -0
- /package/dist/lib/node-esm/{schema-defs-B74N3GQ5.mjs.map → schema-defs-QZJS6UXN.mjs.map} +0 -0
- /package/dist/lib/node-esm/{settings-MJVSCOI4.mjs.map → settings-Q4XDFSYD.mjs.map} +0 -0
- /package/dist/lib/node-esm/{state-QUDYGEU6.mjs.map → state-4ATRHSKA.mjs.map} +0 -0
|
@@ -1,1732 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
useInputSurfaceLookup,
|
|
4
|
-
usePath
|
|
5
|
-
} from "./chunk-HNKAG5CX.mjs";
|
|
6
|
-
import {
|
|
7
|
-
SpaceCapabilities
|
|
8
|
-
} from "./chunk-PIYAWT5N.mjs";
|
|
9
|
-
import {
|
|
10
|
-
COMPOSER_SPACE_LOCK,
|
|
11
|
-
getSpaceDisplayName
|
|
12
|
-
} from "./chunk-S2W6HS4A.mjs";
|
|
13
|
-
import {
|
|
14
|
-
CollectionType,
|
|
15
|
-
SpaceAction,
|
|
16
|
-
SpaceForm
|
|
17
|
-
} from "./chunk-CLRCW6PU.mjs";
|
|
18
|
-
import {
|
|
19
|
-
SPACE_PLUGIN,
|
|
20
|
-
meta
|
|
21
|
-
} from "./chunk-MSWEFAPD.mjs";
|
|
22
|
-
|
|
23
|
-
// packages/plugins/plugin-space/src/components/AwaitingObject.tsx
|
|
24
|
-
import { CheckCircle, CircleDashed, CircleNotch } from "@phosphor-icons/react";
|
|
25
|
-
import React, { useCallback, useEffect, useState } from "react";
|
|
26
|
-
import { createIntent, LayoutAction, useIntentDispatcher, useLayout } from "@dxos/app-framework";
|
|
27
|
-
import { useClient } from "@dxos/react-client";
|
|
28
|
-
import { Filter, fullyQualifiedId, useQuery } from "@dxos/react-client/echo";
|
|
29
|
-
import { Button, Toast, useTranslation } from "@dxos/react-ui";
|
|
30
|
-
import { getSize, mx } from "@dxos/react-ui-theme";
|
|
31
|
-
var WAIT_FOR_OBJECT_TIMEOUT = 18e4;
|
|
32
|
-
var TOAST_TIMEOUT = 24e4;
|
|
33
|
-
var AwaitingObject = ({ id }) => {
|
|
34
|
-
const [open, setOpen] = useState(true);
|
|
35
|
-
const [waiting, setWaiting] = useState(true);
|
|
36
|
-
const [found, setFound] = useState(false);
|
|
37
|
-
const { t } = useTranslation(SPACE_PLUGIN);
|
|
38
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
39
|
-
const layout = useLayout();
|
|
40
|
-
const client = useClient();
|
|
41
|
-
const objects = useQuery(client.spaces, Filter.everything());
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (!id) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const timeout = setTimeout(() => {
|
|
47
|
-
setWaiting(false);
|
|
48
|
-
}, WAIT_FOR_OBJECT_TIMEOUT);
|
|
49
|
-
() => clearTimeout(timeout);
|
|
50
|
-
}, [
|
|
51
|
-
id
|
|
52
|
-
]);
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (objects.findIndex((object) => fullyQualifiedId(object) === id) > -1) {
|
|
55
|
-
setFound(true);
|
|
56
|
-
if (layout.active.includes(id)) {
|
|
57
|
-
setOpen(false);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}, [
|
|
61
|
-
id,
|
|
62
|
-
objects,
|
|
63
|
-
layout
|
|
64
|
-
]);
|
|
65
|
-
const handleClose = useCallback(async () => dispatch(createIntent(SpaceAction.WaitForObject, {
|
|
66
|
-
id: void 0
|
|
67
|
-
})), [
|
|
68
|
-
dispatch
|
|
69
|
-
]);
|
|
70
|
-
const handleNavigate = useCallback(() => {
|
|
71
|
-
void dispatch(createIntent(LayoutAction.Open, {
|
|
72
|
-
part: "main",
|
|
73
|
-
subject: [
|
|
74
|
-
id
|
|
75
|
-
]
|
|
76
|
-
}));
|
|
77
|
-
void handleClose();
|
|
78
|
-
}, [
|
|
79
|
-
id,
|
|
80
|
-
handleClose,
|
|
81
|
-
dispatch
|
|
82
|
-
]);
|
|
83
|
-
return /* @__PURE__ */ React.createElement(Toast.Root, {
|
|
84
|
-
open,
|
|
85
|
-
duration: TOAST_TIMEOUT,
|
|
86
|
-
onOpenChange: setOpen
|
|
87
|
-
}, /* @__PURE__ */ React.createElement(Toast.Body, null, /* @__PURE__ */ React.createElement(Toast.Title, {
|
|
88
|
-
classNames: "flex items-center gap-2"
|
|
89
|
-
}, found ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CheckCircle, {
|
|
90
|
-
className: getSize(5)
|
|
91
|
-
}), /* @__PURE__ */ React.createElement("span", null, t("found object label"))) : waiting ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CircleNotch, {
|
|
92
|
-
className: mx(getSize(5), "animate-spin")
|
|
93
|
-
}), /* @__PURE__ */ React.createElement("span", null, t("waiting for object label"))) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CircleDashed, {
|
|
94
|
-
className: getSize(5)
|
|
95
|
-
}), /* @__PURE__ */ React.createElement("span", null, t("object not found label")))), /* @__PURE__ */ React.createElement(Toast.Description, null, t(found ? "found object description" : waiting ? "waiting for object description" : "object not found description"))), /* @__PURE__ */ React.createElement(Toast.Actions, null, found ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Toast.Action, {
|
|
96
|
-
altText: t("go to object alt"),
|
|
97
|
-
asChild: true
|
|
98
|
-
}, /* @__PURE__ */ React.createElement(Button, {
|
|
99
|
-
variant: "primary",
|
|
100
|
-
onClick: handleNavigate
|
|
101
|
-
}, t("go to object label"))), /* @__PURE__ */ React.createElement(Toast.Close, {
|
|
102
|
-
asChild: true
|
|
103
|
-
}, /* @__PURE__ */ React.createElement(Button, {
|
|
104
|
-
onClick: handleClose
|
|
105
|
-
}, t("close label", {
|
|
106
|
-
ns: "appkit"
|
|
107
|
-
})))) : /* @__PURE__ */ React.createElement(Toast.Close, {
|
|
108
|
-
asChild: true
|
|
109
|
-
}, /* @__PURE__ */ React.createElement(Button, {
|
|
110
|
-
onClick: handleClose
|
|
111
|
-
}, t(waiting ? "close label" : "confirm label", {
|
|
112
|
-
ns: "appkit"
|
|
113
|
-
})))));
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
// packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectDialog.tsx
|
|
117
|
-
import { pipe } from "effect";
|
|
118
|
-
import React3, { useCallback as useCallback3, useRef } from "react";
|
|
119
|
-
import { Capabilities, chain, createIntent as createIntent2, LayoutAction as LayoutAction2, useCapabilities, useIntentDispatcher as useIntentDispatcher2, usePluginManager } from "@dxos/app-framework";
|
|
120
|
-
import { invariant as invariant2 } from "@dxos/invariant";
|
|
121
|
-
import { useClient as useClient2 } from "@dxos/react-client";
|
|
122
|
-
import { getSpace, isLiveObject, isSpace, useSpaces } from "@dxos/react-client/echo";
|
|
123
|
-
import { Button as Button2, Dialog, Icon as Icon2, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
124
|
-
|
|
125
|
-
// packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectPanel.tsx
|
|
126
|
-
import React2, { useCallback as useCallback2, useState as useState2 } from "react";
|
|
127
|
-
import { getTypeAnnotation } from "@dxos/echo-schema";
|
|
128
|
-
import { invariant } from "@dxos/invariant";
|
|
129
|
-
import { Icon, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
130
|
-
import { Form } from "@dxos/react-ui-form";
|
|
131
|
-
import { SearchList } from "@dxos/react-ui-searchlist";
|
|
132
|
-
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
133
|
-
import { isNonNullable } from "@dxos/util";
|
|
134
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectPanel.tsx";
|
|
135
|
-
var CreateObjectPanel = ({ classNames, forms, spaces, typename: initialTypename, target: initialTarget, name: initialName, defaultSpaceId, resolve, onCreateObject }) => {
|
|
136
|
-
const { t } = useTranslation2(SPACE_PLUGIN);
|
|
137
|
-
const [typename, setTypename] = useState2(initialTypename);
|
|
138
|
-
const [target, setTarget] = useState2(initialTarget);
|
|
139
|
-
const form = forms.find((form2) => getTypeAnnotation(form2.objectSchema)?.typename === typename);
|
|
140
|
-
const options = forms.map((form2) => getTypeAnnotation(form2.objectSchema)).filter(isNonNullable).sort((a, b) => {
|
|
141
|
-
const nameA = t("typename label", {
|
|
142
|
-
ns: a.typename,
|
|
143
|
-
defaultValue: a.typename
|
|
144
|
-
});
|
|
145
|
-
const nameB = t("typename label", {
|
|
146
|
-
ns: b.typename,
|
|
147
|
-
defaultValue: b.typename
|
|
148
|
-
});
|
|
149
|
-
return nameA.localeCompare(nameB);
|
|
150
|
-
});
|
|
151
|
-
const handleCreateObject = useCallback2(async (props) => {
|
|
152
|
-
if (!form || !target) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
await onCreateObject?.({
|
|
156
|
-
form,
|
|
157
|
-
target,
|
|
158
|
-
data: props
|
|
159
|
-
});
|
|
160
|
-
}, [
|
|
161
|
-
onCreateObject,
|
|
162
|
-
form,
|
|
163
|
-
target
|
|
164
|
-
]);
|
|
165
|
-
const handleSetTypename = useCallback2(async (typename2) => {
|
|
166
|
-
invariant(target, "target is required", {
|
|
167
|
-
F: __dxlog_file,
|
|
168
|
-
L: 72,
|
|
169
|
-
S: void 0,
|
|
170
|
-
A: [
|
|
171
|
-
"target",
|
|
172
|
-
"'target is required'"
|
|
173
|
-
]
|
|
174
|
-
});
|
|
175
|
-
const form2 = forms.find((form3) => getTypeAnnotation(form3.objectSchema)?.typename === typename2);
|
|
176
|
-
if (form2 && !form2.formSchema) {
|
|
177
|
-
await onCreateObject?.({
|
|
178
|
-
form: form2,
|
|
179
|
-
target
|
|
180
|
-
});
|
|
181
|
-
} else {
|
|
182
|
-
setTypename(typename2);
|
|
183
|
-
}
|
|
184
|
-
}, [
|
|
185
|
-
forms,
|
|
186
|
-
onCreateObject,
|
|
187
|
-
target
|
|
188
|
-
]);
|
|
189
|
-
const inputSurfaceLookup = useInputSurfaceLookup({
|
|
190
|
-
target
|
|
191
|
-
});
|
|
192
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
193
|
-
role: "form",
|
|
194
|
-
className: mx2("flex flex-col gap-2", classNames)
|
|
195
|
-
}, !form ? /* @__PURE__ */ React2.createElement(SelectSchema, {
|
|
196
|
-
options,
|
|
197
|
-
resolve,
|
|
198
|
-
onChange: handleSetTypename
|
|
199
|
-
}) : !target ? /* @__PURE__ */ React2.createElement(SelectSpace, {
|
|
200
|
-
spaces,
|
|
201
|
-
defaultSpaceId,
|
|
202
|
-
onChange: setTarget
|
|
203
|
-
}) : form.formSchema ? /* @__PURE__ */ React2.createElement(Form, {
|
|
204
|
-
classNames: "!p-0",
|
|
205
|
-
autoFocus: true,
|
|
206
|
-
values: {
|
|
207
|
-
name: initialName
|
|
208
|
-
},
|
|
209
|
-
schema: form.formSchema,
|
|
210
|
-
testId: "create-object-form",
|
|
211
|
-
onSave: handleCreateObject,
|
|
212
|
-
lookupComponent: inputSurfaceLookup
|
|
213
|
-
}) : void 0);
|
|
214
|
-
};
|
|
215
|
-
var SelectSpace = ({ spaces, defaultSpaceId, onChange }) => {
|
|
216
|
-
const { t } = useTranslation2(SPACE_PLUGIN);
|
|
217
|
-
return /* @__PURE__ */ React2.createElement(SearchList.Root, {
|
|
218
|
-
label: t("space input label"),
|
|
219
|
-
classNames: "flex flex-col grow overflow-hidden"
|
|
220
|
-
}, /* @__PURE__ */ React2.createElement(SearchList.Input, {
|
|
221
|
-
autoFocus: true,
|
|
222
|
-
"data-testid": "create-object-form.space-input",
|
|
223
|
-
placeholder: t("space input placeholder"),
|
|
224
|
-
classNames: "px-1 my-2"
|
|
225
|
-
}), /* @__PURE__ */ React2.createElement(SearchList.Content, {
|
|
226
|
-
classNames: "max-bs-[24rem] overflow-auto"
|
|
227
|
-
}, spaces.sort((a, b) => {
|
|
228
|
-
const aName = toLocalizedString(getSpaceDisplayName(a, {
|
|
229
|
-
personal: a.id === defaultSpaceId
|
|
230
|
-
}), t);
|
|
231
|
-
const bName = toLocalizedString(getSpaceDisplayName(b, {
|
|
232
|
-
personal: b.id === defaultSpaceId
|
|
233
|
-
}), t);
|
|
234
|
-
return aName.localeCompare(bName);
|
|
235
|
-
}).map((space) => /* @__PURE__ */ React2.createElement(SearchList.Item, {
|
|
236
|
-
key: space.id,
|
|
237
|
-
value: toLocalizedString(getSpaceDisplayName(space, {
|
|
238
|
-
personal: space.id === defaultSpaceId
|
|
239
|
-
}), t),
|
|
240
|
-
onSelect: () => onChange(space),
|
|
241
|
-
classNames: "flex items-center gap-2"
|
|
242
|
-
}, /* @__PURE__ */ React2.createElement("span", {
|
|
243
|
-
className: "grow truncate"
|
|
244
|
-
}, toLocalizedString(getSpaceDisplayName(space, {
|
|
245
|
-
personal: space.id === defaultSpaceId
|
|
246
|
-
}), t))))));
|
|
247
|
-
};
|
|
248
|
-
var SelectSchema = ({ options, resolve, onChange }) => {
|
|
249
|
-
const { t } = useTranslation2(SPACE_PLUGIN);
|
|
250
|
-
return /* @__PURE__ */ React2.createElement(SearchList.Root, {
|
|
251
|
-
label: t("schema input label"),
|
|
252
|
-
classNames: "flex flex-col grow overflow-hidden"
|
|
253
|
-
}, /* @__PURE__ */ React2.createElement(SearchList.Input, {
|
|
254
|
-
autoFocus: true,
|
|
255
|
-
"data-testid": "create-object-form.schema-input",
|
|
256
|
-
placeholder: t("schema input placeholder"),
|
|
257
|
-
classNames: "px-1 my-2"
|
|
258
|
-
}), /* @__PURE__ */ React2.createElement(SearchList.Content, {
|
|
259
|
-
classNames: "max-bs-[24rem] overflow-auto"
|
|
260
|
-
}, options.map((option) => /* @__PURE__ */ React2.createElement(SearchList.Item, {
|
|
261
|
-
key: option.typename,
|
|
262
|
-
value: t("typename label", {
|
|
263
|
-
ns: option.typename,
|
|
264
|
-
defaultValue: option.typename
|
|
265
|
-
}),
|
|
266
|
-
onSelect: () => onChange(option.typename),
|
|
267
|
-
classNames: "flex items-center gap-2"
|
|
268
|
-
}, /* @__PURE__ */ React2.createElement("span", {
|
|
269
|
-
className: "flex gap-2 items-center grow truncate"
|
|
270
|
-
}, /* @__PURE__ */ React2.createElement(Icon, {
|
|
271
|
-
icon: resolve?.(option.typename).icon ?? "ph--placeholder--regular",
|
|
272
|
-
size: 5
|
|
273
|
-
}), t("typename label", {
|
|
274
|
-
ns: option.typename,
|
|
275
|
-
defaultValue: option.typename
|
|
276
|
-
}))))));
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
// packages/plugins/plugin-space/src/capabilities/index.ts
|
|
280
|
-
import { lazy } from "@dxos/app-framework";
|
|
281
|
-
var AppGraphBuilder = lazy(() => import("./app-graph-builder-WVCQZ324.mjs"));
|
|
282
|
-
var AppGraphSerializer = lazy(() => import("./app-graph-serializer-GEUYYXKD.mjs"));
|
|
283
|
-
var IdentityCreated = lazy(() => import("./identity-created-O5X2FFWU.mjs"));
|
|
284
|
-
var IntentResolver = lazy(() => import("./intent-resolver-JT6EB47M.mjs"));
|
|
285
|
-
var ReactRoot = lazy(() => import("./react-root-S2LW4FS7.mjs"));
|
|
286
|
-
var ReactSurface = lazy(() => import("./react-surface-ZNNMO7QQ.mjs"));
|
|
287
|
-
var SchemaDefs = lazy(() => import("./schema-defs-B74N3GQ5.mjs"));
|
|
288
|
-
var SchemaTools = lazy(() => import("./schema-tools-YTJLA3NQ.mjs"));
|
|
289
|
-
var SpaceSettings = lazy(() => import("./settings-MJVSCOI4.mjs"));
|
|
290
|
-
var SpaceState = lazy(() => import("./state-QUDYGEU6.mjs"));
|
|
291
|
-
var SpacesReady = lazy(() => import("./spaces-ready-XKG57SL5.mjs"));
|
|
292
|
-
|
|
293
|
-
// packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectDialog.tsx
|
|
294
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectDialog.tsx";
|
|
295
|
-
var CREATE_OBJECT_DIALOG = `${SPACE_PLUGIN}/CreateObjectDialog`;
|
|
296
|
-
var CreateObjectDialog = ({ target, typename, name, shouldNavigate: _shouldNavigate }) => {
|
|
297
|
-
const closeRef = useRef(null);
|
|
298
|
-
const manager = usePluginManager();
|
|
299
|
-
const { t } = useTranslation3(SPACE_PLUGIN);
|
|
300
|
-
const client = useClient2();
|
|
301
|
-
const spaces = useSpaces();
|
|
302
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher2();
|
|
303
|
-
const forms = useCapabilities(SpaceCapabilities.ObjectForm);
|
|
304
|
-
const resolve = useCallback3((typename2) => manager.context.getCapabilities(Capabilities.Metadata).find(({ id }) => id === typename2)?.metadata ?? {}, [
|
|
305
|
-
manager
|
|
306
|
-
]);
|
|
307
|
-
const handleCreateObject = useCallback3(async ({ form, target: target2, data = {} }) => {
|
|
308
|
-
if (!target2) {
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
closeRef.current?.click();
|
|
312
|
-
const space = isSpace(target2) ? target2 : getSpace(target2);
|
|
313
|
-
invariant2(space, "Missing space", {
|
|
314
|
-
F: __dxlog_file2,
|
|
315
|
-
L: 72,
|
|
316
|
-
S: void 0,
|
|
317
|
-
A: [
|
|
318
|
-
"space",
|
|
319
|
-
"'Missing space'"
|
|
320
|
-
]
|
|
321
|
-
});
|
|
322
|
-
const result = await dispatch(form.getIntent(data, {
|
|
323
|
-
space
|
|
324
|
-
}));
|
|
325
|
-
const object = result.data?.object;
|
|
326
|
-
if (isLiveObject(object)) {
|
|
327
|
-
const addObjectIntent = createIntent2(SpaceAction.AddObject, {
|
|
328
|
-
target: target2,
|
|
329
|
-
object,
|
|
330
|
-
hidden: form.hidden
|
|
331
|
-
});
|
|
332
|
-
const shouldNavigate = _shouldNavigate ?? (() => true);
|
|
333
|
-
if (shouldNavigate(object)) {
|
|
334
|
-
await dispatch(pipe(addObjectIntent, chain(LayoutAction2.Open, {
|
|
335
|
-
part: "main"
|
|
336
|
-
})));
|
|
337
|
-
} else {
|
|
338
|
-
await dispatch(addObjectIntent);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}, [
|
|
342
|
-
dispatch,
|
|
343
|
-
resolve
|
|
344
|
-
]);
|
|
345
|
-
return (
|
|
346
|
-
// TODO(wittjosiah): The tablist dialog pattern is copied from @dxos/plugin-manager.
|
|
347
|
-
// Consider factoring it out to the tabs package.
|
|
348
|
-
/* @__PURE__ */ React3.createElement(Dialog.Content, {
|
|
349
|
-
classNames: "p-0 bs-content max-bs-full md:max-is-[40rem] overflow-hidden"
|
|
350
|
-
}, /* @__PURE__ */ React3.createElement("div", {
|
|
351
|
-
role: "none",
|
|
352
|
-
className: "flex justify-between pbs-2 pis-2 pie-2 @md:pbs-4 @md:pis-4 @md:pie-4"
|
|
353
|
-
}, /* @__PURE__ */ React3.createElement(Dialog.Title, null, t("create object dialog title")), /* @__PURE__ */ React3.createElement(Dialog.Close, {
|
|
354
|
-
asChild: true
|
|
355
|
-
}, /* @__PURE__ */ React3.createElement(Button2, {
|
|
356
|
-
ref: closeRef,
|
|
357
|
-
density: "fine",
|
|
358
|
-
variant: "ghost",
|
|
359
|
-
autoFocus: true
|
|
360
|
-
}, /* @__PURE__ */ React3.createElement(Icon2, {
|
|
361
|
-
icon: "ph--x--regular",
|
|
362
|
-
size: 4
|
|
363
|
-
})))), /* @__PURE__ */ React3.createElement(CreateObjectPanel, {
|
|
364
|
-
classNames: "p-4",
|
|
365
|
-
forms,
|
|
366
|
-
spaces,
|
|
367
|
-
target,
|
|
368
|
-
typename,
|
|
369
|
-
name,
|
|
370
|
-
defaultSpaceId: client.spaces.default.id,
|
|
371
|
-
resolve,
|
|
372
|
-
onCreateObject: handleCreateObject
|
|
373
|
-
}))
|
|
374
|
-
);
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
// packages/plugins/plugin-space/src/components/CreateDialog/CreateSpaceDialog.tsx
|
|
378
|
-
import { Effect } from "effect";
|
|
379
|
-
import React4, { useCallback as useCallback4, useRef as useRef2 } from "react";
|
|
380
|
-
import { createIntent as createIntent3, LayoutAction as LayoutAction3, useIntentDispatcher as useIntentDispatcher3 } from "@dxos/app-framework";
|
|
381
|
-
import { Button as Button3, Dialog as Dialog2, Icon as Icon3, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
382
|
-
import { Form as Form2 } from "@dxos/react-ui-form";
|
|
383
|
-
var CREATE_SPACE_DIALOG = `${SPACE_PLUGIN}/CreateSpaceDialog`;
|
|
384
|
-
var initialValues = {
|
|
385
|
-
edgeReplication: true
|
|
386
|
-
};
|
|
387
|
-
var CreateSpaceDialog = () => {
|
|
388
|
-
const closeRef = useRef2(null);
|
|
389
|
-
const { t } = useTranslation4(SPACE_PLUGIN);
|
|
390
|
-
const { dispatch } = useIntentDispatcher3();
|
|
391
|
-
const inputSurfaceLookup = useInputSurfaceLookup();
|
|
392
|
-
const handleCreateSpace = useCallback4(async (data) => {
|
|
393
|
-
const program = Effect.gen(function* () {
|
|
394
|
-
const { space } = yield* dispatch(createIntent3(SpaceAction.Create, data));
|
|
395
|
-
yield* dispatch(createIntent3(LayoutAction3.SwitchWorkspace, {
|
|
396
|
-
part: "workspace",
|
|
397
|
-
subject: space.id
|
|
398
|
-
}));
|
|
399
|
-
yield* dispatch(createIntent3(SpaceAction.OpenCreateObject, {
|
|
400
|
-
target: space
|
|
401
|
-
}));
|
|
402
|
-
});
|
|
403
|
-
await Effect.runPromise(program);
|
|
404
|
-
}, [
|
|
405
|
-
dispatch
|
|
406
|
-
]);
|
|
407
|
-
return (
|
|
408
|
-
// TODO(wittjosiah): The tablist dialog pattern is copied from @dxos/plugin-manager.
|
|
409
|
-
// Consider factoring it out to the tabs package.
|
|
410
|
-
/* @__PURE__ */ React4.createElement(Dialog2.Content, {
|
|
411
|
-
classNames: "p-0 bs-content min-bs-[16rem] max-bs-full md:max-is-[32rem] overflow-hidden"
|
|
412
|
-
}, /* @__PURE__ */ React4.createElement("div", {
|
|
413
|
-
role: "none",
|
|
414
|
-
className: "flex justify-between pbs-2 pis-2 pie-2 @md:pbs-4 @md:pis-4 @md:pie-4"
|
|
415
|
-
}, /* @__PURE__ */ React4.createElement(Dialog2.Title, null, t("create space dialog title")), /* @__PURE__ */ React4.createElement(Dialog2.Close, {
|
|
416
|
-
asChild: true
|
|
417
|
-
}, /* @__PURE__ */ React4.createElement(Button3, {
|
|
418
|
-
ref: closeRef,
|
|
419
|
-
density: "fine",
|
|
420
|
-
variant: "ghost",
|
|
421
|
-
autoFocus: true
|
|
422
|
-
}, /* @__PURE__ */ React4.createElement(Icon3, {
|
|
423
|
-
icon: "ph--x--regular",
|
|
424
|
-
size: 4
|
|
425
|
-
})))), /* @__PURE__ */ React4.createElement("div", {
|
|
426
|
-
className: "p-4"
|
|
427
|
-
}, /* @__PURE__ */ React4.createElement(Form2, {
|
|
428
|
-
testId: "create-space-form",
|
|
429
|
-
classNames: "!p-0",
|
|
430
|
-
autoFocus: true,
|
|
431
|
-
values: initialValues,
|
|
432
|
-
schema: SpaceForm,
|
|
433
|
-
lookupComponent: inputSurfaceLookup,
|
|
434
|
-
onSave: handleCreateSpace
|
|
435
|
-
})))
|
|
436
|
-
);
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
// packages/plugins/plugin-space/src/components/CollectionMain.tsx
|
|
440
|
-
import React5 from "react";
|
|
441
|
-
import { useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
442
|
-
import { baseSurface, descriptionMessage, mx as mx3 } from "@dxos/react-ui-theme";
|
|
443
|
-
var CollectionMain = ({ collection }) => {
|
|
444
|
-
const { t } = useTranslation5(SPACE_PLUGIN);
|
|
445
|
-
return /* @__PURE__ */ React5.createElement("div", {
|
|
446
|
-
role: "none",
|
|
447
|
-
className: mx3(baseSurface, "min-bs-screen is-full flex items-center justify-center p-8"),
|
|
448
|
-
"data-testid": "composer.firstRunMessage"
|
|
449
|
-
}, /* @__PURE__ */ React5.createElement("p", {
|
|
450
|
-
role: "alert",
|
|
451
|
-
className: mx3(descriptionMessage, "rounded-lg p-8 font-normal text-lg max-is-[24rem] break-words")
|
|
452
|
-
}, collection.name ?? t("unnamed collection label")));
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
// packages/plugins/plugin-space/src/components/CollectionSection.tsx
|
|
456
|
-
import React6 from "react";
|
|
457
|
-
import { useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
458
|
-
var CollectionSection = ({ collection }) => {
|
|
459
|
-
const { t } = useTranslation6(SPACE_PLUGIN);
|
|
460
|
-
return /* @__PURE__ */ React6.createElement("div", {
|
|
461
|
-
className: "min-bs-[3.5rem] grid grid-rows-subgrid grid-cols-subgrid items-center"
|
|
462
|
-
}, /* @__PURE__ */ React6.createElement("span", {
|
|
463
|
-
className: "truncate"
|
|
464
|
-
}, collection.name ?? t("unnamed collection label")));
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
// packages/plugins/plugin-space/src/components/JoinDialog.tsx
|
|
468
|
-
import React7, { useCallback as useCallback5 } from "react";
|
|
469
|
-
import { createIntent as createIntent4, LayoutAction as LayoutAction4, useAppGraph, useIntentDispatcher as useIntentDispatcher4 } from "@dxos/app-framework";
|
|
470
|
-
import { Trigger } from "@dxos/async";
|
|
471
|
-
import { ObservabilityAction } from "@dxos/plugin-observability/types";
|
|
472
|
-
import { useClient as useClient3 } from "@dxos/react-client";
|
|
473
|
-
import { Dialog as Dialog3, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
474
|
-
import { JoinPanel } from "@dxos/shell/react";
|
|
475
|
-
var JOIN_DIALOG = `${SPACE_PLUGIN}/JoinDialog`;
|
|
476
|
-
var JoinDialog = ({ navigableCollections, onDone, ...props }) => {
|
|
477
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher4();
|
|
478
|
-
const client = useClient3();
|
|
479
|
-
const { graph } = useAppGraph();
|
|
480
|
-
const { t } = useTranslation7(SPACE_PLUGIN);
|
|
481
|
-
const handleDone = useCallback5(async (result) => {
|
|
482
|
-
const spaceKey = result?.spaceKey;
|
|
483
|
-
if (!spaceKey) {
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
await Promise.all([
|
|
487
|
-
dispatch(createIntent4(LayoutAction4.AddToast, {
|
|
488
|
-
part: "toast",
|
|
489
|
-
subject: {
|
|
490
|
-
id: `${SPACE_PLUGIN}/join-success`,
|
|
491
|
-
duration: 5e3,
|
|
492
|
-
title: [
|
|
493
|
-
"join success label",
|
|
494
|
-
{
|
|
495
|
-
ns: SPACE_PLUGIN
|
|
496
|
-
}
|
|
497
|
-
],
|
|
498
|
-
closeLabel: [
|
|
499
|
-
"dismiss label",
|
|
500
|
-
{
|
|
501
|
-
ns: SPACE_PLUGIN
|
|
502
|
-
}
|
|
503
|
-
]
|
|
504
|
-
}
|
|
505
|
-
})),
|
|
506
|
-
dispatch(createIntent4(LayoutAction4.UpdateDialog, {
|
|
507
|
-
part: "dialog",
|
|
508
|
-
options: {
|
|
509
|
-
state: false
|
|
510
|
-
}
|
|
511
|
-
}))
|
|
512
|
-
]);
|
|
513
|
-
let space = client.spaces.get(spaceKey);
|
|
514
|
-
if (!space) {
|
|
515
|
-
const trigger = new Trigger();
|
|
516
|
-
client.spaces.subscribe(() => {
|
|
517
|
-
const space2 = client.spaces.get(spaceKey);
|
|
518
|
-
if (space2) {
|
|
519
|
-
trigger.wake(space2);
|
|
520
|
-
}
|
|
521
|
-
});
|
|
522
|
-
space = await trigger.wait();
|
|
523
|
-
}
|
|
524
|
-
await dispatch(createIntent4(LayoutAction4.SwitchWorkspace, {
|
|
525
|
-
part: "workspace",
|
|
526
|
-
subject: space.id
|
|
527
|
-
}));
|
|
528
|
-
const target = result?.target || (navigableCollections ? space?.id : void 0);
|
|
529
|
-
if (target) {
|
|
530
|
-
await graph.waitForPath({
|
|
531
|
-
target
|
|
532
|
-
}).catch(() => {
|
|
533
|
-
});
|
|
534
|
-
await Promise.all([
|
|
535
|
-
dispatch(createIntent4(LayoutAction4.Open, {
|
|
536
|
-
part: "main",
|
|
537
|
-
subject: [
|
|
538
|
-
target
|
|
539
|
-
]
|
|
540
|
-
})),
|
|
541
|
-
dispatch(createIntent4(LayoutAction4.Expose, {
|
|
542
|
-
part: "navigation",
|
|
543
|
-
subject: target
|
|
544
|
-
}))
|
|
545
|
-
]);
|
|
546
|
-
}
|
|
547
|
-
await onDone?.(result);
|
|
548
|
-
if (space) {
|
|
549
|
-
await dispatch(createIntent4(ObservabilityAction.SendEvent, {
|
|
550
|
-
name: "space.join",
|
|
551
|
-
properties: {
|
|
552
|
-
spaceId: space.id
|
|
553
|
-
}
|
|
554
|
-
}));
|
|
555
|
-
}
|
|
556
|
-
}, [
|
|
557
|
-
dispatch,
|
|
558
|
-
client,
|
|
559
|
-
graph
|
|
560
|
-
]);
|
|
561
|
-
return /* @__PURE__ */ React7.createElement(Dialog3.Content, null, /* @__PURE__ */ React7.createElement(Dialog3.Title, {
|
|
562
|
-
classNames: "sr-only"
|
|
563
|
-
}, t("join space label", {
|
|
564
|
-
ns: "os"
|
|
565
|
-
})), /* @__PURE__ */ React7.createElement(JoinPanel, {
|
|
566
|
-
...props,
|
|
567
|
-
exitActionParent: /* @__PURE__ */ React7.createElement(Dialog3.Close, {
|
|
568
|
-
asChild: true
|
|
569
|
-
}),
|
|
570
|
-
doneActionParent: /* @__PURE__ */ React7.createElement(Dialog3.Close, {
|
|
571
|
-
asChild: true
|
|
572
|
-
}),
|
|
573
|
-
onDone: handleDone
|
|
574
|
-
}));
|
|
575
|
-
};
|
|
576
|
-
|
|
577
|
-
// packages/plugins/plugin-space/src/components/MembersContainer.tsx
|
|
578
|
-
import { Check, X } from "@phosphor-icons/react";
|
|
579
|
-
import React8, { useCallback as useCallback6, useMemo, useState as useState3 } from "react";
|
|
580
|
-
import { QR } from "react-qr-rounded";
|
|
581
|
-
import { createIntent as createIntent5, useIntentDispatcher as useIntentDispatcher5 } from "@dxos/app-framework";
|
|
582
|
-
import { log } from "@dxos/log";
|
|
583
|
-
import { useConfig } from "@dxos/react-client";
|
|
584
|
-
import { fullyQualifiedId as fullyQualifiedId2, useSpaceInvitations } from "@dxos/react-client/echo";
|
|
585
|
-
import { Invitation, InvitationEncoder } from "@dxos/react-client/invitations";
|
|
586
|
-
import { Button as Button4, Clipboard, Icon as Icon4, Input, useId, useTranslation as useTranslation8 } from "@dxos/react-ui";
|
|
587
|
-
import { ControlPage, ControlSection, ControlFrame, ControlFrameItem, ControlItemInput } from "@dxos/react-ui-form";
|
|
588
|
-
import { StackItem } from "@dxos/react-ui-stack";
|
|
589
|
-
import { getSize as getSize2, mx as mx4 } from "@dxos/react-ui-theme";
|
|
590
|
-
import { AuthCode, BifurcatedAction, Centered, Emoji, InvitationList, SpaceMemberList, Viewport } from "@dxos/shell/react";
|
|
591
|
-
import { hexToEmoji } from "@dxos/util";
|
|
592
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/MembersContainer.tsx";
|
|
593
|
-
var activeActionKey = "dxos:react-shell/space-manager/active-action";
|
|
594
|
-
var handleInvitationEvent = (invitation, subscription) => {
|
|
595
|
-
const invitationCode = InvitationEncoder.encode(invitation);
|
|
596
|
-
if (invitation.state === Invitation.State.CONNECTING) {
|
|
597
|
-
log.info(JSON.stringify({
|
|
598
|
-
invitationCode,
|
|
599
|
-
authCode: invitation.authCode
|
|
600
|
-
}), void 0, {
|
|
601
|
-
F: __dxlog_file3,
|
|
602
|
-
L: 40,
|
|
603
|
-
S: void 0,
|
|
604
|
-
C: (f, a) => f(...a)
|
|
605
|
-
});
|
|
606
|
-
subscription.unsubscribe();
|
|
607
|
-
}
|
|
608
|
-
};
|
|
609
|
-
var MembersContainer = ({ space, createInvitationUrl }) => {
|
|
610
|
-
const { t } = useTranslation8(SPACE_PLUGIN);
|
|
611
|
-
const config = useConfig();
|
|
612
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher5();
|
|
613
|
-
const invitations = useSpaceInvitations(space.key);
|
|
614
|
-
const visibleInvitations = invitations?.filter((invitation) => ![
|
|
615
|
-
Invitation.State.CANCELLED
|
|
616
|
-
].includes(invitation.get().state));
|
|
617
|
-
const [activeAction, setInternalActiveAction] = useState3(localStorage.getItem(activeActionKey) ?? "inviteMany");
|
|
618
|
-
const setActiveAction = (nextAction) => {
|
|
619
|
-
setInternalActiveAction(nextAction);
|
|
620
|
-
localStorage.setItem(activeActionKey, nextAction);
|
|
621
|
-
};
|
|
622
|
-
const target = space.properties[CollectionType.typename]?.target?.objects[0]?.target;
|
|
623
|
-
const locked = space.properties[COMPOSER_SPACE_LOCK];
|
|
624
|
-
const handleChangeLocked = useCallback6(() => {
|
|
625
|
-
space.properties[COMPOSER_SPACE_LOCK] = !locked;
|
|
626
|
-
}, [
|
|
627
|
-
locked,
|
|
628
|
-
space
|
|
629
|
-
]);
|
|
630
|
-
const inviteActions = useMemo(() => ({
|
|
631
|
-
inviteOne: {
|
|
632
|
-
label: t("invite one label", {
|
|
633
|
-
ns: "os"
|
|
634
|
-
}),
|
|
635
|
-
description: t("invite one description", {
|
|
636
|
-
ns: "os"
|
|
637
|
-
}),
|
|
638
|
-
icon: () => /* @__PURE__ */ React8.createElement(Icon4, {
|
|
639
|
-
icon: "ph--user-plus--regular",
|
|
640
|
-
size: 5
|
|
641
|
-
}),
|
|
642
|
-
testId: "membersContainer.inviteOne",
|
|
643
|
-
onClick: async () => {
|
|
644
|
-
const { data: invitation } = await dispatch(createIntent5(SpaceAction.Share, {
|
|
645
|
-
space,
|
|
646
|
-
type: Invitation.Type.INTERACTIVE,
|
|
647
|
-
authMethod: Invitation.AuthMethod.SHARED_SECRET,
|
|
648
|
-
multiUse: false,
|
|
649
|
-
target: target && fullyQualifiedId2(target)
|
|
650
|
-
}));
|
|
651
|
-
if (invitation && config.values.runtime?.app?.env?.DX_ENVIRONMENT !== "production") {
|
|
652
|
-
const subscription = invitation.subscribe((invitation2) => handleInvitationEvent(invitation2, subscription));
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
},
|
|
656
|
-
inviteMany: {
|
|
657
|
-
label: t("invite many label", {
|
|
658
|
-
ns: "os"
|
|
659
|
-
}),
|
|
660
|
-
description: t("invite many description", {
|
|
661
|
-
ns: "os"
|
|
662
|
-
}),
|
|
663
|
-
icon: () => /* @__PURE__ */ React8.createElement(Icon4, {
|
|
664
|
-
icon: "ph--users-three--regular",
|
|
665
|
-
size: 5
|
|
666
|
-
}),
|
|
667
|
-
testId: "membersContainer.inviteMany",
|
|
668
|
-
onClick: async () => {
|
|
669
|
-
const { data: invitation } = await dispatch(createIntent5(SpaceAction.Share, {
|
|
670
|
-
space,
|
|
671
|
-
type: Invitation.Type.DELEGATED,
|
|
672
|
-
authMethod: Invitation.AuthMethod.KNOWN_PUBLIC_KEY,
|
|
673
|
-
multiUse: true,
|
|
674
|
-
target: target && fullyQualifiedId2(target)
|
|
675
|
-
}));
|
|
676
|
-
if (invitation && config.values.runtime?.app?.env?.DX_ENVIRONMENT !== "production") {
|
|
677
|
-
const subscription = invitation.subscribe((invitation2) => handleInvitationEvent(invitation2, subscription));
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
}), [
|
|
682
|
-
t,
|
|
683
|
-
space,
|
|
684
|
-
target
|
|
685
|
-
]);
|
|
686
|
-
const [selectedInvitation, setSelectedInvitation] = useState3(null);
|
|
687
|
-
const handleSend = (event) => {
|
|
688
|
-
setSelectedInvitation(event.invitation);
|
|
689
|
-
};
|
|
690
|
-
const handleBack = () => {
|
|
691
|
-
setSelectedInvitation(null);
|
|
692
|
-
};
|
|
693
|
-
return /* @__PURE__ */ React8.createElement(Clipboard.Provider, null, /* @__PURE__ */ React8.createElement(StackItem.Content, {
|
|
694
|
-
classNames: "block overflow-y-auto"
|
|
695
|
-
}, /* @__PURE__ */ React8.createElement(ControlPage, null, /* @__PURE__ */ React8.createElement(ControlSection, {
|
|
696
|
-
title: t("members verbose label"),
|
|
697
|
-
description: t("members description")
|
|
698
|
-
}, /* @__PURE__ */ React8.createElement(ControlFrame, null, /* @__PURE__ */ React8.createElement(ControlFrameItem, {
|
|
699
|
-
title: t("members label")
|
|
700
|
-
}, /* @__PURE__ */ React8.createElement(SpaceMemberList, {
|
|
701
|
-
spaceKey: space.key,
|
|
702
|
-
includeSelf: true
|
|
703
|
-
})), locked && /* @__PURE__ */ React8.createElement(ControlFrameItem, {
|
|
704
|
-
title: t("invitations label")
|
|
705
|
-
}, /* @__PURE__ */ React8.createElement("p", {
|
|
706
|
-
className: "text-description mbe-2"
|
|
707
|
-
}, t("locked space description"))), !locked && /* @__PURE__ */ React8.createElement(ControlFrameItem, {
|
|
708
|
-
title: t("invitations label")
|
|
709
|
-
}, selectedInvitation && /* @__PURE__ */ React8.createElement(InvitationSection, {
|
|
710
|
-
...selectedInvitation,
|
|
711
|
-
onBack: handleBack
|
|
712
|
-
}), !selectedInvitation && /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement("p", {
|
|
713
|
-
className: "text-description mbe-2"
|
|
714
|
-
}, t("space invitation description")), /* @__PURE__ */ React8.createElement(InvitationList, {
|
|
715
|
-
className: "mb-2",
|
|
716
|
-
send: handleSend,
|
|
717
|
-
invitations: visibleInvitations ?? [],
|
|
718
|
-
onClickRemove: (invitation) => invitation.cancel(),
|
|
719
|
-
createInvitationUrl
|
|
720
|
-
}), /* @__PURE__ */ React8.createElement(BifurcatedAction, {
|
|
721
|
-
actions: inviteActions,
|
|
722
|
-
activeAction,
|
|
723
|
-
onChangeActiveAction: setActiveAction,
|
|
724
|
-
"data-testid": "membersContainer.createInvitation"
|
|
725
|
-
})))), /* @__PURE__ */ React8.createElement("div", {
|
|
726
|
-
className: "justify-center gap-4 p-0 mbs-4 container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content]"
|
|
727
|
-
}, /* @__PURE__ */ React8.createElement(ControlItemInput, {
|
|
728
|
-
title: t("space locked label"),
|
|
729
|
-
description: t("space locked description")
|
|
730
|
-
}, /* @__PURE__ */ React8.createElement(Input.Switch, {
|
|
731
|
-
checked: locked,
|
|
732
|
-
onCheckedChange: handleChangeLocked,
|
|
733
|
-
classNames: "justify-self-end"
|
|
734
|
-
})))))));
|
|
735
|
-
};
|
|
736
|
-
var InvitationSection = ({ state = Invitation.State.INIT, authCode, invitationId = "never", url = "never", onBack }) => {
|
|
737
|
-
const activeView = state < 0 ? "init" : state >= Invitation.State.CANCELLED ? "complete" : state >= Invitation.State.READY_FOR_AUTHENTICATION && authCode ? "auth-code" : "qr-code";
|
|
738
|
-
return /* @__PURE__ */ React8.createElement(Viewport.Root, {
|
|
739
|
-
activeView
|
|
740
|
-
}, /* @__PURE__ */ React8.createElement(Viewport.Views, null, /* @__PURE__ */ React8.createElement(Viewport.View, {
|
|
741
|
-
id: "init"
|
|
742
|
-
}), /* @__PURE__ */ React8.createElement(Viewport.View, {
|
|
743
|
-
id: "complete"
|
|
744
|
-
}, /* @__PURE__ */ React8.createElement(InvitationComplete, {
|
|
745
|
-
statusValue: state
|
|
746
|
-
})), /* @__PURE__ */ React8.createElement(Viewport.View, {
|
|
747
|
-
id: "auth-code"
|
|
748
|
-
}, /* @__PURE__ */ React8.createElement(InvitationAuthCode, {
|
|
749
|
-
id: invitationId,
|
|
750
|
-
code: authCode ?? "never",
|
|
751
|
-
onCancel: onBack
|
|
752
|
-
})), /* @__PURE__ */ React8.createElement(Viewport.View, {
|
|
753
|
-
id: "qr-code"
|
|
754
|
-
}, /* @__PURE__ */ React8.createElement(InvitationQR, {
|
|
755
|
-
id: invitationId,
|
|
756
|
-
url,
|
|
757
|
-
onCancel: onBack
|
|
758
|
-
}))));
|
|
759
|
-
};
|
|
760
|
-
var InvitationQR = ({ id, url, onCancel }) => {
|
|
761
|
-
const { t } = useTranslation8("os");
|
|
762
|
-
const qrLabel = useId("members-container__qr-code");
|
|
763
|
-
const emoji = hexToEmoji(id);
|
|
764
|
-
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement("p", {
|
|
765
|
-
className: "text-description"
|
|
766
|
-
}, t("qr code description", {
|
|
767
|
-
ns: SPACE_PLUGIN
|
|
768
|
-
})), /* @__PURE__ */ React8.createElement("div", {
|
|
769
|
-
role: "group",
|
|
770
|
-
className: "grid grid-cols-[1fr_min-content] mlb-2 gap-2"
|
|
771
|
-
}, /* @__PURE__ */ React8.createElement("div", {
|
|
772
|
-
role: "none",
|
|
773
|
-
className: "is-full aspect-square relative text-description"
|
|
774
|
-
}, /* @__PURE__ */ React8.createElement(QR, {
|
|
775
|
-
rounding: 100,
|
|
776
|
-
backgroundColor: "transparent",
|
|
777
|
-
color: "currentColor",
|
|
778
|
-
"aria-labelledby": qrLabel,
|
|
779
|
-
errorCorrectionLevel: "Q",
|
|
780
|
-
cutout: true
|
|
781
|
-
}, url ?? "never"), /* @__PURE__ */ React8.createElement(Centered, null, /* @__PURE__ */ React8.createElement(Emoji, {
|
|
782
|
-
text: emoji
|
|
783
|
-
}))), /* @__PURE__ */ React8.createElement("span", {
|
|
784
|
-
id: qrLabel,
|
|
785
|
-
className: "sr-only"
|
|
786
|
-
}, t("qr label")), /* @__PURE__ */ React8.createElement(Clipboard.Button, {
|
|
787
|
-
value: url ?? "never"
|
|
788
|
-
})), /* @__PURE__ */ React8.createElement(Button4, {
|
|
789
|
-
variant: "ghost",
|
|
790
|
-
onClick: onCancel
|
|
791
|
-
}, t("cancel label")));
|
|
792
|
-
};
|
|
793
|
-
var InvitationAuthCode = ({ id, code, onCancel }) => {
|
|
794
|
-
const { t } = useTranslation8("os");
|
|
795
|
-
const emoji = hexToEmoji(id);
|
|
796
|
-
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement("p", {
|
|
797
|
-
className: "text-description"
|
|
798
|
-
}, t("auth other device emoji message")), emoji && /* @__PURE__ */ React8.createElement(Emoji, {
|
|
799
|
-
text: emoji,
|
|
800
|
-
className: "mli-auto mlb-2 text-center"
|
|
801
|
-
}), /* @__PURE__ */ React8.createElement("p", {
|
|
802
|
-
className: "text-description"
|
|
803
|
-
}, t("auth code message")), /* @__PURE__ */ React8.createElement(AuthCode, {
|
|
804
|
-
code,
|
|
805
|
-
large: true,
|
|
806
|
-
classNames: "mli-auto mlb-2 text-center grow"
|
|
807
|
-
}), /* @__PURE__ */ React8.createElement(Button4, {
|
|
808
|
-
variant: "ghost",
|
|
809
|
-
onClick: onCancel
|
|
810
|
-
}, t("cancel label")));
|
|
811
|
-
};
|
|
812
|
-
var InvitationComplete = ({ statusValue }) => {
|
|
813
|
-
return statusValue > 0 ? /* @__PURE__ */ React8.createElement(Check, {
|
|
814
|
-
className: mx4("m-1.5", getSize2(6))
|
|
815
|
-
}) : /* @__PURE__ */ React8.createElement(X, {
|
|
816
|
-
className: mx4("m-1.5", getSize2(6))
|
|
817
|
-
});
|
|
818
|
-
};
|
|
819
|
-
|
|
820
|
-
// packages/plugins/plugin-space/src/components/MenuFooter.tsx
|
|
821
|
-
import { Planet } from "@phosphor-icons/react";
|
|
822
|
-
import React9 from "react";
|
|
823
|
-
import { getSpace as getSpace2 } from "@dxos/client/echo";
|
|
824
|
-
import { useClient as useClient4 } from "@dxos/react-client";
|
|
825
|
-
import { DropdownMenu, toLocalizedString as toLocalizedString2, useTranslation as useTranslation9 } from "@dxos/react-ui";
|
|
826
|
-
var MenuFooter = ({ object }) => {
|
|
827
|
-
const { t } = useTranslation9(SPACE_PLUGIN);
|
|
828
|
-
const client = useClient4();
|
|
829
|
-
const space = getSpace2(object);
|
|
830
|
-
const spaceName = space ? getSpaceDisplayName(space, {
|
|
831
|
-
personal: client.spaces.default === space
|
|
832
|
-
}) : "";
|
|
833
|
-
return space ? /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(DropdownMenu.Separator, null), /* @__PURE__ */ React9.createElement(DropdownMenu.GroupLabel, null, t("menu footer label")), /* @__PURE__ */ React9.createElement("dl", {
|
|
834
|
-
className: "pis-2 mbe-2 text-xs grid grid-cols-[max-content_1fr] gap-2"
|
|
835
|
-
}, /* @__PURE__ */ React9.createElement("dt", {
|
|
836
|
-
className: "uppercase text-[.75em] tracking-wide font-medium mbs-px self-start"
|
|
837
|
-
}, t("location label")), /* @__PURE__ */ React9.createElement("dd", {
|
|
838
|
-
className: "line-clamp-3"
|
|
839
|
-
}, /* @__PURE__ */ React9.createElement(Planet, {
|
|
840
|
-
className: "inline-block mie-1"
|
|
841
|
-
}), toLocalizedString2(spaceName, t)))) : null;
|
|
842
|
-
};
|
|
843
|
-
|
|
844
|
-
// packages/plugins/plugin-space/src/components/ObjectSettings/ObjectSettingsContainer.tsx
|
|
845
|
-
import React11, { useMemo as useMemo2 } from "react";
|
|
846
|
-
import { Surface } from "@dxos/app-framework";
|
|
847
|
-
import { Clipboard as Clipboard2 } from "@dxos/react-ui";
|
|
848
|
-
import { StackItem as StackItem2 } from "@dxos/react-ui-stack";
|
|
849
|
-
|
|
850
|
-
// packages/plugins/plugin-space/src/components/ObjectSettings/BaseObjectSettings.tsx
|
|
851
|
-
import React10, { useRef as useRef3 } from "react";
|
|
852
|
-
import { Input as Input2, useTranslation as useTranslation10 } from "@dxos/react-ui";
|
|
853
|
-
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
854
|
-
var BaseObjectSettings = ({ classNames, children, object }) => {
|
|
855
|
-
const { t } = useTranslation10(meta.id);
|
|
856
|
-
const inputRef = useRef3(null);
|
|
857
|
-
return /* @__PURE__ */ React10.createElement("form", {
|
|
858
|
-
className: mx5("flex flex-col p-2 gap-2", classNames)
|
|
859
|
-
}, /* @__PURE__ */ React10.createElement(Input2.Root, null, /* @__PURE__ */ React10.createElement(Input2.Label, null, t("name label")), /* @__PURE__ */ React10.createElement(Input2.TextInput, {
|
|
860
|
-
ref: inputRef,
|
|
861
|
-
placeholder: t("name placeholder"),
|
|
862
|
-
value: object.name ?? "",
|
|
863
|
-
onChange: (event) => {
|
|
864
|
-
object.name = event.target.value;
|
|
865
|
-
},
|
|
866
|
-
onKeyDown: (event) => {
|
|
867
|
-
if (event.key === "Enter") {
|
|
868
|
-
inputRef.current?.blur();
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
})), children);
|
|
872
|
-
};
|
|
873
|
-
|
|
874
|
-
// packages/plugins/plugin-space/src/components/ObjectSettings/ObjectSettingsContainer.tsx
|
|
875
|
-
var ObjectSettingsContainer = ({ object, role }) => {
|
|
876
|
-
const data = useMemo2(() => ({
|
|
877
|
-
subject: object
|
|
878
|
-
}), [
|
|
879
|
-
object
|
|
880
|
-
]);
|
|
881
|
-
return /* @__PURE__ */ React11.createElement(Clipboard2.Provider, null, /* @__PURE__ */ React11.createElement(StackItem2.Content, {
|
|
882
|
-
toolbar: false,
|
|
883
|
-
role
|
|
884
|
-
}, /* @__PURE__ */ React11.createElement("div", {
|
|
885
|
-
className: "flex flex-col overflow-y-auto divide-y divide-separator"
|
|
886
|
-
}, /* @__PURE__ */ React11.createElement(BaseObjectSettings, {
|
|
887
|
-
object
|
|
888
|
-
}, /* @__PURE__ */ React11.createElement(Surface, {
|
|
889
|
-
role: "base-object-settings",
|
|
890
|
-
data
|
|
891
|
-
})), /* @__PURE__ */ React11.createElement(Surface, {
|
|
892
|
-
role: "object-settings",
|
|
893
|
-
data
|
|
894
|
-
}))));
|
|
895
|
-
};
|
|
896
|
-
|
|
897
|
-
// packages/plugins/plugin-space/src/components/PersistenceStatus.tsx
|
|
898
|
-
import { ArrowsCounterClockwise, CheckCircle as CheckCircle2, Warning } from "@phosphor-icons/react";
|
|
899
|
-
import React12, { useEffect as useEffect2, useState as useState4 } from "react";
|
|
900
|
-
import { debounce } from "@dxos/async";
|
|
901
|
-
import { Tooltip, useTranslation as useTranslation11 } from "@dxos/react-ui";
|
|
902
|
-
import { getSize as getSize3, mx as mx6, staticPlaceholderText, warningText } from "@dxos/react-ui-theme";
|
|
903
|
-
var Status;
|
|
904
|
-
(function(Status2) {
|
|
905
|
-
Status2[Status2["PERSISTED_LOCALLY"] = 0] = "PERSISTED_LOCALLY";
|
|
906
|
-
Status2[Status2["PENDING"] = 1] = "PENDING";
|
|
907
|
-
Status2[Status2["ERROR"] = 2] = "ERROR";
|
|
908
|
-
})(Status || (Status = {}));
|
|
909
|
-
var PersistenceStatus = ({ db }) => {
|
|
910
|
-
const { t } = useTranslation11(SPACE_PLUGIN);
|
|
911
|
-
const [displayMessage, setDisplayMessage] = useState4(false);
|
|
912
|
-
const [status, naturalSetStatus] = useState4(0);
|
|
913
|
-
const [prevStatus, setPrevStatus] = useState4(0);
|
|
914
|
-
const _setStatus = debounce(naturalSetStatus, 500);
|
|
915
|
-
useEffect2(() => {
|
|
916
|
-
setPrevStatus(status);
|
|
917
|
-
if (prevStatus !== status && status === 0) {
|
|
918
|
-
setDisplayMessage(true);
|
|
919
|
-
const timeout = setTimeout(() => setDisplayMessage(false), 5e3);
|
|
920
|
-
return () => clearTimeout(timeout);
|
|
921
|
-
}
|
|
922
|
-
}, [
|
|
923
|
-
status
|
|
924
|
-
]);
|
|
925
|
-
switch (status) {
|
|
926
|
-
case 2:
|
|
927
|
-
return /* @__PURE__ */ React12.createElement("div", {
|
|
928
|
-
className: "flex items-center"
|
|
929
|
-
}, /* @__PURE__ */ React12.createElement(Warning, {
|
|
930
|
-
className: mx6(getSize3(4), "me-1")
|
|
931
|
-
}), /* @__PURE__ */ React12.createElement("span", {
|
|
932
|
-
className: mx6("text-sm", warningText)
|
|
933
|
-
}, t("persistence error label")));
|
|
934
|
-
case 1:
|
|
935
|
-
return /* @__PURE__ */ React12.createElement("div", {
|
|
936
|
-
className: "flex items-center"
|
|
937
|
-
}, /* @__PURE__ */ React12.createElement(ArrowsCounterClockwise, {
|
|
938
|
-
className: mx6(getSize3(4), "me-1")
|
|
939
|
-
}), /* @__PURE__ */ React12.createElement("span", {
|
|
940
|
-
className: mx6("text-sm", staticPlaceholderText)
|
|
941
|
-
}, t("persistence pending label")));
|
|
942
|
-
case 0:
|
|
943
|
-
default:
|
|
944
|
-
return /* @__PURE__ */ React12.createElement(Tooltip.Trigger, {
|
|
945
|
-
delayDuration: 400,
|
|
946
|
-
role: "status",
|
|
947
|
-
content: t("persisted locally message"),
|
|
948
|
-
className: "flex items-center"
|
|
949
|
-
}, /* @__PURE__ */ React12.createElement(CheckCircle2, {
|
|
950
|
-
className: mx6(getSize3(4), "me-1")
|
|
951
|
-
}), displayMessage && /* @__PURE__ */ React12.createElement("span", {
|
|
952
|
-
className: mx6("text-sm", staticPlaceholderText)
|
|
953
|
-
}, t("persisted locally label")));
|
|
954
|
-
}
|
|
955
|
-
};
|
|
956
|
-
|
|
957
|
-
// packages/plugins/plugin-space/src/components/PopoverRenameObject.tsx
|
|
958
|
-
import React13, { useCallback as useCallback7, useRef as useRef4, useState as useState5 } from "react";
|
|
959
|
-
import { createIntent as createIntent6, LayoutAction as LayoutAction5, useIntentDispatcher as useIntentDispatcher6 } from "@dxos/app-framework";
|
|
960
|
-
import { log as log2 } from "@dxos/log";
|
|
961
|
-
import { Button as Button5, Input as Input3, useTranslation as useTranslation12 } from "@dxos/react-ui";
|
|
962
|
-
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/PopoverRenameObject.tsx";
|
|
963
|
-
var POPOVER_RENAME_OBJECT = `${SPACE_PLUGIN}/PopoverRenameObject`;
|
|
964
|
-
var PopoverRenameObject = ({ object: obj }) => {
|
|
965
|
-
const { t } = useTranslation12(SPACE_PLUGIN);
|
|
966
|
-
const doneButton = useRef4(null);
|
|
967
|
-
const object = obj;
|
|
968
|
-
const [name, setName] = useState5(object.name || object.title || "");
|
|
969
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher6();
|
|
970
|
-
const handleDone = useCallback7(() => {
|
|
971
|
-
try {
|
|
972
|
-
object.name = name;
|
|
973
|
-
} catch {
|
|
974
|
-
try {
|
|
975
|
-
object.title = name;
|
|
976
|
-
} catch (err) {
|
|
977
|
-
log2.error("Failed to rename object", {
|
|
978
|
-
err
|
|
979
|
-
}, {
|
|
980
|
-
F: __dxlog_file4,
|
|
981
|
-
L: 32,
|
|
982
|
-
S: void 0,
|
|
983
|
-
C: (f, a) => f(...a)
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
void dispatch(createIntent6(LayoutAction5.UpdatePopover, {
|
|
988
|
-
part: "popover",
|
|
989
|
-
options: {
|
|
990
|
-
variant: "react",
|
|
991
|
-
anchorId: "",
|
|
992
|
-
state: false
|
|
993
|
-
}
|
|
994
|
-
}));
|
|
995
|
-
}, [
|
|
996
|
-
object,
|
|
997
|
-
name
|
|
998
|
-
]);
|
|
999
|
-
return /* @__PURE__ */ React13.createElement("div", {
|
|
1000
|
-
role: "none",
|
|
1001
|
-
className: "p-1 flex gap-2"
|
|
1002
|
-
}, /* @__PURE__ */ React13.createElement("div", {
|
|
1003
|
-
role: "none",
|
|
1004
|
-
className: "flex-1"
|
|
1005
|
-
}, /* @__PURE__ */ React13.createElement(Input3.Root, null, /* @__PURE__ */ React13.createElement(Input3.Label, {
|
|
1006
|
-
srOnly: true
|
|
1007
|
-
}, t("object name label")), /* @__PURE__ */ React13.createElement(Input3.TextInput, {
|
|
1008
|
-
placeholder: t("object placeholder"),
|
|
1009
|
-
value: name,
|
|
1010
|
-
"data-testid": "spacePlugin.renameObject.input",
|
|
1011
|
-
onChange: ({ target: { value } }) => setName(value),
|
|
1012
|
-
onKeyDown: ({ key }) => key === "Enter" && doneButton.current?.click()
|
|
1013
|
-
}))), /* @__PURE__ */ React13.createElement(Button5, {
|
|
1014
|
-
ref: doneButton,
|
|
1015
|
-
classNames: "self-stretch",
|
|
1016
|
-
onClick: handleDone
|
|
1017
|
-
}, t("done label", {
|
|
1018
|
-
ns: "os"
|
|
1019
|
-
})));
|
|
1020
|
-
};
|
|
1021
|
-
|
|
1022
|
-
// packages/plugins/plugin-space/src/components/PopoverRenameSpace.tsx
|
|
1023
|
-
import React14, { useCallback as useCallback8, useRef as useRef5, useState as useState6 } from "react";
|
|
1024
|
-
import { createIntent as createIntent7, LayoutAction as LayoutAction6, useIntentDispatcher as useIntentDispatcher7 } from "@dxos/app-framework";
|
|
1025
|
-
import { Button as Button6, Input as Input4, Popover, useTranslation as useTranslation13 } from "@dxos/react-ui";
|
|
1026
|
-
var POPOVER_RENAME_SPACE = `${SPACE_PLUGIN}/PopoverRenameSpace`;
|
|
1027
|
-
var PopoverRenameSpace = ({ space }) => {
|
|
1028
|
-
const { t } = useTranslation13(SPACE_PLUGIN);
|
|
1029
|
-
const doneButton = useRef5(null);
|
|
1030
|
-
const [name, setName] = useState6(space.properties.name ?? "");
|
|
1031
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher7();
|
|
1032
|
-
const handleDone = useCallback8(() => {
|
|
1033
|
-
space.properties.name = name;
|
|
1034
|
-
void dispatch(createIntent7(LayoutAction6.UpdatePopover, {
|
|
1035
|
-
part: "popover",
|
|
1036
|
-
options: {
|
|
1037
|
-
variant: "react",
|
|
1038
|
-
anchorId: "",
|
|
1039
|
-
state: false
|
|
1040
|
-
}
|
|
1041
|
-
}));
|
|
1042
|
-
}, [
|
|
1043
|
-
space,
|
|
1044
|
-
name
|
|
1045
|
-
]);
|
|
1046
|
-
return /* @__PURE__ */ React14.createElement("div", {
|
|
1047
|
-
role: "none",
|
|
1048
|
-
className: "p-1 flex gap-2"
|
|
1049
|
-
}, /* @__PURE__ */ React14.createElement("div", {
|
|
1050
|
-
role: "none",
|
|
1051
|
-
className: "flex-1"
|
|
1052
|
-
}, /* @__PURE__ */ React14.createElement(Input4.Root, null, /* @__PURE__ */ React14.createElement(Input4.Label, {
|
|
1053
|
-
srOnly: true
|
|
1054
|
-
}, t("space name label")), /* @__PURE__ */ React14.createElement(Input4.TextInput, {
|
|
1055
|
-
defaultValue: space.properties.name ?? "",
|
|
1056
|
-
placeholder: t("unnamed space label"),
|
|
1057
|
-
onChange: ({ target: { value } }) => setName(value),
|
|
1058
|
-
// TODO(wittjosiah): Ideally this should access the popover context to close the popover.
|
|
1059
|
-
// Currently this is not possible because Radix does not expose the popover context.
|
|
1060
|
-
onKeyDown: ({ key }) => key === "Enter" && doneButton.current?.click()
|
|
1061
|
-
}))), /* @__PURE__ */ React14.createElement(Popover.Close, {
|
|
1062
|
-
asChild: true
|
|
1063
|
-
}, /* @__PURE__ */ React14.createElement(Button6, {
|
|
1064
|
-
ref: doneButton,
|
|
1065
|
-
classNames: "self-stretch",
|
|
1066
|
-
onClick: handleDone
|
|
1067
|
-
}, t("done label", {
|
|
1068
|
-
ns: "os"
|
|
1069
|
-
}))));
|
|
1070
|
-
};
|
|
1071
|
-
|
|
1072
|
-
// packages/plugins/plugin-space/src/components/SchemaContainer.tsx
|
|
1073
|
-
import React15, { useState as useState7, useEffect as useEffect3 } from "react";
|
|
1074
|
-
import { useTranslation as useTranslation14 } from "@dxos/react-ui";
|
|
1075
|
-
import { controlItemClasses, ControlPage as ControlPage2, ControlSection as ControlSection2 } from "@dxos/react-ui-form";
|
|
1076
|
-
import { StackItem as StackItem3 } from "@dxos/react-ui-stack";
|
|
1077
|
-
var useQuerySpaceSchemas = (space) => {
|
|
1078
|
-
const [schemas, setSchemas] = useState7([]);
|
|
1079
|
-
useEffect3(() => {
|
|
1080
|
-
const query = space.db.schemaRegistry.query();
|
|
1081
|
-
const initialResults = query.runSync();
|
|
1082
|
-
setSchemas(initialResults);
|
|
1083
|
-
const unsubscribe = query.subscribe(() => setSchemas(query.results));
|
|
1084
|
-
return () => unsubscribe();
|
|
1085
|
-
}, [
|
|
1086
|
-
space
|
|
1087
|
-
]);
|
|
1088
|
-
return schemas;
|
|
1089
|
-
};
|
|
1090
|
-
var SchemaContainer = ({ space }) => {
|
|
1091
|
-
const { t } = useTranslation14(SPACE_PLUGIN);
|
|
1092
|
-
const schemas = useQuerySpaceSchemas(space);
|
|
1093
|
-
return /* @__PURE__ */ React15.createElement(StackItem3.Content, {
|
|
1094
|
-
classNames: "block overflow-y-auto"
|
|
1095
|
-
}, /* @__PURE__ */ React15.createElement(ControlPage2, null, /* @__PURE__ */ React15.createElement(ControlSection2, {
|
|
1096
|
-
title: t("schema verbose label"),
|
|
1097
|
-
description: t("schema description")
|
|
1098
|
-
}, /* @__PURE__ */ React15.createElement("div", {
|
|
1099
|
-
role: "none",
|
|
1100
|
-
className: controlItemClasses
|
|
1101
|
-
}, schemas.length === 0 && /* @__PURE__ */ React15.createElement("div", {
|
|
1102
|
-
className: "text-center plb-4"
|
|
1103
|
-
}, t("no schemas found message")), schemas.map((schema) => /* @__PURE__ */ React15.createElement("div", {
|
|
1104
|
-
key: schema.id
|
|
1105
|
-
}, /* @__PURE__ */ React15.createElement("div", null, schema.typename)))))));
|
|
1106
|
-
};
|
|
1107
|
-
|
|
1108
|
-
// packages/plugins/plugin-space/src/components/SpacePresence.tsx
|
|
1109
|
-
import { Option } from "effect";
|
|
1110
|
-
import React16, { forwardRef, useCallback as useCallback9, useEffect as useEffect4, useState as useState8 } from "react";
|
|
1111
|
-
import { useAppGraph as useAppGraph2, useCapability } from "@dxos/app-framework";
|
|
1112
|
-
import { generateName } from "@dxos/display-name";
|
|
1113
|
-
import { PublicKey, useClient as useClient5 } from "@dxos/react-client";
|
|
1114
|
-
import { getSpace as getSpace3, useMembers, fullyQualifiedId as fullyQualifiedId3 } from "@dxos/react-client/echo";
|
|
1115
|
-
import { useIdentity } from "@dxos/react-client/halo";
|
|
1116
|
-
import { Avatar, Tooltip as Tooltip2, Popover as Popover2, useTranslation as useTranslation15, List, ListItem, useDefaultValue } from "@dxos/react-ui";
|
|
1117
|
-
import { AttentionGlyph, useAttended, useAttention } from "@dxos/react-ui-attention";
|
|
1118
|
-
import { ComplexMap, keyToFallback } from "@dxos/util";
|
|
1119
|
-
var REFRESH_INTERVAL = 5e3;
|
|
1120
|
-
var ACTIVITY_DURATION = 3e4;
|
|
1121
|
-
var noViewers = new ComplexMap(PublicKey.hash);
|
|
1122
|
-
var getName = (identity) => identity.profile?.displayName ?? generateName(identity.identityKey.toHex());
|
|
1123
|
-
var SpacePresence = ({ object, spaceKey }) => {
|
|
1124
|
-
const spaceState = useCapability(SpaceCapabilities.MutableState);
|
|
1125
|
-
const client = useClient5();
|
|
1126
|
-
const identity = useIdentity();
|
|
1127
|
-
const space = spaceKey ? client.spaces.get(spaceKey) : getSpace3(object);
|
|
1128
|
-
const spaceMembers = useMembers(space?.key);
|
|
1129
|
-
const [_moment, setMoment] = useState8(Date.now());
|
|
1130
|
-
useEffect4(() => {
|
|
1131
|
-
const interval = setInterval(() => setMoment(Date.now()), REFRESH_INTERVAL);
|
|
1132
|
-
return () => clearInterval(interval);
|
|
1133
|
-
}, []);
|
|
1134
|
-
const memberOnline = useCallback9((member) => member.presence === 1, []);
|
|
1135
|
-
const memberIsNotSelf = useCallback9((member) => !identity?.identityKey.equals(member.identity.identityKey), [
|
|
1136
|
-
identity?.identityKey
|
|
1137
|
-
]);
|
|
1138
|
-
if (!identity || !spaceState || !space) {
|
|
1139
|
-
return null;
|
|
1140
|
-
}
|
|
1141
|
-
const currentObjectViewers = spaceState.viewersByObject[fullyQualifiedId3(object)] ?? noViewers;
|
|
1142
|
-
const membersForObject = spaceMembers.filter((member) => memberOnline(member) && memberIsNotSelf(member)).filter((member) => currentObjectViewers.has(member.identity.identityKey)).map((member) => {
|
|
1143
|
-
const objectView = currentObjectViewers.get(member.identity.identityKey);
|
|
1144
|
-
const lastSeen = objectView?.lastSeen ?? -Infinity;
|
|
1145
|
-
const currentlyAttended = objectView?.currentlyAttended ?? false;
|
|
1146
|
-
return {
|
|
1147
|
-
...member,
|
|
1148
|
-
currentlyAttended,
|
|
1149
|
-
lastSeen
|
|
1150
|
-
};
|
|
1151
|
-
}).toSorted((a, b) => a.lastSeen - b.lastSeen);
|
|
1152
|
-
return /* @__PURE__ */ React16.createElement(FullPresence, {
|
|
1153
|
-
members: membersForObject
|
|
1154
|
-
});
|
|
1155
|
-
};
|
|
1156
|
-
var FullPresence = (props) => {
|
|
1157
|
-
const { size = 9, onMemberClick } = props;
|
|
1158
|
-
const members = useDefaultValue(props.members, () => []);
|
|
1159
|
-
if (members.length === 0) {
|
|
1160
|
-
return null;
|
|
1161
|
-
}
|
|
1162
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
1163
|
-
className: "dx-avatar-group",
|
|
1164
|
-
"data-testid": "spacePlugin.presence"
|
|
1165
|
-
}, members.slice(0, 3).map((member, i) => /* @__PURE__ */ React16.createElement(Tooltip2.Trigger, {
|
|
1166
|
-
key: member.identity.identityKey.toHex(),
|
|
1167
|
-
side: "bottom",
|
|
1168
|
-
content: getName(member.identity),
|
|
1169
|
-
className: "grid focus:outline-none"
|
|
1170
|
-
}, /* @__PURE__ */ React16.createElement(PresenceAvatar, {
|
|
1171
|
-
identity: member.identity,
|
|
1172
|
-
match: member.currentlyAttended,
|
|
1173
|
-
index: members.length - i,
|
|
1174
|
-
onClick: () => onMemberClick?.(member),
|
|
1175
|
-
size
|
|
1176
|
-
}))), members.length > 3 && /* @__PURE__ */ React16.createElement(Popover2.Root, null, /* @__PURE__ */ React16.createElement(Popover2.Trigger, {
|
|
1177
|
-
className: "grid focus:outline-none"
|
|
1178
|
-
}, /* @__PURE__ */ React16.createElement(Avatar.Root, null, /* @__PURE__ */ React16.createElement(Avatar.Content, {
|
|
1179
|
-
status: "inactive",
|
|
1180
|
-
style: {
|
|
1181
|
-
zIndex: members.length - 4
|
|
1182
|
-
},
|
|
1183
|
-
fallback: `+${members.length - 3}`,
|
|
1184
|
-
size
|
|
1185
|
-
}))), /* @__PURE__ */ React16.createElement(Popover2.Portal, null, /* @__PURE__ */ React16.createElement(Popover2.Content, {
|
|
1186
|
-
side: "bottom"
|
|
1187
|
-
}, /* @__PURE__ */ React16.createElement(Popover2.Arrow, null), /* @__PURE__ */ React16.createElement(List, {
|
|
1188
|
-
classNames: "max-h-56 overflow-y-auto"
|
|
1189
|
-
}, members.map((member) => /* @__PURE__ */ React16.createElement(ListItem.Root, {
|
|
1190
|
-
key: member.identity.identityKey.toHex(),
|
|
1191
|
-
classNames: "flex gap-2 items-center cursor-pointer mbe-2",
|
|
1192
|
-
onClick: () => onMemberClick?.(member),
|
|
1193
|
-
"data-testid": "identity-list-item"
|
|
1194
|
-
}, /* @__PURE__ */ React16.createElement(PresenceAvatar, {
|
|
1195
|
-
identity: member.identity,
|
|
1196
|
-
size,
|
|
1197
|
-
showName: true,
|
|
1198
|
-
match: member.currentlyAttended
|
|
1199
|
-
}))))))));
|
|
1200
|
-
};
|
|
1201
|
-
var PresenceAvatar = /* @__PURE__ */ forwardRef(({ identity, showName, match, index, onClick, size }, forwardedRef) => {
|
|
1202
|
-
const status = match ? "current" : "active";
|
|
1203
|
-
const fallbackValue = keyToFallback(identity.identityKey);
|
|
1204
|
-
return /* @__PURE__ */ React16.createElement(Avatar.Root, null, /* @__PURE__ */ React16.createElement(Avatar.Content, {
|
|
1205
|
-
status,
|
|
1206
|
-
hue: identity.profile?.data?.hue || fallbackValue.hue,
|
|
1207
|
-
"data-testid": "spacePlugin.presence.member",
|
|
1208
|
-
"data-status": status,
|
|
1209
|
-
size,
|
|
1210
|
-
...index ? {
|
|
1211
|
-
style: {
|
|
1212
|
-
zIndex: index
|
|
1213
|
-
}
|
|
1214
|
-
} : {},
|
|
1215
|
-
onClick,
|
|
1216
|
-
fallback: identity.profile?.data?.emoji || fallbackValue.emoji,
|
|
1217
|
-
ref: forwardedRef
|
|
1218
|
-
}), /* @__PURE__ */ React16.createElement(Avatar.Label, {
|
|
1219
|
-
classNames: showName ? "text-sm truncate pli-2" : "sr-only"
|
|
1220
|
-
}, getName(identity)));
|
|
1221
|
-
});
|
|
1222
|
-
var SmallPresenceLive = ({ id, open, viewers }) => {
|
|
1223
|
-
const { hasAttention, isAncestor, isRelated } = useAttention(id);
|
|
1224
|
-
const isAttended = hasAttention || isAncestor || isRelated;
|
|
1225
|
-
const { graph } = useAppGraph2();
|
|
1226
|
-
const attended = useAttended();
|
|
1227
|
-
const startOfAttention = attended.at(-1);
|
|
1228
|
-
const path = usePath(graph, startOfAttention);
|
|
1229
|
-
const containsAttended = !open && !isAttended && id && Option.isSome(path) ? path.value.includes(id) : false;
|
|
1230
|
-
const getActiveViewers = (viewers2) => {
|
|
1231
|
-
const moment = Date.now();
|
|
1232
|
-
return Array.from(viewers2.values()).filter((viewer) => moment - viewer.lastSeen < ACTIVITY_DURATION);
|
|
1233
|
-
};
|
|
1234
|
-
const [activeViewers, setActiveViewers] = useState8(viewers ? getActiveViewers(viewers) : []);
|
|
1235
|
-
useEffect4(() => {
|
|
1236
|
-
if (viewers) {
|
|
1237
|
-
setActiveViewers(getActiveViewers(viewers));
|
|
1238
|
-
const interval = setInterval(() => {
|
|
1239
|
-
setActiveViewers(getActiveViewers(viewers));
|
|
1240
|
-
}, REFRESH_INTERVAL);
|
|
1241
|
-
return () => clearInterval(interval);
|
|
1242
|
-
}
|
|
1243
|
-
}, [
|
|
1244
|
-
viewers
|
|
1245
|
-
]);
|
|
1246
|
-
return /* @__PURE__ */ React16.createElement(SmallPresence, {
|
|
1247
|
-
count: activeViewers.length,
|
|
1248
|
-
attended: isAttended,
|
|
1249
|
-
containsAttended
|
|
1250
|
-
});
|
|
1251
|
-
};
|
|
1252
|
-
var SmallPresence = ({ count = 0, attended, containsAttended }) => {
|
|
1253
|
-
const { t } = useTranslation15(SPACE_PLUGIN);
|
|
1254
|
-
return /* @__PURE__ */ React16.createElement(Tooltip2.Trigger, {
|
|
1255
|
-
asChild: true,
|
|
1256
|
-
content: t("presence label", {
|
|
1257
|
-
count
|
|
1258
|
-
}),
|
|
1259
|
-
side: "bottom"
|
|
1260
|
-
}, /* @__PURE__ */ React16.createElement(AttentionGlyph, {
|
|
1261
|
-
attended,
|
|
1262
|
-
containsAttended,
|
|
1263
|
-
presence: count > 1 ? "many" : count === 1 ? "one" : "none",
|
|
1264
|
-
classNames: "self-center mie-1"
|
|
1265
|
-
}));
|
|
1266
|
-
};
|
|
1267
|
-
|
|
1268
|
-
// packages/plugins/plugin-space/src/components/SpacePluginSettings.tsx
|
|
1269
|
-
import React17 from "react";
|
|
1270
|
-
import { createIntent as createIntent8, useIntentDispatcher as useIntentDispatcher8 } from "@dxos/app-framework";
|
|
1271
|
-
import { useClient as useClient6 } from "@dxos/react-client";
|
|
1272
|
-
import { useSpaces as useSpaces2 } from "@dxos/react-client/echo";
|
|
1273
|
-
import { Input as Input5, toLocalizedString as toLocalizedString3, useTranslation as useTranslation16, List as List2, ListItem as ListItem2, Button as Button7 } from "@dxos/react-ui";
|
|
1274
|
-
import { DeprecatedFormContainer, DeprecatedFormInput } from "@dxos/react-ui-form";
|
|
1275
|
-
var SpacePluginSettings = ({ settings }) => {
|
|
1276
|
-
const { t } = useTranslation16(SPACE_PLUGIN);
|
|
1277
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher8();
|
|
1278
|
-
const client = useClient6();
|
|
1279
|
-
const spaces = useSpaces2({
|
|
1280
|
-
all: settings.showHidden
|
|
1281
|
-
});
|
|
1282
|
-
return /* @__PURE__ */ React17.createElement(DeprecatedFormContainer, null, /* @__PURE__ */ React17.createElement(DeprecatedFormInput, {
|
|
1283
|
-
label: t("show hidden spaces label")
|
|
1284
|
-
}, /* @__PURE__ */ React17.createElement(Input5.Switch, {
|
|
1285
|
-
checked: settings.showHidden,
|
|
1286
|
-
onCheckedChange: (checked) => settings.showHidden = !!checked
|
|
1287
|
-
})), /* @__PURE__ */ React17.createElement("div", {
|
|
1288
|
-
role: "none"
|
|
1289
|
-
}, /* @__PURE__ */ React17.createElement("h2", {
|
|
1290
|
-
className: "text-xl my-4"
|
|
1291
|
-
}, "Space Settings"), /* @__PURE__ */ React17.createElement(List2, {
|
|
1292
|
-
classNames: "max-w-md mx-auto"
|
|
1293
|
-
}, spaces.map((space) => /* @__PURE__ */ React17.createElement(ListItem2.Root, {
|
|
1294
|
-
key: space.id
|
|
1295
|
-
}, /* @__PURE__ */ React17.createElement(ListItem2.Heading, {
|
|
1296
|
-
classNames: "flex flex-col grow truncate mbe-2"
|
|
1297
|
-
}, toLocalizedString3(getSpaceDisplayName(space, {
|
|
1298
|
-
personal: space === client.spaces.default
|
|
1299
|
-
}), t)), /* @__PURE__ */ React17.createElement(ListItem2.Endcap, null, /* @__PURE__ */ React17.createElement(Button7, {
|
|
1300
|
-
onClick: () => dispatch(createIntent8(SpaceAction.OpenSettings, {
|
|
1301
|
-
space
|
|
1302
|
-
}))
|
|
1303
|
-
}, t("open space settings label"))))))));
|
|
1304
|
-
};
|
|
1305
|
-
|
|
1306
|
-
// packages/plugins/plugin-space/src/components/SpaceSettings/SpaceSettingsContainer.tsx
|
|
1307
|
-
import { pipe as pipe2, Schema } from "effect";
|
|
1308
|
-
import React18, { useCallback as useCallback10, useMemo as useMemo3, useState as useState9 } from "react";
|
|
1309
|
-
import { chain as chain2, createIntent as createIntent9, LayoutAction as LayoutAction7, useIntentDispatcher as useIntentDispatcher9 } from "@dxos/app-framework";
|
|
1310
|
-
import { log as log3 } from "@dxos/log";
|
|
1311
|
-
import { EdgeReplicationSetting } from "@dxos/protocols/proto/dxos/echo/metadata";
|
|
1312
|
-
import { useClient as useClient7 } from "@dxos/react-client";
|
|
1313
|
-
import { SpaceState as SpaceState2 } from "@dxos/react-client/echo";
|
|
1314
|
-
import { Button as Button8, Input as Input6, useMulticastObservable, useTranslation as useTranslation17 } from "@dxos/react-ui";
|
|
1315
|
-
import { Form as Form3, ControlItem, ControlItemInput as ControlItemInput2, ControlSection as ControlSection3, ControlPage as ControlPage3 } from "@dxos/react-ui-form";
|
|
1316
|
-
import { HuePicker, IconPicker } from "@dxos/react-ui-pickers";
|
|
1317
|
-
import { StackItem as StackItem4 } from "@dxos/react-ui-stack";
|
|
1318
|
-
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/SpaceSettings/SpaceSettingsContainer.tsx";
|
|
1319
|
-
var FormSchema = SpaceForm.pipe(Schema.extend(Schema.Struct({
|
|
1320
|
-
archived: Schema.Boolean.annotations({
|
|
1321
|
-
title: "Archive space"
|
|
1322
|
-
})
|
|
1323
|
-
})));
|
|
1324
|
-
var SpaceSettingsContainer = ({ space }) => {
|
|
1325
|
-
const { t } = useTranslation17(SPACE_PLUGIN);
|
|
1326
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher9();
|
|
1327
|
-
const client = useClient7();
|
|
1328
|
-
const archived = useMulticastObservable(space.state) === SpaceState2.SPACE_INACTIVE;
|
|
1329
|
-
const [edgeReplication, setEdgeReplication] = useState9(space.internal.data.edgeReplication === EdgeReplicationSetting.ENABLED);
|
|
1330
|
-
const toggleEdgeReplication = useCallback10(async (next) => {
|
|
1331
|
-
setEdgeReplication(next);
|
|
1332
|
-
await space?.internal.setEdgeReplicationPreference(next ? EdgeReplicationSetting.ENABLED : EdgeReplicationSetting.DISABLED).catch((err) => {
|
|
1333
|
-
log3.catch(err, void 0, {
|
|
1334
|
-
F: __dxlog_file5,
|
|
1335
|
-
L: 51,
|
|
1336
|
-
S: void 0,
|
|
1337
|
-
C: (f, a) => f(...a)
|
|
1338
|
-
});
|
|
1339
|
-
setEdgeReplication(!next);
|
|
1340
|
-
});
|
|
1341
|
-
}, [
|
|
1342
|
-
space
|
|
1343
|
-
]);
|
|
1344
|
-
const handleSave = useCallback10((properties) => {
|
|
1345
|
-
void toggleEdgeReplication(properties.edgeReplication);
|
|
1346
|
-
if (properties.name !== space.properties.name) {
|
|
1347
|
-
space.properties.name = properties.name;
|
|
1348
|
-
}
|
|
1349
|
-
if (properties.icon !== space.properties.icon) {
|
|
1350
|
-
space.properties.icon = properties.icon;
|
|
1351
|
-
}
|
|
1352
|
-
if (properties.hue !== space.properties.hue) {
|
|
1353
|
-
space.properties.hue = properties.hue;
|
|
1354
|
-
}
|
|
1355
|
-
if (properties.archived && !archived) {
|
|
1356
|
-
void dispatch(pipe2(createIntent9(SpaceAction.Close, {
|
|
1357
|
-
space
|
|
1358
|
-
}), chain2(LayoutAction7.SwitchWorkspace, {
|
|
1359
|
-
part: "workspace",
|
|
1360
|
-
subject: client.spaces.default.id
|
|
1361
|
-
})));
|
|
1362
|
-
} else if (!properties.archived && archived) {
|
|
1363
|
-
void dispatch(createIntent9(SpaceAction.Open, {
|
|
1364
|
-
space
|
|
1365
|
-
}));
|
|
1366
|
-
}
|
|
1367
|
-
}, [
|
|
1368
|
-
space,
|
|
1369
|
-
toggleEdgeReplication,
|
|
1370
|
-
archived
|
|
1371
|
-
]);
|
|
1372
|
-
const values = useMemo3(() => ({
|
|
1373
|
-
name: space.properties.name,
|
|
1374
|
-
icon: space.properties.icon,
|
|
1375
|
-
hue: space.properties.hue,
|
|
1376
|
-
edgeReplication,
|
|
1377
|
-
archived
|
|
1378
|
-
}), [
|
|
1379
|
-
space.properties.name,
|
|
1380
|
-
space.properties.icon,
|
|
1381
|
-
space.properties.hue,
|
|
1382
|
-
edgeReplication,
|
|
1383
|
-
archived
|
|
1384
|
-
]);
|
|
1385
|
-
const customElements = useMemo3(() => ({
|
|
1386
|
-
name: ({ type, label, getValue, onValueChange }) => {
|
|
1387
|
-
const handleChange = useCallback10(({ target: { value } }) => onValueChange(type, value), [
|
|
1388
|
-
onValueChange,
|
|
1389
|
-
type
|
|
1390
|
-
]);
|
|
1391
|
-
return /* @__PURE__ */ React18.createElement(ControlItemInput2, {
|
|
1392
|
-
title: label,
|
|
1393
|
-
description: t("display name description")
|
|
1394
|
-
}, /* @__PURE__ */ React18.createElement(Input6.TextInput, {
|
|
1395
|
-
value: getValue(),
|
|
1396
|
-
onChange: handleChange,
|
|
1397
|
-
placeholder: t("display name input placeholder"),
|
|
1398
|
-
classNames: "min-is-64"
|
|
1399
|
-
}));
|
|
1400
|
-
},
|
|
1401
|
-
icon: ({ type, label, getValue, onValueChange }) => {
|
|
1402
|
-
const handleChange = useCallback10((nextEmoji) => onValueChange(type, nextEmoji), [
|
|
1403
|
-
onValueChange,
|
|
1404
|
-
type
|
|
1405
|
-
]);
|
|
1406
|
-
const handleEmojiReset = useCallback10(() => onValueChange(type, void 0), [
|
|
1407
|
-
onValueChange,
|
|
1408
|
-
type
|
|
1409
|
-
]);
|
|
1410
|
-
return /* @__PURE__ */ React18.createElement(ControlItem, {
|
|
1411
|
-
title: label,
|
|
1412
|
-
description: t("icon description")
|
|
1413
|
-
}, /* @__PURE__ */ React18.createElement(IconPicker, {
|
|
1414
|
-
value: getValue(),
|
|
1415
|
-
onChange: handleChange,
|
|
1416
|
-
onReset: handleEmojiReset,
|
|
1417
|
-
classNames: "justify-self-end",
|
|
1418
|
-
iconSize: 5
|
|
1419
|
-
}));
|
|
1420
|
-
},
|
|
1421
|
-
hue: ({ type, label, getValue, onValueChange }) => {
|
|
1422
|
-
const handleChange = useCallback10((nextHue) => onValueChange(type, nextHue), [
|
|
1423
|
-
onValueChange,
|
|
1424
|
-
type
|
|
1425
|
-
]);
|
|
1426
|
-
const handleHueReset = useCallback10(() => onValueChange(type, void 0), [
|
|
1427
|
-
onValueChange,
|
|
1428
|
-
type
|
|
1429
|
-
]);
|
|
1430
|
-
return /* @__PURE__ */ React18.createElement(ControlItem, {
|
|
1431
|
-
title: label,
|
|
1432
|
-
description: t("hue description")
|
|
1433
|
-
}, /* @__PURE__ */ React18.createElement(HuePicker, {
|
|
1434
|
-
value: getValue(),
|
|
1435
|
-
onChange: handleChange,
|
|
1436
|
-
onReset: handleHueReset,
|
|
1437
|
-
classNames: "[--hue-preview-size:1.25rem] justify-self-end"
|
|
1438
|
-
}));
|
|
1439
|
-
},
|
|
1440
|
-
edgeReplication: ({ type, label, getValue, onValueChange }) => {
|
|
1441
|
-
const handleChange = useCallback10((checked) => onValueChange(type, checked), [
|
|
1442
|
-
onValueChange,
|
|
1443
|
-
type
|
|
1444
|
-
]);
|
|
1445
|
-
return /* @__PURE__ */ React18.createElement(ControlItemInput2, {
|
|
1446
|
-
title: label,
|
|
1447
|
-
description: t("edge replication description")
|
|
1448
|
-
}, /* @__PURE__ */ React18.createElement(Input6.Switch, {
|
|
1449
|
-
checked: getValue(),
|
|
1450
|
-
onCheckedChange: handleChange,
|
|
1451
|
-
classNames: "justify-self-end"
|
|
1452
|
-
}));
|
|
1453
|
-
},
|
|
1454
|
-
archived: ({ type, label, getValue, onValueChange }) => {
|
|
1455
|
-
const handleChange = useCallback10(() => onValueChange(type, !getValue()), [
|
|
1456
|
-
onValueChange,
|
|
1457
|
-
type,
|
|
1458
|
-
getValue
|
|
1459
|
-
]);
|
|
1460
|
-
return /* @__PURE__ */ React18.createElement(ControlItemInput2, {
|
|
1461
|
-
title: label,
|
|
1462
|
-
description: t("archive space description")
|
|
1463
|
-
}, /* @__PURE__ */ React18.createElement(Button8, {
|
|
1464
|
-
disabled: space === client.spaces.default,
|
|
1465
|
-
onClick: handleChange
|
|
1466
|
-
}, getValue() ? t("unarchive space label") : t("archive space label")));
|
|
1467
|
-
}
|
|
1468
|
-
}), [
|
|
1469
|
-
t,
|
|
1470
|
-
space
|
|
1471
|
-
]);
|
|
1472
|
-
return /* @__PURE__ */ React18.createElement(StackItem4.Content, {
|
|
1473
|
-
classNames: "block overflow-y-auto pli-2"
|
|
1474
|
-
}, /* @__PURE__ */ React18.createElement(ControlPage3, null, /* @__PURE__ */ React18.createElement(ControlSection3, {
|
|
1475
|
-
title: t("space properties settings verbose label", {
|
|
1476
|
-
ns: SPACE_PLUGIN
|
|
1477
|
-
}),
|
|
1478
|
-
description: t("space properties settings description", {
|
|
1479
|
-
ns: SPACE_PLUGIN
|
|
1480
|
-
})
|
|
1481
|
-
}, /* @__PURE__ */ React18.createElement(Form3, {
|
|
1482
|
-
schema: FormSchema,
|
|
1483
|
-
values,
|
|
1484
|
-
autoSave: true,
|
|
1485
|
-
onSave: handleSave,
|
|
1486
|
-
Custom: customElements,
|
|
1487
|
-
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'
|
|
1488
|
-
}))));
|
|
1489
|
-
};
|
|
1490
|
-
|
|
1491
|
-
// packages/plugins/plugin-space/src/components/SyncStatus/InlineSyncStatus.tsx
|
|
1492
|
-
import { Option as Option2 } from "effect";
|
|
1493
|
-
import React19, { useEffect as useEffect5, useState as useState10 } from "react";
|
|
1494
|
-
import { useAppGraph as useAppGraph3 } from "@dxos/app-framework";
|
|
1495
|
-
import { EdgeStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
1496
|
-
import { EdgeReplicationSetting as EdgeReplicationSetting2 } from "@dxos/protocols/proto/dxos/echo/metadata";
|
|
1497
|
-
import { useClient as useClient8 } from "@dxos/react-client";
|
|
1498
|
-
import { useSpaceSyncState } from "@dxos/react-client/echo";
|
|
1499
|
-
import { Tooltip as Tooltip3, useTranslation as useTranslation18 } from "@dxos/react-ui";
|
|
1500
|
-
import { AttentionGlyph as AttentionGlyph2, useAttended as useAttended2, useAttention as useAttention2 } from "@dxos/react-ui-attention";
|
|
1501
|
-
var useEdgeStatus = () => {
|
|
1502
|
-
const [status, setStatus] = useState10(EdgeStatus.NOT_CONNECTED);
|
|
1503
|
-
const client = useClient8();
|
|
1504
|
-
useEffect5(() => {
|
|
1505
|
-
client.services.services.EdgeAgentService?.queryEdgeStatus().subscribe(({ status: status2 }) => {
|
|
1506
|
-
setStatus(status2);
|
|
1507
|
-
});
|
|
1508
|
-
}, [
|
|
1509
|
-
client
|
|
1510
|
-
]);
|
|
1511
|
-
return status;
|
|
1512
|
-
};
|
|
1513
|
-
var InlineSyncStatus = ({ space, open }) => {
|
|
1514
|
-
const { t } = useTranslation18(SPACE_PLUGIN);
|
|
1515
|
-
const id = space.id;
|
|
1516
|
-
const { hasAttention, isAncestor, isRelated } = useAttention2(id);
|
|
1517
|
-
const isAttended = hasAttention || isAncestor || isRelated;
|
|
1518
|
-
const { graph } = useAppGraph3();
|
|
1519
|
-
const attended = useAttended2();
|
|
1520
|
-
const startOfAttention = attended.at(-1);
|
|
1521
|
-
const path = usePath(graph, startOfAttention);
|
|
1522
|
-
const containsAttended = !open && !isAttended && id && Option2.isSome(path) ? path.value.includes(id) : false;
|
|
1523
|
-
const connectedToEdge = useEdgeStatus() === EdgeStatus.CONNECTED;
|
|
1524
|
-
const edgeSyncEnabled = space.internal.data.edgeReplication === EdgeReplicationSetting2.ENABLED;
|
|
1525
|
-
const syncState = useSpaceSyncState(space);
|
|
1526
|
-
const syncing = connectedToEdge && edgeSyncEnabled && syncState && syncState.missingOnLocal > 0;
|
|
1527
|
-
return /* @__PURE__ */ React19.createElement(Tooltip3.Trigger, {
|
|
1528
|
-
asChild: true,
|
|
1529
|
-
content: t("syncing label"),
|
|
1530
|
-
side: "bottom"
|
|
1531
|
-
}, /* @__PURE__ */ React19.createElement(AttentionGlyph2, {
|
|
1532
|
-
syncing,
|
|
1533
|
-
attended: isAttended,
|
|
1534
|
-
containsAttended,
|
|
1535
|
-
classNames: "self-center mie-1"
|
|
1536
|
-
}));
|
|
1537
|
-
};
|
|
1538
|
-
|
|
1539
|
-
// packages/plugins/plugin-space/src/components/SyncStatus/SyncStatus.tsx
|
|
1540
|
-
import React20, { useEffect as useEffect6, useState as useState11 } from "react";
|
|
1541
|
-
import { StatusBar } from "@dxos/plugin-status-bar";
|
|
1542
|
-
import { useClient as useClient9 } from "@dxos/react-client";
|
|
1543
|
-
import { getSyncSummary, useSyncState } from "@dxos/react-client/echo";
|
|
1544
|
-
import { Icon as Icon5, useTranslation as useTranslation19 } from "@dxos/react-ui";
|
|
1545
|
-
|
|
1546
|
-
// packages/plugins/plugin-space/src/components/SyncStatus/save-tracker.ts
|
|
1547
|
-
import { Context } from "@dxos/context";
|
|
1548
|
-
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/SyncStatus/save-tracker.ts";
|
|
1549
|
-
var createClientSaveTracker = (client, cb) => {
|
|
1550
|
-
const CleanupFns = {};
|
|
1551
|
-
const state = {};
|
|
1552
|
-
const install = (spaces) => {
|
|
1553
|
-
for (const space of spaces) {
|
|
1554
|
-
if (state[space.id]) {
|
|
1555
|
-
continue;
|
|
1556
|
-
}
|
|
1557
|
-
state[space.id] = "saved";
|
|
1558
|
-
CleanupFns[space.id] = createSpaceSaveTracker(space, (s) => {
|
|
1559
|
-
state[space.id] = s;
|
|
1560
|
-
cb(Object.values(state).some((s2) => s2 === "saving") ? "saving" : "saved");
|
|
1561
|
-
});
|
|
1562
|
-
}
|
|
1563
|
-
};
|
|
1564
|
-
client.spaces.subscribe((spaces) => {
|
|
1565
|
-
install(spaces);
|
|
1566
|
-
});
|
|
1567
|
-
install(client.spaces.get());
|
|
1568
|
-
return () => {
|
|
1569
|
-
for (const unsubscribe of Object.values(CleanupFns)) {
|
|
1570
|
-
unsubscribe();
|
|
1571
|
-
}
|
|
1572
|
-
};
|
|
1573
|
-
};
|
|
1574
|
-
var createSpaceSaveTracker = (space, cb) => {
|
|
1575
|
-
const ctx = new Context(void 0, {
|
|
1576
|
-
F: __dxlog_file6,
|
|
1577
|
-
L: 40
|
|
1578
|
-
});
|
|
1579
|
-
void space.waitUntilReady().then(() => {
|
|
1580
|
-
if (ctx.disposed) {
|
|
1581
|
-
return;
|
|
1582
|
-
}
|
|
1583
|
-
let hasUnsavedChanges = false;
|
|
1584
|
-
let lastFlushPromise;
|
|
1585
|
-
space.crud.saveStateChanged.on(ctx, ({ unsavedDocuments }) => {
|
|
1586
|
-
hasUnsavedChanges = unsavedDocuments.length > 0;
|
|
1587
|
-
});
|
|
1588
|
-
space.crud.saveStateChanged.debounce(500).on(ctx, () => {
|
|
1589
|
-
if (hasUnsavedChanges) {
|
|
1590
|
-
lastFlushPromise = void 0;
|
|
1591
|
-
cb("saving");
|
|
1592
|
-
} else {
|
|
1593
|
-
const flushPromise = space.crud.flush();
|
|
1594
|
-
lastFlushPromise = flushPromise;
|
|
1595
|
-
void flushPromise.then(() => {
|
|
1596
|
-
if (lastFlushPromise === flushPromise) {
|
|
1597
|
-
cb("saved");
|
|
1598
|
-
}
|
|
1599
|
-
});
|
|
1600
|
-
}
|
|
1601
|
-
});
|
|
1602
|
-
});
|
|
1603
|
-
return () => {
|
|
1604
|
-
void ctx.dispose();
|
|
1605
|
-
};
|
|
1606
|
-
};
|
|
1607
|
-
|
|
1608
|
-
// packages/plugins/plugin-space/src/components/SyncStatus/status.ts
|
|
1609
|
-
var getStatus = ({ offline, saved, needsToUpload, needsToDownload }) => {
|
|
1610
|
-
if (!saved) {
|
|
1611
|
-
return "saving locally";
|
|
1612
|
-
} else if (!offline && needsToDownload) {
|
|
1613
|
-
return "downloading";
|
|
1614
|
-
} else if (!offline && needsToUpload) {
|
|
1615
|
-
return "uploading";
|
|
1616
|
-
} else if (offline && !needsToUpload && !needsToDownload) {
|
|
1617
|
-
return "offline persisted";
|
|
1618
|
-
} else {
|
|
1619
|
-
return "remote synced";
|
|
1620
|
-
}
|
|
1621
|
-
};
|
|
1622
|
-
var getIcon = (status) => {
|
|
1623
|
-
switch (status) {
|
|
1624
|
-
case "saving locally":
|
|
1625
|
-
return "ph--download--regular";
|
|
1626
|
-
case "downloading":
|
|
1627
|
-
return "ph--cloud-arrow-down--regular";
|
|
1628
|
-
case "uploading":
|
|
1629
|
-
return "ph--cloud-arrow-up--regular";
|
|
1630
|
-
case "offline persisted":
|
|
1631
|
-
return "ph--check-circle--regular";
|
|
1632
|
-
case "remote synced":
|
|
1633
|
-
return "ph--cloud-check--regular";
|
|
1634
|
-
}
|
|
1635
|
-
};
|
|
1636
|
-
|
|
1637
|
-
// packages/plugins/plugin-space/src/components/SyncStatus/SyncStatus.tsx
|
|
1638
|
-
var SYNC_STALLED_TIMEOUT = 5e3;
|
|
1639
|
-
var SyncStatus = () => {
|
|
1640
|
-
const client = useClient9();
|
|
1641
|
-
const state = useSyncState();
|
|
1642
|
-
const [saved, setSaved] = useState11(true);
|
|
1643
|
-
useEffect6(() => {
|
|
1644
|
-
return createClientSaveTracker(client, (state2) => {
|
|
1645
|
-
setSaved(state2 === "saved");
|
|
1646
|
-
});
|
|
1647
|
-
}, []);
|
|
1648
|
-
return /* @__PURE__ */ React20.createElement(SyncStatusIndicator, {
|
|
1649
|
-
state,
|
|
1650
|
-
saved
|
|
1651
|
-
});
|
|
1652
|
-
};
|
|
1653
|
-
var SyncStatusIndicator = ({ state, saved }) => {
|
|
1654
|
-
const { t } = useTranslation19(SPACE_PLUGIN);
|
|
1655
|
-
const summary = getSyncSummary(state);
|
|
1656
|
-
const offline = Object.values(state).length === 0;
|
|
1657
|
-
const needsToUpload = summary.differentDocuments > 0 || summary.missingOnRemote > 0;
|
|
1658
|
-
const needsToDownload = summary.differentDocuments > 0 || summary.missingOnLocal > 0;
|
|
1659
|
-
const status = getStatus({
|
|
1660
|
-
offline,
|
|
1661
|
-
saved,
|
|
1662
|
-
needsToUpload,
|
|
1663
|
-
needsToDownload
|
|
1664
|
-
});
|
|
1665
|
-
const [classNames, setClassNames] = useState11();
|
|
1666
|
-
useEffect6(() => {
|
|
1667
|
-
setClassNames(void 0);
|
|
1668
|
-
if (offline || !needsToUpload && !needsToDownload) {
|
|
1669
|
-
return;
|
|
1670
|
-
}
|
|
1671
|
-
const t2 = setTimeout(() => {
|
|
1672
|
-
setClassNames("text-orange-500");
|
|
1673
|
-
}, SYNC_STALLED_TIMEOUT);
|
|
1674
|
-
return () => clearTimeout(t2);
|
|
1675
|
-
}, [
|
|
1676
|
-
offline,
|
|
1677
|
-
needsToUpload,
|
|
1678
|
-
needsToDownload
|
|
1679
|
-
]);
|
|
1680
|
-
const title = t(`${status} label`);
|
|
1681
|
-
const icon = /* @__PURE__ */ React20.createElement(Icon5, {
|
|
1682
|
-
icon: getIcon(status),
|
|
1683
|
-
size: 4,
|
|
1684
|
-
classNames
|
|
1685
|
-
});
|
|
1686
|
-
return /* @__PURE__ */ React20.createElement(StatusBar.Item, {
|
|
1687
|
-
title
|
|
1688
|
-
}, icon);
|
|
1689
|
-
};
|
|
1690
|
-
|
|
1691
|
-
export {
|
|
1692
|
-
AwaitingObject,
|
|
1693
|
-
CREATE_OBJECT_DIALOG,
|
|
1694
|
-
CreateObjectDialog,
|
|
1695
|
-
CREATE_SPACE_DIALOG,
|
|
1696
|
-
CreateSpaceDialog,
|
|
1697
|
-
CollectionMain,
|
|
1698
|
-
CollectionSection,
|
|
1699
|
-
JOIN_DIALOG,
|
|
1700
|
-
JoinDialog,
|
|
1701
|
-
MembersContainer,
|
|
1702
|
-
MenuFooter,
|
|
1703
|
-
ObjectSettingsContainer,
|
|
1704
|
-
PersistenceStatus,
|
|
1705
|
-
POPOVER_RENAME_OBJECT,
|
|
1706
|
-
PopoverRenameObject,
|
|
1707
|
-
POPOVER_RENAME_SPACE,
|
|
1708
|
-
PopoverRenameSpace,
|
|
1709
|
-
useQuerySpaceSchemas,
|
|
1710
|
-
SchemaContainer,
|
|
1711
|
-
SpacePresence,
|
|
1712
|
-
FullPresence,
|
|
1713
|
-
SmallPresenceLive,
|
|
1714
|
-
SmallPresence,
|
|
1715
|
-
SpacePluginSettings,
|
|
1716
|
-
SpaceSettingsContainer,
|
|
1717
|
-
InlineSyncStatus,
|
|
1718
|
-
SyncStatus,
|
|
1719
|
-
SyncStatusIndicator,
|
|
1720
|
-
AppGraphBuilder,
|
|
1721
|
-
AppGraphSerializer,
|
|
1722
|
-
IdentityCreated,
|
|
1723
|
-
IntentResolver,
|
|
1724
|
-
ReactRoot,
|
|
1725
|
-
ReactSurface,
|
|
1726
|
-
SchemaDefs,
|
|
1727
|
-
SchemaTools,
|
|
1728
|
-
SpaceSettings,
|
|
1729
|
-
SpaceState,
|
|
1730
|
-
SpacesReady
|
|
1731
|
-
};
|
|
1732
|
-
//# sourceMappingURL=chunk-FI3WV22Y.mjs.map
|