balibabu commited on
Commit
9d3ef9c
·
1 Parent(s): 41d18bc

fix: remove unused libraries #1306 (#1649)

Browse files

### What problem does this PR solve?
fix: remove unused libraries #1306


### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

web/package-lock.json CHANGED
@@ -28,10 +28,8 @@
28
  "lodash": "^4.17.21",
29
  "mammoth": "^1.7.2",
30
  "rc-tween-one": "^3.0.6",
31
- "react-chat-elements": "^12.0.13",
32
  "react-copy-to-clipboard": "^5.1.0",
33
  "react-i18next": "^14.0.0",
34
- "react-infinite-scroll-component": "^6.1.0",
35
  "react-markdown": "^9.0.1",
36
  "react-pdf-highlighter": "^6.1.0",
37
  "react-string-replace": "^1.1.1",
@@ -17724,11 +17722,6 @@
17724
  "node": ">=8.9.0"
17725
  }
17726
  },
17727
- "node_modules/loaders.css": {
17728
- "version": "0.1.2",
17729
- "resolved": "https://registry.npmmirror.com/loaders.css/-/loaders.css-0.1.2.tgz",
17730
- "integrity": "sha512-Rhowlq24ey1VOeor+3wYOt9+MjaxBOJm1u4KlQgNC3+0xJ0LS4wq4iG57D/BPzvuD/7HHDGQOWJ+81oR2EI9bQ=="
17731
- },
17732
  "node_modules/local-pkg": {
17733
  "version": "0.4.3",
17734
  "resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.4.3.tgz",
@@ -20744,15 +20737,6 @@
20744
  "resolved": "https://registry.npmmirror.com/process-warning/-/process-warning-1.0.0.tgz",
20745
  "integrity": "sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q=="
20746
  },
20747
- "node_modules/progressbar.js": {
20748
- "version": "1.1.1",
20749
- "resolved": "https://registry.npmmirror.com/progressbar.js/-/progressbar.js-1.1.1.tgz",
20750
- "integrity": "sha512-FBsw3BKsUbb+hNeYfiP3xzvAAQrPi4DnGDw66bCmfuRCDLcslxyxv2GyYUdBSKFGSIBa73CUP5WMcl6F8AAXlw==",
20751
- "dependencies": {
20752
- "lodash.merge": "^4.6.2",
20753
- "shifty": "^2.8.3"
20754
- }
20755
- },
20756
  "node_modules/prompts": {
20757
  "version": "2.4.2",
20758
  "resolved": "https://registry.npmmirror.com/prompts/-/prompts-2.4.2.tgz",
@@ -21626,22 +21610,6 @@
21626
  "node": ">=0.10.0"
21627
  }
21628
  },
21629
- "node_modules/react-chat-elements": {
21630
- "version": "12.0.13",
21631
- "resolved": "https://registry.npmmirror.com/react-chat-elements/-/react-chat-elements-12.0.13.tgz",
21632
- "integrity": "sha512-Vu5x8kW4LPu8onKfz5vsuDwZsDhoQmTBHJdqKAhVsi42PCQ8KOfzHiDp0fPUJlinJZ/MTJTm69UAchpys4iSTQ==",
21633
- "dependencies": {
21634
- "classnames": "^2.2.5",
21635
- "progressbar.js": "^1.1.0",
21636
- "react-icons": "^4.3.1",
21637
- "react-spinkit": "^3.0.0",
21638
- "timeago.js": "^4.0.2"
21639
- },
21640
- "peerDependencies": {
21641
- "react": "^18.2.0",
21642
- "react-dom": "18.2.0"
21643
- }
21644
- },
21645
  "node_modules/react-copy-to-clipboard": {
21646
  "version": "5.1.0",
21647
  "resolved": "https://registry.npmmirror.com/react-copy-to-clipboard/-/react-copy-to-clipboard-5.1.0.tgz",
@@ -22013,33 +21981,6 @@
22013
  }
22014
  }
22015
  },
