Skip to content

Commit

Permalink
enable new query button in query create flow (finos#3179)
Browse files Browse the repository at this point in the history
  • Loading branch information
YannanGao-gs authored and MauricioUyaguari committed May 29, 2024
1 parent 4221e10 commit 1ab1893
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .changeset/tasty-llamas-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-application-query': patch
---

enable new query button in query create flow
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ import {
LEGEND_QUERY_ROUTE_PATTERN,
} from '../__lib__/LegendQueryNavigation.js';
import {
ActionAlertActionType,
ActionAlertType,
type ApplicationPageEntry,
type LegendApplicationSetup,
} from '@finos/legend-application';
Expand All @@ -65,9 +67,9 @@ import {
generateDataSpaceQueryCreatorRoute,
generateDataSpaceQuerySetupRoute,
} from '../__lib__/DSL_DataSpace_LegendQueryNavigation.js';
import type {
QueryBuilderHeaderActionConfiguration,
QueryBuilderMenuActionConfiguration,
import {
type QueryBuilderHeaderActionConfiguration,
type QueryBuilderMenuActionConfiguration,
} from '@finos/legend-query-builder';
import {
ExistingQueryEditorStore,
Expand Down Expand Up @@ -426,8 +428,6 @@ export class Core_LegendQueryApplicationPlugin extends LegendQueryApplicationPlu
) {
const editorStore =
queryBuilderState.workflowState.actionConfig.editorStore;
const isExistingQuery =
editorStore instanceof ExistingQueryEditorStore;
const handleNewQuery = (): void => {
if (editorStore instanceof ExistingQueryEditorStore) {
const query = editorStore.query;
Expand Down Expand Up @@ -464,24 +464,47 @@ export class Core_LegendQueryApplicationPlugin extends LegendQueryApplicationPlu
}
}
}
} else {
if (queryBuilderState.changeDetectionState.hasChanged) {
queryBuilderState.applicationStore.alertService.setActionAlertInfo(
{
message:
'Current query will be lost when creating a new query. Do you still want to proceed?',
type: ActionAlertType.CAUTION,
actions: [
{
label: 'Proceed',
type: ActionAlertActionType.PROCEED_WITH_CAUTION,
handler:
queryBuilderState.applicationStore.guardUnhandledError(
async () => queryBuilderState.resetQueryContent(),
),
},
{
label: 'Cancel',
type: ActionAlertActionType.PROCEED,
default: true,
},
],
},
);
} else {
queryBuilderState.resetQueryContent();
}
}
};
return (
<>
{isExistingQuery && (
<Button
className="query-editor__header__action btn--dark"
disabled={editorStore.isPerformingBlockingAction}
onClick={handleNewQuery}
title="New query"
>
<SaveCurrIcon />
<div className="query-editor__header__action__label">
New Query
</div>
</Button>
)}
</>
<Button
className="query-editor__header__action btn--dark"
disabled={editorStore.isPerformingBlockingAction}
onClick={handleNewQuery}
title="New query"
>
<SaveCurrIcon />
<div className="query-editor__header__action__label">
New Query
</div>
</Button>
);
}
return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ export abstract class QueryEditorStore {
this.queryBuilderState = (yield this.initializeQueryBuilderState(
stopWatch,
)) as QueryBuilderState;
this.queryBuilderState.changeDetectionState.initialize(
this.queryBuilderState.buildQuery(),
);
this.queryLoaderState.initialize(this.queryBuilderState);
this.initState.pass();
} catch (error) {
Expand Down

0 comments on commit 1ab1893

Please sign in to comment.