Skip to content

Commit

Permalink
update baskets used in showcase examples to match server tables (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
heswell authored Nov 7, 2023
1 parent bf96238 commit 5389536
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 258 deletions.
7 changes: 3 additions & 4 deletions vuu-ui/showcase/src/examples/Apps/NewTheme.examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
registerComponent,
useLayoutContextMenuItems,
} from "@finos/vuu-layout";
import { ContextMenuProvider, Dialog, useDialog } from "@finos/vuu-popups";
import { ContextMenuProvider, useDialog } from "@finos/vuu-popups";
import {
FeatureConfig,
FeatureProps,
Expand Down Expand Up @@ -73,9 +73,8 @@ const features: FeatureProps[] = [
...featurePaths[env].BasketTrading,
ComponentProps: {
basketSchema: schemas.basket,
// basketDefinitionsSchema: schemas.basketDefinitions,
// basketDesignSchema: schemas.basketDesign,
// basketOrdersSchema: schemas.basketOrders,
basketTradingSchema: schemas.basketTrading,
basketTradingConstituentJoinSchema: schemas.basketTradingConstituentJoin,
instrumentsSchema: schemas.instruments,
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import { getSchema } from "@finos/vuu-data-test";
import { getAllSchemas } from "@finos/vuu-data-test";
import { LayoutProvider, registerComponent, View } from "@finos/vuu-layout";
import { Feature, FeatureProps, useLayoutManager } from "@finos/vuu-shell";
import { useCallback, useEffect } from "react";
import { BasketTradingFeature } from "../../features/BasketTrading.feature";
import { BasketTradingNoBasketsFeature } from "../../features/BasketTradingNoBaskets.feature";
import { BasketTradingOneBasketFeature } from "../../features/BasketTradingOneBasket.feature";
import { VuuBlotterHeader } from "./VuuBlotterHeader";

registerComponent("BasketTradingFeature", BasketTradingFeature, "view");

let displaySequence = 1;

export const DefaultBasketTradingFeature = () => {
const basketSchema = getSchema("basket");
// const basketDefinitionsSchema = getSchema("basketDefinitions");
// const basketDesignSchema = getSchema("basketDesign");
// const basketOrdersSchema = getSchema("basketOrders");
const instrumentsSchema = getSchema("instruments");
const schemas = getAllSchemas();
//-----------------------------------------------------------------------------------
// Note the following functionality is provided by the Shell in a full application.
// Likewise the Shell provides the LayoutProvider wrapper. Again, in a full Vuu
Expand Down Expand Up @@ -52,126 +46,19 @@ export const DefaultBasketTradingFeature = () => {
style={{ width: 1260, height: 600 }}
>
<BasketTradingFeature
basketSchema={basketSchema}
// basketDefinitionsSchema={basketDefinitionsSchema}
// basketDesignSchema={basketDesignSchema}
// basketOrdersSchema={basketOrdersSchema}
instrumentsSchema={instrumentsSchema}
basketSchema={schemas.basket}
basketTradingSchema={schemas.basketTrading}
basketTradingConstituentJoinSchema={
schemas.basketTradingConstituentJoin
}
instrumentsSchema={schemas.instruments}
/>
</View>
</LayoutProvider>
);
};
DefaultBasketTradingFeature.displaySequence = displaySequence++;

export const BasketTradingFeatureNoBaskets = () => {
const basketSchema = getSchema("basket");
// const basketDefinitionsSchema = getSchema("basketDefinitions");
// const basketDesignSchema = getSchema("basketDesign");
// const basketOrdersSchema = getSchema("basketOrders");
const instrumentsSchema = getSchema("instruments");

//-----------------------------------------------------------------------------------
// Note the following functionality is provided by the Shell in a full application.
// Likewise the Shell provides the LayoutProvider wrapper. Again, in a full Vuu
// application, the Palette wraps each feature in a View.
//-----------------------------------------------------------------------------------
const { applicationLayout, saveApplicationLayout } = useLayoutManager();

useEffect(() => {
console.log(`%clayout changed`, "color: blue; font-weight: bold;");
}, [applicationLayout]);

const handleLayoutChange = useCallback(
(layout) => {
console.log("layout change");
saveApplicationLayout(layout);
},
[saveApplicationLayout]
);
// ----------------------------------------------------------------------------------

return (
<LayoutProvider
layout={applicationLayout}
onLayoutChange={handleLayoutChange}
>
<View
Header={VuuBlotterHeader}
id="table-next-feature"
className="vuuTableNextFeature"
closeable
header
title="Instruments"
style={{ width: 1260, height: 600 }}
>
<BasketTradingNoBasketsFeature
basketSchema={basketSchema}
// basketDefinitionsSchema={basketDefinitionsSchema}
// basketDesignSchema={basketDesignSchema}
// basketOrdersSchema={basketOrdersSchema}
instrumentsSchema={instrumentsSchema}
/>
</View>
</LayoutProvider>
);
};
BasketTradingFeatureNoBaskets.displaySequence = displaySequence++;

export const BasketTradingFeatureOneBasket = () => {
const basketSchema = getSchema("basket");
// const basketDefinitionsSchema = getSchema("basketDefinitions");
// const basketDesignSchema = getSchema("basketDesign");
// const basketOrdersSchema = getSchema("basketOrders");
const instrumentsSchema = getSchema("instruments");

//-----------------------------------------------------------------------------------
// Note the following functionality is provided by the Shell in a full application.
// Likewise the Shell provides the LayoutProvider wrapper. Again, in a full Vuu
// application, the Palette wraps each feature in a View.
//-----------------------------------------------------------------------------------
const { applicationLayout, saveApplicationLayout } = useLayoutManager();

useEffect(() => {
console.log(`%clayout changed`, "color: blue; font-weight: bold;");
}, [applicationLayout]);

const handleLayoutChange = useCallback(
(layout) => {
console.log("layout change");
saveApplicationLayout(layout);
},
[saveApplicationLayout]
);
// ----------------------------------------------------------------------------------

return (
<LayoutProvider
layout={applicationLayout}
onLayoutChange={handleLayoutChange}
>
<View
Header={VuuBlotterHeader}
id="table-next-feature"
className="vuuTableNextFeature"
closeable
header
title="Instruments"
style={{ width: 1260, height: 600 }}
>
<BasketTradingOneBasketFeature
basketSchema={basketSchema}
// basketDefinitionsSchema={basketDefinitionsSchema}
// basketDesignSchema={basketDesignSchema}
// basketOrdersSchema={basketOrdersSchema}
instrumentsSchema={instrumentsSchema}
/>
</View>
</LayoutProvider>
);
};
BasketTradingFeatureOneBasket.displaySequence = displaySequence++;

type Environment = "development" | "production";
const env = process.env.NODE_ENV as Environment;
const featurePropsForEnv: Record<Environment, FeatureProps> = {
Expand All @@ -186,11 +73,7 @@ const featurePropsForEnv: Record<Environment, FeatureProps> = {

export const BasketTradingFeatureAsFeature = () => {
const { url, css } = featurePropsForEnv[env];
const basketSchema = getSchema("basket");
// const basketDefinitionsSchema = getSchema("basketDefinitions");
// const basketDesignSchema = getSchema("basketDesign");
// const basketOrdersSchema = getSchema("basketOrders");
const instrumentsSchema = getSchema("instruments");
const schemas = getAllSchemas();

return (
<View
Expand All @@ -204,11 +87,11 @@ export const BasketTradingFeatureAsFeature = () => {
>
<Feature
ComponentProps={{
basketSchema,
// basketDefinitionsSchema,
// basketDesignSchema,
// basketOrdersSchema,
instrumentsSchema,
basketSchema: schemas.basket,
basketTradingSchema: schemas.basketTrading,
basketTradingSchemaConstituentJoin:
schemas.basketTradingConstituentJoin,
instrumentsSchema: schemas.instruments,
}}
url={url}
css={css}
Expand Down
33 changes: 16 additions & 17 deletions vuu-ui/showcase/src/features/BasketTrading.feature.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,40 @@ import { createArrayDataSource } from "../examples/utils/createArrayDataSource";

export const BasketTradingFeature = ({
basketSchema,
// basketDefinitionsSchema,
// basketDesignSchema,
// basketOrdersSchema,
basketTradingSchema,
basketTradingConstituentJoinSchema,
instrumentsSchema,
}: BasketTradingFeatureProps) => {
const { saveSession } = useViewContext();

useMemo(() => {
const dataSourceConfig: [basketDataSourceKey, TableSchema, number?][] = [
["data-source-basket", basketSchema, 4],
// ["data-source-basket-definitions", basketDefinitionsSchema, 5],
// ["data-source-basket-definitions-search", basketDefinitionsSchema, 5],
// ["data-source-basket-design", basketDesignSchema],
// ["data-source-basket-orders", basketOrdersSchema],
const dataSourceConfig: [basketDataSourceKey, TableSchema][] = [
["data-source-basket", basketSchema],
["data-source-basket-trading-control", basketTradingSchema],
["data-source-basket-trading-search", basketTradingSchema],
[
"data-source-basket-trading-constituent-join",
basketTradingConstituentJoinSchema,
],
["data-source-instruments", instrumentsSchema],
];
for (const [key, schema, count] of dataSourceConfig) {
const dataSource = createArrayDataSource({ count, table: schema.table });
for (const [key, schema] of dataSourceConfig) {
const dataSource = createArrayDataSource({ table: schema.table });
saveSession?.(dataSource, key);
}
}, [
basketSchema,
// basketDefinitionsSchema,
// basketDesignSchema,
// basketOrdersSchema,
basketTradingConstituentJoinSchema,
basketTradingSchema,
instrumentsSchema,
saveSession,
]);

return (
<VuuBasketTradingFeature
basketSchema={basketSchema}
// basketDefinitionsSchema={basketDefinitionsSchema}
// basketDesignSchema={basketDesignSchema}
// basketOrdersSchema={basketOrdersSchema}
basketTradingSchema={basketTradingSchema}
basketTradingConstituentJoinSchema={basketTradingConstituentJoinSchema}
instrumentsSchema={instrumentsSchema}
/>
);
Expand Down
53 changes: 0 additions & 53 deletions vuu-ui/showcase/src/features/BasketTradingNoBaskets.feature.tsx

This file was deleted.

53 changes: 0 additions & 53 deletions vuu-ui/showcase/src/features/BasketTradingOneBasket.feature.tsx

This file was deleted.

0 comments on commit 5389536

Please sign in to comment.