@finos/legend-extension-dsl-data-space-studio 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +3 -0
  3. package/lib/__lib__/DSL_DataSpace_LegendStudioCodeSnippet.d.ts +17 -0
  4. package/lib/__lib__/DSL_DataSpace_LegendStudioCodeSnippet.d.ts.map +1 -0
  5. package/lib/__lib__/DSL_DataSpace_LegendStudioCodeSnippet.js +54 -0
  6. package/lib/__lib__/DSL_DataSpace_LegendStudioCodeSnippet.js.map +1 -0
  7. package/lib/__lib__/DSL_DataSpace_LegendStudioDocumentation.d.ts +21 -0
  8. package/lib/__lib__/DSL_DataSpace_LegendStudioDocumentation.d.ts.map +1 -0
  9. package/lib/__lib__/DSL_DataSpace_LegendStudioDocumentation.js +22 -0
  10. package/lib/__lib__/DSL_DataSpace_LegendStudioDocumentation.js.map +1 -0
  11. package/lib/components/DSL_DataSpace_LegendStudioApplicationPlugin.d.ts +39 -0
  12. package/lib/components/DSL_DataSpace_LegendStudioApplicationPlugin.d.ts.map +1 -0
  13. package/lib/components/DSL_DataSpace_LegendStudioApplicationPlugin.js +206 -0
  14. package/lib/components/DSL_DataSpace_LegendStudioApplicationPlugin.js.map +1 -0
  15. package/lib/components/DataSpacePreviewAction.d.ts +25 -0
  16. package/lib/components/DataSpacePreviewAction.d.ts.map +1 -0
  17. package/lib/components/DataSpacePreviewAction.js +53 -0
  18. package/lib/components/DataSpacePreviewAction.js.map +1 -0
  19. package/lib/components/DataSpaceQueryAction.d.ts +24 -0
  20. package/lib/components/DataSpaceQueryAction.d.ts.map +1 -0
  21. package/lib/components/DataSpaceQueryAction.js +52 -0
  22. package/lib/components/DataSpaceQueryAction.js.map +1 -0
  23. package/lib/components/DataSpaceTemplateQueryPromoteReview.d.ts +19 -0
  24. package/lib/components/DataSpaceTemplateQueryPromoteReview.d.ts.map +1 -0
  25. package/lib/components/DataSpaceTemplateQueryPromoteReview.js +81 -0
  26. package/lib/components/DataSpaceTemplateQueryPromoteReview.js.map +1 -0
  27. package/lib/index.css +17 -0
  28. package/lib/index.css.map +1 -0
  29. package/lib/index.d.ts +17 -0
  30. package/lib/index.d.ts.map +1 -0
  31. package/lib/index.js +17 -0
  32. package/lib/index.js.map +1 -0
  33. package/lib/package.json +75 -0
  34. package/lib/stores/DataSpacePreviewState.d.ts +33 -0
  35. package/lib/stores/DataSpacePreviewState.d.ts.map +1 -0
  36. package/lib/stores/DataSpacePreviewState.js +116 -0
  37. package/lib/stores/DataSpacePreviewState.js.map +1 -0
  38. package/lib/stores/DataSpaceTemplateQueryPromotionReviewerStore.d.ts +61 -0
  39. package/lib/stores/DataSpaceTemplateQueryPromotionReviewerStore.d.ts.map +1 -0
  40. package/lib/stores/DataSpaceTemplateQueryPromotionReviewerStore.js +406 -0
  41. package/lib/stores/DataSpaceTemplateQueryPromotionReviewerStore.js.map +1 -0
  42. package/package.json +75 -0
  43. package/src/__lib__/DSL_DataSpace_LegendStudioCodeSnippet.ts +54 -0
  44. package/src/__lib__/DSL_DataSpace_LegendStudioDocumentation.ts +21 -0
  45. package/src/components/DSL_DataSpace_LegendStudioApplicationPlugin.tsx +299 -0
  46. package/src/components/DataSpacePreviewAction.tsx +136 -0
  47. package/src/components/DataSpaceQueryAction.tsx +100 -0
  48. package/src/components/DataSpaceTemplateQueryPromoteReview.tsx +292 -0
  49. package/src/index.ts +17 -0
  50. package/src/stores/DataSpacePreviewState.ts +199 -0
  51. package/src/stores/DataSpaceTemplateQueryPromotionReviewerStore.ts +636 -0
  52. package/tsconfig.json +54 -0
  53. package/tsconfig.package.json +37 -0
