Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable new query button in query create flow #3179

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -425,8 +427,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 @@ -463,24 +463,47 @@ export class Core_LegendQueryApplicationPlugin extends LegendQueryApplicationPlu
}
}
}
} else {
if (queryBuilderState.changeDetectionState.hasChanged) {
MauricioUyaguari marked this conversation as resolved.
Show resolved Hide resolved
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(
MauricioUyaguari marked this conversation as resolved.
Show resolved Hide resolved
this.queryBuilderState.buildQuery(),
);
this.queryLoaderState.initialize(this.queryBuilderState);
this.initState.pass();
} catch (error) {
Expand Down
Loading