Skip to content

Commit 578e653

Browse files
fix: compass readonly allows to drop namespaces from the sidebar COMPASS-6687 (#4266)
* fix: compass readonly allows to drop namespaces from the sidebar COMPASS-6687 * refactor: build isReadOnly at database sidebar navigation level * test: rename tests back
1 parent 1f064ba commit 578e653

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ const DatabasesNavigationTree: React.FunctionComponent<{
160160
__TEST_REACT_WINDOW_OVERSCAN = null,
161161
}) => {
162162
const listRef = useRef<List | null>(null);
163-
164163
const id = useId();
165164

166165
const items: TreeItem[] = useMemo(() => {

packages/compass-sidebar/src/components/sidebar-databases-navigation.ts renamed to packages/compass-sidebar/src/components/sidebar-databases-navigation.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ import toNS from 'mongodb-ns';
88
import { toggleDatabaseExpanded } from '../modules/databases';
99
import { withPreferences } from 'compass-preferences-model';
1010

11+
function SidebarDatabasesNavigation(
12+
dbNavigationProps: React.ComponentProps<typeof DatabasesNavigationTree> & {
13+
readOnly?: boolean;
14+
isDataLake?: boolean;
15+
isWritable?: boolean;
16+
}
17+
) {
18+
const isReadOnly =
19+
dbNavigationProps.readOnly ||
20+
dbNavigationProps.isDataLake ||
21+
!dbNavigationProps.isWritable;
22+
return (
23+
<DatabasesNavigationTree {...dbNavigationProps} isReadOnly={isReadOnly} />
24+
);
25+
}
26+
1127
function mapStateToProps(state: any) {
1228
// TODO: type state
1329
const {
@@ -79,4 +95,4 @@ const onNamespaceAction = (namespace: string, action: Actions) => {
7995
export default connect(mapStateToProps, {
8096
onDatabaseExpand: toggleDatabaseExpanded,
8197
onNamespaceAction,
82-
})(withPreferences(DatabasesNavigationTree, ['readOnly'], React));
98+
})(withPreferences(SidebarDatabasesNavigation, ['readOnly'], React));

0 commit comments

Comments
 (0)