@finos/legend-extension-dsl-service 0.0.1

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.
Files changed (68) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +3 -0
  3. package/lib/components/studio/DSL_Service_LegendStudioApplicationPlugin.d.ts +22 -0
  4. package/lib/components/studio/DSL_Service_LegendStudioApplicationPlugin.d.ts.map +1 -0
  5. package/lib/components/studio/DSL_Service_LegendStudioApplicationPlugin.js +59 -0
  6. package/lib/components/studio/DSL_Service_LegendStudioApplicationPlugin.js.map +1 -0
  7. package/lib/components/studio/ServiceQueryEditor.d.ts +25 -0
  8. package/lib/components/studio/ServiceQueryEditor.d.ts.map +1 -0
  9. package/lib/components/studio/ServiceQueryEditor.js +190 -0
  10. package/lib/components/studio/ServiceQueryEditor.js.map +1 -0
  11. package/lib/components/studio/ServiceQueryEditorReviewAction.d.ts +19 -0
  12. package/lib/components/studio/ServiceQueryEditorReviewAction.d.ts.map +1 -0
  13. package/lib/components/studio/ServiceQueryEditorReviewAction.js +71 -0
  14. package/lib/components/studio/ServiceQueryEditorReviewAction.js.map +1 -0
  15. package/lib/components/studio/ServiceQueryEditorStoreProvider.d.ts +31 -0
  16. package/lib/components/studio/ServiceQueryEditorStoreProvider.d.ts.map +1 -0
  17. package/lib/components/studio/ServiceQueryEditorStoreProvider.js +40 -0
  18. package/lib/components/studio/ServiceQueryEditorStoreProvider.js.map +1 -0
  19. package/lib/components/studio/ServiceQueryEditorWorkspaceStatus.d.ts +19 -0
  20. package/lib/components/studio/ServiceQueryEditorWorkspaceStatus.d.ts.map +1 -0
  21. package/lib/components/studio/ServiceQueryEditorWorkspaceStatus.js +69 -0
  22. package/lib/components/studio/ServiceQueryEditorWorkspaceStatus.js.map +1 -0
  23. package/lib/components/studio/UpdateProjectServiceQuerySetup.d.ts +18 -0
  24. package/lib/components/studio/UpdateProjectServiceQuerySetup.d.ts.map +1 -0
  25. package/lib/components/studio/UpdateProjectServiceQuerySetup.js +182 -0
  26. package/lib/components/studio/UpdateProjectServiceQuerySetup.js.map +1 -0
  27. package/lib/components/studio/UpdateServiceQuerySetup.d.ts +18 -0
  28. package/lib/components/studio/UpdateServiceQuerySetup.d.ts.map +1 -0
  29. package/lib/components/studio/UpdateServiceQuerySetup.js +172 -0
  30. package/lib/components/studio/UpdateServiceQuerySetup.js.map +1 -0
  31. package/lib/index.css +17 -0
  32. package/lib/index.css.map +1 -0
  33. package/lib/index.d.ts +17 -0
  34. package/lib/index.d.ts.map +1 -0
  35. package/lib/index.js +17 -0
  36. package/lib/index.js.map +1 -0
  37. package/lib/package.json +84 -0
  38. package/lib/stores/studio/DSL_Service_LegendStudioRouter.d.ts +53 -0
  39. package/lib/stores/studio/DSL_Service_LegendStudioRouter.d.ts.map +1 -0
  40. package/lib/stores/studio/DSL_Service_LegendStudioRouter.js +62 -0
  41. package/lib/stores/studio/DSL_Service_LegendStudioRouter.js.map +1 -0
  42. package/lib/stores/studio/ServiceQueryEditorStore.d.ts +64 -0
  43. package/lib/stores/studio/ServiceQueryEditorStore.d.ts.map +1 -0
  44. package/lib/stores/studio/ServiceQueryEditorStore.js +260 -0
  45. package/lib/stores/studio/ServiceQueryEditorStore.js.map +1 -0
  46. package/lib/stores/studio/UpdateProjectServiceQuerySetupStore.d.ts +46 -0
  47. package/lib/stores/studio/UpdateProjectServiceQuerySetupStore.d.ts.map +1 -0
  48. package/lib/stores/studio/UpdateProjectServiceQuerySetupStore.js +184 -0
  49. package/lib/stores/studio/UpdateProjectServiceQuerySetupStore.js.map +1 -0
  50. package/lib/stores/studio/UpdateServiceQuerySetupStore.d.ts +48 -0
  51. package/lib/stores/studio/UpdateServiceQuerySetupStore.d.ts.map +1 -0
  52. package/lib/stores/studio/UpdateServiceQuerySetupStore.js +184 -0
  53. package/lib/stores/studio/UpdateServiceQuerySetupStore.js.map +1 -0
  54. package/package.json +84 -0
  55. package/src/components/studio/DSL_Service_LegendStudioApplicationPlugin.tsx +71 -0
  56. package/src/components/studio/ServiceQueryEditor.tsx +551 -0
  57. package/src/components/studio/ServiceQueryEditorReviewAction.tsx +172 -0
  58. package/src/components/studio/ServiceQueryEditorStoreProvider.tsx +89 -0
  59. package/src/components/studio/ServiceQueryEditorWorkspaceStatus.tsx +121 -0
  60. package/src/components/studio/UpdateProjectServiceQuerySetup.tsx +479 -0
  61. package/src/components/studio/UpdateServiceQuerySetup.tsx +476 -0
  62. package/src/index.ts +17 -0
  63. package/src/stores/studio/DSL_Service_LegendStudioRouter.ts +159 -0
  64. package/src/stores/studio/ServiceQueryEditorStore.ts +487 -0
  65. package/src/stores/studio/UpdateProjectServiceQuerySetupStore.ts +281 -0
  66. package/src/stores/studio/UpdateServiceQuerySetupStore.ts +314 -0
  67. package/tsconfig.json +58 -0
  68. package/tsconfig.package.json +38 -0
