@finos/legend-extension-dsl-data-space 10.2.0 → 10.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. package/lib/__lib__/query/DSL_DataSpace_LegendQueryNavigation.d.ts +18 -6
  2. package/lib/__lib__/query/DSL_DataSpace_LegendQueryNavigation.d.ts.map +1 -1
  3. package/lib/__lib__/query/DSL_DataSpace_LegendQueryNavigation.js +18 -6
  4. package/lib/__lib__/query/DSL_DataSpace_LegendQueryNavigation.js.map +1 -1
  5. package/lib/components/DSL_DataSpace_LegendApplicationPlugin.d.ts.map +1 -1
  6. package/lib/components/DSL_DataSpace_LegendApplicationPlugin.js +1 -0
  7. package/lib/components/DSL_DataSpace_LegendApplicationPlugin.js.map +1 -1
  8. package/lib/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.d.ts +4 -1
  9. package/lib/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.d.ts.map +1 -1
  10. package/lib/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.js +55 -5
  11. package/lib/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.js.map +1 -1
  12. package/lib/components/query/DSL_DataSpace_LegendQueryDocumentation.d.ts +19 -0
  13. package/lib/components/query/DSL_DataSpace_LegendQueryDocumentation.d.ts.map +1 -0
  14. package/lib/components/query/DSL_DataSpace_LegendQueryDocumentation.js +20 -0
  15. package/lib/components/query/DSL_DataSpace_LegendQueryDocumentation.js.map +1 -0
  16. package/lib/components/query/DataSpaceQueryBuilderTemplateQueryPanelContent.d.ts.map +1 -1
  17. package/lib/components/query/DataSpaceQueryBuilderTemplateQueryPanelContent.js +4 -2
  18. package/lib/components/query/DataSpaceQueryBuilderTemplateQueryPanelContent.js.map +1 -1
  19. package/lib/components/query/DataSpaceTemplateQueryCreator.js +4 -4
  20. package/lib/components/query/DataSpaceTemplateQueryCreator.js.map +1 -1
  21. package/lib/components/studio/DSL_DataSpace_LegendStudioApplicationPlugin.d.ts +2 -0
  22. package/lib/components/studio/DSL_DataSpace_LegendStudioApplicationPlugin.d.ts.map +1 -1
  23. package/lib/components/studio/DSL_DataSpace_LegendStudioApplicationPlugin.js +13 -0
  24. package/lib/components/studio/DSL_DataSpace_LegendStudioApplicationPlugin.js.map +1 -1
  25. package/lib/components/studio/DataSpaceTemplateQueryPromoteReview.d.ts +19 -0
  26. package/lib/components/studio/DataSpaceTemplateQueryPromoteReview.d.ts.map +1 -0
  27. package/lib/components/studio/DataSpaceTemplateQueryPromoteReview.js +81 -0
  28. package/lib/components/studio/DataSpaceTemplateQueryPromoteReview.js.map +1 -0
  29. package/lib/graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.d.ts +1 -0
  30. package/lib/graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.d.ts.map +1 -1
  31. package/lib/graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.js +2 -0
  32. package/lib/graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.js.map +1 -1
  33. package/lib/graph-manager/action/analytics/DataSpaceAnalysis.d.ts +1 -0
  34. package/lib/graph-manager/action/analytics/DataSpaceAnalysis.d.ts.map +1 -1
  35. package/lib/graph-manager/action/analytics/DataSpaceAnalysis.js +1 -0
  36. package/lib/graph-manager/action/analytics/DataSpaceAnalysis.js.map +1 -1
  37. package/lib/graph-manager/protocol/pure/DSL_DataSpace_PureGraphManagerExtension.d.ts +10 -1
  38. package/lib/graph-manager/protocol/pure/DSL_DataSpace_PureGraphManagerExtension.d.ts.map +1 -1
  39. package/lib/graph-manager/protocol/pure/DSL_DataSpace_PureGraphManagerExtension.js.map +1 -1
  40. package/lib/graph-manager/protocol/pure/DSL_DataSpace_PureProtocolProcessorPlugin.d.ts.map +1 -1
  41. package/lib/graph-manager/protocol/pure/DSL_DataSpace_PureProtocolProcessorPlugin.js +2 -0
  42. package/lib/graph-manager/protocol/pure/DSL_DataSpace_PureProtocolProcessorPlugin.js.map +1 -1
  43. package/lib/graph-manager/protocol/pure/v1/V1_DSL_DataSpace_PureGraphManagerExtension.d.ts +12 -1
  44. package/lib/graph-manager/protocol/pure/v1/V1_DSL_DataSpace_PureGraphManagerExtension.d.ts.map +1 -1
  45. package/lib/graph-manager/protocol/pure/v1/V1_DSL_DataSpace_PureGraphManagerExtension.js +28 -3
  46. package/lib/graph-manager/protocol/pure/v1/V1_DSL_DataSpace_PureGraphManagerExtension.js.map +1 -1
  47. package/lib/graph-manager/protocol/pure/v1/engine/analytics/V1_DataSpaceAnalysis.d.ts +1 -0
  48. package/lib/graph-manager/protocol/pure/v1/engine/analytics/V1_DataSpaceAnalysis.d.ts.map +1 -1
  49. package/lib/graph-manager/protocol/pure/v1/engine/analytics/V1_DataSpaceAnalysis.js +2 -0
  50. package/lib/graph-manager/protocol/pure/v1/engine/analytics/V1_DataSpaceAnalysis.js.map +1 -1
  51. package/lib/graph-manager/protocol/pure/v1/model/packageableElements/dataSpace/V1_DSL_DataSpace_DataSpace.d.ts +1 -0
  52. package/lib/graph-manager/protocol/pure/v1/model/packageableElements/dataSpace/V1_DSL_DataSpace_DataSpace.d.ts.map +1 -1
  53. package/lib/graph-manager/protocol/pure/v1/model/packageableElements/dataSpace/V1_DSL_DataSpace_DataSpace.js +2 -0
  54. package/lib/graph-manager/protocol/pure/v1/model/packageableElements/dataSpace/V1_DSL_DataSpace_DataSpace.js.map +1 -1
  55. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_DataSpace_ProtocolHelper.d.ts.map +1 -1
  56. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_DataSpace_ProtocolHelper.js +1 -0
  57. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_DataSpace_ProtocolHelper.js.map +1 -1
  58. package/lib/index.css +2 -2
  59. package/lib/index.css.map +1 -1
  60. package/lib/package.json +2 -1
  61. package/lib/stores/query/DataSpaceTemplateQueryCreatorStore.d.ts +3 -2
  62. package/lib/stores/query/DataSpaceTemplateQueryCreatorStore.d.ts.map +1 -1
  63. package/lib/stores/query/DataSpaceTemplateQueryCreatorStore.js +9 -13
  64. package/lib/stores/query/DataSpaceTemplateQueryCreatorStore.js.map +1 -1
  65. package/lib/stores/query/DataSpaceTemplateQueryPromotionReviewerStore.d.ts +61 -0
  66. package/lib/stores/query/DataSpaceTemplateQueryPromotionReviewerStore.d.ts.map +1 -0
  67. package/lib/stores/query/DataSpaceTemplateQueryPromotionReviewerStore.js +407 -0
  68. package/lib/stores/query/DataSpaceTemplateQueryPromotionReviewerStore.js.map +1 -0
  69. package/package.json +8 -7
  70. package/src/__lib__/query/DSL_DataSpace_LegendQueryNavigation.ts +43 -9
  71. package/src/components/DSL_DataSpace_LegendApplicationPlugin.tsx +1 -0
  72. package/src/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.tsx +117 -3
  73. package/src/components/query/DSL_DataSpace_LegendQueryDocumentation.ts +19 -0
  74. package/src/components/query/DataSpaceQueryBuilderTemplateQueryPanelContent.tsx +8 -1
  75. package/src/components/query/DataSpaceTemplateQueryCreator.tsx +6 -6
  76. package/src/components/studio/DSL_DataSpace_LegendStudioApplicationPlugin.tsx +18 -1
  77. package/src/components/studio/DataSpaceTemplateQueryPromoteReview.tsx +292 -0
  78. package/src/graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.ts +2 -0
  79. package/src/graph-manager/action/analytics/DataSpaceAnalysis.ts +1 -0
  80. package/src/graph-manager/protocol/pure/DSL_DataSpace_PureGraphManagerExtension.ts +15 -0
  81. package/src/graph-manager/protocol/pure/DSL_DataSpace_PureProtocolProcessorPlugin.ts +2 -0
  82. package/src/graph-manager/protocol/pure/v1/V1_DSL_DataSpace_PureGraphManagerExtension.ts +66 -2
  83. package/src/graph-manager/protocol/pure/v1/engine/analytics/V1_DataSpaceAnalysis.ts +2 -0
  84. package/src/graph-manager/protocol/pure/v1/model/packageableElements/dataSpace/V1_DSL_DataSpace_DataSpace.ts +2 -0
  85. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_DataSpace_ProtocolHelper.ts +1 -0
  86. package/src/stores/query/DataSpaceTemplateQueryCreatorStore.ts +12 -24
  87. package/src/stores/query/DataSpaceTemplateQueryPromotionReviewerStore.ts +636 -0
  88. package/tsconfig.json +3 -0
@@ -16,15 +16,17 @@
16
16
 
17
17
  import packageJson from '../../../package.json' assert { type: 'json' };
18
18
  import {
19
- type QuerySetupActionConfiguration,
20
19
  type ExistingQueryEditorStateBuilder,
21
- type ExistingQueryEditorStore,
20
+ type QueryEditorStore,
21
+ type QuerySetupActionConfiguration,
22
+ ExistingQueryEditorStore,
22
23
  LegendQueryApplicationPlugin,
23
24
  LEGEND_QUERY_APP_EVENT,
24
25
  createViewProjectHandler,
25
26
  createViewSDLCProjectHandler,
27
+ type QueryEditorActionConfiguration,
26
28
  } from '@finos/legend-application-query';
27
- import { SquareIcon } from '@finos/legend-art';
29
+ import { ArrowCircleUpIcon, SquareIcon } from '@finos/legend-art';
28
30
  import {
29
31
  ActionAlertActionType,
30
32
  ActionAlertType,
@@ -34,6 +36,7 @@ import {
34
36
  DATA_SPACE_QUERY_ROUTE_PATTERN,
35
37
  generateDataSpaceQueryCreatorRoute,
36
38
  generateDataSpaceQuerySetupRoute,
39
+ generateDataSpaceTemplateQueryPromotionRoute,
37
40
  } from '../../__lib__/query/DSL_DataSpace_LegendQueryNavigation.js';
38
41
  import { DataSpaceQueryCreator } from './DataSpaceQueryCreator.js';
39
42
  import {
@@ -54,6 +57,7 @@ import type { DataSpaceInfo } from '../../stores/query/DataSpaceInfo.js';
54
57
  import { getOwnDataSpace } from '../../graph-manager/DSL_DataSpace_GraphManagerHelper.js';
55
58
  import {
56
59
  assertErrorThrown,
60
+ buildUrl,
57
61
  guaranteeNonNullable,
58
62
  LogEvent,
59
63
  } from '@finos/legend-shared';
@@ -71,6 +75,8 @@ import type {
71
75
  DataSpaceExecutionContext,
72
76
  } from '../../graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.js';
73
77
  import { DataSpaceTemplateQueryCreator } from './DataSpaceTemplateQueryCreator.js';
78
+ import { DataSpaceTemplateQueryCreatorStore } from '../../stores/query/DataSpaceTemplateQueryCreatorStore.js';
79
+ import { parseProjectIdentifier } from '@finos/legend-storage';
74
80
 
75
81
  const resolveExecutionContext = (
76
82
  dataSpace: DataSpace,
@@ -305,4 +311,112 @@ export class DSL_DataSpace_LegendQueryApplicationPlugin extends LegendQueryAppli
305
311
  },
306
312
  ];
307
313
  }
