Skip to content

Commit 36741c0

Browse files
authored
Merge pull request #1463 from finos/shell-layout-left-tabs
refactor feature and datasource provider useFullHeightLeftPanel
2 parents e2a0e8f + 5ebffb9 commit 36741c0

42 files changed

Lines changed: 709 additions & 457 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { VuuDataSource, getServerAPI } from "@finos/vuu-data-remote";
2+
import { DataSourceProvider } from "@finos/vuu-utils";
3+
import { ReactNode } from "react";
4+
5+
export const VuuDataSourceProvider = ({
6+
children,
7+
}: {
8+
children: ReactNode;
9+
}) => (
10+
<DataSourceProvider
11+
VuuDataSource={VuuDataSource}
12+
getServerAPI={getServerAPI}
13+
isLocalData={false}
14+
>
15+
{children}
16+
</DataSourceProvider>
17+
);
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { getServerAPI } from "@finos/vuu-data-remote";
21
import type { TableSchema } from "@finos/vuu-data-types";
3-
import type { VuuTable } from "@finos/vuu-protocol-types";
2+
import { useDataSource } from "@finos/vuu-utils";
43
import { useCallback, useEffect, useState } from "react";
54

65
export const useVuuTables = () => {
76
const [tables, setTables] = useState<Map<string, TableSchema> | undefined>();
87

8+
const { getServerAPI } = useDataSource();
9+
910
const buildTables = useCallback((schemas: TableSchema[]) => {
1011
const vuuTables = new Map<string, TableSchema>();
1112
schemas.forEach((schema) => {
@@ -21,22 +22,19 @@ export const useVuuTables = () => {
2122
const { tables } = await server.getTableList();
2223
const tableSchemas = buildTables(
2324
await Promise.all(
24-
tables.map((vuuTable) => server.getTableSchema(vuuTable))
25-
)
25+
tables.map((vuuTable) => server.getTableSchema(vuuTable)),
26+
),
2627
);
2728
setTables(tableSchemas);
2829
} catch (err) {
2930
console.warn(
30-
`useVuuTables: unable to connect to Vuu server ${String(err)}`
31+
`useVuuTables: error fetching table metedata ${String(err)}`,
3132
);
3233
}
3334
}
3435

3536
fetchTableMetadata();
36-
}, [buildTables]);
37+
}, [buildTables, getServerAPI]);
3738

3839
return tables;
3940
};
40-
41-
export const getVuuTableSchema = (table: VuuTable) =>
42-
getServerAPI().then((server) => server.getTableSchema(table));

vuu-ui/packages/vuu-data-test/src/basket/basket-schemas.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { TableSchema } from "@finos/vuu-data-types";
2+
import { VuuTable } from "@finos/vuu-protocol-types";
23

