Plugin-based datasource credentials (Notion, Jina, Firecrawl, etc.) were implicitly shared with every workspace member. PR #35468 added the visibility column, creator tracking and read-side filtering for datasource providers, but left no way to actually set or change a credential's scope, so every datasource credential stayed effectively all_team_members. This completes the datasource side: Backend: - add_datasource_api_key_provider / add_datasource_oauth_provider accept user_id and visibility; API keys default to all_team_members, OAuth defaults to only_me (matching the plugin-credential philosophy) - new update_datasource_credential_visibility (+ console endpoint) so the creator can switch between only_me / all_team_members / partial_members; only the creator (or legacy NULL-owner rows) may change the scope - replace_partial_member_list / clear_partial_member_list helpers on CredentialPermissionService (caller owns the transaction) - list_datasource_credentials returns visibility, user_id, is_editable and partial_member_list Frontend: - VisibilityModal reusing PermissionSelector, with an empty-partial-members guard (the backend rejects an empty list) - "Who can use" action in the credential operator, gated on is_editable - scope badges (only me / partial team members) on the credential item Existing credentials keep working: the visibility column defaults to all_team_members and legacy rows with a NULL owner are always visible. |
||
|---|---|---|
| .. | ||
| __mocks__ | ||
| __tests__ | ||
| .storybook | ||
| .vscode | ||
| app | ||
| assets | ||
| bin | ||
| config | ||
| constants | ||
| context | ||
| contract | ||
| docker | ||
| docs | ||
| features | ||
| hooks | ||
| i18n | ||
| i18n-config | ||
| models | ||
| next | ||
| plugins | ||
| public | ||
| scripts | ||
| service | ||
| test | ||
| themes | ||
| types | ||
| utils | ||
| .env.example | ||
| .gitignore | ||
| AGENTS.md | ||
| CLAUDE.md | ||
| dev-proxy.config.ts | ||
| Dockerfile | ||
| Dockerfile.dockerignore | ||
| env.ts | ||
| eslint.config.mjs | ||
| eslint.constants.mjs | ||
| global.d.ts | ||
| instrumentation-client.ts | ||
| knip.config.ts | ||
| next.config.ts | ||
| package.json | ||
| postcss.config.js | ||
| proxy.ts | ||
| README.md | ||
| tsconfig.json | ||
| tsslint.config.ts | ||
| vite.config.ts | ||
| vitest.setup.ts | ||
Dify Frontend
This is a Next.js project, but you can dev with vinext.
Getting Started
Run by source code
Before starting the web frontend service, please make sure the following environment is ready.
You can also use Vite+ with the corresponding vp commands.
For example, use vp install instead of pnpm install and vp test instead of pnpm run test.
Tip
It is recommended to install and enable Corepack to manage package manager versions automatically:
npm install -g corepack corepack enableLearn more: Corepack
Run the following commands from the repository root.
First, install the dependencies:
pnpm install
Note
JavaScript dependencies are managed by the workspace files at the repository root:
package.json,pnpm-lock.yaml,pnpm-workspace.yaml, and.nvmrc. Install dependencies from the repository root, then run frontend scripts fromweb/.
Then, configure the environment variables.
Create web/.env.local and copy the contents from web/.env.example.
Modify the values of these environment variables according to your requirements:
cp web/.env.example web/.env.local
Important
- When the frontend and backend run on different subdomains, set NEXT_PUBLIC_COOKIE_DOMAIN=1. The frontend and backend must be under the same top-level domain in order to share authentication cookies.
- It's necessary to set NEXT_PUBLIC_API_PREFIX and NEXT_PUBLIC_PUBLIC_API_PREFIX to the correct backend API URL.
Finally, run the development server:
pnpm -C web run dev
# or if you are using vinext which provides a better development experience
pnpm -C web run dev:vinext
# (optional) start the dev proxy server so that you can use online API in development
# edit web/dev-proxy.config.ts to choose proxy paths
# edit web/.env.local to override DEV_PROXY_TARGET, DEV_PROXY_ENTERPRISE_TARGET, DEV_PROXY_HOST, or DEV_PROXY_PORT
pnpm -C web run dev:proxy
Open http://localhost:3000 with your browser to see the result.
You can start editing the files under web/app.
The page auto-updates as you edit the file.
Deploy
Deploy on server
First, build the app for production:
pnpm -C web run build
Then, start the server:
pnpm -C web run start
If you build the Docker image manually, use the repository root as the build context:
docker build -f web/Dockerfile -t dify-web .
If you want to customize the host and port:
pnpm -C web run start --port=3001 --host=0.0.0.0
Storybook
This project uses Storybook for UI component development.
To start the storybook server, run:
pnpm -C web storybook
Open http://localhost:6006 with your browser to see the result.
Lint Code
If your IDE is VSCode, rename .vscode/settings.example.json to .vscode/settings.json for lint code setting.
Then follow the Lint Documentation to lint the code.
Test
We use Vitest and React Testing Library for Unit Testing.
📖 Complete Testing Guide: See web/docs/test.md for detailed testing specifications, best practices, and examples.
Important
As we are using Vite+, the
vitestcommand is not available. Please make sure to run tests withvpcommands. For example, usenpx vp testinstead ofnpx vitest.
Run test:
pnpm -C web test
Note
Our test is not fully stable yet, and we are actively working on improving it. If you encounter test failures only in CI but not locally, please feel free to ignore them and report the issue to us. You can try to re-run the test in CI, and it may pass successfully.
Example Code
If you are not familiar with writing tests, refer to:
- index.spec.tsx - Component test example
Analyze Component Complexity
Before writing tests, use the script to analyze component complexity:
pnpm analyze-component app/components/your-component/index.tsx
This will help you determine the testing strategy. See [web/testing/testing.md] for details.
Documentation
Visit https://docs.dify.ai to view the full documentation.
Community
The Dify community can be found on Discord community, where you can ask questions, voice ideas, and share your projects.