Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
mabaasit committed Sep 19, 2024
1 parent bcbe0cc commit c747cb2
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 50 deletions.
6 changes: 3 additions & 3 deletions packages/compass-aggregations/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ const CompassAggregationsHadronPlugin = registerHadronPlugin(

export const CompassAggregationsPlugin = {
name: 'Aggregations' as const,
provider: CompassAggregationsHadronPlugin,
content: AggregationsPlugin,
header: AggregationsPluginName,
Provider: CompassAggregationsHadronPlugin,
Content: AggregationsPlugin,
Header: AggregationsPluginName,
};

export const CreateViewPlugin = registerHadronPlugin(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import type { CollectionSubtab } from '@mongodb-js/compass-workspaces';

export interface CollectionTabPlugin {
name: CollectionSubtab;
provider: HadronPluginComponent<CollectionTabPluginMetadata, any, any>;
content: React.FunctionComponent<CollectionTabPluginMetadata>;
header: React.FunctionComponent<CollectionTabPluginMetadata>;
Provider: HadronPluginComponent<CollectionTabPluginMetadata, any, any>;
Content: React.FunctionComponent<CollectionTabPluginMetadata>;
Header: React.FunctionComponent;
}

type CollectionTabComponentsProviderValue = {
tabs: CollectionTabPlugin[];
modals: CollectionTabPlugin['content'][];
queryBar: CollectionTabPlugin['content'];
modals: CollectionTabPlugin['Content'][];
queryBar: CollectionTabPlugin['Content'];
};

const defaultComponents: CollectionTabComponentsProviderValue = {
Expand Down
58 changes: 28 additions & 30 deletions packages/compass-collection/src/components/collection-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,38 +88,36 @@ type CollectionTabProps = Omit<CollectionTabOptions, 'tabId'> &
function useCollectionTabs(props: CollectionMetadata) {
const pluginTabs = useCollectionSubTabs();
const { log, mongoLogId } = useLogger('COMPASS-COLLECTION-TAB-UI');
return pluginTabs.map(
({ name, content: Content, provider: Provider, header: Header }) => {
// `pluginTabs` never change in runtime so it's safe to call the hook here
// eslint-disable-next-line react-hooks/rules-of-hooks
Provider.useActivate(props);
return {
name,
content: (
<ErrorBoundary
key={name}
onError={(error: Error, errorInfo: unknown) => {
log.error(
mongoLogId(1001000107),
'Collection Workspace',
'Rendering collection tab failed',
{ name: name, error: error.stack, errorInfo }
);
}}
>
<Provider {...props}>
<Content {...props} />
</Provider>
</ErrorBoundary>
),
title: (
return pluginTabs.map(({ name, Content, Provider, Header }) => {
// `pluginTabs` never change in runtime so it's safe to call the hook here
// eslint-disable-next-line react-hooks/rules-of-hooks
Provider.useActivate(props);
return {
name,
content: (
<ErrorBoundary
key={name}
onError={(error: Error, errorInfo: unknown) => {
log.error(
mongoLogId(1001000107),
'Collection Workspace',
'Rendering collection tab failed',
{ name, error: error.stack, errorInfo }
);
}}
>
<Provider {...props}>
<Header {...props} />
<Content {...props} />
</Provider>
),
};
}
);
</ErrorBoundary>
),
title: (
<Provider {...props}>
<Header />
</Provider>
),
};
});
}

const CollectionTabWithMetadata: React.FunctionComponent<
Expand Down
6 changes: 3 additions & 3 deletions packages/compass-crud/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ const CompassDocumentsHadronPlugin = registerHadronPlugin(

export const CompassDocumentsPlugin = {
name: 'Documents' as const,
provider: CompassDocumentsHadronPlugin,
content: DocumentList /* reflux store */,
header: CrudPluginName,
Provider: CompassDocumentsHadronPlugin,
Content: DocumentList as any, // as any because of reflux store
Header: CrudPluginName as any, // as any because of reflux store
};

export default DocumentList;
Expand Down
6 changes: 3 additions & 3 deletions packages/compass-indexes/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const CompassIndexesHadronPlugin = registerHadronPlugin(

export const CompassIndexesPlugin = {
name: 'Indexes' as const,
provider: CompassIndexesHadronPlugin,
content: Indexes,
header: IndexesPluginName,
Provider: CompassIndexesHadronPlugin,
Content: Indexes as React.FunctionComponent,
Header: IndexesPluginName as React.FunctionComponent,
};
6 changes: 3 additions & 3 deletions packages/compass-schema-validation/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const CompassSchemaValidationHadronPlugin = registerHadronPlugin(
);
export const CompassSchemaValidationPlugin = {
name: 'Validation' as const,
provider: CompassSchemaValidationHadronPlugin,
content: CompassSchemaValidation,
header: SchemaValidationPluginName,
Provider: CompassSchemaValidationHadronPlugin,
Content: CompassSchemaValidation,
Header: SchemaValidationPluginName,
};
6 changes: 3 additions & 3 deletions packages/compass-schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const CompassSchemaHadronPlugin = registerHadronPlugin(

export const CompassSchemaPlugin = {
name: 'Schema' as const,
provider: CompassSchemaHadronPlugin,
content: CompassSchema /* reflux store */,
header: SchemaPluginName,
Provider: CompassSchemaHadronPlugin,
Content: CompassSchema as React.FunctionComponent /* reflux store */,
Header: SchemaPluginName,
};

0 comments on commit c747cb2

Please sign in to comment.