style: database refactor (#2460)

* fix: dataset folder modal

* style: dataset style refactor

* sideTag i18n pef
This commit is contained in:
papapatrick
2024-08-21 18:15:05 +08:00
committed by GitHub
parent 649de7f028
commit 113c57bcbe
16 changed files with 412 additions and 223 deletions

View File

@@ -137,7 +137,9 @@ export type DatasetSimpleItemType = {
};
export type DatasetListItemType = {
_id: string;
tmbId: string;
avatar: string;
updateTime: Date;
name: string;
intro: string;
type: `${DatasetTypeEnum}`;

View File

@@ -32,6 +32,7 @@ export const iconPaths = {
'common/googleFill': () => import('./icons/common/googleFill.svg'),
'common/importLight': () => import('./icons/common/importLight.svg'),
'common/info': () => import('./icons/common/info.svg'),
'common/help': () => import('./icons/common/help.svg'),
'common/inviteLight': () => import('./icons/common/inviteLight.svg'),
'common/language/en': () => import('./icons/common/language/en.svg'),
'common/language/zh': () => import('./icons/common/language/zh.svg'),
@@ -129,11 +130,15 @@ export const iconPaths = {
'core/chat/stopSpeech': () => import('./icons/core/chat/stopSpeech.svg'),
'core/dataset/commonDataset': () => import('./icons/core/dataset/commonDataset.svg'),
'core/dataset/commonDatasetColor': () => import('./icons/core/dataset/commonDatasetColor.svg'),
'core/dataset/commonDatasetOutline': () =>
import('./icons/core/dataset/commonDatasetOutline.svg'),
'core/dataset/datasetFill': () => import('./icons/core/dataset/datasetFill.svg'),
'core/dataset/datasetLight': () => import('./icons/core/dataset/datasetLight.svg'),
'core/dataset/externalDataset': () => import('./icons/core/dataset/externalDataset.svg'),
'core/dataset/externalDatasetColor': () =>
import('./icons/core/dataset/externalDatasetColor.svg'),
'core/dataset/externalDatasetOutline': () =>
import('./icons/core/dataset/externalDatasetOutline.svg'),
'core/dataset/fileCollection': () => import('./icons/core/dataset/fileCollection.svg'),
'core/dataset/fullTextRecall': () => import('./icons/core/dataset/fullTextRecall.svg'),
'core/dataset/manualCollection': () => import('./icons/core/dataset/manualCollection.svg'),
@@ -145,6 +150,8 @@ export const iconPaths = {
'core/dataset/tag': () => import('./icons/core/dataset/tag.svg'),
'core/dataset/websiteDataset': () => import('./icons/core/dataset/websiteDataset.svg'),
'core/dataset/websiteDatasetColor': () => import('./icons/core/dataset/websiteDatasetColor.svg'),
'core/dataset/websiteDatasetOutline': () =>
import('./icons/core/dataset/websiteDatasetOutline.svg'),
'core/modules/basicNode': () => import('./icons/core/modules/basicNode.svg'),
'core/modules/fixview': () => import('./icons/core/modules/fixview.svg'),
'core/modules/flowLight': () => import('./icons/core/modules/flowLight.svg'),

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.99998 2.5568C4.99379 2.5568 2.55678 4.9938 2.55678 8C2.55678 11.0062 4.99379 13.4432 7.99998 13.4432C11.0062 13.4432 13.4432 11.0062 13.4432 8C13.4432 4.9938 11.0062 2.5568 7.99998 2.5568ZM1.22345 8C1.22345 4.25742 4.25741 1.22346 7.99998 1.22346C11.7426 1.22346 14.7765 4.25742 14.7765 8C14.7765 11.7426 11.7426 14.7765 7.99998 14.7765C4.25741 14.7765 1.22345 11.7426 1.22345 8ZM8.14828 5.62579C7.87681 5.57923 7.59763 5.63024 7.36017 5.7698C7.12271 5.90935 6.9423 6.12844 6.8509 6.38827C6.72872 6.73559 6.34811 6.91811 6.00078 6.79593C5.65346 6.67375 5.47094 6.29314 5.59312 5.94581C5.78901 5.38895 6.17566 4.91939 6.68459 4.62029C7.19352 4.32119 7.79187 4.21185 8.37369 4.31165C8.9555 4.41144 9.48322 4.71393 9.86338 5.16553C10.2435 5.61704 10.4515 6.18846 10.4507 6.77864C10.4504 7.74319 9.73579 8.37518 9.23739 8.70745C8.96785 8.88714 8.70305 9.01906 8.50826 9.10563C8.40993 9.14934 8.32705 9.18254 8.2672 9.20534C8.23721 9.21676 8.21285 9.22563 8.19503 9.23197L8.17327 9.23959L8.16626 9.24199L8.16375 9.24283L8.16275 9.24317C8.16255 9.24323 8.16192 9.24344 7.95111 8.61099L8.16192 9.24344C7.81263 9.35987 7.43508 9.1711 7.31865 8.82181C7.20226 8.47263 7.39087 8.09522 7.73994 7.97865L7.74835 7.97568C7.75738 7.97247 7.7724 7.96703 7.79254 7.95936C7.83292 7.94397 7.89325 7.91989 7.96675 7.88722C8.11564 7.82104 8.30909 7.72385 8.49779 7.59805C8.91576 7.3194 9.1174 7.0351 9.1174 6.77803L9.1174 6.77703C9.11781 6.5016 9.02073 6.23491 8.84335 6.0242C8.66597 5.81349 8.41975 5.67235 8.14828 5.62579ZM7.33332 11.0549C7.33332 10.6867 7.63179 10.3883 7.99998 10.3883H8.00609C8.37428 10.3883 8.67276 10.6867 8.67276 11.0549C8.67276 11.4231 8.37428 11.7216 8.00609 11.7216H7.99998C7.63179 11.7216 7.33332 11.4231 7.33332 11.0549Z" />
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -1,8 +1,8 @@
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="url(#paint0_linear_7964_19459)" rx="2" ry="2" />
<rect width="100%" height="100%" fill="url(#paint0_linear_7964_19459)" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.28019 5.36532C4.17847 5.56497 4.17847 5.82633 4.17847 6.34905V8.02905C4.17847 8.55176 4.17847 8.81312 4.28019 9.01277C4.36968 9.18839 4.51246 9.33117 4.68808 9.42065C4.88773 9.52238 5.14908 9.52238 5.6718 9.52238H14.3984C14.9211 9.52238 15.1825 9.52238 15.3821 9.42065C15.5578 9.33117 15.7005 9.18839 15.79 9.01277C15.8918 8.81312 15.8918 8.55176 15.8918 8.02905V6.34905C15.8918 5.82633 15.8918 5.56497 15.79 5.36532C15.7005 5.1897 15.5578 5.04692 15.3821 4.95744C15.1825 4.85571 14.9211 4.85571 14.3984 4.85571H5.6718C5.14908 4.85571 4.88773 4.85571 4.68808 4.95744C4.51246 5.04692 4.36968 5.1897 4.28019 5.36532ZM6.6542 8.06405C7.13745 8.06405 7.5292 7.6723 7.5292 7.18905C7.5292 6.7058 7.13745 6.31405 6.6542 6.31405C6.17095 6.31405 5.7792 6.7058 5.7792 7.18905C5.7792 7.6723 6.17095 8.06405 6.6542 8.06405Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.28019 10.9873C4.17847 11.1869 4.17847 11.4483 4.17847 11.971V13.651C4.17847 14.1737 4.17847 14.4351 4.28019 14.6347C4.36968 14.8103 4.51246 14.9531 4.68808 15.0426C4.88773 15.1443 5.14908 15.1443 5.6718 15.1443H14.3984C14.9211 15.1443 15.1825 15.1443 15.3821 15.0426C15.5578 14.9531 15.7005 14.8103 15.79 14.6347C15.8918 14.4351 15.8918 14.1737 15.8918 13.651V11.971C15.8918 11.4483 15.8918 11.1869 15.79 10.9873C15.7005 10.8116 15.5578 10.6689 15.3821 10.5794C15.1825 10.4777 14.9211 10.4777 14.3984 10.4777H5.6718C5.14908 10.4777 4.88773 10.4777 4.68808 10.5794C4.51246 10.6689 4.36968 10.8116 4.28019 10.9873ZM6.6542 13.686C7.13745 13.686 7.5292 13.2942 7.5292 12.811C7.5292 12.3277 7.13745 11.936 6.6542 11.936C6.17095 11.936 5.7792 12.3277 5.7792 12.811C5.7792 13.2942 6.17095 13.686 6.6542 13.686Z" fill="white"/>
<defs>
<defs>
<linearGradient id="paint0_linear_7964_19459" x1="1.5" y1="20" x2="20" y2="1.6056e-06" gradientUnits="userSpaceOnUse">
<stop stop-color="#4484FF"/>
<stop offset="1" stop-color="#5CA7FF"/>

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -0,0 +1,7 @@
<svg viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3.65419 5.06405C4.13743 5.06405 4.52919 4.6723 4.52919 4.18905C4.52919 3.7058 4.13743 3.31405 3.65419 3.31405C3.17094 3.31405 2.77919 3.7058 2.77919 4.18905C2.77919 4.6723 3.17094 5.06405 3.65419 5.06405Z" fill="#667085"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.17845 3.34905C1.17845 2.82633 1.17845 2.56497 1.28018 2.36532C1.36966 2.1897 1.51244 2.04692 1.68806 1.95744C1.88771 1.85571 2.14907 1.85571 2.67179 1.85571H11.3984C11.9211 1.85571 12.1825 1.85571 12.3821 1.95744C12.5578 2.04692 12.7005 2.1897 12.79 2.36532C12.8917 2.56497 12.8917 2.82633 12.8917 3.34905V5.02905C12.8917 5.55176 12.8917 5.81312 12.79 6.01277C12.7005 6.18839 12.5578 6.33117 12.3821 6.42065C12.1825 6.52238 11.9211 6.52238 11.3984 6.52238H2.67178C2.14907 6.52238 1.88771 6.52238 1.68806 6.42065C1.51244 6.33117 1.36966 6.18839 1.28018 6.01277C1.17845 5.81312 1.17845 5.55176 1.17845 5.02905V3.34905ZM2.67179 3.02238H11.3984C11.5305 3.02238 11.6342 3.02241 11.7237 3.02379C11.725 3.11329 11.7251 3.21696 11.7251 3.34905V5.02905C11.7251 5.16113 11.725 5.2648 11.7237 5.35431C11.6342 5.35568 11.5305 5.35571 11.3984 5.35571H2.67178C2.5397 5.35571 2.43603 5.35568 2.34652 5.35431C2.34515 5.2648 2.34512 5.16113 2.34512 5.02905V3.34905C2.34512 3.21696 2.34515 3.11329 2.34652 3.02379C2.43603 3.02241 2.5397 3.02238 2.67179 3.02238Z" fill="#667085"/>
<path d="M3.65419 10.686C4.13743 10.686 4.52919 10.2942 4.52919 9.81099C4.52919 9.32774 4.13743 8.93599 3.65419 8.93599C3.17094 8.93599 2.77919 9.32774 2.77919 9.81099C2.77919 10.2942 3.17094 10.686 3.65419 10.686Z" fill="#667085"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.17845 8.97099C1.17845 8.44827 1.17845 8.18691 1.28018 7.98726C1.36966 7.81164 1.51244 7.66886 1.68806 7.57938C1.88771 7.47765 2.14907 7.47765 2.67179 7.47765H11.3984C11.9211 7.47765 12.1825 7.47765 12.3821 7.57938C12.5578 7.66886 12.7005 7.81164 12.79 7.98726C12.8917 8.18691 12.8917 8.44827 12.8917 8.97099V10.651C12.8917 11.1737 12.8917 11.4351 12.79 11.6347C12.7005 11.8103 12.5578 11.9531 12.3821 12.0426C12.1825 12.1443 11.9211 12.1443 11.3984 12.1443H2.67178C2.14907 12.1443 1.88771 12.1443 1.68806 12.0426C1.51244 11.9531 1.36966 11.8103 1.28018 11.6347C1.17845 11.4351 1.17845 11.1737 1.17845 10.651V8.97099ZM2.67179 8.64432H11.3984C11.5305 8.64432 11.6342 8.64435 11.7237 8.64573C11.725 8.73523 11.7251 8.8389 11.7251 8.97099V10.651C11.7251 10.7831 11.725 10.8867 11.7237 10.9762C11.6342 10.9776 11.5305 10.9777 11.3984 10.9777H2.67178C2.5397 10.9777 2.43603 10.9776 2.34652 10.9762C2.34515 10.8867 2.34512 10.7831 2.34512 10.651V8.97099C2.34512 8.8389 2.34515 8.73523 2.34652 8.64573C2.43603 8.64435 2.5397 8.64432 2.67179 8.64432Z" fill="#667085"/>
</svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -1,5 +1,5 @@
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="url(#paint0_linear_7967_30275)" rx="2" ry="2" />
<rect width="100%" height="100%" fill="url(#paint0_linear_7967_30275)" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.7552 4.8767C12.3073 4.92969 11.9962 5.33456 12.0603 5.78101L13.3235 14.5762C13.3876 15.0226 13.8027 15.3416 14.2506 15.2886L16.1502 15.0639C16.5981 15.0109 16.9093 14.606 16.8451 14.1596L15.582 5.36443C15.5178 4.91798 15.1028 4.59901 14.6548 4.65199L12.7552 4.8767ZM4.0675 5.52248C4.0675 5.07145 4.43314 4.70582 4.88417 4.70582H6.80225C7.25328 4.70582 7.61892 5.07145 7.61892 5.52248V14.4772C7.61892 14.9282 7.25328 15.2938 6.80225 15.2938H4.88417C4.43314 15.2938 4.0675 14.9282 4.0675 14.4772V5.52248ZM8.20321 5.52248C8.20321 5.07145 8.56885 4.70582 9.01988 4.70582H10.938C11.389 4.70582 11.7546 5.07145 11.7546 5.52248V14.4772C11.7546 14.9282 11.389 15.2938 10.938 15.2938H9.01988C8.56885 15.2938 8.20321 14.9282 8.20321 14.4772V5.52248Z" fill="white"/>
<defs>
<linearGradient id="paint0_linear_7967_30275" x1="1.5" y1="20" x2="20" y2="1.6056e-06" gradientUnits="userSpaceOnUse">
@@ -8,3 +8,4 @@
</linearGradient>
</defs>
</svg>

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,5 @@
<svg viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.06033 2.78093C8.99621 2.33448 9.30734 1.9296 9.75525 1.87662L11.6548 1.65191C12.1028 1.59892 12.5178 1.91789 12.582 2.36434L13.8451 11.1595C13.9093 11.6059 13.5981 12.0108 13.1502 12.0638L11.2506 12.2885C10.8027 12.3415 10.3876 12.0225 10.3235 11.5761L9.06033 2.78093ZM11.3083 11.2541L10.1031 2.8631L11.5972 2.68636L12.8024 11.0773L11.3083 11.2541Z" fill="#667085"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.88417 1.70573C1.43314 1.70573 1.0675 2.07137 1.0675 2.5224V11.4771C1.0675 11.9281 1.43314 12.2937 1.88417 12.2937H3.80225C4.25328 12.2937 4.61892 11.9281 4.61892 11.4771V2.5224C4.61892 2.07137 4.25328 1.70573 3.80225 1.70573H1.88417ZM2.08834 2.72657V11.2729H3.59808V2.72657H2.08834Z" fill="#667085"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.01988 1.70573C5.56885 1.70573 5.20321 2.07137 5.20321 2.5224V11.4771C5.20321 11.9281 5.56885 12.2937 6.01988 12.2937H7.93796C8.38899 12.2937 8.75462 11.9281 8.75462 11.4771V2.5224C8.75462 2.07137 8.38899 1.70573 7.93796 1.70573H6.01988ZM6.22404 2.72657V11.2729H7.73379V2.72657H6.22404Z" fill="#667085"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -1,5 +1,5 @@
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="url(#paint0_linear_7967_30271)" rx="2" ry="2" />
<rect width="100%" height="100%" fill="url(#paint0_linear_7967_30271)" />
<path d="M12.8568 4.51367H7.14332C6.70594 4.51366 6.34265 4.51366 6.04623 4.53788C5.73762 4.56309 5.45049 4.61744 5.17975 4.75539C4.76247 4.968 4.4232 5.30727 4.21059 5.72455C4.07264 5.99529 4.01829 6.28242 3.99308 6.59103C3.96886 6.88745 3.96886 7.25074 3.96887 7.68812V10.1329C3.96886 10.5702 3.96886 10.9335 3.99308 11.23C4.01829 11.5386 4.07264 11.8257 4.21059 12.0964C4.4232 12.5137 4.76247 12.853 5.17975 13.0656C5.45049 13.2036 5.73762 13.2579 6.04623 13.2831C6.34263 13.3073 6.70588 13.3073 7.14321 13.3073H9.41671V14.3198H7.82091C7.49874 14.3198 7.23758 14.581 7.23758 14.9031C7.23758 15.2253 7.49874 15.4865 7.82091 15.4865H12.1792C12.5014 15.4865 12.7625 15.2253 12.7625 14.9031C12.7625 14.581 12.5014 14.3198 12.1792 14.3198H10.5834V13.3073H12.8568C13.2941 13.3073 13.6575 13.3073 13.9539 13.2831C14.2625 13.2579 14.5496 13.2036 14.8203 13.0656C15.2376 12.853 15.5769 12.5137 15.7895 12.0964C15.9275 11.8257 15.9818 11.5386 16.007 11.23C16.0312 10.9335 16.0312 10.5703 16.0312 10.1329V7.6881C16.0312 7.25075 16.0312 6.88744 16.007 6.59103C15.9818 6.28242 15.9275 5.99529 15.7895 5.72455C15.5769 5.30727 15.2376 4.968 14.8203 4.75539C14.5496 4.61744 14.2625 4.56309 13.9539 4.53788C13.6574 4.51366 13.2942 4.51366 12.8568 4.51367Z" fill="white"/>
<defs>
<linearGradient id="paint0_linear_7967_30271" x1="1.5" y1="20" x2="20" y2="1.6056e-06" gradientUnits="userSpaceOnUse">

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,4 @@
<svg viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.14327 1.51361H9.85673C10.2941 1.5136 10.6574 1.5136 10.9538 1.53782C11.2624 1.56303 11.5496 1.61737 11.8203 1.75532C12.2376 1.96794 12.5768 2.3072 12.7895 2.72449C12.9274 2.99523 12.9818 3.28236 13.007 3.59097C13.0312 3.88739 13.0312 4.25068 13.0312 4.68804V7.13282C13.0312 7.57019 13.0312 7.93348 13.007 8.2299C12.9818 8.53851 12.9274 8.82564 12.7895 9.09638C12.5768 9.51366 12.2376 9.85293 11.8203 10.0655C11.5496 10.2035 11.2624 10.2578 10.9538 10.2831C10.6574 10.3073 10.2941 10.3073 9.85672 10.3073H7.58333V11.3197H9.17914C9.5013 11.3197 9.76247 11.5809 9.76247 11.9031C9.76247 12.2252 9.5013 12.4864 9.17914 12.4864H4.82087C4.4987 12.4864 4.23753 12.2252 4.23753 11.9031C4.23753 11.5809 4.4987 11.3197 4.82087 11.3197H6.41667V10.3073H4.14329C3.70591 10.3073 3.34261 10.3073 3.04618 10.2831C2.73758 10.2578 2.45045 10.2035 2.1797 10.0655C1.76242 9.85293 1.42316 9.51366 1.21054 9.09638C1.07259 8.82564 1.01824 8.53851 0.993031 8.2299C0.968812 7.93348 0.968819 7.57018 0.968827 7.13281V4.68806C0.968819 4.25068 0.968812 3.88739 0.993031 3.59097C1.01824 3.28236 1.07259 2.99523 1.21054 2.72449C1.42316 2.3072 1.76242 1.96794 2.1797 1.75532C2.45045 1.61737 2.73758 1.56303 3.04618 1.53782C3.34261 1.5136 3.7059 1.5136 4.14327 1.51361ZM9.83288 9.14059C10.3002 9.14059 10.6155 9.14014 10.8588 9.12026C11.0953 9.10094 11.2118 9.06622 11.2906 9.02603C11.4884 8.92527 11.6492 8.76448 11.75 8.56672C11.7901 8.48786 11.8249 8.37135 11.8442 8.1349C11.8641 7.89163 11.8645 7.57625 11.8645 7.10896V4.71191C11.8645 4.24462 11.8641 3.92924 11.8442 3.68597C11.8249 3.44951 11.7901 3.33301 11.75 3.25414C11.6492 3.05638 11.4884 2.8956 11.2906 2.79483C11.2118 2.75465 11.0953 2.71993 10.8588 2.70061C10.6155 2.68073 10.3002 2.68028 9.83288 2.68028H4.16712C3.69984 2.68028 3.38445 2.68073 3.14119 2.70061C2.90473 2.71993 2.78822 2.75465 2.70936 2.79483C2.5116 2.8956 2.35081 3.05638 2.25005 3.25414C2.20986 3.33301 2.17514 3.44951 2.15582 3.68597C2.13595 3.92924 2.13549 4.24462 2.13549 4.71191V7.10896C2.13549 7.57625 2.13595 7.89163 2.15582 8.1349C2.17514 8.37135 2.20986 8.48786 2.25005 8.56672C2.35081 8.76448 2.5116 8.92527 2.70936 9.02603C2.78822 9.06622 2.90473 9.10094 3.14119 9.12026C3.38445 9.14014 3.69984 9.14059 4.16712 9.14059H9.83288Z" fill="#667085"/>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -6,7 +6,8 @@ import {
Box,
useOutsideClick,
MenuButton,
MenuItemProps
MenuItemProps,
PlacementWithLogical
} from '@chakra-ui/react';
import MyDivider from '../MyDivider';
import type { IconNameType } from '../Icon/type';
@@ -21,6 +22,8 @@ export type Props = {
Button: React.ReactNode;
trigger?: 'hover' | 'click';
iconSize?: string;
iconRadius?: string;
placement?: PlacementWithLogical;
menuList: {
label?: string;
children: {
@@ -40,7 +43,9 @@ const MyMenu = ({
offset,
iconSize = '1rem',
Button,
menuList
menuList,
iconRadius = 'sm',
placement = 'bottom-start'
}: Props) => {
const typeMapStyle: Record<MenuItemType, MenuItemProps> = {
primary: {
@@ -107,7 +112,7 @@ const MyMenu = ({
direction={'ltr'}
isLazy
lazyBehavior={'keepMounted'}
placement="bottom-start"
placement={placement}
computePositionOnMount
>
<Box
@@ -172,7 +177,14 @@ const MyMenu = ({
_notLast={{ mb: 0.5 }}
{...typeMapStyle[child.type || 'primary']}
>
{!!child.icon && <Avatar src={child.icon as any} w={iconSize} mr={3} />}
{!!child.icon && (
<Avatar
src={child.icon as any}
borderRadius={iconRadius}
w={iconSize}
mr={3}
/>
)}
<Box>
<Box color={child.description ? 'myGray.900' : 'inherit'} fontSize={'sm'}>
{child.label}

View File

@@ -128,7 +128,9 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
permission: item.permission,
vectorModel: getVectorModel(item.vectorModel),
defaultPermission: item.defaultPermission ?? DatasetDefaultPermissionVal,
inheritPermission: item.inheritPermission
inheritPermission: item.inheritPermission,
tmbId: item.tmbId,
updateTime: item.updateTime
}))
);

View File

@@ -186,7 +186,7 @@ const MyApps = () => {
{userInfo?.team.permission.hasWritePer &&
folderDetail?.type !== AppTypeEnum.httpPlugin && (
<MyMenu
iconSize="1.5rem"
iconSize="2rem"
Button={
<Button variant={'primary'} leftIcon={<AddIcon />}>
<Box>{t('common:common.Create New')}</Box>

View File

@@ -17,8 +17,7 @@ import { useTranslation } from 'next-i18next';
import { DatasetTypeEnum } from '@fastgpt/global/core/dataset/constants';
import { MongoImageTypeEnum } from '@fastgpt/global/common/file/image/constants';
import AIModelSelector from '@/components/Select/AIModelSelector';
import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip';
import MyIcon from '@fastgpt/web/components/common/Icon';
import { useSystem } from '@fastgpt/web/hooks/useSystem';
export type CreateDatasetType =
@@ -116,17 +115,23 @@ const CreateModal = ({
return (
<MyModal
iconSrc={iconMap[type]}
title={t('common:core.dataset.Create dataset', { name: databaseNameMap[type] })}
title={
<Flex alignItems={'center'} ml={-3}>
<Avatar w={'20px'} h={'20px'} borderRadius={'4px'} src={iconMap[type]} pr={'10px'} />
{t('common:core.dataset.Create dataset', { name: databaseNameMap[type] })}
</Flex>
}
isOpen
onClose={onClose}
isCentered={!isPc}
w={'450px'}
w={'490px'}
>
<ModalBody py={2}>
<Box mt={5}>
<Box color={'myGray.900'}>{t('common:common.Set Name')}</Box>
<Flex mt={1} alignItems={'center'}>
<ModalBody py={'24px'} px={'36px'}>
<Box>
<Box color={'myGray.900'} fontWeight={500} fontSize={'14px'}>
{t('common:common.Set Name')}
</Box>
<Flex mt={'12px'} alignItems={'center'}>
<MyTooltip label={t('common:common.avatar.Select Avatar')}>
<Avatar
flexShrink={0}
@@ -152,14 +157,28 @@ const CreateModal = ({
</Flex>
</Box>
{filterNotHiddenVectorModelList.length > 1 && (
<Flex mt={6} alignItems={'center'}>
<Flex alignItems={'center'} flex={'0 0 100px'} fontSize={'sm'}>
<Flex
mt={6}
alignItems={['flex-start', 'center']}
justify={'space-between'}
flexDir={['column', 'row']}
>
<Flex
alignItems={'center'}
flex={['', '0 0 100px']}
fontSize={'sm'}
color={'myGray.900'}
fontWeight={500}
pb={['12px', '0']}
>
{t('common:core.ai.model.Vector Model')}
<QuestionTip label={t('common:core.dataset.embedding model tip')} />
<MyTooltip label={t('common:core.dataset.embedding model tip')}>
<MyIcon w={'16px'} h={'16px'} color={'myGray.500'} ml={'4px'} name="common/help" />
</MyTooltip>
</Flex>
<Box flex={1}>
<Box w={['100%', '300px']}>
<AIModelSelector
w={'100%'}
w={['100%', '300px']}
value={vectorModel}
list={filterNotHiddenVectorModelList.map((item) => ({
label: item.name,
@@ -173,13 +192,24 @@ const CreateModal = ({
</Flex>
)}
{datasetModelList.length > 1 && (
<Flex mt={6} alignItems={'center'}>
<Box flex={'0 0 100px'} fontSize={'sm'}>
<Flex
mt={6}
alignItems={['flex-start', 'center']}
justify={'space-between'}
flexDir={['column', 'row']}
>
<Box
flex={['', '0 0 100px']}
fontSize={'sm'}
color={'myGray.900'}
fontWeight={500}
pb={['12px', '0']}
>
{t('common:core.ai.model.Dataset Agent Model')}
</Box>
<Box flex={1}>
<Box w={['100%', '300px']}>
<AIModelSelector
w={'100%'}
w={['100%', '300px']}
value={agentModel}
list={datasetModelList.map((item) => ({
label: item.name,
@@ -194,7 +224,7 @@ const CreateModal = ({
)}
</ModalBody>
<ModalFooter>
<ModalFooter pt={'0px'} pb={'24px'}>
<Button variant={'whiteBase'} mr={3} onClick={onClose}>
{t('common:common.Close')}
</Button>

View File

@@ -1,16 +1,15 @@
import React, { useMemo, useRef, useState } from 'react';
import { resumeInheritPer } from '@/web/core/dataset/api';
import { useDatasetStore } from '@/web/core/dataset/store/dataset';
import { Box, Flex, Grid } from '@chakra-ui/react';
import { Box, Flex, Grid, HStack } from '@chakra-ui/react';
import { DatasetTypeEnum, DatasetTypeMap } from '@fastgpt/global/core/dataset/constants';
import MyMenu from '@fastgpt/web/components/common/MyMenu';
import MyIcon from '@fastgpt/web/components/common/Icon';
import { useRouter } from 'next/router';
import PermissionIconText from '@/components/support/permission/IconText';
import DatasetTypeTag from '@/components/core/dataset/DatasetTypeTag';
import Avatar from '@fastgpt/web/components/common/Avatar';
import { useConfirm } from '@fastgpt/web/hooks/useConfirm';
import { useRequest } from '@fastgpt/web/hooks/useRequest';
import { useRequest, useRequest2 } from '@fastgpt/web/hooks/useRequest';
import { DatasetItemType } from '@fastgpt/global/core/dataset/type';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import { useToast } from '@fastgpt/web/hooks/useToast';
@@ -35,12 +34,18 @@ import { useFolderDrag } from '@/components/common/folder/useFolderDrag';
import MyBox from '@fastgpt/web/components/common/MyBox';
import { useI18n } from '@/web/context/I18n';
import { useTranslation } from 'next-i18next';
import { useUserStore } from '@/web/support/user/useUserStore';
import { formatTimeToChatTime } from '@fastgpt/global/common/string/time';
import { useSystem } from '@fastgpt/web/hooks/useSystem';
import SideTag from './SideTag';
function List() {
const { setLoading } = useSystemStore();
const { toast } = useToast();
const { isPc } = useSystem();
const { t } = useTranslation();
const { commonT } = useI18n();
const { loadAndGetTeamMembers } = useUserStore();
const {
loadMyDatasets,
setMoveDatasetId,
@@ -71,6 +76,10 @@ function List() {
}
});
const { data: members = [], loading: isLoadMembers } = useRequest2(loadAndGetTeamMembers, {
manual: false
});
const editPerDataset = useMemo(
() => (editPerDatasetIndex !== undefined ? myDatasets[editPerDatasetIndex] : undefined),
[editPerDatasetIndex, myDatasets]
@@ -152,197 +161,238 @@ function List() {
gridGap={5}
alignItems={'stretch'}
>
{formatDatasets.map((dataset, index) => (
<MyTooltip
key={dataset._id}
label={
<Flex flexDirection={'column'} alignItems={'center'}>
<Box fontSize={'xs'} color={'myGray.500'}>
{dataset.type === DatasetTypeEnum.folder
? t('common.folder.Open folder')
: t('common.folder.open_dataset')}
</Box>
</Flex>
}
>
<MyBox
isLoading={loadingDatasetId === dataset._id}
display={'flex'}
flexDirection={'column'}
lineHeight={1.5}
h="100%"
py={3}
px={5}
cursor={'pointer'}
borderWidth={1.5}
border={'base'}
boxShadow={'2'}
bg={'white'}
borderRadius={'lg'}
position={'relative'}
minH={'150px'}
{...getBoxProps({
dataId: dataset._id,
isFolder: dataset.type === DatasetTypeEnum.folder
})}
_hover={{
borderColor: 'primary.300',
boxShadow: '1.5',
'& .delete': {
display: 'block'
},
'& .more': {
display: 'flex'
{!isLoadMembers &&
formatDatasets.map((dataset, index) => {
const owner = members.find((v) => v.tmbId === dataset.tmbId);
return (
<MyTooltip
key={dataset._id}
label={
<Flex flexDirection={'column'} alignItems={'center'}>
<Box fontSize={'xs'} color={'myGray.500'}>
{dataset.type === DatasetTypeEnum.folder
? t('common.folder.Open folder')
: t('common.folder.open_dataset')}
</Box>
</Flex>
}
}}
onClick={() => {
if (dataset.type === DatasetTypeEnum.folder) {
router.push({
pathname: '/dataset/list',
query: {
parentId: dataset._id
}
});
} else {
router.push({
pathname: '/dataset/detail',
query: {
datasetId: dataset._id
}
});
}
}}
>
{dataset.permission.hasWritePer && (
<Box
className="more"
display={['', 'none']}
position={'absolute'}
top={3.5}
right={4}
borderRadius={'md'}
>
<MyBox
isLoading={loadingDatasetId === dataset._id}
display={'flex'}
flexDirection={'column'}
lineHeight={1.5}
h="100%"
pt={5}
pb={3}
px={5}
cursor={'pointer'}
borderWidth={1.5}
border={'base'}
boxShadow={'2'}
bg={'white'}
borderRadius={'lg'}
position={'relative'}
minH={'150px'}
{...getBoxProps({
dataId: dataset._id,
isFolder: dataset.type === DatasetTypeEnum.folder
})}
_hover={{
color: 'primary.500',
'& .icon': {
bg: 'myGray.100'
borderColor: 'primary.300',
boxShadow: '1.5',
'& .delete': {
display: 'block'
},
'& .more': {
display: 'flex'
},
'& .time': {
display: ['flex', 'none']
}
}}
onClick={(e) => {
e.stopPropagation();
onClick={() => {
if (dataset.type === DatasetTypeEnum.folder) {
router.push({
pathname: '/dataset/list',
query: {
parentId: dataset._id
}
});
} else {
router.push({
pathname: '/dataset/detail',
query: {
datasetId: dataset._id
}
});
}
}}
>
<MyMenu
Button={
<Box w={'22px'} h={'22px'}>
<MyIcon
className="icon"
name={'more'}
h={'16px'}
w={'16px'}
px={1}
py={1}
borderRadius={'md'}
cursor={'pointer'}
/>
</Box>
}
menuList={[
{
children: [
{
icon: 'edit',
label: commonT('dataset.Edit Info'),
onClick: () =>
setEditedDataset({
id: dataset._id,
name: dataset.name,
intro: dataset.intro,
avatar: dataset.avatar
})
},
{
icon: 'common/file/move',
label: t('common:Move'),
onClick: () => setMoveDatasetId(dataset._id)
},
...(dataset.permission.hasManagePer
? [
{
icon: 'support/team/key',
label: t('common:permission.Permission'),
onClick: () => setEditPerDatasetIndex(index)
}
]
: [])
]
},
...(dataset.type != DatasetTypeEnum.folder
? [
{
children: [
{
icon: 'export',
label: t('common:Export'),
onClick: () => {
exportDataset(dataset);
}
}
]
}
]
: []),
...(dataset.permission.hasManagePer
? [
{
children: [
{
icon: 'delete',
label: t('common:common.Delete'),
type: 'danger' as 'danger',
onClick: () => onClickDeleteDataset(dataset._id)
}
]
}
]
: [])
]}
/>
</Box>
)}
<HStack>
<Avatar src={dataset.avatar} borderRadius={6} w={'28px'} />
<Box flex={'1 0 0'} className="textEllipsis3">
{dataset.name}
</Box>
<Flex alignItems={'center'} h={'38px'}>
<Avatar src={dataset.avatar} borderRadius={'md'} w={'28px'} />
<Box mx={3} className="textEllipsis3">
{dataset.name}
</Box>
</Flex>
<Box
flex={1}
className={'textEllipsis3'}
py={1}
wordBreak={'break-all'}
fontSize={'xs'}
color={'myGray.500'}
>
{dataset.intro ||
(dataset.type === DatasetTypeEnum.folder
? t('common:core.dataset.Folder placeholder')
: t('common:core.dataset.Intro Placeholder'))}
</Box>
<Flex alignItems={'center'} fontSize={'sm'}>
<Box flex={1}>
<PermissionIconText
defaultPermission={dataset.defaultPermission}
color={'myGray.600'}
/>
</Box>
{dataset.type !== DatasetTypeEnum.folder && (
<DatasetTypeTag type={dataset.type} py={1} px={2} />
)}
</Flex>
</MyBox>
</MyTooltip>
))}
<Box mr={'-1.25rem'}>
{dataset.type !== DatasetTypeEnum.folder && (
<SideTag
type={dataset.type}
py={0.5}
px={2}
borderLeftRadius={'sm'}
borderRightRadius={0}
/>
)}
</Box>
</HStack>
<Box
flex={1}
className={'textEllipsis3'}
py={3}
wordBreak={'break-all'}
fontSize={'xs'}
color={'myGray.500'}
>
{dataset.intro ||
(dataset.type === DatasetTypeEnum.folder
? t('common:core.dataset.Folder placeholder')
: t('common:core.dataset.Intro Placeholder'))}
</Box>
<Flex
h={'24px'}
alignItems={'center'}
justifyContent={'space-between'}
fontSize={'12px'}
fontWeight={500}
color={'myGray.500'}
>
<HStack spacing={3.5}>
{owner && (
<HStack spacing={1}>
<Avatar src={owner.avatar} w={'0.875rem'} borderRadius={'50%'} />
<Box maxW={'150px'} className="textEllipsis">
{owner.memberName}
</Box>
</HStack>
)}
<PermissionIconText
iconColor="myGray.400"
defaultPermission={dataset.defaultPermission}
color={'myGray.500'}
/>
</HStack>
<HStack>
{isPc && (
<HStack spacing={1} className="time">
<MyIcon name={'history'} w={'0.85rem'} color={'myGray.400'} />
<Box color={'myGray.500'}>
{formatTimeToChatTime(dataset.updateTime)}
</Box>
</HStack>
)}
{dataset.permission.hasWritePer && (
<Box
className="more"
display={['', 'none']}
borderRadius={'md'}
_hover={{
'& .icon': {
bg: 'myGray.100'
}
}}
onClick={(e) => {
e.stopPropagation();
}}
>
<MyMenu
Button={
<Box w={'22px'} h={'22px'}>
<MyIcon
className="icon"
name={'more'}
h={'16px'}
w={'16px'}
px={1}
py={1}
borderRadius={'md'}
cursor={'pointer'}
/>
</Box>
}
menuList={[
{
children: [
{
icon: 'edit',
label: commonT('dataset.Edit Info'),
onClick: () =>
setEditedDataset({
id: dataset._id,
name: dataset.name,
intro: dataset.intro,
avatar: dataset.avatar
})
},
{
icon: 'common/file/move',
label: t('common:Move'),
onClick: () => setMoveDatasetId(dataset._id)
},
...(dataset.permission.hasManagePer
? [
{
icon: 'support/team/key',
label: t('common:permission.Permission'),
onClick: () => setEditPerDatasetIndex(index)
}
]
: [])
]
},
...(dataset.type != DatasetTypeEnum.folder
? [
{
children: [
{
icon: 'export',
label: t('common:Export'),
onClick: () => {
exportDataset(dataset);
}
}
]
}
]
: []),
...(dataset.permission.hasManagePer
? [
{
children: [
{
icon: 'delete',
label: t('common:common.Delete'),
type: 'danger' as 'danger',
onClick: () => onClickDeleteDataset(dataset._id)
}
]
}
]
: [])
]}
/>
</Box>
)}
</HStack>
</Flex>
</MyBox>
</MyTooltip>
);
})}
</Grid>
)}
{myDatasets.length === 0 && (

View File

@@ -0,0 +1,53 @@
import { Box, Flex, FlexProps } from '@chakra-ui/react';
import { DatasetTypeEnum } from '@fastgpt/global/core/dataset/constants';
import MyIcon from '@fastgpt/web/components/common/Icon';
import React, { useMemo } from 'react';
import { useTranslation } from 'next-i18next';
const SideTag = ({ type, ...props }: { type: `${DatasetTypeEnum}` } & FlexProps) => {
if (type === DatasetTypeEnum.folder) return null;
const { t } = useTranslation();
const DatasetListTypeMap = useMemo(() => {
return {
[DatasetTypeEnum.dataset]: {
icon: 'core/dataset/commonDatasetOutline',
label: t('dataset:common_dataset'),
collectionLabel: 'common.File'
},
[DatasetTypeEnum.websiteDataset]: {
icon: 'core/dataset/websiteDatasetOutline',
label: t('dataset:website_dataset'),
collectionLabel: 'common.Website'
},
[DatasetTypeEnum.externalFile]: {
icon: 'core/dataset/externalDatasetOutline',
label: t('dataset:external_file'),
collectionLabel: 'common.File'
}
};
}, [t]);
const item = DatasetListTypeMap[type] || DatasetListTypeMap['dataset'];
return (
<Flex
bg={'myGray.100'}
borderWidth={'1px'}
borderColor={'myGray.200'}
py={'3px'}
pl={'8px'}
pr={'12px'}
borderRadius={'md'}
fontSize={'xs'}
alignItems={'center'}
{...props}
>
<MyIcon name={item.icon as any} w={'0.8rem'} color={'myGray.400'} />
<Box fontSize={'mini'} ml={1}>
{/* @ts-ignore */}
{item.label}
</Box>
</Flex>
);
};
export default SideTag;

View File

@@ -10,7 +10,6 @@ import {
Input
} from '@chakra-ui/react';
import { useRouter } from 'next/router';
import PageContainer from '@/components/PageContainer';
import { useTranslation } from 'next-i18next';
import { serviceSideProps } from '@/web/common/utils/i18n';
import ParentPaths from '@/components/common/folder/Path';
@@ -92,14 +91,17 @@ const Dataset = () => {
const RenderSearchInput = useMemo(
() => (
<InputGroup maxW={['auto', '250px']} pr={4}>
<InputGroup maxW={['auto', '250px']} pr={[0, 4]}>
<InputLeftElement h={'full'} alignItems={'center'} display={'flex'}>
<MyIcon name={'common/searchLight'} w={'1rem'} />
<MyIcon color={'myGray.600'} name={'common/searchLight'} w={'1rem'} />
</InputLeftElement>
<Input
pl={'34px'}
value={searchKey}
onChange={(e) => setSearchKey(e.target.value)}
placeholder={t('common:dataset.dataset_name')}
py={0}
lineHeight={'34px'}
maxLength={30}
bg={'white'}
/>
@@ -112,15 +114,23 @@ const Dataset = () => {
isLoading={myDatasets.length === 0 && isFetchingDatasets}
flexDirection={'column'}
h={'100%'}
overflowY={'auto'}
overflowX={'hidden'}
>
<Flex pt={[4, 6]} pl={3} pr={10}>
<Flex pt={[4, 6]} pl={3} pr={[3, 10]}>
<Flex flexGrow={1} flexDirection="column">
<Flex alignItems={'flex-start'} justifyContent={'space-between'}>
<ParentPaths
paths={paths}
FirstPathDom={
<Flex flex={1} alignItems={'center'}>
<Box pl={2} letterSpacing={1} fontSize={'1.25rem'} fontWeight={'bold'}>
<Box
pl={2}
letterSpacing={1}
fontSize={'1.25rem'}
fontWeight={'bold'}
color={'myGray.900'}
>
{t('common:core.dataset.My Dataset')}
</Box>
</Flex>
@@ -138,9 +148,11 @@ const Dataset = () => {
{userInfo?.team?.permission.hasWritePer && (
<MyMenu
offset={[-30, 5]}
offset={[0, 10]}
width={120}
iconSize="2rem"
iconRadius="6px"
placement="bottom-end"
Button={
<Button variant={'primary'} px="0">
<Flex alignItems={'center'} px={'20px'}>
@@ -204,7 +216,7 @@ const Dataset = () => {
name={folderDetail.name}
intro={folderDetail.intro}
onEdit={() => {
setEditedDataset({
setEditFolderData({
id: folderDetail._id,
name: folderDetail.name,
intro: folderDetail.intro
@@ -263,6 +275,7 @@ const Dataset = () => {
{!!editFolderData && (
<EditFolderModal
{...editFolderData}
onClose={() => setEditFolderData(undefined)}
onCreate={async ({ name, intro }) => {
try {