Skip to content

Commit 7eb2cb9

Browse files
committed
fixup: improve header interface, update workspace context provider typing
1 parent db1ee5d commit 7eb2cb9

File tree

19 files changed

+189
-144
lines changed

19 files changed

+189
-144
lines changed

packages/compass-collection/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { WorkspacePlugin } from '@mongodb-js/compass-workspaces';
1212
import { workspacesServiceLocator } from '@mongodb-js/compass-workspaces/provider';
1313
import {
1414
CollectionWorkspaceTitle,
15-
CollectionPluginTitle,
15+
CollectionPluginTitleComponent,
1616
} from './plugin-tab-title';
1717

1818
export const WorkspaceTab: WorkspacePlugin<typeof CollectionWorkspaceTitle> = {
@@ -32,7 +32,7 @@ export const WorkspaceTab: WorkspacePlugin<typeof CollectionWorkspaceTitle> = {
3232
}
3333
),
3434
content: CollectionTab,
35-
header: CollectionPluginTitle,
35+
header: CollectionPluginTitleComponent,
3636
};
3737

3838
export type { CollectionTabPluginMetadata } from './modules/collection-tab';

packages/compass-collection/src/plugin-tab-title.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,14 @@ const ConnectedPluginTitle = connect((state: CollectionState) => ({
9999
}))(_PluginTitle);
100100

101101
export const CollectionWorkspaceTitle = 'Collection' as const;
102-
export function CollectionPluginTitle(workspaceProps: WorkspaceProps) {
103-
return (tabProps: WorkspaceTabCoreProps) => {
104-
return (
105-
<ConnectedPluginTitle
106-
tabProps={tabProps}
107-
workspaceProps={workspaceProps}
108-
/>
109-
);
110-
};
102+
export function CollectionPluginTitleComponent({
103+
tabProps,
104+
workspaceProps,
105+
}: {
106+
tabProps: WorkspaceTabCoreProps;
107+
workspaceProps: WorkspaceProps;
108+
}) {
109+
return (
110+
<ConnectedPluginTitle tabProps={tabProps} workspaceProps={workspaceProps} />
111+
);
111112
}

packages/compass-data-modeling/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import DataModelingComponent from './components/data-modeling';
99
import { mongoDBInstancesManagerLocator } from '@mongodb-js/compass-app-stores/provider';
1010
import { dataModelStorageServiceLocator } from './provider';
1111
import { activateDataModelingStore } from './store';
12-
import { PluginTabTitle, WorkspaceName } from './plugin-tab-title';
12+
import { PluginTabTitleComponent, WorkspaceName } from './plugin-tab-title';
1313

1414
export const WorkspaceTab: WorkspacePlugin<typeof WorkspaceName> = {
1515
name: WorkspaceName,
@@ -31,5 +31,5 @@ export const WorkspaceTab: WorkspacePlugin<typeof WorkspaceName> = {
3131
}
3232
),
3333
content: DataModelingComponent,
34-
header: PluginTabTitle,
34+
header: PluginTabTitleComponent,
3535
};

packages/compass-data-modeling/src/plugin-tab-title.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,14 @@ const ConnectedTabTitle = connect((state: DataModelingState) => {
4242
};
4343
})(_TabTitle);
4444

