balibabu commited on
Commit
c4edd97
·
1 Parent(s): d3ccaa9

Feat: Add tooltip to question item of ChunkCreatingModal #3873 (#3880)

Browse files

### What problem does this PR solve?

Feat: Add tooltip to question item of ChunkCreatingModal #3873

### Type of change


- [x] New Feature (non-breaking change which adds functionality)

web/src/components/edit-tag/index.less CHANGED
@@ -1,8 +1,21 @@
1
  .tweenGroup {
2
- display: inline-block;
3
- :global(.ant-tag) {
4
- margin-bottom: 8px;
5
- font-size: 14px;
6
- padding: 2px 8px;
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  }
8
  }
 
1
  .tweenGroup {
2
+ display: flex;
3
+ gap: 8px;
4
+ flex-wrap: wrap;
5
+ width: 100%;
6
+ margin-bottom: 8px;
7
+ }
8
+
9
+ .tag {
10
+ max-width: 100%;
11
+ margin: 0;
12
+ padding: 2px 20px 2px 4px;
13
+ font-size: 14px;
14
+ .textEllipsis();
15
+ position: relative;
16
+ :global(.ant-tag-close-icon) {
17
+ position: absolute;
18
+ top: 7px;
19
+ right: 4px;
20
  }
21
  }
web/src/components/edit-tag/index.tsx CHANGED
@@ -45,8 +45,10 @@ const EditTag = ({ tags, setTags }: EditTagsProps) => {
45
  };
46
 
