Commit 1cb67b38 by Ryo Committed by GitHub

fix: home chat file uploads (#6838)

* chore: update actions workflow yamls

* chore: update turbo.json

* fix: split admin preview image workflows

* fix: allow home chat file uploads
parent a08edc42
...@@ -2,22 +2,22 @@ name: Preview Admin Image - Build ...@@ -2,22 +2,22 @@ name: Preview Admin Image - Build
on: on:
pull_request_target: pull_request_target:
types: [opened, synchronize, reopened] types: [ opened, synchronize, reopened ]
paths: paths:
- 'pro' - "pro"
- 'pro/**' - "pro/**"
- 'packages/**' - "packages/**"
- 'sdk/**' - "sdk/**"
- 'pnpm-lock.yaml' - "pnpm-lock.yaml"
- 'pnpm-workspace.yaml' - "pnpm-workspace.yaml"
- 'turbo.json' - "turbo.json"
- '.gitmodules' - ".gitmodules"
- '.github/workflows/preview-admin-build.yml' - ".github/workflows/preview-admin-build.yml"
- '.github/workflows/preview-admin-push.yml' - ".github/workflows/preview-admin-push.yml"
workflow_dispatch: workflow_dispatch:
concurrency: concurrency:
group: 'preview-admin-build-${{ github.event.pull_request.number || github.ref }}' group: "preview-admin-build-${{ github.event.pull_request.number || github.ref }}"
cancel-in-progress: true cancel-in-progress: true
permissions: permissions:
...@@ -31,8 +31,11 @@ jobs: ...@@ -31,8 +31,11 @@ jobs:
- name: Checkout PR code - name: Checkout PR code
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }} ref: ${{ github.event_name == 'pull_request_target' &&
repository: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name || github.repository }} github.event.pull_request.head.sha || github.ref }}
repository: ${{ github.event_name == 'pull_request_target' &&
github.event.pull_request.head.repo.full_name || github.repository
}}
fetch-depth: 1 fetch-depth: 1
- name: Update submodules - name: Update submodules
...@@ -60,7 +63,8 @@ jobs: ...@@ -60,7 +63,8 @@ jobs:
file: pro/admin/Dockerfile file: pro/admin/Dockerfile
platforms: linux/amd64 platforms: linux/amd64
push: false push: false
tags: fastgpt-pro-pr:${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }} tags: fastgpt-pro-pr:${{ github.event_name == 'pull_request_target' &&
github.event.pull_request.head.sha || github.sha }}
labels: | labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository_owner }}/FastGPT org.opencontainers.image.source=https://github.com/${{ github.repository_owner }}/FastGPT
org.opencontainers.image.description=fastgpt-pro admin image org.opencontainers.image.description=fastgpt-pro admin image
......
...@@ -254,13 +254,22 @@ const Provider = ({ ...@@ -254,13 +254,22 @@ const Provider = ({
getHistoryResponseData, getHistoryResponseData,
chatType chatType
}; };
const runtimeFileSelectConfig = useMemo(() => {
if (chatType === ChatTypeEnumValue.test) {
return fileSelectConfig;
}
if (chatType === ChatTypeEnumValue.home && !props.currentQuickAppId) {
return fileSelectConfig;
}
return undefined;
}, [chatType, fileSelectConfig, props.currentQuickAppId]);
return ( return (
<WorkflowRuntimeContextProvider <WorkflowRuntimeContextProvider
appId={appId} appId={appId}
chatId={chatId} chatId={chatId}
outLinkAuthData={formatOutLinkAuth} outLinkAuthData={formatOutLinkAuth}
runtimeFileSelectConfig={chatType === ChatTypeEnumValue.test ? fileSelectConfig : undefined} runtimeFileSelectConfig={runtimeFileSelectConfig}
> >
<ChatBoxContext.Provider value={value}>{children}</ChatBoxContext.Provider> <ChatBoxContext.Provider value={value}>{children}</ChatBoxContext.Provider>
</WorkflowRuntimeContextProvider> </WorkflowRuntimeContextProvider>
......
...@@ -12,6 +12,7 @@ import { getTeamPlanStatus } from '@fastgpt/service/support/wallet/sub/utils'; ...@@ -12,6 +12,7 @@ import { getTeamPlanStatus } from '@fastgpt/service/support/wallet/sub/utils';
import { authApp } from '@fastgpt/service/support/permission/app/auth'; import { authApp } from '@fastgpt/service/support/permission/app/auth';
import { WritePermissionVal } from '@fastgpt/global/support/permission/constant'; import { WritePermissionVal } from '@fastgpt/global/support/permission/constant';
import { S3ErrEnum } from '@fastgpt/global/common/error/code/s3'; import { S3ErrEnum } from '@fastgpt/global/common/error/code/s3';
import { MongoChatSetting } from '@fastgpt/service/core/chat/setting/schema';
async function handler(req: ApiRequestProps): Promise<CreatePostPresignedUrlResponseType> { async function handler(req: ApiRequestProps): Promise<CreatePostPresignedUrlResponseType> {
const { filename, appId, chatId, outLinkAuthData, fileSelectConfig } = const { filename, appId, chatId, outLinkAuthData, fileSelectConfig } =
...@@ -31,12 +32,16 @@ async function handler(req: ApiRequestProps): Promise<CreatePostPresignedUrlResp ...@@ -31,12 +32,16 @@ async function handler(req: ApiRequestProps): Promise<CreatePostPresignedUrlResp
]); ]);
const effectiveFileSelectConfig = fileSelectConfig const effectiveFileSelectConfig = fileSelectConfig
? await (async () => { ? await (async () => {
const isHomeApp = await MongoChatSetting.exists({ teamId, appId });
if (!isHomeApp) {
await authApp({ await authApp({
req, req,
authToken: true, authToken: true,
appId, appId,
per: WritePermissionVal per: WritePermissionVal
}); });
}
return fileSelectConfig; return fileSelectConfig;
})() })()
: app?.chatConfig?.fileSelectConfig; : app?.chatConfig?.fileSelectConfig;
......
...@@ -11,6 +11,11 @@ ...@@ -11,6 +11,11 @@
"cache": false, "cache": false,
"persistent": true "persistent": true
}, },
"dev:pro": {
"with": ["@fastgpt/admin#dev"],
"cache": false,
"persistent": true
},
"build": { "build": {
"dependsOn": ["^build"], "dependsOn": ["^build"],
"outputs": [".next/**", "dist/**", "worker/**"] "outputs": [".next/**", "dist/**", "worker/**"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment