@@ -47,6 +47,7 @@ import {
4747 getHighlightedFields ,
4848 relationshipToDiagramEdge ,
4949} from '../utils/nodes-and-edges' ;
50+ import toNS from 'mongodb-ns' ;
5051
5152const loadingContainerStyles = css ( {
5253 width : '100%' ,
@@ -57,14 +58,25 @@ const loaderStyles = css({
5758 margin : '0 auto' ,
5859} ) ;
5960
60- const bannerStyles = css ( {
61+ const errorBannerStyles = css ( {
6162 margin : spacing [ 200 ] ,
6263 '& > div' : {
6364 display : 'flex' ,
6465 alignItems : 'center' ,
6566 } ,
6667} ) ;
6768
69+ const dataInfoBannerStyles = css ( {
70+ margin : spacing [ 400 ] ,
71+ position : 'absolute' ,
72+ zIndex : 100 ,
73+
74+ h4 : {
75+ marginTop : 0 ,
76+ marginBottom : 0 ,
77+ } ,
78+ } ) ;
79+
6880const bannerButtonStyles = css ( {
6981 marginLeft : 'auto' ,
7082} ) ;
@@ -73,7 +85,7 @@ const ErrorBannerWithRetry: React.FunctionComponent<{
7385 onRetryClick : ( ) => void ;
7486} > = ( { children, onRetryClick } ) => {
7587 return (
76- < Banner variant = "danger" className = { bannerStyles } >
88+ < Banner variant = "danger" className = { errorBannerStyles } >
7789 < div > { children } </ div >
7890 < Button
7991 className = { bannerButtonStyles }
@@ -113,6 +125,8 @@ type SelectedItems = NonNullable<DiagramState>['selectedItems'];
113125
114126const DiagramContent : React . FunctionComponent < {
115127 diagramLabel : string ;
128+ database : string | null ;
129+ isNewlyCreatedDiagram ?: boolean ;
116130 model : StaticModel | null ;
117131 isInRelationshipDrawingMode : boolean ;
118132 editErrors ?: string [ ] ;
@@ -134,6 +148,8 @@ const DiagramContent: React.FunctionComponent<{
134148 onRelationshipDrawn : ( ) => void ;
135149} > = ( {
136150 diagramLabel,
151+ database,
152+ isNewlyCreatedDiagram,
137153 model,
138154 isInRelationshipDrawingMode,
139155 newCollection,
@@ -151,6 +167,9 @@ const DiagramContent: React.FunctionComponent<{
151167 const diagram = useRef ( useDiagram ( ) ) ;
152168 const { openDrawer } = useDrawerActions ( ) ;
153169 const { isDrawerOpen } = useDrawerState ( ) ;
170+ const [ showDataInfoBanner , setshowDataInfoBanner ] = useState (
171+ isNewlyCreatedDiagram ?? false
172+ ) ;
154173
155174 const setDiagramContainerRef = useCallback ( ( ref : HTMLDivElement | null ) => {
156175 if ( ref ) {
@@ -307,6 +326,20 @@ const DiagramContent: React.FunctionComponent<{
307326 data-testid = "diagram-editor-container"
308327 >
309328 < div className = { modelPreviewStyles } data-testid = "model-preview" >
329+ { showDataInfoBanner && (
330+ < Banner
331+ variant = "info"
332+ dismissible
333+ onClose = { ( ) => setshowDataInfoBanner ( false ) }
334+ className = { dataInfoBannerStyles }
335+ >
336+ < h4 > Worried about your data?</ h4 >
337+ This diagram was generated based on a sample of documents from{ ' ' }
338+ { database ?? 'a database' } . Changes made to the model here persist
339+ in the diagram for planning purposes only and will not impact your
340+ data.
341+ </ Banner >
342+ ) }
310343 < Diagram
311344 isDarkMode = { isDarkMode }
312345 title = { diagramLabel }
@@ -331,11 +364,16 @@ const DiagramContent: React.FunctionComponent<{
331364const ConnectedDiagramContent = connect (
332365 ( state : DataModelingState ) => {
333366 const { diagram } = state ;
367+ const model = diagram ? selectCurrentModelFromState ( state ) : null ;
334368 return {
335- model : diagram ? selectCurrentModelFromState ( state ) : null ,
369+ model,
336370 diagramLabel : diagram ?. name || 'Schema Preview' ,
337371 selectedItems : state . diagram ?. selectedItems ?? null ,
338372 newCollection : diagram ?. draftCollection ,
373+ isNewlyCreatedDiagram : diagram ?. isNewlyCreated ,
374+ database : model ?. collections [ 0 ] ?. ns
375+ ? toNS ( model . collections [ 0 ] . ns ) . database
376+ : null , // TODO(COMPASS-9718): use diagram.database
339377 } ;
340378 } ,
341379 {
0 commit comments