@sanity/embeddings-index-ui 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +25 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +25 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/isEnabled.tsx +10 -2
- package/src/embeddingsIndexDashboard/EmbeddingsIndexTool.tsx +20 -11
- package/src/referenceInput/SemanticSearchReferenceInput.tsx +7 -1
package/package.json
CHANGED
package/src/api/isEnabled.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import {createContext, PropsWithChildren, useContext, useEffect, useState} from
|
|
|
3
3
|
import {Card, Text} from '@sanity/ui'
|
|
4
4
|
import {useApiClient} from './embeddingsApiHooks'
|
|
5
5
|
|
|
6
|
-
export type FeatureStatus = 'enabled' | 'disabled' | 'loading'
|
|
6
|
+
export type FeatureStatus = 'enabled' | 'disabled' | 'loading' | 'error'
|
|
7
7
|
export const FeatureEnabledContext = createContext<FeatureStatus>('loading')
|
|
8
8
|
|
|
9
9
|
export function useIsFeatureEnabled() {
|
|
@@ -21,7 +21,7 @@ export function useIsFeatureEnabled() {
|
|
|
21
21
|
})
|
|
22
22
|
.catch((err) => {
|
|
23
23
|
console.error(err)
|
|
24
|
-
setStatus('
|
|
24
|
+
setStatus('error')
|
|
25
25
|
})
|
|
26
26
|
}, [client])
|
|
27
27
|
|
|
@@ -54,3 +54,11 @@ export function FeatureDisabledNotice(props: {urlSuffix?: string}) {
|
|
|
54
54
|
</Card>
|
|
55
55
|
)
|
|
56
56
|
}
|
|
57
|
+
|
|
58
|
+
export function FeatureError() {
|
|
59
|
+
return (
|
|
60
|
+
<Card padding={4} border tone="critical">
|
|
61
|
+
An error occurred. See console for details.
|
|
62
|
+
</Card>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
@@ -6,27 +6,36 @@ import {EditIndexDialog} from './IndexEditor'
|
|
|
6
6
|
import {IndexList} from './IndexList'
|
|
7
7
|
import {IndexInfo} from './IndexInfo'
|
|
8
8
|
import {useApiClient} from '../api/embeddingsApiHooks'
|
|
9
|
-
import {FeatureDisabledNotice, useIsFeatureEnabled} from '../api/isEnabled'
|
|
9
|
+
import {FeatureDisabledNotice, FeatureError, useIsFeatureEnabled} from '../api/isEnabled'
|
|
10
10
|
|
|
11
11
|
export function EmbeddingsIndexTool() {
|
|
12
12
|
const featureState = useIsFeatureEnabled()
|
|
13
13
|
return (
|
|
14
|
-
<Card>
|
|
14
|
+
<Card flex={1}>
|
|
15
15
|
<Flex justify="center" flex={1}>
|
|
16
|
-
{featureState
|
|
16
|
+
{featureState === 'error' ? (
|
|
17
|
+
<Box padding={4}>
|
|
18
|
+
<FeatureError />
|
|
19
|
+
</Box>
|
|
20
|
+
) : null}
|
|
21
|
+
|
|
22
|
+
{featureState === 'disabled' ? (
|
|
17
23
|
<Box padding={4}>
|
|
18
24
|
<FeatureDisabledNotice urlSuffix="?ref=embeddings-tab" />
|
|
19
25
|
</Box>
|
|
20
26
|
) : null}
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
{
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
{featureState === 'loading' ? (
|
|
29
|
+
<Box padding={6}>
|
|
30
|
+
<Spinner size={4} />
|
|
31
|
+
</Box>
|
|
32
|
+
) : null}
|
|
33
|
+
|
|
34
|
+
{featureState === 'enabled' ? (
|
|
35
|
+
<Card flex={1} style={{maxWidth: 1200}} padding={5}>
|
|
36
|
+
<Indexes />
|
|
37
|
+
</Card>
|
|
38
|
+
) : null}
|
|
30
39
|
</Flex>
|
|
31
40
|
</Card>
|
|
32
41
|
)
|
|
@@ -12,7 +12,7 @@ import {useCallback, useEffect, useMemo, useRef, useState} from 'react'
|
|
|
12
12
|
import {useDocumentPane} from 'sanity/desk'
|
|
13
13
|
import {QueryResult} from '../api/embeddingsApi'
|
|
14
14
|
import {publicId} from '../utils/id'
|
|
15
|
-
import {FeatureDisabledNotice, useIsFeatureEnabledContext} from '../api/isEnabled'
|
|
15
|
+
import {FeatureDisabledNotice, FeatureError, useIsFeatureEnabledContext} from '../api/isEnabled'
|
|
16
16
|
import {EmbeddingsIndexConfig} from '../schemas/typeDefExtensions'
|
|
17
17
|
import {SemanticSearchAutocomplete} from './SemanticSearchAutocomplete'
|
|
18
18
|
|
|
@@ -71,6 +71,12 @@ export function SemanticSearchReferenceInput(
|
|
|
71
71
|
<FeatureDisabledNotice urlSuffix="?ref=embeddings-ref" />
|
|
72
72
|
) : null}
|
|
73
73
|
|
|
74
|
+
{semantic && featureState === 'error' ? (
|
|
75
|
+
<Box padding={4}>
|
|
76
|
+
<FeatureError />
|
|
77
|
+
</Box>
|
|
78
|
+
) : null}
|
|
79
|
+
|
|
74
80
|
<Box flex={1} style={{maxHeight: 36, overflow: 'hidden'}}>
|
|
75
81
|
{semantic && featureState == 'enabled' ? (
|
|
76
82
|
<SemanticSearchInput {...props} indexConfig={config} />
|