@dxos/plugin-pipeline 0.8.4-main.52d7546f51 → 0.8.4-main.74a063c4e0
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/index.mjs +63 -74
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +0 -9
- package/dist/types/src/PipelinePlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder.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/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/PipelineComponent/PipelineColumn.d.ts +9 -0
- package/dist/types/src/components/PipelineComponent/PipelineColumn.d.ts.map +1 -0
- package/dist/types/src/components/PipelineComponent/PipelineComponent.d.ts +65 -0
- package/dist/types/src/components/PipelineComponent/PipelineComponent.d.ts.map +1 -0
- package/dist/types/src/components/PipelineComponent/PipelineComponent.stories.d.ts +43 -0
- package/dist/types/src/components/PipelineComponent/PipelineComponent.stories.d.ts.map +1 -0
- package/dist/types/src/components/PipelineComponent/index.d.ts +3 -0
- package/dist/types/src/components/PipelineComponent/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/PipelineContainer/PipelineContainer.d.ts +6 -0
- package/dist/types/src/containers/PipelineContainer/PipelineContainer.d.ts.map +1 -0
- package/dist/types/src/containers/PipelineContainer/PipelineContainer.stories.d.ts +57 -0
- package/dist/types/src/containers/PipelineContainer/PipelineContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/PipelineContainer/index.d.ts +2 -0
- package/dist/types/src/containers/PipelineContainer/index.d.ts.map +1 -0
- package/dist/types/src/{components/PipelineSettings.d.ts → containers/PipelineObjectSettings/PipelineObjectSettings.d.ts} +1 -2
- package/dist/types/src/containers/PipelineObjectSettings/PipelineObjectSettings.d.ts.map +1 -0
- package/dist/types/src/containers/PipelineObjectSettings/index.d.ts +2 -0
- package/dist/types/src/containers/PipelineObjectSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/usePipelineBoardModel.d.ts +6 -0
- package/dist/types/src/hooks/usePipelineBoardModel.d.ts.map +1 -0
- package/dist/types/src/templates/research.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +22 -21
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +0 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +53 -41
- package/src/PipelinePlugin.tsx +20 -19
- package/src/capabilities/app-graph-builder.ts +40 -0
- package/src/capabilities/index.ts +4 -3
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +20 -14
- package/src/components/PipelineComponent/PipelineColumn.tsx +164 -0
- package/src/components/{PipelineComponent.stories.tsx → PipelineComponent/PipelineComponent.stories.tsx} +45 -30
- package/src/components/PipelineComponent/PipelineComponent.tsx +140 -0
- package/src/components/PipelineComponent/index.ts +6 -0
- package/src/components/index.ts +1 -7
- package/src/containers/PipelineContainer/PipelineContainer.stories.tsx +229 -0
- package/src/containers/PipelineContainer/PipelineContainer.tsx +86 -0
- package/src/containers/PipelineContainer/index.ts +5 -0
- package/src/{components/PipelineSettings.tsx → containers/PipelineObjectSettings/PipelineObjectSettings.tsx} +75 -63
- package/src/containers/PipelineObjectSettings/index.ts +5 -0
- package/src/containers/index.ts +8 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/usePipelineBoardModel.ts +79 -0
- package/src/meta.ts +1 -1
- package/src/templates/research.ts +14 -15
- package/src/translations.ts +22 -21
- package/src/types/index.ts +0 -3
- package/dist/lib/browser/PipelineContainer-I3TPA7ZN.mjs +0 -217
- package/dist/lib/browser/PipelineContainer-I3TPA7ZN.mjs.map +0 -7
- package/dist/lib/browser/PipelineSettings-YSGSJHBT.mjs +0 -212
- package/dist/lib/browser/PipelineSettings-YSGSJHBT.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-NUJB33F7.mjs +0 -65
- package/dist/lib/browser/app-graph-builder-NUJB33F7.mjs.map +0 -7
- package/dist/lib/browser/chunk-7GVESVYR.mjs +0 -42
- package/dist/lib/browser/chunk-7GVESVYR.mjs.map +0 -7
- package/dist/lib/browser/chunk-QWNKLHBY.mjs +0 -28
- package/dist/lib/browser/chunk-QWNKLHBY.mjs.map +0 -7
- package/dist/lib/browser/react-surface-JMMCTIL3.mjs +0 -57
- package/dist/lib/browser/react-surface-JMMCTIL3.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +0 -6
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +0 -3
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -2
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/PipelineColumn.d.ts +0 -10
- package/dist/types/src/components/PipelineColumn.d.ts.map +0 -1
- package/dist/types/src/components/PipelineComponent.d.ts +0 -38
- package/dist/types/src/components/PipelineComponent.d.ts.map +0 -1
- package/dist/types/src/components/PipelineComponent.stories.d.ts +0 -42
- package/dist/types/src/components/PipelineComponent.stories.d.ts.map +0 -1
- package/dist/types/src/components/PipelineContainer.d.ts +0 -7
- package/dist/types/src/components/PipelineContainer.d.ts.map +0 -1
- package/dist/types/src/components/PipelineContainer.stories.d.ts +0 -56
- package/dist/types/src/components/PipelineContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/PipelineSettings.d.ts.map +0 -1
- package/dist/types/src/types/PipelineAction.d.ts +0 -25
- package/dist/types/src/types/PipelineAction.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +0 -51
- package/src/capabilities/app-graph-builder/index.ts +0 -7
- package/src/capabilities/operation-resolver/index.ts +0 -5
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -29
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/components/PipelineColumn.tsx +0 -145
- package/src/components/PipelineComponent.tsx +0 -103
- package/src/components/PipelineContainer.stories.tsx +0 -226
- package/src/components/PipelineContainer.tsx +0 -57
- package/src/types/PipelineAction.ts +0 -29
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useAtomValue } from '@effect-atom/atom-react';
|
|
6
|
+
import { createContext } from '@radix-ui/react-context';
|
|
7
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
8
|
+
import React, { type FC, type PropsWithChildren } from 'react';
|
|
9
|
+
|
|
10
|
+
import { Obj } from '@dxos/echo';
|
|
11
|
+
import { Toolbar, type ToolbarRootProps, useTranslation } from '@dxos/react-ui';
|
|
12
|
+
import { Board, type BoardModel, useBoard, useEventHandlerAdapter } from '@dxos/react-ui-mosaic';
|
|
13
|
+
import { type ProjectionModel } from '@dxos/schema';
|
|
14
|
+
import { type Pipeline } from '@dxos/types';
|
|
15
|
+
import { composable, composableProps, slottable } from '@dxos/ui-theme';
|
|
16
|
+
|
|
17
|
+
import { meta } from '#meta';
|
|
18
|
+
|
|
19
|
+
import { PipelineColumn } from './PipelineColumn';
|
|
20
|
+
|
|
21
|
+
type ItemProps = {
|
|
22
|
+
item: Obj.Unknown;
|
|
23
|
+
projectionModel?: ProjectionModel;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const itemNoOp = ({ item }: ItemProps) => <span>{item.id}</span>;
|
|
27
|
+
|
|
28
|
+
//
|
|
29
|
+
// Root
|
|
30
|
+
//
|
|
31
|
+
|
|
32
|
+
type PipelineContextValue = {
|
|
33
|
+
Item: FC<ItemProps>;
|
|
34
|
+
// TODO(wittjosiah): Support adding items.
|
|
35
|
+
// If the created item doesn't match the current query, it will not be visible.
|
|
36
|
+
// TODO(wittjosiah): onAddItem?: (schema: Schema.Schema.AnyNoContext) => void;
|
|
37
|
+
onAddColumn?: () => void;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type PipelineRootProps = PropsWithChildren<PipelineContextValue>;
|
|
41
|
+
|
|
42
|
+
const PIPELINE_ROOT = 'Pipeline.Root';
|
|
43
|
+
|
|
44
|
+
const [PipelineRootContext, usePipeline] = createContext<PipelineContextValue>(PIPELINE_ROOT, {
|
|
45
|
+
Item: itemNoOp,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const PipelineRoot = ({ children, ...contextValue }: PipelineRootProps) => (
|
|
49
|
+
<PipelineRootContext {...contextValue}>{children}</PipelineRootContext>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
PipelineRoot.displayName = PIPELINE_ROOT;
|
|
53
|
+
|
|
54
|
+
//
|
|
55
|
+
// Content
|
|
56
|
+
//
|
|
57
|
+
|
|
58
|
+
const PIPELINE_CONTENT_NAME = 'Pipeline.Content';
|
|
59
|
+
|
|
60
|
+
type PipelineContentProps = PropsWithChildren<{
|
|
61
|
+
model: BoardModel<Pipeline.Column, Obj.Unknown>;
|
|
62
|
+
}>;
|
|
63
|
+
|
|
64
|
+
const PipelineContent = slottable<HTMLDivElement, PipelineContentProps>(
|
|
65
|
+
({ asChild, model, children, ...props }, forwardedRef) => {
|
|
66
|
+
const Comp = asChild ? Slot : 'div';
|
|
67
|
+
return (
|
|
68
|
+
<Board.Root model={model}>
|
|
69
|
+
<Comp {...composableProps(props)} ref={forwardedRef}>
|
|
70
|
+
{children}
|
|
71
|
+
</Comp>
|
|
72
|
+
</Board.Root>
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
PipelineContent.displayName = PIPELINE_CONTENT_NAME;
|
|
78
|
+
|
|
79
|
+
//
|
|
80
|
+
// Columns
|
|
81
|
+
//
|
|
82
|
+
|
|
83
|
+
const PIPELINE_COLUMNS_NAME = 'Pipeline.Columns';
|
|
84
|
+
|
|
85
|
+
type PipelineColumnsProps = {
|
|
86
|
+
pipeline: Pipeline.Pipeline;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const PipelineColumns = composable<HTMLDivElement, PipelineColumnsProps>(({ pipeline, ...props }) => {
|
|
90
|
+
const { model } = useBoard(PIPELINE_COLUMNS_NAME);
|
|
91
|
+
const columns = useAtomValue(model.columns);
|
|
92
|
+
const eventHandler = useEventHandlerAdapter<Pipeline.Column, Obj.Unknown>({
|
|
93
|
+
id: pipeline.id,
|
|
94
|
+
// TODO(wittjosiah): Cast because columns array is readonly.
|
|
95
|
+
items: columns as any,
|
|
96
|
+
getId: model.getColumnId,
|
|
97
|
+
get: (data) => data as unknown as Obj.Unknown,
|
|
98
|
+
make: (object) => object as unknown as Pipeline.Column,
|
|
99
|
+
canDrop: ({ source }) => model.isColumn(source.data),
|
|
100
|
+
onChange: (mutate) => Obj.change(pipeline, (obj) => mutate(obj.columns)),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return <Board.Content {...props} id='pipeline' eventHandler={eventHandler} Tile={PipelineColumn} />;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
PipelineColumns.displayName = PIPELINE_COLUMNS_NAME;
|
|
107
|
+
|
|
108
|
+
//
|
|
109
|
+
// Toolbar
|
|
110
|
+
//
|
|
111
|
+
|
|
112
|
+
const PIPELINE_TOOLBAR_NAME = 'Pipeline.Toolbar';
|
|
113
|
+
|
|
114
|
+
export const PipelineToolbar = composable<HTMLDivElement, ToolbarRootProps>(({ children, ...props }, forwardedRef) => {
|
|
115
|
+
const { t } = useTranslation(meta.id);
|
|
116
|
+
const { onAddColumn } = usePipeline(PIPELINE_TOOLBAR_NAME);
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<Toolbar.Root {...composableProps(props)} ref={forwardedRef}>
|
|
120
|
+
<Toolbar.IconButton icon='ph--plus--regular' iconOnly label={t('add-column.label')} onClick={onAddColumn} />
|
|
121
|
+
</Toolbar.Root>
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
PipelineToolbar.displayName = PIPELINE_TOOLBAR_NAME;
|
|
126
|
+
|
|
127
|
+
//
|
|
128
|
+
// Project
|
|
129
|
+
//
|
|
130
|
+
|
|
131
|
+
export const PipelineComponent = {
|
|
132
|
+
Root: PipelineRoot,
|
|
133
|
+
Content: PipelineContent,
|
|
134
|
+
Columns: PipelineColumns,
|
|
135
|
+
Toolbar: PipelineToolbar,
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export { usePipeline };
|
|
139
|
+
|
|
140
|
+
export type { ItemProps, PipelineContextValue, PipelineRootProps, PipelineContentProps, PipelineColumnsProps };
|
package/src/components/index.ts
CHANGED
|
@@ -2,10 +2,4 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export type { PipelineContainerProps } from './PipelineContainer';
|
|
8
|
-
export type { PipelineObjectSettingsProps } from './PipelineSettings';
|
|
9
|
-
|
|
10
|
-
export const PipelineContainer = lazy(() => import('./PipelineContainer'));
|
|
11
|
-
export const PipelineObjectSettings = lazy(() => import('./PipelineSettings'));
|
|
5
|
+
export * from './PipelineComponent';
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import * as Layer from 'effect/Layer';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
11
|
+
import { Filter, Ref } from '@dxos/client/echo';
|
|
12
|
+
import { Database, Feed, JsonSchema, Obj, Query, Tag } from '@dxos/echo';
|
|
13
|
+
import { Collection, View } from '@dxos/echo';
|
|
14
|
+
import { createFeedServiceLayer } from '@dxos/echo-db';
|
|
15
|
+
import { ClientPlugin } from '@dxos/plugin-client';
|
|
16
|
+
import { initializeIdentity } from '@dxos/plugin-client/testing';
|
|
17
|
+
import { InboxPlugin } from '@dxos/plugin-inbox';
|
|
18
|
+
import { PreviewPlugin } from '@dxos/plugin-preview';
|
|
19
|
+
import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
|
|
20
|
+
import { random } from '@dxos/random';
|
|
21
|
+
import { useDatabase, useQuery } from '@dxos/react-client/echo';
|
|
22
|
+
import { translations as stackTranslations } from '@dxos/react-ui-stack';
|
|
23
|
+
import { withLayout } from '@dxos/react-ui/testing';
|
|
24
|
+
import { ViewModel } from '@dxos/schema';
|
|
25
|
+
import { createObjectFactory } from '@dxos/schema/testing';
|
|
26
|
+
import { Message, Organization, Person, Pipeline, Task } from '@dxos/types';
|
|
27
|
+
|
|
28
|
+
import { translations } from '../../translations';
|
|
29
|
+
import PipelineObjectSettings from '../PipelineObjectSettings';
|
|
30
|
+
import { PipelineContainer } from './PipelineContainer';
|
|
31
|
+
|
|
32
|
+
random.seed(0);
|
|
33
|
+
|
|
34
|
+
const DefaultStory = () => {
|
|
35
|
+
const db = useDatabase();
|
|
36
|
+
const pipelines = useQuery(db, Filter.type(Pipeline.Pipeline));
|
|
37
|
+
const pipeline = pipelines[0];
|
|
38
|
+
|
|
39
|
+
if (!pipeline) {
|
|
40
|
+
return <p>Loading…</p>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div className='grow grid grid-cols-[1fr_350px] overflow-hidden h-full w-full'>
|
|
45
|
+
<PipelineContainer role='article' subject={pipeline} attendableId='test' />
|
|
46
|
+
<PipelineObjectSettings pipeline={pipeline} classNames='border-s border-separator' />
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const meta = {
|
|
52
|
+
title: 'plugins/plugin-pipeline/containers/PipelineContainer',
|
|
53
|
+
render: DefaultStory,
|
|
54
|
+
decorators: [
|
|
55
|
+
withLayout({ layout: 'fullscreen' }),
|
|
56
|
+
withPluginManager({
|
|
57
|
+
plugins: [
|
|
58
|
+
...corePlugins(),
|
|
59
|
+
StorybookPlugin({}),
|
|
60
|
+
ClientPlugin({
|
|
61
|
+
types: [
|
|
62
|
+
Tag.Tag,
|
|
63
|
+
Feed.Feed,
|
|
64
|
+
Pipeline.Pipeline,
|
|
65
|
+
View.View,
|
|
66
|
+
Collection.Collection,
|
|
67
|
+
Organization.Organization,
|
|
68
|
+
Task.Task,
|
|
69
|
+
Person.Person,
|
|
70
|
+
Message.Message,
|
|
71
|
+
],
|
|
72
|
+
onClientInitialized: Effect.fnUntraced(function* ({ client }) {
|
|
73
|
+
const { personalSpace } = yield* initializeIdentity(client);
|
|
74
|
+
|
|
75
|
+
yield* Effect.gen(function* () {
|
|
76
|
+
const tag = yield* Database.add(Tag.make({ label: 'important', hue: 'green' }));
|
|
77
|
+
const tagDxn = Obj.getDXN(tag).toString();
|
|
78
|
+
|
|
79
|
+
// Create a view for Contacts.
|
|
80
|
+
const personView = ViewModel.make({
|
|
81
|
+
query: Query.select(Filter.type(Person.Person)),
|
|
82
|
+
jsonSchema: JsonSchema.toJsonSchema(Person.Person),
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Create a view for Organizations.
|
|
86
|
+
const organizationView = ViewModel.make({
|
|
87
|
+
query: Query.select(Filter.type(Organization.Organization)).select(Filter.tag(tagDxn)),
|
|
88
|
+
jsonSchema: JsonSchema.toJsonSchema(Organization.Organization),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Create a view for Tasks.
|
|
92
|
+
const taskView = ViewModel.make({
|
|
93
|
+
query: Query.select(Filter.type(Task.Task)).select(Filter.tag(tagDxn)),
|
|
94
|
+
jsonSchema: JsonSchema.toJsonSchema(Task.Task),
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// Create a view for Project-Projects.
|
|
98
|
+
const projectView = ViewModel.make({
|
|
99
|
+
query: Query.select(Filter.type(Pipeline.Pipeline)),
|
|
100
|
+
jsonSchema: JsonSchema.toJsonSchema(Pipeline.Pipeline),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Create a feed for Messages.
|
|
104
|
+
const messageFeed = yield* Database.add(Feed.make({ name: 'Messages' }));
|
|
105
|
+
const messages = Array.from({ length: 20 }).map(() =>
|
|
106
|
+
Obj.make(Message.Message, {
|
|
107
|
+
created: random.date.recent().toISOString(),
|
|
108
|
+
sender: { role: 'user' },
|
|
109
|
+
blocks: [{ _tag: 'text' as const, text: random.lorem.sentences(2) }],
|
|
110
|
+
}),
|
|
111
|
+
);
|
|
112
|
+
yield* Feed.append(messageFeed, messages);
|
|
113
|
+
|
|
114
|
+
const messageQueueDxn = Feed.getQueueDxn(messageFeed)!.toString();
|
|
115
|
+
const messageView = ViewModel.make({
|
|
116
|
+
query: Query.select(Filter.type(Message.Message)).from({
|
|
117
|
+
queues: [messageQueueDxn],
|
|
118
|
+
}),
|
|
119
|
+
jsonSchema: JsonSchema.toJsonSchema(Message.Message),
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Create a feed for Tasks (for testing feed switching in settings).
|
|
123
|
+
const taskFeed = yield* Database.add(Feed.make({ name: 'Tasks' }));
|
|
124
|
+
const feedTasks = Array.from({ length: 10 }).map(() =>
|
|
125
|
+
Obj.make(Task.Task, {
|
|
126
|
+
title: random.lorem.sentence(),
|
|
127
|
+
status: random.helpers.arrayElement(['todo', 'in-progress', 'done']) as any,
|
|
128
|
+
priority: random.helpers.arrayElement(['low', 'medium', 'high']) as any,
|
|
129
|
+
}),
|
|
130
|
+
);
|
|
131
|
+
yield* Feed.append(taskFeed, feedTasks);
|
|
132
|
+
|
|
133
|
+
// Create pipeline with columns.
|
|
134
|
+
const pipeline = Pipeline.make({
|
|
135
|
+
columns: [
|
|
136
|
+
{
|
|
137
|
+
name: 'Contacts',
|
|
138
|
+
view: Ref.make(personView),
|
|
139
|
+
order: [],
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: 'Organizations',
|
|
143
|
+
view: Ref.make(organizationView),
|
|
144
|
+
order: [],
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: 'Tasks',
|
|
148
|
+
view: Ref.make(taskView),
|
|
149
|
+
order: [],
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: 'Projects',
|
|
153
|
+
view: Ref.make(projectView),
|
|
154
|
+
order: [],
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: 'Messages',
|
|
158
|
+
view: Ref.make(messageView),
|
|
159
|
+
order: [],
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
});
|
|
163
|
+
yield* Database.add(pipeline);
|
|
164
|
+
|
|
165
|
+
// Generate sample Organizations.
|
|
166
|
+
for (const _ of Array.from({ length: 20 })) {
|
|
167
|
+
yield* Database.add(
|
|
168
|
+
Obj.make(Organization.Organization, {
|
|
169
|
+
[Obj.Meta]: {
|
|
170
|
+
tags: random.datatype.boolean() ? [tagDxn] : [],
|
|
171
|
+
},
|
|
172
|
+
name: random.company.name(),
|
|
173
|
+
website: random.internet.url(),
|
|
174
|
+
description: random.lorem.paragraph(),
|
|
175
|
+
image: random.image.url(),
|
|
176
|
+
}),
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Generate sample Tasks.
|
|
181
|
+
for (const _ of Array.from({ length: 20 })) {
|
|
182
|
+
yield* Database.add(
|
|
183
|
+
Obj.make(Task.Task, {
|
|
184
|
+
[Obj.Meta]: {
|
|
185
|
+
tags: random.datatype.boolean() ? [tagDxn] : [],
|
|
186
|
+
},
|
|
187
|
+
title: random.lorem.sentence(),
|
|
188
|
+
status: random.helpers.arrayElement(['todo', 'in-progress', 'done']) as any,
|
|
189
|
+
priority: random.helpers.arrayElement(['low', 'medium', 'high']) as any,
|
|
190
|
+
}),
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Generate sample Contacts.
|
|
195
|
+
const factory = createObjectFactory(personalSpace.db, random as any);
|
|
196
|
+
yield* Effect.promise(() => factory([{ type: Person.Person, count: 12 }]));
|
|
197
|
+
|
|
198
|
+
// Generate sample Projects.
|
|
199
|
+
for (const _ of Array.from({ length: 20 })) {
|
|
200
|
+
yield* Database.add(
|
|
201
|
+
Pipeline.make({
|
|
202
|
+
name: random.commerce.productName(),
|
|
203
|
+
description: random.lorem.sentence(),
|
|
204
|
+
}),
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
}).pipe(
|
|
208
|
+
Effect.provide(
|
|
209
|
+
Layer.merge(Database.layer(personalSpace.db), createFeedServiceLayer(personalSpace.queues)),
|
|
210
|
+
),
|
|
211
|
+
);
|
|
212
|
+
}),
|
|
213
|
+
}),
|
|
214
|
+
InboxPlugin(),
|
|
215
|
+
PreviewPlugin(),
|
|
216
|
+
],
|
|
217
|
+
}),
|
|
218
|
+
],
|
|
219
|
+
parameters: {
|
|
220
|
+
layout: 'fullscreen',
|
|
221
|
+
translations: [...translations, ...stackTranslations],
|
|
222
|
+
},
|
|
223
|
+
} satisfies Meta<typeof PipelineContainer>;
|
|
224
|
+
|
|
225
|
+
export default meta;
|
|
226
|
+
|
|
227
|
+
type Story = StoryObj<typeof meta>;
|
|
228
|
+
|
|
229
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback, useEffect } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Capabilities } from '@dxos/app-framework';
|
|
8
|
+
import { useCapability } from '@dxos/app-framework/ui';
|
|
9
|
+
import { useOperationInvoker } from '@dxos/app-framework/ui';
|
|
10
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
11
|
+
import {
|
|
12
|
+
OBJECT_ACTIONS_CONTRIBUTION_ID,
|
|
13
|
+
OBJECT_ACTIONS_CONTRIBUTION_PRIORITY,
|
|
14
|
+
useObjectMenuItems,
|
|
15
|
+
} from '@dxos/app-toolkit/ui';
|
|
16
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
17
|
+
import { DeckOperation } from '@dxos/plugin-deck/operations';
|
|
18
|
+
import { Panel } from '@dxos/react-ui';
|
|
19
|
+
import { linkedSegment } from '@dxos/react-ui-attention';
|
|
20
|
+
import { useAttention } from '@dxos/react-ui-attention';
|
|
21
|
+
import { useMenu } from '@dxos/react-ui-menu';
|
|
22
|
+
import { type Pipeline } from '@dxos/types';
|
|
23
|
+
|
|
24
|
+
import { type ItemProps, PipelineComponent } from '#components';
|
|
25
|
+
import { usePipelineBoardModel } from '#hooks';
|
|
26
|
+
|
|
27
|
+
const PIPELINE_ITEM = 'PipelineItem';
|
|
28
|
+
|
|
29
|
+
export type PipelineContainerProps = AppSurface.ObjectArticleProps<Pipeline.Pipeline>;
|
|
30
|
+
|
|
31
|
+
export const PipelineContainer = ({ role, subject: pipeline, attendableId }: PipelineContainerProps) => {
|
|
32
|
+
const registry = useCapability(Capabilities.AtomRegistry);
|
|
33
|
+
const model = usePipelineBoardModel(pipeline, registry);
|
|
34
|
+
const { invokePromise } = useOperationInvoker();
|
|
35
|
+
const { hasAttention } = useAttention(attendableId);
|
|
36
|
+
|
|
37
|
+
const handleColumnAdd = useCallback(
|
|
38
|
+
() =>
|
|
39
|
+
invokePromise(DeckOperation.ChangeCompanion, {
|
|
40
|
+
companion: linkedSegment('settings'),
|
|
41
|
+
}),
|
|
42
|
+
[invokePromise],
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<PipelineComponent.Root Item={PipelineItem} onAddColumn={handleColumnAdd}>
|
|
47
|
+
<Panel.Root role={role}>
|
|
48
|
+
<Panel.Toolbar asChild>
|
|
49
|
+
<PipelineComponent.Toolbar disabled={!hasAttention} />
|
|
50
|
+
</Panel.Toolbar>
|
|
51
|
+
<Panel.Content asChild>
|
|
52
|
+
<PipelineComponent.Content asChild model={model}>
|
|
53
|
+
<PipelineComponent.Columns pipeline={pipeline} />
|
|
54
|
+
</PipelineComponent.Content>
|
|
55
|
+
</Panel.Content>
|
|
56
|
+
</Panel.Root>
|
|
57
|
+
</PipelineComponent.Root>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const PipelineItem = ({ item, projectionModel }: ItemProps) => {
|
|
62
|
+
const menu = useMenu(PIPELINE_ITEM);
|
|
63
|
+
const items = useObjectMenuItems(item);
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
menu.addMenuItems({
|
|
67
|
+
id: OBJECT_ACTIONS_CONTRIBUTION_ID,
|
|
68
|
+
mode: 'additive',
|
|
69
|
+
priority: OBJECT_ACTIONS_CONTRIBUTION_PRIORITY,
|
|
70
|
+
items,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return () => menu.removeMenuItems(OBJECT_ACTIONS_CONTRIBUTION_ID);
|
|
74
|
+
}, [menu, items]);
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<Surface.Surface
|
|
78
|
+
role='card--content'
|
|
79
|
+
data={{
|
|
80
|
+
subject: item,
|
|
81
|
+
projection: projectionModel,
|
|
82
|
+
}}
|
|
83
|
+
limit={1}
|
|
84
|
+
/>
|
|
85
|
+
);
|
|
86
|
+
};
|