From fb10f50ed989ec7df9eb88607582126b76dfe02f Mon Sep 17 00:00:00 2001 From: NFish Date: Fri, 9 May 2025 14:26:14 +0800 Subject: [PATCH 1/2] fix: hide access control in publish panel --- web/app/components/app/app-publisher/index.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/web/app/components/app/app-publisher/index.tsx b/web/app/components/app/app-publisher/index.tsx index b24c865c42..8d0028c7d7 100644 --- a/web/app/components/app/app-publisher/index.tsx +++ b/web/app/components/app/app-publisher/index.tsx @@ -263,11 +263,11 @@ const AppPublisher = ({ ) } - {(isGettingUserCanAccessApp || isGettingAppWhiteListSubjects) + {(systemFeatures.webapp_auth.enabled && (isGettingUserCanAccessApp || isGettingAppWhiteListSubjects)) ?
: <> -
+ {systemFeatures.webapp_auth.enabled &&

{t('app.publishApp.title')}

@@ -287,12 +287,12 @@ const AppPublisher = ({
{!isAppAccessSet &&

{t('app.publishApp.notSetDesc')}

} - + }
- + } > @@ -301,10 +301,10 @@ const AppPublisher = ({ {appDetail?.mode === 'workflow' || appDetail?.mode === 'completion' ? ( - + } > @@ -324,13 +324,13 @@ const AppPublisher = ({ {t('workflow.common.embedIntoSite')} )} - + { publishedAt && handleOpenInExplore() }} - disabled={!publishedAt || !userCanAccessApp?.result} + disabled={!publishedAt || (systemFeatures.webapp_auth.enabled && !userCanAccessApp?.result)} icon={} > {t('workflow.common.openInExplore')} From db92ba92b87752156da3db7b56883d52ac1437a4 Mon Sep 17 00:00:00 2001 From: NFish Date: Fri, 9 May 2025 14:55:26 +0800 Subject: [PATCH 2/2] fix: add missed systemFeatures in webapp pages --- web/app/components/base/chat/chat-with-history/hooks.tsx | 7 ++++--- web/app/components/base/chat/embedded-chatbot/hooks.tsx | 7 ++++--- web/app/components/share/text-generation/index.tsx | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/web/app/components/base/chat/chat-with-history/hooks.tsx b/web/app/components/base/chat/chat-with-history/hooks.tsx index 5ed72650be..d03a28ae57 100644 --- a/web/app/components/base/chat/chat-with-history/hooks.tsx +++ b/web/app/components/base/chat/chat-with-history/hooks.tsx @@ -45,6 +45,7 @@ import { TransferMethod } from '@/types/app' import { noop } from 'lodash-es' import { useGetAppAccessMode, useGetUserCanAccessApp } from '@/service/access-control' import { useGlobalPublicStore } from '@/context/global-public-context' +import { AccessMode } from '@/models/access-control' function getFormattedChatList(messages: any[]) { const newChatList: ChatItem[] = [] @@ -460,9 +461,9 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => { return { appInfoError, - appInfoLoading: appInfoLoading || isGettingAccessMode || isCheckingPermission, - accessMode: appAccessMode?.accessMode, - userCanAccess: userCanAccessResult?.result, + appInfoLoading: appInfoLoading || (systemFeatures.webapp_auth.enabled && (isGettingAccessMode || isCheckingPermission)), + accessMode: systemFeatures.webapp_auth.enabled ? appAccessMode?.accessMode : AccessMode.PUBLIC, + userCanAccess: systemFeatures.webapp_auth.enabled ? userCanAccessResult?.result : true, isInstalledApp, appId, currentConversationId, diff --git a/web/app/components/base/chat/embedded-chatbot/hooks.tsx b/web/app/components/base/chat/embedded-chatbot/hooks.tsx index e00c40e771..ce42575bc9 100644 --- a/web/app/components/base/chat/embedded-chatbot/hooks.tsx +++ b/web/app/components/base/chat/embedded-chatbot/hooks.tsx @@ -38,6 +38,7 @@ import { addFileInfos, sortAgentSorts } from '@/app/components/tools/utils' import { noop } from 'lodash-es' import { useGetAppAccessMode, useGetUserCanAccessApp } from '@/service/access-control' import { useGlobalPublicStore } from '@/context/global-public-context' +import { AccessMode } from '@/models/access-control' function getFormattedChatList(messages: any[]) { const newChatList: ChatItem[] = [] @@ -377,9 +378,9 @@ export const useEmbeddedChatbot = () => { return { appInfoError, - appInfoLoading: appInfoLoading || isGettingAccessMode || isCheckingPermission, - accessMode: appAccessMode?.accessMode, - userCanAccess: userCanAccessResult?.result, + appInfoLoading: appInfoLoading || (systemFeatures.webapp_auth.enabled && (isGettingAccessMode || isCheckingPermission)), + accessMode: systemFeatures.webapp_auth.enabled ? appAccessMode?.accessMode : AccessMode.PUBLIC, + userCanAccess: systemFeatures.webapp_auth.enabled ? userCanAccessResult?.result : true, isInstalledApp, allowResetChat, appId, diff --git a/web/app/components/share/text-generation/index.tsx b/web/app/components/share/text-generation/index.tsx index 2de5863859..368a03f113 100644 --- a/web/app/components/share/text-generation/index.tsx +++ b/web/app/components/share/text-generation/index.tsx @@ -434,7 +434,7 @@ const TextGeneration: FC = ({ setMoreLikeThisConfig(more_like_this) setTextToSpeechConfig(text_to_speech) })() - }, [fetchInitData]) + }, []) // Can Use metadata(https://beta.nextjs.org/docs/api-reference/metadata) to set title. But it only works in server side client. useDocumentTitle(siteInfo?.title || t('share.generation.title')) @@ -536,13 +536,13 @@ const TextGeneration: FC = ({
) - if (!appId || !siteInfo || !promptConfig || isGettingAccessMode || isCheckingPermission) { + if (!appId || !siteInfo || !promptConfig || (systemFeatures.webapp_auth.enabled && (isGettingAccessMode || isCheckingPermission))) { return (
) } - if (!userCanAccessResult?.result) + if (systemFeatures.webapp_auth.enabled && !userCanAccessResult?.result) return return (