@mdbase-dev/ui 0.1.0-beta.160 → 0.1.0-beta.161
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/css/collections.css +18 -0
- package/dist/AppSwitcher.js +0 -9
- package/dist/brand.js +1 -1
- package/dist/collections/CollectionGate.js +56 -0
- package/dist/collections/CollectionSwitcher.js +3 -3
- package/dist/collections/SetupReview.js +6 -0
- package/dist/collections/UnsyncedWork.d.ts +26 -0
- package/dist/collections/UnsyncedWork.js +160 -0
- package/dist/collections/copy.d.ts +20 -0
- package/dist/collections/copy.js +210 -0
- package/dist/collections/model.d.ts +9 -0
- package/dist/collections/model.js +13 -1
- package/dist/collections/unsynced.d.ts +56 -0
- package/dist/collections/unsynced.js +18 -0
- package/dist/collections/use-collection-ui.d.ts +26 -1
- package/dist/collections/use-collection-ui.js +110 -4
- package/dist/collections.d.ts +3 -1
- package/dist/collections.js +1 -0
- package/dist/locales/de/messages.json +1 -1
- package/dist/locales/en/messages.json +1 -1
- package/dist/locales/es/messages.json +1 -1
- package/dist/locales/fr/messages.json +1 -1
- package/dist/locales/it/messages.json +1 -1
- package/dist/locales/ja/messages.json +1 -1
- package/dist/locales/ko/messages.json +1 -1
- package/dist/locales/pt/messages.json +1 -1
- package/dist/locales/ru/messages.json +1 -1
- package/dist/locales/zh/messages.json +1 -1
- package/package.json +2 -2
package/css/collections.css
CHANGED
|
@@ -307,6 +307,24 @@
|
|
|
307
307
|
gap: 8px;
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
+
/* Work before connecting: where it is kept, and the way to connect it. One
|
|
311
|
+
quiet line above the app, never a modal or a nag. */
|
|
312
|
+
.mdbase-collections-unsynced {
|
|
313
|
+
display: flex;
|
|
314
|
+
flex-wrap: wrap;
|
|
315
|
+
align-items: center;
|
|
316
|
+
justify-content: space-between;
|
|
317
|
+
gap: 4px 12px;
|
|
318
|
+
padding: 6px 14px;
|
|
319
|
+
border-bottom: 1px solid var(--_border);
|
|
320
|
+
background: var(--_surface);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.mdbase-collections-unsynced-status {
|
|
324
|
+
margin: 0;
|
|
325
|
+
color: var(--_text-soft);
|
|
326
|
+
}
|
|
327
|
+
|
|
310
328
|
/* Collections are a list, not buttons among actions. */
|
|
311
329
|
.mdbase-collections-section {
|
|
312
330
|
display: grid;
|
package/dist/AppSwitcher.js
CHANGED
|
@@ -32,15 +32,6 @@ export function AppSwitcher({
|
|
|
32
32
|
ref: triggerRef,
|
|
33
33
|
type: "button",
|
|
34
34
|
className: "mdbase-app-switcher",
|
|
35
|
-
"aria-label": _i18n._(
|
|
36
|
-
/** i18n */
|
|
37
|
-
{
|
|
38
|
-
id: "54P3Y1",
|
|
39
|
-
message: "mdbase {current}: open this collection in another app",
|
|
40
|
-
values: {
|
|
41
|
-
current: current
|
|
42
|
-
}
|
|
43
|
-
}),
|
|
44
35
|
"aria-haspopup": "menu",
|
|
45
36
|
"aria-expanded": open,
|
|
46
37
|
"aria-controls": open ? menuId : undefined,
|
package/dist/brand.js
CHANGED
|
@@ -8,6 +8,8 @@ import { RowDialogs, SignOutDialog } from "./dialogs.js";
|
|
|
8
8
|
import { problemControl, actionNotice } from "./model.js";
|
|
9
9
|
import { ActionButton, CollectionMark, GateFooter, ItemCopy, ItemMore, NoticeBlock, RowCopy, RowMore } from "./parts.js";
|
|
10
10
|
import { SetupReview } from "./SetupReview.js";
|
|
11
|
+
import { BringInBanner, UnsyncedLine } from "./UnsyncedWork.js";
|
|
12
|
+
import { unsyncedApi } from "./unsynced.js";
|
|
11
13
|
import { useAutoStart, useCollectionUi } from "./use-collection-ui.js";
|
|
12
14
|
/**
|
|
13
15
|
* Everything before a collection is open: sign-in, choosing, approval, setup
|
|
@@ -44,6 +46,8 @@ export function CollectionGate({
|
|
|
44
46
|
ui: ui,
|
|
45
47
|
variant: "banner"
|
|
46
48
|
})
|
|
49
|
+
}), _jsx(BringInBanner, {
|
|
50
|
+
ui: ui
|
|
47
51
|
}), _jsx(CollectionMdbaseContext, {
|
|
48
52
|
value: options.mdbase,
|
|
49
53
|
children: children(ui.view.phase.connection)
|
|
@@ -52,6 +56,17 @@ export function CollectionGate({
|
|
|
52
56
|
})]
|
|
53
57
|
});
|
|
54
58
|
}
|
|
59
|
+
// Work before connecting: the app as usual, saved only on this device.
|
|
60
|
+
if (ui.view.kind === "unsynced") {
|
|
61
|
+
return _jsxs(_Fragment, {
|
|
62
|
+
children: [_jsx(UnsyncedLine, {
|
|
63
|
+
ui: ui
|
|
64
|
+
}), _jsx(CollectionMdbaseContext, {
|
|
65
|
+
value: options.mdbase,
|
|
66
|
+
children: children(ui.view.phase.connection)
|
|
67
|
+
})]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
55
70
|
return _jsx(GateScreen, {
|
|
56
71
|
ui: ui,
|
|
57
72
|
layout: layout,
|
|
@@ -70,6 +85,12 @@ export function CollectionPanel({
|
|
|
70
85
|
const ui = useCollectionUi(options);
|
|
71
86
|
useAutoStart(options.mdbase, autoStart);
|
|
72
87
|
const [dialog, setDialog] = useState(null);
|
|
88
|
+
if (ui.view.kind === "unsynced") return _jsx("div", {
|
|
89
|
+
className: "mdbase-collections mdbase-collections-panel",
|
|
90
|
+
children: _jsx(UnsyncedPanel, {
|
|
91
|
+
ui: ui
|
|
92
|
+
})
|
|
93
|
+
});
|
|
73
94
|
if (ui.view.kind !== "ready") return _jsx(GateScreen, {
|
|
74
95
|
ui: ui,
|
|
75
96
|
layout: "panel",
|
|
@@ -81,6 +102,9 @@ export function CollectionPanel({
|
|
|
81
102
|
notice: ui.view.notice,
|
|
82
103
|
ui: ui,
|
|
83
104
|
variant: "inline"
|
|
105
|
+
}), _jsx(BringInBanner, {
|
|
106
|
+
ui: ui,
|
|
107
|
+
variant: "inline"
|
|
84
108
|
}), _jsx(SwitcherContent, {
|
|
85
109
|
ui: ui,
|
|
86
110
|
onDone: () => {},
|
|
@@ -263,6 +287,11 @@ function GateBody({
|
|
|
263
287
|
progress: busy === "sign_out" ? copy.signingOut : busy === "sign_in" ? copy.addingCollection : null,
|
|
264
288
|
onClick: actions.signIn,
|
|
265
289
|
children: copy.signIn
|
|
290
|
+
}), ui.options.unsynced && unsyncedApi(ui.options.mdbase) && _jsx(ActionButton, {
|
|
291
|
+
tone: "secondary",
|
|
292
|
+
inert: inert,
|
|
293
|
+
onClick: actions.continueWithoutConnecting,
|
|
294
|
+
children: copy.continueWithoutConnecting
|
|
266
295
|
}), extraActions]
|
|
267
296
|
}), _jsx(AppSections, {
|
|
268
297
|
ui: ui,
|
|
@@ -346,9 +375,36 @@ function GateBody({
|
|
|
346
375
|
})]
|
|
347
376
|
});
|
|
348
377
|
case "ready":
|
|
378
|
+
case "unsynced":
|
|
349
379
|
return null;
|
|
350
380
|
}
|
|
351
381
|
}
|
|
382
|
+
/** In a settings panel: where the work is kept, and the way to connect it. */
|
|
383
|
+
function UnsyncedPanel({
|
|
384
|
+
ui
|
|
385
|
+
}) {
|
|
386
|
+
const options = ui.options.unsynced;
|
|
387
|
+
const saved = typeof options === "object" && options.storage === "device" ? ui.copy.unsyncedSavedDevice : ui.copy.unsyncedSavedBrowser;
|
|
388
|
+
return _jsxs(_Fragment, {
|
|
389
|
+
children: [_jsx("p", {
|
|
390
|
+
className: "mdbase-collections-lead",
|
|
391
|
+
children: saved
|
|
392
|
+
}), _jsx("div", {
|
|
393
|
+
className: "mdbase-collections-actions",
|
|
394
|
+
children: _jsx(ActionButton, {
|
|
395
|
+
tone: "primary",
|
|
396
|
+
inert: ui.busy !== null,
|
|
397
|
+
progress: ui.busy === "sign_in" || ui.busy === "add" ? ui.copy.addingCollection : null,
|
|
398
|
+
onClick: ui.actions.connect,
|
|
399
|
+
children: ui.copy.unsyncedConnect
|
|
400
|
+
})
|
|
401
|
+
}), ui.error && _jsx(NoticeBlock, {
|
|
402
|
+
notice: ui.error,
|
|
403
|
+
ui: ui,
|
|
404
|
+
variant: "inline"
|
|
405
|
+
})]
|
|
406
|
+
});
|
|
407
|
+
}
|
|
352
408
|
/** The approved collections as a labelled list: one row per collection, never mixed with actions. */
|
|
353
409
|
function CollectionList({
|
|
354
410
|
ui,
|
|
@@ -73,9 +73,9 @@ export function CollectionSwitcher({
|
|
|
73
73
|
"aria-haspopup": "dialog",
|
|
74
74
|
"aria-expanded": open,
|
|
75
75
|
"aria-controls": open ? panelId : undefined,
|
|
76
|
-
"aria-label": currentName ? say("switchCollection", {
|
|
76
|
+
"aria-label": variant === "icon" ? currentName ? say("switchCollection", {
|
|
77
77
|
collection: currentName
|
|
78
|
-
}) : copy.switchCollectionNone,
|
|
78
|
+
}) : copy.switchCollectionNone : undefined,
|
|
79
79
|
title: name,
|
|
80
80
|
onClick: () => setOpen(!open),
|
|
81
81
|
children: [busy === "select" || busy === "add" || view.kind === "opening" ? _jsx("span", {
|
|
@@ -88,7 +88,7 @@ export function CollectionSwitcher({
|
|
|
88
88
|
}) : variant === "icon" ? _jsx(CollectionsGlyph, {}) : null, variant !== "icon" && _jsx("span", {
|
|
89
89
|
className: "mdbase-collections-trigger-name",
|
|
90
90
|
children: name
|
|
91
|
-
}), variant === "full" && current && _jsx("span", {
|
|
91
|
+
}), variant === "full" && current && " ", variant === "full" && current && _jsx("span", {
|
|
92
92
|
className: "mdbase-collections-trigger-role",
|
|
93
93
|
children: current.roleLabel
|
|
94
94
|
}), _jsx("svg", {
|
|
@@ -111,6 +111,12 @@ export function SetupReview({
|
|
|
111
111
|
...current,
|
|
112
112
|
notice
|
|
113
113
|
} : current);
|
|
114
|
+
// A dispatched apply consumes its plan: clicking again with it can only be
|
|
115
|
+
// refused. Plan again quietly, keeping this review and notice on screen.
|
|
116
|
+
setRequest(current => ({
|
|
117
|
+
...current,
|
|
118
|
+
quiet: true
|
|
119
|
+
}));
|
|
114
120
|
});
|
|
115
121
|
};
|
|
116
122
|
if (state.status === "planning") {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type JSX } from "react";
|
|
2
|
+
import type { Mdbase } from "@mdbase-dev/sdk";
|
|
3
|
+
import type { CollectionUi } from "./use-collection-ui.js";
|
|
4
|
+
/**
|
|
5
|
+
* The one quiet, persistent line while the app works in its unsynced
|
|
6
|
+
* collection and something has been saved there: where it is kept, and the
|
|
7
|
+
* way to connect it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function UnsyncedLine({ ui }: {
|
|
10
|
+
readonly ui: CollectionUi;
|
|
11
|
+
}): JSX.Element | null;
|
|
12
|
+
/**
|
|
13
|
+
* With a collection open and work saved before connecting: offer to bring it
|
|
14
|
+
* in (asking first when names or types change), or to discard it. Afterwards,
|
|
15
|
+
* how it went.
|
|
16
|
+
*/
|
|
17
|
+
export declare function BringInBanner({ ui, variant }: {
|
|
18
|
+
readonly ui: CollectionUi;
|
|
19
|
+
readonly variant?: "banner" | "inline";
|
|
20
|
+
}): JSX.Element | null;
|
|
21
|
+
/**
|
|
22
|
+
* The save label for the app's own save notice while it works in its unsynced
|
|
23
|
+
* collection ("Saved only in this browser" instead of "Saved"), or null
|
|
24
|
+
* otherwise. Inside the gate it finds the entry by itself.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useUnsyncedSavedLabel(supplied?: Mdbase, storage?: "browser" | "device"): string | null;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useState, useSyncExternalStore } from "react";
|
|
3
|
+
import { ConfirmDialog } from "../ConfirmDialog.js";
|
|
4
|
+
import { useLocaleRevision } from "../i18n.js";
|
|
5
|
+
import { CollectionMdbaseContext } from "./CollectionSaveWarning.js";
|
|
6
|
+
import { defaultCollectionCopy } from "./copy.js";
|
|
7
|
+
import { ActionButton, NoticeBlock } from "./parts.js";
|
|
8
|
+
import { unsyncedPhase } from "./unsynced.js";
|
|
9
|
+
const savedLabel = ui => {
|
|
10
|
+
const options = ui.options.unsynced;
|
|
11
|
+
return typeof options === "object" && options.storage === "device" ? ui.copy.unsyncedSavedDevice : ui.copy.unsyncedSavedBrowser;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The one quiet, persistent line while the app works in its unsynced
|
|
15
|
+
* collection and something has been saved there: where it is kept, and the
|
|
16
|
+
* way to connect it.
|
|
17
|
+
*/
|
|
18
|
+
export function UnsyncedLine({
|
|
19
|
+
ui
|
|
20
|
+
}) {
|
|
21
|
+
if (ui.view.kind !== "unsynced" || !ui.view.unsyncedWork) return null;
|
|
22
|
+
return _jsxs("div", {
|
|
23
|
+
className: "mdbase-collections mdbase-collections-unsynced",
|
|
24
|
+
children: [_jsx("p", {
|
|
25
|
+
className: "mdbase-collections-unsynced-status",
|
|
26
|
+
children: savedLabel(ui)
|
|
27
|
+
}), _jsx(ActionButton, {
|
|
28
|
+
tone: "quiet",
|
|
29
|
+
inert: ui.busy !== null,
|
|
30
|
+
progress: ui.busy === "sign_in" || ui.busy === "add" ? ui.copy.addingCollection : null,
|
|
31
|
+
onClick: ui.actions.connect,
|
|
32
|
+
children: ui.copy.unsyncedConnect
|
|
33
|
+
})]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* With a collection open and work saved before connecting: offer to bring it
|
|
38
|
+
* in (asking first when names or types change), or to discard it. Afterwards,
|
|
39
|
+
* how it went.
|
|
40
|
+
*/
|
|
41
|
+
export function BringInBanner({
|
|
42
|
+
ui,
|
|
43
|
+
variant = "banner"
|
|
44
|
+
}) {
|
|
45
|
+
const [discarding, setDiscarding] = useState(false);
|
|
46
|
+
const {
|
|
47
|
+
view,
|
|
48
|
+
copy,
|
|
49
|
+
busy,
|
|
50
|
+
actions
|
|
51
|
+
} = ui;
|
|
52
|
+
if (view.kind !== "ready") return null;
|
|
53
|
+
const name = view.current?.name ?? view.heading;
|
|
54
|
+
const notice = ui.unsyncedNotice;
|
|
55
|
+
const review = ui.unsyncedReview;
|
|
56
|
+
if (!notice && !view.unsyncedWork && !ui.error) return null;
|
|
57
|
+
const consequence = review ? [review.counts.renamed > 0 ? copy.unsyncedReviewRenamed : null, (review.counts.changed ?? 0) > 0 ? copy.unsyncedReviewChanged : null, review.addTypes?.length ? ui.say("unsyncedReviewTypes", {
|
|
58
|
+
types: review.addTypes.join(", ")
|
|
59
|
+
}) : null, review.missingTypes.length > 0 ? copy.unsyncedReviewMissing : null].filter(Boolean).join(" ") : undefined;
|
|
60
|
+
return _jsxs("div", {
|
|
61
|
+
className: "mdbase-collections",
|
|
62
|
+
children: [ui.error && _jsx(NoticeBlock, {
|
|
63
|
+
notice: ui.error,
|
|
64
|
+
ui: ui,
|
|
65
|
+
variant: variant
|
|
66
|
+
}), !notice && !view.unsyncedWork ? null : notice ? _jsxs("div", {
|
|
67
|
+
className: `mdbase-collections-notice is-${variant}`,
|
|
68
|
+
"data-tone": notice.tone,
|
|
69
|
+
role: notice.tone === "info" ? "status" : "alert",
|
|
70
|
+
children: [_jsx("div", {
|
|
71
|
+
className: "mdbase-collections-notice-copy",
|
|
72
|
+
children: _jsx("p", {
|
|
73
|
+
className: "mdbase-collections-notice-message",
|
|
74
|
+
children: notice.message
|
|
75
|
+
})
|
|
76
|
+
}), _jsxs("div", {
|
|
77
|
+
className: "mdbase-collections-notice-actions",
|
|
78
|
+
children: [notice.key !== "unsynced_brought_in" && view.unsyncedWork && _jsx(ActionButton, {
|
|
79
|
+
tone: "primary",
|
|
80
|
+
inert: busy !== null,
|
|
81
|
+
progress: busy === "bring_in" ? copy.unsyncedBringingIn : null,
|
|
82
|
+
onClick: actions.bringIn,
|
|
83
|
+
children: copy.unsyncedBringIn
|
|
84
|
+
}), _jsx(ActionButton, {
|
|
85
|
+
tone: "quiet",
|
|
86
|
+
onClick: actions.dismissUnsyncedNotice,
|
|
87
|
+
children: copy.close
|
|
88
|
+
})]
|
|
89
|
+
})]
|
|
90
|
+
}) : _jsxs("div", {
|
|
91
|
+
className: `mdbase-collections-notice is-${variant}`,
|
|
92
|
+
"data-tone": "info",
|
|
93
|
+
role: "status",
|
|
94
|
+
children: [_jsx("div", {
|
|
95
|
+
className: "mdbase-collections-notice-copy",
|
|
96
|
+
children: _jsx("p", {
|
|
97
|
+
className: "mdbase-collections-notice-message",
|
|
98
|
+
children: ui.say("unsyncedBringInLead", {
|
|
99
|
+
collection: name
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
}), _jsxs("div", {
|
|
103
|
+
className: "mdbase-collections-notice-actions",
|
|
104
|
+
children: [_jsx(ActionButton, {
|
|
105
|
+
tone: "primary",
|
|
106
|
+
inert: busy !== null,
|
|
107
|
+
progress: busy === "bring_in" ? copy.unsyncedBringingIn : null,
|
|
108
|
+
onClick: actions.bringIn,
|
|
109
|
+
children: copy.unsyncedBringIn
|
|
110
|
+
}), _jsx(ActionButton, {
|
|
111
|
+
tone: "quiet",
|
|
112
|
+
inert: busy !== null,
|
|
113
|
+
onClick: () => setDiscarding(true),
|
|
114
|
+
children: copy.unsyncedDiscard
|
|
115
|
+
})]
|
|
116
|
+
})]
|
|
117
|
+
}), _jsx(ConfirmDialog, {
|
|
118
|
+
open: review !== null,
|
|
119
|
+
tone: "default",
|
|
120
|
+
initialFocus: "confirm",
|
|
121
|
+
title: ui.say("unsyncedReviewTitle", {
|
|
122
|
+
collection: name
|
|
123
|
+
}),
|
|
124
|
+
...(consequence ? {
|
|
125
|
+
consequence
|
|
126
|
+
} : {}),
|
|
127
|
+
confirmLabel: copy.unsyncedBringIn,
|
|
128
|
+
pendingLabel: copy.unsyncedBringingIn,
|
|
129
|
+
onClose: actions.dismissBringIn,
|
|
130
|
+
onConfirm: actions.confirmBringIn
|
|
131
|
+
}), _jsx(ConfirmDialog, {
|
|
132
|
+
open: discarding,
|
|
133
|
+
title: copy.unsyncedDiscardTitle,
|
|
134
|
+
consequence: ui.say("unsyncedDiscardBody"),
|
|
135
|
+
confirmLabel: copy.unsyncedDiscardConfirm,
|
|
136
|
+
pendingLabel: copy.unsyncedDiscarding,
|
|
137
|
+
busy: busy === "discard_unsynced",
|
|
138
|
+
onClose: () => setDiscarding(false),
|
|
139
|
+
onConfirm: () => {
|
|
140
|
+
setDiscarding(false);
|
|
141
|
+
actions.discardUnsynced();
|
|
142
|
+
}
|
|
143
|
+
})]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
const emptySubscribe = () => () => {};
|
|
147
|
+
const emptySnapshot = () => null;
|
|
148
|
+
/**
|
|
149
|
+
* The save label for the app's own save notice while it works in its unsynced
|
|
150
|
+
* collection ("Saved only in this browser" instead of "Saved"), or null
|
|
151
|
+
* otherwise. Inside the gate it finds the entry by itself.
|
|
152
|
+
*/
|
|
153
|
+
export function useUnsyncedSavedLabel(supplied, storage = "browser") {
|
|
154
|
+
useLocaleRevision();
|
|
155
|
+
const inherited = useContext(CollectionMdbaseContext);
|
|
156
|
+
const mdbase = supplied ?? inherited;
|
|
157
|
+
const phase = useSyncExternalStore(mdbase?.subscribe ?? emptySubscribe, () => mdbase?.getSnapshot().phase ?? null, emptySnapshot);
|
|
158
|
+
if (!phase || !unsyncedPhase(phase)) return null;
|
|
159
|
+
return storage === "device" ? defaultCollectionCopy.unsyncedSavedDevice : defaultCollectionCopy.unsyncedSavedBrowser;
|
|
160
|
+
}
|
|
@@ -92,6 +92,26 @@ export declare const defaultCollectionCopy: {
|
|
|
92
92
|
readonly deleteConfirm: string;
|
|
93
93
|
readonly deleting: string;
|
|
94
94
|
readonly signOutAnyway: string;
|
|
95
|
+
readonly unsyncedSavedBrowser: string;
|
|
96
|
+
readonly unsyncedSavedDevice: string;
|
|
97
|
+
readonly unsyncedConnect: string;
|
|
98
|
+
readonly continueWithoutConnecting: string;
|
|
99
|
+
readonly unsyncedBringInLead: string;
|
|
100
|
+
readonly unsyncedBringIn: string;
|
|
101
|
+
readonly unsyncedBringingIn: string;
|
|
102
|
+
readonly unsyncedBroughtIn: string;
|
|
103
|
+
readonly unsyncedBroughtInOpen: string;
|
|
104
|
+
readonly unsyncedBringInFailed: string;
|
|
105
|
+
readonly unsyncedReviewTitle: string;
|
|
106
|
+
readonly unsyncedReviewRenamed: string;
|
|
107
|
+
readonly unsyncedReviewTypes: string;
|
|
108
|
+
readonly unsyncedReviewChanged: string;
|
|
109
|
+
readonly unsyncedReviewMissing: string;
|
|
110
|
+
readonly unsyncedDiscard: string;
|
|
111
|
+
readonly unsyncedDiscardTitle: string;
|
|
112
|
+
readonly unsyncedDiscardBody: string;
|
|
113
|
+
readonly unsyncedDiscardConfirm: string;
|
|
114
|
+
readonly unsyncedDiscarding: string;
|
|
95
115
|
readonly close: string;
|
|
96
116
|
};
|
|
97
117
|
export type CollectionCopyKey = keyof typeof defaultCollectionCopy;
|
package/dist/collections/copy.js
CHANGED
|
@@ -921,6 +921,216 @@ export const defaultCollectionCopy = {
|
|
|
921
921
|
context: "Collection access interface"
|
|
922
922
|
});
|
|
923
923
|
},
|
|
924
|
+
get unsyncedSavedBrowser() {
|
|
925
|
+
return i18n._(
|
|
926
|
+
/** i18n */
|
|
927
|
+
{
|
|
928
|
+
id: "JhrsQK",
|
|
929
|
+
message: "Saved only in this browser",
|
|
930
|
+
context: "Collection access interface"
|
|
931
|
+
});
|
|
932
|
+
},
|
|
933
|
+
get unsyncedSavedDevice() {
|
|
934
|
+
return i18n._(
|
|
935
|
+
/** i18n */
|
|
936
|
+
{
|
|
937
|
+
id: "J-tjpL",
|
|
938
|
+
message: "Saved only on this device",
|
|
939
|
+
context: "Collection access interface"
|
|
940
|
+
});
|
|
941
|
+
},
|
|
942
|
+
get unsyncedConnect() {
|
|
943
|
+
return i18n._(
|
|
944
|
+
/** i18n */
|
|
945
|
+
{
|
|
946
|
+
id: "noD4R_",
|
|
947
|
+
message: "Connect to sync your work",
|
|
948
|
+
context: "Collection access interface"
|
|
949
|
+
});
|
|
950
|
+
},
|
|
951
|
+
get continueWithoutConnecting() {
|
|
952
|
+
return i18n._(
|
|
953
|
+
/** i18n */
|
|
954
|
+
{
|
|
955
|
+
id: "S3F0VP",
|
|
956
|
+
message: "Continue without connecting",
|
|
957
|
+
context: "Collection access interface"
|
|
958
|
+
});
|
|
959
|
+
},
|
|
960
|
+
get unsyncedBringInLead() {
|
|
961
|
+
return i18n._({
|
|
962
|
+
...
|
|
963
|
+
/** i18n */
|
|
964
|
+
{
|
|
965
|
+
id: "s1Ck-j",
|
|
966
|
+
message: "You have work that isn't in {collection} yet.",
|
|
967
|
+
context: "Collection access interface"
|
|
968
|
+
},
|
|
969
|
+
values: {
|
|
970
|
+
collection: "{collection}"
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
},
|
|
974
|
+
get unsyncedBringIn() {
|
|
975
|
+
return i18n._(
|
|
976
|
+
/** i18n */
|
|
977
|
+
{
|
|
978
|
+
id: "F3WtMc",
|
|
979
|
+
message: "Bring it in",
|
|
980
|
+
context: "Collection access interface"
|
|
981
|
+
});
|
|
982
|
+
},
|
|
983
|
+
get unsyncedBringingIn() {
|
|
984
|
+
return i18n._(
|
|
985
|
+
/** i18n */
|
|
986
|
+
{
|
|
987
|
+
id: "nLO4R9",
|
|
988
|
+
message: "Bringing in\u2026",
|
|
989
|
+
context: "Collection access interface"
|
|
990
|
+
});
|
|
991
|
+
},
|
|
992
|
+
get unsyncedBroughtIn() {
|
|
993
|
+
return i18n._({
|
|
994
|
+
...
|
|
995
|
+
/** i18n */
|
|
996
|
+
{
|
|
997
|
+
id: "22raEF",
|
|
998
|
+
message: "Your work is now in {collection}.",
|
|
999
|
+
context: "Collection access interface"
|
|
1000
|
+
},
|
|
1001
|
+
values: {
|
|
1002
|
+
collection: "{collection}"
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
},
|
|
1006
|
+
get unsyncedBroughtInOpen() {
|
|
1007
|
+
return i18n._({
|
|
1008
|
+
...
|
|
1009
|
+
/** i18n */
|
|
1010
|
+
{
|
|
1011
|
+
id: "YFAS9T",
|
|
1012
|
+
message: "Your work is now in {collection}. If it's still open in another tab, close it there, then bring it in again.",
|
|
1013
|
+
context: "Collection access interface"
|
|
1014
|
+
},
|
|
1015
|
+
values: {
|
|
1016
|
+
collection: "{collection}"
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
},
|
|
1020
|
+
get unsyncedBringInFailed() {
|
|
1021
|
+
return i18n._(
|
|
1022
|
+
/** i18n */
|
|
1023
|
+
{
|
|
1024
|
+
id: "YeTn-r",
|
|
1025
|
+
message: "Some of your work couldn't be brought in. Try again.",
|
|
1026
|
+
context: "Collection access interface"
|
|
1027
|
+
});
|
|
1028
|
+
},
|
|
1029
|
+
get unsyncedReviewTitle() {
|
|
1030
|
+
return i18n._({
|
|
1031
|
+
...
|
|
1032
|
+
/** i18n */
|
|
1033
|
+
{
|
|
1034
|
+
id: "RAaA7k",
|
|
1035
|
+
message: "Bring your work into {collection}?",
|
|
1036
|
+
context: "Collection access interface"
|
|
1037
|
+
},
|
|
1038
|
+
values: {
|
|
1039
|
+
collection: "{collection}"
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
},
|
|
1043
|
+
get unsyncedReviewRenamed() {
|
|
1044
|
+
return i18n._(
|
|
1045
|
+
/** i18n */
|
|
1046
|
+
{
|
|
1047
|
+
id: "gpOX_m",
|
|
1048
|
+
message: "Some items get a new name because their names are already taken.",
|
|
1049
|
+
context: "Collection access interface"
|
|
1050
|
+
});
|
|
1051
|
+
},
|
|
1052
|
+
get unsyncedReviewTypes() {
|
|
1053
|
+
return i18n._({
|
|
1054
|
+
...
|
|
1055
|
+
/** i18n */
|
|
1056
|
+
{
|
|
1057
|
+
id: "1m_O5B",
|
|
1058
|
+
message: "These types are added: {types}.",
|
|
1059
|
+
context: "Collection access interface"
|
|
1060
|
+
},
|
|
1061
|
+
values: {
|
|
1062
|
+
types: "{types}"
|
|
1063
|
+
}
|
|
1064
|
+
});
|
|
1065
|
+
},
|
|
1066
|
+
get unsyncedReviewChanged() {
|
|
1067
|
+
return i18n._(
|
|
1068
|
+
/** i18n */
|
|
1069
|
+
{
|
|
1070
|
+
id: "vJnf00",
|
|
1071
|
+
message: "Some items changed after they were brought in. Their newer versions are added beside them.",
|
|
1072
|
+
context: "Collection access interface"
|
|
1073
|
+
});
|
|
1074
|
+
},
|
|
1075
|
+
get unsyncedReviewMissing() {
|
|
1076
|
+
return i18n._(
|
|
1077
|
+
/** i18n */
|
|
1078
|
+
{
|
|
1079
|
+
id: "E5Yg13",
|
|
1080
|
+
message: "Some items use types this collection doesn't have. They're brought in as they are.",
|
|
1081
|
+
context: "Collection access interface"
|
|
1082
|
+
});
|
|
1083
|
+
},
|
|
1084
|
+
get unsyncedDiscard() {
|
|
1085
|
+
return i18n._(
|
|
1086
|
+
/** i18n */
|
|
1087
|
+
{
|
|
1088
|
+
id: "nuwdSX",
|
|
1089
|
+
message: "Discard\u2026",
|
|
1090
|
+
context: "Collection access interface"
|
|
1091
|
+
});
|
|
1092
|
+
},
|
|
1093
|
+
get unsyncedDiscardTitle() {
|
|
1094
|
+
return i18n._(
|
|
1095
|
+
/** i18n */
|
|
1096
|
+
{
|
|
1097
|
+
id: "O_A3T7",
|
|
1098
|
+
message: "Discard work that isn't in a collection?",
|
|
1099
|
+
context: "Collection access interface"
|
|
1100
|
+
});
|
|
1101
|
+
},
|
|
1102
|
+
get unsyncedDiscardBody() {
|
|
1103
|
+
return i18n._({
|
|
1104
|
+
...
|
|
1105
|
+
/** i18n */
|
|
1106
|
+
{
|
|
1107
|
+
id: "Eo7hjG",
|
|
1108
|
+
message: "It's erased from {app} on this device. This can't be undone.",
|
|
1109
|
+
context: "Collection access interface"
|
|
1110
|
+
},
|
|
1111
|
+
values: {
|
|
1112
|
+
app: "{app}"
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1115
|
+
},
|
|
1116
|
+
get unsyncedDiscardConfirm() {
|
|
1117
|
+
return i18n._(
|
|
1118
|
+
/** i18n */
|
|
1119
|
+
{
|
|
1120
|
+
id: "BtShoJ",
|
|
1121
|
+
message: "Discard",
|
|
1122
|
+
context: "Collection access interface"
|
|
1123
|
+
});
|
|
1124
|
+
},
|
|
1125
|
+
get unsyncedDiscarding() {
|
|
1126
|
+
return i18n._(
|
|
1127
|
+
/** i18n */
|
|
1128
|
+
{
|
|
1129
|
+
id: "_9_0zY",
|
|
1130
|
+
message: "Discarding\u2026",
|
|
1131
|
+
context: "Collection access interface"
|
|
1132
|
+
});
|
|
1133
|
+
},
|
|
924
1134
|
get close() {
|
|
925
1135
|
return i18n._(
|
|
926
1136
|
/** i18n */
|
|
@@ -7,6 +7,7 @@ import "../i18n.js";
|
|
|
7
7
|
*/
|
|
8
8
|
import type { MdbaseLinks, MdbasePhase, MdbaseProblem, MdbaseSnapshot } from "@mdbase-dev/sdk";
|
|
9
9
|
import { type CollectionCopy } from "./copy.js";
|
|
10
|
+
import { type UnsyncedPhase } from "./unsynced.js";
|
|
10
11
|
export type CollectionRole = "owner" | "editor" | "viewer";
|
|
11
12
|
/** One approved collection, ready to render as a list row. */
|
|
12
13
|
export interface CollectionRow {
|
|
@@ -81,6 +82,8 @@ interface Common {
|
|
|
81
82
|
readonly links: MdbaseLinks | null;
|
|
82
83
|
/** True when "Choose a different collection" leaves something open or requested. */
|
|
83
84
|
readonly canChooseAnother: boolean;
|
|
85
|
+
/** Work saved before connecting that is not in a collection yet. */
|
|
86
|
+
readonly unsyncedWork: boolean;
|
|
84
87
|
}
|
|
85
88
|
export type CollectionView = Common & ({
|
|
86
89
|
readonly kind: "starting";
|
|
@@ -116,6 +119,12 @@ export type CollectionView = Common & ({
|
|
|
116
119
|
kind: "ready";
|
|
117
120
|
}>;
|
|
118
121
|
readonly notice: CollectionNotice | null;
|
|
122
|
+
}
|
|
123
|
+
/** The app's unsynced collection is open: render the app, saved only on this device. */
|
|
124
|
+
| {
|
|
125
|
+
readonly kind: "unsynced";
|
|
126
|
+
readonly collectionId: string;
|
|
127
|
+
readonly phase: UnsyncedPhase;
|
|
119
128
|
} | {
|
|
120
129
|
readonly kind: "unavailable";
|
|
121
130
|
readonly notice: CollectionNotice;
|
|
@@ -2,6 +2,7 @@ import { i18n as _i18n } from "@lingui/core";
|
|
|
2
2
|
import "../i18n.js";
|
|
3
3
|
import { describeError } from "@mdbase-dev/sdk/describe";
|
|
4
4
|
import { defaultCollectionCopy, fill } from "./copy.js";
|
|
5
|
+
import { hasUnsyncedWork, unsyncedPhase } from "./unsynced.js";
|
|
5
6
|
/** Map an SDK snapshot to the screen to show. */
|
|
6
7
|
export function collectionView(snapshot, options) {
|
|
7
8
|
const copy = {
|
|
@@ -25,7 +26,18 @@ export function collectionView(snapshot, options) {
|
|
|
25
26
|
collections,
|
|
26
27
|
current,
|
|
27
28
|
links: snapshot.links ?? null,
|
|
28
|
-
canChooseAnother: signedIn && (currentId !== null || (snapshot.selection.requested.collectionId ?? null) !== null)
|
|
29
|
+
canChooseAnother: signedIn && (currentId !== null || (snapshot.selection.requested.collectionId ?? null) !== null),
|
|
30
|
+
unsyncedWork: hasUnsyncedWork(snapshot)
|
|
31
|
+
};
|
|
32
|
+
// Not part of every SDK's phase union yet (see unsynced.ts).
|
|
33
|
+
const unsynced = unsyncedPhase(phase);
|
|
34
|
+
if (unsynced) return {
|
|
35
|
+
...common,
|
|
36
|
+
kind: "unsynced",
|
|
37
|
+
collectionId: unsynced.collectionId,
|
|
38
|
+
phase: unsynced,
|
|
39
|
+
heading: app,
|
|
40
|
+
lead: null
|
|
29
41
|
};
|
|
30
42
|
switch (phase.kind) {
|
|
31
43
|
case "starting":
|