22016
- "node_modules/react-icons": {
22017
- "version": "4.12.0",
22018
- "resolved": "https://registry.npmmirror.com/react-icons/-/react-icons-4.12.0.tgz",
22019
- "integrity": "sha512-IBaDuHiShdZqmfc/TwHu6+d6k2ltNCf3AszxNmjJc1KUfXdEeRJOKyNvLmAHaarhzGmTSVygNdyu8/opXv2gaw==",
22020
- "peerDependencies": {
22021
- "react": "*"
22022
- }
22023
- },
22024
- "node_modules/react-infinite-scroll-component": {
22025
- "version": "6.1.0",
22026
- "resolved": "https://registry.npmmirror.com/react-infinite-scroll-component/-/react-infinite-scroll-component-6.1.0.tgz",
22027
- "integrity": "sha512-SQu5nCqy8DxQWpnUVLx7V7b7LcA37aM7tvoWjTLZp1dk6EJibM5/4EJKzOnl07/BsM1Y40sKLuqjCwwH/xV0TQ==",
22028
- "dependencies": {
22029
- "throttle-debounce": "^2.1.0"
22030
- },
22031
- "peerDependencies": {
22032
- "react": ">=16.0.0"
22033
- }
22034
- },
22035
- "node_modules/react-infinite-scroll-component/node_modules/throttle-debounce": {
22036
- "version": "2.3.0",
22037
- "resolved": "https://registry.npmmirror.com/throttle-debounce/-/throttle-debounce-2.3.0.tgz",
22038
- "integrity": "sha512-H7oLPV0P7+jgvrk+6mwwwBDmxTaxnu9HMXmloNLXwnNO0ZxZ31Orah2n8lU1eMPvsaowP2CX+USCgyovXfdOFQ==",
22039
- "engines": {
22040
- "node": ">=8"
22041
- }
22042
- },
22043
  "node_modules/react-is": {
22044
  "version": "18.2.0",
22045
  "resolved": "https://registry.npmmirror.com/react-is/-/react-is-18.2.0.tgz",
@@ -22246,17 +22187,6 @@
22246
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
22247
  }
22248
  },
22249
- "node_modules/react-spinkit": {
22250
- "version": "3.0.0",
22251
- "resolved": "https://registry.npmmirror.com/react-spinkit/-/react-spinkit-3.0.0.tgz",
22252
- "integrity": "sha512-RrfGRPjqxHQiy7quPqhjPynTu0zobgQaZu1QYBMpJJ6pCSRRRK16EZMaxdE6fLVYFRJWpX/eGATWLMoVFFT5uQ==",
22253
- "dependencies": {
22254
- "classnames": "^2.2.3",
22255
- "loaders.css": "^0.1.2",
22256
- "object-assign": "^4.1.0",
22257
- "prop-types": "^15.5.8"
22258
- }
22259
- },
22260
  "node_modules/react-string-replace": {
22261
  "version": "1.1.1",
22262
  "resolved": "https://registry.npmmirror.com/react-string-replace/-/react-string-replace-1.1.1.tgz",
@@ -23315,14 +23245,6 @@
23315
  "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==",
23316
  "dev": true
23317
  },
23318
- "node_modules/shifty": {
23319
- "version": "2.20.4",
23320
- "resolved": "https://registry.npmmirror.com/shifty/-/shifty-2.20.4.tgz",
23321
- "integrity": "sha512-4Y0qRkg8ME5XN8yGNAwmFOmsIURGFKT9UQfNL6DDJQErYtN5HsjyoBuJn41ZQfTkuu2rIbRMn9qazjKsDpO2TA==",
23322
- "optionalDependencies": {
23323
- "fsevents": "^2.3.2"
23324
- }
23325
- },
23326
  "node_modules/side-channel": {
23327
  "version": "1.0.4",
23328
  "resolved": "https://registry.npmmirror.com/side-channel/-/side-channel-1.0.4.tgz",
@@ -24597,11 +24519,6 @@
24597
  "node": ">=12.22"
24598
  }
24599
  },
24600
- "node_modules/timeago.js": {
24601
- "version": "4.0.2",
24602
- "resolved": "https://registry.npmmirror.com/timeago.js/-/timeago.js-4.0.2.tgz",
24603
- "integrity": "sha512-a7wPxPdVlQL7lqvitHGGRsofhdwtkoSXPGATFuSOA2i1ZNQEPLrGnj68vOp2sOJTCFAQVXPeNMX/GctBaO9L2w=="
24604
- },
24605
  "node_modules/timers-browserify": {
24606
  "version": "2.0.12",
24607
  "resolved": "https://registry.npmmirror.com/timers-browserify/-/timers-browserify-2.0.12.tgz",
 
28
  "lodash": "^4.17.21",
29
  "mammoth": "^1.7.2",
30
  "rc-tween-one": "^3.0.6",
 
31
  "react-copy-to-clipboard": "^5.1.0",
32
  "react-i18next": "^14.0.0",
 
33
  "react-markdown": "^9.0.1",
34
  "react-pdf-highlighter": "^6.1.0",
35
  "react-string-replace": "^1.1.1",
 
17722
  "node": ">=8.9.0"
17723
  }
17724
  },
 
 
 
 
 