47
  const forMap = (tag: string) => {
48
- const tagElem = (
49
  <Tag
 
 
50
  closable
51
  onClose={(e) => {
52
  e.preventDefault();
@@ -56,11 +58,6 @@ const EditTag = ({ tags, setTags }: EditTagsProps) => {
56
  {tag}
57
  </Tag>
58
  );
59
- return (
60
- <span key={tag} style={{ display: 'inline-block' }}>
61
- {tagElem}
62
- </span>
63
- );
64
  };
65
 
66
  const tagChild = tags?.map(forMap);
@@ -71,8 +68,8 @@ const EditTag = ({ tags, setTags }: EditTagsProps) => {
71
  };
72
 
73
  return (
74
- <>
75
- <span>
76
  <TweenOneGroup
77
  className={styles.tweenGroup}
78
  enter={{
@@ -91,7 +88,7 @@ const EditTag = ({ tags, setTags }: EditTagsProps) => {
91
  >
92
  {tagChild}
93
  </TweenOneGroup>
94
- </span>
95
  {inputVisible ? (
96
  <Input
97
  ref={inputRef}
@@ -107,7 +104,7 @@ const EditTag = ({ tags, setTags }: EditTagsProps) => {
107
  <PlusOutlined />
108
  </Tag>
109
  )}
110
- </>
111
  );
112
  };
113
 
 
45
  };
46
 
47
  const forMap = (tag: string) => {
48
+ return (
49
  <Tag
50
+ key={tag}
51
+ className={styles.tag}
52
  closable
53
  onClose={(e) => {
54
  e.preventDefault();
 
58
  {tag}
59
  </Tag>
60
  );
 
 
 
 
 
61
  };
62
 
63
  const tagChild = tags?.map(forMap);
 
68
  };
69
 
70
  return (
71
+ <div>
72
+ {Array.isArray(tagChild) && tagChild.length > 0 && (
73
  <TweenOneGroup
74
  className={styles.tweenGroup}
75
  enter={{
 
88
  >
89
  {tagChild}
90
  </TweenOneGroup>
91
+ )}
92
  {inputVisible ? (
93
  <Input
94
  ref={inputRef}
 
104
  <PlusOutlined />
105
  </Tag>
106
  )}
107
+ </div>
108
  );
109
  };
110
 
web/src/locales/en.ts CHANGED
@@ -326,6 +326,7 @@ When you want to search the given knowledge base at first place, set a higher pa
326
  graph: 'Knowledge graph',
327
  mind: 'Mind map',
328
  question: 'Question',
 
329
  },
330
  chat: {
331
  newConversation: 'New conversation',
 
326
  graph: 'Knowledge graph',
327
  mind: 'Mind map',
328
  question: 'Question',
329
+ questionTip: `If there're given questions, the embedding of the chunk will be based on them.`,
330
  },
331
  chat: {
332
  newConversation: 'New conversation',
web/src/locales/zh-traditional.ts CHANGED
@@ -310,6 +310,7 @@ export default {
310
  graph: '知識圖譜',
311
  mind: '心智圖',
312
  question: '問題',
 
313
  },
314
  chat: {
315
  newConversation: '新會話',
 
310
  graph: '知識圖譜',
311
  mind: '心智圖',
312
  question: '問題',
313
+ questionTip: `如果存在給定的問題,則區塊的嵌入將基於它們。`,
314
  },
315
  chat: {
316
  newConversation: '新會話',
web/src/locales/zh.ts CHANGED
@@ -327,6 +327,7 @@ export default {
327
  graph: '知识图谱',
328
  mind: '思维导图',
329
  question: '问题',
 
330
  },
331
  chat: {
332
  newConversation: '新会话',
 
327
  graph: '知识图谱',
328
  mind: '思维导图',
329
  question: '问题',
330
+ questionTip: `如果有给定的问题,则块的嵌入将基于它们。`,
331
  },
332
  chat: {
333
  newConversation: '新会话',
web/src/pages/add-knowledge/components/knowledge-chunk/components/chunk-creating-modal/index.tsx CHANGED
@@ -1,8 +1,8 @@
1
  import EditTag from '@/components/edit-tag';
2
  import { useFetchChunk } from '@/hooks/chunk-hooks';
3
  import { IModalProps } from '@/interfaces/common';
4
- import { DeleteOutlined } from '@ant-design/icons';
5
- import { Divider, Form, Input, Modal, Space, Switch } from 'antd';
6
  import React, { useEffect, useState } from 'react';
7
  import { useTranslation } from 'react-i18next';
8
  import { useDeleteChunkByIds } from '../../hooks';
@@ -41,7 +41,7 @@ const ChunkCreatingModal: React.FC<IModalProps<any> & kFProps> = ({
41
  form.setFieldsValue({ content: content_with_weight });
42
  setKeywords(important_kwd);
43
  setQuestion(question_kwd);
44
- setChecked(available_int === 1);
45
  }
46
 
47
  if (!chunkId) {
@@ -93,11 +93,16 @@ const ChunkCreatingModal: React.FC<IModalProps<any> & kFProps> = ({
93
  </Form.Item>
94
  </Form>
95
  <section>
96
- <p className="mb-2">{t('chunk.keyword')} *</p>
97
  <EditTag tags={keywords} setTags={setKeywords} />
98
  </section>
99
- <section className="pt-2">
100
- <p className="mb-2">{t('chunk.question')} *</p>
 
 
 
 
 
101
  <EditTag tags={question} setTags={setQuestion} />
102
  </section>
103
  {chunkId && (
 
1
  import EditTag from '@/components/edit-tag';
2
  import { useFetchChunk } from '@/hooks/chunk-hooks';
3
  import { IModalProps } from '@/interfaces/common';
4
+ import { DeleteOutlined, QuestionCircleOutlined } from '@ant-design/icons';
5
+ import { Divider, Form, Input, Modal, Space, Switch, Tooltip } from 'antd';
6
  import React, { useEffect, useState } from 'react';
7
  import { useTranslation } from 'react-i18next';
8
  import { useDeleteChunkByIds } from '../../hooks';
 
41
  form.setFieldsValue({ content: content_with_weight });
42
  setKeywords(important_kwd);
43
  setQuestion(question_kwd);
44
+ setChecked(available_int !== 0);
45
  }
46
 
47
  if (!chunkId) {
 
93
  </Form.Item>
94
  </Form>
95
  <section>
96
+ <p className="mb-2">{t('chunk.keyword')} </p>
97
  <EditTag tags={keywords} setTags={setKeywords} />
98
  </section>
99
+ <section className="mt-4">
100
+ <div className="flex items-center gap-2 mb-2">
101
+ <span>{t('chunk.question')}</span>
102
+ <Tooltip title={t('chunk.questionTip')}>
103
+ <QuestionCircleOutlined className="text-xs" />
104
+ </Tooltip>
105
+ </div>
106
  <EditTag tags={question} setTags={setQuestion} />
107
  </section>
108
  {chunkId && (
web/src/utils/file-util.ts CHANGED
@@ -112,20 +112,6 @@ export const downloadFileFromBlob = (blob: Blob, name?: string) => {
112
  window.URL.revokeObjectURL(url);
113
  };
114
 
115
- export const downloadFile = async ({
116
- id,
117
- filename,
118
- target,
119
- }: {
120
- id: string;
121
- filename?: string;
122
- target?: string;
123
- }) => {
124
- const response = await fileManagerService.getFile({}, id);
125
- const blob = new Blob([response.data], { type: response.data.type });
126
- downloadFileFromBlob(blob, filename);
127
- };
128
-
129
  export const downloadDocument = async ({
130
  id,
131
  filename,
 
112
  window.URL.revokeObjectURL(url);
113
  };
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  export const downloadDocument = async ({
116
  id,
117
  filename,