mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-26 15:37:02 +00:00
Accumulate properties rather than replace for column definitions
This commit is contained in:
parent
ce0cfed128
commit
bea3aa8b55
@ -1246,9 +1246,18 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
|
|||||||
return columnDefinitions;
|
return columnDefinitions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract column definitions from document and add to the definitions
|
||||||
|
* @param document
|
||||||
|
*/
|
||||||
const setColumnDefinitionsFromDocument = (document: unknown): void => {
|
const setColumnDefinitionsFromDocument = (document: unknown): void => {
|
||||||
// TODO Add fields rather than replace
|
const currentIds = new Set(columnDefinitions.map((columnDefinition) => columnDefinition.id));
|
||||||
setColumnDefinitions(extractColumnDefinitionsFromDocument(document));
|
extractColumnDefinitionsFromDocument(document).forEach((columnDefinition) => {
|
||||||
|
if (!currentIds.has(columnDefinition.id)) {
|
||||||
|
columnDefinitions.push(columnDefinition);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setColumnDefinitions([...columnDefinitions]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1359,6 +1368,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
|
|||||||
return () => resizeObserver.disconnect(); // clean up
|
return () => resizeObserver.disconnect(); // clean up
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// Column definition is a map<id, ColumnDefinition> to garantee uniqueness
|
||||||
const [columnDefinitions, setColumnDefinitions] = useState<ColumnDefinition[]>(() =>
|
const [columnDefinitions, setColumnDefinitions] = useState<ColumnDefinition[]>(() =>
|
||||||
extractColumnDefinitionsFromDocument({
|
extractColumnDefinitionsFromDocument({
|
||||||
id: "id",
|
id: "id",
|
||||||
|
Loading…
Reference in New Issue
Block a user