mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-05-13 11:54:01 +01:00
Only allow data fields that can be rendered (string and numbers) in column selection
This commit is contained in:
parent
c0a79c1e67
commit
ce0cfed128
@ -1055,8 +1055,6 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
|
|||||||
);
|
);
|
||||||
setOnLoadStartKey(undefined);
|
setOnLoadStartKey(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update column definitions
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let loadNextPage = useCallback(
|
let loadNextPage = useCallback(
|
||||||
@ -1225,11 +1223,14 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
|
|||||||
});
|
});
|
||||||
|
|
||||||
const extractColumnDefinitionsFromDocument = (document: unknown): ColumnDefinition[] => {
|
const extractColumnDefinitionsFromDocument = (document: unknown): ColumnDefinition[] => {
|
||||||
let columnDefinitions: ColumnDefinition[] = Object.keys(document).map((key) =>
|
let columnDefinitions: ColumnDefinition[] = Object.keys(document)
|
||||||
key === "id"
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
? { id: key, label: isPreferredApiMongoDB ? "_id" : "id", group: undefined }
|
.filter((key) => typeof (document as any)[key] === "string" || typeof (document as any)[key] === "number") // Only allow safe types for displayable React children
|
||||||
: { id: key, label: key, group: undefined },
|
.map((key) =>
|
||||||
);
|
key === "id"
|
||||||
|
? { id: key, label: isPreferredApiMongoDB ? "_id" : "id", group: undefined }
|
||||||
|
: { id: key, label: key, group: undefined },
|
||||||
|
);
|
||||||
|
|
||||||
if (showPartitionKey(_collection, isPreferredApiMongoDB)) {
|
if (showPartitionKey(_collection, isPreferredApiMongoDB)) {
|
||||||
columnDefinitions.push(
|
columnDefinitions.push(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user