@dxos/plugin-kanban 0.8.4-main.72ec0f3 → 0.8.4-main.937b3ca
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-T2544VMJ.mjs +17 -0
- package/dist/lib/browser/blueprint-definition-T2544VMJ.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 +58 -65
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-UEJHX42A.mjs +162 -0
- package/dist/lib/browser/operation-resolver-UEJHX42A.mjs.map +7 -0
- package/dist/lib/browser/react-surface-XZSKFDM5.mjs +236 -0
- package/dist/lib/browser/react-surface-XZSKFDM5.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +8 -5
- package/dist/lib/node-esm/blueprint-definition-APJQFSHJ.mjs +18 -0
- package/dist/lib/node-esm/blueprint-definition-APJQFSHJ.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 +58 -65
- 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-5RPWHZCF.mjs +163 -0
- package/dist/lib/node-esm/operation-resolver-5RPWHZCF.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-JWRKX7GS.mjs +237 -0
- package/dist/lib/node-esm/react-surface-JWRKX7GS.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +8 -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 +9 -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 +35 -10
- 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 -2
- 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/schema.d.ts +97 -42
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +63 -48
- package/src/KanbanPlugin.tsx +34 -53
- 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 +23 -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 +86 -0
- package/src/components/KanbanContainer.stories.tsx +119 -87
- package/src/components/KanbanContainer.tsx +34 -46
- package/src/components/KanbanViewEditor.tsx +36 -41
- package/src/meta.ts +2 -2
- package/src/translations.ts +5 -5
- package/src/types/schema.ts +83 -38
- package/dist/lib/browser/blueprint-definition-UYVX622Q.mjs +0 -28
- package/dist/lib/browser/blueprint-definition-UYVX622Q.mjs.map +0 -7
- package/dist/lib/browser/chunk-HO3LQ5T7.mjs +0 -86
- package/dist/lib/browser/chunk-HO3LQ5T7.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-OPYUDNSU.mjs +0 -111
- package/dist/lib/browser/intent-resolver-OPYUDNSU.mjs.map +0 -7
- package/dist/lib/browser/react-surface-X54TNDDN.mjs +0 -257
- package/dist/lib/browser/react-surface-X54TNDDN.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-42P47FUY.mjs +0 -30
- package/dist/lib/node-esm/blueprint-definition-42P47FUY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QZMZU5HM.mjs +0 -88
- package/dist/lib/node-esm/chunk-QZMZU5HM.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-BDKNXV3R.mjs +0 -112
- package/dist/lib/node-esm/intent-resolver-BDKNXV3R.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-CVDMIHSC.mjs +0 -258
- package/dist/lib/node-esm/react-surface-CVDMIHSC.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/blueprint-definition.d.ts +0 -5
- package/dist/types/src/capabilities/blueprint-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/src/capabilities/artifact-definition.ts +0 -148
- package/src/capabilities/blueprint-definition.ts +0 -30
- package/src/capabilities/intent-resolver.ts +0 -71
- package/src/capabilities/react-surface.tsx +0 -89
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import type * as Schema from 'effect/Schema';
|
|
7
|
+
import React, { useMemo } from 'react';
|
|
8
|
+
|
|
9
|
+
import { Capability, Common } from '@dxos/app-framework';
|
|
10
|
+
import { Database, Obj, Type } from '@dxos/echo';
|
|
11
|
+
import { findAnnotation } from '@dxos/effect';
|
|
12
|
+
import { type FormFieldComponentProps, SelectField, useFormValues } from '@dxos/react-ui-form';
|
|
13
|
+
import { Kanban } from '@dxos/react-ui-kanban/types';
|
|
14
|
+
import { type Collection } from '@dxos/schema';
|
|
15
|
+
|
|
16
|
+
import { KanbanContainer, KanbanViewEditor } from '../../components';
|
|
17
|
+
import { meta } from '../../meta';
|
|
18
|
+
import { PivotColumnAnnotationId } from '../../types';
|
|
19
|
+
|
|
20
|
+
export default Capability.makeModule(() =>
|
|
21
|
+
Effect.succeed(
|
|
22
|
+
Capability.contributes(Common.Capability.ReactSurface, [
|
|
23
|
+
Common.createSurface({
|
|
24
|
+
id: meta.id,
|
|
25
|
+
role: ['article', 'section'],
|
|
26
|
+
filter: (data): data is { subject: Kanban.Kanban } => Obj.instanceOf(Kanban.Kanban, data.subject),
|
|
27
|
+
component: ({ data, role }) => <KanbanContainer role={role} subject={data.subject} />,
|
|
28
|
+
}),
|
|
29
|
+
Common.createSurface({
|
|
30
|
+
id: `${meta.id}/object-settings`,
|
|
31
|
+
role: 'object-settings',
|
|
32
|
+
position: 'hoist',
|
|
33
|
+
filter: (data): data is { subject: Kanban.Kanban } => Obj.instanceOf(Kanban.Kanban, data.subject),
|
|
34
|
+
component: ({ data }) => <KanbanViewEditor object={data.subject} />,
|
|
35
|
+
}),
|
|
36
|
+
Common.createSurface({
|
|
37
|
+
id: `${meta.id}/create-initial-schema-form-[pivot-column]`,
|
|
38
|
+
role: 'form-input',
|
|
39
|
+
filter: (
|
|
40
|
+
data,
|
|
41
|
+
): data is {
|
|
42
|
+
prop: string;
|
|
43
|
+
schema: Schema.Schema<any>;
|
|
44
|
+
target: Database.Database | Collection.Collection | undefined;
|
|
45
|
+
} => {
|
|
46
|
+
const annotation = findAnnotation<boolean>((data.schema as Schema.Schema.All).ast, PivotColumnAnnotationId);
|
|
47
|
+
return !!annotation;
|
|
48
|
+
},
|
|
49
|
+
component: ({ data: { target }, ...inputProps }) => {
|
|
50
|
+
const props = inputProps as any as FormFieldComponentProps;
|
|
51
|
+
const db = Database.isDatabase(target) ? target : target && Obj.getDatabase(target);
|
|
52
|
+
if (!db) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const { typename } = useFormValues('KanbanForm');
|
|
57
|
+
const [selectedSchema] = useMemo(
|
|
58
|
+
() => db.schemaRegistry.query({ location: ['database', 'runtime'], typename }).runSync(),
|
|
59
|
+
[db, typename],
|
|
60
|
+
);
|
|
61
|
+
const singleSelectColumns = useMemo(() => {
|
|
62
|
+
const properties = Type.toJsonSchema(selectedSchema).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]);
|
|
76
|
+
|
|
77
|
+
if (!typename) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return <SelectField {...props} options={singleSelectColumns.map((column) => ({ value: column }))} />;
|
|
82
|
+
},
|
|
83
|
+
}),
|
|
84
|
+
]),
|
|
85
|
+
),
|
|
86
|
+
);
|
|
@@ -2,40 +2,41 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { RegistryContext } from '@effect-atom/atom-react';
|
|
5
6
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
-
import
|
|
7
|
+
import * as Effect from 'effect/Effect';
|
|
8
|
+
import React, { useCallback, useContext } from 'react';
|
|
9
|
+
import { expect, waitFor, within } from 'storybook/test';
|
|
7
10
|
|
|
8
|
-
import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
|
|
9
11
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
12
|
import { Obj, type QueryAST, Type } from '@dxos/echo';
|
|
13
|
+
import { type Mutable } from '@dxos/echo/internal';
|
|
11
14
|
import { invariant } from '@dxos/invariant';
|
|
12
15
|
import { ClientPlugin } from '@dxos/plugin-client';
|
|
13
16
|
import { PreviewPlugin } from '@dxos/plugin-preview';
|
|
14
17
|
import { useGlobalFilteredObjects } from '@dxos/plugin-search';
|
|
15
18
|
import { SpacePlugin } from '@dxos/plugin-space';
|
|
16
|
-
import {
|
|
17
|
-
import { ThemePlugin } from '@dxos/plugin-theme';
|
|
19
|
+
import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
|
|
18
20
|
import { faker } from '@dxos/random';
|
|
19
|
-
import { useClient } from '@dxos/react-client';
|
|
20
21
|
import { Filter, useQuery, useSchema, useSpaces } from '@dxos/react-client/echo';
|
|
21
22
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
22
23
|
import { ViewEditor } from '@dxos/react-ui-form';
|
|
23
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
Kanban as KanbanComponent,
|
|
26
|
+
translations as kanbanTranslations,
|
|
27
|
+
useKanbanModel,
|
|
28
|
+
useProjectionModel,
|
|
29
|
+
} from '@dxos/react-ui-kanban';
|
|
24
30
|
import { Kanban } from '@dxos/react-ui-kanban/types';
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import { ProjectionModel, View, getTypenameFromQuery } from '@dxos/schema';
|
|
31
|
+
import { JsonFilter } from '@dxos/react-ui-syntax-highlighter';
|
|
32
|
+
import { View, getTypenameFromQuery } from '@dxos/schema';
|
|
28
33
|
import { Organization, Person } from '@dxos/types';
|
|
29
34
|
|
|
30
35
|
import { translations } from '../translations';
|
|
31
36
|
|
|
32
37
|
faker.seed(0);
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
// Story components.
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
const rollOrg = () => ({
|
|
39
|
+
const createOrg = () => ({
|
|
39
40
|
name: faker.commerce.productName(),
|
|
40
41
|
description: faker.lorem.paragraph(),
|
|
41
42
|
image: faker.image.url(),
|
|
@@ -43,38 +44,24 @@ const rollOrg = () => ({
|
|
|
43
44
|
status: faker.helpers.arrayElement(Organization.StatusOptions).id as Organization.Organization['status'],
|
|
44
45
|
});
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
//
|
|
48
|
+
// Story components.
|
|
49
|
+
//
|
|
50
|
+
|
|
51
|
+
const DefaultComponent = () => {
|
|
52
|
+
const registry = useContext(RegistryContext);
|
|
48
53
|
const spaces = useSpaces();
|
|
49
54
|
const space = spaces[spaces.length - 1];
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
if (views.length && !view) {
|
|
58
|
-
const view = views[0];
|
|
59
|
-
setView(view);
|
|
60
|
-
}
|
|
61
|
-
}, [views]);
|
|
62
|
-
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
if (view?.projection && schema) {
|
|
65
|
-
const jsonSchema = Type.toJsonSchema(schema);
|
|
66
|
-
setProjection(new ProjectionModel(jsonSchema, view.projection));
|
|
67
|
-
}
|
|
68
|
-
// TODO(ZaymonFC): Is there a better way to get notified about deep changes in the json schema?
|
|
69
|
-
// @dmaretskyi? Once resolved, update in multiple places (e.g., storybooks).
|
|
70
|
-
}, [view?.projection, schema, JSON.stringify(schema ? Type.toJsonSchema(schema) : {})]);
|
|
71
|
-
|
|
72
|
-
const objects = useQuery(space, schema ? Filter.type(schema) : Filter.nothing());
|
|
55
|
+
const [object] = useQuery(space?.db, Filter.type(Kanban.Kanban));
|
|
56
|
+
const typename = object?.view.target?.query ? getTypenameFromQuery(object.view.target.query.ast) : undefined;
|
|
57
|
+
const schema = useSchema(space?.db, typename);
|
|
58
|
+
|
|
59
|
+
const objects = useQuery(space?.db, schema ? Filter.type(schema) : Filter.nothing());
|
|
73
60
|
const filteredObjects = useGlobalFilteredObjects(objects);
|
|
74
61
|
|
|
62
|
+
const projection = useProjectionModel(schema, object, registry);
|
|
75
63
|
const model = useKanbanModel({
|
|
76
|
-
|
|
77
|
-
schema,
|
|
64
|
+
object,
|
|
78
65
|
projection,
|
|
79
66
|
items: filteredObjects,
|
|
80
67
|
});
|
|
@@ -82,9 +69,9 @@ const StorybookKanban = () => {
|
|
|
82
69
|
const handleAddCard = useCallback(
|
|
83
70
|
(columnValue: string | undefined) => {
|
|
84
71
|
const path = model?.columnFieldPath;
|
|
85
|
-
if (space && schema && path) {
|
|
72
|
+
if (space && schema && Type.isObjectSchema(schema) && path) {
|
|
86
73
|
const card = Obj.make(schema, {
|
|
87
|
-
...
|
|
74
|
+
...createOrg(),
|
|
88
75
|
[path]: columnValue,
|
|
89
76
|
});
|
|
90
77
|
|
|
@@ -95,100 +82,145 @@ const StorybookKanban = () => {
|
|
|
95
82
|
[space, schema, model],
|
|
96
83
|
);
|
|
97
84
|
|
|
98
|
-
const handleRemoveCard = useCallback((card: { id: string }) => space
|
|
85
|
+
const handleRemoveCard = useCallback((card: { id: string }) => Obj.isObject(card) && space?.db.remove(card), [space]);
|
|
99
86
|
|
|
100
87
|
const handleUpdateQuery = useCallback(
|
|
101
88
|
(newQuery: QueryAST.Query) => {
|
|
102
89
|
invariant(schema);
|
|
103
90
|
invariant(Type.isMutable(schema));
|
|
104
|
-
invariant(view);
|
|
91
|
+
invariant(object.view.target);
|
|
105
92
|
|
|
106
93
|
schema.updateTypename(getTypenameFromQuery(newQuery));
|
|
107
|
-
view.
|
|
94
|
+
Obj.change(object.view.target, (v) => {
|
|
95
|
+
v.query.ast = newQuery as Mutable<typeof newQuery>;
|
|
96
|
+
});
|
|
108
97
|
},
|
|
109
|
-
[
|
|
98
|
+
[object, schema],
|
|
110
99
|
);
|
|
111
100
|
|
|
112
|
-
if (!schema || !view) {
|
|
101
|
+
if (!schema || !object.view.target) {
|
|
113
102
|
return null;
|
|
114
103
|
}
|
|
115
104
|
|
|
116
105
|
return (
|
|
117
|
-
<div className='grow grid grid-cols-[1fr_350px]'>
|
|
106
|
+
<div className='grow grid grid-cols-[1fr_350px] overflow-hidden'>
|
|
118
107
|
{model ? <KanbanComponent model={model} onAddCard={handleAddCard} onRemoveCard={handleRemoveCard} /> : <div />}
|
|
119
|
-
<div className='flex flex-col bs-full border-
|
|
108
|
+
<div className='flex flex-col bs-full overflow-hidden border-l border-separator'>
|
|
120
109
|
<ViewEditor
|
|
110
|
+
classNames='p-2'
|
|
121
111
|
registry={space?.db.schemaRegistry}
|
|
122
112
|
schema={schema}
|
|
123
|
-
view={view}
|
|
113
|
+
view={object.view.target}
|
|
124
114
|
onQueryChanged={handleUpdateQuery}
|
|
125
115
|
onDelete={(fieldId: string) => {
|
|
126
116
|
console.log('[ViewEditor]', 'onDelete', fieldId);
|
|
127
117
|
}}
|
|
128
118
|
/>
|
|
129
|
-
<
|
|
130
|
-
{JSON.stringify({ view, schema }, null, 2)}
|
|
131
|
-
</SyntaxHighlighter>
|
|
119
|
+
<JsonFilter data={{ view: object.view.target, schema }} classNames='text-xs' />
|
|
132
120
|
</div>
|
|
133
121
|
</div>
|
|
134
122
|
);
|
|
135
123
|
};
|
|
136
124
|
|
|
137
|
-
type StoryProps = {
|
|
138
|
-
rows?: number;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
125
|
//
|
|
142
126
|
// Story definitions.
|
|
143
127
|
//
|
|
144
128
|
|
|
145
129
|
const meta = {
|
|
146
130
|
title: 'plugins/plugin-kanban/Kanban',
|
|
147
|
-
component:
|
|
148
|
-
render: () => <
|
|
131
|
+
component: DefaultComponent,
|
|
132
|
+
render: () => <DefaultComponent />,
|
|
149
133
|
decorators: [
|
|
150
134
|
withTheme,
|
|
151
135
|
withPluginManager({
|
|
152
136
|
plugins: [
|
|
137
|
+
...corePlugins(),
|
|
153
138
|
ClientPlugin({
|
|
154
139
|
types: [Organization.Organization, Person.Person, View.View, Kanban.Kanban],
|
|
155
|
-
onClientInitialized:
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
140
|
+
onClientInitialized: ({ client }) =>
|
|
141
|
+
Effect.gen(function* () {
|
|
142
|
+
yield* Effect.promise(() => client.halo.createIdentity());
|
|
143
|
+
const space = yield* Effect.promise(() => client.spaces.create());
|
|
144
|
+
yield* Effect.promise(() => space.waitUntilReady());
|
|
145
|
+
|
|
146
|
+
const { view } = yield* Effect.promise(() =>
|
|
147
|
+
View.makeFromDatabase({
|
|
148
|
+
db: space.db,
|
|
149
|
+
typename: Organization.Organization.typename,
|
|
150
|
+
pivotFieldName: 'status',
|
|
151
|
+
}),
|
|
152
|
+
);
|
|
153
|
+
const kanban = Kanban.make({ view });
|
|
154
|
+
space.db.add(kanban);
|
|
155
|
+
|
|
156
|
+
// TODO(burdon): Replace with sdk/schema/testing.
|
|
157
|
+
Array.from({ length: 80 }).map(() => {
|
|
158
|
+
return space.db.add(Obj.make(Organization.Organization, createOrg()));
|
|
159
|
+
});
|
|
160
|
+
}),
|
|
172
161
|
}),
|
|
173
|
-
SpacePlugin({}),
|
|
174
|
-
IntentPlugin(),
|
|
175
|
-
SettingsPlugin(),
|
|
176
|
-
|
|
177
|
-
// UI
|
|
178
|
-
ThemePlugin({ tx: defaultTx }),
|
|
179
162
|
PreviewPlugin(),
|
|
180
|
-
|
|
163
|
+
SpacePlugin({}),
|
|
164
|
+
StorybookPlugin({}),
|
|
181
165
|
],
|
|
182
166
|
}),
|
|
183
167
|
],
|
|
184
168
|
parameters: {
|
|
185
169
|
layout: 'fullscreen',
|
|
186
|
-
translations,
|
|
170
|
+
translations: [...translations, ...kanbanTranslations],
|
|
187
171
|
},
|
|
188
|
-
} satisfies Meta<typeof
|
|
172
|
+
} satisfies Meta<typeof DefaultComponent>;
|
|
189
173
|
|
|
190
174
|
export default meta;
|
|
191
175
|
|
|
192
176
|
type Story = StoryObj<typeof meta>;
|
|
193
177
|
|
|
194
|
-
export const Default: Story = {
|
|
178
|
+
export const Default: Story = {
|
|
179
|
+
play: async ({ canvasElement }) => {
|
|
180
|
+
const canvas = within(canvasElement);
|
|
181
|
+
|
|
182
|
+
// Wait for the kanban columns to render by finding the status tags.
|
|
183
|
+
// Organization.StatusOptions: prospect, qualified, active, commit, reject.
|
|
184
|
+
const activeTag = await canvas.findByText('Active', undefined, { timeout: 30_000 });
|
|
185
|
+
const prospectTag = await canvas.findByText('Prospect', undefined, { timeout: 10_000 });
|
|
186
|
+
const commitTag = await canvas.findByText('Commit', undefined, { timeout: 10_000 });
|
|
187
|
+
|
|
188
|
+
// Verify all expected columns are rendered.
|
|
189
|
+
await expect(activeTag).toBeTruthy();
|
|
190
|
+
await expect(prospectTag).toBeTruthy();
|
|
191
|
+
await expect(commitTag).toBeTruthy();
|
|
192
|
+
|
|
193
|
+
// Find the column containers.
|
|
194
|
+
const activeColumn = activeTag.closest('[data-dx-stack-item]') as HTMLElement;
|
|
195
|
+
const prospectColumn = prospectTag.closest('[data-dx-stack-item]') as HTMLElement;
|
|
196
|
+
await expect(activeColumn).toBeTruthy();
|
|
197
|
+
await expect(prospectColumn).toBeTruthy();
|
|
198
|
+
|
|
199
|
+
// Wait for cards to render in the columns.
|
|
200
|
+
// Cards have data-dx-item-id attribute from StackItem.Root.
|
|
201
|
+
const getColumnCards = (column: HTMLElement) =>
|
|
202
|
+
Array.from(column.querySelectorAll('[data-dx-item-id]')) as HTMLElement[];
|
|
203
|
+
|
|
204
|
+
await waitFor(() => expect(getColumnCards(activeColumn).length).toBeGreaterThan(0));
|
|
205
|
+
|
|
206
|
+
// Verify cards are distributed across columns.
|
|
207
|
+
const activeCards = getColumnCards(activeColumn);
|
|
208
|
+
const prospectCards = getColumnCards(prospectColumn);
|
|
209
|
+
await expect(activeCards.length).toBeGreaterThan(0);
|
|
210
|
+
await expect(prospectCards.length).toBeGreaterThan(0);
|
|
211
|
+
|
|
212
|
+
// Verify cards have drag handles (first button in toolbar).
|
|
213
|
+
const firstActiveCard = activeCards[0];
|
|
214
|
+
const buttons = firstActiveCard.querySelectorAll('button');
|
|
215
|
+
await expect(buttons.length).toBeGreaterThan(0);
|
|
216
|
+
|
|
217
|
+
// Verify the drop zone exists in each column.
|
|
218
|
+
const activeDropZone = activeColumn.querySelector('.kanban-drop');
|
|
219
|
+
const prospectDropZone = prospectColumn.querySelector('.kanban-drop');
|
|
220
|
+
await expect(activeDropZone).toBeTruthy();
|
|
221
|
+
await expect(prospectDropZone).toBeTruthy();
|
|
222
|
+
|
|
223
|
+
// TODO(wittjosiah): Get drag & drop tests working.
|
|
224
|
+
// See packages/apps/composer-app/src/playwright/stack.spec.ts for reference.
|
|
225
|
+
},
|
|
226
|
+
};
|
|
@@ -2,43 +2,38 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { RegistryContext } from '@effect-atom/atom-react';
|
|
6
|
+
import React, { useCallback, useContext, useEffect, useState } from 'react';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
8
|
+
import { Common } from '@dxos/app-framework';
|
|
9
|
+
import { type SurfaceComponentProps, useCapabilities, useOperationInvoker } from '@dxos/app-framework/react';
|
|
9
10
|
import { Filter, Obj, Type } from '@dxos/echo';
|
|
10
|
-
import { EchoSchema, type TypedObject } from '@dxos/echo/internal';
|
|
11
11
|
import { useGlobalFilteredObjects } from '@dxos/plugin-search';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { Kanban
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
12
|
+
import { useQuery } from '@dxos/react-client/echo';
|
|
13
|
+
import { Kanban as KanbanComponent, useKanbanModel, useProjectionModel } from '@dxos/react-ui-kanban';
|
|
14
|
+
import { type Kanban } from '@dxos/react-ui-kanban/types';
|
|
15
|
+
import { Layout } from '@dxos/react-ui-mosaic';
|
|
16
|
+
import { getTypenameFromQuery } from '@dxos/schema';
|
|
17
17
|
|
|
18
|
-
import {
|
|
18
|
+
import { KanbanOperation } from '../types';
|
|
19
19
|
|
|
20
|
-
export
|
|
21
|
-
const client = useClient();
|
|
22
|
-
const [cardSchema, setCardSchema] = useState<TypedObject<any, any>>();
|
|
23
|
-
const [projection, setProjection] = useState<ProjectionModel>();
|
|
24
|
-
const space = getSpace(view);
|
|
25
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
26
|
-
const typename = view.query ? getTypenameFromQuery(view.query.ast) : undefined;
|
|
20
|
+
export type KanbanContainerProps = SurfaceComponentProps<Kanban.Kanban>;
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
22
|
+
export const KanbanContainer = ({ role, subject: object }: KanbanContainerProps) => {
|
|
23
|
+
const registry = useContext(RegistryContext);
|
|
24
|
+
const schemas = useCapabilities(Common.Capability.Schema);
|
|
25
|
+
const [cardSchema, setCardSchema] = useState<Type.Obj.Any>();
|
|
26
|
+
const db = Obj.getDatabase(object);
|
|
27
|
+
const { invokePromise } = useOperationInvoker();
|
|
28
|
+
const typename = object.view.target?.query ? getTypenameFromQuery(object.view.target.query.ast) : undefined;
|
|
34
29
|
|
|
35
30
|
useEffect(() => {
|
|
36
|
-
const staticSchema =
|
|
31
|
+
const staticSchema = schemas.flat().find((schema) => Type.getTypename(schema) === typename);
|
|
37
32
|
if (staticSchema) {
|
|
38
|
-
setCardSchema(
|
|
33
|
+
setCardSchema(staticSchema);
|
|
39
34
|
}
|
|
40
|
-
if (!staticSchema && typename &&
|
|
41
|
-
const query =
|
|
35
|
+
if (!staticSchema && typename && db) {
|
|
36
|
+
const query = db.schemaRegistry.query({ typename });
|
|
42
37
|
const unsubscribe = query.subscribe(
|
|
43
38
|
() => {
|
|
44
39
|
const [schema] = query.results;
|
|
@@ -50,21 +45,14 @@ export const KanbanContainer = ({ view }: { view: View.View; role: string }) =>
|
|
|
50
45
|
);
|
|
51
46
|
return unsubscribe;
|
|
52
47
|
}
|
|
53
|
-
}, [
|
|
54
|
-
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
if (jsonSchema) {
|
|
57
|
-
setProjection(new ProjectionModel(jsonSchema, view.projection));
|
|
58
|
-
}
|
|
59
|
-
// TODO(ZaymonFC): Is there a better way to get notified about deep changes in the json schema?
|
|
60
|
-
}, [view.projection, JSON.stringify(jsonSchema)]);
|
|
48
|
+
}, [schemas, db, typename]);
|
|
61
49
|
|
|
62
|
-
const objects = useQuery(
|
|
50
|
+
const objects = useQuery(db, cardSchema ? Filter.type(cardSchema) : Filter.nothing());
|
|
63
51
|
const filteredObjects = useGlobalFilteredObjects(objects);
|
|
64
52
|
|
|
53
|
+
const projection = useProjectionModel(cardSchema, object, registry);
|
|
65
54
|
const model = useKanbanModel({
|
|
66
|
-
|
|
67
|
-
schema: cardSchema,
|
|
55
|
+
object,
|
|
68
56
|
projection,
|
|
69
57
|
items: filteredObjects,
|
|
70
58
|
});
|
|
@@ -72,25 +60,25 @@ export const KanbanContainer = ({ view }: { view: View.View; role: string }) =>
|
|
|
72
60
|
const handleAddCard = useCallback(
|
|
73
61
|
(columnValue: string | undefined) => {
|
|
74
62
|
const path = model?.columnFieldPath;
|
|
75
|
-
if (
|
|
63
|
+
if (db && cardSchema && path) {
|
|
76
64
|
const card = Obj.make(cardSchema, { [path]: columnValue });
|
|
77
|
-
|
|
65
|
+
db.add(card);
|
|
78
66
|
return card.id;
|
|
79
67
|
}
|
|
80
68
|
},
|
|
81
|
-
[
|
|
69
|
+
[db, cardSchema, model],
|
|
82
70
|
);
|
|
83
71
|
|
|
84
72
|
const handleRemoveCard = useCallback(
|
|
85
73
|
(card: { id: string }) => {
|
|
86
|
-
void
|
|
74
|
+
void invokePromise(KanbanOperation.DeleteCard, { card });
|
|
87
75
|
},
|
|
88
|
-
[
|
|
76
|
+
[invokePromise],
|
|
89
77
|
);
|
|
90
78
|
|
|
91
79
|
return (
|
|
92
|
-
<
|
|
93
|
-
{model && <
|
|
94
|
-
</
|
|
80
|
+
<Layout.Main role={role}>
|
|
81
|
+
{model && <KanbanComponent model={model} onAddCard={handleAddCard} onRemoveCard={handleRemoveCard} />}
|
|
82
|
+
</Layout.Main>
|
|
95
83
|
);
|
|
96
84
|
};
|
|
@@ -2,63 +2,58 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return projection;
|
|
29
|
-
}
|
|
30
|
-
}, [view.projection, JSON.stringify(schema)]);
|
|
5
|
+
import { RegistryContext } from '@effect-atom/atom-react';
|
|
6
|
+
import React, { useCallback, useContext, useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
9
|
+
import { Format } from '@dxos/echo/internal';
|
|
10
|
+
import { invariant } from '@dxos/invariant';
|
|
11
|
+
import { useSchema } from '@dxos/react-client/echo';
|
|
12
|
+
import { Form, type FormFieldMap, SelectField } from '@dxos/react-ui-form';
|
|
13
|
+
import { useProjectionModel } from '@dxos/react-ui-kanban';
|
|
14
|
+
import { type Kanban } from '@dxos/react-ui-kanban/types';
|
|
15
|
+
import { getTypenameFromQuery } from '@dxos/schema';
|
|
16
|
+
|
|
17
|
+
import { SettingsSchema } from '../types';
|
|
18
|
+
|
|
19
|
+
type KanbanViewEditorProps = { object: Kanban.Kanban };
|
|
20
|
+
|
|
21
|
+
export const KanbanViewEditor = ({ object }: KanbanViewEditorProps) => {
|
|
22
|
+
const registry = useContext(RegistryContext);
|
|
23
|
+
const db = Obj.getDatabase(object);
|
|
24
|
+
const view = object.view.target;
|
|
25
|
+
const currentTypename = view?.query ? getTypenameFromQuery(view.query.ast) : undefined;
|
|
26
|
+
const schema = useSchema(db, currentTypename);
|
|
27
|
+
const projection = useProjectionModel(schema, object, registry);
|
|
31
28
|
|
|
32
29
|
const fieldProjections = projection?.getFieldProjections() || [];
|
|
33
30
|
const selectFields = fieldProjections
|
|
34
|
-
.filter((field) => field.props.format ===
|
|
31
|
+
.filter((field) => field.props.format === Format.TypeFormat.SingleSelect)
|
|
35
32
|
.map(({ field }) => ({ value: field.id, label: field.path }));
|
|
36
33
|
|
|
37
34
|
const handleSave = useCallback(
|
|
38
35
|
(values: Partial<{ columnFieldId: string }>) => {
|
|
39
|
-
view
|
|
36
|
+
invariant(view);
|
|
37
|
+
Obj.change(view, (v) => {
|
|
38
|
+
v.projection.pivotFieldId = values.columnFieldId;
|
|
39
|
+
});
|
|
40
40
|
},
|
|
41
41
|
[view],
|
|
42
42
|
);
|
|
43
43
|
|
|
44
44
|
const initialValues = useMemo(
|
|
45
|
-
() => ({ columnFieldId: view
|
|
46
|
-
[view
|
|
45
|
+
() => ({ columnFieldId: view?.projection.pivotFieldId }),
|
|
46
|
+
[view?.projection.pivotFieldId],
|
|
47
47
|
);
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
|
|
49
|
+
const fieldMap: FormFieldMap = useMemo(
|
|
50
|
+
() => ({ columnFieldId: (props) => <SelectField {...props} options={selectFields} /> }),
|
|
50
51
|
[selectFields],
|
|
51
52
|
);
|
|
52
53
|
|
|
53
54
|
return (
|
|
54
|
-
<Form
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
values={initialValues}
|
|
58
|
-
onSave={handleSave}
|
|
59
|
-
autoSave
|
|
60
|
-
outerSpacing={false}
|
|
61
|
-
classNames='pbs-inputSpacingBlock'
|
|
62
|
-
/>
|
|
55
|
+
<Form.Root schema={SettingsSchema} values={initialValues} fieldMap={fieldMap} autoSave onSave={handleSave}>
|
|
56
|
+
<Form.FieldSet />
|
|
57
|
+
</Form.Root>
|
|
63
58
|
);
|
|
64
59
|
};
|
package/src/meta.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
|
-
export const meta:
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
9
|
id: 'dxos.org/plugin/kanban',
|
|
10
10
|
name: 'Kanban',
|
|
11
11
|
description: trim`
|