Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor(web): mark Props of tools/ components as read-only (#25219) (#37255)

Rohit Gahlawat50e23f40a449
diff --git a/web/app/components/tools/edit-custom-collection-modal/config-credentials.tsx b/web/app/components/tools/edit-custom-collection-modal/config-credentials.tsx
index dcbf834ede3..0c5c7620635 100644
--- a/web/app/components/tools/edit-custom-collection-modal/config-credentials.tsx
+++ b/web/app/components/tools/edit-custom-collection-modal/config-credentials.tsx
@@ -23,12 +23,12 @@ import { useTranslation } from 'react-i18next'
import { Infotip } from '@/app/components/base/infotip'
import { AuthHeaderPrefix, AuthType } from '@/app/components/tools/types'
-type Props = {
+type Props = Readonly<{
positionCenter?: boolean
credential: Credential
onChange: (credential: Credential) => void
onHide: () => void
-}
+}>
type ItemProps = {
text: string
diff --git a/web/app/components/tools/edit-custom-collection-modal/get-schema.tsx b/web/app/components/tools/edit-custom-collection-modal/get-schema.tsx
index b07d21ce146..a27b52e2a9c 100644
--- a/web/app/components/tools/edit-custom-collection-modal/get-schema.tsx
+++ b/web/app/components/tools/edit-custom-collection-modal/get-schema.tsx
@@ -15,9 +15,9 @@ import Input from '@/app/components/base/input'
import { importSchemaFromURL } from '@/service/tools'
import examples from './examples'
-type Props = {
+type Props = Readonly<{
onChange: (value: string) => void
-}
+}>
const GetSchema: FC<Props> = ({
onChange,
diff --git a/web/app/components/tools/edit-custom-collection-modal/index.tsx b/web/app/components/tools/edit-custom-collection-modal/index.tsx
index 6806a78adae..ef3218bb570 100644
--- a/web/app/components/tools/edit-custom-collection-modal/index.tsx
+++ b/web/app/components/tools/edit-custom-collection-modal/index.tsx
@@ -33,7 +33,7 @@ import ConfigCredentials from './config-credentials'
import GetSchema from './get-schema'
import TestApi from './test-api'
-type Props = {
+type Props = Readonly<{
positionLeft?: boolean
dialogClassName?: string
payload: any
@@ -41,7 +41,7 @@ type Props = {
onAdd?: (payload: CustomCollectionBackend) => void
onRemove?: () => void
onEdit?: (payload: CustomCollectionBackend) => void
-}
+}>
// Add and Edit
const EditCustomCollectionModal: FC<Props> = ({
positionLeft,
diff --git a/web/app/components/tools/edit-custom-collection-modal/test-api.tsx b/web/app/components/tools/edit-custom-collection-modal/test-api.tsx
index d53cab8c8ab..b438bf859e5 100644
--- a/web/app/components/tools/edit-custom-collection-modal/test-api.tsx
+++ b/web/app/components/tools/edit-custom-collection-modal/test-api.tsx
@@ -24,12 +24,12 @@ import { getLanguage } from '@/i18n-config/language'
import { testAPIAvailable } from '@/service/tools'
import ConfigCredentials from './config-credentials'
-type Props = {
+type Props = Readonly<{
positionCenter?: boolean
customCollection: CustomCollectionBackend
tool: CustomParamSchema
onHide: () => void
-}
+}>
const TestApi: FC<Props> = ({
positionCenter,
diff --git a/web/app/components/tools/provider/custom-create-card.tsx b/web/app/components/tools/provider/custom-create-card.tsx
index 90c597de15b..0879d2cd0df 100644
--- a/web/app/components/tools/provider/custom-create-card.tsx
+++ b/web/app/components/tools/provider/custom-create-card.tsx
@@ -10,9 +10,9 @@ import EditCustomToolModal from '@/app/components/tools/edit-custom-collection-m
import { useAppContext } from '@/context/app-context'
import { createCustomCollection } from '@/service/tools'
-type Props = {
+type Props = Readonly<{
onRefreshData: () => void
-}
+}>
const Contribute = ({ onRefreshData }: Props) => {
const { t } = useTranslation()
diff --git a/web/app/components/tools/provider/detail.tsx b/web/app/components/tools/provider/detail.tsx
index ff64e0044cb..597c7b10978 100644
--- a/web/app/components/tools/provider/detail.tsx
+++ b/web/app/components/tools/provider/detail.tsx
@@ -63,11 +63,11 @@ import { basePath } from '@/utils/var'
import { AuthHeaderPrefix, AuthType, CollectionType } from '../types'
import ToolItem from './tool-item'
-type Props = {
+type Props = Readonly<{
collection: Collection
onHide: () => void
onRefreshData: () => void
-}
+}>
const ProviderDetail = ({
collection,
diff --git a/web/app/components/tools/provider/empty.tsx b/web/app/components/tools/provider/empty.tsx
index 5d86708f572..5b98a2937ee 100644
--- a/web/app/components/tools/provider/empty.tsx
+++ b/web/app/components/tools/provider/empty.tsx
@@ -7,10 +7,10 @@ import Link from '@/next/link'
import { NoToolPlaceholder } from '../../base/icons/src/vender/other'
import { ToolTypeEnum } from '../../workflow/block-selector/types'
-type Props = {
+type Props = Readonly<{
type?: ToolTypeEnum
isAgent?: boolean
-}
+}>
const getLink = (type?: ToolTypeEnum) => {
switch (type) {
diff --git a/web/app/components/tools/provider/tool-item.tsx b/web/app/components/tools/provider/tool-item.tsx
index 83ffd465db1..09e52e34365 100644
--- a/web/app/components/tools/provider/tool-item.tsx
+++ b/web/app/components/tools/provider/tool-item.tsx
@@ -7,13 +7,13 @@ import SettingBuiltInTool from '@/app/components/app/configuration/config/agent/
import { useLocale } from '@/context/i18n'
import { getLanguage } from '@/i18n-config/language'
-type Props = {
+type Props = Readonly<{
disabled?: boolean
collection: Collection
tool: Tool
isBuiltIn: boolean
isModel: boolean
-}
+}>
const ToolItem = ({
disabled,
diff --git a/web/app/components/tools/setting/build-in/config-credentials.tsx b/web/app/components/tools/setting/build-in/config-credentials.tsx
index ed545720709..a7ef23657d9 100644
--- a/web/app/components/tools/setting/build-in/config-credentials.tsx
+++ b/web/app/components/tools/setting/build-in/config-credentials.tsx
@@ -26,14 +26,14 @@ import Form from '@/app/components/header/account-setting/model-provider-page/mo
import { fetchBuiltInToolCredential, fetchBuiltInToolCredentialSchema } from '@/service/tools'
import { addDefaultValue, toolCredentialToFormSchemas } from '../../utils/to-form-schema'
-type Props = {
+type Props = Readonly<{
collection: Collection
onCancel: () => void
onSaved: (value: Record<string, any>) => void
isHideRemoveBtn?: boolean
onRemove?: () => void
isSaving?: boolean
-}
+}>
const ConfigCredential: FC<Props> = ({
collection,
diff --git a/web/app/components/tools/workflow-tool/configure-button.tsx b/web/app/components/tools/workflow-tool/configure-button.tsx
index 0adc923e480..19dcf29dcf8 100644
--- a/web/app/components/tools/workflow-tool/configure-button.tsx
+++ b/web/app/components/tools/workflow-tool/configure-button.tsx
@@ -7,7 +7,7 @@ import Loading from '@/app/components/base/loading'
import { useRouter } from '@/next/navigation'
import Divider from '../../base/divider'
-type Props = {
+type Props = Readonly<{
disabled: boolean
published: boolean
isLoading: boolean
@@ -15,7 +15,7 @@ type Props = {
isCurrentWorkspaceManager: boolean
onConfigure: () => void
disabledReason?: string
-}
+}>
const WorkflowToolConfigureButton = ({
disabled,