From 6013d9042662b627db503c02a5bf87f44a63f7b9 Mon Sep 17 00:00:00 2001 From: NFish Date: Tue, 1 Jul 2025 10:42:11 +0800 Subject: [PATCH] Fix/ serveral bugs fixed in enterprise (#21729) --- web/app/(commonLayout)/apps/AppCard.tsx | 14 ++++++++++---- web/app/components/base/popover/index.tsx | 4 +++- .../block-selector/market-place-plugin/list.tsx | 6 +++--- .../_base/components/switch-plugin-version.tsx | 4 ++-- web/hooks/use-tab-searchparams.ts | 5 +++-- web/i18n/en-US/app.ts | 8 ++++---- web/service/access-control.ts | 3 +++ 7 files changed, 28 insertions(+), 16 deletions(-) diff --git a/web/app/(commonLayout)/apps/AppCard.tsx b/web/app/(commonLayout)/apps/AppCard.tsx index 31b9ed87c2..b7c9a2eee4 100644 --- a/web/app/(commonLayout)/apps/AppCard.tsx +++ b/web/app/(commonLayout)/apps/AppCard.tsx @@ -36,6 +36,7 @@ import AccessControl from '@/app/components/app/app-access-control' import { AccessMode } from '@/models/access-control' import { useGlobalPublicStore } from '@/context/global-public-context' import { formatTime } from '@/utils/time' +import { useGetUserCanAccessApp } from '@/service/access-control' export type AppCardProps = { app: App @@ -190,6 +191,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => { }, [onRefresh, mutateApps, setShowAccessControl]) const Operations = (props: HtmlContentProps) => { + const { data: userCanAccessApp, isLoading: isGettingUserCanAccessApp } = useGetUserCanAccessApp({ appId: app?.id, enabled: (!!props?.open && systemFeatures.webapp_auth.enabled) }) const onMouseLeave = async () => { props.onClose?.() } @@ -267,10 +269,14 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => { )} - - + { + (isGettingUserCanAccessApp || !userCanAccessApp?.result) ? null : <> + + + + } { systemFeatures.webapp_auth.enabled && isCurrentWorkspaceEditor && <> diff --git a/web/app/components/base/popover/index.tsx b/web/app/components/base/popover/index.tsx index 2a831e0c24..0e7c384564 100644 --- a/web/app/components/base/popover/index.tsx +++ b/web/app/components/base/popover/index.tsx @@ -3,6 +3,7 @@ import { Fragment, cloneElement, useRef } from 'react' import cn from '@/utils/classnames' export type HtmlContentProps = { + open?: boolean onClose?: () => void onClick?: () => void } @@ -100,7 +101,8 @@ export default function CustomPopover({ } > {cloneElement(htmlContent as React.ReactElement, { - onClose: () => onMouseLeave(open), + open, + onClose: close, ...(manualClose ? { onClick: close, diff --git a/web/app/components/workflow/block-selector/market-place-plugin/list.tsx b/web/app/components/workflow/block-selector/market-place-plugin/list.tsx index 019b32ae25..e2b4a7acc6 100644 --- a/web/app/components/workflow/block-selector/market-place-plugin/list.tsx +++ b/web/app/components/workflow/block-selector/market-place-plugin/list.tsx @@ -6,9 +6,9 @@ import Item from './item' import type { Plugin } from '@/app/components/plugins/types.ts' import cn from '@/utils/classnames' import Link from 'next/link' -import { MARKETPLACE_URL_PREFIX } from '@/config' import { RiArrowRightUpLine, RiSearchLine } from '@remixicon/react' import { noop } from 'lodash-es' +import { getMarketplaceUrl } from '@/utils/var' export type ListProps = { wrapElemRef: React.RefObject @@ -32,7 +32,7 @@ const List = forwardRef(({ const { t } = useTranslation() const hasFilter = !searchText const hasRes = list.length > 0 - const urlWithSearchText = `${MARKETPLACE_URL_PREFIX}/?q=${searchText}&tags=${tags.join(',')}` + const urlWithSearchText = getMarketplaceUrl('', { q: searchText, tags: tags.join(',') }) const nextToStickyELemRef = useRef(null) const { handleScroll, scrollPosition } = useStickyScroll({ @@ -71,7 +71,7 @@ const List = forwardRef(({ return ( {t('plugin.findMoreInMarketplace')} diff --git a/web/app/components/workflow/nodes/_base/components/switch-plugin-version.tsx b/web/app/components/workflow/nodes/_base/components/switch-plugin-version.tsx index cddd529aea..94b3ce7bfc 100644 --- a/web/app/components/workflow/nodes/_base/components/switch-plugin-version.tsx +++ b/web/app/components/workflow/nodes/_base/components/switch-plugin-version.tsx @@ -15,7 +15,7 @@ import { pluginManifestToCardPluginProps } from '@/app/components/plugins/instal import { Badge as Badge2, BadgeState } from '@/app/components/base/badge/index' import Link from 'next/link' import { useTranslation } from 'react-i18next' -import { MARKETPLACE_URL_PREFIX } from '@/config' +import { getMarketplaceUrl } from '@/utils/var' export type SwitchPluginVersionProps = { uniqueIdentifier: string @@ -82,7 +82,7 @@ export const SwitchPluginVersion: FC = (props) => { modalBottomLeft={ diff --git a/web/hooks/use-tab-searchparams.ts b/web/hooks/use-tab-searchparams.ts index 0c0e3b7773..444944f812 100644 --- a/web/hooks/use-tab-searchparams.ts +++ b/web/hooks/use-tab-searchparams.ts @@ -29,9 +29,10 @@ export const useTabSearchParams = ({ const router = useRouter() const pathName = pathnameFromHook || window?.location?.pathname const searchParams = useSearchParams() + const searchParamValue = searchParams.has(searchParamName) ? decodeURIComponent(searchParams.get(searchParamName)!) : defaultTab const [activeTab, setTab] = useState( !disableSearchParams - ? (searchParams.get(searchParamName) || defaultTab) + ? searchParamValue : defaultTab, ) @@ -39,7 +40,7 @@ export const useTabSearchParams = ({ setTab(newActiveTab) if (disableSearchParams) return - router[`${routingBehavior}`](`${pathName}?${searchParamName}=${newActiveTab}`) + router[`${routingBehavior}`](`${pathName}?${searchParamName}=${encodeURIComponent(newActiveTab)}`) } return [activeTab, setActiveTab] as const diff --git a/web/i18n/en-US/app.ts b/web/i18n/en-US/app.ts index e75a9d5358..1162a3d0aa 100644 --- a/web/i18n/en-US/app.ts +++ b/web/i18n/en-US/app.ts @@ -199,9 +199,9 @@ const translation = { accessControl: 'Web App Access Control', accessItemsDescription: { anyone: 'Anyone can access the web app (no login required)', - specific: 'Only specific members within the platform can access the Web application', - organization: 'All members within the platform can access the Web application', - external: 'Only authenticated external users can access the Web application', + specific: 'Only specific members within the platform can access the web app', + organization: 'All members within the platform can access the web app', + external: 'Only authenticated external users can access the web app', }, accessControlDialog: { title: 'Web App Access Control', @@ -218,7 +218,7 @@ const translation = { members_one: '{{count}} MEMBER', members_other: '{{count}} MEMBERS', noGroupsOrMembers: 'No groups or members selected', - webAppSSONotEnabledTip: 'Please contact your organization administrator to configure external authentication for the Web application.', + webAppSSONotEnabledTip: 'Please contact your organization administrator to configure external authentication for the web app.', operateGroupAndMember: { searchPlaceholder: 'Search groups and members', allMembers: 'All members', diff --git a/web/service/access-control.ts b/web/service/access-control.ts index 865909d2f9..36999bf8f3 100644 --- a/web/service/access-control.ts +++ b/web/service/access-control.ts @@ -86,5 +86,8 @@ export const useGetUserCanAccessApp = ({ appId, isInstalledApp = true, enabled } enabled: !!appId && enabled, staleTime: 0, gcTime: 0, + initialData: { + result: !enabled, + }, }) }