Skip to content

Commit 3b30da4

Browse files
committed
init
1 parent e7b7d3e commit 3b30da4

File tree

7 files changed

+86
-13
lines changed

7 files changed

+86
-13
lines changed

packages/compass-components/src/hooks/use-theme.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ enum Theme {
1111
export function useDarkMode(localDarkMode?: boolean): boolean | undefined {
1212
const darkMode = useLeafyGreenDarkMode(localDarkMode);
1313
return darkMode.darkMode;
14+
// return false;
1415
}
1516

1617
interface WithDarkModeProps {

packages/compass-connections-navigation/src/base-navigation-item.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ import {
55
css,
66
ItemActionControls,
77
cx,
8+
Badge,
9+
BadgeVariant,
810
} from '@mongodb-js/compass-components';
911
import { type Actions, ROW_HEIGHT } from './constants';
1012
import { ExpandButton } from './tree-item';
1113
import { type NavigationItemActions } from './item-actions';
14+
import type { SidebarTreeItem, SidebarActionableItem } from './tree-data';
1215

1316
type NavigationBaseItemProps = {
17+
item: SidebarTreeItem;
1418
name: string;
1519
isActive: boolean;
1620
isExpandVisible: boolean;
@@ -87,6 +91,7 @@ const actionControlsWrapperStyles = css({
8791
});
8892

8993
export const NavigationBaseItem: React.FC<NavigationBaseItemProps> = ({
94+
item,
9095
isActive,
9196
actionProps,
9297
name,
@@ -101,6 +106,26 @@ export const NavigationBaseItem: React.FC<NavigationBaseItemProps> = ({
101106
toggleExpand,
102107
children,
103108
}) => {
109+
// TODO: add extra UI stuff here
110+
111+
let isDisabled = false;
112+
let status = '';
113+
let variant = BadgeVariant.LightGray;
114+
if (item.type === 'connection') {
115+
const connectionInfo = item.connectionInfo;
116+
isDisabled =
117+
connectionInfo.atlasMetadata?.clusterState === 'DELETING' ||
118+
connectionInfo.atlasMetadata?.clusterState === 'PAUSED' ||
119+
connectionInfo.atlasMetadata?.clusterState === 'CREATING';
120+
if (isDisabled) {
121+
status = connectionInfo.atlasMetadata?.clusterState;
122+
if (status === 'CREATING') {
123+
variant = BadgeVariant.Blue;
124+
}
125+
console.log(status);
126+
}
127+
}
128+
104129
const [hoverProps, isHovered] = useHoverState();
105130
return (
106131
<div
@@ -127,6 +152,18 @@ export const NavigationBaseItem: React.FC<NavigationBaseItemProps> = ({
127152
{icon}
128153
<span title={name}>{name}</span>
129154
</div>
155+
{isDisabled && (
156+
<Badge
157+
variant={variant}
158+
className={css({
159+
verticalAlign: 'middle',
160+
marginLeft: spacing[100],
161+
})}
162+
data-testid="navigation-item-state-badge"
163+
>
164+
{status}
165+
</Badge>
166+
)}
130167
<div className={actionControlsWrapperStyles}>
131168
<ItemActionControls
132169
menuClassName={menuStyles}

packages/compass-connections-navigation/src/item-actions.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ export const notConnectedConnectionItemActions = ({
146146
connectionInfo: ConnectionInfo;
147147
connectionStatus: NotConnectedConnectionStatus;
148148
}): NavigationItemActions => {
149+
if (
150+
connectionInfo.atlasMetadata?.clusterState === 'DELETING' ||
151+
connectionInfo.atlasMetadata?.clusterState === 'PAUSED' ||
152+
connectionInfo.atlasMetadata?.clusterState === 'CREATING'
153+
) {
154+
return [];
155+
}
149156
const commonActions = commonConnectionItemActions({ connectionInfo });
150157
if (connectionStatus === 'connecting') {
151158
return commonActions;

packages/compass-connections-navigation/src/navigation-item.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,23 @@ export function NavigationItem({
111111
onItemExpand,
112112
getItemActions,
113113
}: NavigationItemProps) {
114+
let isDisabled = false;
115+
if (item.type === 'connection') {
116+
const connectionInfo = item.connectionInfo;
117+
isDisabled =
118+
connectionInfo.atlasMetadata?.clusterState === 'DELETING' ||
119+
connectionInfo.atlasMetadata?.clusterState === 'PAUSED' ||
120+
connectionInfo.atlasMetadata?.clusterState === 'CREATING';
121+
}
122+
114123
const isDarkMode = useDarkMode();
115124
const onAction = useCallback(
116125
(action: Actions) => {
117-
if (item.type !== 'placeholder') {
126+
if (item.type !== 'placeholder' || !isDisabled) {
118127
onItemAction(item, action);
119128
}
120129
},
121-
[item, onItemAction]
130+
[item, onItemAction, isDisabled]
122131
);
123132

124133
const style = useMemo(() => getTreeItemStyles(item), [item]);
@@ -201,17 +210,18 @@ export function NavigationItem({
201210
}, [item, isDarkMode]);
202211

203212
const toggleExpand = useCallback(() => {
204-
if (item.type !== 'placeholder') {
213+
if (item.type !== 'placeholder' || isDisabled) {
205214
onItemExpand(item, !item.isExpanded);
206215
}
207-
}, [onItemExpand, item]);
216+
}, [onItemExpand, item, isDisabled]);
208217

209218
return (
210219
<StyledNavigationItem item={item}>
211220
{item.type === 'placeholder' ? (
212221
<PlaceholderItem level={item.level} />
213222
) : (
214223
<NavigationBaseItem
224+
item={item}
215225
isActive={isActive}
216226
isFocused={isFocused}
217227
isExpanded={!!item.isExpanded}

packages/compass-connections-navigation/src/styled-navigation-item.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default function StyledNavigationItem({
3434
const style: AcceptedStyles = {};
3535
const isDisconnectedConnection =
3636
item.type === 'connection' && item.connectionStatus !== 'connected';
37+
3738
const isNonExistentNamespace =
3839
(item.type === 'database' || item.type === 'collection') &&
3940
item.isNonExistent;
@@ -44,12 +45,21 @@ export default function StyledNavigationItem({
4445
style['--item-bg-color-active'] = connectionColorToHexActive(colorCode);
4546
}
4647

47-
if (isDisconnectedConnection || isNonExistentNamespace) {
48+
if (isDisconnectedConnection) {
4849
style['--item-color'] = inactiveColor;
50+
const connectionInfo = item.connectionInfo;
51+
if (
52+
connectionInfo.atlasMetadata?.clusterState === 'DELETING' ||
53+
connectionInfo.atlasMetadata?.clusterState === 'PAUSED' ||
54+
connectionInfo.atlasMetadata?.clusterState === 'CREATING'
55+
) {
56+
style['--item-color-active'] = inactiveColor;
57+
}
4958
}
5059

5160
// For a non-existent namespace, even if its active, we show it as inactive
5261
if (isNonExistentNamespace) {
62+
style['--item-color'] = inactiveColor;
5363
style['--item-color-active'] = inactiveColor;
5464
}
5565
return style;

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,13 @@ export function buildConnectionInfoFromClusterDescription(
247247
};
248248
}
249249

250-
const CONNECTABLE_CLUSTER_STATES: AtlasClusterMetadata['clusterState'][] = [
250+
const VISIBLE_CLUSTER_STATES: AtlasClusterMetadata['clusterState'][] = [
251251
'IDLE',
252-
'REPARING',
252+
'REPAIRING',
253253
'UPDATING',
254+
'PAUSED',
255+
'CREATING',
256+
'DELETING',
254257
];
255258

256259
/**
@@ -288,20 +291,21 @@ export class AtlasCloudConnectionStorage
288291

289292
const connectionInfoList = (await res.json()) as ConnectionInfo[];
290293

291-
return connectionInfoList
294+
console.log(connectionInfoList);
295+
296+
const cil = connectionInfoList
292297
.map((connectionInfo: ConnectionInfo): ConnectionInfo | null => {
293298
if (
294-
!connectionInfo.connectionOptions.connectionString ||
295299
!connectionInfo.atlasMetadata ||
296-
// TODO(COMPASS-8228): do not filter out those connections, display
297-
// them in navigation, but in a way that doesn't allow connecting
298-
!CONNECTABLE_CLUSTER_STATES.includes(
300+
!VISIBLE_CLUSTER_STATES.includes(
299301
connectionInfo.atlasMetadata.clusterState
300302
)
301303
) {
302304
return null;
303305
}
304306

307+
console.log(connectionInfo);
308+
305309
const clusterName = connectionInfo.atlasMetadata.clusterName;
306310

307311
return {
@@ -323,6 +327,10 @@ export class AtlasCloudConnectionStorage
323327
.filter((connectionInfo): connectionInfo is ConnectionInfo => {
324328
return !!connectionInfo;
325329
});
330+
331+
console.log('FILTERED');
332+
console.log(cil);
333+
return cil;
326334
}
327335

328336
/**

packages/connection-info/src/connection-info.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export interface AtlasClusterMetadata {
4848
| 'UPDATING'
4949
| 'PAUSED'
5050
| 'IDLE'
51-
| 'REPARING'
51+
| 'REPAIRING'
5252
| 'DELETING'
5353
| 'DELETED';
5454

0 commit comments

Comments
 (0)