@formicoidea/labre-core-database 2.0.0 → 2.1.0
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/creation-popover.js +9 -8
- package/dist/data-source-picker.js +8 -9
- package/dist/database-page/database-page-root.js +10 -5
- package/dist/database-page/database-page.js +21 -0
- package/dist/new-source-entry.d.ts +20 -0
- package/dist/new-source-entry.js +130 -0
- package/dist/translations.d.ts +5 -0
- package/dist/translations.js +26 -0
- package/dist/view-bar/add-view-menu.d.ts +4 -2
- package/dist/view-bar/add-view-menu.js +8 -7
- package/package.json +2 -2
package/dist/creation-popover.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { connectDatabaseToSource, DATABASE_CREATION_TITLE, reconnectDatabaseView, } from '@formicoidea/labre-core/blocks/database';
|
|
2
2
|
import { menu, popMenu, popupTargetFromElement, } from '@formicoidea/labre-core/components/context-menu';
|
|
3
3
|
import { DataSourcePickerProvider, translateKey, } from '@formicoidea/labre-core/shared/services';
|
|
4
|
-
import { LinkIcon
|
|
4
|
+
import { LinkIcon } from '@blocksuite/icons/lit';
|
|
5
5
|
import { dataSourcePickerItems } from './data-source-picker.js';
|
|
6
|
+
import { named, newSourceEntry } from './new-source-entry.js';
|
|
6
7
|
import { DATABASE_CREATION_LINK_EXISTING, DATABASE_CREATION_NEW_SOURCE, } from './translations.js';
|
|
7
8
|
/** The block the entry inserted, while it is still a database. */
|
|
8
9
|
function databaseModel(std, blockId) {
|
|
@@ -38,15 +39,13 @@ export function databaseCreationItems(std, picker, blockId, viewId) {
|
|
|
38
39
|
};
|
|
39
40
|
const createDatabase = picker.createDatabase;
|
|
40
41
|
const list = picker.list();
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
const newSource = createDatabase &&
|
|
43
|
+
newSourceEntry(std, picker.sourceName, {
|
|
43
44
|
name: t(DATABASE_CREATION_NEW_SOURCE),
|
|
44
|
-
prefix: PlusIcon(),
|
|
45
45
|
testId: 'database-creation-new-source',
|
|
46
|
-
|
|
47
|
-
select: () => {
|
|
46
|
+
create: sourceName => {
|
|
48
47
|
createDatabase
|
|
49
|
-
|
|
48
|
+
.call(picker, ...named(sourceName))
|
|
50
49
|
.then(database => {
|
|
51
50
|
const source = database?.sources[0];
|
|
52
51
|
if (database && source)
|
|
@@ -54,7 +53,9 @@ export function databaseCreationItems(std, picker, blockId, viewId) {
|
|
|
54
53
|
})
|
|
55
54
|
.catch(console.error);
|
|
56
55
|
},
|
|
57
|
-
})
|
|
56
|
+
});
|
|
57
|
+
return [
|
|
58
|
+
(popover, index) => newSource && !std.store.readonly ? newSource(popover, index) : undefined,
|
|
58
59
|
menu.subMenu({
|
|
59
60
|
name: t(DATABASE_CREATION_LINK_EXISTING),
|
|
60
61
|
prefix: LinkIcon(),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { menu, popMenu, } from '@formicoidea/labre-core/components/context-menu';
|
|
2
2
|
import { DOC_UNTITLED, translateKey, } from '@formicoidea/labre-core/shared/services';
|
|
3
|
-
import { DatabaseTableViewIcon
|
|
3
|
+
import { DatabaseTableViewIcon } from '@blocksuite/icons/lit';
|
|
4
|
+
import { named, newSourceEntry } from './new-source-entry.js';
|
|
4
5
|
import { PICKER_EMPTY, PICKER_NEW_DATABASE, PICKER_NEW_SOURCE, PICKER_TITLE, } from './translations.js';
|
|
5
6
|
function sourceItems(std, picker, database, onPick, offerCreate) {
|
|
6
7
|
const t = (wording) => translateKey(std, wording[0], wording[1]);
|
|
@@ -12,13 +13,12 @@ function sourceItems(std, picker, database, onPick, offerCreate) {
|
|
|
12
13
|
}));
|
|
13
14
|
const createSource = picker.createSource;
|
|
14
15
|
if (createSource && offerCreate && !std.store.readonly) {
|
|
15
|
-
items.push(
|
|
16
|
+
items.push(newSourceEntry(std, picker.sourceName, {
|
|
16
17
|
name: t(PICKER_NEW_SOURCE),
|
|
17
|
-
prefix: PlusIcon(),
|
|
18
18
|
testId: 'data-source-picker-new-source',
|
|
19
|
-
|
|
19
|
+
create: sourceName => {
|
|
20
20
|
createSource
|
|
21
|
-
.call(picker, database.id)
|
|
21
|
+
.call(picker, database.id, ...named(sourceName))
|
|
22
22
|
.then(created => {
|
|
23
23
|
if (!created)
|
|
24
24
|
return;
|
|
@@ -80,13 +80,12 @@ export function dataSourcePickerItems(std, picker, options) {
|
|
|
80
80
|
if (createDatabase && !std.store.readonly) {
|
|
81
81
|
items.push(menu.group({
|
|
82
82
|
items: [
|
|
83
|
-
|
|
83
|
+
newSourceEntry(std, picker.sourceName, {
|
|
84
84
|
name: t(PICKER_NEW_DATABASE),
|
|
85
|
-
prefix: PlusIcon(),
|
|
86
85
|
testId: 'data-source-picker-new-database',
|
|
87
|
-
|
|
86
|
+
create: sourceName => {
|
|
88
87
|
createDatabase
|
|
89
|
-
.call(picker)
|
|
88
|
+
.call(picker, ...named(sourceName))
|
|
90
89
|
.then(database => {
|
|
91
90
|
const first = database?.sources[0];
|
|
92
91
|
if (!database || !first)
|
|
@@ -90,6 +90,10 @@ export class DatabasePageRoot extends BlockComponent {
|
|
|
90
90
|
affine-database-page-root:has(dv-table-view-ui[data-page-layout]) {
|
|
91
91
|
width: max-content;
|
|
92
92
|
min-width: 100%;
|
|
93
|
+
/* The paddings sit inside that 100%: in the content box a table
|
|
94
|
+
narrower than the page overflowed by both gutters, and every page
|
|
95
|
+
showed a sideways scrollbar (labre recette of 2.0). */
|
|
96
|
+
box-sizing: border-box;
|
|
93
97
|
/* Widened, the root is no longer centred by its auto margins: it
|
|
94
98
|
pads its left side by what centring gave the page heading (whose
|
|
95
99
|
container in doc-title is the same max-width, centred in the
|
|
@@ -105,12 +109,13 @@ export class DatabasePageRoot extends BlockComponent {
|
|
|
105
109
|
var(--affine-editor-side-padding, 24px)
|
|
106
110
|
);
|
|
107
111
|
}
|
|
108
|
-
/* A phone keeps the page root's narrow padding (page-root-block.ts).
|
|
112
|
+
/* A phone keeps the page root's narrow padding (page-root-block.ts).
|
|
113
|
+
The variable, not the padding: the block's sticky view bar reads it,
|
|
114
|
+
and a fixed 24px left the bar at the host's wider gutter, right of
|
|
115
|
+
the title and the rows (labre recette of 2.0). */
|
|
109
116
|
@container viewport (width <= 640px) {
|
|
110
|
-
affine-database-page-root
|
|
111
|
-
|
|
112
|
-
padding-left: 24px;
|
|
113
|
-
padding-right: 24px;
|
|
117
|
+
affine-database-page-root {
|
|
118
|
+
--affine-editor-side-padding: 24px;
|
|
114
119
|
}
|
|
115
120
|
}
|
|
116
121
|
.affine-database-page-missing {
|
|
@@ -115,6 +115,27 @@ let DatabasePageHost = (() => {
|
|
|
115
115
|
/* The container the page root's narrow-screen query reads. */
|
|
116
116
|
container-type: inline-size;
|
|
117
117
|
container-name: viewport;
|
|
118
|
+
/* A wide table scrolled sideways fades into the gutters instead of
|
|
119
|
+
being cut at the page's edges (labre recette of 2.0). The fade
|
|
120
|
+
stays in the gutter (at most 24px, the phone's), so nothing at
|
|
121
|
+
rest is faded. Its layer covers the padding box only: the two
|
|
122
|
+
layers below it give back the scrollbars, which sit between the
|
|
123
|
+
padding box and the border box. */
|
|
124
|
+
--affine-database-page-fade: min(
|
|
125
|
+
var(--affine-editor-side-padding, 24px),
|
|
126
|
+
24px
|
|
127
|
+
);
|
|
128
|
+
mask:
|
|
129
|
+
linear-gradient(
|
|
130
|
+
to right,
|
|
131
|
+
transparent,
|
|
132
|
+
#000 var(--affine-database-page-fade),
|
|
133
|
+
#000 calc(100% - var(--affine-database-page-fade)),
|
|
134
|
+
transparent
|
|
135
|
+
)
|
|
136
|
+
padding-box add,
|
|
137
|
+
linear-gradient(#000 0 0) border-box exclude,
|
|
138
|
+
linear-gradient(#000 0 0) padding-box;
|
|
118
139
|
}
|
|
119
140
|
/* The editor takes the height the heading leaves (std gives it 100%,
|
|
120
141
|
which overflowed by the heading's height: a scrollbar on a short
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type MenuConfig } from '@formicoidea/labre-core/components/context-menu';
|
|
2
|
+
import { type DataSourcePickerSourceNaming } from '@formicoidea/labre-core/shared/services';
|
|
3
|
+
import type { BlockStdScope } from '@formicoidea/labre-core/std';
|
|
4
|
+
export interface NewSourceEntry {
|
|
5
|
+
name: string;
|
|
6
|
+
testId: string;
|
|
7
|
+
/** Create, with the trimmed name when the host names its sources. */
|
|
8
|
+
create: (sourceName: string | undefined) => void;
|
|
9
|
+
}
|
|
10
|
+
/** The name as an argument only when there is one: a host without naming is called as in 2.0. */
|
|
11
|
+
export declare const named: (sourceName: string | undefined) => [] | [string];
|
|
12
|
+
/**
|
|
13
|
+
* Every entry that creates a source (ADR 0035 amendment of 2026-10-30):
|
|
14
|
+
* "New source", "New database", "With a new source", "New empty source".
|
|
15
|
+
* Without the host's `sourceName` it creates at once, as in 2.0. With it,
|
|
16
|
+
* it opens a step in the same cascade (a sub-menu, as renaming a select
|
|
17
|
+
* option does): the field on the host's suggestion, the host's verdict
|
|
18
|
+
* under it, "Create". Only `'ok'` creates; Enter is "Create".
|
|
19
|
+
*/
|
|
20
|
+
export declare function newSourceEntry(std: BlockStdScope | undefined, naming: DataSourcePickerSourceNaming | undefined, entry: NewSourceEntry): MenuConfig;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { menu, } from '@formicoidea/labre-core/components/context-menu';
|
|
2
|
+
import { translateKey, } from '@formicoidea/labre-core/shared/services';
|
|
3
|
+
import { PlusIcon } from '@blocksuite/icons/lit';
|
|
4
|
+
import { computed, signal } from '@preact/signals-core';
|
|
5
|
+
import { html } from 'lit';
|
|
6
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
|
7
|
+
import { SOURCE_NAME_CREATE, SOURCE_NAME_EMPTY, SOURCE_NAME_OK, SOURCE_NAME_PLACEHOLDER, SOURCE_NAME_TAKEN, } from './translations.js';
|
|
8
|
+
/** The name as an argument only when there is one: a host without naming is called as in 2.0. */
|
|
9
|
+
export const named = (sourceName) => sourceName === undefined ? [] : [sourceName];
|
|
10
|
+
const VERDICT_WORDING = {
|
|
11
|
+
ok: SOURCE_NAME_OK,
|
|
12
|
+
taken: SOURCE_NAME_TAKEN,
|
|
13
|
+
empty: SOURCE_NAME_EMPTY,
|
|
14
|
+
};
|
|
15
|
+
function verdictOf(naming, name) {
|
|
16
|
+
try {
|
|
17
|
+
return naming.check(name);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.error(error);
|
|
21
|
+
return 'empty';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Every entry that creates a source (ADR 0035 amendment of 2026-10-30):
|
|
26
|
+
* "New source", "New database", "With a new source", "New empty source".
|
|
27
|
+
* Without the host's `sourceName` it creates at once, as in 2.0. With it,
|
|
28
|
+
* it opens a step in the same cascade (a sub-menu, as renaming a select
|
|
29
|
+
* option does): the field on the host's suggestion, the host's verdict
|
|
30
|
+
* under it, "Create". Only `'ok'` creates; Enter is "Create".
|
|
31
|
+
*/
|
|
32
|
+
export function newSourceEntry(std, naming, entry) {
|
|
33
|
+
if (!naming) {
|
|
34
|
+
return menu.action({
|
|
35
|
+
name: entry.name,
|
|
36
|
+
prefix: PlusIcon(),
|
|
37
|
+
testId: entry.testId,
|
|
38
|
+
select: () => entry.create(undefined),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const t = (wording) => std ? translateKey(std, ...wording) : wording[1];
|
|
42
|
+
return parent => {
|
|
43
|
+
const suggested$ = signal(undefined);
|
|
44
|
+
const typed$ = signal(undefined);
|
|
45
|
+
const name$ = computed(() => typed$.value ?? suggested$.value ?? '');
|
|
46
|
+
let asked = false;
|
|
47
|
+
// Never written while the step draws (a computed): always a microtask.
|
|
48
|
+
const ask = () => {
|
|
49
|
+
asked = true;
|
|
50
|
+
Promise.resolve()
|
|
51
|
+
.then(() => naming.suggest())
|
|
52
|
+
.then(name => {
|
|
53
|
+
suggested$.value = name;
|
|
54
|
+
}, error => {
|
|
55
|
+
console.error(error);
|
|
56
|
+
suggested$.value = '';
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const create = () => {
|
|
60
|
+
const name = name$.peek();
|
|
61
|
+
if (verdictOf(naming, name) !== 'ok')
|
|
62
|
+
return false;
|
|
63
|
+
entry.create(name.trim());
|
|
64
|
+
return true;
|
|
65
|
+
};
|
|
66
|
+
const field = (step) => {
|
|
67
|
+
if (!asked)
|
|
68
|
+
ask();
|
|
69
|
+
if (suggested$.value === undefined)
|
|
70
|
+
return;
|
|
71
|
+
return menu.input({
|
|
72
|
+
initialValue: suggested$.value,
|
|
73
|
+
placeholder: t(SOURCE_NAME_PLACEHOLDER),
|
|
74
|
+
onChange: value => {
|
|
75
|
+
typed$.value = value;
|
|
76
|
+
},
|
|
77
|
+
onEnter: () => {
|
|
78
|
+
if (!create())
|
|
79
|
+
return false;
|
|
80
|
+
step.options.onComplete?.();
|
|
81
|
+
return true;
|
|
82
|
+
},
|
|
83
|
+
})(step);
|
|
84
|
+
};
|
|
85
|
+
const verdict = () => {
|
|
86
|
+
if (suggested$.value === undefined)
|
|
87
|
+
return;
|
|
88
|
+
const value = verdictOf(naming, name$.value);
|
|
89
|
+
return html `<div
|
|
90
|
+
role="status"
|
|
91
|
+
data-testid="${entry.testId}-verdict"
|
|
92
|
+
data-verdict=${value}
|
|
93
|
+
style=${styleMap({
|
|
94
|
+
padding: '0 6px',
|
|
95
|
+
fontSize: '12px',
|
|
96
|
+
lineHeight: '20px',
|
|
97
|
+
color: value === 'ok'
|
|
98
|
+
? 'var(--affine-text-secondary-color)'
|
|
99
|
+
: 'var(--affine-error-color)',
|
|
100
|
+
})}
|
|
101
|
+
>
|
|
102
|
+
${t(VERDICT_WORDING[value])}
|
|
103
|
+
</div>`;
|
|
104
|
+
};
|
|
105
|
+
return menu.subMenu({
|
|
106
|
+
name: entry.name,
|
|
107
|
+
prefix: PlusIcon(),
|
|
108
|
+
testId: entry.testId,
|
|
109
|
+
options: {
|
|
110
|
+
testId: `${entry.testId}-naming`,
|
|
111
|
+
// Each opening of the step starts again from a new suggestion.
|
|
112
|
+
onClose: () => {
|
|
113
|
+
asked = false;
|
|
114
|
+
suggested$.value = undefined;
|
|
115
|
+
typed$.value = undefined;
|
|
116
|
+
},
|
|
117
|
+
items: [
|
|
118
|
+
field,
|
|
119
|
+
verdict,
|
|
120
|
+
menu.action({
|
|
121
|
+
name: t(SOURCE_NAME_CREATE),
|
|
122
|
+
testId: `${entry.testId}-create`,
|
|
123
|
+
hide: () => suggested$.value === undefined,
|
|
124
|
+
select: () => (create() ? undefined : false),
|
|
125
|
+
}),
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
})(parent);
|
|
129
|
+
};
|
|
130
|
+
}
|
package/dist/translations.d.ts
CHANGED
|
@@ -64,6 +64,11 @@ export declare const PICKER_TITLE: ChromeWording;
|
|
|
64
64
|
export declare const PICKER_NEW_SOURCE: ChromeWording;
|
|
65
65
|
export declare const PICKER_NEW_DATABASE: ChromeWording;
|
|
66
66
|
/** The picker on a host that lists no database and creates none. */
|
|
67
|
+
export declare const SOURCE_NAME_PLACEHOLDER: ChromeWording;
|
|
68
|
+
export declare const SOURCE_NAME_OK: ChromeWording;
|
|
69
|
+
export declare const SOURCE_NAME_TAKEN: ChromeWording;
|
|
70
|
+
export declare const SOURCE_NAME_CREATE: ChromeWording;
|
|
71
|
+
export declare const SOURCE_NAME_EMPTY: ChromeWording;
|
|
67
72
|
export declare const PICKER_EMPTY: ChromeWording;
|
|
68
73
|
export declare const SLASH_LINKED_VIEW: ChromeWording;
|
|
69
74
|
export declare const SLASH_LINKED_VIEW_DESCRIPTION: ChromeWording;
|
package/dist/translations.js
CHANGED
|
@@ -133,6 +133,27 @@ export const PICKER_NEW_DATABASE = [
|
|
|
133
133
|
'New database',
|
|
134
134
|
];
|
|
135
135
|
/** The picker on a host that lists no database and creates none. */
|
|
136
|
+
/* ── Naming a new source (ADR 0035 amendment of 2026-10-30) ───────────── */
|
|
137
|
+
export const SOURCE_NAME_PLACEHOLDER = [
|
|
138
|
+
'com.labre.database.source-name.placeholder',
|
|
139
|
+
'Source name',
|
|
140
|
+
];
|
|
141
|
+
export const SOURCE_NAME_OK = [
|
|
142
|
+
'com.labre.database.source-name.ok',
|
|
143
|
+
'Available',
|
|
144
|
+
];
|
|
145
|
+
export const SOURCE_NAME_TAKEN = [
|
|
146
|
+
'com.labre.database.source-name.taken',
|
|
147
|
+
'Another source already has this name.',
|
|
148
|
+
];
|
|
149
|
+
export const SOURCE_NAME_CREATE = [
|
|
150
|
+
'com.labre.database.source-name.create',
|
|
151
|
+
'Create source',
|
|
152
|
+
];
|
|
153
|
+
export const SOURCE_NAME_EMPTY = [
|
|
154
|
+
'com.labre.database.source-name.empty',
|
|
155
|
+
'Give the source a name.',
|
|
156
|
+
];
|
|
136
157
|
export const PICKER_EMPTY = [
|
|
137
158
|
'com.labre.database.picker.empty',
|
|
138
159
|
'No database to show',
|
|
@@ -162,6 +183,11 @@ const DATABASE_EDITOR_WORDINGS = [
|
|
|
162
183
|
PROPERTIES_PANEL_UNAVAILABLE,
|
|
163
184
|
SLASH_LINKED_VIEW,
|
|
164
185
|
SLASH_LINKED_VIEW_DESCRIPTION,
|
|
186
|
+
SOURCE_NAME_CREATE,
|
|
187
|
+
SOURCE_NAME_EMPTY,
|
|
188
|
+
SOURCE_NAME_OK,
|
|
189
|
+
SOURCE_NAME_PLACEHOLDER,
|
|
190
|
+
SOURCE_NAME_TAKEN,
|
|
165
191
|
VIEW_MENU_IMPORT,
|
|
166
192
|
VIEW_SETTINGS_SOURCE,
|
|
167
193
|
];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HostedDataSourceBase } from '@formicoidea/labre-core/blocks/database';
|
|
2
|
-
import { type DataSourcePickerService } from '@formicoidea/labre-core/shared/services';
|
|
2
|
+
import { type DataSourcePickerService, type DataSourcePickerSourceNaming } from '@formicoidea/labre-core/shared/services';
|
|
3
3
|
import { type AddViewMenu, type AddViewMenuContext } from '@formicoidea/labre-core/data-view';
|
|
4
4
|
import { type AddViewSource } from './add-view-sources.js';
|
|
5
5
|
/**
|
|
@@ -12,7 +12,9 @@ export interface AddViewSourcePicker {
|
|
|
12
12
|
/** Sources of this database that no view reads yet. */
|
|
13
13
|
extraSourceIds?(dataSource: HostedDataSourceBase): readonly string[];
|
|
14
14
|
/** Creates a source in this database; resolves to its id, or nothing. */
|
|
15
|
-
createSource?(dataSource: HostedDataSourceBase): Promise<string | undefined>;
|
|
15
|
+
createSource?(dataSource: HostedDataSourceBase, sourceName?: string): Promise<string | undefined>;
|
|
16
|
+
/** How the host names a new source; absent, "With a new source" creates at once. */
|
|
17
|
+
sourceName?: DataSourcePickerSourceNaming;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* The host's data-source picker (`DataSourcePickerProvider`, B12) as "+ view"
|
|
@@ -2,10 +2,11 @@ import { HostedDataSourceBase } from '@formicoidea/labre-core/blocks/database';
|
|
|
2
2
|
import { menu } from '@formicoidea/labre-core/components/context-menu';
|
|
3
3
|
import { DataSourcePickerProvider, translateKey, } from '@formicoidea/labre-core/shared/services';
|
|
4
4
|
import { viewDefaultName, } from '@formicoidea/labre-core/data-view';
|
|
5
|
-
import { ImportIcon
|
|
5
|
+
import { ImportIcon } from '@blocksuite/icons/lit';
|
|
6
6
|
import { html } from 'lit';
|
|
7
7
|
import { DATABASE_ADD_VIEW_EXISTING_SOURCE, DATABASE_ADD_VIEW_IMPORT, DATABASE_ADD_VIEW_NEW_SOURCE, DATABASE_ADD_VIEW_UNTITLED_SOURCE, } from '../translations.js';
|
|
8
8
|
import { canImportView, requestViewImport, } from '../view-transfer/import-view.js';
|
|
9
|
+
import { named, newSourceEntry } from '../new-source-entry.js';
|
|
9
10
|
import { addViewOnSource } from './add-view-on-source.js';
|
|
10
11
|
import { existingSources } from './add-view-sources.js';
|
|
11
12
|
/**
|
|
@@ -28,14 +29,15 @@ export function addViewSourcePicker(picker) {
|
|
|
28
29
|
return database?.sources.map(source => source.id) ?? [];
|
|
29
30
|
},
|
|
30
31
|
createSource: createSource
|
|
31
|
-
? async (dataSource) => {
|
|
32
|
+
? async (dataSource, sourceName) => {
|
|
32
33
|
const databaseId = databaseOf(dataSource);
|
|
33
34
|
if (databaseId === undefined)
|
|
34
35
|
return undefined;
|
|
35
|
-
const created = await createSource.call(picker, databaseId);
|
|
36
|
+
const created = await createSource.call(picker, databaseId, ...named(sourceName));
|
|
36
37
|
return created?.id;
|
|
37
38
|
}
|
|
38
39
|
: undefined,
|
|
40
|
+
sourceName: picker.sourceName,
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
43
|
export function addViewMenuShape(sources, canCreateSource, canImport = false) {
|
|
@@ -123,12 +125,11 @@ export function databaseAddViewMenu(picker) {
|
|
|
123
125
|
}));
|
|
124
126
|
}
|
|
125
127
|
if (shape.newSource && createSource) {
|
|
126
|
-
items.push(
|
|
128
|
+
items.push(newSourceEntry(context.std, sourcePicker?.sourceName, {
|
|
127
129
|
name: wording(DATABASE_ADD_VIEW_NEW_SOURCE),
|
|
128
|
-
prefix: PlusIcon(),
|
|
129
130
|
testId: 'database-add-view-new-source',
|
|
130
|
-
|
|
131
|
-
createSource(dataSource)
|
|
131
|
+
create: sourceName => {
|
|
132
|
+
createSource(dataSource, ...named(sourceName))
|
|
132
133
|
.then(sourceId => {
|
|
133
134
|
// The source arrived after a round trip: the page may have
|
|
134
135
|
// turned read-only meanwhile.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formicoidea/labre-core-database",
|
|
3
3
|
"description": "Labre core-database editing chrome for @formicoidea/labre-core.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"author": "lajola",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@formicoidea/labre-core": "2.
|
|
30
|
+
"@formicoidea/labre-core": "2.1.0",
|
|
31
31
|
"@blocksuite/icons": "^2.2.12",
|
|
32
32
|
"@preact/signals-core": "^1.8.0",
|
|
33
33
|
"lit": "^3.2.0"
|