@@ -0,0 +1,299 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import packageJson from '../../package.json' assert { type: 'json' };
18
+ import {
19
+ type NewElementFromStateCreator,
20
+ type ElementClassifier,
21
+ type DragElementClassifier,
22
+ type ElementIconGetter,
23
+ type DSL_LegendStudioApplicationPlugin_Extension,
24
+ type NewElementState,
25
+ type ElementEditorStateCreator,
26
+ type EditorStore,
27
+ type ElementEditorState,
28
+ type PureGrammarParserElementDocumentationGetter,
29
+ type PureGrammarParserDocumentationGetter,
30
+ type PureGrammarParserKeywordSuggestionGetter,
31
+ type PureGrammarParserElementSnippetSuggestionsGetter,
32
+ UnsupportedElementEditorState,
33
+ LegendStudioApplicationPlugin,
34
+ type ExplorerContextMenuItemRendererConfiguration,
35
+ type EditorExtensionStateBuilder,
36
+ type EditorExtensionComponentRendererConfiguration,
37
+ PACKAGEABLE_ELEMENT_GROUP_BY_CATEGORY,
38
+ } from '@finos/legend-application-studio';
39
+ import {
40
+ PackageableElementExplicitReference,
41
+ stub_Mapping,
42
+ stub_PackageableRuntime,
43
+ type PackageableElement,
44
+ } from '@finos/legend-graph';
45
+ import type {
46
+ ApplicationPageEntry,
47
+ DocumentationEntry,
48
+ } from '@finos/legend-application';
49
+ import type { PureGrammarTextSuggestion } from '@finos/legend-lego/code-editor';
50
+ import {
51
+ DataSpace,
52
+ DataSpaceExecutionContext,
53
+ } from '@finos/legend-extension-dsl-data-space/graph';
54
+ import { DSL_DATA_SPACE_LEGEND_STUDIO_DOCUMENTATION_KEY } from '../__lib__/DSL_DataSpace_LegendStudioDocumentation.js';
55
+ import { DataSpacePreviewState } from '../stores/DataSpacePreviewState.js';
56
+ import { SIMPLE_DATA_SPACE_SNIPPET } from '../__lib__/DSL_DataSpace_LegendStudioCodeSnippet.js';
57
+ import {
58
+ DATA_SPACE_STUDIO_ROUTE_PATTERN,
59
+ DataSpaceIcon,
60
+ } from '@finos/legend-extension-dsl-data-space/application';
61
+ import { DataSpaceTemplateQueryPromotionReviewer } from './DataSpaceTemplateQueryPromoteReview.js';
62
+ import { DataSpaceQueryAction } from './DataSpaceQueryAction.js';
63
+ import {
64
+ DataSpacePreviewAction,
65
+ DataSpacePreviewDialog,
66
+ } from './DataSpacePreviewAction.js';
67
+
68
+ const DATA_SPACE_ELEMENT_TYPE = 'DATA SPACE';
69
+ const DATA_SPACE_ELEMENT_PROJECT_EXPLORER_DND_TYPE =
70
+ 'PROJECT_EXPLORER_DATA_SPACE';
71
+
72
+ const PURE_GRAMMAR_DATA_SPACE_PARSER_NAME = 'DataSpace';
73
+ const PURE_GRAMMAR_DATA_SPACE_ELEMENT_TYPE_LABEL = 'DataSpace';
74
+
75
+ export class DSL_DataSpace_LegendStudioApplicationPlugin
76
+ extends LegendStudioApplicationPlugin
77
+ implements DSL_LegendStudioApplicationPlugin_Extension
78
+ {
79
+ constructor() {
80
+ super(packageJson.extensions.applicationStudioPlugin, packageJson.version);
81
+ }
82
+
83
+ override getExtraRequiredDocumentationKeys(): string[] {
84
+ return [
85
+ DSL_DATA_SPACE_LEGEND_STUDIO_DOCUMENTATION_KEY.CONCEPT_ELEMENT_DATA_SPACE,
86
+ DSL_DATA_SPACE_LEGEND_STUDIO_DOCUMENTATION_KEY.GRAMMAR_PARSER,
87
+ ];
88
+ }
89
+
90
+ override getExtraApplicationPageEntries(): ApplicationPageEntry[] {
91
+ return [
92
+ {
93
+ key: 'promote-as-curated-template-query-page',
94
+ addressPatterns: [
95
+ DATA_SPACE_STUDIO_ROUTE_PATTERN.PROMOTE_TEMPLATE_QUERY,
96
+ ],
97
+ renderer: DataSpaceTemplateQueryPromotionReviewer,
98
+ },
99
+ ];
100
+ }
101
+
102
+ override getExtraExplorerContextMenuItemRendererConfigurations(): ExplorerContextMenuItemRendererConfiguration[] {
103
+ return [
104
+ {
105
+ key: 'data-space-query',
106
+ renderer: (editorStore, element) => {
107
+ if (element instanceof DataSpace) {
108
+ return <DataSpaceQueryAction dataSpace={element} />;
109
+ }
110
+ return undefined;
111
+ },
112
+ },
113
+ {
114
+ key: 'data-space-preview',
115
+ renderer: (editorStore, element) => {
116
+ if (element instanceof DataSpace) {
117
+ return <DataSpacePreviewAction dataSpace={element} />;
118
+ }
119
+ return undefined;
120
+ },
121
+ },
122
+ ];
123
+ }
124
+
125
+ override getExtraEditorExtensionStateBuilders(): EditorExtensionStateBuilder[] {
126
+ return [(editorStore) => new DataSpacePreviewState(editorStore)];
127
+ }
128
+
129
+ override getExtraEditorExtensionComponentRendererConfigurations(): EditorExtensionComponentRendererConfiguration[] {
130
+ return [
131
+ {
132
+ key: 'data-space-preview',
133
+ renderer: (editorStore) => <DataSpacePreviewDialog />,
134
+ },
135
+ ];
136
+ }
137
+
138
+ getExtraPureGrammarKeywords(): string[] {
139
+ return [PURE_GRAMMAR_DATA_SPACE_ELEMENT_TYPE_LABEL];
140
+ }
141
+
142
+ getExtraSupportedElementTypes(): string[] {
143
+ return [DATA_SPACE_ELEMENT_TYPE];
144
+ }
145
+
146
+ getExtraSupportedElementTypesWithCategory?(): Map<string, string[]> {
147
+ const elementTypesWithCategoryMap = new Map<string, string[]>();
148
+ elementTypesWithCategoryMap.set(
149
+ PACKAGEABLE_ELEMENT_GROUP_BY_CATEGORY.QUERY,
150
+ [DATA_SPACE_ELEMENT_TYPE],
151
+ );
152
+ return elementTypesWithCategoryMap;
153
+ }
154
+
155
+ getExtraElementClassifiers(): ElementClassifier[] {
156
+ return [
157
+ (element: PackageableElement): string | undefined => {
158
+ if (element instanceof DataSpace) {
159
+ return DATA_SPACE_ELEMENT_TYPE;
160
+ }
161
+ return undefined;
162
+ },
163
+ ];
164
+ }
165
+
166
+ getExtraElementIconGetters(): ElementIconGetter[] {
167
+ return [
168
+ (type: string): React.ReactNode | undefined => {
169
+ if (type === DATA_SPACE_ELEMENT_TYPE) {
170
+ return <DataSpaceIcon />;
171
+ }
172
+ return undefined;
173
+ },
174
+ ];
175
+ }
176
+
177
+ getExtraNewElementFromStateCreators(): NewElementFromStateCreator[] {
178
+ return [
179
+ (
180
+ type: string,
181
+ name: string,
182
+ state: NewElementState,
183
+ ): PackageableElement | undefined => {
184
+ if (type === DATA_SPACE_ELEMENT_TYPE) {
185
+ const dataSpace = new DataSpace(name);
186
+ const dataSpaceExecutionContext = new DataSpaceExecutionContext();
187
+ dataSpaceExecutionContext.name = 'dummyContext';
188
+ dataSpaceExecutionContext.mapping =
189
+ PackageableElementExplicitReference.create(stub_Mapping());
190
+ dataSpaceExecutionContext.defaultRuntime =
191
+ PackageableElementExplicitReference.create(
192
+ stub_PackageableRuntime(),
193
+ );
194
+ dataSpace.executionContexts = [dataSpaceExecutionContext];
195
+ dataSpace.defaultExecutionContext = dataSpaceExecutionContext;
196
+ return dataSpace;
197
+ }
198
+ return undefined;
199
+ },
200
+ ];
201
+ }
202
+
203
+ getExtraElementEditorStateCreators(): ElementEditorStateCreator[] {
204
+ return [
205
+ (
206
+ editorStore: EditorStore,
207
+ element: PackageableElement,
208
+ ): ElementEditorState | undefined => {
209
+ if (element instanceof DataSpace) {
210
+ return new UnsupportedElementEditorState(editorStore, element);
211
+ }
212
+ return undefined;
213
+ },
214
+ ];
215
+ }
216
+
217
+ getExtraDragElementClassifiers(): DragElementClassifier[] {
218
+ return [
219
+ (element: PackageableElement): string | undefined => {
220
+ if (element instanceof DataSpace) {
221
+ return DATA_SPACE_ELEMENT_PROJECT_EXPLORER_DND_TYPE;
222
+ }
223
+ return undefined;
224
+ },
225
+ ];
226
+ }
227
+
228
+ getExtraPureGrammarTextEditorDragElementTypes(): string[] {
229
+ return [DATA_SPACE_ELEMENT_PROJECT_EXPLORER_DND_TYPE];
230
+ }
231
+
232
+ getExtraPureGrammarParserElementDocumentationGetters(): PureGrammarParserElementDocumentationGetter[] {
233
+ return [
234
+ (
235
+ editorStore: EditorStore,
236
+ parserKeyword: string,
237
+ elementKeyword: string,
238
+ ): DocumentationEntry | undefined => {
239
+ if (parserKeyword === PURE_GRAMMAR_DATA_SPACE_PARSER_NAME) {
240
+ if (elementKeyword === PURE_GRAMMAR_DATA_SPACE_ELEMENT_TYPE_LABEL) {
241
+ return editorStore.applicationStore.documentationService.getDocEntry(
242
+ DSL_DATA_SPACE_LEGEND_STUDIO_DOCUMENTATION_KEY.CONCEPT_ELEMENT_DATA_SPACE,
243
+ );
244
+ }
245
+ }
246
+ return undefined;
247
+ },
248
+ ];
249
+ }
250
+
251
+ getExtraPureGrammarParserDocumentationGetters(): PureGrammarParserDocumentationGetter[] {
252
+ return [
253
+ (
254
+ editorStore: EditorStore,
255
+ parserKeyword: string,
256
+ ): DocumentationEntry | undefined => {
257
+ if (parserKeyword === PURE_GRAMMAR_DATA_SPACE_PARSER_NAME) {
258
+ return editorStore.applicationStore.documentationService.getDocEntry(
259
+ DSL_DATA_SPACE_LEGEND_STUDIO_DOCUMENTATION_KEY.GRAMMAR_PARSER,
260
+ );
261
+ }
262
+ return undefined;
263
+ },
264
+ ];
265
+ }
266
+
267
+ getExtraPureGrammarParserKeywordSuggestionGetters(): PureGrammarParserKeywordSuggestionGetter[] {
268
+ return [
269
+ (editorStore: EditorStore): PureGrammarTextSuggestion[] => [
270
+ {
271
+ text: PURE_GRAMMAR_DATA_SPACE_PARSER_NAME,
272
+ description: `(dsl)`,
273
+ documentation:
274
+ editorStore.applicationStore.documentationService.getDocEntry(
275
+ DSL_DATA_SPACE_LEGEND_STUDIO_DOCUMENTATION_KEY.GRAMMAR_PARSER,
276
+ ),
277
+ insertText: PURE_GRAMMAR_DATA_SPACE_PARSER_NAME,
278
+ },
279
+ ],
280
+ ];
281
+ }
282
+
283
+ getExtraPureGrammarParserElementSnippetSuggestionsGetters(): PureGrammarParserElementSnippetSuggestionsGetter[] {
284
+ return [
285
+ (
286
+ editorStore: EditorStore,
287
+ parserKeyword: string,
288
+ ): PureGrammarTextSuggestion[] | undefined =>
289
+ parserKeyword === PURE_GRAMMAR_DATA_SPACE_PARSER_NAME
290
+ ? [
291
+ {
292
+ text: PURE_GRAMMAR_DATA_SPACE_ELEMENT_TYPE_LABEL,
293
+ insertText: SIMPLE_DATA_SPACE_SNIPPET,
294
+ },
295
+ ]
296
+ : undefined,
297
+ ];
298
+ }
299
+ }
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { useApplicationStore } from '@finos/legend-application';
18
+ import {
19
+ MenuContentItem,
20
+ BlankPanelContent,
21
+ TimesCircleIcon,
22
+ PanelLoadingIndicator,
23
+ Dialog,
24
+ TimesIcon,
25
+ Modal,
26
+ ModalHeader,
27
+ ModalTitle,
28
+ ModalHeaderActions,
29
+ } from '@finos/legend-art';
30
+ import { flowResult } from 'mobx';
31
+ import { observer } from 'mobx-react-lite';
32
+ import { useEditorStore } from '@finos/legend-application-studio';
33
+ import type { DataSpace } from '@finos/legend-extension-dsl-data-space/graph';
34
+ import { DataSpacePreviewState } from '../stores/DataSpacePreviewState.js';
35
+ import { DataSpaceViewer } from '@finos/legend-extension-dsl-data-space/application';
36
+
37
+ export const DataSpacePreviewAction = observer(
38
+ (props: { dataSpace: DataSpace }) => {
39
+ const { dataSpace } = props;
40
+ const editorStore = useEditorStore();
41
+ const applicationStore = useApplicationStore();
42
+ const dataSpacePreviewState =
43
+ DataSpacePreviewState.retrieveNullableState(editorStore);
44
+ if (!dataSpacePreviewState) {
45
+ return null;
46
+ }
47
+
48
+ const previewDataSpace = (): void => {
49
+ flowResult(dataSpacePreviewState.previewDataSpace(dataSpace)).catch(
50
+ applicationStore.alertUnhandledError,
51
+ );
52
+ };
53
+
54
+ return (
55
+ <MenuContentItem onClick={previewDataSpace}>Preview</MenuContentItem>
56
+ );
57
+ },
58
+ );
59
+
60
+ export const DataSpacePreviewDialog = observer(() => {
61
+ const editorStore = useEditorStore();
62
+ const applicationStore = editorStore.applicationStore;
63
+ const dataSpacePreviewState =
64
+ DataSpacePreviewState.retrieveNullableState(editorStore);
65
+ if (!dataSpacePreviewState) {
66
+ return null;
67
+ }
68
+
69
+ const onClose = (): void => {
70
+ dataSpacePreviewState.setDataSpace(undefined);
71
+ };
72
+
73
+ return (
74
+ <Dialog
75
+ open={Boolean(dataSpacePreviewState.dataSpace)}
76
+ onClose={onClose}
77
+ classes={{
78
+ root: 'editor-modal__root-container',
79
+ container: 'editor-modal__container',
80
+ paper:
81
+ 'editor-modal__content data-space-preview__dialog__container__content',
82
+ }}
83
+ >
84
+ <Modal
85
+ darkMode={
86
+ !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
87
+ }
88
+ className="editor-modal data-space-preview__dialog"
89
+ >
90
+ <ModalHeader className="data-space-preview__dialog__header">
91
+ <ModalTitle title="Preview Data Space" />
92
+ <ModalHeaderActions>
93
+ <button
94
+ className="modal__header__action"
95
+ title="Close"
96
+ onClick={onClose}
97
+ >
98
+ <TimesIcon />
99
+ </button>
100
+ </ModalHeaderActions>
101
+ </ModalHeader>
102
+ <div className="data-space-preview__dialog__content">
103
+ <PanelLoadingIndicator
104
+ isLoading={dataSpacePreviewState.loadDataSpaceState.isInProgress}
105
+ />
106
+ {dataSpacePreviewState.dataSpaceViewerState && (
107
+ <DataSpaceViewer
108
+ dataSpaceViewerState={dataSpacePreviewState.dataSpaceViewerState}
109
+ />
110
+ )}
111
+ {!dataSpacePreviewState.dataSpaceViewerState && (
112
+ <>
113
+ {dataSpacePreviewState.loadDataSpaceState.isInProgress && (
114
+ <BlankPanelContent>
115
+ {dataSpacePreviewState.loadDataSpaceState.message}
116
+ </BlankPanelContent>
117
+ )}
118
+ {dataSpacePreviewState.loadDataSpaceState.hasFailed && (
119
+ <BlankPanelContent>
120
+ <div className="data-space-preview__dialog__content--failed">
121
+ <div className="data-space-preview__dialog__content--failed__icon">
122
+ <TimesCircleIcon />
123
+ </div>
124
+ <div className="data-space-preview__dialog__content--failed__text">
125
+ {`Can't load data space`}
126
+ </div>
127
+ </div>
128
+ </BlankPanelContent>
129
+ )}
130
+ </>
131
+ )}
132
+ </div>
133
+ </Modal>
134
+ </Dialog>
135
+ );
136
+ });
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { MenuContentItem } from '@finos/legend-art';
18
+ import { observer } from 'mobx-react-lite';
19
+ import {
20
+ type EditorStore,
21
+ useEditorStore,
22
+ } from '@finos/legend-application-studio';
23
+ import { flowResult } from 'mobx';
24
+ import { guaranteeType } from '@finos/legend-shared';
25
+ import { DataSpace } from '@finos/legend-extension-dsl-data-space/graph';
26
+ import {
27
+ DataSpaceQueryBuilderState,
28
+ type DataSpaceInfo,
29
+ } from '@finos/legend-extension-dsl-data-space/application';
30
+
31
+ export const queryDataSpace = async (
32
+ dataSpace: DataSpace,
33
+ editorStore: EditorStore,
34
+ ): Promise<void> => {
35
+ const embeddedQueryBuilderState = editorStore.embeddedQueryBuilderState;
36
+ await flowResult(
37
+ embeddedQueryBuilderState.setEmbeddedQueryBuilderConfiguration({
38
+ setupQueryBuilderState: () => {
39
+ const sourceInfo = Object.assign(
40
+ {},
41
+ editorStore.editorMode.getSourceInfo(),
42
+ {
43
+ dataSpace: dataSpace.path,
44
+ },
45
+ );
46
+ const queryBuilderState = new DataSpaceQueryBuilderState(
47
+ editorStore.applicationStore,
48
+ editorStore.graphManagerState,
49
+ editorStore.depotServerClient,
50
+ dataSpace,
51
+ dataSpace.defaultExecutionContext,
52
+ (dataSpaceInfo: DataSpaceInfo) => {
53
+ queryBuilderState.dataSpace = guaranteeType(
54
+ queryBuilderState.graphManagerState.graph.getElement(
55
+ dataSpaceInfo.path,
56
+ ),
57
+ DataSpace,
58
+ );
59
+ queryBuilderState.setExecutionContext(
60
+ queryBuilderState.dataSpace.defaultExecutionContext,
61
+ );
62
+ queryBuilderState.propagateExecutionContextChange(
63
+ queryBuilderState.dataSpace.defaultExecutionContext,
64
+ );
65
+ },
66
+ false,
67
+ undefined,
68
+ undefined,
69
+ undefined,
70
+ undefined,
71
+ undefined,
72
+ editorStore.applicationStore.config.options.queryBuilderConfig,
73
+ sourceInfo,
74
+ );
75
+ queryBuilderState.setExecutionContext(
76
+ dataSpace.defaultExecutionContext,
77
+ );
78
+ queryBuilderState.propagateExecutionContextChange(
79
+ dataSpace.defaultExecutionContext,
80
+ );
81
+ return queryBuilderState;
82
+ },
83
+ actionConfigs: [],
84
+ disableCompile: true,
85
+ }),
86
+ );
87
+ };
88
+
89
+ export const DataSpaceQueryAction = observer(
90
+ (props: { dataSpace: DataSpace }) => {
91
+ const { dataSpace } = props;
92
+ const editorStore = useEditorStore();
93
+ const buildQuery = editorStore.applicationStore.guardUnhandledError(
94
+ async () => {
95
+ await queryDataSpace(dataSpace, editorStore);
96
+ },
97
+ );
98
+ return <MenuContentItem onClick={buildQuery}>Query...</MenuContentItem>;
99
+ },
100
+ );