Skip to content

Commit

Permalink
datacube: refactor query source (#3606)
Browse files Browse the repository at this point in the history
  • Loading branch information
akphi authored Oct 16, 2024
1 parent 2044bce commit 63f6e02
Show file tree
Hide file tree
Showing 116 changed files with 1,888 additions and 1,913 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-insects-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-application-repl': patch
'@finos/legend-query-builder': patch
'@finos/legend-data-cube': patch
---
6 changes: 6 additions & 0 deletions .changeset/neat-chicken-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@finos/legend-application-query': patch
'@finos/legend-application-repl': patch
'@finos/legend-query-builder': patch
'@finos/legend-data-cube': patch
---
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import {
} from './ExistingQueryEditorStoreProviderProvider.js';
import { useEffect } from 'react';
import { flowResult } from 'mobx';
import { DataCube, DataCubeProvider } from '@finos/legend-data-cube';
import { QueryBuilderDataCubeApplicationEngine } from '@finos/legend-query-builder';
import { DataCube } from '@finos/legend-data-cube';
import { guaranteeNonNullable } from '@finos/legend-shared';

export const DataCubeWrapper = observer(() => {
Expand All @@ -42,15 +41,7 @@ export const DataCubeWrapper = observer(() => {
if (!store.engine) {
return null;
}
const _appEngine = new QueryBuilderDataCubeApplicationEngine(
applicationStore,
);

return (
<DataCubeProvider application={_appEngine} engine={store.engine}>
<DataCube />
</DataCubeProvider>
);
return <DataCube engine={store.engine} />;
});

export const ExistingQueryDataCubeViewer = observer(() => {
Expand Down
3 changes: 2 additions & 1 deletion packages/legend-application-repl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"mobx": "6.13.3",
"mobx-react-lite": "4.0.7",
"react": "18.3.1",
"react-dom": "18.3.1"
"react-dom": "18.3.1",
"serializr": "3.0.2"
},
"devDependencies": {
"@finos/legend-dev-utils": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import {
import { observer } from 'mobx-react-lite';
import { useEffect, useMemo } from 'react';
import {
formatDate,
guaranteeNonNullable,
LogEvent,
NetworkClient,
} from '@finos/legend-shared';
import { LegendREPLServerClient } from '../stores/LegendREPLServerClient.js';
import { LegendREPLDataCubeApplicationEngine } from '../stores/LegendREPLDataCubeApplicationEngine.js';
import { LegendREPLDataCubeEngine } from '../stores/LegendREPLDataCubeEngine.js';
import { DataCube, DataCubeProvider } from '@finos/legend-data-cube';
import { DataCube, DataCubeSettingKey } from '@finos/legend-data-cube';
import {
APPLICATION_EVENT,
ApplicationFrameworkProvider,
Expand All @@ -38,53 +38,81 @@ import {
type LegendApplicationPluginManager,
} from '@finos/legend-application';
import type { LegendREPLApplicationConfig } from '../application/LegendREPLApplicationConfig.js';
import { LegendREPLDataCubeSource } from '../stores/LegendREPLDataCubeSource.js';

const LegendREPLDataCube = observer(() => {
const applicationStore = useApplicationStore<
const application = useApplicationStore<
LegendREPLApplicationConfig,
LegendApplicationPluginManager<LegendApplicationPlugin>
>();
const application = useMemo(
() => new LegendREPLDataCubeApplicationEngine(applicationStore),
[applicationStore],
);
const engine = new LegendREPLDataCubeEngine(
application,
new LegendREPLServerClient(
new NetworkClient({
baseUrl: applicationStore.config.useDynamicREPLServer
? window.location.origin +
guaranteeNonNullable(applicationStore.config.baseAddress).replace(
'/repl/',
'',
)
: applicationStore.config.replUrl,
}),
),
const config = application.config;
const engine = useMemo(
() =>
new LegendREPLDataCubeEngine(
application,
new LegendREPLServerClient(
new NetworkClient({
baseUrl: config.useDynamicREPLServer
? window.location.origin +
guaranteeNonNullable(config.baseAddress).replace('/repl/', '')
: config.replUrl,
}),
),
),
[application, config],
);

useEffect(() => {
application.blockNavigation(
engine.blockNavigation(
// Only block navigation in production
// eslint-disable-next-line no-process-env
[() => process.env.NODE_ENV === 'production'],
undefined,
() => {
application.logWarning(
engine.logWarning(
LogEvent.create(APPLICATION_EVENT.NAVIGATION_BLOCKED),
`Navigation from the application is blocked`,
);
},
);
return (): void => {
application.unblockNavigation();
engine.unblockNavigation();
};
}, [application]);
}, [engine]);

return (
<DataCubeProvider application={application} engine={engine}>
<DataCube />
</DataCubeProvider>
<DataCube
engine={engine}
options={{
onNameChanged(name, source) {
const timestamp =
source instanceof LegendREPLDataCubeSource
? source.timestamp
: undefined;
application.layoutService.setWindowTitle(
`\u229E ${name}${timestamp ? ` - ${formatDate(new Date(timestamp), 'HH:mm:ss EEE MMM dd yyyy')}` : ''}`,
);
},
onSettingChanged(key, value) {
engine.persistSettingValue(key, value);
},

enableDebugMode: application.settingService.getBooleanValue(
DataCubeSettingKey.ENABLE_DEBUG_MODE,
),
gridClientRowBuffer: application.settingService.getNumericValue(
DataCubeSettingKey.GRID_CLIENT_ROW_BUFFER,
),
gridClientPurgeClosedRowNodes:
application.settingService.getBooleanValue(
DataCubeSettingKey.GRID_CLIENT_PURGE_CLOSED_ROW_NODES,
),
gridClientSuppressLargeDatasetWarning:
application.settingService.getBooleanValue(
DataCubeSettingKey.GRID_CLIENT_SUPPRESS_LARGE_DATASET_WARNING,
),
}}
/>
);
});

Expand Down

This file was deleted.

Loading

0 comments on commit 63f6e02

Please sign in to comment.