314
+
315
+ override getExtraQueryHeaders(): ((
316
+ editorStore: QueryEditorStore,
317
+ ) => React.ReactNode | undefined)[] {
318
+ return [
319
+ (editorStore: QueryEditorStore): React.ReactNode | undefined => {
320
+ if (editorStore instanceof DataSpaceTemplateQueryCreatorStore) {
321
+ return (
322
+ <div className="query-editor__dataspace__header">
323
+ <div className="query-editor__header__content__main query-editor__header__content__title__text query-editor__dataspace__header__title__text">
324
+ {editorStore.templateQueryTitle}
325
+ </div>
326
+ <div className="query-editor__dataspace__header__title__tag">
327
+ template
328
+ </div>
329
+ </div>
330
+ );
331
+ }
332
+ return undefined;
333
+ },
334
+ ];
335
+ }
336
+
337
+ override getExtraQueryEditorActionConfigurations(): QueryEditorActionConfiguration[] {
338
+ return [
339
+ {
340
+ key: 'promote-as-curated-template-query',
341
+ renderer: (editorStore, queryBuilderState) => {
342
+ const proceedCuratedTemplateQueryPromotion =
343
+ async (): Promise<void> => {
344
+ if (
345
+ !(
346
+ editorStore instanceof ExistingQueryEditorStore &&
347
+ queryBuilderState instanceof DataSpaceQueryBuilderState
348
+ )
349
+ ) {
350
+ return;
351
+ }
352
+ // fetch project data
353
+ const project = StoreProjectData.serialization.fromJson(
354
+ await editorStore.depotServerClient.getProject(
355
+ editorStore.lightQuery.groupId,
356
+ editorStore.lightQuery.artifactId,
357
+ ),
358
+ );
359
+
360
+ // find the matching SDLC instance
361
+ const projectIDPrefix = parseProjectIdentifier(
362
+ project.projectId,
363
+ ).prefix;
364
+ const matchingSDLCEntry =
365
+ editorStore.applicationStore.config.studioInstances.find(
366
+ (entry) => entry.sdlcProjectIDPrefix === projectIDPrefix,
367
+ );
368
+ if (matchingSDLCEntry) {
369
+ editorStore.applicationStore.navigationService.navigator.visitAddress(
370
+ buildUrl([
371
+ editorStore.applicationStore.config.studioApplicationUrl,
372
+ generateDataSpaceTemplateQueryPromotionRoute(
373
+ editorStore.lightQuery.groupId,
374
+ editorStore.lightQuery.artifactId,
375
+ editorStore.lightQuery.versionId,
376
+ queryBuilderState.dataSpace.path,
377
+ editorStore.lightQuery.id,
378
+ ),
379
+ ]),
380
+ );
381
+ } else {
382
+ editorStore.applicationStore.notificationService.notifyWarning(
383
+ `Can't find the corresponding SDLC instance to productionize the query`,
384
+ );
385
+ }
386
+ };
387
+
388
+ const proceed = (): void => {
389
+ queryBuilderState.changeDetectionState.alertUnsavedChanges(() => {
390
+ proceedCuratedTemplateQueryPromotion().catch(
391
+ editorStore.applicationStore.alertUnhandledError,
392
+ );
393
+ });
394
+ };
395
+
396
+ return (
397
+ <>
398
+ {editorStore instanceof ExistingQueryEditorStore &&
399
+ queryBuilderState instanceof DataSpaceQueryBuilderState && (
400
+ <button
401
+ className="query-editor__header__action btn--dark"
402
+ tabIndex={-1}
403
+ onClick={proceed}
404
+ title={
405
+ !(editorStore instanceof ExistingQueryEditorStore)
406
+ ? 'Please save your query first before promoting'
407
+ : 'Promote Curated Template query...'
408
+ }
409
+ >
410
+ <ArrowCircleUpIcon className="query-editor__header__action__icon--productionize" />
411
+ <div className="query-editor__header__action__label">
412
+ Promote as Template Query
413
+ </div>
414
+ </button>
415
+ )}
416
+ </>
417
+ );
418
+ },
419
+ },
420
+ ];
421
+ }
308
422
  }
