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
a98b5ca9
Commit
a98b5ca9
authored
Feb 28, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: auth i18n
parent
076fe8ca
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
13 deletions
+48
-13
index.tsx
...ts/workflow/nodes/http/components/authorization/index.tsx
+17
-11
panel.tsx
web/app/components/workflow/nodes/http/panel.tsx
+7
-2
workflow.ts
web/i18n/en-US/workflow.ts
+12
-0
workflow.ts
web/i18n/zh-Hans/workflow.ts
+12
-0
No files found.
web/app/components/workflow/nodes/http/components/authorization/index.tsx
View file @
a98b5ca9
'use client'
'use client'
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
React
,
{
useCallback
}
from
'react'
import
React
,
{
useCallback
}
from
'react'
import
produce
from
'immer'
import
produce
from
'immer'
import
type
{
Authorization
as
AuthorizationPayloadType
}
from
'../../types'
import
type
{
Authorization
as
AuthorizationPayloadType
}
from
'../../types'
...
@@ -7,6 +8,9 @@ import { APIType, AuthorizationType } from '../../types'
...
@@ -7,6 +8,9 @@ import { APIType, AuthorizationType } from '../../types'
import
RadioGroup
from
'./radio-group'
import
RadioGroup
from
'./radio-group'
import
Modal
from
'@/app/components/base/modal'
import
Modal
from
'@/app/components/base/modal'
import
Button
from
'@/app/components/base/button'
import
Button
from
'@/app/components/base/button'
const
i18nPrefix
=
'workflow.nodes.http.authorization'
type
Props
=
{
type
Props
=
{
payload
:
AuthorizationPayloadType
payload
:
AuthorizationPayloadType
onChange
:
(
newPayload
:
AuthorizationPayloadType
)
=>
void
onChange
:
(
newPayload
:
AuthorizationPayloadType
)
=>
void
...
@@ -29,6 +33,8 @@ const Authorization: FC<Props> = ({
...
@@ -29,6 +33,8 @@ const Authorization: FC<Props> = ({
isShow
,
isShow
,
onHide
,
onHide
,
})
=>
{
})
=>
{
const
{
t
}
=
useTranslation
()
const
[
tempPayload
,
setTempPayload
]
=
React
.
useState
<
AuthorizationPayloadType
>
(
payload
)
const
[
tempPayload
,
setTempPayload
]
=
React
.
useState
<
AuthorizationPayloadType
>
(
payload
)
const
handleAuthTypeChange
=
useCallback
((
type
:
string
)
=>
{
const
handleAuthTypeChange
=
useCallback
((
type
:
string
)
=>
{
const
newPayload
=
produce
(
tempPayload
,
(
draft
:
AuthorizationPayloadType
)
=>
{
const
newPayload
=
produce
(
tempPayload
,
(
draft
:
AuthorizationPayloadType
)
=>
{
...
@@ -84,11 +90,11 @@ const Authorization: FC<Props> = ({
...
@@ -84,11 +90,11 @@ const Authorization: FC<Props> = ({
>
>
<
div
>
<
div
>
<
div
className=
'space-y-2'
>
<
div
className=
'space-y-2'
>
<
Field
title=
'Type'
>
<
Field
title=
{
t
(
`${i18nPrefix}.authorizationType`
)
}
>
<
RadioGroup
<
RadioGroup
options=
{
[
options=
{
[
{
value
:
AuthorizationType
.
none
,
label
:
'Basic'
},
{
value
:
AuthorizationType
.
none
,
label
:
t
(
`${i18nPrefix}.no-auth`
)
},
{
value
:
AuthorizationType
.
apiKey
,
label
:
'Bearer'
},
{
value
:
AuthorizationType
.
apiKey
,
label
:
t
(
`${i18nPrefix}.api-key`
)
},
]
}
]
}
value=
{
tempPayload
.
type
}
value=
{
tempPayload
.
type
}
onChange=
{
handleAuthTypeChange
}
onChange=
{
handleAuthTypeChange
}
...
@@ -97,19 +103,19 @@ const Authorization: FC<Props> = ({
...
@@ -97,19 +103,19 @@ const Authorization: FC<Props> = ({
{
tempPayload
.
type
===
AuthorizationType
.
apiKey
&&
(
{
tempPayload
.
type
===
AuthorizationType
.
apiKey
&&
(
<>
<>
<
Field
title=
'Auth type'
>
<
Field
title=
{
t
(
`${i18nPrefix}.auth-type`
)
}
>
<
RadioGroup
<
RadioGroup
options=
{
[
options=
{
[
{
value
:
APIType
.
basic
,
label
:
'Basic'
},
{
value
:
APIType
.
basic
,
label
:
t
(
`${i18nPrefix}.basic`
)
},
{
value
:
APIType
.
bearer
,
label
:
'Bearer'
},
{
value
:
APIType
.
bearer
,
label
:
t
(
`${i18nPrefix}.bearer`
)
},
{
value
:
APIType
.
custom
,
label
:
'Custom'
},
{
value
:
APIType
.
custom
,
label
:
t
(
`${i18nPrefix}.custom`
)
},
]
}
]
}
value=
{
tempPayload
.
config
?.
type
||
APIType
.
basic
}
value=
{
tempPayload
.
config
?.
type
||
APIType
.
basic
}
onChange=
{
handleAuthAPITypeChange
}
onChange=
{
handleAuthAPITypeChange
}
/>
/>
</
Field
>
</
Field
>
{
tempPayload
.
config
?.
type
===
APIType
.
custom
&&
(
{
tempPayload
.
config
?.
type
===
APIType
.
custom
&&
(
<
Field
title=
'header'
>
<
Field
title=
{
t
(
`${i18nPrefix}.header`
)
}
>
<
input
<
input
type=
'text'
type=
'text'
className=
'w-full h-8 leading-8 px-2.5 rounded-lg border-0 bg-gray-100 text-gray-900 text-[13px] placeholder:text-gray-400 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-gray-200'
className=
'w-full h-8 leading-8 px-2.5 rounded-lg border-0 bg-gray-100 text-gray-900 text-[13px] placeholder:text-gray-400 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-gray-200'
...
@@ -119,7 +125,7 @@ const Authorization: FC<Props> = ({
...
@@ -119,7 +125,7 @@ const Authorization: FC<Props> = ({
</
Field
>
</
Field
>
)
}
)
}
<
Field
title=
'API Key'
>
<
Field
title=
{
t
(
`${i18nPrefix}.api-key-title`
)
}
>
<
input
<
input
type=
'text'
type=
'text'
className=
'w-full h-8 leading-8 px-2.5 rounded-lg border-0 bg-gray-100 text-gray-900 text-[13px] placeholder:text-gray-400 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-gray-200'
className=
'w-full h-8 leading-8 px-2.5 rounded-lg border-0 bg-gray-100 text-gray-900 text-[13px] placeholder:text-gray-400 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-gray-200'
...
@@ -131,8 +137,8 @@ const Authorization: FC<Props> = ({
...
@@ -131,8 +137,8 @@ const Authorization: FC<Props> = ({
)
}
)
}
</
div
>
</
div
>
<
div
className=
'mt-6 flex justify-end space-x-2'
>
<
div
className=
'mt-6 flex justify-end space-x-2'
>
<
Button
onClick=
{
onHide
}
className=
'flex items-center !h-8 leading-[18px] !text-[13px] !font-medium'
>
Cancel
</
Button
>
<
Button
onClick=
{
onHide
}
className=
'flex items-center !h-8 leading-[18px] !text-[13px] !font-medium'
>
{
t
(
'common.operation.cancel'
)
}
</
Button
>
<
Button
type=
'primary'
onClick=
{
handleConfirm
}
className=
'flex items-center !h-8 leading-[18px] !text-[13px] !font-medium'
>
Confirm
</
Button
>
<
Button
type=
'primary'
onClick=
{
handleConfirm
}
className=
'flex items-center !h-8 leading-[18px] !text-[13px] !font-medium'
>
{
t
(
'common.operation.save'
)
}
</
Button
>
</
div
>
</
div
>
</
div
>
</
div
>
</
Modal
>
</
Modal
>
...
...
web/app/components/workflow/nodes/http/panel.tsx
View file @
a98b5ca9
...
@@ -11,6 +11,7 @@ import Field from '@/app/components/workflow/nodes/_base/components/field'
...
@@ -11,6 +11,7 @@ import Field from '@/app/components/workflow/nodes/_base/components/field'
import
AddButton
from
'@/app/components/base/button/add-button'
import
AddButton
from
'@/app/components/base/button/add-button'
import
Split
from
'@/app/components/workflow/nodes/_base/components/split'
import
Split
from
'@/app/components/workflow/nodes/_base/components/split'
import
OutputVars
,
{
VarItem
}
from
'@/app/components/workflow/nodes/_base/components/output-vars'
import
OutputVars
,
{
VarItem
}
from
'@/app/components/workflow/nodes/_base/components/output-vars'
import
{
Settings01
}
from
'@/app/components/base/icons/src/vender/line/general'
const
i18nPrefix
=
'workflow.nodes.http'
const
i18nPrefix
=
'workflow.nodes.http'
const
Panel
:
FC
=
()
=>
{
const
Panel
:
FC
=
()
=>
{
...
@@ -60,9 +61,13 @@ const Panel: FC = () => {
...
@@ -60,9 +61,13 @@ const Panel: FC = () => {
operations=
{
operations=
{
<
div
<
div
onClick=
{
showAuthorization
}
onClick=
{
showAuthorization
}
className=
'flex '
className=
'flex
items-center h-6 space-x-1 cursor-pointer
'
>
>
API-KEY
<
Settings01
className=
'w-3 h-3 text-gray-500'
/>
<
div
className=
'text-xs font-medium text-gray-500'
>
{
t
(
`${i18nPrefix}.authorization.authorization`
)
}
<
span
className=
'ml-1 text-gray-700'
>
{
t
(
`${i18nPrefix}.authorization.${inputs.authorization.type}`
)
}
</
span
>
</
div
>
</
div
>
</
div
>
}
}
>
>
...
...
web/i18n/en-US/workflow.ts
View file @
a98b5ca9
...
@@ -61,6 +61,18 @@ const translation = {
...
@@ -61,6 +61,18 @@ const translation = {
statusCode
:
'Response Status Code'
,
statusCode
:
'Response Status Code'
,
headers
:
'Response Header List JSON'
,
headers
:
'Response Header List JSON'
,
},
},
authorization
:
{
'authorization'
:
'Authorization'
,
'authorizationType'
:
'Authorization Type'
,
'no-auth'
:
'None'
,
'api-key'
:
'API-Key'
,
'auth-type'
:
'Auth Type'
,
'basic'
:
'Basic'
,
'bearer'
:
'Bearer'
,
'custom'
:
'Custom'
,
'api-key-title'
:
'API Key'
,
'header'
:
'Header'
,
},
},
},
code
:
{
code
:
{
inputVars
:
'Input Variables'
,
inputVars
:
'Input Variables'
,
...
...
web/i18n/zh-Hans/workflow.ts
View file @
a98b5ca9
...
@@ -60,6 +60,18 @@ const translation = {
...
@@ -60,6 +60,18 @@ const translation = {
statusCode
:
'响应状态码'
,
statusCode
:
'响应状态码'
,
headers
:
'响应头列表 JSON'
,
headers
:
'响应头列表 JSON'
,
},
},
authorization
:
{
'authorization'
:
'鉴权'
,
'authorizationType'
:
'鉴权类型'
,
'no-auth'
:
'无'
,
'api-key'
:
'API-Key'
,
'auth-type'
:
'API 鉴权类型'
,
'basic'
:
'基础'
,
'bearer'
:
'Bearer'
,
'custom'
:
'自定义'
,
'api-key-title'
:
'API Key'
,
'header'
:
'Header'
,
},
},
},
code
:
{
code
:
{
inputVars
:
'输入变量'
,
inputVars
:
'输入变量'
,
...
...
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