@dxos/plugin-space 0.7.4 → 0.7.5-feature-compute.4d9d99a
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-5D2QB43K.mjs +365 -0
- package/dist/lib/browser/app-graph-builder-5D2QB43K.mjs.map +7 -0
- package/dist/lib/browser/app-graph-serializer-VNWPLPDF.mjs +80 -0
- package/dist/lib/browser/app-graph-serializer-VNWPLPDF.mjs.map +7 -0
- package/dist/lib/browser/chunk-5TBRONF6.mjs +133 -0
- package/dist/lib/browser/chunk-5TBRONF6.mjs.map +7 -0
- package/dist/lib/browser/chunk-6SWQRWOD.mjs +1672 -0
- package/dist/lib/browser/chunk-6SWQRWOD.mjs.map +7 -0
- package/dist/lib/browser/chunk-HCXWKGTE.mjs +316 -0
- package/dist/lib/browser/chunk-HCXWKGTE.mjs.map +7 -0
- package/dist/lib/browser/chunk-SOXNANA6.mjs +12 -0
- package/dist/lib/browser/chunk-SOXNANA6.mjs.map +7 -0
- package/dist/lib/browser/chunk-UH5P4UL3.mjs +21 -0
- package/dist/lib/browser/chunk-UH5P4UL3.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZBKFJNHH.mjs +523 -0
- package/dist/lib/browser/chunk-ZBKFJNHH.mjs.map +7 -0
- package/dist/lib/browser/identity-created-EC5FOCX2.mjs +28 -0
- package/dist/lib/browser/identity-created-EC5FOCX2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +192 -3521
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-VBL572N7.mjs +459 -0
- package/dist/lib/browser/intent-resolver-VBL572N7.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-root-AZJFNTKK.mjs +28 -0
- package/dist/lib/browser/react-root-AZJFNTKK.mjs.map +7 -0
- package/dist/lib/browser/react-surface-E2VSYVNZ.mjs +238 -0
- package/dist/lib/browser/react-surface-E2VSYVNZ.mjs.map +7 -0
- package/dist/lib/browser/settings-ASFF5BZL.mjs +24 -0
- package/dist/lib/browser/settings-ASFF5BZL.mjs.map +7 -0
- package/dist/lib/browser/spaces-ready-4SFNS5JQ.mjs +200 -0
- package/dist/lib/browser/spaces-ready-4SFNS5JQ.mjs.map +7 -0
- package/dist/lib/browser/state-MS4KYJWI.mjs +47 -0
- package/dist/lib/browser/state-MS4KYJWI.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +14 -5
- package/dist/lib/node/app-graph-builder-ZQ5S62YR.cjs +368 -0
- package/dist/lib/node/app-graph-builder-ZQ5S62YR.cjs.map +7 -0
- package/dist/lib/node/app-graph-serializer-72S7P33H.cjs +88 -0
- package/dist/lib/node/app-graph-serializer-72S7P33H.cjs.map +7 -0
- package/dist/lib/node/chunk-56NGXG2A.cjs +41 -0
- package/dist/lib/node/chunk-56NGXG2A.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → chunk-AO4EW2RX.cjs} +12 -13
- package/dist/lib/node/chunk-AO4EW2RX.cjs.map +7 -0
- package/dist/lib/node/chunk-BQRNTKSQ.cjs +150 -0
- package/dist/lib/node/chunk-BQRNTKSQ.cjs.map +7 -0
- package/dist/lib/node/chunk-DDZYVNVP.cjs +345 -0
- package/dist/lib/node/chunk-DDZYVNVP.cjs.map +7 -0
- package/dist/lib/node/chunk-M64YG2FY.cjs +1669 -0
- package/dist/lib/node/chunk-M64YG2FY.cjs.map +7 -0
- package/dist/lib/node/chunk-Z34MTEU7.cjs +551 -0
- package/dist/lib/node/chunk-Z34MTEU7.cjs.map +7 -0
- package/dist/lib/node/identity-created-IMDS4A6A.cjs +44 -0
- package/dist/lib/node/identity-created-IMDS4A6A.cjs.map +7 -0
- package/dist/lib/node/index.cjs +175 -3506
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-S4HZABYI.cjs +458 -0
- package/dist/lib/node/intent-resolver-S4HZABYI.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-root-RB3OM3QG.cjs +50 -0
- package/dist/lib/node/react-root-RB3OM3QG.cjs.map +7 -0
- package/dist/lib/node/react-surface-TLKQEHHT.cjs +233 -0
- package/dist/lib/node/react-surface-TLKQEHHT.cjs.map +7 -0
- package/dist/lib/node/settings-QLCKAUHK.cjs +38 -0
- package/dist/lib/node/settings-QLCKAUHK.cjs.map +7 -0
- package/dist/lib/node/spaces-ready-RZTKEXOL.cjs +211 -0
- package/dist/lib/node/spaces-ready-RZTKEXOL.cjs.map +7 -0
- package/dist/lib/node/state-4UIOUKLJ.cjs +61 -0
- package/dist/lib/node/state-4UIOUKLJ.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +23 -14
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/app-graph-builder-CD6IYPSS.mjs +366 -0
- package/dist/lib/node-esm/app-graph-builder-CD6IYPSS.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-serializer-CFXS6ZE2.mjs +81 -0
- package/dist/lib/node-esm/app-graph-serializer-CFXS6ZE2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-375RB3CZ.mjs +22 -0
- package/dist/lib/node-esm/chunk-375RB3CZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7FUVU45N.mjs +14 -0
- package/dist/lib/node-esm/chunk-7FUVU45N.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CLGCKZ2D.mjs +317 -0
- package/dist/lib/node-esm/chunk-CLGCKZ2D.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CMKML5IN.mjs +1673 -0
- package/dist/lib/node-esm/chunk-CMKML5IN.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FUMGYUD3.mjs +524 -0
- package/dist/lib/node-esm/chunk-FUMGYUD3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-M4XTHK35.mjs +134 -0
- package/dist/lib/node-esm/chunk-M4XTHK35.mjs.map +7 -0
- package/dist/lib/node-esm/identity-created-SJYZZ7Q3.mjs +29 -0
- package/dist/lib/node-esm/identity-created-SJYZZ7Q3.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +192 -3521
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-OIQH7HN7.mjs +460 -0
- package/dist/lib/node-esm/intent-resolver-OIQH7HN7.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-root-WKJWCHXR.mjs +29 -0
- package/dist/lib/node-esm/react-root-WKJWCHXR.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-RVEHOSAD.mjs +239 -0
- package/dist/lib/node-esm/react-surface-RVEHOSAD.mjs.map +7 -0
- package/dist/lib/node-esm/settings-WLVEO4JM.mjs +25 -0
- package/dist/lib/node-esm/settings-WLVEO4JM.mjs.map +7 -0
- package/dist/lib/node-esm/spaces-ready-ITGYYT5A.mjs +201 -0
- package/dist/lib/node-esm/spaces-ready-ITGYYT5A.mjs.map +7 -0
- package/dist/lib/node-esm/state-BMISGQ2O.mjs +48 -0
- package/dist/lib/node-esm/state-BMISGQ2O.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +14 -5
- package/dist/types/src/SpacePlugin.d.ts +1 -24
- package/dist/types/src/SpacePlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-serializer.d.ts +4 -0
- package/dist/types/src/capabilities/app-graph-serializer.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +15 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/identity-created.d.ts +4 -0
- package/dist/types/src/capabilities/identity-created.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +195 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +8 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-root.d.ts +7 -0
- package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +7 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +4 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/capabilities/spaces-ready.d.ts +4 -0
- package/dist/types/src/capabilities/spaces-ready.d.ts.map +1 -0
- package/dist/types/src/capabilities/state.d.ts +5 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/components/AdvancedObjectSettings/AdvancedObjectSettings.d.ts +7 -0
- package/dist/types/src/components/AdvancedObjectSettings/AdvancedObjectSettings.d.ts.map +1 -0
- package/dist/types/src/components/AdvancedObjectSettings/ForeignKeys.d.ts +8 -0
- package/dist/types/src/components/AdvancedObjectSettings/ForeignKeys.d.ts.map +1 -0
- package/dist/types/src/components/AdvancedObjectSettings/index.d.ts +2 -0
- package/dist/types/src/components/AdvancedObjectSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/AwaitingObject.d.ts.map +1 -1
- package/dist/types/src/components/BaseObjectSettings.d.ts +7 -0
- package/dist/types/src/components/BaseObjectSettings.d.ts.map +1 -0
- package/dist/types/src/components/CreateDialog/CreateObjectDialog.d.ts +5 -4
- package/dist/types/src/components/CreateDialog/CreateObjectDialog.d.ts.map +1 -1
- package/dist/types/src/components/CreateDialog/CreateObjectPanel.d.ts +5 -6
- package/dist/types/src/components/CreateDialog/CreateObjectPanel.d.ts.map +1 -1
- package/dist/types/src/components/CreateDialog/CreateSpaceDialog.d.ts +1 -0
- package/dist/types/src/components/CreateDialog/CreateSpaceDialog.d.ts.map +1 -1
- package/dist/types/src/components/JoinDialog.d.ts +1 -0
- package/dist/types/src/components/JoinDialog.d.ts.map +1 -1
- package/dist/types/src/components/PopoverRenameObject.d.ts +1 -0
- package/dist/types/src/components/PopoverRenameObject.d.ts.map +1 -1
- package/dist/types/src/components/PopoverRenameSpace.d.ts +1 -0
- package/dist/types/src/components/PopoverRenameSpace.d.ts.map +1 -1
- package/dist/types/src/components/ShareSpaceButton.d.ts.map +1 -1
- package/dist/types/src/components/SpacePluginSettings.d.ts.map +1 -1
- package/dist/types/src/components/SpacePresence.d.ts +9 -6
- package/dist/types/src/components/SpacePresence.d.ts.map +1 -1
- package/dist/types/src/components/SpacePresence.stories.d.ts +1 -1
- package/dist/types/src/components/SpacePresence.stories.d.ts.map +1 -1
- package/dist/types/src/components/SpaceSettings/SpaceSettingsDialog.d.ts +1 -0
- package/dist/types/src/components/SpaceSettings/SpaceSettingsDialog.d.ts.map +1 -1
- package/dist/types/src/components/SpaceSettings/SpaceSettingsDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/SpaceSettings/SpaceSettingsPanel.d.ts +4 -3
- package/dist/types/src/components/SpaceSettings/SpaceSettingsPanel.d.ts.map +1 -1
- package/dist/types/src/components/SpaceSettings/SpaceSettingsPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/SyncStatus/InlineSyncStatus.d.ts +3 -3
- package/dist/types/src/components/SyncStatus/InlineSyncStatus.d.ts.map +1 -1
- package/dist/types/src/components/SyncStatus/SyncStatusDetail.stories.d.ts +2 -2
- package/dist/types/src/components/SyncStatus/SyncStatusDetail.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +5 -0
- package/dist/types/src/events.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/usePath.d.ts +11 -0
- package/dist/types/src/hooks/usePath.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -27
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +18 -3
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/collection.d.ts +8 -12
- package/dist/types/src/types/collection.d.ts.map +1 -1
- package/dist/types/src/types/thread.d.ts +180 -186
- package/dist/types/src/types/thread.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +228 -16
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +9 -8
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +38 -46
- package/src/SpacePlugin.tsx +119 -1541
- package/src/capabilities/app-graph-builder.ts +392 -0
- package/src/capabilities/app-graph-serializer.ts +73 -0
- package/src/capabilities/capabilities.ts +23 -0
- package/src/capabilities/identity-created.ts +26 -0
- package/src/capabilities/index.ts +17 -0
- package/src/capabilities/intent-resolver.ts +420 -0
- package/src/capabilities/react-root.tsx +20 -0
- package/src/capabilities/react-surface.tsx +234 -0
- package/src/capabilities/settings.ts +17 -0
- package/src/capabilities/spaces-ready.ts +231 -0
- package/src/capabilities/state.ts +45 -0
- package/src/components/AdvancedObjectSettings/AdvancedObjectSettings.tsx +72 -0
- package/src/components/AdvancedObjectSettings/ForeignKeys.tsx +51 -0
- package/src/components/AdvancedObjectSettings/index.ts +5 -0
- package/src/components/AwaitingObject.tsx +15 -19
- package/src/components/{DefaultObjectSettings.tsx → BaseObjectSettings.tsx} +2 -2
- package/src/components/CreateDialog/CreateObjectDialog.tsx +36 -25
- package/src/components/CreateDialog/CreateObjectPanel.tsx +61 -24
- package/src/components/CreateDialog/CreateSpaceDialog.tsx +10 -14
- package/src/components/JoinDialog.tsx +18 -34
- package/src/components/PersistenceStatus.tsx +1 -1
- package/src/components/PopoverRenameObject.tsx +2 -0
- package/src/components/PopoverRenameSpace.tsx +2 -0
- package/src/components/ShareSpaceButton.tsx +5 -4
- package/src/components/SpacePluginSettings.tsx +2 -13
- package/src/components/SpacePresence.stories.tsx +25 -17
- package/src/components/SpacePresence.tsx +42 -21
- package/src/components/SpaceSettings/SpaceSettingsDialog.stories.tsx +2 -3
- package/src/components/SpaceSettings/SpaceSettingsDialog.tsx +3 -1
- package/src/components/SpaceSettings/SpaceSettingsPanel.stories.tsx +7 -5
- package/src/components/SpaceSettings/SpaceSettingsPanel.tsx +6 -5
- package/src/components/SyncStatus/InlineSyncStatus.tsx +37 -27
- package/src/components/SyncStatus/SyncStatusDetail.stories.tsx +55 -51
- package/src/components/index.ts +2 -1
- package/src/events.ts +12 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/usePath.ts +44 -0
- package/src/index.ts +3 -7
- package/src/meta.ts +1 -29
- package/src/translations.ts +7 -2
- package/src/types/collection.ts +3 -3
- package/src/types/thread.ts +6 -6
- package/src/types/types.ts +177 -42
- package/src/util.tsx +77 -64
- package/dist/lib/browser/chunk-FTKV32QZ.mjs +0 -43
- package/dist/lib/browser/chunk-FTKV32QZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-MWKXNS5S.mjs +0 -124
- package/dist/lib/browser/chunk-MWKXNS5S.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -15
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/lib/node/chunk-6SNOZF7Y.cjs +0 -152
- package/dist/lib/node/chunk-6SNOZF7Y.cjs.map +0 -7
- package/dist/lib/node/chunk-QNVEU2UD.cjs +0 -69
- package/dist/lib/node/chunk-QNVEU2UD.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-OHEAWSCA.mjs +0 -126
- package/dist/lib/node-esm/chunk-OHEAWSCA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UMV7XREB.mjs +0 -45
- package/dist/lib/node-esm/chunk-UMV7XREB.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -16
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/types/src/components/DefaultObjectSettings.d.ts +0 -7
- package/dist/types/src/components/DefaultObjectSettings.d.ts.map +0 -1
- package/dist/types/src/components/SyncStatus/InlineSyncStatus.stories.d.ts +0 -6
- package/dist/types/src/components/SyncStatus/InlineSyncStatus.stories.d.ts.map +0 -1
- package/src/components/SyncStatus/InlineSyncStatus.stories.tsx +0 -57
|
@@ -0,0 +1,1672 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SpaceCapabilities
|
|
3
|
+
} from "./chunk-UH5P4UL3.mjs";
|
|
4
|
+
import {
|
|
5
|
+
COMPOSER_SPACE_LOCK,
|
|
6
|
+
getSpaceDisplayName
|
|
7
|
+
} from "./chunk-ZBKFJNHH.mjs";
|
|
8
|
+
import {
|
|
9
|
+
CollectionType,
|
|
10
|
+
SpaceAction,
|
|
11
|
+
SpaceForm
|
|
12
|
+
} from "./chunk-HCXWKGTE.mjs";
|
|
13
|
+
import {
|
|
14
|
+
SPACE_PLUGIN
|
|
15
|
+
} from "./chunk-SOXNANA6.mjs";
|
|
16
|
+
|
|
17
|
+
// packages/plugins/plugin-space/src/components/AdvancedObjectSettings/AdvancedObjectSettings.tsx
|
|
18
|
+
import React2, { useCallback as useCallback2, useState } from "react";
|
|
19
|
+
import { ForeignKeySchema } from "@dxos/echo-schema";
|
|
20
|
+
import { getMeta } from "@dxos/react-client/echo";
|
|
21
|
+
import { IconButton as IconButton2, useTranslation as useTranslation2, Separator } from "@dxos/react-ui";
|
|
22
|
+
import { Form } from "@dxos/react-ui-form";
|
|
23
|
+
|
|
24
|
+
// packages/plugins/plugin-space/src/components/AdvancedObjectSettings/ForeignKeys.tsx
|
|
25
|
+
import React, { useCallback } from "react";
|
|
26
|
+
import { IconButton, List, ListItem, useTranslation } from "@dxos/react-ui";
|
|
27
|
+
var ForeignKeys = ({ keys, onDelete }) => {
|
|
28
|
+
return /* @__PURE__ */ React.createElement(List, {
|
|
29
|
+
classNames: "flex flex-col gap-2"
|
|
30
|
+
}, keys.map((key) => /* @__PURE__ */ React.createElement(KeyItem, {
|
|
31
|
+
key: key.id,
|
|
32
|
+
forignKey: key,
|
|
33
|
+
onDelete
|
|
34
|
+
})));
|
|
35
|
+
};
|
|
36
|
+
var KeyItem = ({ forignKey, onDelete }) => {
|
|
37
|
+
const { t } = useTranslation(SPACE_PLUGIN);
|
|
38
|
+
const handleDelete = useCallback(() => {
|
|
39
|
+
onDelete?.(forignKey);
|
|
40
|
+
}, [
|
|
41
|
+
forignKey,
|
|
42
|
+
onDelete
|
|
43
|
+
]);
|
|
44
|
+
return /* @__PURE__ */ React.createElement(ListItem.Root, {
|
|
45
|
+
classNames: "px-2"
|
|
46
|
+
}, /* @__PURE__ */ React.createElement(ListItem.Heading, {
|
|
47
|
+
classNames: "flex flex-col grow truncate"
|
|
48
|
+
}, /* @__PURE__ */ React.createElement("div", null, forignKey.source), /* @__PURE__ */ React.createElement("div", {
|
|
49
|
+
className: "text-description text-sm truncate"
|
|
50
|
+
}, forignKey.id)), /* @__PURE__ */ React.createElement(ListItem.Endcap, null, /* @__PURE__ */ React.createElement(IconButton, {
|
|
51
|
+
iconOnly: true,
|
|
52
|
+
icon: "ph--x--regular",
|
|
53
|
+
variant: "ghost",
|
|
54
|
+
label: t("delete key"),
|
|
55
|
+
onClick: handleDelete
|
|
56
|
+
})));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// packages/plugins/plugin-space/src/components/AdvancedObjectSettings/AdvancedObjectSettings.tsx
|
|
60
|
+
var initialValues = {
|
|
61
|
+
source: "",
|
|
62
|
+
id: ""
|
|
63
|
+
};
|
|
64
|
+
var AdvancedObjectSettings = ({ object }) => {
|
|
65
|
+
const { t } = useTranslation2(SPACE_PLUGIN);
|
|
66
|
+
const [adding, setAdding] = useState(false);
|
|
67
|
+
const keys = getMeta(object).keys;
|
|
68
|
+
const handleNew = useCallback2(() => setAdding(true), []);
|
|
69
|
+
const handleCancel = useCallback2(() => setAdding(false), []);
|
|
70
|
+
const handleSave = useCallback2((key) => {
|
|
71
|
+
const index = keys.findIndex(({ source, id }) => source === key.source && id === key.id);
|
|
72
|
+
if (index === -1) {
|
|
73
|
+
keys.push(key);
|
|
74
|
+
}
|
|
75
|
+
setAdding(false);
|
|
76
|
+
}, [
|
|
77
|
+
keys
|
|
78
|
+
]);
|
|
79
|
+
const handleDelete = useCallback2((key) => {
|
|
80
|
+
const index = keys.findIndex(({ source, id }) => source === key.source && id === key.id);
|
|
81
|
+
if (index !== -1) {
|
|
82
|
+
keys.splice(index, 1);
|
|
83
|
+
}
|
|
84
|
+
}, [
|
|
85
|
+
keys
|
|
86
|
+
]);
|
|
87
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Separator, null), /* @__PURE__ */ React2.createElement("div", {
|
|
88
|
+
className: "p-2 flex flex-col gap-4"
|
|
89
|
+
}, /* @__PURE__ */ React2.createElement("h2", null, t("advanced settings label")), /* @__PURE__ */ React2.createElement("div", {
|
|
90
|
+
className: "flex items-center"
|
|
91
|
+
}, /* @__PURE__ */ React2.createElement("h3", {
|
|
92
|
+
className: "text-sm font-semibold"
|
|
93
|
+
}, t("foreign keys")), /* @__PURE__ */ React2.createElement("div", {
|
|
94
|
+
className: "grow"
|
|
95
|
+
}), /* @__PURE__ */ React2.createElement(IconButton2, {
|
|
96
|
+
classNames: adding && "invisible",
|
|
97
|
+
icon: "ph--plus--regular",
|
|
98
|
+
label: t("add key"),
|
|
99
|
+
onClick: handleNew
|
|
100
|
+
})), !adding && /* @__PURE__ */ React2.createElement(ForeignKeys, {
|
|
101
|
+
keys,
|
|
102
|
+
onDelete: handleDelete
|
|
103
|
+
})), adding && /* @__PURE__ */ React2.createElement(Form, {
|
|
104
|
+
schema: ForeignKeySchema,
|
|
105
|
+
values: initialValues,
|
|
106
|
+
onSave: handleSave,
|
|
107
|
+
onCancel: handleCancel
|
|
108
|
+
}));
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// packages/plugins/plugin-space/src/components/AwaitingObject.tsx
|
|
112
|
+
import { CheckCircle, CircleDashed, CircleNotch } from "@phosphor-icons/react";
|
|
113
|
+
import React3, { useCallback as useCallback3, useEffect, useState as useState2 } from "react";
|
|
114
|
+
import { NavigationAction, useIntentDispatcher, createIntent, useCapability, Capabilities } from "@dxos/app-framework";
|
|
115
|
+
import { useClient } from "@dxos/react-client";
|
|
116
|
+
import { Filter, fullyQualifiedId, useQuery } from "@dxos/react-client/echo";
|
|
117
|
+
import { Button, Toast, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
118
|
+
import { getSize, mx } from "@dxos/react-ui-theme";
|
|
119
|
+
var WAIT_FOR_OBJECT_TIMEOUT = 18e4;
|
|
120
|
+
var TOAST_TIMEOUT = 24e4;
|
|
121
|
+
var AwaitingObject = ({ id }) => {
|
|
122
|
+
const [open, setOpen] = useState2(true);
|
|
123
|
+
const [waiting, setWaiting] = useState2(true);
|
|
124
|
+
const [found, setFound] = useState2(false);
|
|
125
|
+
const { t } = useTranslation3(SPACE_PLUGIN);
|
|
126
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
127
|
+
const location = useCapability(Capabilities.Location);
|
|
128
|
+
const client = useClient();
|
|
129
|
+
const objects = useQuery(client.spaces, Filter.all());
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
if (!id) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const timeout = setTimeout(() => {
|
|
135
|
+
setWaiting(false);
|
|
136
|
+
}, WAIT_FOR_OBJECT_TIMEOUT);
|
|
137
|
+
() => clearTimeout(timeout);
|
|
138
|
+
}, [
|
|
139
|
+
id
|
|
140
|
+
]);
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (objects.findIndex((object) => fullyQualifiedId(object) === id) > -1) {
|
|
143
|
+
setFound(true);
|
|
144
|
+
if (location.active.solo?.[0].id === id) {
|
|
145
|
+
setOpen(false);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}, [
|
|
149
|
+
id,
|
|
150
|
+
objects,
|
|
151
|
+
location
|
|
152
|
+
]);
|
|
153
|
+
const handleClose = useCallback3(async () => dispatch(createIntent(SpaceAction.WaitForObject, {
|
|
154
|
+
id: void 0
|
|
155
|
+
})), [
|
|
156
|
+
dispatch
|
|
157
|
+
]);
|
|
158
|
+
const handleNavigate = useCallback3(() => {
|
|
159
|
+
void dispatch(createIntent(NavigationAction.Open, {
|
|
160
|
+
activeParts: {
|
|
161
|
+
main: [
|
|
162
|
+
id
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
}));
|
|
166
|
+
void handleClose();
|
|
167
|
+
}, [
|
|
168
|
+
id,
|
|
169
|
+
handleClose,
|
|
170
|
+
dispatch
|
|
171
|
+
]);
|
|
172
|
+
return /* @__PURE__ */ React3.createElement(Toast.Root, {
|
|
173
|
+
open,
|
|
174
|
+
duration: TOAST_TIMEOUT,
|
|
175
|
+
onOpenChange: setOpen
|
|
176
|
+
}, /* @__PURE__ */ React3.createElement(Toast.Body, null, /* @__PURE__ */ React3.createElement(Toast.Title, {
|
|
177
|
+
classNames: "flex items-center gap-2"
|
|
178
|
+
}, found ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(CheckCircle, {
|
|
179
|
+
className: getSize(5)
|
|
180
|
+
}), /* @__PURE__ */ React3.createElement("span", null, t("found object label"))) : waiting ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(CircleNotch, {
|
|
181
|
+
className: mx(getSize(5), "animate-spin")
|
|
182
|
+
}), /* @__PURE__ */ React3.createElement("span", null, t("waiting for object label"))) : /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(CircleDashed, {
|
|
183
|
+
className: getSize(5)
|
|
184
|
+
}), /* @__PURE__ */ React3.createElement("span", null, t("object not found label")))), /* @__PURE__ */ React3.createElement(Toast.Description, null, t(found ? "found object description" : waiting ? "waiting for object description" : "object not found description"))), /* @__PURE__ */ React3.createElement(Toast.Actions, null, found ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(Toast.Action, {
|
|
185
|
+
altText: t("go to object alt"),
|
|
186
|
+
asChild: true
|
|
187
|
+
}, /* @__PURE__ */ React3.createElement(Button, {
|
|
188
|
+
variant: "primary",
|
|
189
|
+
onClick: handleNavigate
|
|
190
|
+
}, t("go to object label"))), /* @__PURE__ */ React3.createElement(Toast.Close, {
|
|
191
|
+
asChild: true
|
|
192
|
+
}, /* @__PURE__ */ React3.createElement(Button, {
|
|
193
|
+
onClick: handleClose
|
|
194
|
+
}, t("close label", {
|
|
195
|
+
ns: "appkit"
|
|
196
|
+
})))) : /* @__PURE__ */ React3.createElement(Toast.Close, {
|
|
197
|
+
asChild: true
|
|
198
|
+
}, /* @__PURE__ */ React3.createElement(Button, {
|
|
199
|
+
onClick: handleClose
|
|
200
|
+
}, t(waiting ? "close label" : "confirm label", {
|
|
201
|
+
ns: "appkit"
|
|
202
|
+
})))));
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// packages/plugins/plugin-space/src/components/BaseObjectSettings.tsx
|
|
206
|
+
import React4 from "react";
|
|
207
|
+
import { Input, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
208
|
+
var BaseObjectSettings = ({ object }) => {
|
|
209
|
+
const { t } = useTranslation4(SPACE_PLUGIN);
|
|
210
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
211
|
+
role: "form",
|
|
212
|
+
className: "flex flex-col w-full p-2 gap-1"
|
|
213
|
+
}, /* @__PURE__ */ React4.createElement(Input.Root, null, /* @__PURE__ */ React4.createElement(Input.Label, null, t("name label")), /* @__PURE__ */ React4.createElement(Input.TextInput, {
|
|
214
|
+
placeholder: t("name placeholder"),
|
|
215
|
+
value: object.name ?? "",
|
|
216
|
+
onChange: (event) => {
|
|
217
|
+
object.name = event.target.value;
|
|
218
|
+
}
|
|
219
|
+
})));
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectDialog.tsx
|
|
223
|
+
import { pipe } from "effect";
|
|
224
|
+
import React6, { useCallback as useCallback5, useRef } from "react";
|
|
225
|
+
import { chain, createIntent as createIntent2, NavigationAction as NavigationAction2, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
|
|
226
|
+
import { useClient as useClient2 } from "@dxos/react-client";
|
|
227
|
+
import { getSpace, isReactiveObject, isSpace as isSpace2, useSpaces } from "@dxos/react-client/echo";
|
|
228
|
+
import { Button as Button2, Dialog, Icon as Icon2, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
229
|
+
|
|
230
|
+
// packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectPanel.tsx
|
|
231
|
+
import React5, { useCallback as useCallback4, useMemo, useState as useState3 } from "react";
|
|
232
|
+
import { Surface, isSurfaceAvailable, usePluginManager } from "@dxos/app-framework";
|
|
233
|
+
import { getObjectAnnotation, S } from "@dxos/echo-schema";
|
|
234
|
+
import { isSpace } from "@dxos/react-client/echo";
|
|
235
|
+
import { Icon, IconButton as IconButton3, Input as Input2, toLocalizedString, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
236
|
+
import { Form as Form2, InputHeader } from "@dxos/react-ui-form";
|
|
237
|
+
import { SearchList } from "@dxos/react-ui-searchlist";
|
|
238
|
+
import { nonNullable } from "@dxos/util";
|
|
239
|
+
var useInputSurfaceLookup = (baseData) => {
|
|
240
|
+
const pluginManager = usePluginManager();
|
|
241
|
+
return useCallback4(({ prop, schema, inputProps }) => {
|
|
242
|
+
const composedData = {
|
|
243
|
+
prop,
|
|
244
|
+
schema,
|
|
245
|
+
...baseData
|
|
246
|
+
};
|
|
247
|
+
if (!isSurfaceAvailable(pluginManager.context, {
|
|
248
|
+
role: "form-input",
|
|
249
|
+
data: composedData
|
|
250
|
+
})) {
|
|
251
|
+
return void 0;
|
|
252
|
+
}
|
|
253
|
+
return /* @__PURE__ */ React5.createElement(Surface, {
|
|
254
|
+
role: "form-input",
|
|
255
|
+
data: composedData,
|
|
256
|
+
...inputProps
|
|
257
|
+
});
|
|
258
|
+
}, [
|
|
259
|
+
pluginManager,
|
|
260
|
+
baseData
|
|
261
|
+
]);
|
|
262
|
+
};
|
|
263
|
+
var CreateObjectPanel = ({ schemas, spaces, typename: initialTypename, target: initialTarget, name: initialName, defaultSpaceId, resolve, onCreateObject }) => {
|
|
264
|
+
const { t } = useTranslation5(SPACE_PLUGIN);
|
|
265
|
+
const [typename, setTypename] = useState3(initialTypename);
|
|
266
|
+
const [target, setTarget] = useState3(initialTarget);
|
|
267
|
+
const schema = schemas.find((schema2) => getObjectAnnotation(schema2)?.typename === typename);
|
|
268
|
+
const options = schemas.map(getObjectAnnotation).filter(nonNullable);
|
|
269
|
+
const handleClearSchema = useCallback4(() => setTypename(void 0), []);
|
|
270
|
+
const handleClearTarget = useCallback4(() => setTarget(void 0), []);
|
|
271
|
+
const handleCreateObject = useCallback4(async (props) => {
|
|
272
|
+
if (!schema || !target) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
await onCreateObject?.({
|
|
276
|
+
schema,
|
|
277
|
+
target,
|
|
278
|
+
data: props
|
|
279
|
+
});
|
|
280
|
+
}, [
|
|
281
|
+
onCreateObject,
|
|
282
|
+
schema,
|
|
283
|
+
target
|
|
284
|
+
]);
|
|
285
|
+
const metadata = useMemo(() => {
|
|
286
|
+
if (!typename) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
return resolve?.(typename);
|
|
290
|
+
}, [
|
|
291
|
+
resolve,
|
|
292
|
+
typename
|
|
293
|
+
]);
|
|
294
|
+
const schemaInput = /* @__PURE__ */ React5.createElement(SearchList.Root, {
|
|
295
|
+
label: t("schema input label"),
|
|
296
|
+
classNames: "flex flex-col grow overflow-hidden"
|
|
297
|
+
}, /* @__PURE__ */ React5.createElement(SearchList.Input, {
|
|
298
|
+
autoFocus: true,
|
|
299
|
+
"data-testid": "create-object-form.schema-input",
|
|
300
|
+
placeholder: t("schema input placeholder"),
|
|
301
|
+
classNames: "px-1 my-2"
|
|
302
|
+
}), /* @__PURE__ */ React5.createElement(SearchList.Content, {
|
|
303
|
+
classNames: "max-bs-[24rem] overflow-auto"
|
|
304
|
+
}, options.map((option) => /* @__PURE__ */ React5.createElement(SearchList.Item, {
|
|
305
|
+
key: option.typename,
|
|
306
|
+
value: t("typename label", {
|
|
307
|
+
ns: option.typename,
|
|
308
|
+
defaultValue: option.typename
|
|
309
|
+
}),
|
|
310
|
+
onSelect: () => setTypename(option.typename),
|
|
311
|
+
classNames: "flex items-center gap-2"
|
|
312
|
+
}, /* @__PURE__ */ React5.createElement("span", {
|
|
313
|
+
className: "flex gap-2 items-center grow truncate"
|
|
314
|
+
}, /* @__PURE__ */ React5.createElement(Icon, {
|
|
315
|
+
icon: resolve?.(option.typename).icon ?? "ph--placeholder--regular",
|
|
316
|
+
size: 5
|
|
317
|
+
}), t("typename label", {
|
|
318
|
+
ns: option.typename,
|
|
319
|
+
defaultValue: option.typename
|
|
320
|
+
}))))));
|
|
321
|
+
const spaceInput = /* @__PURE__ */ React5.createElement(SearchList.Root, {
|
|
322
|
+
label: t("space input label"),
|
|
323
|
+
classNames: "flex flex-col grow overflow-hidden"
|
|
324
|
+
}, /* @__PURE__ */ React5.createElement(SearchList.Input, {
|
|
325
|
+
autoFocus: true,
|
|
326
|
+
"data-testid": "create-object-form.space-input",
|
|
327
|
+
placeholder: t("space input placeholder"),
|
|
328
|
+
classNames: "px-1 my-2"
|
|
329
|
+
}), /* @__PURE__ */ React5.createElement(SearchList.Content, {
|
|
330
|
+
classNames: "max-bs-[24rem] overflow-auto"
|
|
331
|
+
}, spaces.map((space) => /* @__PURE__ */ React5.createElement(SearchList.Item, {
|
|
332
|
+
key: space.id,
|
|
333
|
+
value: toLocalizedString(getSpaceDisplayName(space, {
|
|
334
|
+
personal: space.id === defaultSpaceId
|
|
335
|
+
}), t),
|
|
336
|
+
onSelect: () => setTarget(space),
|
|
337
|
+
classNames: "flex items-center gap-2"
|
|
338
|
+
}, /* @__PURE__ */ React5.createElement("span", {
|
|
339
|
+
className: "grow truncate"
|
|
340
|
+
}, toLocalizedString(getSpaceDisplayName(space, {
|
|
341
|
+
personal: space.id === defaultSpaceId
|
|
342
|
+
}), t))))));
|
|
343
|
+
const inputSurfaceLookup = useInputSurfaceLookup({
|
|
344
|
+
target
|
|
345
|
+
});
|
|
346
|
+
const form = useMemo(() => {
|
|
347
|
+
const schema2 = metadata?.creationSchema ?? S.Struct({
|
|
348
|
+
name: S.optional(S.String)
|
|
349
|
+
});
|
|
350
|
+
return /* @__PURE__ */ React5.createElement(Form2, {
|
|
351
|
+
autoFocus: true,
|
|
352
|
+
values: {
|
|
353
|
+
name: initialName
|
|
354
|
+
},
|
|
355
|
+
schema: schema2,
|
|
356
|
+
testId: "create-object-form",
|
|
357
|
+
onSave: handleCreateObject,
|
|
358
|
+
lookupComponent: inputSurfaceLookup
|
|
359
|
+
});
|
|
360
|
+
}, [
|
|
361
|
+
initialName,
|
|
362
|
+
handleCreateObject,
|
|
363
|
+
metadata
|
|
364
|
+
]);
|
|
365
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
366
|
+
role: "form",
|
|
367
|
+
className: "flex flex-col gap-2"
|
|
368
|
+
}, target && /* @__PURE__ */ React5.createElement("div", {
|
|
369
|
+
role: "none"
|
|
370
|
+
}, /* @__PURE__ */ React5.createElement(Input2.Root, null, /* @__PURE__ */ React5.createElement(InputHeader, null, /* @__PURE__ */ React5.createElement(Input2.Label, null, t(isSpace(target) ? "creating in space label" : "creating in collection label"))), /* @__PURE__ */ React5.createElement("div", {
|
|
371
|
+
role: "none",
|
|
372
|
+
className: "flex gap-2"
|
|
373
|
+
}, /* @__PURE__ */ React5.createElement(Input2.TextInput, {
|
|
374
|
+
disabled: true,
|
|
375
|
+
value: isSpace(target) ? toLocalizedString(getSpaceDisplayName(target, {
|
|
376
|
+
personal: target.id === defaultSpaceId
|
|
377
|
+
}), t) : target.name || t("unnamed collection label")
|
|
378
|
+
}), /* @__PURE__ */ React5.createElement(IconButton3, {
|
|
379
|
+
iconOnly: true,
|
|
380
|
+
icon: "ph--x--regular",
|
|
381
|
+
label: t("clear input label"),
|
|
382
|
+
onClick: handleClearTarget
|
|
383
|
+
})))), schema && /* @__PURE__ */ React5.createElement("div", {
|
|
384
|
+
role: "none"
|
|
385
|
+
}, /* @__PURE__ */ React5.createElement(Input2.Root, null, /* @__PURE__ */ React5.createElement(InputHeader, null, /* @__PURE__ */ React5.createElement(Input2.Label, null, t("creating object type label"))), /* @__PURE__ */ React5.createElement("div", {
|
|
386
|
+
role: "none",
|
|
387
|
+
className: "flex gap-2"
|
|
388
|
+
}, /* @__PURE__ */ React5.createElement(Input2.TextInput, {
|
|
389
|
+
disabled: true,
|
|
390
|
+
value: t("typename label", {
|
|
391
|
+
ns: schema.typename,
|
|
392
|
+
defaultValue: schema.typename
|
|
393
|
+
})
|
|
394
|
+
}), /* @__PURE__ */ React5.createElement(IconButton3, {
|
|
395
|
+
iconOnly: true,
|
|
396
|
+
icon: "ph--x--regular",
|
|
397
|
+
label: t("clear input label"),
|
|
398
|
+
onClick: handleClearSchema
|
|
399
|
+
})))), !schema ? schemaInput : !target ? spaceInput : form);
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
// packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectDialog.tsx
|
|
403
|
+
var CREATE_OBJECT_DIALOG = `${SPACE_PLUGIN}/CreateObjectDialog`;
|
|
404
|
+
var CreateObjectDialog = ({ schemas, target, typename, name, shouldNavigate: _shouldNavigate, resolve }) => {
|
|
405
|
+
const closeRef = useRef(null);
|
|
406
|
+
const { t } = useTranslation6(SPACE_PLUGIN);
|
|
407
|
+
const client = useClient2();
|
|
408
|
+
const spaces = useSpaces();
|
|
409
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher2();
|
|
410
|
+
const handleCreateObject = useCallback5(async ({ schema, target: _target, data }) => {
|
|
411
|
+
const target2 = isSpace2(_target) ? _target.properties[CollectionType.typename]?.target : _target;
|
|
412
|
+
const createObjectIntent = resolve?.(schema.typename)?.createObject;
|
|
413
|
+
if (!createObjectIntent || !target2) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
closeRef.current?.click();
|
|
417
|
+
const space = isSpace2(target2) ? target2 : getSpace(target2);
|
|
418
|
+
const result = await dispatch(createObjectIntent(data, {
|
|
419
|
+
space
|
|
420
|
+
}));
|
|
421
|
+
const object = result.data?.object;
|
|
422
|
+
if (isReactiveObject(object)) {
|
|
423
|
+
const addObjectIntent = createIntent2(SpaceAction.AddObject, {
|
|
424
|
+
target: target2,
|
|
425
|
+
object
|
|
426
|
+
});
|
|
427
|
+
const shouldNavigate = _shouldNavigate ?? (() => true);
|
|
428
|
+
if (shouldNavigate(object)) {
|
|
429
|
+
await dispatch(pipe(addObjectIntent, chain(NavigationAction2.Open, {})));
|
|
430
|
+
} else {
|
|
431
|
+
await dispatch(addObjectIntent);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}, [
|
|
435
|
+
dispatch,
|
|
436
|
+
resolve
|
|
437
|
+
]);
|
|
438
|
+
return (
|
|
439
|
+
// TODO(wittjosiah): The tablist dialog pattern is copied from @dxos/plugin-manager.
|
|
440
|
+
// Consider factoring it out to the tabs package.
|
|
441
|
+
/* @__PURE__ */ React6.createElement(Dialog.Content, {
|
|
442
|
+
classNames: "p-0 bs-content min-bs-[15rem] max-bs-full md:max-is-[40rem] overflow-hidden"
|
|
443
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
444
|
+
role: "none",
|
|
445
|
+
className: "flex justify-between pbs-2 pis-2 pie-2 @md:pbs-4 @md:pis-4 @md:pie-4"
|
|
446
|
+
}, /* @__PURE__ */ React6.createElement(Dialog.Title, null, t("create object dialog title")), /* @__PURE__ */ React6.createElement(Dialog.Close, {
|
|
447
|
+
asChild: true
|
|
448
|
+
}, /* @__PURE__ */ React6.createElement(Button2, {
|
|
449
|
+
ref: closeRef,
|
|
450
|
+
density: "fine",
|
|
451
|
+
variant: "ghost",
|
|
452
|
+
autoFocus: true
|
|
453
|
+
}, /* @__PURE__ */ React6.createElement(Icon2, {
|
|
454
|
+
icon: "ph--x--regular",
|
|
455
|
+
size: 4
|
|
456
|
+
})))), /* @__PURE__ */ React6.createElement("div", {
|
|
457
|
+
className: "p-4"
|
|
458
|
+
}, /* @__PURE__ */ React6.createElement(CreateObjectPanel, {
|
|
459
|
+
schemas,
|
|
460
|
+
spaces,
|
|
461
|
+
target,
|
|
462
|
+
typename,
|
|
463
|
+
name,
|
|
464
|
+
defaultSpaceId: client.spaces.default.id,
|
|
465
|
+
resolve,
|
|
466
|
+
onCreateObject: handleCreateObject
|
|
467
|
+
})))
|
|
468
|
+
);
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
// packages/plugins/plugin-space/src/components/CreateDialog/CreateSpaceDialog.tsx
|
|
472
|
+
import React7, { useCallback as useCallback6, useRef as useRef2 } from "react";
|
|
473
|
+
import { createIntent as createIntent3, useIntentDispatcher as useIntentDispatcher3 } from "@dxos/app-framework";
|
|
474
|
+
import { Button as Button3, Dialog as Dialog2, Icon as Icon3, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
475
|
+
import { Form as Form3 } from "@dxos/react-ui-form";
|
|
476
|
+
var CREATE_SPACE_DIALOG = `${SPACE_PLUGIN}/CreateSpaceDialog`;
|
|
477
|
+
var initialValues2 = {
|
|
478
|
+
edgeReplication: true
|
|
479
|
+
};
|
|
480
|
+
var CreateSpaceDialog = () => {
|
|
481
|
+
const closeRef = useRef2(null);
|
|
482
|
+
const { t } = useTranslation7(SPACE_PLUGIN);
|
|
483
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher3();
|
|
484
|
+
const handleCreateSpace = useCallback6(async (data) => {
|
|
485
|
+
const result = await dispatch(createIntent3(SpaceAction.Create, data));
|
|
486
|
+
const target = result.data?.space;
|
|
487
|
+
if (target) {
|
|
488
|
+
await dispatch(createIntent3(SpaceAction.OpenCreateObject, {
|
|
489
|
+
target
|
|
490
|
+
}));
|
|
491
|
+
}
|
|
492
|
+
}, [
|
|
493
|
+
dispatch
|
|
494
|
+
]);
|
|
495
|
+
return (
|
|
496
|
+
// TODO(wittjosiah): The tablist dialog pattern is copied from @dxos/plugin-manager.
|
|
497
|
+
// Consider factoring it out to the tabs package.
|
|
498
|
+
/* @__PURE__ */ React7.createElement(Dialog2.Content, {
|
|
499
|
+
classNames: "p-0 bs-content min-bs-[15rem] max-bs-full md:max-is-[40rem] overflow-hidden"
|
|
500
|
+
}, /* @__PURE__ */ React7.createElement("div", {
|
|
501
|
+
role: "none",
|
|
502
|
+
className: "flex justify-between pbs-2 pis-2 pie-2 @md:pbs-4 @md:pis-4 @md:pie-4"
|
|
503
|
+
}, /* @__PURE__ */ React7.createElement(Dialog2.Title, null, t("create space dialog title")), /* @__PURE__ */ React7.createElement(Dialog2.Close, {
|
|
504
|
+
asChild: true
|
|
505
|
+
}, /* @__PURE__ */ React7.createElement(Button3, {
|
|
506
|
+
ref: closeRef,
|
|
507
|
+
density: "fine",
|
|
508
|
+
variant: "ghost",
|
|
509
|
+
autoFocus: true
|
|
510
|
+
}, /* @__PURE__ */ React7.createElement(Icon3, {
|
|
511
|
+
icon: "ph--x--regular",
|
|
512
|
+
size: 4
|
|
513
|
+
})))), /* @__PURE__ */ React7.createElement("div", {
|
|
514
|
+
className: "p-4"
|
|
515
|
+
}, /* @__PURE__ */ React7.createElement(Form3, {
|
|
516
|
+
testId: "create-space-form",
|
|
517
|
+
values: initialValues2,
|
|
518
|
+
schema: SpaceForm,
|
|
519
|
+
onSave: handleCreateSpace
|
|
520
|
+
})))
|
|
521
|
+
);
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
// packages/plugins/plugin-space/src/components/CollectionMain.tsx
|
|
525
|
+
import React8 from "react";
|
|
526
|
+
import { useTranslation as useTranslation8 } from "@dxos/react-ui";
|
|
527
|
+
import { baseSurface, descriptionText, mx as mx2 } from "@dxos/react-ui-theme";
|
|
528
|
+
var CollectionMain = ({ collection }) => {
|
|
529
|
+
const { t } = useTranslation8(SPACE_PLUGIN);
|
|
530
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
531
|
+
role: "none",
|
|
532
|
+
className: mx2(baseSurface, "min-bs-screen is-full flex items-center justify-center p-8"),
|
|
533
|
+
"data-testid": "composer.firstRunMessage"
|
|
534
|
+
}, /* @__PURE__ */ React8.createElement("p", {
|
|
535
|
+
role: "alert",
|
|
536
|
+
className: mx2(descriptionText, "border border-dashed border-neutral-400/50 rounded-lg p-8 font-normal text-lg max-is-[24rem] break-words")
|
|
537
|
+
}, collection.name ?? t("unnamed collection label")));
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
// packages/plugins/plugin-space/src/components/CollectionSection.tsx
|
|
541
|
+
import React9 from "react";
|
|
542
|
+
import { useTranslation as useTranslation9 } from "@dxos/react-ui";
|
|
543
|
+
var CollectionSection = ({ collection }) => {
|
|
544
|
+
const { t } = useTranslation9(SPACE_PLUGIN);
|
|
545
|
+
return /* @__PURE__ */ React9.createElement("div", {
|
|
546
|
+
className: "min-bs-[3.5rem] grid grid-rows-subgrid grid-cols-subgrid items-center"
|
|
547
|
+
}, /* @__PURE__ */ React9.createElement("span", {
|
|
548
|
+
className: "truncate"
|
|
549
|
+
}, collection.name ?? t("unnamed collection label")));
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
// packages/plugins/plugin-space/src/components/JoinDialog.tsx
|
|
553
|
+
import React10, { useCallback as useCallback7 } from "react";
|
|
554
|
+
import { createIntent as createIntent4, LayoutAction, NavigationAction as NavigationAction3, useIntentDispatcher as useIntentDispatcher4 } from "@dxos/app-framework";
|
|
555
|
+
import { useGraph } from "@dxos/plugin-graph";
|
|
556
|
+
import { ObservabilityAction } from "@dxos/plugin-observability/types";
|
|
557
|
+
import { useSpaces as useSpaces2 } from "@dxos/react-client/echo";
|
|
558
|
+
import { Dialog as Dialog3, useTranslation as useTranslation10 } from "@dxos/react-ui";
|
|
559
|
+
import { JoinPanel } from "@dxos/shell/react";
|
|
560
|
+
var JOIN_DIALOG = `${SPACE_PLUGIN}/JoinDialog`;
|
|
561
|
+
var JoinDialog = ({ navigableCollections, onDone, ...props }) => {
|
|
562
|
+
const { t } = useTranslation10(SPACE_PLUGIN);
|
|
563
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher4();
|
|
564
|
+
const spaces = useSpaces2();
|
|
565
|
+
const { graph } = useGraph();
|
|
566
|
+
const handleDone = useCallback7(async (result) => {
|
|
567
|
+
if (result?.spaceKey) {
|
|
568
|
+
await Promise.all([
|
|
569
|
+
dispatch(createIntent4(LayoutAction.SetLayout, {
|
|
570
|
+
element: "toast",
|
|
571
|
+
subject: {
|
|
572
|
+
id: `${SPACE_PLUGIN}/join-success`,
|
|
573
|
+
duration: 5e3,
|
|
574
|
+
title: t("join success label"),
|
|
575
|
+
closeLabel: t("dismiss label")
|
|
576
|
+
}
|
|
577
|
+
})),
|
|
578
|
+
dispatch(createIntent4(LayoutAction.SetLayout, {
|
|
579
|
+
element: "dialog",
|
|
580
|
+
state: false
|
|
581
|
+
}))
|
|
582
|
+
]);
|
|
583
|
+
}
|
|
584
|
+
const space = spaces.find(({ key }) => result?.spaceKey?.equals(key));
|
|
585
|
+
const target = result?.target || (navigableCollections ? space?.id : void 0);
|
|
586
|
+
if (target) {
|
|
587
|
+
await graph.waitForPath({
|
|
588
|
+
target
|
|
589
|
+
}).catch(() => {
|
|
590
|
+
});
|
|
591
|
+
await Promise.all([
|
|
592
|
+
dispatch(createIntent4(NavigationAction3.Open, {
|
|
593
|
+
activeParts: {
|
|
594
|
+
main: [
|
|
595
|
+
target
|
|
596
|
+
]
|
|
597
|
+
}
|
|
598
|
+
})),
|
|
599
|
+
dispatch(createIntent4(NavigationAction3.Expose, {
|
|
600
|
+
id: target
|
|
601
|
+
}))
|
|
602
|
+
]);
|
|
603
|
+
}
|
|
604
|
+
await onDone?.(result);
|
|
605
|
+
if (space) {
|
|
606
|
+
await dispatch(createIntent4(ObservabilityAction.SendEvent, {
|
|
607
|
+
name: "space.join",
|
|
608
|
+
properties: {
|
|
609
|
+
spaceId: space.id
|
|
610
|
+
}
|
|
611
|
+
}));
|
|
612
|
+
}
|
|
613
|
+
}, [
|
|
614
|
+
dispatch,
|
|
615
|
+
spaces
|
|
616
|
+
]);
|
|
617
|
+
return /* @__PURE__ */ React10.createElement(Dialog3.Content, null, /* @__PURE__ */ React10.createElement(JoinPanel, {
|
|
618
|
+
...props,
|
|
619
|
+
exitActionParent: /* @__PURE__ */ React10.createElement(Dialog3.Close, {
|
|
620
|
+
asChild: true
|
|
621
|
+
}),
|
|
622
|
+
doneActionParent: /* @__PURE__ */ React10.createElement(Dialog3.Close, {
|
|
623
|
+
asChild: true
|
|
624
|
+
}),
|
|
625
|
+
onDone: handleDone
|
|
626
|
+
}));
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
// packages/plugins/plugin-space/src/components/MenuFooter.tsx
|
|
630
|
+
import { Planet } from "@phosphor-icons/react";
|
|
631
|
+
import React11 from "react";
|
|
632
|
+
import { getSpace as getSpace2 } from "@dxos/client/echo";
|
|
633
|
+
import { useClient as useClient3 } from "@dxos/react-client";
|
|
634
|
+
import { DropdownMenu, toLocalizedString as toLocalizedString2, useTranslation as useTranslation11 } from "@dxos/react-ui";
|
|
635
|
+
var MenuFooter = ({ object }) => {
|
|
636
|
+
const { t } = useTranslation11(SPACE_PLUGIN);
|
|
637
|
+
const client = useClient3();
|
|
638
|
+
const space = getSpace2(object);
|
|
639
|
+
const spaceName = space ? getSpaceDisplayName(space, {
|
|
640
|
+
personal: client.spaces.default === space
|
|
641
|
+
}) : "";
|
|
642
|
+
return space ? /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(DropdownMenu.Separator, null), /* @__PURE__ */ React11.createElement(DropdownMenu.GroupLabel, null, t("menu footer label")), /* @__PURE__ */ React11.createElement("dl", {
|
|
643
|
+
className: "pis-2 mbe-2 text-xs grid grid-cols-[max-content_1fr] gap-2"
|
|
644
|
+
}, /* @__PURE__ */ React11.createElement("dt", {
|
|
645
|
+
className: "uppercase text-[.75em] tracking-wide font-medium mbs-px self-start"
|
|
646
|
+
}, t("location label")), /* @__PURE__ */ React11.createElement("dd", {
|
|
647
|
+
className: "line-clamp-3"
|
|
648
|
+
}, /* @__PURE__ */ React11.createElement(Planet, {
|
|
649
|
+
className: "inline-block mie-1"
|
|
650
|
+
}), toLocalizedString2(spaceName, t)))) : null;
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
// packages/plugins/plugin-space/src/components/PersistenceStatus.tsx
|
|
654
|
+
import { ArrowsCounterClockwise, CheckCircle as CheckCircle2, Warning } from "@phosphor-icons/react";
|
|
655
|
+
import React12, { useEffect as useEffect2, useState as useState4 } from "react";
|
|
656
|
+
import { debounce } from "@dxos/async";
|
|
657
|
+
import { Tooltip, useTranslation as useTranslation12 } from "@dxos/react-ui";
|
|
658
|
+
import { getSize as getSize2, mx as mx3, staticPlaceholderText, warningText } from "@dxos/react-ui-theme";
|
|
659
|
+
var Status;
|
|
660
|
+
(function(Status2) {
|
|
661
|
+
Status2[Status2["PERSISTED_LOCALLY"] = 0] = "PERSISTED_LOCALLY";
|
|
662
|
+
Status2[Status2["PENDING"] = 1] = "PENDING";
|
|
663
|
+
Status2[Status2["ERROR"] = 2] = "ERROR";
|
|
664
|
+
})(Status || (Status = {}));
|
|
665
|
+
var PersistenceStatus = ({ db }) => {
|
|
666
|
+
const { t } = useTranslation12(SPACE_PLUGIN);
|
|
667
|
+
const [displayMessage, setDisplayMessage] = useState4(false);
|
|
668
|
+
const [status, naturalSetStatus] = useState4(0);
|
|
669
|
+
const [prevStatus, setPrevStatus] = useState4(0);
|
|
670
|
+
const _setStatus = debounce(naturalSetStatus, 500);
|
|
671
|
+
useEffect2(() => {
|
|
672
|
+
setPrevStatus(status);
|
|
673
|
+
if (prevStatus !== status && status === 0) {
|
|
674
|
+
setDisplayMessage(true);
|
|
675
|
+
const timeout = setTimeout(() => setDisplayMessage(false), 5e3);
|
|
676
|
+
return () => clearTimeout(timeout);
|
|
677
|
+
}
|
|
678
|
+
}, [
|
|
679
|
+
status
|
|
680
|
+
]);
|
|
681
|
+
switch (status) {
|
|
682
|
+
case 2:
|
|
683
|
+
return /* @__PURE__ */ React12.createElement("div", {
|
|
684
|
+
className: "flex items-center"
|
|
685
|
+
}, /* @__PURE__ */ React12.createElement(Warning, {
|
|
686
|
+
className: mx3(getSize2(4), "me-1")
|
|
687
|
+
}), /* @__PURE__ */ React12.createElement("span", {
|
|
688
|
+
className: mx3("text-sm", warningText)
|
|
689
|
+
}, t("persistence error label")));
|
|
690
|
+
case 1:
|
|
691
|
+
return /* @__PURE__ */ React12.createElement("div", {
|
|
692
|
+
className: "flex items-center"
|
|
693
|
+
}, /* @__PURE__ */ React12.createElement(ArrowsCounterClockwise, {
|
|
694
|
+
className: mx3(getSize2(4), "me-1")
|
|
695
|
+
}), /* @__PURE__ */ React12.createElement("span", {
|
|
696
|
+
className: mx3("text-sm", staticPlaceholderText)
|
|
697
|
+
}, t("persistence pending label")));
|
|
698
|
+
case 0:
|
|
699
|
+
default:
|
|
700
|
+
return /* @__PURE__ */ React12.createElement(Tooltip.Root, {
|
|
701
|
+
delayDuration: 400
|
|
702
|
+
}, /* @__PURE__ */ React12.createElement(Tooltip.Trigger, {
|
|
703
|
+
role: "status",
|
|
704
|
+
className: "flex items-center"
|
|
705
|
+
}, /* @__PURE__ */ React12.createElement(CheckCircle2, {
|
|
706
|
+
className: mx3(getSize2(4), "me-1")
|
|
707
|
+
}), displayMessage && /* @__PURE__ */ React12.createElement("span", {
|
|
708
|
+
className: mx3("text-sm", staticPlaceholderText)
|
|
709
|
+
}, t("persisted locally label"))), /* @__PURE__ */ React12.createElement(Tooltip.Portal, null, /* @__PURE__ */ React12.createElement(Tooltip.Content, null, t("persisted locally message"), /* @__PURE__ */ React12.createElement(Tooltip.Arrow, null))));
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
// packages/plugins/plugin-space/src/components/PopoverRenameObject.tsx
|
|
714
|
+
import React13, { useCallback as useCallback8, useRef as useRef3, useState as useState5 } from "react";
|
|
715
|
+
import { log } from "@dxos/log";
|
|
716
|
+
import { Button as Button4, Input as Input3, Popover, useTranslation as useTranslation13 } from "@dxos/react-ui";
|
|
717
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/PopoverRenameObject.tsx";
|
|
718
|
+
var POPOVER_RENAME_OBJECT = `${SPACE_PLUGIN}/PopoverRenameObject`;
|
|
719
|
+
var PopoverRenameObject = ({ object: obj }) => {
|
|
720
|
+
const { t } = useTranslation13(SPACE_PLUGIN);
|
|
721
|
+
const doneButton = useRef3(null);
|
|
722
|
+
const object = obj;
|
|
723
|
+
const [name, setName] = useState5(object.name || object.title || "");
|
|
724
|
+
const handleDone = useCallback8(() => {
|
|
725
|
+
try {
|
|
726
|
+
object.name = name;
|
|
727
|
+
} catch {
|
|
728
|
+
try {
|
|
729
|
+
object.title = name;
|
|
730
|
+
} catch (err) {
|
|
731
|
+
log.error("Failed to rename object", {
|
|
732
|
+
err
|
|
733
|
+
}, {
|
|
734
|
+
F: __dxlog_file,
|
|
735
|
+
L: 30,
|
|
736
|
+
S: void 0,
|
|
737
|
+
C: (f, a) => f(...a)
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
}, [
|
|
742
|
+
object,
|
|
743
|
+
name
|
|
744
|
+
]);
|
|
745
|
+
return /* @__PURE__ */ React13.createElement("div", {
|
|
746
|
+
role: "none",
|
|
747
|
+
className: "p-1 flex gap-2"
|
|
748
|
+
}, /* @__PURE__ */ React13.createElement("div", {
|
|
749
|
+
role: "none",
|
|
750
|
+
className: "flex-1"
|
|
751
|
+
}, /* @__PURE__ */ React13.createElement(Input3.Root, null, /* @__PURE__ */ React13.createElement(Input3.Label, {
|
|
752
|
+
srOnly: true
|
|
753
|
+
}, t("object name label")), /* @__PURE__ */ React13.createElement(Input3.TextInput, {
|
|
754
|
+
placeholder: t("object title placeholder"),
|
|
755
|
+
value: name,
|
|
756
|
+
"data-testid": "spacePlugin.renameObject.input",
|
|
757
|
+
onChange: ({ target: { value } }) => setName(value),
|
|
758
|
+
onKeyDown: ({ key }) => key === "Enter" && doneButton.current?.click()
|
|
759
|
+
}))), /* @__PURE__ */ React13.createElement(Popover.Close, {
|
|
760
|
+
asChild: true
|
|
761
|
+
}, /* @__PURE__ */ React13.createElement(Button4, {
|
|
762
|
+
ref: doneButton,
|
|
763
|
+
classNames: "self-stretch",
|
|
764
|
+
onClick: handleDone
|
|
765
|
+
}, t("done label", {
|
|
766
|
+
ns: "os"
|
|
767
|
+
}))));
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
// packages/plugins/plugin-space/src/components/PopoverRenameSpace.tsx
|
|
771
|
+
import React14, { useCallback as useCallback9, useRef as useRef4, useState as useState6 } from "react";
|
|
772
|
+
import { Button as Button5, Input as Input4, Popover as Popover2, useTranslation as useTranslation14 } from "@dxos/react-ui";
|
|
773
|
+
var POPOVER_RENAME_SPACE = `${SPACE_PLUGIN}/PopoverRenameSpace`;
|
|
774
|
+
var PopoverRenameSpace = ({ space }) => {
|
|
775
|
+
const { t } = useTranslation14(SPACE_PLUGIN);
|
|
776
|
+
const doneButton = useRef4(null);
|
|
777
|
+
const [name, setName] = useState6(space.properties.name ?? "");
|
|
778
|
+
const handleDone = useCallback9(() => {
|
|
779
|
+
space.properties.name = name;
|
|
780
|
+
}, [
|
|
781
|
+
space,
|
|
782
|
+
name
|
|
783
|
+
]);
|
|
784
|
+
return /* @__PURE__ */ React14.createElement("div", {
|
|
785
|
+
role: "none",
|
|
786
|
+
className: "p-1 flex gap-2"
|
|
787
|
+
}, /* @__PURE__ */ React14.createElement("div", {
|
|
788
|
+
role: "none",
|
|
789
|
+
className: "flex-1"
|
|
790
|
+
}, /* @__PURE__ */ React14.createElement(Input4.Root, null, /* @__PURE__ */ React14.createElement(Input4.Label, {
|
|
791
|
+
srOnly: true
|
|
792
|
+
}, t("space name label")), /* @__PURE__ */ React14.createElement(Input4.TextInput, {
|
|
793
|
+
defaultValue: space.properties.name ?? "",
|
|
794
|
+
placeholder: t("unnamed space label"),
|
|
795
|
+
onChange: ({ target: { value } }) => setName(value),
|
|
796
|
+
// TODO(wittjosiah): Ideally this should access the popover context to close the popover.
|
|
797
|
+
// Currently this is not possible because Radix does not expose the popover context.
|
|
798
|
+
onKeyDown: ({ key }) => key === "Enter" && doneButton.current?.click()
|
|
799
|
+
}))), /* @__PURE__ */ React14.createElement(Popover2.Close, {
|
|
800
|
+
asChild: true
|
|
801
|
+
}, /* @__PURE__ */ React14.createElement(Button5, {
|
|
802
|
+
ref: doneButton,
|
|
803
|
+
classNames: "self-stretch",
|
|
804
|
+
onClick: handleDone
|
|
805
|
+
}, t("done label", {
|
|
806
|
+
ns: "os"
|
|
807
|
+
}))));
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
// packages/plugins/plugin-space/src/components/ShareSpaceButton.tsx
|
|
811
|
+
import React15 from "react";
|
|
812
|
+
import { createIntent as createIntent5, useIntentDispatcher as useIntentDispatcher5 } from "@dxos/app-framework";
|
|
813
|
+
import { IconButton as IconButton4, useTranslation as useTranslation15 } from "@dxos/react-ui";
|
|
814
|
+
var ShareSpaceButton = ({ space }) => {
|
|
815
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher5();
|
|
816
|
+
return /* @__PURE__ */ React15.createElement(ShareSpaceButtonImpl, {
|
|
817
|
+
onClick: () => dispatch(createIntent5(SpaceAction.Share, {
|
|
818
|
+
space
|
|
819
|
+
}))
|
|
820
|
+
});
|
|
821
|
+
};
|
|
822
|
+
var ShareSpaceButtonImpl = ({ onClick }) => {
|
|
823
|
+
const { t } = useTranslation15(SPACE_PLUGIN);
|
|
824
|
+
return /* @__PURE__ */ React15.createElement(IconButton4, {
|
|
825
|
+
"data-testid": "spacePlugin.shareSpaceButton",
|
|
826
|
+
icon: "ph--users--regular",
|
|
827
|
+
label: t("share space label"),
|
|
828
|
+
onClick
|
|
829
|
+
});
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
// packages/plugins/plugin-space/src/components/SpacePresence.tsx
|
|
833
|
+
import React16, { useCallback as useCallback10, useEffect as useEffect4, useState as useState8 } from "react";
|
|
834
|
+
import { useCapability as useCapability2 } from "@dxos/app-framework";
|
|
835
|
+
import { generateName } from "@dxos/display-name";
|
|
836
|
+
import { useGraph as useGraph2 } from "@dxos/plugin-graph";
|
|
837
|
+
import { PublicKey, useClient as useClient4 } from "@dxos/react-client";
|
|
838
|
+
import { getSpace as getSpace3, useMembers, fullyQualifiedId as fullyQualifiedId2 } from "@dxos/react-client/echo";
|
|
839
|
+
import { useIdentity } from "@dxos/react-client/halo";
|
|
840
|
+
import { Avatar, AvatarGroup, AvatarGroupItem, Tooltip as Tooltip2, useTranslation as useTranslation16, List as List2, ListItem as ListItem2, useDefaultValue } from "@dxos/react-ui";
|
|
841
|
+
import { AttentionGlyph, useAttended, useAttention } from "@dxos/react-ui-attention";
|
|
842
|
+
import { ComplexMap, keyToFallback } from "@dxos/util";
|
|
843
|
+
|
|
844
|
+
// packages/plugins/plugin-space/src/capabilities/index.ts
|
|
845
|
+
import { lazy } from "@dxos/app-framework";
|
|
846
|
+
var AppGraphBuilder = lazy(() => import("./app-graph-builder-5D2QB43K.mjs"));
|
|
847
|
+
var AppGraphSerializer = lazy(() => import("./app-graph-serializer-VNWPLPDF.mjs"));
|
|
848
|
+
var IdentityCreated = lazy(() => import("./identity-created-EC5FOCX2.mjs"));
|
|
849
|
+
var IntentResolver = lazy(() => import("./intent-resolver-VBL572N7.mjs"));
|
|
850
|
+
var ReactRoot = lazy(() => import("./react-root-AZJFNTKK.mjs"));
|
|
851
|
+
var ReactSurface = lazy(() => import("./react-surface-E2VSYVNZ.mjs"));
|
|
852
|
+
var SpaceSettings = lazy(() => import("./settings-ASFF5BZL.mjs"));
|
|
853
|
+
var SpaceState = lazy(() => import("./state-MS4KYJWI.mjs"));
|
|
854
|
+
var SpacesReady = lazy(() => import("./spaces-ready-4SFNS5JQ.mjs"));
|
|
855
|
+
|
|
856
|
+
// packages/plugins/plugin-space/src/hooks/usePath.ts
|
|
857
|
+
import { useEffect as useEffect3, useState as useState7 } from "react";
|
|
858
|
+
var usePath = (graph, id, timeout) => {
|
|
859
|
+
const [pathState, setPathState] = useState7(id ? graph.getPath({
|
|
860
|
+
target: id
|
|
861
|
+
}) : void 0);
|
|
862
|
+
useEffect3(() => {
|
|
863
|
+
if (!id && pathState) {
|
|
864
|
+
setPathState(void 0);
|
|
865
|
+
}
|
|
866
|
+
if (pathState?.at(-1) === id || !id) {
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
const frame = requestAnimationFrame(async () => {
|
|
870
|
+
try {
|
|
871
|
+
const path = await graph.waitForPath({
|
|
872
|
+
target: id
|
|
873
|
+
}, {
|
|
874
|
+
timeout
|
|
875
|
+
});
|
|
876
|
+
if (path) {
|
|
877
|
+
setPathState(path);
|
|
878
|
+
}
|
|
879
|
+
} catch {
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
return () => cancelAnimationFrame(frame);
|
|
883
|
+
}, [
|
|
884
|
+
graph,
|
|
885
|
+
id,
|
|
886
|
+
timeout,
|
|
887
|
+
pathState
|
|
888
|
+
]);
|
|
889
|
+
return pathState;
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
// packages/plugins/plugin-space/src/components/SpacePresence.tsx
|
|
893
|
+
var REFRESH_INTERVAL = 5e3;
|
|
894
|
+
var ACTIVITY_DURATION = 3e4;
|
|
895
|
+
var noViewers = new ComplexMap(PublicKey.hash);
|
|
896
|
+
var getName = (identity) => identity.profile?.displayName ?? generateName(identity.identityKey.toHex());
|
|
897
|
+
var SpacePresence = ({ object, spaceKey }) => {
|
|
898
|
+
const spaceState = useCapability2(SpaceCapabilities.MutableState);
|
|
899
|
+
const client = useClient4();
|
|
900
|
+
const identity = useIdentity();
|
|
901
|
+
const space = spaceKey ? client.spaces.get(spaceKey) : getSpace3(object);
|
|
902
|
+
const spaceMembers = useMembers(space?.key);
|
|
903
|
+
const [_moment, setMoment] = useState8(Date.now());
|
|
904
|
+
useEffect4(() => {
|
|
905
|
+
const interval = setInterval(() => setMoment(Date.now()), REFRESH_INTERVAL);
|
|
906
|
+
return () => clearInterval(interval);
|
|
907
|
+
}, []);
|
|
908
|
+
const memberOnline = useCallback10((member) => member.presence === 1, []);
|
|
909
|
+
const memberIsNotSelf = useCallback10((member) => !identity?.identityKey.equals(member.identity.identityKey), [
|
|
910
|
+
identity?.identityKey
|
|
911
|
+
]);
|
|
912
|
+
if (!identity || !spaceState || !space) {
|
|
913
|
+
return null;
|
|
914
|
+
}
|
|
915
|
+
const currentObjectViewers = spaceState.viewersByObject[fullyQualifiedId2(object)] ?? noViewers;
|
|
916
|
+
const membersForObject = spaceMembers.filter((member) => memberOnline(member) && memberIsNotSelf(member)).filter((member) => currentObjectViewers.has(member.identity.identityKey)).map((member) => {
|
|
917
|
+
const objectView = currentObjectViewers.get(member.identity.identityKey);
|
|
918
|
+
const lastSeen = objectView?.lastSeen ?? -Infinity;
|
|
919
|
+
const currentlyAttended = objectView?.currentlyAttended ?? false;
|
|
920
|
+
return {
|
|
921
|
+
...member,
|
|
922
|
+
currentlyAttended,
|
|
923
|
+
lastSeen
|
|
924
|
+
};
|
|
925
|
+
}).toSorted((a, b) => a.lastSeen - b.lastSeen);
|
|
926
|
+
return /* @__PURE__ */ React16.createElement(FullPresence, {
|
|
927
|
+
members: membersForObject
|
|
928
|
+
});
|
|
929
|
+
};
|
|
930
|
+
var FullPresence = (props) => {
|
|
931
|
+
const { size = 9, onMemberClick } = props;
|
|
932
|
+
const members = useDefaultValue(props.members, () => []);
|
|
933
|
+
if (members.length === 0) {
|
|
934
|
+
return null;
|
|
935
|
+
}
|
|
936
|
+
return /* @__PURE__ */ React16.createElement(AvatarGroup.Root, {
|
|
937
|
+
size,
|
|
938
|
+
classNames: "mbs-2 mie-4",
|
|
939
|
+
"data-testid": "spacePlugin.presence"
|
|
940
|
+
}, members.slice(0, 3).map((member, i) => /* @__PURE__ */ React16.createElement(Tooltip2.Root, {
|
|
941
|
+
key: member.identity.identityKey.toHex()
|
|
942
|
+
}, /* @__PURE__ */ React16.createElement(Tooltip2.Trigger, null, /* @__PURE__ */ React16.createElement(PrensenceAvatar, {
|
|
943
|
+
identity: member.identity,
|
|
944
|
+
group: true,
|
|
945
|
+
match: member.currentlyAttended,
|
|
946
|
+
index: members.length - i,
|
|
947
|
+
onClick: () => onMemberClick?.(member)
|
|
948
|
+
})), /* @__PURE__ */ React16.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React16.createElement(Tooltip2.Content, {
|
|
949
|
+
side: "bottom"
|
|
950
|
+
}, /* @__PURE__ */ React16.createElement("span", null, getName(member.identity)), /* @__PURE__ */ React16.createElement(Tooltip2.Arrow, null))))), members.length > 3 && /* @__PURE__ */ React16.createElement(Tooltip2.Root, null, /* @__PURE__ */ React16.createElement(Tooltip2.Trigger, null, /* @__PURE__ */ React16.createElement(AvatarGroupItem.Root, {
|
|
951
|
+
status: "inactive"
|
|
952
|
+
}, /* @__PURE__ */ React16.createElement(Avatar.Frame, {
|
|
953
|
+
style: {
|
|
954
|
+
zIndex: members.length - 4
|
|
955
|
+
}
|
|
956
|
+
}, /* @__PURE__ */ React16.createElement(Avatar.Fallback, {
|
|
957
|
+
text: `+${members.length - 3}`
|
|
958
|
+
})))), /* @__PURE__ */ React16.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React16.createElement(Tooltip2.Content, {
|
|
959
|
+
side: "bottom"
|
|
960
|
+
}, /* @__PURE__ */ React16.createElement(Tooltip2.Arrow, null), /* @__PURE__ */ React16.createElement(List2, {
|
|
961
|
+
classNames: "max-h-56 overflow-y-auto"
|
|
962
|
+
}, members.map((member) => /* @__PURE__ */ React16.createElement(ListItem2.Root, {
|
|
963
|
+
key: member.identity.identityKey.toHex(),
|
|
964
|
+
classNames: "flex gap-2 items-center cursor-pointer mbe-2",
|
|
965
|
+
onClick: () => onMemberClick?.(member),
|
|
966
|
+
"data-testid": "identity-list-item"
|
|
967
|
+
}, /* @__PURE__ */ React16.createElement(PrensenceAvatar, {
|
|
968
|
+
identity: member.identity,
|
|
969
|
+
showName: true,
|
|
970
|
+
match: member.currentlyAttended
|
|
971
|
+
}))))))));
|
|
972
|
+
};
|
|
973
|
+
var PrensenceAvatar = ({ identity, showName, match, group, index, onClick }) => {
|
|
974
|
+
const Root = group ? AvatarGroupItem.Root : Avatar.Root;
|
|
975
|
+
const status = match ? "current" : "active";
|
|
976
|
+
const fallbackValue = keyToFallback(identity.identityKey);
|
|
977
|
+
return /* @__PURE__ */ React16.createElement(Root, {
|
|
978
|
+
status,
|
|
979
|
+
hue: identity.profile?.data?.hue || fallbackValue.hue
|
|
980
|
+
}, /* @__PURE__ */ React16.createElement(Avatar.Frame, {
|
|
981
|
+
"data-testid": "spacePlugin.presence.member",
|
|
982
|
+
"data-status": status,
|
|
983
|
+
...index ? {
|
|
984
|
+
style: {
|
|
985
|
+
zIndex: index
|
|
986
|
+
}
|
|
987
|
+
} : {},
|
|
988
|
+
onClick: () => onClick?.()
|
|
989
|
+
}, /* @__PURE__ */ React16.createElement(Avatar.Fallback, {
|
|
990
|
+
text: identity.profile?.data?.emoji || fallbackValue.emoji
|
|
991
|
+
})), showName && /* @__PURE__ */ React16.createElement(Avatar.Label, {
|
|
992
|
+
classNames: "text-sm truncate pli-2"
|
|
993
|
+
}, getName(identity)));
|
|
994
|
+
};
|
|
995
|
+
var SmallPresenceLive = ({ id, open, viewers }) => {
|
|
996
|
+
const { hasAttention, isAncestor, isRelated } = useAttention(id);
|
|
997
|
+
const isAttended = hasAttention || isAncestor || isRelated;
|
|
998
|
+
const { graph } = useGraph2();
|
|
999
|
+
const attended = useAttended();
|
|
1000
|
+
const startOfAttention = attended.at(-1);
|
|
1001
|
+
const path = usePath(graph, startOfAttention);
|
|
1002
|
+
const containsAttended = !open && !isAttended && id && path ? path.includes(id) : false;
|
|
1003
|
+
const getActiveViewers = (viewers2) => {
|
|
1004
|
+
const moment = Date.now();
|
|
1005
|
+
return Array.from(viewers2.values()).filter((viewer) => moment - viewer.lastSeen < ACTIVITY_DURATION);
|
|
1006
|
+
};
|
|
1007
|
+
const [activeViewers, setActiveViewers] = useState8(viewers ? getActiveViewers(viewers) : []);
|
|
1008
|
+
useEffect4(() => {
|
|
1009
|
+
if (viewers) {
|
|
1010
|
+
setActiveViewers(getActiveViewers(viewers));
|
|
1011
|
+
const interval = setInterval(() => {
|
|
1012
|
+
setActiveViewers(getActiveViewers(viewers));
|
|
1013
|
+
}, REFRESH_INTERVAL);
|
|
1014
|
+
return () => clearInterval(interval);
|
|
1015
|
+
}
|
|
1016
|
+
}, [
|
|
1017
|
+
viewers
|
|
1018
|
+
]);
|
|
1019
|
+
return /* @__PURE__ */ React16.createElement(SmallPresence, {
|
|
1020
|
+
count: activeViewers.length,
|
|
1021
|
+
attended: isAttended,
|
|
1022
|
+
containsAttended
|
|
1023
|
+
});
|
|
1024
|
+
};
|
|
1025
|
+
var SmallPresence = ({ count = 0, attended, containsAttended }) => {
|
|
1026
|
+
const { t } = useTranslation16(SPACE_PLUGIN);
|
|
1027
|
+
return /* @__PURE__ */ React16.createElement(Tooltip2.Root, null, /* @__PURE__ */ React16.createElement(Tooltip2.Trigger, {
|
|
1028
|
+
asChild: true
|
|
1029
|
+
}, /* @__PURE__ */ React16.createElement(AttentionGlyph, {
|
|
1030
|
+
attended,
|
|
1031
|
+
containsAttended,
|
|
1032
|
+
presence: count > 1 ? "many" : count === 1 ? "one" : "none",
|
|
1033
|
+
classNames: "self-center mie-1"
|
|
1034
|
+
})), /* @__PURE__ */ React16.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React16.createElement(Tooltip2.Content, {
|
|
1035
|
+
side: "bottom"
|
|
1036
|
+
}, /* @__PURE__ */ React16.createElement("span", null, t("presence label", {
|
|
1037
|
+
count
|
|
1038
|
+
})), /* @__PURE__ */ React16.createElement(Tooltip2.Arrow, null))));
|
|
1039
|
+
};
|
|
1040
|
+
|
|
1041
|
+
// packages/plugins/plugin-space/src/components/SpacePluginSettings.tsx
|
|
1042
|
+
import React17 from "react";
|
|
1043
|
+
import { Input as Input5, useTranslation as useTranslation17 } from "@dxos/react-ui";
|
|
1044
|
+
import { DeprecatedFormInput } from "@dxos/react-ui-form";
|
|
1045
|
+
var SpacePluginSettings = ({ settings }) => {
|
|
1046
|
+
const { t } = useTranslation17(SPACE_PLUGIN);
|
|
1047
|
+
return /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(DeprecatedFormInput, {
|
|
1048
|
+
label: t("show hidden spaces label")
|
|
1049
|
+
}, /* @__PURE__ */ React17.createElement(Input5.Switch, {
|
|
1050
|
+
checked: settings.showHidden,
|
|
1051
|
+
onCheckedChange: (checked) => settings.showHidden = !!checked
|
|
1052
|
+
})));
|
|
1053
|
+
};
|
|
1054
|
+
|
|
1055
|
+
// packages/plugins/plugin-space/src/components/SpaceSettings/SpaceSettingsPanel.tsx
|
|
1056
|
+
import React18, { useCallback as useCallback11, useState as useState9 } from "react";
|
|
1057
|
+
import { log as log2 } from "@dxos/log";
|
|
1058
|
+
import { EdgeReplicationSetting } from "@dxos/protocols/proto/dxos/echo/metadata";
|
|
1059
|
+
import { useClient as useClient5 } from "@dxos/react-client";
|
|
1060
|
+
import { Input as Input6, useTranslation as useTranslation18 } from "@dxos/react-ui";
|
|
1061
|
+
import { DeprecatedFormInput as DeprecatedFormInput2 } from "@dxos/react-ui-form";
|
|
1062
|
+
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
1063
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/SpaceSettings/SpaceSettingsPanel.tsx";
|
|
1064
|
+
var SpaceSettingsPanel = ({ classNames, space }) => {
|
|
1065
|
+
const { t } = useTranslation18(SPACE_PLUGIN);
|
|
1066
|
+
const client = useClient5();
|
|
1067
|
+
const edgeEnabled = Boolean(client.config.values.runtime?.client?.edgeFeatures?.echoReplicator);
|
|
1068
|
+
const [edgeReplication, setEdgeReplication] = useState9(space.internal.data.edgeReplication === EdgeReplicationSetting.ENABLED);
|
|
1069
|
+
const toggleEdgeReplication = useCallback11(async (next) => {
|
|
1070
|
+
setEdgeReplication(next);
|
|
1071
|
+
await space?.internal.setEdgeReplicationPreference(next ? EdgeReplicationSetting.ENABLED : EdgeReplicationSetting.DISABLED).catch((err) => {
|
|
1072
|
+
log2.catch(err, void 0, {
|
|
1073
|
+
F: __dxlog_file2,
|
|
1074
|
+
L: 36,
|
|
1075
|
+
S: void 0,
|
|
1076
|
+
C: (f, a) => f(...a)
|
|
1077
|
+
});
|
|
1078
|
+
setEdgeReplication(!next);
|
|
1079
|
+
});
|
|
1080
|
+
}, [
|
|
1081
|
+
space
|
|
1082
|
+
]);
|
|
1083
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
1084
|
+
role: "form",
|
|
1085
|
+
className: mx4("flex flex-col", classNames)
|
|
1086
|
+
}, /* @__PURE__ */ React18.createElement(DeprecatedFormInput2, {
|
|
1087
|
+
label: t("name label")
|
|
1088
|
+
}, /* @__PURE__ */ React18.createElement(Input6.TextInput, {
|
|
1089
|
+
placeholder: t("unnamed space label"),
|
|
1090
|
+
value: space.properties.name ?? "",
|
|
1091
|
+
onChange: (event) => {
|
|
1092
|
+
space.properties.name = event.target.value;
|
|
1093
|
+
}
|
|
1094
|
+
})), edgeEnabled && /* @__PURE__ */ React18.createElement(DeprecatedFormInput2, {
|
|
1095
|
+
label: t("edge replication label")
|
|
1096
|
+
}, /* @__PURE__ */ React18.createElement(Input6.Switch, {
|
|
1097
|
+
checked: edgeReplication,
|
|
1098
|
+
onCheckedChange: toggleEdgeReplication
|
|
1099
|
+
})));
|
|
1100
|
+
};
|
|
1101
|
+
|
|
1102
|
+
// packages/plugins/plugin-space/src/components/SpaceSettings/SpaceSettingsDialog.tsx
|
|
1103
|
+
import React19, { useState as useState10 } from "react";
|
|
1104
|
+
import { useClient as useClient6 } from "@dxos/react-client";
|
|
1105
|
+
import { Button as Button6, Clipboard, Dialog as Dialog4, Icon as Icon4, toLocalizedString as toLocalizedString3, useTranslation as useTranslation19 } from "@dxos/react-ui";
|
|
1106
|
+
import { Tabs } from "@dxos/react-ui-tabs";
|
|
1107
|
+
import { SpacePanel } from "@dxos/shell/react";
|
|
1108
|
+
var SPACE_SETTINGS_DIALOG = `${SPACE_PLUGIN}/SpaceSettingsDialog`;
|
|
1109
|
+
var SpaceSettingsDialog = ({ space, target, createInvitationUrl, initialTab = "members", namesCache }) => {
|
|
1110
|
+
const { t } = useTranslation19(SPACE_PLUGIN);
|
|
1111
|
+
const client = useClient6();
|
|
1112
|
+
const [tabsActivePart, setTabsActivePart] = useState10("list");
|
|
1113
|
+
const [selected, setSelected] = useState10(initialTab);
|
|
1114
|
+
const locked = space.properties[COMPOSER_SPACE_LOCK];
|
|
1115
|
+
const name = getSpaceDisplayName(space, {
|
|
1116
|
+
personal: client.spaces.default === space,
|
|
1117
|
+
namesCache
|
|
1118
|
+
});
|
|
1119
|
+
return (
|
|
1120
|
+
// TODO(wittjosiah): The tablist dialog pattern is copied from @dxos/plugin-manager.
|
|
1121
|
+
// Consider factoring it out to the tabs package.
|
|
1122
|
+
/* @__PURE__ */ React19.createElement(Dialog4.Content, {
|
|
1123
|
+
classNames: "p-0 bs-content min-bs-[15rem] max-bs-full md:max-is-[40rem] overflow-hidden"
|
|
1124
|
+
}, /* @__PURE__ */ React19.createElement("div", {
|
|
1125
|
+
role: "none",
|
|
1126
|
+
className: "flex justify-between pbs-2 pis-2 pie-2 @md:pbs-4 @md:pis-4 @md:pie-4"
|
|
1127
|
+
}, /* @__PURE__ */ React19.createElement(Dialog4.Title, {
|
|
1128
|
+
onClick: () => setTabsActivePart("list"),
|
|
1129
|
+
"aria-description": t("click to return to tablist description"),
|
|
1130
|
+
classNames: "flex cursor-pointer items-center group/title"
|
|
1131
|
+
}, /* @__PURE__ */ React19.createElement(Icon4, {
|
|
1132
|
+
icon: "ph--caret-left--regular",
|
|
1133
|
+
size: 4,
|
|
1134
|
+
classNames: [
|
|
1135
|
+
"@md:hidden",
|
|
1136
|
+
tabsActivePart === "list" && "invisible"
|
|
1137
|
+
]
|
|
1138
|
+
}), /* @__PURE__ */ React19.createElement("span", {
|
|
1139
|
+
className: tabsActivePart !== "list" ? "group-hover/title:underline @md:group-hover/title:no-underline underline-offset-4 decoration-1" : ""
|
|
1140
|
+
}, toLocalizedString3(name, t))), /* @__PURE__ */ React19.createElement(Dialog4.Close, {
|
|
1141
|
+
asChild: true
|
|
1142
|
+
}, /* @__PURE__ */ React19.createElement(Button6, {
|
|
1143
|
+
density: "fine",
|
|
1144
|
+
variant: "ghost",
|
|
1145
|
+
autoFocus: true
|
|
1146
|
+
}, /* @__PURE__ */ React19.createElement(Icon4, {
|
|
1147
|
+
icon: "ph--x--regular",
|
|
1148
|
+
size: 4
|
|
1149
|
+
})))), /* @__PURE__ */ React19.createElement(Tabs.Root, {
|
|
1150
|
+
orientation: "vertical",
|
|
1151
|
+
value: selected,
|
|
1152
|
+
onValueChange: setSelected,
|
|
1153
|
+
activePart: tabsActivePart,
|
|
1154
|
+
onActivePartChange: setTabsActivePart,
|
|
1155
|
+
classNames: "flex flex-col flex-1 mbs-2"
|
|
1156
|
+
}, /* @__PURE__ */ React19.createElement(Tabs.Viewport, {
|
|
1157
|
+
classNames: "flex-1 min-bs-0"
|
|
1158
|
+
}, /* @__PURE__ */ React19.createElement("div", {
|
|
1159
|
+
role: "none",
|
|
1160
|
+
className: "overflow-y-auto pli-3 @md:pis-2 @md:pie-0 mbe-4 border-r border-separator"
|
|
1161
|
+
}, /* @__PURE__ */ React19.createElement(Tabs.Tablist, {
|
|
1162
|
+
classNames: "flex flex-col max-bs-none min-is-[200px] gap-4 overflow-y-auto"
|
|
1163
|
+
}, /* @__PURE__ */ React19.createElement("div", {
|
|
1164
|
+
role: "none",
|
|
1165
|
+
className: "flex flex-col ml-1"
|
|
1166
|
+
}, /* @__PURE__ */ React19.createElement(Tabs.Tab, {
|
|
1167
|
+
value: "settings"
|
|
1168
|
+
}, t("settings tab label")), /* @__PURE__ */ React19.createElement(Tabs.Tab, {
|
|
1169
|
+
value: "members",
|
|
1170
|
+
disabled: locked
|
|
1171
|
+
}, t("members tab label"))))), /* @__PURE__ */ React19.createElement(Tabs.Tabpanel, {
|
|
1172
|
+
value: "settings",
|
|
1173
|
+
classNames: "pli-3 @md:pli-5 max-bs-dvh overflow-y-auto"
|
|
1174
|
+
}, /* @__PURE__ */ React19.createElement(SpaceSettingsPanel, {
|
|
1175
|
+
space
|
|
1176
|
+
})), /* @__PURE__ */ React19.createElement(Tabs.Tabpanel, {
|
|
1177
|
+
value: "members",
|
|
1178
|
+
classNames: "pli-3 @md:pli-5 max-bs-dvh overflow-y-auto"
|
|
1179
|
+
}, /* @__PURE__ */ React19.createElement(Clipboard.Provider, null, /* @__PURE__ */ React19.createElement(SpacePanel, {
|
|
1180
|
+
space,
|
|
1181
|
+
hideHeading: true,
|
|
1182
|
+
target,
|
|
1183
|
+
createInvitationUrl
|
|
1184
|
+
}))))))
|
|
1185
|
+
);
|
|
1186
|
+
};
|
|
1187
|
+
|
|
1188
|
+
// packages/plugins/plugin-space/src/components/SyncStatus/InlineSyncStatus.tsx
|
|
1189
|
+
import React20, { useEffect as useEffect6, useState as useState12 } from "react";
|
|
1190
|
+
import { useGraph as useGraph3 } from "@dxos/plugin-graph";
|
|
1191
|
+
import { QueryEdgeStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
1192
|
+
import { EdgeReplicationSetting as EdgeReplicationSetting2 } from "@dxos/protocols/proto/dxos/echo/metadata";
|
|
1193
|
+
import { useClient as useClient8 } from "@dxos/react-client";
|
|
1194
|
+
import { Tooltip as Tooltip3, useTranslation as useTranslation20 } from "@dxos/react-ui";
|
|
1195
|
+
import { AttentionGlyph as AttentionGlyph2, useAttended as useAttended2, useAttention as useAttention2 } from "@dxos/react-ui-attention";
|
|
1196
|
+
|
|
1197
|
+
// packages/plugins/plugin-space/src/components/SyncStatus/sync-state.ts
|
|
1198
|
+
import { useEffect as useEffect5, useState as useState11 } from "react";
|
|
1199
|
+
import { Context } from "@dxos/context";
|
|
1200
|
+
import { EdgeService } from "@dxos/protocols";
|
|
1201
|
+
import { useClient as useClient7 } from "@dxos/react-client";
|
|
1202
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/SyncStatus/sync-state.ts";
|
|
1203
|
+
var createEmptyEdgeSyncState = () => ({
|
|
1204
|
+
missingOnLocal: 0,
|
|
1205
|
+
missingOnRemote: 0,
|
|
1206
|
+
localDocumentCount: 0,
|
|
1207
|
+
remoteDocumentCount: 0,
|
|
1208
|
+
differentDocuments: 0
|
|
1209
|
+
});
|
|
1210
|
+
var getSyncSummary = (syncMap) => {
|
|
1211
|
+
return Object.entries(syncMap).reduce((summary, [_spaceId, peerState]) => {
|
|
1212
|
+
summary.missingOnLocal += peerState.missingOnLocal;
|
|
1213
|
+
summary.missingOnRemote += peerState.missingOnRemote;
|
|
1214
|
+
summary.localDocumentCount += peerState.localDocumentCount;
|
|
1215
|
+
summary.remoteDocumentCount += peerState.remoteDocumentCount;
|
|
1216
|
+
summary.differentDocuments += peerState.differentDocuments;
|
|
1217
|
+
return summary;
|
|
1218
|
+
}, createEmptyEdgeSyncState());
|
|
1219
|
+
};
|
|
1220
|
+
var isEdgePeerId = (peerId, spaceId) => peerId.startsWith(`${EdgeService.AUTOMERGE_REPLICATOR}:${spaceId}`);
|
|
1221
|
+
var useSyncState = () => {
|
|
1222
|
+
const client = useClient7();
|
|
1223
|
+
const [spaceState, setSpaceState] = useState11({});
|
|
1224
|
+
useEffect5(() => {
|
|
1225
|
+
const ctx = new Context(void 0, {
|
|
1226
|
+
F: __dxlog_file3,
|
|
1227
|
+
L: 48
|
|
1228
|
+
});
|
|
1229
|
+
const createSubscriptions = (spaces) => {
|
|
1230
|
+
for (const space of spaces) {
|
|
1231
|
+
if (spaceState[space.id]) {
|
|
1232
|
+
continue;
|
|
1233
|
+
}
|
|
1234
|
+
ctx.onDispose(space.crud.subscribeToSyncState(ctx, ({ peers = [] }) => {
|
|
1235
|
+
const syncState = peers.find((state) => isEdgePeerId(state.peerId, space.id));
|
|
1236
|
+
if (syncState) {
|
|
1237
|
+
setSpaceState((spaceState2) => ({
|
|
1238
|
+
...spaceState2,
|
|
1239
|
+
[space.id]: syncState
|
|
1240
|
+
}));
|
|
1241
|
+
}
|
|
1242
|
+
}));
|
|
1243
|
+
}
|
|
1244
|
+
};
|
|
1245
|
+
createSubscriptions(client.spaces.get());
|
|
1246
|
+
client.spaces.subscribe((spaces) => {
|
|
1247
|
+
createSubscriptions(spaces);
|
|
1248
|
+
});
|
|
1249
|
+
return () => {
|
|
1250
|
+
void ctx.dispose();
|
|
1251
|
+
};
|
|
1252
|
+
}, [
|
|
1253
|
+
client
|
|
1254
|
+
]);
|
|
1255
|
+
return spaceState;
|
|
1256
|
+
};
|
|
1257
|
+
var useSpaceSyncState = (space) => {
|
|
1258
|
+
const [spaceState, setSpaceState] = useState11();
|
|
1259
|
+
useEffect5(() => {
|
|
1260
|
+
const ctx = new Context(void 0, {
|
|
1261
|
+
F: __dxlog_file3,
|
|
1262
|
+
L: 87
|
|
1263
|
+
});
|
|
1264
|
+
space.crud.subscribeToSyncState(ctx, ({ peers = [] }) => {
|
|
1265
|
+
const syncState = peers.find((state) => isEdgePeerId(state.peerId, space.id));
|
|
1266
|
+
if (syncState) {
|
|
1267
|
+
setSpaceState(syncState);
|
|
1268
|
+
}
|
|
1269
|
+
});
|
|
1270
|
+
return () => {
|
|
1271
|
+
void ctx.dispose();
|
|
1272
|
+
};
|
|
1273
|
+
}, [
|
|
1274
|
+
space
|
|
1275
|
+
]);
|
|
1276
|
+
return spaceState;
|
|
1277
|
+
};
|
|
1278
|
+
|
|
1279
|
+
// packages/plugins/plugin-space/src/components/SyncStatus/InlineSyncStatus.tsx
|
|
1280
|
+
var useEdgeStatus = () => {
|
|
1281
|
+
const [status, setStatus] = useState12(QueryEdgeStatusResponse.EdgeStatus.NOT_CONNECTED);
|
|
1282
|
+
const client = useClient8();
|
|
1283
|
+
useEffect6(() => {
|
|
1284
|
+
client.services.services.EdgeAgentService?.queryEdgeStatus().subscribe(({ status: status2 }) => {
|
|
1285
|
+
setStatus(status2);
|
|
1286
|
+
});
|
|
1287
|
+
}, [
|
|
1288
|
+
client
|
|
1289
|
+
]);
|
|
1290
|
+
return status;
|
|
1291
|
+
};
|
|
1292
|
+
var InlineSyncStatus = ({ space, open }) => {
|
|
1293
|
+
const { t } = useTranslation20(SPACE_PLUGIN);
|
|
1294
|
+
const id = space.id;
|
|
1295
|
+
const { hasAttention, isAncestor, isRelated } = useAttention2(id);
|
|
1296
|
+
const isAttended = hasAttention || isAncestor || isRelated;
|
|
1297
|
+
const { graph } = useGraph3();
|
|
1298
|
+
const attended = useAttended2();
|
|
1299
|
+
const startOfAttention = attended.at(-1);
|
|
1300
|
+
const path = usePath(graph, startOfAttention);
|
|
1301
|
+
const containsAttended = !open && !isAttended && id && path ? path.includes(id) : false;
|
|
1302
|
+
const connectedToEdge = useEdgeStatus() === QueryEdgeStatusResponse.EdgeStatus.CONNECTED;
|
|
1303
|
+
const edgeSyncEnabled = space.internal.data.edgeReplication === EdgeReplicationSetting2.ENABLED;
|
|
1304
|
+
const syncState = useSpaceSyncState(space);
|
|
1305
|
+
const syncing = connectedToEdge && edgeSyncEnabled && syncState && syncState.missingOnLocal > 0;
|
|
1306
|
+
return /* @__PURE__ */ React20.createElement(Tooltip3.Root, null, /* @__PURE__ */ React20.createElement(Tooltip3.Trigger, {
|
|
1307
|
+
asChild: true
|
|
1308
|
+
}, /* @__PURE__ */ React20.createElement(AttentionGlyph2, {
|
|
1309
|
+
syncing,
|
|
1310
|
+
attended: isAttended,
|
|
1311
|
+
containsAttended,
|
|
1312
|
+
classNames: "self-center mie-1"
|
|
1313
|
+
})), /* @__PURE__ */ React20.createElement(Tooltip3.Portal, null, /* @__PURE__ */ React20.createElement(Tooltip3.Content, {
|
|
1314
|
+
side: "bottom",
|
|
1315
|
+
classNames: "z-[70]"
|
|
1316
|
+
}, /* @__PURE__ */ React20.createElement("span", null, t("syncing label")), /* @__PURE__ */ React20.createElement(Tooltip3.Arrow, null))));
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1319
|
+
// packages/plugins/plugin-space/src/components/SyncStatus/SyncStatus.tsx
|
|
1320
|
+
import React22, { useCallback as useCallback12, useEffect as useEffect8, useState as useState14 } from "react";
|
|
1321
|
+
import { StatusBar } from "@dxos/plugin-status-bar";
|
|
1322
|
+
import { useClient as useClient10 } from "@dxos/react-client";
|
|
1323
|
+
import { Icon as Icon6, Input as Input7, Popover as Popover3, useTranslation as useTranslation22 } from "@dxos/react-ui";
|
|
1324
|
+
import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
|
|
1325
|
+
import { mx as mx6 } from "@dxos/react-ui-theme";
|
|
1326
|
+
|
|
1327
|
+
// packages/plugins/plugin-space/src/components/SyncStatus/Space.tsx
|
|
1328
|
+
import React21, { useEffect as useEffect7, useState as useState13 } from "react";
|
|
1329
|
+
import { useClient as useClient9 } from "@dxos/react-client";
|
|
1330
|
+
import { useSpace } from "@dxos/react-client/echo";
|
|
1331
|
+
import { Icon as Icon5, toLocalizedString as toLocalizedString4, useTranslation as useTranslation21 } from "@dxos/react-ui";
|
|
1332
|
+
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
1333
|
+
var SYNC_STALLED_TIMEOUT = 5e3;
|
|
1334
|
+
var styles = {
|
|
1335
|
+
barBg: "bg-neutral-50 dark:bg-green-900 text-black",
|
|
1336
|
+
barFg: "bg-neutral-100 bg-green-500",
|
|
1337
|
+
barHover: "dark:hover:bg-green-500"
|
|
1338
|
+
};
|
|
1339
|
+
var useActive = (count) => {
|
|
1340
|
+
const [current, setCurrent] = useState13(count);
|
|
1341
|
+
const [active, setActive] = useState13(false);
|
|
1342
|
+
useEffect7(() => {
|
|
1343
|
+
let t;
|
|
1344
|
+
if (count !== current) {
|
|
1345
|
+
setActive(true);
|
|
1346
|
+
setCurrent(count);
|
|
1347
|
+
t && clearTimeout(t);
|
|
1348
|
+
t = setTimeout(() => {
|
|
1349
|
+
setActive(false);
|
|
1350
|
+
}, SYNC_STALLED_TIMEOUT);
|
|
1351
|
+
}
|
|
1352
|
+
return () => {
|
|
1353
|
+
setActive(false);
|
|
1354
|
+
clearTimeout(t);
|
|
1355
|
+
};
|
|
1356
|
+
}, [
|
|
1357
|
+
count,
|
|
1358
|
+
current
|
|
1359
|
+
]);
|
|
1360
|
+
return active;
|
|
1361
|
+
};
|
|
1362
|
+
var SpaceRowContainer = ({ spaceId, state }) => {
|
|
1363
|
+
const { t } = useTranslation21(SPACE_PLUGIN);
|
|
1364
|
+
const client = useClient9();
|
|
1365
|
+
const space = useSpace(spaceId);
|
|
1366
|
+
if (!space) {
|
|
1367
|
+
return null;
|
|
1368
|
+
}
|
|
1369
|
+
const spaceName = toLocalizedString4(getSpaceDisplayName(space, {
|
|
1370
|
+
personal: space === client.spaces.default
|
|
1371
|
+
}), t);
|
|
1372
|
+
return /* @__PURE__ */ React21.createElement(SpaceRow, {
|
|
1373
|
+
spaceId,
|
|
1374
|
+
spaceName,
|
|
1375
|
+
state
|
|
1376
|
+
});
|
|
1377
|
+
};
|
|
1378
|
+
var SpaceRow = ({ spaceId, spaceName, state: { localDocumentCount, remoteDocumentCount, missingOnLocal, missingOnRemote } }) => {
|
|
1379
|
+
const downActive = useActive(localDocumentCount);
|
|
1380
|
+
const upActive = useActive(remoteDocumentCount);
|
|
1381
|
+
return /* @__PURE__ */ React21.createElement("div", {
|
|
1382
|
+
className: "flex items-center mx-0.5 gap-0.5 cursor-pointer",
|
|
1383
|
+
title: spaceId,
|
|
1384
|
+
onClick: () => {
|
|
1385
|
+
void navigator.clipboard.writeText(spaceId);
|
|
1386
|
+
}
|
|
1387
|
+
}, /* @__PURE__ */ React21.createElement("span", {
|
|
1388
|
+
className: "is-1/2 truncate"
|
|
1389
|
+
}, spaceName), /* @__PURE__ */ React21.createElement(Icon5, {
|
|
1390
|
+
icon: "ph--arrow-fat-line-left--regular",
|
|
1391
|
+
size: 3,
|
|
1392
|
+
classNames: mx5(downActive && "animate-[pulse_1s_infinite]")
|
|
1393
|
+
}), /* @__PURE__ */ React21.createElement(Candle, {
|
|
1394
|
+
up: {
|
|
1395
|
+
count: remoteDocumentCount,
|
|
1396
|
+
total: remoteDocumentCount + missingOnRemote
|
|
1397
|
+
},
|
|
1398
|
+
down: {
|
|
1399
|
+
count: localDocumentCount,
|
|
1400
|
+
total: localDocumentCount + missingOnLocal
|
|
1401
|
+
},
|
|
1402
|
+
title: spaceId
|
|
1403
|
+
}), /* @__PURE__ */ React21.createElement(Icon5, {
|
|
1404
|
+
icon: "ph--arrow-fat-line-right--regular",
|
|
1405
|
+
size: 3,
|
|
1406
|
+
classNames: mx5(upActive && "animate-[pulse_1s_step-start_infinite]")
|
|
1407
|
+
}));
|
|
1408
|
+
};
|
|
1409
|
+
var Candle = ({ classNames, up, down }) => {
|
|
1410
|
+
return /* @__PURE__ */ React21.createElement("div", {
|
|
1411
|
+
className: mx5("grid grid-cols-[1fr_2rem_1fr] w-full h-3", classNames)
|
|
1412
|
+
}, /* @__PURE__ */ React21.createElement(Bar, {
|
|
1413
|
+
classNames: "justify-end",
|
|
1414
|
+
...up
|
|
1415
|
+
}), /* @__PURE__ */ React21.createElement("div", {
|
|
1416
|
+
className: "relative"
|
|
1417
|
+
}, /* @__PURE__ */ React21.createElement("div", {
|
|
1418
|
+
className: mx5("absolute inset-0 flex items-center justify-center text-xs", styles.barBg)
|
|
1419
|
+
}, up.total)), /* @__PURE__ */ React21.createElement(Bar, down));
|
|
1420
|
+
};
|
|
1421
|
+
var Bar = ({ classNames, count, total }) => {
|
|
1422
|
+
let p = count / total * 100;
|
|
1423
|
+
if (count < total) {
|
|
1424
|
+
p = Math.min(p, 95);
|
|
1425
|
+
}
|
|
1426
|
+
return /* @__PURE__ */ React21.createElement("div", {
|
|
1427
|
+
className: mx5("relative flex w-full", styles.barBg, classNames)
|
|
1428
|
+
}, /* @__PURE__ */ React21.createElement("div", {
|
|
1429
|
+
className: mx5("shrink-0", styles.barFg),
|
|
1430
|
+
style: {
|
|
1431
|
+
width: `${p}%`
|
|
1432
|
+
}
|
|
1433
|
+
}), count !== total && /* @__PURE__ */ React21.createElement("div", {
|
|
1434
|
+
className: "absolute top-0 bottom-0 flex items-center mx-0.5 text-black text-xs"
|
|
1435
|
+
}, count));
|
|
1436
|
+
};
|
|
1437
|
+
|
|
1438
|
+
// packages/plugins/plugin-space/src/components/SyncStatus/save-tracker.ts
|
|
1439
|
+
import { Context as Context2 } from "@dxos/context";
|
|
1440
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/SyncStatus/save-tracker.ts";
|
|
1441
|
+
var createClientSaveTracker = (client, cb) => {
|
|
1442
|
+
const unsubscribeCallbacks = {};
|
|
1443
|
+
const state = {};
|
|
1444
|
+
const install = (spaces) => {
|
|
1445
|
+
for (const space of spaces) {
|
|
1446
|
+
if (state[space.id]) {
|
|
1447
|
+
continue;
|
|
1448
|
+
}
|
|
1449
|
+
state[space.id] = "saved";
|
|
1450
|
+
unsubscribeCallbacks[space.id] = createSpaceSaveTracker(space, (s) => {
|
|
1451
|
+
state[space.id] = s;
|
|
1452
|
+
cb(Object.values(state).some((s2) => s2 === "saving") ? "saving" : "saved");
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
client.spaces.subscribe((spaces) => {
|
|
1457
|
+
install(spaces);
|
|
1458
|
+
});
|
|
1459
|
+
install(client.spaces.get());
|
|
1460
|
+
return () => {
|
|
1461
|
+
for (const unsubscribe of Object.values(unsubscribeCallbacks)) {
|
|
1462
|
+
unsubscribe();
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
};
|
|
1466
|
+
var createSpaceSaveTracker = (space, cb) => {
|
|
1467
|
+
const ctx = new Context2(void 0, {
|
|
1468
|
+
F: __dxlog_file4,
|
|
1469
|
+
L: 40
|
|
1470
|
+
});
|
|
1471
|
+
void space.waitUntilReady().then(() => {
|
|
1472
|
+
if (ctx.disposed) {
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1475
|
+
let hasUnsavedChanges = false;
|
|
1476
|
+
let lastFlushPromise;
|
|
1477
|
+
space.crud.saveStateChanged.on(ctx, ({ unsavedDocuments }) => {
|
|
1478
|
+
hasUnsavedChanges = unsavedDocuments.length > 0;
|
|
1479
|
+
});
|
|
1480
|
+
space.crud.saveStateChanged.debounce(500).on(ctx, () => {
|
|
1481
|
+
if (hasUnsavedChanges) {
|
|
1482
|
+
lastFlushPromise = void 0;
|
|
1483
|
+
cb("saving");
|
|
1484
|
+
} else {
|
|
1485
|
+
const flushPromise = space.crud.flush();
|
|
1486
|
+
lastFlushPromise = flushPromise;
|
|
1487
|
+
void flushPromise.then(() => {
|
|
1488
|
+
if (lastFlushPromise === flushPromise) {
|
|
1489
|
+
cb("saved");
|
|
1490
|
+
}
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
});
|
|
1494
|
+
});
|
|
1495
|
+
return () => {
|
|
1496
|
+
void ctx.dispose();
|
|
1497
|
+
};
|
|
1498
|
+
};
|
|
1499
|
+
|
|
1500
|
+
// packages/plugins/plugin-space/src/components/SyncStatus/status.ts
|
|
1501
|
+
var getStatus = ({ offline, saved, needsToUpload, needsToDownload }) => {
|
|
1502
|
+
if (!saved) {
|
|
1503
|
+
return "saving locally";
|
|
1504
|
+
} else if (!offline && needsToDownload) {
|
|
1505
|
+
return "downloading";
|
|
1506
|
+
} else if (!offline && needsToUpload) {
|
|
1507
|
+
return "uploading";
|
|
1508
|
+
} else if (offline && !needsToUpload && !needsToDownload) {
|
|
1509
|
+
return "offline persisted";
|
|
1510
|
+
} else {
|
|
1511
|
+
return "remote synced";
|
|
1512
|
+
}
|
|
1513
|
+
};
|
|
1514
|
+
var getIcon = (status) => {
|
|
1515
|
+
switch (status) {
|
|
1516
|
+
case "saving locally":
|
|
1517
|
+
return "ph--download--regular";
|
|
1518
|
+
case "downloading":
|
|
1519
|
+
return "ph--cloud-arrow-down--regular";
|
|
1520
|
+
case "uploading":
|
|
1521
|
+
return "ph--cloud-arrow-up--regular";
|
|
1522
|
+
case "offline persisted":
|
|
1523
|
+
return "ph--check-circle--regular";
|
|
1524
|
+
case "remote synced":
|
|
1525
|
+
return "ph--cloud-check--regular";
|
|
1526
|
+
}
|
|
1527
|
+
};
|
|
1528
|
+
|
|
1529
|
+
// packages/plugins/plugin-space/src/components/SyncStatus/SyncStatus.tsx
|
|
1530
|
+
var SyncStatus = () => {
|
|
1531
|
+
const client = useClient10();
|
|
1532
|
+
const state = useSyncState();
|
|
1533
|
+
const [saved, setSaved] = useState14(true);
|
|
1534
|
+
useEffect8(() => {
|
|
1535
|
+
return createClientSaveTracker(client, (state2) => {
|
|
1536
|
+
setSaved(state2 === "saved");
|
|
1537
|
+
});
|
|
1538
|
+
}, []);
|
|
1539
|
+
return /* @__PURE__ */ React22.createElement(SyncStatusIndicator, {
|
|
1540
|
+
state,
|
|
1541
|
+
saved
|
|
1542
|
+
});
|
|
1543
|
+
};
|
|
1544
|
+
var SyncStatusIndicator = ({ state, saved }) => {
|
|
1545
|
+
const { t } = useTranslation22(SPACE_PLUGIN);
|
|
1546
|
+
const summary = getSyncSummary(state);
|
|
1547
|
+
const offline = Object.values(state).length === 0;
|
|
1548
|
+
const needsToUpload = summary.differentDocuments > 0 || summary.missingOnRemote > 0;
|
|
1549
|
+
const needsToDownload = summary.differentDocuments > 0 || summary.missingOnLocal > 0;
|
|
1550
|
+
const status = getStatus({
|
|
1551
|
+
offline,
|
|
1552
|
+
saved,
|
|
1553
|
+
needsToUpload,
|
|
1554
|
+
needsToDownload
|
|
1555
|
+
});
|
|
1556
|
+
const [classNames, setClassNames] = useState14();
|
|
1557
|
+
useEffect8(() => {
|
|
1558
|
+
setClassNames(void 0);
|
|
1559
|
+
if (offline || !needsToUpload && !needsToDownload) {
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
const t2 = setTimeout(() => {
|
|
1563
|
+
setClassNames("text-orange-500");
|
|
1564
|
+
}, SYNC_STALLED_TIMEOUT);
|
|
1565
|
+
return () => clearTimeout(t2);
|
|
1566
|
+
}, [
|
|
1567
|
+
offline,
|
|
1568
|
+
needsToUpload,
|
|
1569
|
+
needsToDownload
|
|
1570
|
+
]);
|
|
1571
|
+
const title = t(`${status} label`);
|
|
1572
|
+
const icon = /* @__PURE__ */ React22.createElement(Icon6, {
|
|
1573
|
+
icon: getIcon(status),
|
|
1574
|
+
size: 4,
|
|
1575
|
+
classNames
|
|
1576
|
+
});
|
|
1577
|
+
if (offline) {
|
|
1578
|
+
return /* @__PURE__ */ React22.createElement(StatusBar.Item, {
|
|
1579
|
+
title
|
|
1580
|
+
}, icon);
|
|
1581
|
+
} else {
|
|
1582
|
+
return /* @__PURE__ */ React22.createElement(Popover3.Root, null, /* @__PURE__ */ React22.createElement(Popover3.Trigger, {
|
|
1583
|
+
asChild: true
|
|
1584
|
+
}, /* @__PURE__ */ React22.createElement(StatusBar.Button, {
|
|
1585
|
+
title
|
|
1586
|
+
}, icon)), /* @__PURE__ */ React22.createElement(Popover3.Portal, null, /* @__PURE__ */ React22.createElement(Popover3.Content, {
|
|
1587
|
+
sideOffset: 16
|
|
1588
|
+
}, /* @__PURE__ */ React22.createElement(SyncStatusDetail, {
|
|
1589
|
+
state,
|
|
1590
|
+
summary,
|
|
1591
|
+
debug: false
|
|
1592
|
+
}))));
|
|
1593
|
+
}
|
|
1594
|
+
};
|
|
1595
|
+
var SyncStatusDetail = ({ classNames, state, summary, debug }) => {
|
|
1596
|
+
const [showAll, setShowAll] = useState14(false);
|
|
1597
|
+
const { t } = useTranslation22(SPACE_PLUGIN);
|
|
1598
|
+
const entries = Object.entries(state).filter(([_, value]) => showAll || value.missingOnLocal + value.missingOnRemote > 0).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
1599
|
+
const handleCheckedChange = useCallback12((state2) => setShowAll(state2), [
|
|
1600
|
+
setShowAll
|
|
1601
|
+
]);
|
|
1602
|
+
return /* @__PURE__ */ React22.createElement("div", {
|
|
1603
|
+
className: mx6("flex flex-col gap-3 p-2 text-xs min-w-96", classNames)
|
|
1604
|
+
}, /* @__PURE__ */ React22.createElement("div", {
|
|
1605
|
+
role: "none",
|
|
1606
|
+
className: "flex items-center"
|
|
1607
|
+
}, /* @__PURE__ */ React22.createElement("h1", {
|
|
1608
|
+
className: "flex-1"
|
|
1609
|
+
}, t("sync status title")), /* @__PURE__ */ React22.createElement("div", {
|
|
1610
|
+
className: "flex items-center gap-2"
|
|
1611
|
+
}, /* @__PURE__ */ React22.createElement(Input7.Root, null, /* @__PURE__ */ React22.createElement(Input7.Label, {
|
|
1612
|
+
classNames: "text-xs"
|
|
1613
|
+
}, t("show all label")), /* @__PURE__ */ React22.createElement(Input7.Checkbox, {
|
|
1614
|
+
checked: showAll,
|
|
1615
|
+
onCheckedChange: handleCheckedChange
|
|
1616
|
+
})))), /* @__PURE__ */ React22.createElement("div", {
|
|
1617
|
+
className: "flex flex-col gap-2"
|
|
1618
|
+
}, entries.length === 0 && /* @__PURE__ */ React22.createElement("div", {
|
|
1619
|
+
role: "none",
|
|
1620
|
+
className: "flex justify-center"
|
|
1621
|
+
}, t("no sync status label")), entries.map(([spaceId, state2]) => /* @__PURE__ */ React22.createElement(SpaceRowContainer, {
|
|
1622
|
+
key: spaceId,
|
|
1623
|
+
spaceId,
|
|
1624
|
+
state: state2
|
|
1625
|
+
}))), debug && /* @__PURE__ */ React22.createElement(SyntaxHighlighter, {
|
|
1626
|
+
language: "json"
|
|
1627
|
+
}, JSON.stringify(summary, null, 2)));
|
|
1628
|
+
};
|
|
1629
|
+
|
|
1630
|
+
export {
|
|
1631
|
+
AdvancedObjectSettings,
|
|
1632
|
+
AwaitingObject,
|
|
1633
|
+
BaseObjectSettings,
|
|
1634
|
+
CREATE_OBJECT_DIALOG,
|
|
1635
|
+
CreateObjectDialog,
|
|
1636
|
+
CREATE_SPACE_DIALOG,
|
|
1637
|
+
CreateSpaceDialog,
|
|
1638
|
+
CollectionMain,
|
|
1639
|
+
CollectionSection,
|
|
1640
|
+
JOIN_DIALOG,
|
|
1641
|
+
JoinDialog,
|
|
1642
|
+
MenuFooter,
|
|
1643
|
+
PersistenceStatus,
|
|
1644
|
+
POPOVER_RENAME_OBJECT,
|
|
1645
|
+
PopoverRenameObject,
|
|
1646
|
+
POPOVER_RENAME_SPACE,
|
|
1647
|
+
PopoverRenameSpace,
|
|
1648
|
+
ShareSpaceButton,
|
|
1649
|
+
ShareSpaceButtonImpl,
|
|
1650
|
+
SpacePresence,
|
|
1651
|
+
FullPresence,
|
|
1652
|
+
SmallPresenceLive,
|
|
1653
|
+
SmallPresence,
|
|
1654
|
+
SpacePluginSettings,
|
|
1655
|
+
SpaceSettingsPanel,
|
|
1656
|
+
SPACE_SETTINGS_DIALOG,
|
|
1657
|
+
SpaceSettingsDialog,
|
|
1658
|
+
InlineSyncStatus,
|
|
1659
|
+
SyncStatus,
|
|
1660
|
+
SyncStatusIndicator,
|
|
1661
|
+
SyncStatusDetail,
|
|
1662
|
+
AppGraphBuilder,
|
|
1663
|
+
AppGraphSerializer,
|
|
1664
|
+
IdentityCreated,
|
|
1665
|
+
IntentResolver,
|
|
1666
|
+
ReactRoot,
|
|
1667
|
+
ReactSurface,
|
|
1668
|
+
SpaceSettings,
|
|
1669
|
+
SpaceState,
|
|
1670
|
+
SpacesReady
|
|
1671
|
+
};
|
|
1672
|
+
//# sourceMappingURL=chunk-6SWQRWOD.mjs.map
|