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: keep home intro without banner (#41155)

yyh3de20e0ba85f
diff --git a/web/features/home/banner/__tests__/banner.spec.tsx b/web/features/home/banner/__tests__/banner.spec.tsx
index 777cb232cc3..243f8ecb6d4 100644
--- a/web/features/home/banner/__tests__/banner.spec.tsx
+++ b/web/features/home/banner/__tests__/banner.spec.tsx
@@ -73,9 +73,7 @@ vi.mock('react-i18next', async () => {
return {
useTranslation: () => ({
i18n: { language: 'en-US' },
- t: withSelectorKey((key: string, opts?: Record<string, unknown>) => {
- if (key === 'banner.greeting') return `Welcome back, ${opts?.name}👋`
- if (key === 'banner.tagline') return 'What if… this is where your next idea begins.'
+ t: withSelectorKey((key: string) => {
return key
}),
}),
@@ -185,10 +183,6 @@ describe('Banner', () => {
it('renders nothing when there are no banners', () => {
render(<Banner banners={[]} />)
- expect(screen.queryByText('Welcome back, Evan👋')).not.toBeInTheDocument()
- expect(
- screen.queryByText('What if… this is where your next idea begins.'),
- ).not.toBeInTheDocument()
expect(screen.queryByRole('region')).not.toBeInTheDocument()
})
diff --git a/web/features/home/banner/banner.tsx b/web/features/home/banner/banner.tsx
index fc6f79eab59..ee6fa24d2c8 100644
--- a/web/features/home/banner/banner.tsx
+++ b/web/features/home/banner/banner.tsx
@@ -188,7 +188,6 @@ type BannerProps = {
}
export function Banner({ banners }: BannerProps) {
- const { t } = useTranslation()
const locale = useLocale()
const { data: userProfile } = useSuspenseQuery({
...userProfileQueryOptions(),
@@ -213,16 +212,7 @@ export function Banner({ banners }: BannerProps) {
const carouselLabel = firstBanner.content.category || firstBanner.content.title
return (
- <div className="relative flex w-full flex-col items-start gap-4 px-8 pt-6 pb-4">
- <div className="flex w-full flex-col gap-1">
- <p className="truncate title-3xl-semi-bold text-text-primary">
- {t(($) => $['banner.greeting'], { name: userProfile.name, ns: 'explore' })}
- </p>
- <p className="truncate body-sm-regular text-text-secondary">
- {t(($) => $['banner.tagline'], { ns: 'explore' })}
- </p>
- </div>
-
+ <div className="relative flex w-full flex-col items-start px-8 pb-4">
<Carousel
opts={CAROUSEL_OPTIONS}
plugins={carouselPlugins}
diff --git a/web/features/home/home-content/__tests__/home-content.spec.tsx b/web/features/home/home-content/__tests__/home-content.spec.tsx
index 26eabc00a3e..5c418b0d692 100644
--- a/web/features/home/home-content/__tests__/home-content.spec.tsx
+++ b/web/features/home/home-content/__tests__/home-content.spec.tsx
@@ -47,7 +47,7 @@ function StepByStepTourSessionFixture({
}
const mockConsoleState = vi.hoisted(() => ({
- userProfile: { id: 'user-1' },
+ userProfile: { id: 'user-1', name: 'Evan' },
currentWorkspace: { id: 'workspace-1' },
workspacePermissionKeys: [] as string[],
}))
@@ -634,6 +634,20 @@ describe('HomeContent', () => {
})
describe('Rendering', () => {
+ it('should always render the page intro as the only h1 when the banner is disabled', () => {
+ renderHomeContent()
+
+ expect(
+ screen.getByRole('heading', {
+ level: 1,
+ name: 'explore.banner.greeting:{"name":"Evan"}',
+ }),
+ ).toBeInTheDocument()
+ expect(screen.getByText('explore.banner.tagline')).toBeInTheDocument()
+ expect(screen.getAllByRole('heading', { level: 1 })).toHaveLength(1)
+ expect(screen.queryByTestId('explore-banner')).not.toBeInTheDocument()
+ })
+
it('should not render learn dify content while learn dify items are loading', () => {
mockExploreData = {
categories: ['Writing'],
@@ -1517,6 +1531,7 @@ describe('HomeContent', () => {
expect(screen.getByTestId('explore-banner')).toBeInTheDocument()
expect(screen.getByTestId('explore-banner')).toHaveAttribute('data-banner-count', '1')
+ expect(screen.getAllByRole('heading', { level: 1 })).toHaveLength(1)
})
})
})
diff --git a/web/features/home/home-content/home-content.tsx b/web/features/home/home-content/home-content.tsx
index e3e28e3ff47..239622e040d 100644
--- a/web/features/home/home-content/home-content.tsx
+++ b/web/features/home/home-content/home-content.tsx
@@ -36,6 +36,7 @@ import { consoleQuery } from '@/service/client'
import { trackCreateApp } from '@/utils/create-app-tracking'
import { hasPermission } from '@/utils/permission'
import { HomeBanner } from '../banner/home-banner'
+import { HomeIntro } from '../home-intro'
import { HomeShell } from '../home-shell'
import { TemplateCard } from '../template-card'
import { HomeRecommendations } from './recommendations'
@@ -410,6 +411,7 @@ export function HomeContent() {
return (
<HomeShell>
<div className="flex flex-1 flex-col overflow-y-auto">
+ <HomeIntro />
{systemFeatures.enable_explore_banner && <HomeBanner />}
<HomeRecommendations
canCreate={canCreateApp}
diff --git a/web/features/home/home-intro.tsx b/web/features/home/home-intro.tsx
new file mode 100644
index 00000000000..beb754f9945
--- /dev/null
+++ b/web/features/home/home-intro.tsx
@@ -0,0 +1,34 @@
+'use client'
+
+import { useSuspenseQuery } from '@tanstack/react-query'
+import { useTranslation } from 'react-i18next'
+import { SkeletonRectangle } from '@/app/components/base/skeleton'
+import { userProfileQueryOptions } from '@/features/account-profile/client'
+
+export function HomeIntroSkeleton() {
+ return (
+ <div className="flex w-full flex-col gap-1 px-8 pt-6 pb-4">
+ <SkeletonRectangle className="my-0 h-6 w-60 max-w-full animate-pulse" />
+ <SkeletonRectangle className="my-0 h-4 w-72 max-w-full animate-pulse" />
+ </div>
+ )
+}
+
+export function HomeIntro() {
+ const { t } = useTranslation()
+ const { data: userProfile } = useSuspenseQuery({
+ ...userProfileQueryOptions(),
+ select: (data) => data.profile,
+ })
+
+ return (
+ <header className="flex w-full flex-col gap-1 px-8 pt-6 pb-4">
+ <h1 className="truncate title-3xl-semi-bold text-text-primary">
+ {t(($) => $['banner.greeting'], { name: userProfile.name, ns: 'explore' })}
+ </h1>
+ <p className="truncate body-sm-regular text-text-secondary">
+ {t(($) => $['banner.tagline'], { ns: 'explore' })}
+ </p>
+ </header>
+ )
+}
diff --git a/web/features/home/home-skeleton.tsx b/web/features/home/home-skeleton.tsx
index db9441fc51f..271d3bb5759 100644
--- a/web/features/home/home-skeleton.tsx
+++ b/web/features/home/home-skeleton.tsx
@@ -2,13 +2,14 @@
import { useTranslation } from 'react-i18next'
import { SkeletonContainer, SkeletonRectangle, SkeletonRow } from '@/app/components/base/skeleton'
+import { HomeIntroSkeleton } from './home-intro'
function HomeTemplateCardSkeleton() {
return (
<div className="col-span-1 flex h-35.5 flex-col overflow-hidden rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-on-panel-item-bg pb-3 shadow-xs shadow-shadow-shadow-3">
<div className="flex shrink-0 items-center gap-3 px-4 pt-4 pb-2">
<div className="relative shrink-0">
- <SkeletonRectangle className="size-10 shrink-0 animate-pulse rounded-lg" />
+ <SkeletonRectangle className="my-0 size-10 shrink-0 animate-pulse rounded-lg" />
</div>
<div className="flex w-0 grow flex-col gap-1 py-px">
<SkeletonRectangle className="my-0 h-4 w-3/5 animate-pulse" />
@@ -32,23 +33,23 @@ function HomeTemplateCardSkeleton() {
function HomeRecommendationsSkeleton() {
return (
- <SkeletonContainer>
- <div className="flex min-h-12 items-end justify-between gap-4 pb-2">
+ <SkeletonContainer className="gap-0">
+ <div className="flex items-center justify-between pt-2">
<div className="min-w-0 flex-1">
- <SkeletonRectangle className="h-5 w-48 animate-pulse" />
+ <SkeletonRectangle className="my-0 h-6 w-48 animate-pulse" />
</div>
</div>
- <div className="grid grid-cols-[repeat(auto-fill,minmax(296px,1fr))] gap-3">
+ <div className="grid grid-cols-[repeat(auto-fill,minmax(296px,1fr))] gap-2.5 pt-2">
{Array.from({ length: 4 }, (_, index) => (
<div
key={index}
- className="rounded-xl border-[0.5px] border-components-panel-border-subtle bg-components-panel-on-panel-item-bg px-4 py-3 shadow-md"
+ className="rounded-xl border-[0.5px] border-components-panel-border-subtle bg-components-panel-on-panel-item-bg px-4 py-4 shadow-md"
>
- <SkeletonRow>
- <SkeletonRectangle className="size-10 shrink-0 animate-pulse rounded-lg" />
+ <SkeletonRow className="gap-3">
+ <SkeletonRectangle className="my-0 size-10 shrink-0 animate-pulse rounded-lg" />
<div className="flex min-w-0 flex-1 flex-col gap-1">
- <SkeletonRectangle className="h-4 w-2/3 animate-pulse" />
- <SkeletonRectangle className="h-3 w-1/2 animate-pulse" />
+ <SkeletonRectangle className="my-0 h-4 w-2/3 animate-pulse" />
+ <SkeletonRectangle className="my-0 h-3 w-1/2 animate-pulse" />
</div>
</SkeletonRow>
</div>
@@ -63,17 +64,17 @@ function HomeTemplatesHeaderSkeletonBody() {
<div className="sticky top-0 z-10 bg-background-body">
<div className="flex items-center gap-2 px-8 pt-6">
<div className="min-w-0 flex-1">
- <SkeletonRectangle className="h-6 w-32 animate-pulse" />
+ <SkeletonRectangle className="my-0 h-6 w-32 animate-pulse" />
</div>
- <SkeletonRectangle className="h-4 w-20 shrink-0 animate-pulse" />
+ <SkeletonRectangle className="my-0 h-4 w-20 shrink-0 animate-pulse" />
</div>
<div className="flex items-start justify-between gap-2 px-8 pt-3 pb-3">
<div className="flex min-w-0 flex-1 gap-1">
{Array.from({ length: 4 }, (_, index) => (
- <SkeletonRectangle key={index} className="h-8 w-24 animate-pulse rounded-lg" />
+ <SkeletonRectangle key={index} className="my-0 h-8 w-24 animate-pulse rounded-lg" />
))}
</div>
- <SkeletonRectangle className="h-8 w-40 shrink-0 animate-pulse rounded-lg" />
+ <SkeletonRectangle className="my-0 h-8 w-40 shrink-0 animate-pulse rounded-lg" />
</div>
</div>
)
@@ -91,12 +92,10 @@ function HomeTemplatesSkeletonBody() {
function HomeBannerSkeleton() {
return (
- <div className="relative flex w-full flex-col items-start gap-4 px-8 pt-6 pb-4">
- <div className="flex w-full flex-col gap-1">
- <SkeletonRectangle className="my-0 h-6 w-60 max-w-full animate-pulse" />
- <SkeletonRectangle className="my-0 h-4 w-72 max-w-full animate-pulse" />
+ <div className="relative flex w-full flex-col items-start px-8 pb-4">
+ <div className="@container/banner w-full">
+ <SkeletonRectangle className="my-0 h-56 w-full animate-pulse rounded-2xl @min-[996px]/banner:h-46" />
</div>
- <SkeletonRectangle className="h-42 w-full animate-pulse rounded-2xl" />
</div>
)
}
@@ -106,6 +105,7 @@ export function HomeSkeleton({ showBanner }: { showBanner: boolean }) {
return (
<div role="status" aria-label={t(($) => $.loading, { ns: 'common' })} className="contents">
+ <HomeIntroSkeleton />
{showBanner && <HomeBannerSkeleton />}
<section className="px-8 pb-5">
<HomeRecommendationsSkeleton />