34
export type BasketsTableName =
45
| "algoType"
@@ -128,3 +129,11 @@ export const schemas: Readonly<
128129
table: { module: "BASKET", table: "priceStrategyType" },
129130
},
130131
};
132+
133+
export type BasketVuuTable = {
134+
module: "BASKET";
135+
table: BasketsTableName;
136+
};
137+
138+
export const isBasketTable = (table: VuuTable): table is BasketVuuTable =>
139+
table.module === "BASKET";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export {
22
type BasketsTableName,
33
schemas as basketSchemas,
4+
isBasketTable,
45
} from "./basket-schemas";
56
export * from "./basket-module";
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import type {
2+
DataSourceConstructorProps,
3+
TableSchema,
4+
} from "@finos/vuu-data-types";
5+
import type { VuuTable, VuuTableList } from "@finos/vuu-protocol-types";
6+
import { basketModule, basketSchemas, isBasketTable } from "../basket";
7+
import { isSimulTable, simulModule, simulSchemas } from "../simul";
8+
import { ReactNode } from "react";
9+
import { DataSourceProvider } from "@finos/vuu-utils";
10+
11+
interface ServerAPI {
12+
getTableList: () => Promise<VuuTableList>;
13+
getTableSchema: (table: VuuTable) => Promise<TableSchema>;
14+
}
15+
16+
const serverAPI: ServerAPI = {
17+
getTableList: async () => {
18+
return {
19+
tables: Object.values(simulSchemas)
20+
.concat(Object.values(basketSchemas))
21+
.map((schema) => schema.table),
22+
};
23+
},
24+
getTableSchema: async (vuuTable: VuuTable) => {
25+
if (isSimulTable(vuuTable)) {
26+
return simulSchemas[vuuTable.table];
27+
} else if (isBasketTable(vuuTable)) {
28+
return basketSchemas[vuuTable.table];
29+
} else {
30+
throw Error(
31+
`unsupported module/table ${vuuTable.module}/${vuuTable.table}`,
32+
);
33+
}
34+
},
35+
};
36+
37+
const getServerAPI = async () => serverAPI;
38+
39+
class VuuDataSource {
40+
constructor({ table }: DataSourceConstructorProps) {
41+
if (isSimulTable(table)) {
42+
return simulModule.createDataSource(table.table);
43+
} else if (isBasketTable(table)) {
44+
return basketModule.createDataSource(table.table);
45+
} else {
46+
throw Error(`unsupported module/table ${table.module}/${table.table}`);
47+
}
48+
}
49+
}
50+
51+
export const LocalDataSourceProvider = ({
52+
children,
53+
modules,
54+
}: {
55+
children: ReactNode;
56+
modules: string[];
57+
}) => {
58+
return (
59+
<DataSourceProvider
60+
VuuDataSource={VuuDataSource as any}
61+
vuuModuleNames={modules}
62+
getServerAPI={getServerAPI}
63+
>
64+
{children}
65+
</DataSourceProvider>
66+
);
67+
};
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
export { type SimulTableName, schemas as simulSchemas } from "./simul-schemas";
1+
export {
2+
type SimulTableName,
3+
isSimulTable,
4+
schemas as simulSchemas,
5+
} from "./simul-schemas";
26
export * from "./simul-module";

vuu-ui/packages/vuu-data-test/src/simul/simul-module.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import {
44
VuuLink,
55
VuuMenu,
66
} from "@finos/vuu-protocol-types";
7+
import { MenuRpcResponse } from "@finos/vuu-data-types";
78
import { Table, buildDataColumnMap, joinTables } from "../Table";
9+
import { RpcService, RpcServiceRequest } from "../VuuModule";
10+
import { SimulModule } from "./SimulModule";
811
import { instrumentsTable } from "./reference-data/instruments";
912
import { instrumentsExtendedTable } from "./reference-data/instruments-extended";
1013
import { ordersTable } from "./reference-data/orders";
1114
import { pricesTable } from "./reference-data/prices";
1215
import { schemas, type SimulTableName } from "./simul-schemas";
13-
import { RpcService, RpcServiceRequest } from "../VuuModule";
14-
import { MenuRpcResponse } from "packages/vuu-data-types";
15-
import { SimulModule } from "./SimulModule";
1616

