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.

feat: skill detail page draft content support export (#42502)

wangxiaoleic4dbc4c830e9
diff --git a/web/features/skills/__tests__/detail-page-metadata.spec.tsx b/web/features/skills/__tests__/detail-page-metadata.spec.tsx
index 17082856c1d..2c2b2602b54 100644
--- a/web/features/skills/__tests__/detail-page-metadata.spec.tsx
+++ b/web/features/skills/__tests__/detail-page-metadata.spec.tsx
@@ -341,38 +341,42 @@ describe('SkillDetailPage metadata', () => {
expect(renameInput).toHaveValue('Untitled skill')
})
- it('duplicates and exports the current skill from the sidebar More menu', async () => {
- const user = userEvent.setup()
- const archive = new Blob(['archive'], { type: 'application/zip' })
- mocks.duplicateSkillMutationFn.mockResolvedValue({})
- mocks.fetchSkillArchiveBlob.mockResolvedValue(archive)
- renderSkillDetailPage()
-
- const moreButton = await screen.findByRole('button', {
- name: 'skill.skillManagement.moreActions:{"name":"Untitled skill"}',
- })
- await user.click(moreButton)
- await user.click(screen.getByRole('menuitem', { name: 'common.operation.duplicate' }))
+ it.each(['version-1', null])(
+ 'duplicates and exports the current skill with published version %s from the sidebar More menu',
+ async (publishedVersionId) => {
+ const user = userEvent.setup()
+ const archive = new Blob(['archive'], { type: 'application/zip' })
+ mocks.skillDetail = createSkillDetail({ latest_published_version_id: publishedVersionId })
+ mocks.duplicateSkillMutationFn.mockResolvedValue({})
+ mocks.fetchSkillArchiveBlob.mockResolvedValue(archive)
+ renderSkillDetailPage()
+
+ const moreButton = await screen.findByRole('button', {
+ name: 'skill.skillManagement.moreActions:{"name":"Untitled skill"}',
+ })
+ await user.click(moreButton)
+ await user.click(screen.getByRole('menuitem', { name: 'common.operation.duplicate' }))
- await waitFor(() => {
- expect(mocks.duplicateSkillMutationFn).toHaveBeenCalledWith(
- { params: { skill_id: 'skill-1' } },
- expect.anything(),
- )
- })
- expect(mocks.toastSuccess).toHaveBeenCalledWith('skill.skillManagement.duplicateSuccess')
+ await waitFor(() => {
+ expect(mocks.duplicateSkillMutationFn).toHaveBeenCalledWith(
+ { params: { skill_id: 'skill-1' } },
+ expect.anything(),
+ )
+ })
+ expect(mocks.toastSuccess).toHaveBeenCalledWith('skill.skillManagement.duplicateSuccess')
- await user.click(moreButton)
- await user.click(screen.getByRole('menuitem', { name: 'common.operation.export' }))
+ await user.click(moreButton)
+ await user.click(screen.getByRole('menuitem', { name: 'common.operation.export' }))
- await waitFor(() => {
- expect(mocks.fetchSkillArchiveBlob).toHaveBeenCalledWith('skill-1')
- expect(mocks.downloadBlob).toHaveBeenCalledWith({
- data: archive,
- fileName: 'github-actions-failure-debugging.zip',
+ await waitFor(() => {
+ expect(mocks.fetchSkillArchiveBlob).toHaveBeenCalledWith('skill-1')
+ expect(mocks.downloadBlob).toHaveBeenCalledWith({
+ data: archive,
+ fileName: 'github-actions-failure-debugging.zip',
+ })
})
- })
- })
+ },
+ )
it('requires the display name before deleting a referenced skill from the sidebar', async () => {
const user = userEvent.setup()
diff --git a/web/features/skills/detail/sidebar-actions.tsx b/web/features/skills/detail/sidebar-actions.tsx
index 191dc923d62..5208818adc5 100644
--- a/web/features/skills/detail/sidebar-actions.tsx
+++ b/web/features/skills/detail/sidebar-actions.tsx
@@ -273,20 +273,18 @@ export function SkillDetailSidebarActions({
<span>{tCommon(($) => $['operation.duplicate'])}</span>
</DropdownMenuItem>
)}
- {detail.latest_published_version_id && (
- <DropdownMenuItem
- className="gap-2"
- onClick={() => {
- if (!exportMutation.isPending) exportMutation.mutate()
- }}
- >
- <span
- aria-hidden
- className="i-ri-file-download-line size-4 shrink-0 text-text-tertiary"
- />
- <span>{tCommon(($) => $['operation.export'])}</span>
- </DropdownMenuItem>
- )}
+ <DropdownMenuItem
+ className="gap-2"
+ onClick={() => {
+ if (!exportMutation.isPending) exportMutation.mutate()
+ }}
+ >
+ <span
+ aria-hidden
+ className="i-ri-file-download-line size-4 shrink-0 text-text-tertiary"
+ />
+ <span>{tCommon(($) => $['operation.export'])}</span>
+ </DropdownMenuItem>
{canDelete && (
<>
<DropdownMenuSeparator />