Skip to content

Commit 3bdc7eb

Browse files
rename connections to context using a provider for is atlas connections
1 parent ae127af commit 3bdc7eb

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

packages/compass-sidebar/src/components/multiple-connections/connections-navigation.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import toNS from 'mongodb-ns';
2-
import React, { useCallback, useEffect, useMemo } from 'react';
2+
import React, { useCallback, useContext, useEffect, useMemo } from 'react';
33
import { connect } from 'react-redux';
4+
import {
5+
connectionStorageLocator,
6+
IsAtlasConnectionStorageContext,
7+
} from '@mongodb-js/connection-storage/provider';
48
import {
59
ChevronCollapse,
610
type ItemAction,
@@ -477,14 +481,16 @@ const ConnectionsNavigation: React.FC<ConnectionsNavigationProps> = ({
477481
}
478482
}, [activeWorkspace, onDatabaseToggle, onConnectionToggle]);
479483

484+
const isAtlasConnectionStorage = useContext(IsAtlasConnectionStorageContext);
485+
480486
return (
481487
<div className={connectionsContainerStyles}>
482488
<div
483489
className={connectionListHeaderStyles}
484490
data-testid="connections-header"
485491
>
486492
<Subtitle className={connectionListHeaderTitleStyles}>
487-
Connections
493+
{isAtlasConnectionStorage ? 'Clusters' : 'Connections'}
488494
{connections.length !== 0 && (
489495
<span className={connectionCountStyles}>
490496
({connections.length})
@@ -503,7 +509,11 @@ const ConnectionsNavigation: React.FC<ConnectionsNavigationProps> = ({
503509
{connections.length > 0 && (
504510
<>
505511
<NavigationItemsFilter
506-
placeholder="Search connections"
512+
placeholder={
513+
isAtlasConnectionStorage
514+
? 'Search clusters'
515+
: 'Search connections'
516+
}
507517
filter={filter}
508518
onFilterChange={onFilterChange}
509519
/>

packages/compass-sidebar/src/components/multiple-connections/sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useState } from 'react';
1+
import React, { useCallback, useContext, useState } from 'react';
22
import { type MapStateToProps, connect } from 'react-redux';
33
import {
44
ConnectionStatus,

packages/compass-web/src/connection-storage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useContext, useRef } from 'react';
2+
import { IsAtlasConnectionStorageContext } from '@mongodb-js/connection-storage/provider';
23
import type {
34
ConnectionStorage,
45
ConnectionInfo,
@@ -374,7 +375,9 @@ export const AtlasCloudConnectionStorageProvider = createServiceProvider(
374375
<ConnectionStorageProvider
375376
value={sandboxConnectionStorage ?? storage.current}
376377
>
377-
{children}
378+
<IsAtlasConnectionStorageContext.Provider value={true}>
379+
{children}
380+
</IsAtlasConnectionStorageContext.Provider>
378381
</ConnectionStorageProvider>
379382
);
380383
}

packages/connection-storage/src/provider.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export const ConnectionStorageContext = createContext<ConnectionStorage | null>(
1515
null
1616
);
1717

18+
export const IsAtlasConnectionStorageContext = createContext<boolean>(false);
19+
1820
export const ConnectionStorageProvider = ConnectionStorageContext.Provider;
1921

2022
// TODO(COMPASS-7397): storage context should not be leaking out of the service

0 commit comments

Comments
 (0)