소스 검색

disable select when no collection available

tumao 4 년 전
부모
커밋
07dc895e43
4개의 변경된 파일12개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 0
      client/src/i18n/cn/search.ts
  2. 1 0
      client/src/i18n/en/search.ts
  3. 2 1
      client/src/pages/seach/SearchParams.tsx
  4. 8 2
      client/src/pages/seach/VectorSearch.tsx

+ 1 - 0
client/src/i18n/cn/search.ts

@@ -4,6 +4,7 @@ const searchTrans = {
   thirdTip: '3. Set search parameters',
   vectorPlaceholder: 'Please input your vector value here, e.g. [1, 2, 3, 4]',
   collection: 'Choose Collection',
+  noCollection: 'No collection',
   field: 'Choose Field',
   startTip: 'Start your vector search',
   empty: 'No result',

+ 1 - 0
client/src/i18n/en/search.ts

@@ -4,6 +4,7 @@ const searchTrans = {
   thirdTip: '3. Set search parameters',
   vectorPlaceholder: 'Please input your vector value here, e.g. [1, 2, 3, 4]',
   collection: 'Choose Collection',
+  noCollection: 'No collection',
   field: 'Choose Field',
   startTip: 'Start your vector search',
   empty: 'No result',

+ 2 - 1
client/src/pages/seach/SearchParams.tsx

@@ -240,7 +240,8 @@ const SearchParams: FC<SearchParamsProps> = ({
           // not selectable now, so not set onChange event
         }}
         // not selectable now
-        readOnly={true}
+        // readOnly can't avoid all events, so we use disabled instead
+        disabled={true}
       />
 
       {/* dynamic params, now every type only has one param except metric type */}

+ 8 - 2
client/src/pages/seach/VectorSearch.tsx

@@ -295,7 +295,12 @@ const VectorSearch = () => {
             options={collectionOptions}
             wrapperClass={classes.selector}
             variant="filled"
-            label={searchTrans('collection')}
+            label={
+              collectionOptions.length === 0
+                ? searchTrans('noCollection')
+                : searchTrans('collection')
+            }
+            disabled={collectionOptions.length === 0}
             value={selectedCollection}
             onChange={(e: { target: { value: unknown } }) => {
               const collection = e.target.value;
@@ -306,7 +311,8 @@ const VectorSearch = () => {
           />
           <CustomSelector
             options={fieldOptions}
-            readOnly={selectedCollection === ''}
+            // readOnly can't avoid all events, so we use disabled instead
+            disabled={selectedCollection === ''}
             wrapperClass={classes.selector}
             variant="filled"
             label={searchTrans('field')}