@finos/legend-application-studio 28.19.116 → 28.19.117

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 (22) hide show
  1. package/lib/__lib__/LegendStudioEvent.d.ts +1 -0
  2. package/lib/__lib__/LegendStudioEvent.d.ts.map +1 -1
  3. package/lib/__lib__/LegendStudioEvent.js +1 -0
  4. package/lib/__lib__/LegendStudioEvent.js.map +1 -1
  5. package/lib/components/editor/editor-group/dataProduct/DataProductQueryBuilderHelper.d.ts.map +1 -1
  6. package/lib/components/editor/editor-group/dataProduct/DataProductQueryBuilderHelper.js +2 -2
  7. package/lib/components/editor/editor-group/dataProduct/DataProductQueryBuilderHelper.js.map +1 -1
  8. package/lib/components/editor/editor-group/service-editor/ServiceRegistrationEditor.d.ts.map +1 -1
  9. package/lib/components/editor/editor-group/service-editor/ServiceRegistrationEditor.js +12 -3
  10. package/lib/components/editor/editor-group/service-editor/ServiceRegistrationEditor.js.map +1 -1
  11. package/lib/index.css +2 -2
  12. package/lib/index.css.map +1 -1
  13. package/lib/package.json +1 -1
  14. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceRegistrationState.d.ts +4 -0
  15. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceRegistrationState.d.ts.map +1 -1
  16. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceRegistrationState.js +29 -0
  17. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceRegistrationState.js.map +1 -1
  18. package/package.json +9 -9
  19. package/src/__lib__/LegendStudioEvent.ts +1 -0
  20. package/src/components/editor/editor-group/dataProduct/DataProductQueryBuilderHelper.ts +4 -3
  21. package/src/components/editor/editor-group/service-editor/ServiceRegistrationEditor.tsx +67 -1
  22. package/src/stores/editor/editor-state/element-editor-state/service/ServiceRegistrationState.ts +39 -0
@@ -15,6 +15,7 @@
15
15
  */
16
16
 
17
17
  import { observer } from 'mobx-react-lite';
18
+ import { useEffect } from 'react';
18
19
  import { ServiceEditorState } from '../../../../stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js';
