Skip to content

Commit 4795a6e

Browse files
Merge branch 'main' into COMPASS-8451
2 parents 9d1d6a7 + 07fe9f0 commit 4795a6e

33 files changed

+789
-507
lines changed

THIRD-PARTY-NOTICES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The following third-party software is used by and included in **Mongodb Compass**.
2-
This document was automatically generated on Mon Nov 11 2024.
2+
This document was automatically generated on Fri Nov 15 2024.
33

44
## List of dependencies
55

docs/tracking-plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Compass Tracking Plan
33

4-
Generated on Mon, Nov 11, 2024 at 04:57 PM
4+
Generated on Fri, Nov 15, 2024 at 03:44 PM
55

66
## Table of Contents
77

packages/compass-collection/src/components/collection-tab.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { connect } from 'react-redux';
33
import { type CollectionState, selectTab } from '../modules/collection-tab';
44
import { css, ErrorBoundary, TabNavBar } from '@mongodb-js/compass-components';
55
import CollectionHeader from './collection-header';
6+
import toNS from 'mongodb-ns';
67
import { useLogger } from '@mongodb-js/compass-logging/provider';
78
import {
89
useCollectionQueryBar,
@@ -118,10 +119,10 @@ function WithErrorBoundary({
118119
function useCollectionTabs(props: CollectionMetadata) {
119120
const pluginTabs = useCollectionSubTabs();
120121
const connectionInfoRef = useConnectionInfoRef();
121-
const isGlobalWritesSupported = useConnectionSupports(
122-
connectionInfoRef.current.id,
123-
'globalWrites'
124-
);
122+
const isGlobalWritesSupported =
123+
useConnectionSupports(connectionInfoRef.current.id, 'globalWrites') &&
124+
!props.isReadonly &&
125+
!toNS(props.namespace).specialish;
125126
return pluginTabs
126127
.filter((x) => {
127128
if (x.name === 'GlobalWrites' && !isGlobalWritesSupported) {

packages/compass-components/src/components/interactive-popover.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { palette } from '@leafygreen-ui/palette';
88
import { rgba } from 'polished';
99
import { useDarkMode } from '../hooks/use-theme';
1010
import { useHotkeys } from '../hooks/use-hotkeys';
11-
import { useId } from '@react-aria/utils';
1211

1312
const borderRadius = spacing[2];
1413

@@ -162,7 +161,7 @@ function InteractivePopover({
162161

163162
useHotkeys('Escape', onClose, { enabled: open }, [onClose]);
164163

165-
const closeButtonId = useId('close-button-id');
164+
const closeButtonId = 'close-button-id';
166165

167166
return trigger({
168167
onClick: onClickTrigger,

packages/compass-components/src/components/item-action-controls.tsx

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export type ItemAction<Action extends string> = {
2929
disabledDescription?: string;
3030
tooltip?: string;
3131
actionButtonClassName?: string;
32+
/** How to show the item when not collapsed into the menu */
33+
expandedPresentation?: 'icon' | 'button';
3234
};
3335

3436
export type ItemSeparator = { separator: true };
@@ -343,26 +345,42 @@ export function ItemActionGroup<Action extends string>({
343345
tooltip,
344346
tooltipProps,
345347
actionButtonClassName,
348+
expandedPresentation = 'icon',
346349
} = menuItem;
347-
const button = (
348-
<ItemActionButton
349-
key={action}
350-
glyph={icon}
351-
label={label}
352-
title={!tooltip ? label : undefined}
353-
size={iconSize}
354-
data-action={action}
355-
data-testid={actionTestId<Action>(dataTestId, action)}
356-
onClick={onClick}
357-
className={cx(
358-
actionGroupButtonStyle,
359-
iconClassName,
360-
actionButtonClassName
361-
)}
362-
style={iconStyle}
363-
disabled={isDisabled}
364-
/>
365-
);
350+
const button =
351+
expandedPresentation === 'icon' ? (
352+
<ItemActionButton
353+
key={action}
354+
glyph={icon}
355+
label={label}
356+
title={!tooltip ? label : undefined}
357+
size={iconSize}
358+
data-action={action}
359+
data-testid={actionTestId<Action>(dataTestId, action)}
360+
onClick={onClick}
361+
className={cx(
362+
actionGroupButtonStyle,
363+
iconClassName,
364+
actionButtonClassName
365+
)}
366+
style={iconStyle}
367+
disabled={isDisabled}
368+
/>
369+
) : (
370+
<Button
371+
key={action}
372+
title={!tooltip ? label : undefined}
373+
size={iconSize}
374+
data-action={action}
375+
data-testid={actionTestId<Action>(dataTestId, action)}
376+
onClick={onClick}
377+
className={actionButtonClassName}
378+
style={iconStyle}
379+
disabled={isDisabled}
380+
>
381+
{label}
382+
</Button>
383+
);
366384

367385
if (tooltip) {
368386
return (

packages/compass-components/src/hooks/use-sort.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('use-sort', function () {
5757
expect(
5858
screen
5959
.getByRole('button', {
60-
name: /title/i,
60+
name: 'Sort by',
6161
})
6262
.getAttribute('aria-disabled')
6363
).to.equal('true');
@@ -70,7 +70,7 @@ describe('use-sort', function () {
7070
// Opens dropdown
7171
userEvent.click(
7272
screen.getByRole('button', {
73-
name: /title/i,
73+
name: 'Sort by',
7474
}),
7575
undefined,
7676
{
@@ -111,7 +111,7 @@ describe('use-sort', function () {
111111
// Opens dropdown
112112
userEvent.click(
113113
screen.getByRole('button', {
114-
name: /title/i,
114+
name: 'Sort by',
115115
}),
116116
undefined,
117117
{
@@ -141,7 +141,7 @@ describe('use-sort', function () {
141141
// Opens dropdown
142142
userEvent.click(
143143
screen.getByRole('button', {
144-
name: /title/i,
144+
name: 'Sort by',
145145
}),
146146
undefined,
147147
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function useSortControls<T extends string>(
4343
items: readonly { name: T; label: string }[],
4444
options?: SortOptions
4545
): [React.ReactElement, SortState<Unwrap<typeof items>['name']>] {
46-
const labelId = useId('Sort by');
46+
const labelId = 'sort-by';
4747
const controlId = useId();
4848

4949
const [sortState, dispatch] = useReducer(

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type NavigationBaseItemProps = {
1717
isExpandDisabled: boolean;
1818
isExpanded: boolean;
1919
isFocused: boolean;
20+
hasDefaultAction: boolean;
2021
icon: React.ReactNode;
2122
style: React.CSSProperties;
2223

@@ -37,7 +38,6 @@ const menuStyles = css({
3738
});
3839

3940
const itemContainerStyles = css({
40-
cursor: 'pointer',
4141
color: 'var(--item-color)',
4242
backgroundColor: 'var(--item-bg-color)',
4343
'&[data-is-active="true"] .item-wrapper': {
@@ -53,6 +53,10 @@ const itemContainerStyles = css({
5353
},
5454
});
5555

56+
const itemContainerWithActionStyles = css({
57+
cursor: 'pointer',
58+
});
59+
5660
const itemWrapperStyles = css({
5761
display: 'flex',
5862
height: ROW_HEIGHT,
@@ -93,14 +97,17 @@ export const NavigationBaseItem: React.FC<NavigationBaseItemProps> = ({
9397
isExpandDisabled,
9498
isExpanded,
9599
isFocused,
100+
hasDefaultAction,
96101
onExpand,
97102
children,
98103
}) => {
99104
const [hoverProps, isHovered] = useHoverState();
100105
return (
101106
<div
102107
data-testid="base-navigation-item"
103-
className={itemContainerStyles}
108+
className={cx(itemContainerStyles, {
109+
[itemContainerWithActionStyles]: hasDefaultAction,
110+
})}
104111
{...hoverProps}
105112
{...dataAttributes}
106113
>

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ const ConnectionsNavigationTree: React.FunctionComponent<
8787
if (item.type === 'connection') {
8888
if (item.connectionStatus === 'connected') {
8989
onItemAction(item, 'select-connection');
90-
} else {
91-
onItemAction(item, 'connection-connect');
9290
}
9391
} else if (item.type === 'database') {
9492
onItemAction(item, 'select-database');
@@ -187,7 +185,7 @@ const ConnectionsNavigationTree: React.FunctionComponent<
187185
connectionInfo: item.connectionInfo,
188186
}),
189187
config: {
190-
collapseAfter: 0,
188+
collapseAfter: 1,
191189
},
192190
};
193191
}

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { type ItemSeparator } from '@mongodb-js/compass-components';
55

66
export type NavigationItemActions = (ItemAction<Actions> | ItemSeparator)[];
77

8-
export const notConnectedConnectionItemActions = ({
8+
export const commonConnectionItemActions = ({
99
connectionInfo,
1010
}: {
1111
connectionInfo: ConnectionInfo;
@@ -81,7 +81,7 @@ export const connectedConnectionItemActions = ({
8181
isShellEnabled: boolean;
8282
}): NavigationItemActions => {
8383
const isAtlas = !!connectionInfo.atlasMetadata;
84-
const connectionManagementActions = notConnectedConnectionItemActions({
84+
const connectionManagementActions = commonConnectionItemActions({
8585
connectionInfo,
8686
});
8787
const actions: (ItemAction<Actions> | ItemSeparator | null)[] = [
@@ -135,6 +135,23 @@ export const connectedConnectionItemActions = ({
135135
});
136136
};
137137

138+
export const notConnectedConnectionItemActions = ({
139+
connectionInfo,
140+
}: {
141+
connectionInfo: ConnectionInfo;
142+
}): NavigationItemActions => {
143+
const commonActions = commonConnectionItemActions({ connectionInfo });
144+
return [
145+
{
146+
action: 'connection-connect',
147+
label: 'Connect',
148+
icon: 'Connect',
149+
expandedPresentation: 'button',
150+
},
151+
...commonActions,
152+
];
153+
};
154+
138155
export const databaseItemActions = ({
139156
hasWriteActionsDisabled,
140157
}: {

0 commit comments

Comments
 (0)