17725
  "node_modules/local-pkg": {
17726
  "version": "0.4.3",
17727
  "resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.4.3.tgz",
 
20737
  "resolved": "https://registry.npmmirror.com/process-warning/-/process-warning-1.0.0.tgz",
20738
  "integrity": "sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q=="
20739
  },
 
 
 
 
 
 
 
 
 
20740
  "node_modules/prompts": {
20741
  "version": "2.4.2",
20742
  "resolved": "https://registry.npmmirror.com/prompts/-/prompts-2.4.2.tgz",
 
21610
  "node": ">=0.10.0"
21611
  }
21612
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21613
  "node_modules/react-copy-to-clipboard": {
21614
  "version": "5.1.0",
21615
  "resolved": "https://registry.npmmirror.com/react-copy-to-clipboard/-/react-copy-to-clipboard-5.1.0.tgz",
 
21981
  }
21982
  }
21983
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21984
  "node_modules/react-is": {
21985
  "version": "18.2.0",
21986
  "resolved": "https://registry.npmmirror.com/react-is/-/react-is-18.2.0.tgz",
 
22187
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
22188
  }
22189
  },
 
 
 
 
 
 
 
 
 
 
 
22190
  "node_modules/react-string-replace": {
22191
  "version": "1.1.1",
22192
  "resolved": "https://registry.npmmirror.com/react-string-replace/-/react-string-replace-1.1.1.tgz",
 
23245
  "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==",
23246
  "dev": true
23247
  },
 
 
 
 
 
 
 
 
23248
  "node_modules/side-channel": {
23249
  "version": "1.0.4",
23250
  "resolved": "https://registry.npmmirror.com/side-channel/-/side-channel-1.0.4.tgz",
 
24519
  "node": ">=12.22"
24520
  }
24521
  },
 
 
 
 
 
