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
b33da6a0
Commit
b33da6a0
authored
Mar 03, 2024
by
JzoNg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
duplicate app supported
parent
7ae23d55
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
9 deletions
+16
-9
AppCard.tsx
web/app/(commonLayout)/apps/AppCard.tsx
+13
-8
index.tsx
web/app/components/app/duplicate-modal/index.tsx
+0
-1
apps.ts
web/service/apps.ts
+3
-0
No files found.
web/app/(commonLayout)/apps/AppCard.tsx
View file @
b33da6a0
...
...
@@ -13,7 +13,7 @@ import type { ConfigParams } from '@/app/components/app/overview/settings'
import
type
{
App
}
from
'@/types/app'
import
Confirm
from
'@/app/components/base/confirm'
import
{
ToastContext
}
from
'@/app/components/base/toast'
import
{
c
reate
App
,
deleteApp
,
fetchAppDetail
,
updateAppSiteConfig
}
from
'@/service/apps'
import
{
c
opy
App
,
deleteApp
,
fetchAppDetail
,
updateAppSiteConfig
}
from
'@/service/apps'
import
DuplicateAppModal
from
'@/app/components/app/duplicate-modal'
import
type
{
DuplicateAppModalProps
}
from
'@/app/components/app/duplicate-modal'
import
AppIcon
from
'@/app/components/base/app-icon'
...
...
@@ -106,16 +106,14 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => {
[
app
.
id
],
)
const
onCreate
:
DuplicateAppModalProps
[
'onConfirm'
]
=
async
({
name
,
icon
,
icon_background
})
=>
{
const
{
app_model_config
:
model_config
}
=
await
fetchAppDetail
({
url
:
'/apps'
,
id
:
app
.
id
})
const
onCopy
:
DuplicateAppModalProps
[
'onConfirm'
]
=
async
({
name
,
icon
,
icon_background
})
=>
{
try
{
const
newApp
=
await
createApp
({
const
newApp
=
await
copyApp
({
appID
:
app
.
id
,
name
,
icon
,
icon_background
,
mode
:
app
.
mode
,
config
:
model_config
,
})
setShowDuplicateModal
(
false
)
notify
({
...
...
@@ -123,7 +121,14 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => {
message
:
t
(
'app.newApp.appCreated'
),
})
localStorage
.
setItem
(
NEED_REFRESH_APP_LIST_KEY
,
'1'
)
push
(
`/app/
${
newApp
.
id
}
/
${
isCurrentWorkspaceManager
?
'configuration'
:
'overview'
}
`
)
if
(
!
isCurrentWorkspaceManager
)
{
push
(
`/app/
${
newApp
.
id
}
/'overview'`
)
}
else
{
if
(
newApp
.
mode
===
'workflow'
||
newApp
.
mode
===
'advanced-chat'
)
push
(
`/app/
${
newApp
.
id
}
/'workflow'`
)
push
(
`/app/
${
newApp
.
id
}
/'configuration'`
)
}
}
catch
(
e
)
{
notify
({
type
:
'error'
,
message
:
t
(
'app.newApp.appCreateFailed'
)
})
...
...
@@ -237,7 +242,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => {
icon=
{
app
.
icon
}
icon_background=
{
app
.
icon_background
}
show=
{
showDuplicateModal
}
onConfirm=
{
onC
reate
}
onConfirm=
{
onC
opy
}
onHide=
{
()
=>
setShowDuplicateModal
(
false
)
}
/>
)
}
...
...
web/app/components/app/duplicate-modal/index.tsx
View file @
b33da6a0
...
...
@@ -72,7 +72,6 @@ const DuplicateAppModal = ({
className=
'h-10 px-3 text-sm font-normal bg-gray-100 rounded-lg grow'
/>
</
div
>
{
/* TODO loc */
}
{
isAppsFull
&&
<
AppsFull
loc=
'app-duplicate-create'
/>
}
</
div
>
<
div
className=
'flex flex-row-reverse'
>
...
...
web/service/apps.ts
View file @
b33da6a0
...
...
@@ -19,6 +19,9 @@ export const fetchAppTemplates: Fetcher<AppTemplatesResponse, { url: string }> =
export
const
createApp
:
Fetcher
<
AppDetailResponse
,
{
name
:
string
;
icon
:
string
;
icon_background
:
string
;
mode
:
AppMode
;
description
?:
string
;
config
?:
ModelConfig
}
>
=
({
name
,
icon
,
icon_background
,
mode
,
description
,
config
})
=>
{
return
post
<
AppDetailResponse
>
(
'apps'
,
{
body
:
{
name
,
icon
,
icon_background
,
mode
,
description
,
model_config
:
config
}
})
}
export
const
copyApp
:
Fetcher
<
AppDetailResponse
,
{
appID
:
string
;
name
:
string
;
icon
:
string
;
icon_background
:
string
;
mode
:
AppMode
;
description
?:
string
}
>
=
({
appID
,
name
,
icon
,
icon_background
,
mode
,
description
})
=>
{
return
post
<
AppDetailResponse
>
(
`apps/
${
appID
}
/copy`
,
{
body
:
{
name
,
icon
,
icon_background
,
mode
,
description
}
})
}
export
const
deleteApp
:
Fetcher
<
CommonResponse
,
string
>
=
(
appID
)
=>
{
return
del
<
CommonResponse
>
(
`apps/
${
appID
}
`
)
...
...
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