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.

fix(web): open publisher navigation links in new tabs (#44808)

yyhc28e136be098
diff --git a/web/app/components/app/app-publisher/__tests__/environment-deployment-flow.spec.tsx b/web/app/components/app/app-publisher/__tests__/environment-deployment-flow.spec.tsx
index 1ffd1fb562d..ef05f49d763 100644
--- a/web/app/components/app/app-publisher/__tests__/environment-deployment-flow.spec.tsx
+++ b/web/app/components/app/app-publisher/__tests__/environment-deployment-flow.spec.tsx
@@ -610,6 +610,8 @@ describe('PublisherEnvironmentFlow', () => {
'href',
'/app/app-1/deploy?environment=staging',
)
+ expect(screen.getByRole('link', { name: 'Access Point' })).toHaveAttribute('target', '_blank')
+ expect(screen.getByRole('link', { name: 'Deploy' })).toHaveAttribute('target', '_blank')
},
)
diff --git a/web/app/components/app/app-publisher/__tests__/sections.spec.tsx b/web/app/components/app/app-publisher/__tests__/sections.spec.tsx
index a8170acb48d..4fd2094462e 100644
--- a/web/app/components/app/app-publisher/__tests__/sections.spec.tsx
+++ b/web/app/components/app/app-publisher/__tests__/sections.spec.tsx
@@ -554,6 +554,9 @@ describe('app-publisher sections', () => {
'href',
'/app/workflow-app/deploy',
)
+ for (const name of [/common\.openWebApp\b/, /appMenus\.accessPoint\b/, /appMenus\.deploy\b/]) {
+ expect(screen.getByRole('link', { name })).toHaveAttribute('target', '_blank')
+ }
const marketplaceAction = screen.getByRole('button', {
name: /common\.publishToMarketplace\b/,
diff --git a/web/app/components/app/app-publisher/__tests__/suggested-action.spec.tsx b/web/app/components/app/app-publisher/__tests__/suggested-action.spec.tsx
index 0bd1149fac1..4d92433dd84 100644
--- a/web/app/components/app/app-publisher/__tests__/suggested-action.spec.tsx
+++ b/web/app/components/app/app-publisher/__tests__/suggested-action.spec.tsx
@@ -3,13 +3,9 @@ import userEvent from '@testing-library/user-event'
import SuggestedAction from '../suggested-action'
describe('SuggestedAction', () => {
- it('should render an enabled external link with supporting copy', () => {
+ it('should open absolute destinations in a new tab with supporting copy', () => {
render(
- <SuggestedAction
- link="https://example.com/docs"
- external
- description="Read the documentation"
- >
+ <SuggestedAction link="https://example.com/docs" description="Read the documentation">
Open docs
</SuggestedAction>,
)
@@ -17,11 +13,12 @@ describe('SuggestedAction', () => {
const link = screen.getByRole('link', { name: 'Open docs' })
expect(link).toHaveAttribute('href', 'https://example.com/docs')
expect(link).toHaveAttribute('target', '_blank')
+ expect(link).toHaveAttribute('rel', 'noreferrer')
expect(link).toHaveAccessibleDescription('Read the documentation')
expect(screen.getByText('Read the documentation')).toBeInTheDocument()
})
- it('should render internal destinations without opening a new tab', () => {
+ it('should open internal destinations in a new tab', () => {
render(
<SuggestedAction link="/app/app-1/deploy" description="Push versions to environments">
Deploy
@@ -30,7 +27,7 @@ describe('SuggestedAction', () => {
const link = screen.getByRole('link', { name: 'Deploy' })
expect(link).toHaveAttribute('href', '/app/app-1/deploy')
- expect(link).not.toHaveAttribute('target')
+ expect(link).toHaveAttribute('target', '_blank')
expect(link).toHaveAccessibleDescription('Push versions to environments')
})
@@ -99,7 +96,6 @@ describe('SuggestedAction', () => {
render(
<SuggestedAction
link="https://example.com/app"
- external
actionButton={{
ariaLabel: 'Configure action',
icon: <span>config</span>,
@@ -126,7 +122,6 @@ describe('SuggestedAction', () => {
render(
<SuggestedAction
link="https://example.com/app"
- external
disabled
actionButton={{
ariaLabel: 'Configure action',
diff --git a/web/app/components/app/app-publisher/built-in-publisher/actions-section.tsx b/web/app/components/app/app-publisher/built-in-publisher/actions-section.tsx
index 3afed918550..19acf88e768 100644
--- a/web/app/components/app/app-publisher/built-in-publisher/actions-section.tsx
+++ b/web/app/components/app/app-publisher/built-in-publisher/actions-section.tsx
@@ -81,7 +81,6 @@ export function PublisherActionsSection({
? disabledFunctionTooltip
: t(($) => $['common.openWebAppDescription'], { ns: 'workflow' })
}
- external
focusableWhenDisabled={Boolean(disabledFunctionTooltip)}
link={appURL}
icon={<span className="i-ri-planet-line size-4" />}
diff --git a/web/app/components/app/app-publisher/suggested-action.tsx b/web/app/components/app/app-publisher/suggested-action.tsx
index d9444ff3168..218c2fefbb4 100644
--- a/web/app/components/app/app-publisher/suggested-action.tsx
+++ b/web/app/components/app/app-publisher/suggested-action.tsx
@@ -12,7 +12,6 @@ type SuggestedActionButton = {
type SuggestedActionProps = PropsWithChildren<{
icon?: ReactNode
link?: string
- external?: boolean
disabled?: boolean
focusableWhenDisabled?: boolean
description?: ReactNode
@@ -25,7 +24,6 @@ type SuggestedActionProps = PropsWithChildren<{
const SuggestedAction = ({
icon,
link,
- external = false,
disabled = false,
focusableWhenDisabled = false,
description,
@@ -138,9 +136,9 @@ const SuggestedAction = ({
{content}
</button>
)
- } else if (external) {
+ } else {
mainAction = (
- <a
+ <Link
href={link}
target="_blank"
rel="noreferrer"
@@ -149,12 +147,6 @@ const SuggestedAction = ({
{...accessibilityProps}
>
{content}
- </a>
- )
- } else {
- mainAction = (
- <Link href={link} className={interactiveClassName} onClick={onClick} {...accessibilityProps}>
- {content}
</Link>
)
}