45-
export function PluginTabTitle(workspaceProps: WorkspaceProps) {
46-
return (tabProps: WorkspaceTabCoreProps) => (
45+
export function PluginTabTitleComponent({
46+
tabProps,
47+
workspaceProps,
48+
}: {
49+
tabProps: WorkspaceTabCoreProps;
50+
workspaceProps: WorkspaceProps;
51+
}) {
52+
return (
4753
<ConnectedTabTitle tabProps={tabProps} workspaceProps={workspaceProps} />
4854
);
4955
}

packages/compass-saved-aggregations-queries/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from '@mongodb-js/my-queries-storage/provider';
1414
import { preferencesLocator } from 'compass-preferences-model/provider';
1515
import { connectionsLocator } from '@mongodb-js/compass-connections/provider';
16-
import { PluginTabTitle, WorkspaceName } from './plugin-tab-title';
16+
import { PluginTabTitleComponent, WorkspaceName } from './plugin-tab-title';
1717

1818
export const WorkspaceTab: WorkspacePlugin<typeof WorkspaceName> = {
1919
name: WorkspaceName,
@@ -37,5 +37,5 @@ export const WorkspaceTab: WorkspacePlugin<typeof WorkspaceName> = {
3737
}
3838
),
3939
content: AggregationsQueriesList,
40-
header: PluginTabTitle,
40+
header: PluginTabTitleComponent,
4141
};

packages/compass-saved-aggregations-queries/src/plugin-tab-title.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ import {
66

77
export const WorkspaceName = 'My Queries' as const;
88

9-
export function PluginTabTitle(workspaceProps: { id: string }) {
10-
return (tabProps: WorkspaceTabCoreProps) => (
9+
export function PluginTabTitleComponent({
10+
tabProps,
11+
workspaceProps,
12+
}: {
13+
tabProps: WorkspaceTabCoreProps;
14+
workspaceProps: { id: string };
15+
}) {
16+
return (
1117
<WorkspaceTab
1218
{...tabProps}
1319
id={workspaceProps.id}

packages/compass-serverstats/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import CurrentOpStore from './stores/current-op-store';
1111
import ServerStatsStore from './stores/server-stats-graphs-store';
1212
import TopStore from './stores/top-store';
1313
import type { WorkspacePlugin } from '@mongodb-js/compass-workspaces';
14-
import { WorkspaceName, ServerStatsPluginTitle } from './plugin-tab-title';
14+
import {
15+
WorkspaceName,
16+
ServerStatsPluginTitleComponent,
17+
} from './plugin-tab-title';
1518

1619
type PerformancePluginInitialProps = {};
1720

@@ -47,7 +50,7 @@ const WorkspaceTab: WorkspacePlugin<typeof WorkspaceName> = {
4750
}
4851
),
4952
content: PerformanceComponent,
50-
header: ServerStatsPluginTitle,
53+
header: ServerStatsPluginTitleComponent,
5154
};
5255

5356
export { WorkspaceTab };

packages/compass-serverstats/src/plugin-tab-title.tsx

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,32 @@ import {
1010

1111
export const WorkspaceName = 'Performance' as const;
1212

13-
export function ServerStatsPluginTitle(workspaceProps: {
14-
id: string;
15-
connectionId: string;
13+
export function ServerStatsPluginTitleComponent({
14+
tabProps,
15+
workspaceProps,
16+
}: {
17+
tabProps: WorkspaceTabCoreProps;
18+
workspaceProps: {
19+
id: string;
20+
connectionId: string;
21+
};
1622
}) {
17-
return (tabProps: WorkspaceTabCoreProps) => {
18-
const { getConnectionById } = useConnectionsListRef();
19-
const connectionName =
20-
getConnectionById(workspaceProps.connectionId)?.title || '';
23+
const { getConnectionById } = useConnectionsListRef();
24+
const connectionName =
25+
getConnectionById(workspaceProps.connectionId)?.title || '';
2126

22-
const { getThemeOf } = useTabConnectionTheme();
27+
const { getThemeOf } = useTabConnectionTheme();
2328

24-
return (
25-
<WorkspaceTab
26-
{...tabProps}
27-
id={workspaceProps.id}
28-
type={WorkspaceName}
29-
connectionName={connectionName}
30-
title={`Performance: ${connectionName}`}
31-
tooltip={[['Performance', connectionName || '']]}
32-
iconGlyph="Gauge"
33-
tabTheme={getThemeOf(workspaceProps.connectionId)}
34-
/>
35-
);
36-
};
29+
return (
30+
<WorkspaceTab
31+
{...tabProps}
32+
id={workspaceProps.id}
33+
type={WorkspaceName}
34+
connectionName={connectionName}
35+
title={`Performance: ${connectionName}`}
36+
tooltip={[['Performance', connectionName || '']]}
37+
iconGlyph="Gauge"
38+
tabTheme={getThemeOf(workspaceProps.connectionId)}
39+
/>
40+
);
3741
}

packages/compass-shell/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
connectionInfoRefLocator,
1212
type DataServiceLocator,
1313
} from '@mongodb-js/compass-connections/provider';
14-
import { WorkspaceName, ShellPluginTitle } from './plugin-tab-title';
14+
import { WorkspaceName, ShellPluginTitleComponent } from './plugin-tab-title';
1515

1616
export const WorkspaceTab: WorkspacePlugin<typeof WorkspaceName> = {
1717
name: WorkspaceName,
@@ -32,5 +32,5 @@ export const WorkspaceTab: WorkspacePlugin<typeof WorkspaceName> = {
3232
}
3333
),
3434
content: ShellPlugin,
35-
header: ShellPluginTitle,
35+
header: ShellPluginTitleComponent,
3636
};

packages/compass-shell/src/plugin-tab-title.tsx

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,31 @@ import {
1010

1111
export const WorkspaceName = 'Shell' as const;
1212

13-
export function ShellPluginTitle(workspaceProps: {
14-
id: string;
15-
connectionId: string;
13+
export function ShellPluginTitleComponent({
14+
tabProps,
15+
workspaceProps,
16+
}: {
17+
tabProps: WorkspaceTabCoreProps;
18+
workspaceProps: {
19+
id: string;
20+
connectionId: string;
21+
};
1622
}) {
17-
return (tabProps: WorkspaceTabCoreProps) => {
18-
const { getThemeOf } = useTabConnectionTheme();
19-
const { getConnectionById } = useConnectionsListRef();
23+
const { getThemeOf } = useTabConnectionTheme();
24+
const { getConnectionById } = useConnectionsListRef();
2025

21-
const connectionName =
22-
getConnectionById(workspaceProps.connectionId)?.title || '';
23-
return (
24-
<WorkspaceTab
25-
{...tabProps}
26-
id={workspaceProps.id}
27-
connectionName={connectionName}
28-
type={WorkspaceName}
29-
title={connectionName ? `mongosh: ${connectionName}` : 'MongoDB Shell'}
30-
tooltip={connectionName ? [['mongosh', connectionName]] : []}
31-
iconGlyph="Shell"
32-
tabTheme={getThemeOf(workspaceProps.connectionId)}
33-
/>
34-
);
35-
};
26+
const connectionName =
27+
getConnectionById(workspaceProps.connectionId)?.title || '';
28+
return (
29+
<WorkspaceTab
30+
{...tabProps}
31+
id={workspaceProps.id}
32+
connectionName={connectionName}
33+
type={WorkspaceName}
34+
title={connectionName ? `mongosh: ${connectionName}` : 'MongoDB Shell'}
35+
tooltip={connectionName ? [['mongosh', connectionName]] : []}
36+
iconGlyph="Shell"
37+
tabTheme={getThemeOf(workspaceProps.connectionId)}
38+
/>
39+
);
3640
}

0 commit comments

Comments
 (0)