24522
  "node_modules/timers-browserify": {
24523
  "version": "2.0.12",
24524
  "resolved": "https://registry.npmmirror.com/timers-browserify/-/timers-browserify-2.0.12.tgz",
web/package.json CHANGED
@@ -39,10 +39,8 @@
39
  "lodash": "^4.17.21",
40
  "mammoth": "^1.7.2",
41
  "rc-tween-one": "^3.0.6",
42
- "react-chat-elements": "^12.0.13",
43
  "react-copy-to-clipboard": "^5.1.0",
44
  "react-i18next": "^14.0.0",
45
- "react-infinite-scroll-component": "^6.1.0",
46
  "react-markdown": "^9.0.1",
47
  "react-pdf-highlighter": "^6.1.0",
48
  "react-string-replace": "^1.1.1",
 
39
  "lodash": "^4.17.21",
40
  "mammoth": "^1.7.2",
41
  "rc-tween-one": "^3.0.6",
 
42
  "react-copy-to-clipboard": "^5.1.0",
43
  "react-i18next": "^14.0.0",
 
44
  "react-markdown": "^9.0.1",
45
  "react-pdf-highlighter": "^6.1.0",
46
  "react-string-replace": "^1.1.1",
web/src/hooks/file-manager-hooks.ts CHANGED
@@ -4,11 +4,12 @@ import {
4
  IFileListRequestBody,
5
  } from '@/interfaces/request/file-manager';
6
  import fileManagerService from '@/services/file-manager-service';
7
- import { useQuery } from '@tanstack/react-query';
8
  import { PaginationProps, UploadFile } from 'antd';
9
  import React, { useCallback } from 'react';
10
  import { useDispatch, useSearchParams, useSelector } from 'umi';
11
  import { useGetNextPagination, useHandleSearchChange } from './logic-hooks';
 
12
 
13
  export const useGetFolderId = () => {
14
  const [searchParams] = useSearchParams();
@@ -48,13 +49,19 @@ export const useFetchNextFileList = (): ResponseType<any> & IListResult => {
48
  const { data } = useQuery({
49
  queryKey: [
50
  'fetchFileList',
51
- id,
52
- pagination.current,
53
- pagination.pageSize,
54
- searchString,
 
 
 
 
 
55
  ],
56
  initialData: {},
57
- queryFn: async () => {
 
58
  const { data } = await fileManagerService.listFile({
59
  parent_id: id,
60
  keywords: searchString,
@@ -99,6 +106,26 @@ export const useRemoveFile = () => {
99
  return removeFile;
100
  };
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  export const useRenameFile = () => {
103
  const dispatch = useDispatch();
104
 
 
4
  IFileListRequestBody,
5
  } from '@/interfaces/request/file-manager';
6
  import fileManagerService from '@/services/file-manager-service';
7
+ import { useMutation, useQuery } from '@tanstack/react-query';
8
  import { PaginationProps, UploadFile } from 'antd';
9
  import React, { useCallback } from 'react';
10
  import { useDispatch, useSearchParams, useSelector } from 'umi';
11
  import { useGetNextPagination, useHandleSearchChange } from './logic-hooks';
12
+ import { useSetPaginationParams } from './route-hook';
13
 
14
  export const useGetFolderId = () => {
15
  const [searchParams] = useSearchParams();
 
49
  const { data } = useQuery({
50
  queryKey: [
51
  'fetchFileList',
52
+ // pagination.current,
53
+ // id,
54
+ // pagination.pageSize,
55
+ // searchString,
56
+ {
57
+ id,
58
+ searchString,
59
+ ...pagination,
60
+ },
61
  ],
62
  initialData: {},
63
+ queryFn: async (params: any) => {
64
+ console.info(params);
65
  const { data } = await fileManagerService.listFile({
66
  parent_id: id,
67
  keywords: searchString,
 
106
  return removeFile;
107
  };
108
 
109
+ export const useDeleteFile = () => {
110
+ const { setPaginationParams } = useSetPaginationParams();
111
+ const {
112
+ data,
113
+ isPending: loading,
114
+ mutateAsync,
115
+ } = useMutation({
116
+ mutationKey: ['deleteFile'],
117
+ mutationFn: async (params: { fileIds: string[]; parentId: string }) => {
118
+ const { data } = await fileManagerService.removeFile(params);
119
+ if (data.retcode === 0) {
120
+ setPaginationParams(1);
121
+ }
122
+ return data?.data ?? {};
123
+ },
124
+ });
125
+
126
+ return { data, loading, deleteFile: mutateAsync };
127
+ };
128
+
129
  export const useRenameFile = () => {
130
  const dispatch = useDispatch();
131
 
web/src/hooks/logic-hooks.ts CHANGED
@@ -23,6 +23,7 @@ import { useDispatch } from 'umi';
23
  import { useSetModalState, useTranslate } from './common-hooks';
24
  import { useSetDocumentParser } from './document-hooks';
25
  import { useFetchLlmList } from './llm-hooks';
 
26
  import { useOneNamespaceEffectsLoading } from './store-hooks';
27
  import {
28
  useFetchTenantInfo,
@@ -101,23 +102,24 @@ export const useChangeLanguage = () => {
101
 
102
  export const useGetNextPagination = () => {
103
  const { t } = useTranslate('common');
104
- const [{ page, pageSize }, setPagination] = useState({
105
- page: 1,
106
- pageSize: 10,
107
- });
 
108
 
109
  const onPageChange: PaginationProps['onChange'] = useCallback(
110
  (pageNumber: number, pageSize: number) => {
111
- setPagination({ page: pageNumber, pageSize });
112
  },
113
- [setPagination],
114
  );
115
 
116
  const setCurrentPagination = useCallback(
117
  (pagination: { page: number; pageSize?: number }) => {
118
- setPagination((p) => ({ ...p, ...pagination }));
119
  },
120
- [setPagination],
121
  );
122
 
123
  const pagination: PaginationProps = useMemo(() => {
 
23
  import { useSetModalState, useTranslate } from './common-hooks';
24
  import { useSetDocumentParser } from './document-hooks';
25
  import { useFetchLlmList } from './llm-hooks';
26
+ import { useSetPaginationParams } from './route-hook';
27
  import { useOneNamespaceEffectsLoading } from './store-hooks';
28
  import {
29
  useFetchTenantInfo,
 
102
 
103
  export const useGetNextPagination = () => {
104
  const { t } = useTranslate('common');
105
+ const {
106
+ setPaginationParams,
107
+ page,
108
+ size: pageSize,
109
+ } = useSetPaginationParams();
110
 
111
  const onPageChange: PaginationProps['onChange'] = useCallback(
112
  (pageNumber: number, pageSize: number) => {
113
+ setPaginationParams(pageNumber, pageSize);
114
  },
115
+ [setPaginationParams],
116
  );
117
 
118
  const setCurrentPagination = useCallback(
119
  (pagination: { page: number; pageSize?: number }) => {
120
+ setPaginationParams(pagination.page, pagination.pageSize);
121
  },
122
+ [setPaginationParams],
123
  );
124
 
125
  const pagination: PaginationProps = useMemo(() => {
web/src/hooks/route-hook.ts CHANGED
@@ -54,3 +54,37 @@ export const useNavigateToDataset = () => {
54
  navigate(`/knowledge/${KnowledgeRouteKey.Dataset}?id=${knowledgeId}`);
55
  }, [knowledgeId, navigate]);
56
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  navigate(`/knowledge/${KnowledgeRouteKey.Dataset}?id=${knowledgeId}`);
55
  }, [knowledgeId, navigate]);
56
  };
57
+
58
+ export const useGetPaginationParams = () => {
59
+ const [currentQueryParameters] = useSearchParams();
60
+
61
+ return {
62
+ page: currentQueryParameters.get('page') || 1,
63
+ size: currentQueryParameters.get('size') || 10,
64
+ };
65
+ };
66
+
67
+ export const useSetPaginationParams = () => {
68
+ const [queryParameters, setSearchParams] = useSearchParams();
69
+ // const newQueryParameters: URLSearchParams = useMemo(
70
+ // () => new URLSearchParams(queryParameters.toString()),
71
+ // [queryParameters],
72
+ // );
73
+
74
+ const setPaginationParams = useCallback(
75
+ (page: number = 1, pageSize?: number) => {
76
+ queryParameters.set('page', page.toString());
77
+ if (pageSize) {
78
+ queryParameters.set('size', pageSize.toString());
79
+ }
80
+ setSearchParams(queryParameters);
81
+ },
82
+ [setSearchParams, queryParameters],
83
+ );
84
+
85
+ return {
86
+ setPaginationParams,
87
+ page: Number(queryParameters.get('page')) || 1,
88
+ size: Number(queryParameters.get('size')) || 10,
89
+ };
90
+ };
web/src/pages/chat/message-box.tsx DELETED
@@ -1,45 +0,0 @@
1
- // RCE CSS
2
- import { MessageList } from 'react-chat-elements';
3
- import 'react-chat-elements/dist/main.css';
4
-
5
- const ChatBox = () => {
6
- return (
7
- <div style={{ width: 600 }}>
8
- {/* <MessageBox
9
- position={'left'}
10
- type={'photo'}
11
- text={'react.svg'}
12
- data={{
13
- uri: 'https://facebook.github.io/react/img/logo.svg',
14
- status: {
15
- click: false,
16
- loading: 0,
17
- },
18
- }}
19
- /> */}
20
-
21
- <MessageList
22
- // referance={messageListReferance}
23
- className="message-list"
24
- lockable={true}
25
- toBottomHeight={'100%'}
26
- dataSource={[
27
- {
28
- position: 'right',
29
- type: 'text',
30
- text: 'Lorem ipsum dolor sit amet',
31
- date: new Date(),
32
- },
33
- {
34
- position: 'left',
35
- type: 'text',
36
- text: 'Lorem ipsum dolor sit amet',
37
- date: new Date(),
38
- },
39
- ]}
40
- />
41
- </div>
42
- );
43
- };
44
-
45
- export default ChatBox;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
web/src/pages/file-manager/hooks.ts CHANGED
@@ -2,9 +2,9 @@ import { useSetModalState, useShowDeleteConfirm } from '@/hooks/common-hooks';
2
  import {
3
  useConnectToKnowledge,
4
  useCreateFolder,
 
5
  useFetchFileList,
6
  useFetchParentFolderList,
7
- useRemoveFile,
8
  useRenameFile,
9
  useSelectFileList,
10
  useSelectParentFolderList,
@@ -215,14 +215,14 @@ export const useHandleDeleteFile = (
215
  fileIds: string[],
216
  setSelectedRowKeys: (keys: string[]) => void,
217
  ) => {
218
- const removeDocument = useRemoveFile();
219
  const showDeleteConfirm = useShowDeleteConfirm();
220
  const parentId = useGetFolderId();
221
 
222
  const handleRemoveFile = () => {
223
  showDeleteConfirm({
224
  onOk: async () => {
225
- const retcode = await removeDocument(fileIds, parentId);
226
  if (retcode === 0) {
227
  setSelectedRowKeys([]);
228
  }
 
2
  import {
3
  useConnectToKnowledge,
4
  useCreateFolder,
5
+ useDeleteFile,
6
  useFetchFileList,
7
  useFetchParentFolderList,
 
8
  useRenameFile,
9
  useSelectFileList,
10
  useSelectParentFolderList,
 
215
  fileIds: string[],
216
  setSelectedRowKeys: (keys: string[]) => void,
217
  ) => {
218
+ const { deleteFile: removeDocument } = useDeleteFile();
219
  const showDeleteConfirm = useShowDeleteConfirm();
220
  const parentId = useGetFolderId();
221
 
222
  const handleRemoveFile = () => {
223
  showDeleteConfirm({
224
  onOk: async () => {
225
+ const retcode = await removeDocument({ fileIds, parentId });
226
  if (retcode === 0) {
227
  setSelectedRowKeys([]);
228
  }