This commit is contained in:
Nishtha Ahuja 2025-02-21 15:25:24 +05:30
parent 82ea06e3d0
commit bde32664bd
2 changed files with 6 additions and 10 deletions

View File

@ -8,11 +8,7 @@ export interface MaterializedViewComponentProps {
}
export const MaterializedViewComponent: React.FC<MaterializedViewComponentProps> = ({ collection }) => {
// If this container itself defines a materialized view, skip rendering this component.
const isTargetContainer = !!collection?.materializedViewDefinition();
if (isTargetContainer) {
return null;
}
const isSourceContainer = !!collection?.materializedViews();
return (
<Stack tokens={{ childrenGap: 8 }} styles={{ root: { maxWidth: 600 } }}>
@ -26,7 +22,7 @@ export const MaterializedViewComponent: React.FC<MaterializedViewComponentProps>
about how to define materialized views and how to use them.
</Text>
</Stack>
<MaterializedViewSourceComponent collection={collection} />
{isSourceContainer && <MaterializedViewSourceComponent collection={collection} />}
</Stack>
);
};

View File

@ -20,11 +20,11 @@ export const MaterializedViewSourceComponent: React.FC<MaterializedViewSourceCom
let definition = "";
let partitionKey: string[] = [];
useDatabases.getState().databases.forEach((database) => {
database.collections().forEach((coll) => {
if (coll.id() === viewId) {
const materializedViewDefinition = coll.materializedViewDefinition();
database.collections().forEach((collection) => {
if (collection.id() === viewId) {
const materializedViewDefinition = collection.materializedViewDefinition();
materializedViewDefinition && (definition = materializedViewDefinition.definition);
coll.partitionKey?.paths && (partitionKey = coll.partitionKey.paths);
collection.partitionKey?.paths && (partitionKey = collection.partitionKey.paths);
}
});
});