@@ -0,0 +1,172 @@
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 { generateReviewRoute } from '@finos/legend-application-studio';
19
+ import {
20
+ Dialog,
21
+ ExternalLinkSquareIcon,
22
+ Panel,
23
+ PanelLoadingIndicator,
24
+ ReviewIcon,
25
+ } from '@finos/legend-art';
26
+ import { flowResult } from 'mobx';
27
+ import { observer } from 'mobx-react-lite';
28
+ import { useRef, useState } from 'react';
29
+ import { useServiceQueryEditorStore } from './ServiceQueryEditorStoreProvider.js';
30
+
31
+ const NewReviewModal = observer(() => {
32
+ const editorStore = useServiceQueryEditorStore();
33
+ const applicationStore = useApplicationStore();
34
+ const messageInputRef = useRef<HTMLInputElement>(null);
35
+ const [message, setMessage] = useState<string>(
36
+ `Update query of service '${editorStore.service.path}'`,
37
+ );
38
+ const changeMessage: React.ChangeEventHandler<HTMLInputElement> = (event) =>
39
+ setMessage(event.target.value);
40
+
41
+ // actions
42
+ const handleEnter = (): void => messageInputRef.current?.focus();
43
+ const submitReview = (): void => {
44
+ if (message) {
45
+ flowResult(
46
+ editorStore.workspaceReviewState.createWorkspaceReview(message),
47
+ )
48
+ .then(() => editorStore.setShowSubmitReviewModal(false))
49
+ .catch(applicationStore.alertUnhandledError);
50
+ }
51
+ };
52
+ const onSubmit = (event: React.FormEvent<HTMLFormElement>): void => {
53
+ event.preventDefault();
54
+ submitReview();
55
+ };
56
+ const onClose = (): void => editorStore.setShowSubmitReviewModal(false);
57
+
58
+ return (
59
+ <Dialog
60
+ open={editorStore.showSubmitReviewModal}
61
+ onClose={onClose}
62
+ TransitionProps={{
63
+ onEnter: handleEnter,
64
+ }}
65
+ PaperProps={{
66
+ classes: {
67
+ root: 'search-modal__inner-container',
68
+ },
69
+ }}
70
+ >
71
+ <form onSubmit={onSubmit} className="modal search-modal modal--dark">
72
+ <div className="modal__title">Submit for Review</div>
73
+ <Panel>
74
+ <PanelLoadingIndicator
75
+ isLoading={
76
+ editorStore.workspaceReviewState.isCreatingWorkspaceReview
77
+ }
78
+ />
79
+ <div className="panel__content--full">
80
+ <div className="input-group">
81
+ <input
82
+ ref={messageInputRef}
83
+ className="input input--dark input-group__input"
84
+ value={message}
85
+ onChange={changeMessage}
86
+ placeholder="What is this change about?"
87
+ />
88
+ {!message && (
89
+ <div className="input-group__error-message">
90
+ Review message must not be empty
91
+ </div>
92
+ )}
93
+ </div>
94
+ </div>
95
+ </Panel>
96
+ <div className="search-modal__actions">
97
+ <button
98
+ className="btn btn--dark"
99
+ disabled={
100
+ !message ||
101
+ editorStore.projectConfigurationEditorState
102
+ .containsSnapshotDependencies ||
103
+ Boolean(editorStore.workspaceReviewState.workspaceReview) ||
104
+ editorStore.workspaceReviewState.isCreatingWorkspaceReview
105
+ }
106
+ title={
107
+ editorStore.projectConfigurationEditorState
108
+ .containsSnapshotDependencies
109
+ ? `Can't submit review: workspace contains unpublished dependencies`
110
+ : undefined
111
+ }
112
+ onClick={submitReview}
113
+ >
114
+ Submit
115
+ </button>
116
+ </div>
117
+ </form>
118
+ </Dialog>
119
+ );
120
+ });
121
+
122
+ export const ServiceQueryEditorReviewAction = observer(() => {
123
+ const editorStore = useServiceQueryEditorStore();
124
+ const applicationStore = useApplicationStore();
125
+ const currentReview = editorStore.workspaceReviewState.workspaceReview;
126
+
127
+ const showCreateReviewModal = (): void =>
128
+ editorStore.setShowSubmitReviewModal(true);
129
+ const visitReview = (): void => {
130
+ if (currentReview) {
131
+ applicationStore.navigator.openNewWindow(
132
+ applicationStore.navigator.generateLocation(
133
+ generateReviewRoute(currentReview.projectId, currentReview.id),
134
+ ),
135
+ );
136
+ }
137
+ };
138
+
139
+ return (
140
+ <>
141
+ {currentReview && (
142
+ <button
143
+ className="service-query-editor__header__action service-query-editor__review"
144
+ title={`${currentReview.title}\n\nClick to see review`}
145
+ onClick={visitReview}
146
+ >
147
+ <div className="service-query-editor__review__icon">
148
+ <ReviewIcon />
149
+ </div>
150
+ <div className="service-query-editor__review__message">
151
+ {currentReview.title}
152
+ </div>
153
+ <div className="service-query-editor__review__action">
154
+ <ExternalLinkSquareIcon />
155
+ </div>
156
+ </button>
157
+ )}
158
+ {!currentReview && (
159
+ <button
160
+ className="service-query-editor__header__action service-query-editor__header__action--simple btn--dark"
161
+ tabIndex={-1}
162
+ disabled={Boolean(currentReview)}
163
+ title="Submit for review"
164
+ onClick={showCreateReviewModal}
165
+ >
166
+ <ReviewIcon />
167
+ {editorStore.showSubmitReviewModal && <NewReviewModal />}
168
+ </button>
169
+ )}
170
+ </>
171
+ );
172
+ });
@@ -0,0 +1,89 @@
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 { createContext, useContext } from 'react';
18
+ import { useLocalObservable } from 'mobx-react-lite';
19
+ import { guaranteeNonNullable } from '@finos/legend-shared';
20
+ import {
21
+ type ServiceQueryEditorStore,
22
+ ServiceQueryUpdaterStore,
23
+ ProjectServiceQueryUpdaterStore,
24
+ } from '../../stores/studio/ServiceQueryEditorStore.js';
25
+ import { useDepotServerClient } from '@finos/legend-server-depot';
26
+ import { useSDLCServerClient } from '@finos/legend-server-sdlc';
27
+ import { useLegendStudioApplicationStore } from '@finos/legend-application-studio';
28
+
29
+ export const ServiceQueryEditorStoreContext = createContext<
30
+ ServiceQueryEditorStore | undefined
31
+ >(undefined);
32
+
33
+ export const ServiceQueryUpdaterStoreProvider: React.FC<{
34
+ children: React.ReactNode;
35
+ serviceCoordinates: string;
36
+ groupWorkspaceId: string;
37
+ }> = ({ children, serviceCoordinates, groupWorkspaceId }) => {
38
+ const applicationStore = useLegendStudioApplicationStore();
39
+ const sdlcServerClient = useSDLCServerClient();
40
+ const depotServerClient = useDepotServerClient();
41
+ const store = useLocalObservable(
42
+ () =>
43
+ new ServiceQueryUpdaterStore(
44
+ applicationStore,
45
+ sdlcServerClient,
46
+ depotServerClient,
47
+ serviceCoordinates,
48
+ groupWorkspaceId,
49
+ ),
50
+ );
51
+ return (
52
+ <ServiceQueryEditorStoreContext.Provider value={store}>
53
+ {children}
54
+ </ServiceQueryEditorStoreContext.Provider>
55
+ );
56
+ };
57
+
58
+ export const ProjectServiceQueryUpdaterStoreProvider: React.FC<{
59
+ children: React.ReactNode;
60
+ projectId: string;
61
+ groupWorkspaceId: string;
62
+ servicePath: string;
63
+ }> = ({ children, projectId, groupWorkspaceId, servicePath }) => {
64
+ const applicationStore = useLegendStudioApplicationStore();
65
+ const sdlcServerClient = useSDLCServerClient();
66
+ const depotServerClient = useDepotServerClient();
67
+ const store = useLocalObservable(
68
+ () =>
69
+ new ProjectServiceQueryUpdaterStore(
70
+ applicationStore,
71
+ sdlcServerClient,
72
+ depotServerClient,
73
+ projectId,
74
+ groupWorkspaceId,
75
+ servicePath,
76
+ ),
77
+ );
78
+ return (
79
+ <ServiceQueryEditorStoreContext.Provider value={store}>
80
+ {children}
81
+ </ServiceQueryEditorStoreContext.Provider>
82
+ );
83
+ };
84
+
85
+ export const useServiceQueryEditorStore = (): ServiceQueryEditorStore =>
86
+ guaranteeNonNullable(
87
+ useContext(ServiceQueryEditorStoreContext),
88
+ `Can't find service query editor store in context`,
89
+ );
@@ -0,0 +1,121 @@
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 {
18
+ ActionAlertActionType,
19
+ ActionAlertType,
20
+ useApplicationStore,
21
+ } from '@finos/legend-application';
22
+ import { CloudDownloadIcon, SyncIcon } from '@finos/legend-art';
23
+ import { flowResult } from 'mobx';
24
+ import { observer } from 'mobx-react-lite';
25
+ import { useServiceQueryEditorStore } from './ServiceQueryEditorStoreProvider.js';
26
+
27
+ export const ServiceQueryEditorWorkspaceStatus = observer(() => {
28
+ const editorStore = useServiceQueryEditorStore();
29
+ const applicationStore = useApplicationStore();
30
+ const isWorkspaceOutOfSync = editorStore.sdlcState.isWorkspaceOutOfSync;
31
+ const isWorkspaceOutated = editorStore.sdlcState.isWorkspaceOutdated;
32
+
33
+ const updateWorkspace = (): void => {
34
+ editorStore.setActionAlertInfo({
35
+ // TODO?: we might want to factor in change-detection to have more confidence here
36
+ message: `Please backup your work. Proceed to update workspace?`,
37
+ type: ActionAlertType.CAUTION,
38
+ actions: [
39
+ {
40
+ label: 'Proceed',
41
+ type: ActionAlertActionType.PROCEED_WITH_CAUTION,
42
+ handler: () => {
43
+ flowResult(editorStore.recreateWorkspace()).catch(
44
+ applicationStore.alertUnhandledError,
45
+ );
46
+ },
47
+ },
48
+ {
49
+ label: 'Abort',
50
+ type: ActionAlertActionType.PROCEED,
51
+ default: true,
52
+ },
53
+ ],
54
+ });
55
+ };
56
+
57
+ const syncWorkspace = (): void => {
58
+ editorStore.setActionAlertInfo({
59
+ // TODO?: we might want to factor in change-detection to have more confidence here
60
+ message: `Please backup your work. Proceed to sync workspace?`,
61
+ type: ActionAlertType.CAUTION,
62
+ actions: [
63
+ {
64
+ label: 'Proceed',
65
+ type: ActionAlertActionType.PROCEED_WITH_CAUTION,
66
+ handler: (): void => applicationStore.navigator.reload(),
67
+ },
68
+ {
69
+ label: 'Abort',
70
+ type: ActionAlertActionType.PROCEED,
71
+ default: true,
72
+ },
73
+ ],
74
+ });
75
+ };
76
+
77
+ return (
78
+ <>
79
+ {isWorkspaceOutOfSync && (
80
+ <button
81
+ className="service-query-editor__header__action service-query-editor__workspace-status service-query-editor__workspace-status--out-of-sync"
82
+ title={`Local workspace is out-of-sync. Please backup your work and refresh the application\n\nClick to sync workspace`}
83
+ tabIndex={-1}
84
+ onClick={syncWorkspace}
85
+ >
86
+ <div className="service-query-editor__workspace-status__icon">
87
+ <SyncIcon />
88
+ </div>
89
+ <div className="service-query-editor__workspace-status__text">
90
+ OUT-OF-SYNC
91
+ </div>
92
+ </button>
93
+ )}
94
+ {isWorkspaceOutated && !isWorkspaceOutOfSync && (
95
+ <button
96
+ className="service-query-editor__header__action service-query-editor__workspace-status service-query-editor__workspace-status--outdated"
97
+ title="Workspace is outdated. Click to update"
98
+ tabIndex={-1}
99
+ onClick={updateWorkspace}
100
+ >
101
+ <div className="service-query-editor__workspace-status__icon">
102
+ <CloudDownloadIcon />
103
+ </div>
104
+ <div className="service-query-editor__workspace-status__text">
105
+ OUTDATED
106
+ </div>
107
+ </button>
108
+ )}
109
+ {!isWorkspaceOutated && !isWorkspaceOutOfSync && (
110
+ <button
111
+ className="service-query-editor__header__action service-query-editor__workspace-status service-query-editor__workspace-status--up-to-date"
112
+ tabIndex={-1}
113
+ disabled={true}
114
+ title="Workspace is up-to-date"
115
+ >
116
+ <CloudDownloadIcon />
117
+ </button>
118
+ )}
119
+ </>
120
+ );
121
+ });