19
20
  import {
20
21
  clsx,
@@ -22,6 +23,8 @@ import {
22
23
  CustomSelectorInput,
23
24
  CheckSquareIcon,
24
25
  SquareIcon,
26
+ ExternalLinkSquareIcon,
27
+ CircleNotchIcon,
25
28
  } from '@finos/legend-art';
26
29
  import { prettyCONSTName } from '@finos/legend-shared';
27
30
  import { LEGEND_STUDIO_TEST_ID } from '../../../../__lib__/LegendStudioTesting.js';
@@ -30,7 +33,10 @@ import { flowResult } from 'mobx';
30
33
  import { useEditorStore } from '../../EditorStoreProvider.js';
31
34
  import { useApplicationStore } from '@finos/legend-application';
32
35
  import { MASTER_SNAPSHOT_ALIAS } from '@finos/legend-server-depot';
33
- import { LATEST_PROJECT_REVISION } from '../../../../stores/editor/editor-state/element-editor-state/service/ServiceRegistrationState.js';
36
+ import {
37
+ LATEST_PROJECT_REVISION,
38
+ generateServiceManagementUrl,
39
+ } from '../../../../stores/editor/editor-state/element-editor-state/service/ServiceRegistrationState.js';
34
40
 
35
41
  export const ServiceRegistrationEditor = observer(() => {
36
42
  const editorStore = useEditorStore();
@@ -136,6 +142,12 @@ export const ServiceRegistrationEditor = observer(() => {
136
142
  !selectedServiceType ||
137
143
  registrationState.registrationState.isInProgress;
138
144
 
145
+ useEffect(() => {
146
+ flowResult(registrationState.checkServiceRegistration()).catch(
147
+ applicationStore.alertUnhandledError,
148
+ );
149
+ }, [registrationState, applicationStore]);
150
+
139
151
  return (
140
152
  <div
141
153
  data-testid={LEGEND_STUDIO_TEST_ID.SERVICE_REGISTRATION_EDITOR}
@@ -169,6 +181,60 @@ export const ServiceRegistrationEditor = observer(() => {
169
181
  {`${registrationState.registrationState.message}...`}
170
182
  </div>
171
183
  )}
184
+ <div className="panel__content__form__section">
185
+ <div className="panel__content__form__section__header__label">
186
+ Deployment Status
187
+ </div>
188
+ <div className="panel__content__form__section__header__prompt">
189
+ Environments where this service is currently deployed
190
+ </div>
191
+ <div className="service-registration-editor__deployment-status">
192
+ {registrationState.deploymentCheckState.isInProgress && (
193
+ <div className="service-registration-editor__deployment-status__loading">
194
+ <CircleNotchIcon className="service-registration-editor__deployment-status__loading-icon" />
195
+ <span>Fetching deployment status...</span>
196
+ </div>
197
+ )}
198
+ {registrationState.deploymentCheckState.hasCompleted &&
199
+ registrationState.registeredEnvs.length === 0 && (
200
+ <div className="service-registration-editor__deployment-status__empty">
201
+ Service is not deployed to any environment
202
+ </div>
203
+ )}
204
+ {registrationState.deploymentCheckState.hasCompleted &&
205
+ registrationState.registeredEnvs.length > 0 && (
206
+ <div className="service-registration-editor__deployment-status__envs">
207
+ <span className="service-registration-editor__deployment-status__label">
208
+ Service is deployed to
209
+ </span>
210
+ {registrationState.registeredEnvs.map((env) => {
211
+ const envConfig =
212
+ registrationState.registrationOptions.find(
213
+ (e) => e.env === env,
214
+ );
215
+ return envConfig ? (
216
+ <a
217
+ key={env}
218
+ className="service-editor__deployment-link"
219
+ href={generateServiceManagementUrl(
220
+ envConfig.managementUrl,
221
+ serviceState.service.pattern,
222
+ )}
223
+ target="_blank"
224
+ rel="noopener noreferrer"
225
+ title={`Open in ${env}`}
226
+ >
227
+ <span className="service-editor__deployment-link__env">
228
+ {env.toUpperCase()}
229
+ </span>
230
+ <ExternalLinkSquareIcon />
231
+ </a>
232
+ ) : null;
233
+ })}
234
+ </div>
235
+ )}
236
+ </div>
237
+ </div>
172
238
  <div className="panel__content__form__section">
173
239
  <div className="panel__content__form__section__header__label">
174
240
  Activate Service
@@ -255,7 +255,9 @@ export class ServiceConfigState {
255
255
 
256
256
  export class ServiceRegistrationState extends ServiceConfigState {
257
257
  readonly service: Service;
258
+ readonly deploymentCheckState = ActionState.create();
258
259
  activatePostRegistration = true;
260
+ registeredEnvs: string[] = [];
259
261
 
260
262
  constructor(
261
263
  editorStore: EditorStore,
@@ -267,8 +269,11 @@ export class ServiceRegistrationState extends ServiceConfigState {
267
269
 
268
270
  makeObservable(this, {
269
271
  activatePostRegistration: observable,
272
+ registeredEnvs: observable,
270
273
  setActivatePostRegistration: action,
274
+ setRegisteredEnvs: action,
271
275
  registerService: flow,
276
+ checkServiceRegistration: flow,
272
277
  });
273
278
 
274
279
  this.service = service;
@@ -277,6 +282,40 @@ export class ServiceRegistrationState extends ServiceConfigState {
277
282
  this.activatePostRegistration = val;
278
283
  }
279
284
 
285
+ setRegisteredEnvs(envs: string[]): void {
286
+ this.registeredEnvs = envs;
287
+ }
288
+
289
+ *checkServiceRegistration(): GeneratorFn<void> {
290
+ this.deploymentCheckState.inProgress();
291
+ const envs: string[] = [];
292
+ const servicePattern = this.service.pattern.startsWith('/')
293
+ ? this.service.pattern.substring(1)
294
+ : this.service.pattern;
295
+ for (const envConfig of this.registrationOptions) {
296
+ try {
297
+ const isRegistered =
298
+ (yield this.editorStore.graphManagerState.graphManager.checkServiceRegisteredByPattern(
299
+ envConfig.executionUrl,
300
+ servicePattern,
301
+ )) as boolean;
302
+ if (isRegistered) {
303
+ envs.push(envConfig.env);
304
+ }
305
+ } catch (error) {
306
+ assertErrorThrown(error);
307
+ this.editorStore.applicationStore.logService.warn(
308
+ LogEvent.create(
309
+ LEGEND_STUDIO_APP_EVENT.SERVICE_REGISTRATION_CHECK_FAILURE,
310
+ ),
311
+ `Can't check registration status for env '${envConfig.env}': ${error.message}`,
312
+ );
313
+ }
314
+ }
315
+ this.setRegisteredEnvs(envs);
316
+ this.deploymentCheckState.complete();
317
+ }
318
+
280
319
  *registerService(): GeneratorFn<void> {
281
320
  try {
282
321
  this.registrationState.inProgress();