refactor(tableComponent): update column definitions to include checkbox selection logic for first column
feat(API): add support for excluding specific columns in getMessagesTable function fix(flowLogsModal): pass excludedFields parameter to getMessagesTable function refactor(GlobalVariablesPage): remove unnecessary checkbox selection properties from column definitions fix(messagesPage): pass excludedFields parameter to getMessagesTable function refactor(utils): add support for excluding specific columns in extractColumnsFromRows function
This commit is contained in:
parent
022ef7c028
commit
a99d0c7eb0
6 changed files with 31 additions and 11 deletions
|
|
@ -46,6 +46,18 @@ const TableComponent = forwardRef<
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const colDef = props.columnDefs.map((col, index) => {
|
||||||
|
if (props.onSelectionChanged && index === 0) {
|
||||||
|
return {
|
||||||
|
...col,
|
||||||
|
checkboxSelection: true,
|
||||||
|
headerCheckboxSelection: true,
|
||||||
|
headerCheckboxSelectionFilteredOnly: true,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
@ -60,6 +72,7 @@ const TableComponent = forwardRef<
|
||||||
defaultColDef={{
|
defaultColDef={{
|
||||||
minWidth: 100,
|
minWidth: 100,
|
||||||
}}
|
}}
|
||||||
|
columnDefs={colDef}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1024,6 +1024,7 @@ export async function getTransactionTable(
|
||||||
export async function getMessagesTable(
|
export async function getMessagesTable(
|
||||||
mode: "intersection" | "union",
|
mode: "intersection" | "union",
|
||||||
id?: string,
|
id?: string,
|
||||||
|
excludedFields?: string[],
|
||||||
params = {},
|
params = {},
|
||||||
): Promise<{ rows: Array<object>; columns: Array<ColDef | ColGroupDef> }> {
|
): Promise<{ rows: Array<object>; columns: Array<ColDef | ColGroupDef> }> {
|
||||||
const config = {};
|
const config = {};
|
||||||
|
|
@ -1034,6 +1035,6 @@ export async function getMessagesTable(
|
||||||
config["params"] = { ...config["params"], ...params };
|
config["params"] = { ...config["params"], ...params };
|
||||||
}
|
}
|
||||||
const rows = await api.get(`${BASE_URL_API}monitor/messages`, config);
|
const rows = await api.get(`${BASE_URL_API}monitor/messages`, config);
|
||||||
const columns = extractColumnsFromRows(rows.data, mode);
|
const columns = extractColumnsFromRows(rows.data, mode, excludedFields);
|
||||||
return { rows: rows.data, columns };
|
return { rows: rows.data, columns };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,13 @@ export default function FlowLogsModal({
|
||||||
setRows(rows);
|
setRows(rows);
|
||||||
});
|
});
|
||||||
} else if (activeTab === "Messages") {
|
} else if (activeTab === "Messages") {
|
||||||
getMessagesTable("union", currentFlowId).then((data) => {
|
getMessagesTable("union", currentFlowId, ["index", "flow_id"]).then(
|
||||||
const { columns, rows } = data;
|
(data) => {
|
||||||
setColumns(columns.map((col) => ({ ...col, editable: true })));
|
const { columns, rows } = data;
|
||||||
setRows(rows);
|
setColumns(columns.map((col) => ({ ...col, editable: true })));
|
||||||
});
|
setRows(rows);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (open && activeTab === "Messages" && !noticed.current) {
|
if (open && activeTab === "Messages" && !noticed.current) {
|
||||||
|
|
|
||||||
|
|
@ -78,9 +78,6 @@ export default function GlobalVariablesPage() {
|
||||||
// Column Definitions: Defines the columns to be displayed.
|
// Column Definitions: Defines the columns to be displayed.
|
||||||
const [colDefs, setColDefs] = useState<(ColDef<any> | ColGroupDef<any>)[]>([
|
const [colDefs, setColDefs] = useState<(ColDef<any> | ColGroupDef<any>)[]>([
|
||||||
{
|
{
|
||||||
headerCheckboxSelection: true,
|
|
||||||
checkboxSelection: true,
|
|
||||||
showDisabledCheckboxes: true,
|
|
||||||
headerName: "Variable Name",
|
headerName: "Variable Name",
|
||||||
field: "name",
|
field: "name",
|
||||||
flex: 2,
|
flex: 2,
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ export default function MessagesPage() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log("MessagesPage useEffect");
|
console.log("MessagesPage useEffect");
|
||||||
getMessagesTable("union").then((data) => {
|
getMessagesTable("union", undefined, ["index"]).then((data) => {
|
||||||
const { columns, rows } = data;
|
const { columns, rows } = data;
|
||||||
console.log(data);
|
console.log(data);
|
||||||
setColumns(columns.map((col) => ({ ...col, editable: true })));
|
setColumns(columns.map((col) => ({ ...col, editable: true })));
|
||||||
|
|
|
||||||
|
|
@ -354,8 +354,9 @@ export function isTimeStampString(str: string): boolean {
|
||||||
export function extractColumnsFromRows(
|
export function extractColumnsFromRows(
|
||||||
rows: object[],
|
rows: object[],
|
||||||
mode: "intersection" | "union",
|
mode: "intersection" | "union",
|
||||||
|
excludeColumns?: Array<string>,
|
||||||
): (ColDef<any> | ColGroupDef<any>)[] {
|
): (ColDef<any> | ColGroupDef<any>)[] {
|
||||||
const columnsKeys: { [key: string]: ColDef<any> | ColGroupDef<any> } = {};
|
let columnsKeys: { [key: string]: ColDef<any> | ColGroupDef<any> } = {};
|
||||||
if (rows.length === 0) {
|
if (rows.length === 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
@ -395,5 +396,11 @@ export function extractColumnsFromRows(
|
||||||
union();
|
union();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (excludeColumns) {
|
||||||
|
for (const key of excludeColumns) {
|
||||||
|
delete columnsKeys[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Object.values(columnsKeys);
|
return Object.values(columnsKeys);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue