mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-17 01:36:57 +00: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);
|
||||
}
|
||||
|
||||
// Update column definitions
|
||||
};
|
||||
|
||||
let loadNextPage = useCallback(
|
||||
@ -1225,11 +1223,14 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
|
||||
});
|
||||
|
||||
const extractColumnDefinitionsFromDocument = (document: unknown): ColumnDefinition[] => {
|
||||
let columnDefinitions: ColumnDefinition[] = Object.keys(document).map((key) =>
|
||||
key === "id"
|
||||
? { id: key, label: isPreferredApiMongoDB ? "_id" : "id", group: undefined }
|
||||
: { id: key, label: key, group: undefined },
|
||||
);
|
||||
let columnDefinitions: ColumnDefinition[] = Object.keys(document)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
.filter((key) => typeof (document as any)[key] === "string" || typeof (document as any)[key] === "number") // Only allow safe types for displayable React children
|
||||
.map((key) =>
|
||||
key === "id"
|
||||
? { id: key, label: isPreferredApiMongoDB ? "_id" : "id", group: undefined }
|
||||
: { id: key, label: key, group: undefined },
|
||||
);
|
||||
|
||||
if (showPartitionKey(_collection, isPreferredApiMongoDB)) {
|
||||
columnDefinitions.push(
|
||||
|
Loading…
x
Reference in New Issue
Block a user