Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
677aec94
Commit
677aec94
authored
Jun 14, 2023
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dataset document list add notion icon
parent
92913251
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
42 deletions
+23
-42
index.tsx
web/app/components/base/notion-icon/index.tsx
+9
-8
index.tsx
...ponents/base/notion-page-selector/page-selector/index.tsx
+1
-8
index.tsx
.../components/datasets/create/notion-page-preview/index.tsx
+1
-11
index.tsx
web/app/components/datasets/create/step-two/index.tsx
+1
-12
list.tsx
web/app/components/datasets/documents/list.tsx
+7
-2
style.module.css
web/app/components/datasets/documents/style.module.css
+3
-0
datasets.ts
web/models/datasets.ts
+1
-1
No files found.
web/app/components/base/notion-icon/index.tsx
View file @
677aec94
import
cn
from
'classnames'
import
cn
from
'classnames'
import
s
from
'./index.module.css'
import
s
from
'./index.module.css'
import
type
{
DataSourceNotionPage
}
from
'@/models/common'
type
IconTypes
=
'workspace'
|
'page'
type
NotionIconProps
=
{
type
NotionIconProps
=
{
type
?:
'workspace'
|
'page'
type
?:
IconTypes
src
?:
string
|
null
name
?:
string
|
null
name
?:
string
|
null
className
?:
string
className
?:
string
src
?:
string
|
null
|
Pick
<
DataSourceNotionPage
,
'page_icon'
>
[
'page_icon'
]
}
}
const
NotionIcon
=
({
const
NotionIcon
=
({
type
=
'workspace'
,
type
=
'workspace'
,
src
,
src
,
...
@@ -15,7 +16,7 @@ const NotionIcon = ({
...
@@ -15,7 +16,7 @@ const NotionIcon = ({
className
,
className
,
}:
NotionIconProps
)
=>
{
}:
NotionIconProps
)
=>
{
if
(
type
===
'workspace'
)
{
if
(
type
===
'workspace'
)
{
if
(
src
)
{
if
(
typeof
src
===
'string'
)
{
if
(
src
.
startsWith
(
'https://'
)
||
src
.
startsWith
(
'http://'
))
{
if
(
src
.
startsWith
(
'https://'
)
||
src
.
startsWith
(
'http://'
))
{
return
(
return
(
<
img
<
img
...
@@ -34,18 +35,18 @@ const NotionIcon = ({
...
@@ -34,18 +35,18 @@ const NotionIcon = ({
)
)
}
}
if
(
src
)
{
if
(
typeof
src
===
'object'
&&
src
!==
null
)
{
if
(
src
.
startsWith
(
'https://'
)
||
src
.
startsWith
(
'http://'
)
)
{
if
(
src
?.
type
===
'url'
)
{
return
(
return
(
<
img
<
img
alt=
'page icon'
alt=
'page icon'
src=
{
src
}
src=
{
src
.
url
||
''
}
className=
{
cn
(
'block object-cover w-5 h-5'
,
className
)
}
className=
{
cn
(
'block object-cover w-5 h-5'
,
className
)
}
/>
/>
)
)
}
}
return
(
return
(
<
div
className=
{
cn
(
'flex items-center justify-center w-5 h-5'
,
className
)
}
>
{
src
}
</
div
>
<
div
className=
{
cn
(
'flex items-center justify-center w-5 h-5'
,
className
)
}
>
{
src
?.
emoji
}
</
div
>
)
)
}
}
...
...
web/app/components/base/notion-page-selector/page-selector/index.tsx
View file @
677aec94
...
@@ -83,13 +83,6 @@ const Item = memo(({ index, style, data }: ListChildComponentProps<{
...
@@ -83,13 +83,6 @@ const Item = memo(({ index, style, data }: ListChildComponentProps<{
const
hasChild
=
currentWithChildrenAndDescendants
.
descendants
.
size
>
0
const
hasChild
=
currentWithChildrenAndDescendants
.
descendants
.
size
>
0
const
ancestors
=
currentWithChildrenAndDescendants
.
ancestors
const
ancestors
=
currentWithChildrenAndDescendants
.
ancestors
const
breadCrumbs
=
ancestors
.
length
?
[...
ancestors
,
current
.
page_name
]
:
[
current
.
page_name
]
const
breadCrumbs
=
ancestors
.
length
?
[...
ancestors
,
current
.
page_name
]
:
[
current
.
page_name
]
let
iconSrc
if
(
current
.
page_icon
&&
current
.
page_icon
.
type
===
'url'
)
iconSrc
=
current
.
page_icon
.
url
if
(
current
.
page_icon
&&
current
.
page_icon
.
type
===
'emoji'
)
iconSrc
=
current
.
page_icon
.
emoji
const
renderArrow
=
()
=>
{
const
renderArrow
=
()
=>
{
return
hasChild
return
hasChild
...
@@ -119,7 +112,7 @@ const Item = memo(({ index, style, data }: ListChildComponentProps<{
...
@@ -119,7 +112,7 @@ const Item = memo(({ index, style, data }: ListChildComponentProps<{
<
NotionIcon
<
NotionIcon
className=
'shrink-0 mr-1'
className=
'shrink-0 mr-1'
type=
'page'
type=
'page'
src=
{
iconSrc
}
src=
{
current
.
page_icon
}
/>
/>
<
div
<
div
className=
'grow text-sm font-medium text-gray-700 truncate'
className=
'grow text-sm font-medium text-gray-700 truncate'
...
...
web/app/components/datasets/create/notion-page-preview/index.tsx
View file @
677aec94
...
@@ -35,16 +35,6 @@ const NotionPagePreview = ({
...
@@ -35,16 +35,6 @@ const NotionPagePreview = ({
}
}
catch
{}
catch
{}
}
}
const
getIcon
=
()
=>
{
let
iconSrc
if
(
currentPage
)
{
if
(
currentPage
.
page_icon
&&
currentPage
.
page_icon
.
type
===
'url'
)
iconSrc
=
currentPage
.
page_icon
.
url
if
(
currentPage
.
page_icon
&&
currentPage
.
page_icon
.
type
===
'emoji'
)
iconSrc
=
currentPage
.
page_icon
.
emoji
}
return
iconSrc
}
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
currentPage
)
{
if
(
currentPage
)
{
...
@@ -66,7 +56,7 @@ const NotionPagePreview = ({
...
@@ -66,7 +56,7 @@ const NotionPagePreview = ({
<
NotionIcon
<
NotionIcon
className=
'shrink-0 mr-1'
className=
'shrink-0 mr-1'
type=
'page'
type=
'page'
src=
{
getIcon
()
}
src=
{
currentPage
?.
page_icon
}
/>
/>
{
currentPage
?.
page_name
}
{
currentPage
?.
page_name
}
</
div
>
</
div
>
...
...
web/app/components/datasets/create/step-two/index.tsx
View file @
677aec94
...
@@ -326,17 +326,6 @@ const StepTwo = ({
...
@@ -326,17 +326,6 @@ const StepTwo = ({
}
}
}
}
const
getIcon
=
()
=>
{
let
iconSrc
if
(
notionPages
.
length
>
0
)
{
if
(
notionPages
[
0
].
page_icon
&&
notionPages
[
0
].
page_icon
.
type
===
'url'
)
iconSrc
=
notionPages
[
0
].
page_icon
.
url
if
(
notionPages
[
0
].
page_icon
&&
notionPages
[
0
].
page_icon
.
type
===
'emoji'
)
iconSrc
=
notionPages
[
0
].
page_icon
.
emoji
}
return
iconSrc
}
useEffect
(()
=>
{
useEffect
(()
=>
{
// fetch rules
// fetch rules
if
(
!
isSetting
)
{
if
(
!
isSetting
)
{
...
@@ -558,7 +547,7 @@ const StepTwo = ({
...
@@ -558,7 +547,7 @@ const StepTwo = ({
<
NotionIcon
<
NotionIcon
className=
'shrink-0 mr-1'
className=
'shrink-0 mr-1'
type=
'page'
type=
'page'
src=
{
getIcon
()
}
src=
{
notionPages
[
0
]?.
page_icon
}
/>
/>
{
notionPages
[
0
]?.
page_name
}
{
notionPages
[
0
]?.
page_name
}
{
notionPages
.
length
>
1
&&
(
{
notionPages
.
length
>
1
&&
(
...
...
web/app/components/datasets/documents/list.tsx
View file @
677aec94
...
@@ -23,7 +23,8 @@ import Indicator from '@/app/components/header/indicator'
...
@@ -23,7 +23,8 @@ import Indicator from '@/app/components/header/indicator'
import
{
asyncRunSafe
}
from
'@/utils'
import
{
asyncRunSafe
}
from
'@/utils'
import
{
formatNumber
}
from
'@/utils/format'
import
{
formatNumber
}
from
'@/utils/format'
import
{
archiveDocument
,
deleteDocument
,
disableDocument
,
enableDocument
,
syncDocument
}
from
'@/service/datasets'
import
{
archiveDocument
,
deleteDocument
,
disableDocument
,
enableDocument
,
syncDocument
}
from
'@/service/datasets'
import
type
{
DocumentDisplayStatus
,
DocumentListResponse
}
from
'@/models/datasets'
import
NotionIcon
from
'@/app/components/base/notion-icon'
import
{
DataSourceType
,
type
DocumentDisplayStatus
,
type
DocumentListResponse
}
from
'@/models/datasets'
import
type
{
CommonResponse
}
from
'@/models/common'
import
type
{
CommonResponse
}
from
'@/models/common'
export
const
SettingsIcon
:
FC
<
{
className
?:
string
}
>
=
({
className
})
=>
{
export
const
SettingsIcon
:
FC
<
{
className
?:
string
}
>
=
({
className
})
=>
{
...
@@ -311,7 +312,11 @@ const DocumentList: FC<IDocumentListProps> = ({ documents = [], datasetId, onUpd
...
@@ -311,7 +312,11 @@ const DocumentList: FC<IDocumentListProps> = ({ documents = [], datasetId, onUpd
}
}
>
}
}
>
<
td
className=
'text-left align-middle text-gray-500 text-xs'
>
{
doc
.
position
}
</
td
>
<
td
className=
'text-left align-middle text-gray-500 text-xs'
>
{
doc
.
position
}
</
td
>
<
td
className=
{
s
.
tdValue
}
>
<
td
className=
{
s
.
tdValue
}
>
<
div
className=
{
cn
(
s
[
`${doc?.data_source_info?.upload_file?.extension ?? suffix}Icon`
],
s
.
commonIcon
,
'mr-1.5'
)
}
></
div
>
{
doc
?.
data_source_type
===
DataSourceType
.
NOTION
?
<
NotionIcon
className=
'inline-block -mt-[3px] mr-1.5 align-middle'
type=
'page'
src=
{
doc
.
data_source_info
.
notion_page_icon
}
/>
:
<
div
className=
{
cn
(
s
[
`${doc?.data_source_info?.upload_file?.extension ?? suffix}Icon`
],
s
.
commonIcon
,
'mr-1.5'
)
}
></
div
>
}
<
span
>
{
doc
?.
name
?.
replace
(
/
\.[^/
.
]
+$/
,
''
)
}
<
span
className=
'text-gray-500'
>
.
{
suffix
}
</
span
></
span
>
<
span
>
{
doc
?.
name
?.
replace
(
/
\.[^/
.
]
+$/
,
''
)
}
<
span
className=
'text-gray-500'
>
.
{
suffix
}
</
span
></
span
>
</
td
>
</
td
>
<
td
>
{
renderCount
(
doc
.
word_count
)
}
</
td
>
<
td
>
{
renderCount
(
doc
.
word_count
)
}
</
td
>
...
...
web/app/components/datasets/documents/style.module.css
View file @
677aec94
...
@@ -75,6 +75,9 @@
...
@@ -75,6 +75,9 @@
.markdownIcon
{
.markdownIcon
{
background-image
:
url(./assets/md.svg)
;
background-image
:
url(./assets/md.svg)
;
}
}
.mdIcon
{
background-image
:
url(./assets/md.svg)
;
}
.xlsIcon
{
.xlsIcon
{
background-image
:
url(./assets/xlsx.svg)
;
background-image
:
url(./assets/xlsx.svg)
;
}
}
...
...
web/models/datasets.ts
View file @
677aec94
...
@@ -137,7 +137,7 @@ export type InitialDocumentDetail = {
...
@@ -137,7 +137,7 @@ export type InitialDocumentDetail = {
batch
:
string
batch
:
string
position
:
number
position
:
number
dataset_id
:
string
dataset_id
:
string
data_source_type
:
'upload_file'
data_source_type
:
DataSourceType
data_source_info
:
DataSourceInfo
data_source_info
:
DataSourceInfo
dataset_process_rule_id
:
string
dataset_process_rule_id
:
string
name
:
string
name
:
string
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment