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