Skip to content

Commit

Permalink
part 1 - start splitting repl and data cube
Browse files Browse the repository at this point in the history
  • Loading branch information
MauricioUyaguari committed Sep 20, 2024
1 parent db6c5f6 commit e11f157
Show file tree
Hide file tree
Showing 34 changed files with 680 additions and 363 deletions.
4 changes: 4 additions & 0 deletions .changeset/silver-pugs-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
'@finos/legend-application-data-cube': patch
'@finos/legend-application-repl': patch
---
6 changes: 6 additions & 0 deletions packages/legend-application-data-cube/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/build
/style
**/__mocks__/**
**/__tests__/**
/*.*
!tsconfig.json
1 change: 1 addition & 0 deletions packages/legend-application-data-cube/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @finos/legend-application-data-cube
3 changes: 3 additions & 0 deletions packages/legend-application-data-cube/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @finos/legend-application-data-cube

Legend Data Cube
24 changes: 24 additions & 0 deletions packages/legend-application-data-cube/_package.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export default {
publish: {
typescript: {
main: './tsconfig.publish.json',
others: ['./tsconfig.package.json'],
},
},
};
29 changes: 29 additions & 0 deletions packages/legend-application-data-cube/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { getBaseJestDOMProjectConfig } from '../../scripts/test/jest.config.base.js';
import { loadJSON } from '@finos/legend-dev-utils/DevUtils';
import { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';

const __dirname = dirname(fileURLToPath(import.meta.url));

const packageJson = loadJSON(resolve(__dirname, './package.json'));

export default getBaseJestDOMProjectConfig(
packageJson.name,
'packages/legend-application-data-cube',
);
65 changes: 65 additions & 0 deletions packages/legend-application-data-cube/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"name": "@finos/legend-application-data-cube",
"version": "0.0.0",
"description": "Legend Data Cube",
"keywords": [
"legend",
"legend-application",
"legend-data-cube",
"data-cube"
],
"homepage": "https://github.com/finos/legend-studio/tree/master/packages/legend-application-data-cube",
"bugs": {
"url": "https://github.com/finos/legend-studio/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/finos/legend-studio.git",
"directory": "packages/legend-application-data-cube"
},
"license": "Apache-2.0",
"sideEffects": false,
"type": "module",
"exports": {
".": "./lib/index.js",
"./lib/index.css": "./lib/index.css"
},
"module": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build": "yarn clean && yarn build:sass && yarn build:ts",
"build:sass": "cross-env INIT_CWD=$INIT_CWD node ../../scripts/workflow/buildSass.js",
"build:ts": "tsc --project ./tsconfig.build.json",
"clean": "npm-run-all clean:cache clean:lib",
"clean:cache": "rimraf \"build\"",
"clean:lib": "rimraf \"lib\"",
"dev": "npm-run-all --parallel dev:sass dev:ts",
"dev:sass": "sass style:lib --watch --load-path=../../node_modules/@finos/legend-art/scss",
"dev:ts": "tsc --watch --preserveWatchOutput",
"lint:js": "cross-env NODE_ENV=production eslint --cache --cache-location ./build/.eslintcache --report-unused-disable-directives --parser-options=project:\"./tsconfig.json\" \"./src/**/*.{js,ts,tsx}\"",
"publish:prepare": "node ../../scripts/release/preparePublishContent.js",
"publish:snapshot": "node ../../scripts/release/publishDevSnapshot.js",
"test": "jest",
"test:watch": "jest --watch"
},
"dependencies": {
"@finos/legend-application": "workspace:*"
},
"devDependencies": {
"@finos/legend-dev-utils": "workspace:*",
"@jest/globals": "29.7.0",
"cross-env": "7.0.3",
"eslint": "8.57.1",
"jest": "29.7.0",
"npm-run-all": "4.1.5",
"rimraf": "6.0.1",
"sass": "1.79.1",
"typescript": "5.6.2"
},
"peerDependencies": {
"react": "^18.0.0"
},
"publishConfig": {
"directory": "build/publishContent"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { GenericLegendApplicationStore } from '@finos/legend-application';

export class DataCubeStore {
readonly applicationStore: GenericLegendApplicationStore;

constructor(applicationStore: GenericLegendApplicationStore) {
this.applicationStore = applicationStore;
}
}
15 changes: 15 additions & 0 deletions packages/legend-application-data-cube/style/data-cube.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
17 changes: 17 additions & 0 deletions packages/legend-application-data-cube/style/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@forward 'data-cube';
9 changes: 9 additions & 0 deletions packages/legend-application-data-cube/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"tsBuildInfoFile": "build/prod.tsbuildinfo",
"jsx": "react-jsx"
},
"exclude": ["src/**/__tests__/**/*.*", "src/**/__mocks__/**/*.*"],
"references": [{ "path": "../legend-application/tsconfig.build.json" }]
}
11 changes: 11 additions & 0 deletions packages/legend-application-data-cube/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "@finos/legend-dev-utils/tsconfig.base.json",
"compilerOptions": {
"outDir": "lib",
"tsBuildInfoFile": "build/dev.tsbuildinfo",
"rootDir": "src",
"jsx": "react-jsxdev"
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.json"],
"references": [{ "path": "../legend-application" }]
}
9 changes: 9 additions & 0 deletions packages/legend-application-data-cube/tsconfig.package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "@finos/legend-dev-utils/tsconfig.base.json",
"compilerOptions": {
"outDir": "lib",
"tsBuildInfoFile": "build/package.tsbuildinfo",
"rootDir": "."
},
"include": ["package.json"]
}
4 changes: 4 additions & 0 deletions packages/legend-application-data-cube/tsconfig.publish.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.build.json",
"references": [{ "path": "./tsconfig.package.json" }]
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,22 @@ import {
Switch,
type TEMPORARY__ReactRouterComponentType,
} from '@finos/legend-application/browser';
import { DataCube } from './dataCube/DataCube.js';
import { LegendREPLFrameworkProvider } from './LegendREPLFrameworkProvider.js';
import { observer } from 'mobx-react-lite';
import { withREPLStore } from './REPLStoreProvider.js';
import { useREPLStore, withREPLStore } from './REPLStoreProvider.js';
import { BlockingActionAlert } from './repl/Alert.js';
import { DataCube } from './dataCube/DataCube.js';

