@@ -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 }
@@ -108,6 +120,8 @@ type SelectedItems = NonNullable<DiagramState>['selectedItems'];
108120
109121const DiagramContent : React . FunctionComponent < {
110122 diagramLabel : string ;
123+ database : string | null ;
124+ isNewlyCreatedDiagram ?: boolean ;
111125 model : StaticModel | null ;
112126 isInRelationshipDrawingMode : boolean ;
113127 editErrors ?: string [ ] ;
@@ -129,6 +143,8 @@ const DiagramContent: React.FunctionComponent<{
129143 onRelationshipDrawn : ( ) => void ;
130144} > = ( {
131145 diagramLabel,
146+ database,
147+ isNewlyCreatedDiagram,
132148 model,
133149 isInRelationshipDrawingMode,
134150 newCollection,
@@ -146,6 +162,9 @@ const DiagramContent: React.FunctionComponent<{
146162 const diagram = useRef ( useDiagram ( ) ) ;
147163 const { openDrawer } = useDrawerActions ( ) ;
148164 const { isDrawerOpen } = useDrawerState ( ) ;
165+ const [ showDataInfoBanner , setshowDataInfoBanner ] = useState (
166+ isNewlyCreatedDiagram ?? false
167+ ) ;
149168
150169 const setDiagramContainerRef = useCallback ( ( ref : HTMLDivElement | null ) => {
151170 if ( ref ) {
@@ -255,6 +274,20 @@ const DiagramContent: React.FunctionComponent<{
255274 data-testid = "diagram-editor-container"
256275 >
257276 < div className = { modelPreviewStyles } data-testid = "model-preview" >
277+ { showDataInfoBanner && (
278+ < Banner
279+ variant = "info"
280+ dismissible
281+ onClose = { ( ) => setshowDataInfoBanner ( false ) }
282+ className = { dataInfoBannerStyles }
283+ >
284+ < h4 > Worried about your data?</ h4 >
285+ This diagram was generated based on a sample of documents from{ ' ' }
286+ { database ?? 'a database' } . Changes made to the model here persist
287+ in the diagram for planning purposes only and will not impact your
288+ data.
289+ </ Banner >
290+ ) }
258291 < Diagram
259292 isDarkMode = { isDarkMode }
260293 title = { diagramLabel }
@@ -300,11 +333,16 @@ const DiagramContent: React.FunctionComponent<{
300333const ConnectedDiagramContent = connect (
301334 ( state : DataModelingState ) => {
302335 const { diagram } = state ;
336+ const model = diagram ? selectCurrentModelFromState ( state ) : null ;
303337 return {
304- model : diagram ? selectCurrentModelFromState ( state ) : null ,
338+ model,
305339 diagramLabel : diagram ?. name || 'Schema Preview' ,
306340 selectedItems : state . diagram ?. selectedItems ?? null ,
307341 newCollection : diagram ?. draftCollection ,
342+ isNewlyCreatedDiagram : diagram ?. isNewlyCreated ,
343+ database : model ?. collections [ 0 ] ?. ns
344+ ? toNS ( model . collections [ 0 ] . ns ) . database
345+ : null , // TODO(COMPASS-9718): use diagram.database
308346 } ;
309347 } ,
310348 {
0 commit comments