Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
akphi committed Oct 10, 2024
1 parent aa0ad8f commit 9e1d1a3
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 71 deletions.
7 changes: 7 additions & 0 deletions .changeset/red-snails-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@finos/legend-application-repl': patch
'@finos/legend-query-builder': patch
'@finos/legend-application': patch
'@finos/legend-data-cube': patch
'@finos/legend-art': patch
---
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ import {
Routes,
} from '@finos/legend-application/browser';
import { observer } from 'mobx-react-lite';
import { useMemo } from 'react';
import { guaranteeNonNullable, NetworkClient } from '@finos/legend-shared';
import { useEffect, useMemo } from 'react';
import {
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 {
APPLICATION_EVENT,
ApplicationFrameworkProvider,
useApplicationStore,
type LegendApplicationPlugin,
Expand Down Expand Up @@ -58,6 +63,24 @@ const LegendREPLDataCube = observer(() => {
),
);

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

return (
<DataCubeProvider application={application} engine={engine}>
<DataCube />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export enum APPLICATION_EVENT {
APPLICATION_CONTEXT__ACCESS = 'application.context.access',

APPLICATION_USAGE__INTERRUPT = 'application.usage.interrupt',
NAVIGATION_BLOCKED = 'application.usage.navigation-blocked',

APPLICATION_TELEMETRY_EVENT__FAILURE = 'application.telemetry-event.failure',

Expand Down
2 changes: 2 additions & 0 deletions packages/legend-art/src/autocomplete/CustomSelectorInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ export const CustomSelectorInput = <
value,
onChange,
inputRef,
placeholder,
...innerProps
} = props;
// Typescript cannot union the 2 types due to many dissimilarities, this goes on to confuse React.createElement
Expand Down Expand Up @@ -332,6 +333,7 @@ export const CustomSelectorInput = <
Input: CustomInput,
...components,
}}
placeholder={placeholder ?? ''}
{...{
...innerProps,
darkMode,
Expand Down
4 changes: 0 additions & 4 deletions packages/legend-art/style/components/_selector-input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@
}

&__value-container {
@include flexVCenter;

height: 2.6rem;
padding: 0 0.5rem;
}
Expand Down Expand Up @@ -269,8 +267,6 @@
}

&__value-container {
@include flexVCenter;

height: 2.6rem;
padding: 0 0.5rem;
color: var(--color-light-grey-200);
Expand Down
19 changes: 0 additions & 19 deletions packages/legend-data-cube/src/__lib__/DataCubeEvent.ts

This file was deleted.

21 changes: 0 additions & 21 deletions packages/legend-data-cube/src/components/DataCube.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import type { DataCubeViewState } from '../stores/view/DataCubeViewState.js';
import { INTERNAL__MonacoEditorWidgetsRoot } from './core/DataCubePureCodeEditorUtils.js';
import { useDataCube } from './DataCubeProvider.js';
import { DataCubeBlockingActionAlert } from './core/DataCubeAlert.js';
import { LogEvent } from '@finos/legend-shared';
import { DataCubeEvent } from '../__lib__/DataCubeEvent.js';

const DataCubeStatusBar = observer((props: { view: DataCubeViewState }) => {
const { view } = props;
Expand Down Expand Up @@ -144,25 +142,6 @@ export const DataCube = observer(() => {
view.initialize().catch((error) => application.logUnhandledError(error));
}, [view, application]);

// TODO: move this to upper layer component when we have multi-view support
useEffect(() => {
application.blockNavigation(
// Only block navigation in production
// eslint-disable-next-line no-process-env
[() => process.env.NODE_ENV === 'production'],
undefined,
() => {
application.logWarning(
LogEvent.create(DataCubeEvent.NAVIGATION_BLOCKED),
`Navigation from the application is blocked`,
);
},
);
return (): void => {
application.unblockNavigation();
};
}, [application]);

return (
<div className="data-cube relative flex h-full w-full flex-col bg-white">
<DataCubeTitleBar view={view} />
Expand Down
5 changes: 2 additions & 3 deletions packages/legend-data-cube/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@

export * from './stores/core/DataCubeEngine.js';
export * from './stores/core/DataCubeApplicationEngine.js';
export * from './stores/core/DataCubeQuery.js';
export * from './stores/core/DataCubeQueryBuilderUtils.js';

export * from './components/core/DataCubeAlert.js';
export * from './components/DataCube.js';
export * from './components/DataCubeProvider.js';

export * from './stores/engine/DataCubeQuery.js';
export * from './stores/core/DataCubeQueryBuilderUtils.js';
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ export abstract class DataCubeApplicationEngine {

abstract openLink(url: string): void;
abstract setWindowTitle(title: string): void;
abstract blockNavigation(
blockCheckers: (() => boolean)[],
onBlock?: ((onProceed: () => void) => void) | undefined,
onNativePlatformNavigationBlock?: (() => void) | undefined,
): void;
abstract unblockNavigation(): void;

abstract logDebug(message: string, ...data: unknown[]): void;
abstract debugProcess(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ export class DataCubeQuerySnapshot {
*/
INTERNAL__fullClone() {
const clone = new DataCubeQuerySnapshot('', '', '', {}, {});
(clone.uuid as Writable<string>) = this.uuid;
(clone.timestamp as Writable<number>) = this.timestamp;
(clone.data as Writable<DataCubeQuerySnapshotData>) = JSON.parse(
(clone as Writable<DataCubeQuerySnapshot>).uuid = this.uuid;
(clone as Writable<DataCubeQuerySnapshot>).timestamp = this.timestamp;
(clone as Writable<DataCubeQuerySnapshot>).data = JSON.parse(
JSON.stringify(this.data),
) as DataCubeQuerySnapshotData;
clone._isPatchChange = this._isPatchChange;
Expand All @@ -217,7 +217,7 @@ export class DataCubeQuerySnapshot {
* to the timestamp provided by the engine.
*/
INTERNAL__setTimestamp(timestamp: number) {
(this.timestamp as Writable<number>) = timestamp;
(this as Writable<DataCubeQuerySnapshot>).timestamp = timestamp;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
ZoomOutIcon,
clsx,
useResizeDetector,
createFilter,
} from '@finos/legend-art';
import { type DataSpaceViewerState } from '../stores/DataSpaceViewerState.js';
import { observer } from 'mobx-react-lite';
Expand Down Expand Up @@ -249,6 +250,11 @@ const DataSpaceDiagramViewerHeader = observer(
diagramViewerState.setCurrentDiagram(option.value);
}
};
const diagramFilterOption = createFilter({
ignoreCase: true,
ignoreAccents: false,
stringify: (option: { data: DiagramOption }) => option.data.value.title,
});
const createModeSwitcher =
(
editMode: DIAGRAM_INTERACTION_MODE,
Expand Down Expand Up @@ -280,6 +286,7 @@ const DataSpaceDiagramViewerHeader = observer(
!applicationStore.layoutService
.TEMPORARY__isLightColorThemeEnabled
}
filterOption={diagramFilterOption}
/>
<div className="data-space__viewer__diagram-viewer__header__navigation__pager">
<input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ import {
shouldDisplayVirtualAssistantDocumentationEntry,
type GenericLegendApplicationStore,
} from '@finos/legend-application';
import {
DataCubeApplicationEngine,
type ActionAlert,
} from '@finos/legend-data-cube';
import { DataCubeApplicationEngine } from '@finos/legend-data-cube';
import { LogEvent, type DocumentationEntry } from '@finos/legend-shared';

export class QueryBuilderDataCubeApplicationEngine extends DataCubeApplicationEngine {
Expand Down Expand Up @@ -58,14 +55,6 @@ export class QueryBuilderDataCubeApplicationEngine extends DataCubeApplicationEn
this.application.layoutService.setWindowTitle(title);
}

alertAction(alertInfo: ActionAlert | undefined) {
this.currentActionAlert = alertInfo;
}

alertUnhandledError(error: Error) {
this.application.alertUnhandledError(error);
}

logDebug(message: string, ...data: unknown[]) {
this.application.logService.debug(
LogEvent.create(APPLICATION_EVENT.DEBUG),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
// we return undefined as we assume the grid license is set at the application level where query builder is built
return Promise.resolve({
gridClientLicense: undefined,
simpleSampleDataTableName: '',
complexSampleDataTableName: '',
});
}
override async getQueryTypeahead(
Expand Down Expand Up @@ -191,6 +193,16 @@ export class QueryBuilderDataCubeEngine extends DataCubeEngine {
);
}

override getQueryCode(
query: V1_ValueSpecification,
pretty?: boolean | undefined,
): Promise<string> {
return this.graphState.graphManager.valueSpecificationToPureCode(
V1_serializeValueSpecification(query, []),
pretty,
);
}

override getQueryRelationType(
query: V1_ValueSpecification,
): Promise<RelationType> {
Expand Down

0 comments on commit 9e1d1a3

Please sign in to comment.