1717
const undefinedTables = {
1818
childOrders: undefined,
@@ -28,21 +28,21 @@ const tables: Record<SimulTableName, Table> = {
2828
childOrders: new Table(
2929
schemas.childOrders,
3030
[],
31-
buildDataColumnMap<SimulTableName>(schemas, "childOrders")
31+
buildDataColumnMap<SimulTableName>(schemas, "childOrders"),
3232
),
3333
instruments: instrumentsTable,
3434
instrumentsExtended: instrumentsExtendedTable,
3535
instrumentPrices: joinTables(
3636
{ module: "SIMUL", table: "instrumentPrices" },
3737
instrumentsTable,
3838
pricesTable,
39-
"ric"
39+
"ric",
4040
),
4141
orders: ordersTable,
4242
parentOrders: new Table(
4343
schemas.parentOrders,
4444
[],
45-
buildDataColumnMap<SimulTableName>(schemas, "parentOrders")
45+
buildDataColumnMap<SimulTableName>(schemas, "parentOrders"),
4646
),
4747
prices: pricesTable,
4848
};
@@ -94,7 +94,7 @@ const menus: Record<SimulTableName, VuuMenu | undefined> = {
9494
};
9595

9696
async function cancelOrder(
97-
rpcRequest: RpcServiceRequest
97+
rpcRequest: RpcServiceRequest,
9898
): Promise<Omit<MenuRpcResponse<ShowNotificationAction>, "requestId">> {
9999
const { rowKey } = rpcRequest as ClientToServerMenuRowRPC;
100100
const table = tables.orders;

vuu-ui/packages/vuu-data-test/src/simul/simul-schemas.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { TableSchema } from "@finos/vuu-data-types";
2+
import { VuuTable } from "@finos/vuu-protocol-types";
23

34
export type SimulTableName =
45
| "instruments"
@@ -143,3 +144,11 @@ export const schemas: Readonly<Record<SimulTableName, Readonly<TableSchema>>> =
143144
table: { module: "SIMUL", table: "prices" },
144145
},
145146
};
147+
148+
export type SimulVuuTable = {
149+
module: "SIMUL";
150+
table: SimulTableName;
151+
};
152+
153+
export const isSimulTable = (table: VuuTable): table is SimulVuuTable =>
154+
table.module === "SIMUL";

vuu-ui/packages/vuu-filters/src/filter-bar/FilterBar.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
calc(var(--salt-size-base) + var(--salt-spacing-100))
88
);
99
--vuuFilterEditor-height: var(--filterbar-height);
10+
--icon-container-height: auto;
1011
--flexbar-gap: var(--salt-spacing-100);
1112
--icon-marginTop: 0;
1213

@@ -27,6 +28,7 @@
2728
}
2829

2930
.vuuFilterBar-quick-filter {
31+
--icon-container-height: 100%;
3032
--icon-marginTop: 20px;
3133
--filterbar-height: var(
3234
--vuuFilterBar-height,
@@ -42,7 +44,7 @@
4244
}
4345

4446
.vuuFilterBar-iconContainer {
45-
height: 100%;
47+
height: var(--icon-container-height);
4648

4749
.saltToggleButtonGroup {
4850
margin-top: var(--icon-marginTop);

vuu-ui/packages/vuu-filters/src/filter-bar/FilterBar.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ export const FilterBar = ({
9393

9494
const startAdornment = useMemo(() => {
9595
if (!allowQuickFilters) {
96-
return <Icon name="tune" />;
97-
} else if (!allowCustomFilters) {
98-
return <Icon name="grid" />;
96+
return <Icon name="filter" size={16} style={{ top: 4 }} />;
9997
} else {
10098
return (
10199
<ToggleButtonGroup
@@ -124,14 +122,20 @@ export const FilterBar = ({
124122
</ToggleButtonGroup>
125123
);
126124
}
127-
}, [allowCustomFilters, allowQuickFilters, filterMode, onChangeFilterMode]);
125+
}, [allowQuickFilters, filterMode, onChangeFilterMode]);
128126

129127
return (
130128
<div
131129
{...htmlAttributes}
132-
className={cx(className, `${classBase}-${filterMode}`)}
130+
className={cx(
131+
className,
132+
`${classBase}-${variant}`,
133+
`${classBase}-${filterMode}`,
134+
)}
133135
>
134-
<div className={`${classBase}-iconContainer`}>{startAdornment}</div>
136+
{variant === "quick-filters" ? null : (
137+
<div className={`${classBase}-iconContainer`}>{startAdornment}</div>
138+
)}
135139
{filterMode === "custom-filter" ? (
136140
<CustomFilters
137141
columnDescriptors={columnDescriptors}

0 commit comments

Comments
 (0)