@dxos/plugin-kanban 0.8.4-main.2e9d522 → 0.8.4-main.3eb6e50203
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/blueprint-definition-GGL6Y5GN.mjs +18 -0
- package/dist/lib/browser/blueprint-definition-GGL6Y5GN.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +8 -0
- package/dist/lib/browser/blueprints/index.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/chunk-L6N4ZDZ7.mjs +35 -0
- package/dist/lib/browser/chunk-L6N4ZDZ7.mjs.map +7 -0
- package/dist/lib/browser/chunk-XYQO4VL7.mjs +150 -0
- package/dist/lib/browser/chunk-XYQO4VL7.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +62 -68
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-RFQU4VAB.mjs +162 -0
- package/dist/lib/browser/operation-resolver-RFQU4VAB.mjs.map +7 -0
- package/dist/lib/browser/react-surface-FZQDOE3J.mjs +237 -0
- package/dist/lib/browser/react-surface-FZQDOE3J.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +6 -5
- package/dist/lib/node-esm/blueprint-definition-AMIOYZSF.mjs +19 -0
- package/dist/lib/node-esm/blueprint-definition-AMIOYZSF.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +9 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NN6JMKIT.mjs +152 -0
- package/dist/lib/node-esm/chunk-NN6JMKIT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZHRMUKTF.mjs +36 -0
- package/dist/lib/node-esm/chunk-ZHRMUKTF.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +62 -68
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-J4JUSY74.mjs +163 -0
- package/dist/lib/node-esm/operation-resolver-J4JUSY74.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-KOQ56TL6.mjs +238 -0
- package/dist/lib/node-esm/react-surface-KOQ56TL6.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +6 -5
- package/dist/types/src/KanbanPlugin.d.ts +2 -1
- package/dist/types/src/KanbanPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/kanban-blueprint.d.ts +22 -0
- package/dist/types/src/blueprints/kanban-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +10 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +3 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/KanbanContainer.d.ts +4 -5
- package/dist/types/src/components/KanbanContainer.d.ts.map +1 -1
- package/dist/types/src/components/KanbanContainer.stories.d.ts +71 -6
- package/dist/types/src/components/KanbanContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/KanbanViewEditor.d.ts +3 -3
- package/dist/types/src/components/KanbanViewEditor.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +21 -9
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +0 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +100 -88
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +65 -46
- package/src/KanbanPlugin.tsx +38 -55
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/kanban-blueprint.ts +24 -0
- package/src/capabilities/artifact-definition/artifact-definition.ts +150 -0
- package/src/capabilities/artifact-definition/index.ts +7 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +24 -0
- package/src/capabilities/blueprint-definition/index.ts +7 -0
- package/src/capabilities/index.ts +3 -5
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +133 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +87 -0
- package/src/components/KanbanContainer.stories.tsx +207 -110
- package/src/components/KanbanContainer.tsx +38 -46
- package/src/components/KanbanViewEditor.tsx +39 -40
- package/src/meta.ts +9 -7
- package/src/translations.ts +6 -6
- package/src/types/index.ts +0 -1
- package/src/types/schema.ts +86 -40
- package/dist/lib/browser/artifact-definition-WMSZK3RW.mjs +0 -174
- package/dist/lib/browser/artifact-definition-WMSZK3RW.mjs.map +0 -7
- package/dist/lib/browser/chunk-X44RHBZK.mjs +0 -108
- package/dist/lib/browser/chunk-X44RHBZK.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-E6O3LBAB.mjs +0 -111
- package/dist/lib/browser/intent-resolver-E6O3LBAB.mjs.map +0 -7
- package/dist/lib/browser/react-surface-MWNNZYMN.mjs +0 -256
- package/dist/lib/browser/react-surface-MWNNZYMN.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-QVZXPDXK.mjs +0 -175
- package/dist/lib/node-esm/artifact-definition-QVZXPDXK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6WK5CGYY.mjs +0 -110
- package/dist/lib/node-esm/chunk-6WK5CGYY.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-LPASDELU.mjs +0 -112
- package/dist/lib/node-esm/intent-resolver-LPASDELU.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-T52BBG45.mjs +0 -257
- package/dist/lib/node-esm/react-surface-T52BBG45.mjs.map +0 -7
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/types/kanban.d.ts +0 -11
- package/dist/types/src/types/kanban.d.ts.map +0 -1
- package/src/capabilities/artifact-definition.ts +0 -144
- package/src/capabilities/intent-resolver.ts +0 -70
- package/src/capabilities/react-surface.tsx +0 -84
- package/src/types/kanban.ts +0 -29
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Schema, pipe } from 'effect';
|
|
6
|
-
|
|
7
|
-
import { createTool, ToolResult } from '@dxos/ai';
|
|
8
|
-
import { Capabilities, chain, contributes, createIntent, type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
-
import { createArtifactElement } from '@dxos/assistant';
|
|
10
|
-
import { defineArtifact } from '@dxos/blueprints';
|
|
11
|
-
import { Obj, Query } from '@dxos/echo';
|
|
12
|
-
import { invariant } from '@dxos/invariant';
|
|
13
|
-
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
14
|
-
import { Filter, fullyQualifiedId, type Space } from '@dxos/react-client/echo';
|
|
15
|
-
import { KanbanView } from '@dxos/react-ui-kanban';
|
|
16
|
-
import { DataType } from '@dxos/schema';
|
|
17
|
-
import { isNonNullable } from '@dxos/util';
|
|
18
|
-
|
|
19
|
-
import { meta } from '../meta';
|
|
20
|
-
import { KanbanAction } from '../types';
|
|
21
|
-
|
|
22
|
-
const QualifiedId = Schema.String.annotations({
|
|
23
|
-
description: 'The fully qualified ID of the kanban `spaceID:objectID`',
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
declare global {
|
|
27
|
-
interface ToolContextExtensions {
|
|
28
|
-
space?: Space;
|
|
29
|
-
dispatch?: PromiseIntentDispatcher;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default () => {
|
|
34
|
-
const definition = defineArtifact({
|
|
35
|
-
id: `artifact:${meta.id}`,
|
|
36
|
-
name: meta.name,
|
|
37
|
-
instructions: `
|
|
38
|
-
- Before adding items to a kanban board, inspect the board to see its schema
|
|
39
|
-
- When adding items, you must not include the 'id' field -- it is automatically generated
|
|
40
|
-
- BEFORE adding items, always make sure the board has been shown to the user!
|
|
41
|
-
`,
|
|
42
|
-
schema: KanbanView,
|
|
43
|
-
tools: [
|
|
44
|
-
createTool(meta.id, {
|
|
45
|
-
name: 'create',
|
|
46
|
-
description: `
|
|
47
|
-
Create a new kanban board using an existing schema.
|
|
48
|
-
Use schema_create first to create a schema, or schema_list to choose an existing one.`,
|
|
49
|
-
caption: 'Creating kanban board...',
|
|
50
|
-
schema: Schema.Struct({
|
|
51
|
-
typename: Schema.String.annotations({
|
|
52
|
-
description: 'The fully qualified typename of the schema to use for the kanban cards.',
|
|
53
|
-
}),
|
|
54
|
-
pivotColumn: Schema.optional(Schema.String).annotations({
|
|
55
|
-
description: 'Optional field name to use as the column pivot.',
|
|
56
|
-
}),
|
|
57
|
-
}),
|
|
58
|
-
execute: async ({ typename, pivotColumn }, { extensions }) => {
|
|
59
|
-
invariant(extensions?.space, 'No space');
|
|
60
|
-
invariant(extensions?.dispatch, 'No intent dispatcher');
|
|
61
|
-
|
|
62
|
-
// Validate schema exists first
|
|
63
|
-
const schema = await extensions.space.db.schemaRegistry.query({ typename }).firstOrUndefined();
|
|
64
|
-
if (!schema) {
|
|
65
|
-
return ToolResult.Error(`Schema not found: ${typename}`);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const intent = pipe(
|
|
69
|
-
createIntent(KanbanAction.Create, {
|
|
70
|
-
space: extensions.space,
|
|
71
|
-
typename,
|
|
72
|
-
initialPivotColumn: pivotColumn,
|
|
73
|
-
}),
|
|
74
|
-
chain(SpaceAction.AddObject, { target: extensions.space }),
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const { data, error } = await extensions.dispatch(intent);
|
|
78
|
-
if (!data || error) {
|
|
79
|
-
return ToolResult.Error(error?.message ?? 'Failed to create kanban board');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return ToolResult.Success(createArtifactElement(data.id));
|
|
83
|
-
},
|
|
84
|
-
}),
|
|
85
|
-
createTool(meta.id, {
|
|
86
|
-
name: 'list',
|
|
87
|
-
description: 'List all kanban boards in the current space.',
|
|
88
|
-
caption: 'Listing kanban boards...',
|
|
89
|
-
schema: Schema.Struct({}),
|
|
90
|
-
execute: async (_input, { extensions }) => {
|
|
91
|
-
invariant(extensions?.space, 'No space');
|
|
92
|
-
const space = extensions.space;
|
|
93
|
-
const { objects } = await space.db.query(Filter.type(DataType.View)).run();
|
|
94
|
-
|
|
95
|
-
const boardInfo = await Promise.all(
|
|
96
|
-
objects.map(async (view) => {
|
|
97
|
-
const kanban = await view.presentation.load();
|
|
98
|
-
if (!Obj.instanceOf(KanbanView, kanban)) {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
id: fullyQualifiedId(view),
|
|
104
|
-
name: view.name ?? 'Unnamed Kanban',
|
|
105
|
-
typename: view.query.typename,
|
|
106
|
-
};
|
|
107
|
-
}),
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
return ToolResult.Success(boardInfo.filter(isNonNullable));
|
|
111
|
-
},
|
|
112
|
-
}),
|
|
113
|
-
createTool(meta.id, {
|
|
114
|
-
name: 'inspect',
|
|
115
|
-
description: 'Get details about a specific kanban board.',
|
|
116
|
-
caption: 'Inspecting kanban board...',
|
|
117
|
-
schema: Schema.Struct({ id: QualifiedId }),
|
|
118
|
-
execute: async ({ id }, { extensions }) => {
|
|
119
|
-
invariant(extensions?.space, 'No space');
|
|
120
|
-
const space = extensions.space;
|
|
121
|
-
const view = (await space.db
|
|
122
|
-
// TODO(wittjosiah): Filter.and should aggregate type
|
|
123
|
-
.query(Query.select(Filter.and(Filter.type(DataType.View), Filter.ids(id))))
|
|
124
|
-
.first()) as DataType.View;
|
|
125
|
-
|
|
126
|
-
const kanban = await view.presentation.load();
|
|
127
|
-
invariant(Obj.instanceOf(KanbanView, kanban));
|
|
128
|
-
|
|
129
|
-
const typename = view.query.typename;
|
|
130
|
-
const schema = await space.db.schemaRegistry.query({ typename }).firstOrUndefined();
|
|
131
|
-
invariant(schema);
|
|
132
|
-
|
|
133
|
-
return ToolResult.Success({
|
|
134
|
-
schema,
|
|
135
|
-
columnField: kanban.columnFieldId,
|
|
136
|
-
viewFields: view.projection.fields,
|
|
137
|
-
});
|
|
138
|
-
},
|
|
139
|
-
}),
|
|
140
|
-
],
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
return contributes(Capabilities.ArtifactDefinition, definition);
|
|
144
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { contributes, Capabilities, createResolver, type PluginContext } from '@dxos/app-framework';
|
|
6
|
-
import { invariant } from '@dxos/invariant';
|
|
7
|
-
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
8
|
-
import { getSpace } from '@dxos/react-client/echo';
|
|
9
|
-
import { ProjectionModel } from '@dxos/schema';
|
|
10
|
-
|
|
11
|
-
import { KANBAN_PLUGIN } from '../meta';
|
|
12
|
-
import { createKanban, KanbanAction } from '../types';
|
|
13
|
-
|
|
14
|
-
export default (context: PluginContext) =>
|
|
15
|
-
contributes(Capabilities.IntentResolver, [
|
|
16
|
-
createResolver({
|
|
17
|
-
intent: KanbanAction.Create,
|
|
18
|
-
resolve: async ({ space, name, typename, initialPivotColumn }) => {
|
|
19
|
-
const client = context.getCapability(ClientCapabilities.Client);
|
|
20
|
-
const { view } = await createKanban({
|
|
21
|
-
client,
|
|
22
|
-
space,
|
|
23
|
-
name,
|
|
24
|
-
typename,
|
|
25
|
-
initialPivotColumn,
|
|
26
|
-
});
|
|
27
|
-
return { data: { object: view } };
|
|
28
|
-
},
|
|
29
|
-
}),
|
|
30
|
-
createResolver({
|
|
31
|
-
intent: KanbanAction.DeleteCardField,
|
|
32
|
-
resolve: async ({ view, fieldId, deletionData }, undo) => {
|
|
33
|
-
const schema = getSpace(view)?.db.schemaRegistry.getSchema(view.query.typename!);
|
|
34
|
-
invariant(schema);
|
|
35
|
-
const projection = new ProjectionModel(schema.jsonSchema, view.projection);
|
|
36
|
-
|
|
37
|
-
if (!undo) {
|
|
38
|
-
const { deleted, index } = projection.deleteFieldProjection(fieldId);
|
|
39
|
-
return {
|
|
40
|
-
undoable: {
|
|
41
|
-
message: ['card field deleted label', { ns: KANBAN_PLUGIN }],
|
|
42
|
-
data: { deletionData: { ...deleted, index } },
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
} else if (undo && deletionData) {
|
|
46
|
-
const { field, props, index } = deletionData;
|
|
47
|
-
projection.setFieldProjection({ field, props }, index);
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
}),
|
|
51
|
-
createResolver({
|
|
52
|
-
intent: KanbanAction.DeleteCard,
|
|
53
|
-
resolve: ({ card }, undo) => {
|
|
54
|
-
const space = getSpace(card);
|
|
55
|
-
invariant(space);
|
|
56
|
-
|
|
57
|
-
if (!undo) {
|
|
58
|
-
space.db.remove(card);
|
|
59
|
-
return {
|
|
60
|
-
undoable: {
|
|
61
|
-
message: ['card deleted label', { ns: KANBAN_PLUGIN }],
|
|
62
|
-
data: { card },
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
} else {
|
|
66
|
-
space.db.add(card);
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
}),
|
|
70
|
-
]);
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Schema } from 'effect';
|
|
6
|
-
import React, { useMemo } from 'react';
|
|
7
|
-
|
|
8
|
-
import { Capabilities, contributes, createSurface, useCapabilities } from '@dxos/app-framework';
|
|
9
|
-
import { Obj, Type } from '@dxos/echo';
|
|
10
|
-
import { findAnnotation } from '@dxos/effect';
|
|
11
|
-
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
12
|
-
import { getSpace, isSpace, type Space } from '@dxos/react-client/echo';
|
|
13
|
-
import { type InputProps, SelectInput, useFormValues } from '@dxos/react-ui-form';
|
|
14
|
-
import { KanbanView } from '@dxos/react-ui-kanban';
|
|
15
|
-
import { DataType } from '@dxos/schema';
|
|
16
|
-
|
|
17
|
-
import { KanbanContainer, KanbanViewEditor } from '../components';
|
|
18
|
-
import { meta } from '../meta';
|
|
19
|
-
import { PivotColumnAnnotationId } from '../types';
|
|
20
|
-
|
|
21
|
-
export default () =>
|
|
22
|
-
contributes(Capabilities.ReactSurface, [
|
|
23
|
-
createSurface({
|
|
24
|
-
id: meta.id,
|
|
25
|
-
role: ['article', 'section'],
|
|
26
|
-
filter: (data): data is { subject: DataType.View } =>
|
|
27
|
-
Obj.instanceOf(DataType.View, data.subject) && Obj.instanceOf(KanbanView, data.subject.presentation.target),
|
|
28
|
-
component: ({ data, role }) => <KanbanContainer view={data.subject} role={role} />,
|
|
29
|
-
}),
|
|
30
|
-
createSurface({
|
|
31
|
-
id: `${meta.id}/object-settings`,
|
|
32
|
-
role: 'object-settings',
|
|
33
|
-
position: 'hoist',
|
|
34
|
-
filter: (data): data is { subject: DataType.View } =>
|
|
35
|
-
Obj.instanceOf(DataType.View, data.subject) && Obj.instanceOf(KanbanView, data.subject.presentation.target),
|
|
36
|
-
component: ({ data }) => <KanbanViewEditor view={data.subject} />,
|
|
37
|
-
}),
|
|
38
|
-
createSurface({
|
|
39
|
-
id: `${meta.id}/create-initial-schema-form-[pivot-column]`,
|
|
40
|
-
role: 'form-input',
|
|
41
|
-
filter: (
|
|
42
|
-
data,
|
|
43
|
-
): data is { prop: string; schema: Schema.Schema<any>; target: Space | DataType.Collection | undefined } => {
|
|
44
|
-
const annotation = findAnnotation<boolean>((data.schema as Schema.Schema.All).ast, PivotColumnAnnotationId);
|
|
45
|
-
return !!annotation;
|
|
46
|
-
},
|
|
47
|
-
component: ({ data: { target }, ...inputProps }) => {
|
|
48
|
-
const props = inputProps as any as InputProps;
|
|
49
|
-
const space = isSpace(target) ? target : getSpace(target);
|
|
50
|
-
if (!space) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
const { typename } = useFormValues();
|
|
54
|
-
// TODO(wittjosiah): Unify this schema lookup.
|
|
55
|
-
const schemaWhitelists = useCapabilities(ClientCapabilities.SchemaWhiteList);
|
|
56
|
-
const staticSchema = schemaWhitelists.flat().find((schema) => Type.getTypename(schema) === typename);
|
|
57
|
-
const [selectedSchema] = space?.db.schemaRegistry.query({ typename }).runSync();
|
|
58
|
-
|
|
59
|
-
const singleSelectColumns = useMemo(() => {
|
|
60
|
-
const properties = staticSchema
|
|
61
|
-
? Type.toJsonSchema(staticSchema).properties
|
|
62
|
-
: selectedSchema?.jsonSchema?.properties;
|
|
63
|
-
if (!properties) {
|
|
64
|
-
return [];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const columns = Object.entries(properties).reduce<string[]>((acc, [key, value]) => {
|
|
68
|
-
if (typeof value === 'object' && value?.format === 'single-select') {
|
|
69
|
-
acc.push(key);
|
|
70
|
-
}
|
|
71
|
-
return acc;
|
|
72
|
-
}, []);
|
|
73
|
-
|
|
74
|
-
return columns;
|
|
75
|
-
}, [selectedSchema?.jsonSchema, staticSchema]);
|
|
76
|
-
|
|
77
|
-
if (!typename) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return <SelectInput {...props} options={singleSelectColumns.map((column) => ({ value: column }))} />;
|
|
82
|
-
},
|
|
83
|
-
}),
|
|
84
|
-
]);
|
package/src/types/kanban.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Obj } from '@dxos/echo';
|
|
6
|
-
import { type JsonSchemaType } from '@dxos/echo-schema';
|
|
7
|
-
import { KanbanView } from '@dxos/react-ui-kanban';
|
|
8
|
-
import { type DataType, type CreateViewFromSpaceProps, createViewFromSpace, ProjectionModel } from '@dxos/schema';
|
|
9
|
-
|
|
10
|
-
type InitializeKanbanProps = Omit<CreateViewFromSpaceProps, 'presentation'> & {
|
|
11
|
-
initialPivotColumn?: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const createKanban = async ({
|
|
15
|
-
initialPivotColumn,
|
|
16
|
-
...props
|
|
17
|
-
}: InitializeKanbanProps): Promise<{ jsonSchema: JsonSchemaType; view: DataType.View }> => {
|
|
18
|
-
const kanban = Obj.make(KanbanView, { columnFieldId: undefined });
|
|
19
|
-
const { jsonSchema, view } = await createViewFromSpace({ ...props, presentation: kanban });
|
|
20
|
-
if (initialPivotColumn) {
|
|
21
|
-
const projection = new ProjectionModel(jsonSchema, view.projection);
|
|
22
|
-
const fieldId = projection.getFieldId(initialPivotColumn);
|
|
23
|
-
if (fieldId) {
|
|
24
|
-
kanban.columnFieldId = fieldId;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return { jsonSchema, view };
|
|
29
|
-
};
|