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

View File

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