export const LEGEND_REPL_GRID_CLIENT_ROUTE_PATTERN = Object.freeze({
DATA_CUBE: `/dataCube`,
});

export const ReplDataCube = observer(() => {
const repl = useREPLStore();

return <DataCube dataCubeStore={repl.dataCubeStore} />;
});

export const LegendREPLRouter = withREPLStore(
observer(() => (
<div className="app">
Expand All @@ -39,7 +45,7 @@ export const LegendREPLRouter = withREPLStore(
path={[LEGEND_REPL_GRID_CLIENT_ROUTE_PATTERN.DATA_CUBE]}
component={
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
DataCube as TEMPORARY__ReactRouterComponentType
ReplDataCube as TEMPORARY__ReactRouterComponentType
}
/>
</Switch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export const REPLStoreProvider = observer(
const store = useLocalObservable(() => new REPLStore(application));

useEffect(() => {
store.initialize().catch(application.logUnhandledError);
store.dataCubeStore.initialize().catch(application.logUnhandledError);
}, [store, application]);

if (!store.initState.hasSucceeded) {
if (!store.dataCubeStore.initState.hasSucceeded) {
return <></>;
}
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import { observer } from 'mobx-react-lite';
import { useREPLStore } from '../REPLStoreProvider.js';
import { useEffect } from 'react';
import { DataCubeGrid } from './grid/DataCubeGrid.js';
import { useApplicationStore } from '@finos/legend-application';
Expand All @@ -29,6 +28,7 @@ import {
import { LayoutManager } from '../repl/LayoutManager.js';
import type { DataCubeState } from '../../stores/dataCube/DataCubeState.js';
import { INTERNAL__MonacoEditorWidgetsRoot } from '../repl/PureCodeEditor.js';
import type { DataCubeStore } from '../../stores/dataCube/DataCubeStore.js';

const DataCubeStatusBar = observer((props: { dataCube: DataCubeState }) => {
const { dataCube } = props;
Expand Down Expand Up @@ -75,7 +75,6 @@ const DataCubeStatusBar = observer((props: { dataCube: DataCubeState }) => {

const DataCubeTitleBar = observer((props: { dataCube: DataCubeState }) => {
const { dataCube } = props;
const repl = useREPLStore();
const application = useApplicationStore();
const [openMenuDropdown, closeMenuDropdown, menuDropdownProps] =
useDropdownMenu();
Expand Down Expand Up @@ -123,7 +122,7 @@ const DataCubeTitleBar = observer((props: { dataCube: DataCubeState }) => {
<DropdownMenuItem
className="flex h-[22px] w-full items-center px-2.5 text-base hover:bg-neutral-100 focus:bg-neutral-100"
onClick={() => {
repl.settingsDisplay.open();
dataCube.store.settingsDisplay.open();
closeMenuDropdown();
}}
>
Expand All @@ -135,10 +134,10 @@ const DataCubeTitleBar = observer((props: { dataCube: DataCubeState }) => {
);
});

export const DataCube = observer(() => {
const repl = useREPLStore();
const application = useApplicationStore();
const dataCube = repl.dataCube;
export const DataCube = observer((props: { dataCubeStore: DataCubeStore }) => {
const { dataCubeStore } = props;
const application = dataCubeStore.application;
const dataCube = dataCubeStore.dataCubeState;

useEffect(() => {
dataCube.initialize().catch(application.logUnhandledError);
Expand All @@ -149,7 +148,7 @@ export const DataCube = observer(() => {
<DataCubeTitleBar dataCube={dataCube} />
<DataCubeGrid dataCube={dataCube} />
<DataCubeStatusBar dataCube={dataCube} />
<LayoutManager layoutManagerState={repl.layout} />
<LayoutManager layoutManagerState={dataCubeStore.layout} />

<INTERNAL__MonacoEditorWidgetsRoot />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export const DataCubeEditorColumnPropertiesPanel = observer(
Column Kind:
<FormDocumentation
className="ml-1"
dataCubeStore={dataCube.store}
documentationKey={
DocumentationKey.DATA_CUBE_COLUMN_KINDS
}
Expand Down Expand Up @@ -420,6 +421,7 @@ export const DataCubeEditorColumnPropertiesPanel = observer(
Dislay as Link?
<FormDocumentation
className="ml-1"
dataCubeStore={dataCube.store}
documentationKey={
DocumentationKey.DATA_CUBE_COLUMN_DISPLAY_AS_LINK
}
Expand Down Expand Up @@ -457,6 +459,7 @@ export const DataCubeEditorColumnPropertiesPanel = observer(
{`Missing Value Format:`}
<FormDocumentation
className="ml-1"
dataCubeStore={dataCube.store}
documentationKey={
DocumentationKey.DATA_CUBE_COLUMN_MISSING_VALUE_FORMAT
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export const DataCubeColumnCreator = observer(
Column Kind:
<FormDocumentation
className="ml-1"
dataCubeStore={dataCube.store}
documentationKey={
DocumentationKey.DATA_CUBE_EXTENDED_COLUMN_LEVELS
}
Expand Down
Loading

0 comments on commit e11f157

Please sign in to comment.