-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(databases-collections): handle non-existent namespaces COMPASS-5750
(#6664) * setup data for the feature * update sidebar * update database-collection * correct icon * update workspace tabs * rename property * fetch collstats only if db exists * clean up * checks and lint * fix log id and message * tests * correcct comment * correct color on grid * rename prop * also handle non-existent collections * fix check * react to changes * do mix with adapt ns info * border on hover * use spacing nums * text change * install
- Loading branch information
Showing
27 changed files
with
704 additions
and
175 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
packages/compass-connections-navigation/src/navigation-item-icon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import React from 'react'; | ||
import type { SidebarTreeItem } from './tree-data'; | ||
import { css, Icon, ServerIcon, Tooltip } from '@mongodb-js/compass-components'; | ||
import type { GlyphName } from '@mongodb-js/compass-components'; | ||
import { WithStatusMarker } from './with-status-marker'; | ||
import { isLocalhost } from 'mongodb-build-info'; | ||
|
||
const NON_EXISTANT_NAMESPACE_TEXT = | ||
'Your privileges grant you access to this namespace, but it does not currently exist'; | ||
|
||
const tooltipTriggerStyles = css({ | ||
display: 'flex', | ||
}); | ||
const IconWithTooltip = ({ | ||
text, | ||
glyph, | ||
}: { | ||
text: string; | ||
glyph: GlyphName; | ||
}) => { | ||
return ( | ||
<Tooltip | ||
align="bottom" | ||
justify="start" | ||
trigger={ | ||
<div className={tooltipTriggerStyles}> | ||
<Icon glyph={glyph} /> | ||
</div> | ||
} | ||
> | ||
{text} | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
export const NavigationItemIcon = ({ item }: { item: SidebarTreeItem }) => { | ||
if (item.type === 'database') { | ||
if (item.isNonExistent) { | ||
return ( | ||
<IconWithTooltip | ||
text={NON_EXISTANT_NAMESPACE_TEXT} | ||
glyph="EmptyDatabase" | ||
/> | ||
); | ||
} | ||
return <Icon glyph="Database" />; | ||
} | ||
if (item.type === 'collection') { | ||
if (item.isNonExistent) { | ||
return ( | ||
<IconWithTooltip | ||
text={NON_EXISTANT_NAMESPACE_TEXT} | ||
glyph="EmptyFolder" | ||
/> | ||
); | ||
} | ||
return <Icon glyph="Folder" />; | ||
} | ||
if (item.type === 'view') { | ||
return <Icon glyph="Visibility" />; | ||
} | ||
if (item.type === 'timeseries') { | ||
return <Icon glyph="TimeSeries" />; | ||
} | ||
if (item.type === 'connection') { | ||
const isFavorite = item.connectionInfo.savedConnectionType === 'favorite'; | ||
if (isFavorite) { | ||
return ( | ||
<WithStatusMarker status={item.connectionStatus}> | ||
<Icon glyph="Favorite" /> | ||
</WithStatusMarker> | ||
); | ||
} | ||
if (isLocalhost(item.connectionInfo.connectionOptions.connectionString)) { | ||
return ( | ||
<WithStatusMarker status={item.connectionStatus}> | ||
<Icon glyph="Laptop" /> | ||
</WithStatusMarker> | ||
); | ||
} | ||
return ( | ||
<WithStatusMarker status={item.connectionStatus}> | ||
<ServerIcon /> | ||
</WithStatusMarker> | ||
); | ||
} | ||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.