mirror of
https://github.com/langgenius/dify.git
synced 2026-09-03 15:27:49 +08:00
fix(web): request templates banners on the templates page
This commit is contained in:
parent
24b977da27
commit
fab9d78c48
@ -272,7 +272,7 @@ const bannerListContract = base
|
||||
.input(
|
||||
type<{
|
||||
query: {
|
||||
page: 'plugins'
|
||||
page: 'plugins' | 'templates'
|
||||
language: string
|
||||
}
|
||||
}>(),
|
||||
|
||||
@ -197,4 +197,20 @@ describe('fetchPluginBanners', () => {
|
||||
await expect(fetchPluginBanners('en-US')).resolves.toEqual([])
|
||||
await expect(fetchPluginBanners('en-US')).resolves.toEqual([])
|
||||
})
|
||||
|
||||
it('requests templates banners when fetching for the templates page', async () => {
|
||||
mockedListBanners.mockResolvedValue({
|
||||
data: {
|
||||
banners: [],
|
||||
},
|
||||
})
|
||||
|
||||
await expect(fetchPluginBanners('en-US', 'templates')).resolves.toEqual([])
|
||||
expect(mockedListBanners).toHaveBeenCalledWith({
|
||||
query: {
|
||||
page: 'templates',
|
||||
language: 'en-US',
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -136,10 +136,13 @@ const normalizePluginBanners = (response: unknown): PluginBanner[] => {
|
||||
.sort((a, b) => a.sort - b.sort)
|
||||
}
|
||||
|
||||
export const fetchPluginBanners = async (language: string): Promise<PluginBanner[]> => {
|
||||
export const fetchPluginBanners = async (
|
||||
language: string,
|
||||
page: 'plugins' | 'templates' = 'plugins',
|
||||
): Promise<PluginBanner[]> => {
|
||||
const response = await marketplaceClient.banners.list({
|
||||
query: {
|
||||
page: 'plugins',
|
||||
page,
|
||||
language,
|
||||
},
|
||||
})
|
||||
|
||||
@ -118,7 +118,7 @@ export async function EmbeddedTemplatesMarketplace({
|
||||
sortBy,
|
||||
sortOrder,
|
||||
}),
|
||||
fetchPluginBanners(locale).catch(() => []),
|
||||
fetchPluginBanners(locale, 'templates').catch(() => []),
|
||||
])
|
||||
const categoryLabels = {
|
||||
all: tPlugin(($) => $['category.all'], { ns: 'plugin' }),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user