@finos/legend-application-query 13.8.70 → 13.8.71

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.
@@ -73,7 +73,20 @@ export const QueryEditorExistingQueryVersionRevertModal = observer(
73
73
  }
74
74
  },
75
75
  );
76
+ const projectVersionOverride = existingEditorStore.projectVersionId;
77
+ const openWithSavedVersion = (): void =>
78
+ applicationStore.navigationService.navigator.goToLocation(
79
+ generateExistingQueryEditorRoute(
80
+ existingEditorStore.lightQuery.id,
81
+ existingEditorStore.revisionId,
82
+ ),
83
+ );
76
84
  useEffect(() => {
85
+ // the version dropdown is not shown when the `projectVersionId` override
86
+ // is what failed, so there is no need to fetch the project versions
87
+ if (projectVersionOverride) {
88
+ return;
89
+ }
77
90
  flowResult(
78
91
  updateState.fetchProjectVersions(
79
92
  existingEditorStore.lightQuery.groupId,
@@ -84,9 +97,40 @@ export const QueryEditorExistingQueryVersionRevertModal = observer(
84
97
  applicationStore,
85
98
  existingEditorStore.lightQuery.artifactId,
86
99
  existingEditorStore.lightQuery.groupId,
100
+ projectVersionOverride,
87
101
  updateState,
88
102
  ]);
89
103
 
104
+ // the `projectVersionId` override is what failed to load: don't force the
105
+ // user to overwrite the stored version, just let them open the query with
106
+ // the version it was saved with
107
+ if (projectVersionOverride) {
108
+ return (
109
+ <BlankPanelContent>
110
+ <Modal
111
+ darkMode={
112
+ !applicationStore.layoutService
113
+ .TEMPORARY__isLightColorThemeEnabled
114
+ }
115
+ className="query-editor__blocking-alert"
116
+ >
117
+ <ModalBody>
118
+ <div className="query-editor__blocking-alert__summary-text">
119
+ Query is incompatible with version `{projectVersionOverride}`
120
+ (from the `projectVersionId` URL parameter).
121
+ </div>
122
+ </ModalBody>
123
+ <ModalFooter>
124
+ <ModalFooterButton
125
+ onClick={openWithSavedVersion}
126
+ text={`Open with saved version ${existingEditorStore.lightQuery.versionId}`}
127
+ />
128
+ </ModalFooter>
129
+ </Modal>
130
+ </BlankPanelContent>
131
+ );
132
+ }
133
+
90
134
  return (
91
135
  <BlankPanelContent>
92
136
  <Modal
@@ -416,6 +416,7 @@ export abstract class QueryEditorStore {
416
416
  generateExistingQueryEditorRoute(
417
417
  query.id,
418
418
  revisionId,
419
+ this.getProjectVersionIdOverride(query),
419
420
  extraQueryParams,
420
421
  ),
421
422
  { ignoreBlocking: true },
@@ -481,6 +482,18 @@ export abstract class QueryEditorStore {
481
482
  return undefined;
482
483
  }
483
484
 
485
+ /**
486
+ * The project version override (e.g. a dev/snapshot version) the graph is
487
+ * currently being built from, if any, so it can be carried across a
488
+ * revert/load-revision navigation to `targetQuery`. It only applies to the
489
+ * query being edited: a different query may belong to another project, where
490
+ * the override version would not exist. Only existing-query editors have
491
+ * this; other editor kinds return `undefined`.
492
+ */
493
+ getProjectVersionIdOverride(targetQuery: LightQuery): string | undefined {
494
+ return undefined;
495
+ }
496
+
484
497
  setExistingQueryName(val: string | undefined): void {
485
498
  this.existingQueryName = val;
486
499
  }
@@ -1993,6 +2006,9 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
1993
2006
  // A specific revision from the query's version history to load, keyed by the
1994
2007
  // revision's `version` identifier. When undefined, the latest is loaded.
1995
2008
  readonly revisionId: string | undefined;
2009
+ // Overrides the project version the graph is built from (e.g. a dev/snapshot
2010
+ // version).
2011
+ readonly projectVersionId: string | undefined;
1996
2012
  private _lightQuery?: LightQuery | undefined;
1997
2013
  query: Query | undefined;
1998
2014
  queryInfo: QueryInfo | undefined;
@@ -2005,6 +2021,7 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2005
2021
  queryId: string,
2006
2022
  urlQueryParamValues: Record<string, string> | undefined,
2007
2023
  revisionId?: string | undefined,
2024
+ projectVersionId?: string | undefined,
2008
2025
  ) {
2009
2026
  super(applicationStore, depotServerClient);
2010
2027
 
@@ -2022,6 +2039,7 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2022
2039
 
2023
2040
  this.queryId = queryId;
2024
2041
  this.revisionId = revisionId;
2042
+ this.projectVersionId = projectVersionId;
2025
2043
  this.urlQueryParamValues = urlQueryParamValues;
2026
2044
  this.updateState = new ExistingQueryUpdateState(this);
2027
2045
  }
@@ -2058,6 +2076,12 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2058
2076
  return this.urlQueryParamValues;
2059
2077
  }
2060
2078
 
2079
+ override getProjectVersionIdOverride(
2080
+ targetQuery: LightQuery,
2081
+ ): string | undefined {
2082
+ return targetQuery.id === this.queryId ? this.projectVersionId : undefined;
2083
+ }
2084
+
2061
2085
  override get isPerformingBlockingAction(): boolean {
2062
2086
  return (
2063
2087
  super.isPerformingBlockingAction ||
@@ -2128,10 +2152,18 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2128
2152
  return {
2129
2153
  groupId: this.lightQuery.groupId,
2130
2154
  artifactId: this.lightQuery.artifactId,
2131
- versionId: this.lightQuery.versionId,
2155
+ versionId: this.projectVersionId ?? this.lightQuery.versionId,
2132
2156
  };
2133
2157
  }
2134
2158
 
2159
+ /**
2160
+ * The project version a query revision is built from: the `projectVersionId`
2161
+ * override if there is one, otherwise the version the revision was saved with.
2162
+ */
2163
+ private getEffectiveVersionId(queryInfo: QueryInfo): string {
2164
+ return this.projectVersionId ?? queryInfo.versionId;
2165
+ }
2166
+
2135
2167
  override *buildGraph(): GeneratorFn<void> {
2136
2168
  const queryInfo = this.queryInfo;
2137
2169
  const dataSpaceTaggedValue = queryInfo?.taggedValues?.find(
@@ -2161,10 +2193,11 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2161
2193
  // skipped, but we still list every ingest in the project so the source
2162
2194
  // dropdown can show them and `swapIngestDefinition` can build a
2163
2195
  // different one on demand.
2196
+ const versionId = this.getEffectiveVersionId(queryInfo);
2164
2197
  yield* this.buildIngestGraph(
2165
2198
  queryInfo.groupId,
2166
2199
  queryInfo.artifactId,
2167
- queryInfo.versionId,
2200
+ versionId,
2168
2201
  queryInfo.executionContext.ingestDefinitionPath,
2169
2202
  );
2170
2203
  }
@@ -2228,11 +2261,12 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2228
2261
  ): Promise<QueryBuilderState> {
2229
2262
  const exec = queryInfo.executionContext;
2230
2263
  if (exec instanceof QueryDataSpaceExecutionContextInfo) {
2264
+ const versionId = this.getEffectiveVersionId(queryInfo);
2231
2265
  const { dataSpaceAnalysisResult, isLightGraphEnabled } =
2232
2266
  await this.buildGraphAndDataspaceAnalyticsResult(
2233
2267
  queryInfo.groupId,
2234
2268
  queryInfo.artifactId,
2235
- queryInfo.versionId,
2269
+ versionId,
2236
2270
  exec.executionKey,
2237
2271
  exec.dataSpacePath,
2238
2272
  );
@@ -2243,8 +2277,7 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2243
2277
  await this.attachDataSpaceFallbackRuntimes(
2244
2278
  dataSpace,
2245
2279
  dataSpaceAnalysisResult,
2246
- isSnapshotVersion(queryInfo.versionId) ||
2247
- queryInfo.versionId === SNAPSHOT_VERSION_ALIAS,
2280
+ isSnapshotVersion(versionId) || versionId === SNAPSHOT_VERSION_ALIAS,
2248
2281
  );
2249
2282
  const mapping = queryInfo.mapping
2250
2283
  ? this.graphManagerState.graph.getMapping(queryInfo.mapping)
@@ -2263,7 +2296,7 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2263
2296
  sourceType: LegendQuerySourceType.DATA_SPACE,
2264
2297
  groupId: queryInfo.groupId,
2265
2298
  artifactId: queryInfo.artifactId,
2266
- versionId: queryInfo.versionId,
2299
+ versionId,
2267
2300
  queryId: queryInfo.id,
2268
2301
  dataSpace: dataSpace.path,
2269
2302
  executionContext: exec.executionKey,
@@ -2285,7 +2318,7 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2285
2318
  {
2286
2319
  groupId: queryInfo.groupId,
2287
2320
  artifactId: queryInfo.artifactId,
2288
- versionId: queryInfo.versionId,
2321
+ versionId,
2289
2322
  },
2290
2323
  (dataSpaceInfo: ResolvedDataSpaceEntityWithOrigin) =>
2291
2324
  hasDataSpaceInfoBeenVisited(dataSpaceInfo, visitedDataSpaces),
@@ -2458,6 +2491,7 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2458
2491
  exec instanceof QueryDataProductModelAccessExecutionContextInfo ||
2459
2492
  exec instanceof QueryDataProductLakehouseExecutionContextInfo
2460
2493
  ) {
2494
+ const versionId = this.getEffectiveVersionId(queryInfo);
2461
2495
  let executionContextId: string;
2462
2496
  let accessType: DataProductAccessType;
2463
2497
  if (exec instanceof QueryDataProductModelAccessExecutionContextInfo) {
@@ -2470,13 +2504,13 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2470
2504
  const artifact = await this.fetchDataProductArtifact(
2471
2505
  queryInfo.groupId,
2472
2506
  queryInfo.artifactId,
2473
- queryInfo.versionId,
2507
+ versionId,
2474
2508
  exec.dataProductPath,
2475
2509
  );
2476
2510
  const queryBuilderState = await this.buildDataProductQueryBuilderState(
2477
2511
  queryInfo.groupId,
2478
2512
  queryInfo.artifactId,
2479
- queryInfo.versionId,
2513
+ versionId,
2480
2514
  exec.dataProductPath,
2481
2515
  artifact,
2482
2516
  executionContextId,
@@ -2492,7 +2526,7 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2492
2526
  sourceType: LegendQuerySourceType.DATA_PRODUCT,
2493
2527
  groupId: queryInfo.groupId,
2494
2528
  artifactId: queryInfo.artifactId,
2495
- versionId: queryInfo.versionId,
2529
+ versionId,
2496
2530
  queryId: queryInfo.id,
2497
2531
  dataProduct: exec.dataProductPath,
2498
2532
  accessType,
@@ -2693,7 +2727,7 @@ export class ExistingQueryEditorStore extends QueryEditorStore {
2693
2727
  query.id = this.lightQuery.id;
2694
2728
  query.groupId = this.lightQuery.groupId;
2695
2729
  query.artifactId = this.lightQuery.artifactId;
2696
- query.versionId = this.lightQuery.versionId;
2730
+ query.versionId = this.getProjectInfo().versionId;
2697
2731
  },
2698
2732
  onQueryUpdate: (query: Query): void => {
2699
2733
  this.setLightQuery(toLightQuery(query));