@@ -16,7 +16,7 @@ import Modal from 'components/Modal'
1616import NoMeilisearchRunning from 'components/NoMeilisearchRunning'
1717import ApiKeyAwarenessBanner from 'components/ApiKeyAwarenessBanner'
1818import getIndexesListWithStats from 'utils/getIndexesListWithStats'
19- import shouldDisplayCloudBanner from 'utils/shouldDisplayCloudBanner '
19+ import isCloudBannerEnabled from 'utils/isCloudBannerEnabled '
2020import shouldDisplayApiKeyModal from 'utils/shouldDisplayApiKeyModal'
2121import hasAnApiKeySet from 'utils/hasAnApiKeySet'
2222import clientAgents from './version/client-agents'
@@ -78,9 +78,8 @@ const App = () => {
7878 } , [ ] )
7979
8080 useEffect ( ( ) => {
81- const shouldCloudBannerBeDisplayed = shouldDisplayCloudBanner ( )
82- if ( shouldCloudBannerBeDisplayed ) {
83- setShowCloudBanner ( shouldCloudBannerBeDisplayed )
81+ if ( isCloudBannerEnabled ( ) ) {
82+ setShowCloudBanner ( true )
8483 }
8584 getApiKeyFromUrl ( )
8685 } , [ ] )
@@ -115,6 +114,20 @@ const App = () => {
115114 onClientUpdate ( )
116115 } , [ meilisearchJsClient ] )
117116
117+ const handleCloudBannerClose = ( ) => {
118+ setShowCloudBanner ( false )
119+ localStorage . setItem ( 'bannerVisibility' , JSON . stringify ( false ) )
120+ }
121+
122+ // Retrieve the banner visibility state from local storage on component mount
123+ React . useEffect ( ( ) => {
124+ const storedVisibility = localStorage . getItem ( 'bannerVisibility' )
125+ if ( storedVisibility ) {
126+ setShowCloudBanner ( JSON . parse ( storedVisibility ) )
127+ }
128+ return ( ) => { }
129+ } , [ ] )
130+
118131 return (
119132 < ApiKeyContext . Provider value = { { apiKey, setApiKey } } >
120133 < Wrapper >
@@ -123,7 +136,12 @@ const App = () => {
123136 onClose = { ( ) => setIsApiKeyBannerVisible ( false ) }
124137 />
125138 ) }
126- { showCloudBanner && < CloudBanner /> }
139+ { showCloudBanner && (
140+ < CloudBanner
141+ handleBannerClose = { handleCloudBannerClose }
142+ isBannerVisible = { showCloudBanner }
143+ />
144+ ) }
127145 { isMeilisearchRunning ? (
128146 < Body
129147 currentIndex = { currentIndex }
@@ -132,6 +150,7 @@ const App = () => {
132150 requireApiKeyToWork = { requireApiKeyToWork }
133151 getIndexesList = { getIndexesList }
134152 isApiKeyBannerVisible = { isApiKeyBannerVisible }
153+ isCloudBannerVisible = { showCloudBanner }
135154 />
136155 ) : (
137156 < NoMeilisearchRunning />
0 commit comments