@@ -0,0 +1,19 @@
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
+ export enum DSL_DATASPACE_LEGEND_QUERY_DOCUMENTATION_KEY {
18
+ CURATED_TEMPLATE_QUERY = 'dsl-dataspace.curated-template-query',
19
+ }
@@ -32,6 +32,8 @@ import {
32
32
  useApplicationStore,
33
33
  } from '@finos/legend-application';
34
34
  import { generateDataSpaceTemplateQueryCreatorRoute } from '../../__lib__/query/DSL_DataSpace_LegendQueryNavigation.js';
35
+ import { DocumentationLink } from '@finos/legend-lego/application';
36
+ import { DSL_DATASPACE_LEGEND_QUERY_DOCUMENTATION_KEY } from './DSL_DataSpace_LegendQueryDocumentation.js';
35
37
 
36
38
  const DataSpaceTemplateQueryDialog = observer(
37
39
  (props: {
@@ -100,7 +102,7 @@ const DataSpaceTemplateQueryDialog = observer(
100
102
  queryBuilderState.projectInfo.artifactId,
101
103
  queryBuilderState.projectInfo.versionId,
102
104
  queryBuilderState.dataSpace.path,
103
- template.title,
105
+ template.id,
104
106
  ),
105
107
  ),
106
108
  );
@@ -132,6 +134,11 @@ const DataSpaceTemplateQueryDialog = observer(
132
134
  <div className="query-builder__data-space__template-query-panel">
133
135
  <div className="query-builder__data-space__template-query-panel__header">
134
136
  Curated Template Queries
137
+ <DocumentationLink
138
+ documentationKey={
139
+ DSL_DATASPACE_LEGEND_QUERY_DOCUMENTATION_KEY.CURATED_TEMPLATE_QUERY
140
+ }
141
+ />
135
142
  </div>
136
143
  {templateQueries.map((query) => (
137
144
  <div
@@ -33,8 +33,8 @@ const DataSpaceTemplateQueryCreatorStoreProvider: React.FC<{
33
33
  children: React.ReactNode;
34
34
  gav: string;
35
35
  dataSpacePath: string;
36
- templateQueryTitle: string;
37
- }> = ({ children, gav, dataSpacePath, templateQueryTitle }) => {
36
+ templateQueryId: string;
37
+ }> = ({ children, gav, dataSpacePath, templateQueryId }) => {
38
38
  const { groupId, artifactId, versionId } = parseGAVCoordinates(gav);
39
39
  const applicationStore = useLegendQueryApplicationStore();
40
40
  const baseStore = useLegendQueryBaseStore();
@@ -47,7 +47,7 @@ const DataSpaceTemplateQueryCreatorStoreProvider: React.FC<{
47
47
  artifactId,
48
48
  versionId,
49
49
  dataSpacePath,
50
- templateQueryTitle,
50
+ templateQueryId,
51
51
  ),
52
52
  );
53
53
  return (
@@ -65,16 +65,16 @@ export const DataSpaceTemplateQueryCreator = observer(() => {
65
65
  parameters[
66
66
  DATA_SPACE_TEMPLATE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.DATA_SPACE_PATH
67
67
  ];
68
- const templateQueryTitle =
68
+ const templateQueryId =
69
69
  parameters[
70
- DATA_SPACE_TEMPLATE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.TEMPLATE_QUERY_TITLE
70
+ DATA_SPACE_TEMPLATE_QUERY_CREATOR_ROUTE_PATTERN_TOKEN.TEMPLATE_QUERY_ID
71
71
  ];
72
72
 
73
73
  return (
74
74
  <DataSpaceTemplateQueryCreatorStoreProvider
75
75
  gav={gav}
76
76
  dataSpacePath={dataSpacePath}
77
- templateQueryTitle={templateQueryTitle}
77
+ templateQueryId={templateQueryId}
78
78
  >
79
79
  <QueryEditor />
80
80
  </DataSpaceTemplateQueryCreatorStoreProvider>
@@ -48,7 +48,10 @@ import {
48
48
  } from '../../graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.js';
49
49
  import { DSL_DATA_SPACE_LEGEND_STUDIO_DOCUMENTATION_KEY } from '../../__lib__/studio/DSL_DataSpace_LegendStudioDocumentation.js';
50
50
  import { SIMPLE_DATA_SPACE_SNIPPET } from '../../__lib__/studio/DSL_DataSpace_LegendStudioCodeSnippet.js';
51
- import type { DocumentationEntry } from '@finos/legend-application';
51
+ import type {
52
+ ApplicationPageEntry,
53
+ DocumentationEntry,
54
+ } from '@finos/legend-application';
52
55
  import { DataSpaceIcon } from '../DSL_DataSpace_Icon.js';
53
56
  import { DataSpacePreviewState } from '../../stores/studio/DataSpacePreviewState.js';
54
57
  import {
@@ -57,6 +60,8 @@ import {
57
60
  } from './DataSpacePreviewAction.js';
58
61
  import type { PureGrammarTextSuggestion } from '@finos/legend-lego/code-editor';
59
62
  import { DataSpaceQueryAction } from './DataSpaceQueryAction.js';
63
+ import { DataSpaceTemplateQueryPromotionReviewer } from './DataSpaceTemplateQueryPromoteReview.js';
64
+ import { DATA_SPACE_QUERY_ROUTE_PATTERN } from '../../__lib__/query/DSL_DataSpace_LegendQueryNavigation.js';
60
65
 
61
66
  const DATA_SPACE_ELEMENT_TYPE = 'DATA SPACE';
62
67
  const DATA_SPACE_ELEMENT_PROJECT_EXPLORER_DND_TYPE =
@@ -80,6 +85,18 @@ export class DSL_DataSpace_LegendStudioApplicationPlugin
80
85
  ];
81
86
  }
82
87
 
88
+ override getExtraApplicationPageEntries(): ApplicationPageEntry[] {
89
+ return [
90
+ {
91
+ key: 'promote-as-curated-template-query-page',
92
+ addressPatterns: [
93
+ DATA_SPACE_QUERY_ROUTE_PATTERN.PROMOTE_TEMPLATE_QUERY,
94
+ ],
95
+ renderer: DataSpaceTemplateQueryPromotionReviewer,
96
+ },
97
+ ];
98
+ }
99
+
83
100
  override getExtraExplorerContextMenuItemRendererConfigurations(): ExplorerContextMenuItemRendererConfiguration[] {
84
101
  return [
85
102
  {
@@ -0,0 +1,292 @@
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 { BlankPanelContent, GitBranchIcon, clsx } from '@finos/legend-art';
18
+ import { observer, useLocalObservable } from 'mobx-react-lite';
19
+ import { useApplicationStore } from '@finos/legend-application';
20
+ import { DataSpaceTemplateQueryPromotionReviewerStore } from '../../stores/query/DataSpaceTemplateQueryPromotionReviewerStore.js';
21
+ import {
22
+ DATA_SPACE_TEMPLATE_QUERY_PROMOTION_ROUTE_PATTERN_TOKEN,
23
+ type DataSpaceTemplateQueryPromotionReviewerPathParams,
24
+ } from '../../__lib__/query/DSL_DataSpace_LegendQueryNavigation.js';
25
+ import { useParams } from '@finos/legend-application/browser';
26
+ import {
27
+ ActivityBarMenu,
28
+ LEGEND_STUDIO_TEST_ID,
29
+ useLegendStudioApplicationStore,
30
+ useLegendStudioBaseStore,
31
+ } from '@finos/legend-application-studio';
32
+ import { createContext, useContext } from 'react';
33
+ import { guaranteeNonNullable } from '@finos/legend-shared';
34
+ import { flowResult } from 'mobx';
35
+ import { DocumentationLink } from '@finos/legend-lego/application';
36
+ import { DSL_DATASPACE_LEGEND_QUERY_DOCUMENTATION_KEY } from '../query/DSL_DataSpace_LegendQueryDocumentation.js';
37
+
38
+ const TemplateQueryPromotionReviewerStoreContext = createContext<
39
+ DataSpaceTemplateQueryPromotionReviewerStore | undefined
40
+ >(undefined);
41
+
42
+ const DataSpaceTemplateQueryPromotionReviewerStoreProvider: React.FC<{
43
+ children: React.ReactNode;
44
+ dataSpacePath: string;
45
+ queryId: string;
46
+ }> = ({ children, dataSpacePath, queryId }) => {
47
+ const applicationStore = useLegendStudioApplicationStore();
48
+ const baseStore = useLegendStudioBaseStore();
49
+ const store = useLocalObservable(
50
+ () =>
51
+ new DataSpaceTemplateQueryPromotionReviewerStore(
52
+ applicationStore,
53
+ baseStore.sdlcServerClient,
54
+ baseStore.depotServerClient,
55
+ ),
56
+ );
57
+ store.initialize(queryId, dataSpacePath);
58
+ return (
59
+ <TemplateQueryPromotionReviewerStoreContext.Provider value={store}>
60
+ {children}
61
+ </TemplateQueryPromotionReviewerStoreContext.Provider>
62
+ );
63
+ };
64
+
65
+ const useTemplateQueryPromotionReviewerStore =
66
+ (): DataSpaceTemplateQueryPromotionReviewerStore =>
67
+ guaranteeNonNullable(
68
+ useContext(TemplateQueryPromotionReviewerStoreContext),
69
+ `Can't find query productionizer store in context`,
70
+ );
71
+
72
+ const TemplateQueryPromotionReviewerContent = observer(() => {
73
+ const applicationStore = useApplicationStore();
74
+ const queryPromotionReviewerStore = useTemplateQueryPromotionReviewerStore();
75
+ const isLoadingEditor = !queryPromotionReviewerStore.initState.hasCompleted;
76
+
77
+ // workspace name
78
+ const changeWorkspaceName: React.ChangeEventHandler<HTMLInputElement> = (
79
+ event,
80
+ ) => queryPromotionReviewerStore.setWorkspaceName(event.target.value);
81
+
82
+ // template query
83
+ const onChangeTemplateQueryId: React.ChangeEventHandler<HTMLInputElement> = (
84
+ event,
85
+ ) => queryPromotionReviewerStore.setTemplateQueryId(event.target.value);
86
+
87
+ const onChangeTemplateQueryTitle: React.ChangeEventHandler<
88
+ HTMLInputElement
89
+ > = (event) =>
90
+ queryPromotionReviewerStore.setTemplateQueryTitle(event.target.value);
91
+
92
+ const onChangeTemplateQueryDescription: React.ChangeEventHandler<
93
+ HTMLInputElement
94
+ > = (event) =>
95
+ queryPromotionReviewerStore.setTemplateQueryDescription(event.target.value);
96
+
97
+ // actions
98
+ const promoteTemplateQuery = (): void => {
99
+ flowResult(queryPromotionReviewerStore.promoteAsTemplateQuery()).catch(
100
+ applicationStore.alertUnhandledError,
101
+ );
102
+ };
103
+
104
+ return (
105
+ <div className="app__page">
106
+ {isLoadingEditor && (
107
+ <BlankPanelContent>
108
+ {queryPromotionReviewerStore.initState.message ??
109
+ queryPromotionReviewerStore.graphManagerState.systemBuildState
110
+ .message ??
111
+ queryPromotionReviewerStore.graphManagerState.dependenciesBuildState
112
+ .message ??
113
+ queryPromotionReviewerStore.graphManagerState.generationsBuildState
114
+ .message ??
115
+ queryPromotionReviewerStore.graphManagerState.graphBuildState
116
+ .message}
117
+ </BlankPanelContent>
118
+ )}
119
+ <div className="template-query-promotor">
120
+ <div className="template-query-promotor__body">
121
+ <div className="activity-bar">
122
+ <ActivityBarMenu />
123
+ </div>
124
+ <div
125
+ className="template-query-promotor__content"
126
+ data-testid={LEGEND_STUDIO_TEST_ID.SETUP__CONTENT}
127
+ >
128
+ <div className="template-query-promotor__content__main">
129
+ <div className="template-query-promotor__title">
130
+ Promote as Curated Template Query
131
+ <DocumentationLink
132
+ documentationKey={
133
+ DSL_DATASPACE_LEGEND_QUERY_DOCUMENTATION_KEY.CURATED_TEMPLATE_QUERY
134
+ }
135
+ />
136
+ </div>
137
+ <div className="template-query-promotor__title__prompt">
138
+ We will promote this query as a curated template query in
139
+ dataspace. This automated process will generate a code review
140
+ and workspace. Please get the generated code review reviewed and
141
+ approved.
142
+ </div>
143
+ <div className="template-query-promotor__group template-query-promotor__group--workspace">
144
+ <div className="template-query-promotor__group__header">
145
+ workspace
146
+ </div>
147
+ <div className="template-query-promotor__group__content">
148
+ <div className="template-query-promotor__input">
149
+ <div
150
+ className="template-query-promotor__input__icon"
151
+ title="workspace"
152
+ >
153
+ <GitBranchIcon className="template-query-promotor__input__icon--workspce" />
154
+ </div>
155
+ <div className="input-group template-query-promotor__input__input">
156
+ <input
157
+ className={clsx(
158
+ 'input input--dark input-group__input',
159
+ {
160
+ 'input-group__input--error':
161
+ !queryPromotionReviewerStore.isWorkspaceNameValid,
162
+ },
163
+ )}
164
+ spellCheck={false}
165
+ value={queryPromotionReviewerStore.workspaceName}
166
+ placeholder="Enter a name for your workspace"
167
+ onChange={changeWorkspaceName}
168
+ />
169
+ {!queryPromotionReviewerStore.isWorkspaceNameValid && (
170
+ <div className="input-group__error-message">
171
+ Workspace already existed
172
+ </div>
173
+ )}
174
+ </div>
175
+ </div>
176
+ </div>
177
+ </div>
178
+ <div className="template-query-promotor__group template-query-promotor__group--template">
179
+ <div className="template-query-promotor__group__header">
180
+ template query
181
+ </div>
182
+ <div className="template-query-promotor__group__content">
183
+ <div className="template-query-promotor__input">
184
+ <div className="template-query-promotor__input__label">
185
+ id
186
+ </div>
187
+ <div className="input-group template-query-promotor__input__input">
188
+ <input
189
+ className={clsx(
190
+ 'input input--dark input-group__input',
191
+ {
192
+ 'input-group__input--error':
193
+ !queryPromotionReviewerStore.isTemplateQueryIdValid,
194
+ },
195
+ )}
196
+ spellCheck={false}
197
+ placeholder="Create an id for your template query"
198
+ value={queryPromotionReviewerStore.templateQueryId}
199
+ onChange={onChangeTemplateQueryId}
200
+ />
201
+ {!queryPromotionReviewerStore.isTemplateQueryIdValid && (
202
+ <div className="input-group__error-message">
203
+ Invalid template query id
204
+ </div>
205
+ )}
206
+ </div>
207
+ </div>
208
+ <div className="template-query-promotor__input">
209
+ <div className="template-query-promotor__input__label">
210
+ title
211
+ </div>
212
+ <div className="input-group template-query-promotor__input__input">
213
+ <input
214
+ className="input input--dark input-group__input"
215
+ spellCheck={false}
216
+ placeholder="Create a title for your template query"
217
+ value={queryPromotionReviewerStore.templateQueryTitle}
218
+ onChange={onChangeTemplateQueryTitle}
219
+ />
220
+ </div>
221
+ </div>
222
+ <div className="template-query-promotor__input">
223
+ <div className="template-query-promotor__input__label">
224
+ description
225
+ </div>
226
+ <div className="input-group template-query-promotor__input__input">
227
+ <input
228
+ className="input input--dark input-group__input"
229
+ spellCheck={false}
230
+ placeholder="Add some descriptions for your template query"
231
+ value={
232
+ queryPromotionReviewerStore.templateQueryDescription
233
+ }
234
+ onChange={onChangeTemplateQueryDescription}
235
+ />
236
+ </div>
237
+ </div>
238
+ </div>
239
+ </div>
240
+ <div className="template-query-promotor__actions">
241
+ <button
242
+ className="template-query-promotor__next-btn btn--dark"
243
+ onClick={promoteTemplateQuery}
244
+ disabled={
245
+ queryPromotionReviewerStore.promoteState.isInProgress ||
246
+ !queryPromotionReviewerStore.currentQuery ||
247
+ !queryPromotionReviewerStore.currentQueryInfo ||
248
+ !queryPromotionReviewerStore.currentProject ||
249
+ !queryPromotionReviewerStore
250
+ .currentProjectConfigurationStatus?.isConfigured ||
251
+ !queryPromotionReviewerStore.workspaceName ||
252
+ !queryPromotionReviewerStore.templateQueryTitle ||
253
+ !queryPromotionReviewerStore.isWorkspaceNameValid ||
254
+ !queryPromotionReviewerStore.isTemplateQueryIdValid
255
+ }
256
+ >
257
+ Promote Query
258
+ </button>
259
+ </div>
260
+ </div>
261
+ </div>
262
+ </div>
263
+ <div
264
+ data-testid={LEGEND_STUDIO_TEST_ID.STATUS_BAR}
265
+ className="editor__status-bar"
266
+ />
267
+ </div>
268
+ </div>
269
+ );
270
+ });
271
+
272
+ export const DataSpaceTemplateQueryPromotionReviewer = observer(() => {
273
+ const parameters =
274
+ useParams<DataSpaceTemplateQueryPromotionReviewerPathParams>();
275
+ const dataSpacePath =
276
+ parameters[
277
+ DATA_SPACE_TEMPLATE_QUERY_PROMOTION_ROUTE_PATTERN_TOKEN.DATA_SPACE_PATH
278
+ ];
279
+ const queryId =
280
+ parameters[
281
+ DATA_SPACE_TEMPLATE_QUERY_PROMOTION_ROUTE_PATTERN_TOKEN.QUERY_ID
282
+ ];
283
+
284
+ return (
285
+ <DataSpaceTemplateQueryPromotionReviewerStoreProvider
286
+ dataSpacePath={dataSpacePath}
287
+ queryId={queryId}
288
+ >
289
+ <TemplateQueryPromotionReviewerContent />
290
+ </DataSpaceTemplateQueryPromotionReviewerStoreProvider>
291
+ );
292
+ });
@@ -100,12 +100,14 @@ export class DataSpaceExecutableTemplate
100
100
  extends DataSpaceExecutable
101
101
  implements Hashable
102
102
  {
103
+ id!: string;
103
104
  query!: RawLambda;
104
105
  executionContextKey?: string;
105
106
 
106
107
  override get hashCode(): string {
107
108
  return hashArray([
108
109
  DATA_SPACE_HASH_STRUCTURE.DATA_SPACE_TEMPLATE_EXECUTABLE,
110
+ this.id,
109
111
  this.title,
110
112
  this.description ?? '',
111
113
  this.query,
@@ -130,6 +130,7 @@ export abstract class DataSpaceExecutableInfo {
130
130
  }
131
131
 
132
132
  export class DataSpaceTemplateExecutableInfo extends DataSpaceExecutableInfo {
133
+ id!: string;
133
134
  executionContextKey!: string;
134
135
  }
135
136
 
@@ -16,6 +16,7 @@
16
16
 
17
17
  import {
18
18
  type AbstractPureGraphManager,
19
+ type RawLambda,
19
20
  AbstractPureGraphManagerExtension,
20
21
  } from '@finos/legend-graph';
21
22
  import type { Entity } from '@finos/legend-storage';
@@ -38,6 +39,20 @@ export abstract class DSL_DataSpace_PureGraphManagerExtension extends AbstractPu
38
39
  cacheRetriever: () => Promise<PlainObject<DataSpaceAnalysisResult>>,
39
40
  actionState?: ActionState,
40
41
  ): Promise<DataSpaceAnalysisResult | undefined>;
42
+
43
+ abstract addNewExecutableToDataSpaceEntity(
44
+ dataSpaceEntity: Entity,
45
+ executable: {
46
+ id: string;
47
+ title: string;
48
+ mapping: string;
49
+ runtime: string;
50
+ query: RawLambda;
51
+ description?: string;
52
+ },
53
+ ): Promise<Entity>;
54
+
55
+ abstract IsTemplateQueryIdValid(dataSpaceEntity: Entity, id: string): boolean;
41
56
  }
42
57
 
43
58
  export const DSL_DataSpace_getGraphManagerExtension = (
@@ -229,6 +229,7 @@ export class DSL_DataSpace_PureProtocolProcessorPlugin
229
229
  executableProtocol instanceof V1_DataSpaceTemplateExecutable
230
230
  ) {
231
231
  const executable = new DataSpaceExecutableTemplate();
232
+ executable.id = executableProtocol.id;
232
233
  executable.title = executableProtocol.title;
233
234
  executable.description = executableProtocol.description;
234
235
  executable.query = V1_buildRawLambdaWithResolvedPaths(
@@ -418,6 +419,7 @@ export class DSL_DataSpace_PureProtocolProcessorPlugin
418
419
  protocol.executables = metamodel.executables?.map((executable) => {
419
420
  if (executable instanceof DataSpaceExecutableTemplate) {
420
421
  const executableProtocol = new V1_DataSpaceTemplateExecutable();
422
+ executableProtocol.id = executable.id;
421
423
  executableProtocol.title = executable.title;
422
424
  executableProtocol.description = executable.description;
423
425
  if (executable.executionContextKey) {