Skip to content

Commit

Permalink
Refactor API key modal opening
Browse files Browse the repository at this point in the history
  • Loading branch information
Strift committed Feb 11, 2025
1 parent f2c0d06 commit 130a50b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Meilisearch
REACT_APP_MEILI_SERVER_ADDRESS=https://edge.meilisearch.com

# Hubspot newsletter
REACT_APP_HUBSPOT_PORTAL_ID=25945010
REACT_APP_HUBSPOT_FORM_GUID=991e2a09-77c2-4428-9242-ebf26bfc6c64
9 changes: 4 additions & 5 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import ApiKeyAwarenessBanner from 'components/ApiKeyAwarenessBanner'
import RightPanel from 'components/RightPanel'
import Header from 'components/Header'
import getIndexesListWithStats from 'utils/getIndexesListWithStats'
import shouldDisplayApiKeyModal from 'utils/shouldDisplayApiKeyModal'
import hasAnApiKeySet from 'utils/hasAnApiKeySet'
import clientAgents from './version/client-agents'

export const baseUrl =
Expand Down Expand Up @@ -106,9 +104,10 @@ const App = () => {
const isInstanceRunning = await meilisearchJsClient.isHealthy()
setIsMeilisearchRunning(isInstanceRunning)
if (isInstanceRunning) {
setRequireApiKeyToWork(await hasAnApiKeySet())
dialog.setVisible(await shouldDisplayApiKeyModal(meilisearchJsClient))
getIndexesList()
} else {
setRequireApiKeyToWork(true)
dialog.setVisible(true)
}
}
onClientUpdate()
Expand Down Expand Up @@ -149,7 +148,7 @@ const App = () => {
/>
</InstantSearch>
) : (
<NoMeilisearchRunning />
<NoMeilisearchRunning baseUrl={baseUrl} />
)}
<Modal dialog={dialog}>
<ApiKeyModalContent dialog={dialog} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/EmptyView.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const EmptyView = ({ buttonLink, children, ...props }) => (
alignItems="center"
flexDirection="column"
justifyContent="center"
maxWidth={264}
maxWidth={600}
m="auto"
{...props}
>
Expand Down
10 changes: 5 additions & 5 deletions src/components/NoMeilisearchRunning.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import EmptyView from 'components/EmptyView'
import BodyWrapper from 'components/BodyWrapper'
import Box from 'components/Box'

const NoMeilisearchRunning = () => (
const NoMeilisearchRunning = ({ baseUrl, errorMessage }) => (
<BodyWrapper>
<Box width={928} m="0 auto" py={4} display="flex" flexDirection="column">
<EmptyView buttonLink="https://docs.meilisearch.com/learn/getting_started/quick_start.html">
Expand All @@ -14,15 +14,15 @@ const NoMeilisearchRunning = () => (
mb={3}
color="gray.0"
>
It seems like Meilisearch isn’t running, did you forget to start it?
Cannot reach Meilisearch at <strong>{baseUrl}</strong>.
</Typography>
<Typography
variant="typo8"
style={{ textAlign: 'center' }}
mb={32}
color="gray.2"
mb={3}
color="gray.0"
>
(Don’t forget to set an API Key if you want one)
Check the provided URL and API Key.
</Typography>
<Typography
variant="typo8"
Expand Down
15 changes: 0 additions & 15 deletions src/utils/hasAnApiKeySet.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/utils/shouldDisplayApiKeyModal.js

This file was deleted.

0 comments on commit 130a50b

Please sign in to comment.