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.

refactor(web): compose confirmation dialogs with their triggers (#43919)

yyhfd6a19774928
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json
index 5b459cc6e77..413e724b5db 100644
--- a/oxlint-suppressions.json
+++ b/oxlint-suppressions.json
@@ -158,14 +158,6 @@
"count": 1
}
},
- "web/app/components/app/annotation/edit-annotation-modal/index.tsx": {
- "jsx-a11y/click-events-have-key-events": {
- "count": 1
- },
- "jsx-a11y/no-static-element-interactions": {
- "count": 1
- }
- },
"web/app/components/app/annotation/header-opts/__tests__/index.spec.tsx": {
"typescript/no-explicit-any": {
"count": 1
diff --git a/web/app/components/app/annotation/edit-annotation-modal/index.tsx b/web/app/components/app/annotation/edit-annotation-modal/index.tsx
index c1d321a25b1..00f3d94bde5 100644
--- a/web/app/components/app/annotation/edit-annotation-modal/index.tsx
+++ b/web/app/components/app/annotation/edit-annotation-modal/index.tsx
@@ -1,4 +1,5 @@
'use client'
+import type { AlertDialogActions } from '@langgenius/dify-ui/alert-dialog'
import type { FC } from 'react'
import {
AlertDialog,
@@ -7,6 +8,7 @@ import {
AlertDialogContent,
AlertDialogFooter,
AlertDialogTitle,
+ AlertDialogTrigger,
} from '@langgenius/dify-ui/alert-dialog'
import {
Drawer,
@@ -20,7 +22,7 @@ import {
} from '@langgenius/dify-ui/drawer'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import * as React from 'react'
-import { useState } from 'react'
+import { useRef } from 'react'
import { useTranslation } from 'react-i18next'
import { toast } from '@/app/notifications'
import useTimestamp from '@/hooks/use-timestamp'
@@ -78,7 +80,7 @@ const EditAnnotationModal: FC<Props> = ({
throw error
}
}
- const [showModal, setShowModal] = useState(false)
+ const removeActionsRef = useRef<AlertDialogActions>(null)
if (!isShow) return null
return (
@@ -127,10 +129,20 @@ const EditAnnotationModal: FC<Props> = ({
content={answer}
onSave={(editedContent) => handleSave(EditItemType.Answer, editedContent)}
/>
- <AlertDialog
- open={showModal}
- onOpenChange={(open) => !open && setShowModal(false)}
- >
+ </div>
+ </div>
+ <div className="shrink-0">
+ <div className="flex h-16 items-center justify-between rounded-b-xl border-t border-divider-subtle bg-background-section-burn px-4 system-sm-medium text-text-tertiary">
+ <AlertDialog actionsRef={removeActionsRef}>
+ <AlertDialogTrigger className="flex cursor-pointer items-center space-x-2 pl-3">
+ <span
+ aria-hidden
+ className="i-custom-vender-line-communication-message-check-remove h-6 w-6"
+ />
+ <span>
+ {t(($) => $['editModal.removeThisCache'], { ns: 'appAnnotation' })}
+ </span>
+ </AlertDialogTrigger>
<AlertDialogContent>
<div className="flex flex-col gap-2 px-6 pt-6 pb-4">
<AlertDialogTitle
@@ -150,7 +162,7 @@ const EditAnnotationModal: FC<Props> = ({
tone="destructive"
onClick={() => {
onRemove()
- setShowModal(false)
+ removeActionsRef.current?.close()
onHide()
}}
>
@@ -159,20 +171,6 @@ const EditAnnotationModal: FC<Props> = ({
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
- </div>
- </div>
- <div className="shrink-0">
- <div className="flex h-16 items-center justify-between rounded-b-xl border-t border-divider-subtle bg-background-section-burn px-4 system-sm-medium text-text-tertiary">
- <div
- className="flex cursor-pointer items-center space-x-2 pl-3"
- onClick={() => setShowModal(true)}
- >
- <span
- aria-hidden
- className="i-custom-vender-line-communication-message-check-remove h-6 w-6"
- />
- <div>{t(($) => $['editModal.removeThisCache'], { ns: 'appAnnotation' })}</div>
- </div>
{!!createdAt && (
<div>
{t(($) => $['editModal.createdAt'], { ns: 'appAnnotation' })}
diff --git a/web/app/components/app/annotation/view-annotation-modal/index.tsx b/web/app/components/app/annotation/view-annotation-modal/index.tsx
index e768f066daa..4127d11e298 100644
--- a/web/app/components/app/annotation/view-annotation-modal/index.tsx
+++ b/web/app/components/app/annotation/view-annotation-modal/index.tsx
@@ -1,4 +1,5 @@
'use client'
+import type { AlertDialogActions } from '@langgenius/dify-ui/alert-dialog'
import type { FC } from 'react'
import type { AnnotationItem, HitHistoryItem } from '../type'
import {
@@ -8,6 +9,7 @@ import {
AlertDialogContent,
AlertDialogFooter,
AlertDialogTitle,
+ AlertDialogTrigger,
} from '@langgenius/dify-ui/alert-dialog'
import { cn } from '@langgenius/dify-ui/cn'
import {
@@ -103,7 +105,7 @@ const ViewAnnotationModal: FC<Props> = ({ appId, isShow, onHide, item, onSave, o
console.error('Failed to save annotation:', error)
}
}
- const [showModal, setShowModal] = useState(false)
+ const removeActionsRef = React.useRef<AlertDialogActions>(null)
const annotationTab = (
<>
@@ -258,10 +260,20 @@ const ViewAnnotationModal: FC<Props> = ({ appId, isShow, onHide, item, onSave, o
<TabsPanel value={TabType.hitHistory} className="p-6 pb-4">
{hitHistoryTab}
</TabsPanel>
- <AlertDialog
- open={showModal}
- onOpenChange={(open) => !open && setShowModal(false)}
- >
+ </div>
+ </Tabs>
+ {id && (
+ <div className="flex h-16 shrink-0 items-center justify-between rounded-b-xl border-t border-divider-subtle bg-background-section-burn px-4 system-sm-medium text-text-tertiary">
+ <AlertDialog actionsRef={removeActionsRef}>
+ <AlertDialogTrigger className="flex cursor-pointer appearance-none items-center space-x-2 border-0 bg-transparent py-0 pr-0 pl-3 text-left">
+ <span
+ aria-hidden
+ className="i-custom-vender-line-communication-message-check-remove h-6 w-6"
+ />
+ <span>
+ {t(($) => $['editModal.removeThisCache'], { ns: 'appAnnotation' })}
+ </span>
+ </AlertDialogTrigger>
<AlertDialogContent>
<div className="flex flex-col gap-2 px-6 pt-6 pb-4">
<AlertDialogTitle
@@ -281,7 +293,7 @@ const ViewAnnotationModal: FC<Props> = ({ appId, isShow, onHide, item, onSave, o
tone="destructive"
onClick={async () => {
await onRemove()
- setShowModal(false)
+ removeActionsRef.current?.close()
onHide()
}}
>
@@ -290,23 +302,6 @@ const ViewAnnotationModal: FC<Props> = ({ appId, isShow, onHide, item, onSave, o
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
- </div>
- </Tabs>
- {id && (
- <div className="flex h-16 shrink-0 items-center justify-between rounded-b-xl border-t border-divider-subtle bg-background-section-burn px-4 system-sm-medium text-text-tertiary">
- <button
- type="button"
- className="flex cursor-pointer appearance-none items-center space-x-2 border-0 bg-transparent py-0 pr-0 pl-3 text-left"
- onClick={() => setShowModal(true)}
- >
- <span
- aria-hidden
- className="i-custom-vender-line-communication-message-check-remove h-6 w-6"
- />
- <span>
- {t(($) => $['editModal.removeThisCache'], { ns: 'appAnnotation' })}
- </span>
- </button>
<div>
{t(($) => $['editModal.createdAt'], { ns: 'appAnnotation' })}
&nbsp;
diff --git a/web/app/components/app/configuration/config/automatic/__tests__/get-automatic-res.spec.tsx b/web/app/components/app/configuration/config/automatic/__tests__/get-automatic-res.spec.tsx
index 125c8cec1a0..43981e8cd8f 100644
--- a/web/app/components/app/configuration/config/automatic/__tests__/get-automatic-res.spec.tsx
+++ b/web/app/components/app/configuration/config/automatic/__tests__/get-automatic-res.spec.tsx
@@ -97,19 +97,8 @@ vi.mock('../res-placeholder', () => ({
default: () => <div>result-placeholder</div>,
}))
-vi.mock('../result', () => ({
- default: ({
- current,
- onApply,
- }: {
- current: { modified?: string; prompt?: string }
- onApply: () => void
- }) => (
- <div data-testid="result-panel">
- <div>{current.modified || current.prompt}</div>
- <button onClick={onApply}>apply-result</button>
- </div>
- ),
+vi.mock('../prompt-res', () => ({
+ default: ({ value }: { value: string }) => <div data-testid="result-panel">{value}</div>,
}))
describe('GetAutomaticRes', () => {
@@ -239,7 +228,7 @@ describe('GetAutomaticRes', () => {
expect(screen.getByTestId('result-panel')).toHaveTextContent('generated prompt')
})
- fireEvent.click(screen.getByText('apply-result'))
+ fireEvent.click(screen.getByRole('button', { name: /(?:^|\.)generate\.apply(?=$|:)/ }))
await waitFor(() => {
expect(screen.getByText(/(?:^|\.)generate\.overwriteTitle(?=$|:)/)).toBeInTheDocument()
@@ -281,7 +270,7 @@ describe('GetAutomaticRes', () => {
expect(screen.getByTestId('result-panel')).toHaveTextContent('generated prompt')
})
- fireEvent.click(screen.getByText('apply-result'))
+ fireEvent.click(screen.getByRole('button', { name: /(?:^|\.)generate\.apply(?=$|:)/ }))
const dialog = await screen.findByRole('alertdialog')
fireEvent.click(
diff --git a/web/app/components/app/configuration/config/automatic/__tests__/result.spec.tsx b/web/app/components/app/configuration/config/automatic/__tests__/result.spec.tsx
index f4eb453b273..3e0587f20d0 100644
--- a/web/app/components/app/configuration/config/automatic/__tests__/result.spec.tsx
+++ b/web/app/components/app/configuration/config/automatic/__tests__/result.spec.tsx
@@ -84,7 +84,12 @@ describe('Result', () => {
fireEvent.click(screen.getByTestId('version-selector'))
fireEvent.click(screen.getByRole('button', { name: 'common.operation.copy' }))
- fireEvent.click(screen.getByText(/(?:^|\.)generate\.apply(?=$|:)/))
+ const trigger = screen.getByRole('button', { name: /(?:^|\.)generate\.apply(?=$|:)/ })
+ expect(trigger).toHaveAttribute('aria-haspopup', 'dialog')
+ fireEvent.click(trigger)
+ expect(trigger).toHaveAttribute('aria-expanded', 'true')
+ expect(mockOnApply).not.toHaveBeenCalled()
+ fireEvent.click(screen.getByRole('button', { name: 'common.operation.confirm' }))
expect(mockSetCurrentVersionIndex).toHaveBeenCalledWith(1)
expect(mockCopy).toHaveBeenCalledWith('generated output')
diff --git a/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx b/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx
index 622b859d040..bf2598f5087 100644
--- a/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx
+++ b/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx
@@ -4,15 +4,6 @@ import type { FormValue } from '@/app/components/header/account-setting/model-pr
// type
import type { GenRes } from '@/service/debug'
import type { AppModeEnum, CompletionParams, Model, ModelModeType } from '@/types/app'
-import {
- AlertDialog,
- AlertDialogCancelButton,
- AlertDialogConfirmButton,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogFooter,
- AlertDialogTitle,
-} from '@langgenius/dify-ui/alert-dialog'
import { Button } from '@langgenius/dify-ui/button'
import { Dialog, DialogContent, DialogTitle } from '@langgenius/dify-ui/dialog'
import { useQuery } from '@tanstack/react-query'
@@ -265,11 +256,6 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
}
}
- const [
- isShowConfirmOverwrite,
- { setTrue: showConfirmOverwrite, setFalse: hideShowConfirmOverwrite },
- ] = useBoolean(false)
-
const isShowAutoPromptResPlaceholder = () => {
return !isLoading && !current
}
@@ -396,41 +382,13 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
currentVersionIndex={currentVersionIndex || 0}
setCurrentVersionIndex={setCurrentVersionIndex}
versions={versions || []}
- onApply={showConfirmOverwrite}
+ onApply={() => onFinished(current!)}
generatorType={GeneratorType.prompt}
/>
</div>
)}
{isLoading && renderLoading}
{isShowAutoPromptResPlaceholder() && <ResPlaceholder />}
- <AlertDialog
- open={isShowConfirmOverwrite}
- onOpenChange={(open) => !open && hideShowConfirmOverwrite()}
- >
- <AlertDialogContent>
- <div className="flex flex-col gap-2 px-6 pt-6 pb-4">
- <AlertDialogTitle className="w-full truncate title-2xl-semi-bold text-text-primary">
- {t(($) => $['generate.overwriteTitle'], { ns: 'appGeneration' })}
- </AlertDialogTitle>
- <AlertDialogDescription className="w-full system-md-regular wrap-break-word whitespace-pre-wrap text-text-tertiary">
- {t(($) => $['generate.overwriteMessage'], { ns: 'appGeneration' })}
- </AlertDialogDescription>
- </div>
- <AlertDialogFooter>
- <AlertDialogCancelButton>
- {t(($) => $['operation.cancel'], { ns: 'common' })}
- </AlertDialogCancelButton>
- <AlertDialogConfirmButton
- onClick={() => {
- hideShowConfirmOverwrite()
- onFinished(current!)
- }}
- >
- {t(($) => $['operation.confirm'], { ns: 'common' })}
- </AlertDialogConfirmButton>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
</div>
</DialogContent>
</Dialog>
diff --git a/web/app/components/app/configuration/config/automatic/result.tsx b/web/app/components/app/configuration/config/automatic/result.tsx
index 0d399619931..c59d657d5b4 100644
--- a/web/app/components/app/configuration/config/automatic/result.tsx
+++ b/web/app/components/app/configuration/config/automatic/result.tsx
@@ -1,10 +1,22 @@
'use client'
+import type { AlertDialogActions } from '@langgenius/dify-ui/alert-dialog'
import type { FC } from 'react'
import type { GenRes } from '@/service/debug'
+import {
+ AlertDialog,
+ AlertDialogCancelButton,
+ AlertDialogConfirmButton,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogTitle,
+ AlertDialogTrigger,
+} from '@langgenius/dify-ui/alert-dialog'
import { Button } from '@langgenius/dify-ui/button'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import copy from 'copy-to-clipboard'
import * as React from 'react'
+import { useRef } from 'react'
import { useTranslation } from 'react-i18next'
import { toast } from '@/app/components/app/configuration/toast'
import CodeEditor from '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/code-editor'
@@ -36,6 +48,7 @@ const Result: FC<Props> = ({
generatorType,
}) => {
const { t } = useTranslation(['common', 'appGeneration'])
+ const actionsRef = useRef<AlertDialogActions>(null)
const isGeneratorPrompt = generatorType === GeneratorType.prompt
return (
@@ -63,9 +76,38 @@ const Result: FC<Props> = ({
>
<span aria-hidden="true" className="i-ri-clipboard-line size-4 text-text-secondary" />
</IconButton>
- <Button variant="primary" onClick={onApply}>
- {t(($) => $['generate.apply'], { ns: 'appGeneration' })}
- </Button>
+ <AlertDialog actionsRef={actionsRef}>
+ <AlertDialogTrigger render={<Button variant="primary" />}>
+ {t(($) => $['generate.apply'], { ns: 'appGeneration' })}
+ </AlertDialogTrigger>
+ <AlertDialogContent>
+ <div className="flex flex-col gap-2 px-6 pt-6 pb-4">
+ <AlertDialogTitle className="w-full truncate title-2xl-semi-bold text-text-primary">
+ {isGeneratorPrompt
+ ? t(($) => $['generate.overwriteTitle'], { ns: 'appGeneration' })
+ : t(($) => $['codegen.overwriteConfirmTitle'], { ns: 'appGeneration' })}
+ </AlertDialogTitle>
+ <AlertDialogDescription className="w-full system-md-regular wrap-break-word whitespace-pre-wrap text-text-tertiary">
+ {isGeneratorPrompt
+ ? t(($) => $['generate.overwriteMessage'], { ns: 'appGeneration' })
+ : t(($) => $['codegen.overwriteConfirmMessage'], { ns: 'appGeneration' })}
+ </AlertDialogDescription>
+ </div>
+ <AlertDialogFooter>
+ <AlertDialogCancelButton>
+ {t(($) => $['operation.cancel'], { ns: 'common' })}
+ </AlertDialogCancelButton>
+ <AlertDialogConfirmButton
+ onClick={() => {
+ actionsRef.current?.close()
+ onApply()
+ }}
+ >
+ {t(($) => $['operation.confirm'], { ns: 'common' })}
+ </AlertDialogConfirmButton>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
</div>
</div>
<div className="flex grow flex-col overflow-y-auto">
diff --git a/web/app/components/app/configuration/config/code-generator/__tests__/get-code-generator-res.spec.tsx b/web/app/components/app/configuration/config/code-generator/__tests__/get-code-generator-res.spec.tsx
index 29a4df0be15..80c5ae8f66d 100644
--- a/web/app/components/app/configuration/config/code-generator/__tests__/get-code-generator-res.spec.tsx
+++ b/web/app/components/app/configuration/config/code-generator/__tests__/get-code-generator-res.spec.tsx
@@ -87,20 +87,12 @@ vi.mock('../../automatic/res-placeholder', () => ({
default: () => <div>code-result-placeholder</div>,
}))
-vi.mock('../../automatic/result', () => ({
- default: ({
- current,
- onApply,
- }: {
- current: { modified?: string; code?: string }
- onApply: () => void
- }) => (
- <div data-testid="code-result-panel">
- <div>{current.modified || current.code}</div>
- <button onClick={onApply}>apply-code-result</button>
- </div>
- ),
-}))
+vi.mock(
+ '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/code-editor',
+ () => ({
+ default: ({ value }: { value: string }) => <div data-testid="code-result-panel">{value}</div>,
+ }),
+)
describe('GetCodeGeneratorResModal', () => {
const mockOnClose = vi.fn()
@@ -237,7 +229,7 @@ describe('GetCodeGeneratorResModal', () => {
expect(screen.getByTestId('code-result-panel')).toHaveTextContent('print("hello")')
})
- fireEvent.click(screen.getByText('apply-code-result'))
+ fireEvent.click(screen.getByRole('button', { name: /(?:^|\.)generate\.apply(?=$|:)/ }))
await waitFor(() => {
expect(screen.getByText(/(?:^|\.)codegen\.overwriteConfirmTitle(?=$|:)/)).toBeInTheDocument()
@@ -279,7 +271,7 @@ describe('GetCodeGeneratorResModal', () => {
expect(screen.getByTestId('code-result-panel')).toHaveTextContent('print("hello")')
})
- fireEvent.click(screen.getByText('apply-code-result'))
+ fireEvent.click(screen.getByRole('button', { name: /(?:^|\.)generate\.apply(?=$|:)/ }))
const dialog = await screen.findByRole('alertdialog')
fireEvent.click(
diff --git a/web/app/components/app/configuration/config/code-generator/get-code-generator-res.tsx b/web/app/components/app/configuration/config/code-generator/get-code-generator-res.tsx
index 5260f4127b8..4a868b916c8 100644
--- a/web/app/components/app/configuration/config/code-generator/get-code-generator-res.tsx
+++ b/web/app/components/app/configuration/config/code-generator/get-code-generator-res.tsx
@@ -3,15 +3,6 @@ import type { FormValue } from '@/app/components/header/account-setting/model-pr
import type { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
import type { GenRes } from '@/service/debug'
import type { AppModeEnum, CompletionParams, Model, ModelModeType } from '@/types/app'
-import {
- AlertDialog,
- AlertDialogCancelButton,
- AlertDialogConfirmButton,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogFooter,
- AlertDialogTitle,
-} from '@langgenius/dify-ui/alert-dialog'
import { Button } from '@langgenius/dify-ui/button'
import { Dialog, DialogContent } from '@langgenius/dify-ui/dialog'
import { useQuery } from '@tanstack/react-query'
@@ -182,11 +173,6 @@ export const GetCodeGeneratorResModal: FC<IGetCodeGeneratorResProps> = ({
}
}
- const [
- isShowConfirmOverwrite,
- { setTrue: showConfirmOverwrite, setFalse: hideShowConfirmOverwrite },
- ] = useBoolean(false)
-
const renderLoading = (
<div className="flex h-full w-0 grow flex-col items-center justify-center space-y-3">
<LoadingPlaceholder />
@@ -269,40 +255,12 @@ export const GetCodeGeneratorResModal: FC<IGetCodeGeneratorResProps> = ({
currentVersionIndex={currentVersionIndex || 0}
setCurrentVersionIndex={setCurrentVersionIndex}
versions={versions || []}
- onApply={showConfirmOverwrite}
+ onApply={() => onFinished(current!)}
generatorType={GeneratorType.code}
/>
</div>
)}
</div>
- <AlertDialog
- open={isShowConfirmOverwrite}
- onOpenChange={(open) => !open && hideShowConfirmOverwrite()}
- >
- <AlertDialogContent>
- <div className="flex flex-col gap-2 px-6 pt-6 pb-4">
- <AlertDialogTitle className="w-full truncate title-2xl-semi-bold text-text-primary">
- {t(($) => $['codegen.overwriteConfirmTitle'], { ns: 'appGeneration' })}
- </AlertDialogTitle>
- <AlertDialogDescription className="w-full system-md-regular wrap-break-word whitespace-pre-wrap text-text-tertiary">
- {t(($) => $['codegen.overwriteConfirmMessage'], { ns: 'appGeneration' })}
- </AlertDialogDescription>
- </div>
- <AlertDialogFooter>
- <AlertDialogCancelButton>
- {t(($) => $['operation.cancel'], { ns: 'common' })}
- </AlertDialogCancelButton>
- <AlertDialogConfirmButton
- onClick={() => {
- hideShowConfirmOverwrite()
- onFinished(current!)
- }}
- >
- {t(($) => $['operation.confirm'], { ns: 'common' })}
- </AlertDialogConfirmButton>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
</DialogContent>
</Dialog>
)
diff --git a/web/app/components/datasets/metadata/metadata-dataset/dataset-metadata-drawer.tsx b/web/app/components/datasets/metadata/metadata-dataset/dataset-metadata-drawer.tsx
index 4744da3cb90..acba8683bc0 100644
--- a/web/app/components/datasets/metadata/metadata-dataset/dataset-metadata-drawer.tsx
+++ b/web/app/components/datasets/metadata/metadata-dataset/dataset-metadata-drawer.tsx
@@ -1,4 +1,5 @@
'use client'
+import type { AlertDialogActions } from '@langgenius/dify-ui/alert-dialog'
import type { FC } from 'react'
import type { BuiltInMetadataItem, MetadataItemWithValueLength } from '../types'
import {
@@ -9,6 +10,7 @@ import {
AlertDialogDescription,
AlertDialogFooter,
AlertDialogTitle,
+ AlertDialogTrigger,
} from '@langgenius/dify-ui/alert-dialog'
import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
@@ -27,7 +29,7 @@ import { IconButton } from '@langgenius/dify-ui/icon-button'
import { Infotip, InfotipContent, InfotipTrigger } from '@langgenius/dify-ui/infotip'
import { Input } from '@langgenius/dify-ui/input'
import { Switch } from '@langgenius/dify-ui/switch'
-import { useBoolean, useHover } from 'ahooks'
+import { useHover } from 'ahooks'
import * as React from 'react'
import { useCallback, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
@@ -66,12 +68,11 @@ const Item: FC<ItemProps> = ({ readonly, disabled, payload, onRename, onDelete }
const deleteBtnRef = useRef<HTMLButtonElement>(null)
const isDeleteHovering = useHover(deleteBtnRef)
- const [isShowDeleteConfirm, { setTrue: showDeleteConfirm, setFalse: hideDeleteConfirm }] =
- useBoolean(false)
+ const deleteActionsRef = useRef<AlertDialogActions>(null)
const handleDelete = useCallback(() => {
- hideDeleteConfirm()
+ deleteActionsRef.current?.close()
onDelete?.()
- }, [hideDeleteConfirm, onDelete])
+ }, [onDelete])
return (
<div
@@ -111,43 +112,43 @@ const Item: FC<ItemProps> = ({ readonly, disabled, payload, onRename, onDelete }
>
<span className="i-ri-edit-line size-4" aria-hidden="true" />
</IconButton>
- <IconButton
- size="sm"
- ref={deleteBtnRef}
- tone="destructive"
- aria-label={t(($) => $['operation.remove'], { ns: 'common' })}
- onClick={showDeleteConfirm}
- >
- <span className="i-ri-delete-bin-line size-4" aria-hidden="true" />
- </IconButton>
+ <AlertDialog actionsRef={deleteActionsRef}>
+ <AlertDialogTrigger
+ ref={deleteBtnRef}
+ render={
+ <IconButton
+ aria-label={t(($) => $['operation.remove'], { ns: 'common' })}
+ size="sm"
+ tone="destructive"
+ >
+ <span className="i-ri-delete-bin-line size-4" aria-hidden="true" />
+ </IconButton>
+ }
+ />
+ <AlertDialogContent>
+ <div className="flex flex-col gap-2 px-6 pt-6 pb-4">
+ <AlertDialogTitle className="w-full truncate title-2xl-semi-bold text-text-primary">
+ {t(($) => $['metadata.datasetMetadata.deleteTitle'], { ns: 'dataset' })}
+ </AlertDialogTitle>
+ <AlertDialogDescription className="w-full system-md-regular wrap-break-word whitespace-pre-wrap text-text-tertiary">
+ {t(($) => $['metadata.datasetMetadata.deleteContent'], {
+ ns: 'dataset',
+ name: payload.name,
+ })}
+ </AlertDialogDescription>
+ </div>
+ <AlertDialogFooter>
+ <AlertDialogCancelButton>
+ {t(($) => $['operation.cancel'], { ns: 'common' })}
+ </AlertDialogCancelButton>
+ <AlertDialogConfirmButton onClick={handleDelete}>
+ {t(($) => $['operation.confirm'], { ns: 'common' })}
+ </AlertDialogConfirmButton>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
</div>
)}
- <AlertDialog
- open={isShowDeleteConfirm}
- onOpenChange={(open) => !open && hideDeleteConfirm()}
- >
- <AlertDialogContent>
- <div className="flex flex-col gap-2 px-6 pt-6 pb-4">
- <AlertDialogTitle className="w-full truncate title-2xl-semi-bold text-text-primary">
- {t(($) => $['metadata.datasetMetadata.deleteTitle'], { ns: 'dataset' })}
- </AlertDialogTitle>
- <AlertDialogDescription className="w-full system-md-regular wrap-break-word whitespace-pre-wrap text-text-tertiary">
- {t(($) => $['metadata.datasetMetadata.deleteContent'], {
- ns: 'dataset',
- name: payload.name,
- })}
- </AlertDialogDescription>
- </div>
- <AlertDialogFooter>
- <AlertDialogCancelButton>
- {t(($) => $['operation.cancel'], { ns: 'common' })}
- </AlertDialogCancelButton>
- <AlertDialogConfirmButton onClick={handleDelete}>
- {t(($) => $['operation.confirm'], { ns: 'common' })}
- </AlertDialogConfirmButton>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
</div>
</div>
)
diff --git a/web/app/components/header/account-setting/api-based-extension-page/__tests__/item.spec.tsx b/web/app/components/header/account-setting/api-based-extension-page/__tests__/item.spec.tsx
index c84d668b983..75cceac81b6 100644
--- a/web/app/components/header/account-setting/api-based-extension-page/__tests__/item.spec.tsx
+++ b/web/app/components/header/account-setting/api-based-extension-page/__tests__/item.spec.tsx
@@ -1,34 +1,13 @@
import type { ApiBasedExtensionResponse } from '@dify/contracts/api/console/api-based-extension/types.gen'
import type { TFunction } from 'i18next'
-import { fireEvent, render, screen, waitFor, within } from '@testing-library/react'
+import { fireEvent, screen, waitFor, within } from '@testing-library/react'
import * as reactI18next from 'react-i18next'
+import { renderWithConsoleQuery as render } from '@/test/console/query-data'
import { withSelectorKey } from '@/test/i18n-mock'
import { Item } from '../item'
-const { mockDeleteApiBasedExtension } = vi.hoisted(() => ({
- mockDeleteApiBasedExtension: vi.fn(),
-}))
-
-vi.mock('@/service/console', () => ({
- consoleQuery: {
- apiBasedExtension: {
- byId: {
- delete: {
- mutationOptions: () => ({ mutationFn: mockDeleteApiBasedExtension }),
- },
- },
- },
- },
-}))
-
-vi.mock('@tanstack/react-query', () => ({
- useMutation: vi.fn((options: { mutationFn: (variables: unknown) => Promise<unknown> }) => ({
- isPending: false,
- mutate: (variables: unknown, mutationOptions?: { onSuccess?: (data: unknown) => void }) => {
- options.mutationFn(variables).then((data) => mutationOptions?.onSuccess?.(data))
- },
- })),
-}))
+const { request } = vi.hoisted(() => ({ request: vi.fn() }))
+vi.mock('@/service/base', () => ({ request }))
describe('Item Component', () => {
const mockData: ApiBasedExtensionResponse = {
@@ -41,6 +20,7 @@ describe('Item Component', () => {
beforeEach(() => {
vi.clearAllMocks()
+ request.mockImplementation(() => Promise.resolve(Response.json({ result: 'success' })))
})
describe('Rendering', () => {
@@ -139,7 +119,12 @@ describe('Item Component', () => {
it('should show delete confirmation dialog when clicking delete button', () => {
// Act
render(<Item apiBasedExtension={mockData} onEdit={mockOnEdit} />)
- fireEvent.click(screen.getByText('common.operation.delete'))
+ const trigger = screen.getByRole('button', {
+ name: /common\.operation\.delete.*Test Extension/i,
+ })
+ expect(trigger).toHaveAttribute('aria-haspopup', 'dialog')
+ fireEvent.click(trigger)
+ expect(trigger).toHaveAttribute('aria-expanded', 'true')
// Assert
// Assert
@@ -150,7 +135,6 @@ describe('Item Component', () => {
it('should call delete mutation when confirming deletion', async () => {
// Arrange
- mockDeleteApiBasedExtension.mockResolvedValue({})
render(<Item apiBasedExtension={mockData} onEdit={mockOnEdit} />)
// Act
@@ -163,17 +147,15 @@ describe('Item Component', () => {
// Assert
await waitFor(() => {
- expect(mockDeleteApiBasedExtension).toHaveBeenCalledWith({
- params: {
- id: '1',
- },
- })
+ expect(request).toHaveBeenCalledTimes(1)
+ const sent = request.mock.calls[0]![2].request as Request
+ expect(sent.method).toBe('DELETE')
+ expect(new URL(sent.url).pathname).toMatch(/\/api-based-extension\/1$/)
})
})
it('should hide delete confirmation dialog after successful deletion', async () => {
// Arrange
- mockDeleteApiBasedExtension.mockResolvedValue({})
render(<Item apiBasedExtension={mockData} onEdit={mockOnEdit} />)
// Act
@@ -213,7 +195,7 @@ describe('Item Component', () => {
fireEvent.click(screen.getByText('common.operation.cancel'))
// Assert
- expect(mockDeleteApiBasedExtension).not.toHaveBeenCalled()
+ expect(request).not.toHaveBeenCalled()
})
})
diff --git a/web/app/components/header/account-setting/api-based-extension-page/item.tsx b/web/app/components/header/account-setting/api-based-extension-page/item.tsx
index 1d2892d79ba..1cc43e15e0d 100644
--- a/web/app/components/header/account-setting/api-based-extension-page/item.tsx
+++ b/web/app/components/header/account-setting/api-based-extension-page/item.tsx
@@ -1,4 +1,5 @@
import type { ApiBasedExtensionResponse } from '@dify/contracts/api/console/api-based-extension/types.gen'
+import type { AlertDialogActions } from '@langgenius/dify-ui/alert-dialog'
import {
AlertDialog,
AlertDialogCancelButton,
@@ -6,10 +7,11 @@ import {
AlertDialogContent,
AlertDialogFooter,
AlertDialogTitle,
+ AlertDialogTrigger,
} from '@langgenius/dify-ui/alert-dialog'
import { Button } from '@langgenius/dify-ui/button'
import { useMutation } from '@tanstack/react-query'
-import { useId, useState } from 'react'
+import { useId, useRef } from 'react'
import { useTranslation } from 'react-i18next'
import { consoleQuery } from '@/service/console'
@@ -23,7 +25,7 @@ export function Item({ apiBasedExtension, onEdit, canManage = true }: ItemProps)
const nameId = useId()
const editLabelId = useId()
const deleteLabelId = useId()
- const [showDeleteConfirm, setShowDeleteConfirm] = useState(false)
+ const actionsRef = useRef<AlertDialogActions>(null)
const deleteApiBasedExtensionMutation = useMutation(
consoleQuery.apiBasedExtension.byId.delete.mutationOptions(),
)
@@ -43,9 +45,7 @@ export function Item({ apiBasedExtension, onEdit, canManage = true }: ItemProps)
},
},
{
- onSuccess: () => {
- setShowDeleteConfirm(false)
- },
+ onSuccess: () => actionsRef.current?.close(),
},
)
}
@@ -67,38 +67,35 @@ export function Item({ apiBasedExtension, onEdit, canManage = true }: ItemProps)
<span className="i-ri-edit-line size-4" aria-hidden="true" />
<span id={editLabelId}>{t(($) => $['operation.edit'], { ns: 'common' })}</span>
</Button>
- <Button
- aria-labelledby={`${deleteLabelId} ${nameId}`}
- disabled={!canManage}
- onClick={() => canManage && setShowDeleteConfirm(true)}
- >
- <span className="i-ri-delete-bin-line size-4" aria-hidden="true" />
- <span id={deleteLabelId}>{t(($) => $['operation.delete'], { ns: 'common' })}</span>
- </Button>
+ <AlertDialog actionsRef={actionsRef}>
+ <AlertDialogTrigger
+ aria-labelledby={`${deleteLabelId} ${nameId}`}
+ disabled={!canManage}
+ render={<Button />}
+ >
+ <span className="i-ri-delete-bin-line size-4" aria-hidden="true" />
+ <span id={deleteLabelId}>{t(($) => $['operation.delete'], { ns: 'common' })}</span>
+ </AlertDialogTrigger>
+ <AlertDialogContent backdropProps={{ forceRender: true }}>
+ <div className="flex flex-col gap-2 px-6 pt-6 pb-4">
+ <AlertDialogTitle className="w-full truncate title-2xl-semi-bold text-text-primary">
+ {`${t(($) => $['operation.delete'], { ns: 'common' })} \u201C${apiBasedExtension.name}\u201D?`}
+ </AlertDialogTitle>
+ </div>
+ <AlertDialogFooter>
+ <AlertDialogCancelButton>
+ {t(($) => $['operation.cancel'], { ns: 'common' })}
+ </AlertDialogCancelButton>
+ <AlertDialogConfirmButton
+ disabled={!canManage || deleteApiBasedExtensionMutation.isPending}
+ onClick={handleDeleteApiBasedExtension}
+ >
+ {t(($) => $['operation.delete'], { ns: 'common' }) || ''}
+ </AlertDialogConfirmButton>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
</div>
- <AlertDialog
- open={showDeleteConfirm}
- onOpenChange={(open) => !open && setShowDeleteConfirm(false)}
- >
- <AlertDialogContent backdropProps={{ forceRender: true }}>
- <div className="flex flex-col gap-2 px-6 pt-6 pb-4">
- <AlertDialogTitle className="w-full truncate title-2xl-semi-bold text-text-primary">
- {`${t(($) => $['operation.delete'], { ns: 'common' })} \u201C${apiBasedExtension.name}\u201D?`}
- </AlertDialogTitle>
- </div>
- <AlertDialogFooter>
- <AlertDialogCancelButton>
- {t(($) => $['operation.cancel'], { ns: 'common' })}
- </AlertDialogCancelButton>
- <AlertDialogConfirmButton
- disabled={!canManage || deleteApiBasedExtensionMutation.isPending}
- onClick={handleDeleteApiBasedExtension}
- >
- {t(($) => $['operation.delete'], { ns: 'common' }) || ''}
- </AlertDialogConfirmButton>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
</div>
)
}
diff --git a/web/app/components/plugins/plugin-detail-panel/__tests__/endpoint-list.spec.tsx b/web/app/components/plugins/plugin-detail-panel/__tests__/endpoint-list.spec.tsx
index 44c6a0f150e..b0118fd7bc0 100644
--- a/web/app/components/plugins/plugin-detail-panel/__tests__/endpoint-list.spec.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/__tests__/endpoint-list.spec.tsx
@@ -163,9 +163,12 @@ describe('Endpoint management', () => {
it('deletes through the canonical route and refreshes the empty state', async () => {
const user = userEvent.setup()
renderEndpoints()
- await user.click(
- await screen.findByRole('button', { name: 'common.operation.delete Endpoint 1' }),
- )
+ const trigger = await screen.findByRole('button', {
+ name: 'common.operation.delete Endpoint 1',
+ })
+ expect(trigger).toHaveAttribute('aria-haspopup', 'dialog')
+ await user.click(trigger)
+ expect(trigger).toHaveAttribute('aria-expanded', 'true')
await user.click(screen.getByRole('button', { name: 'common.operation.confirm' }))
expect(await screen.findByText('plugin.detailPanel.endpointsEmpty')).toBeInTheDocument()
expect(mutations).toEqual([
diff --git a/web/app/components/plugins/plugin-detail-panel/endpoint-card.tsx b/web/app/components/plugins/plugin-detail-panel/endpoint-card.tsx
index b48d3bdac36..9e63d9cb6a3 100644
--- a/web/app/components/plugins/plugin-detail-panel/endpoint-card.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/endpoint-card.tsx
@@ -1,4 +1,5 @@
import type { EndpointListItemResponse } from '@dify/contracts/api/console/workspaces/types.gen'
+import type { AlertDialogActions } from '@langgenius/dify-ui/alert-dialog'
import type { PluginDetail } from '../types'
import {
AlertDialog,
@@ -7,6 +8,7 @@ import {
AlertDialogContent,
AlertDialogFooter,
AlertDialogTitle,
+ AlertDialogTrigger,
} from '@langgenius/dify-ui/alert-dialog'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { StatusDot } from '@langgenius/dify-ui/status-dot'
@@ -16,7 +18,7 @@ import { useMutation } from '@tanstack/react-query'
import { useBoolean } from 'ahooks'
import copy from 'copy-to-clipboard'
import * as React from 'react'
-import { useEffect, useState } from 'react'
+import { useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { toast } from '@/app/notifications'
import { consoleQuery } from '@/service/console'
@@ -33,8 +35,7 @@ const EndpointCard = ({ pluginDetail, data }: Props) => {
const endpointID = data.id
const [isShowDisableConfirm, { setTrue: showDisableConfirm, setFalse: hideDisableConfirm }] =
useBoolean(false)
- const [isShowDeleteConfirm, { setTrue: showDeleteConfirm, setFalse: hideDeleteConfirm }] =
- useBoolean(false)
+ const deleteActionsRef = useRef<AlertDialogActions>(null)
const [
isShowEndpointModal,
{ setTrue: showEndpointModalConfirm, setFalse: hideEndpointModalConfirm },
@@ -55,7 +56,7 @@ const EndpointCard = ({ pluginDetail, data }: Props) => {
)
const { mutate: deleteEndpoint, isPending: isDeleting } = useMutation(
consoleQuery.workspaces.current.endpoints.byId.delete.mutationOptions({
- onSuccess: hideDeleteConfirm,
+ onSuccess: () => deleteActionsRef.current?.close(),
onError: showSaveError,
}),
)
@@ -104,13 +105,42 @@ const EndpointCard = ({ pluginDetail, data }: Props) => {
>
<span aria-hidden className="i-ri-edit-line size-4" />
</IconButton>
- <IconButton
- aria-label={`${t(($) => $['operation.delete'], { ns: 'common' })} ${data.name}`}
- tone="destructive"
- onClick={showDeleteConfirm}
- >
- <span aria-hidden className="i-ri-delete-bin-line size-4" />
- </IconButton>
+ <AlertDialog actionsRef={deleteActionsRef}>
+ <AlertDialogTrigger
+ render={
+ <IconButton
+ aria-label={`${t(($) => $['operation.delete'], { ns: 'common' })} ${data.name}`}
+ tone="destructive"
+ >
+ <span aria-hidden className="i-ri-delete-bin-line size-4" />
+ </IconButton>
+ }
+ />
+ <AlertDialogContent backdropProps={{ forceRender: true }}>
+ <div className="flex flex-col gap-2 px-6 pt-6 pb-4">
+ <AlertDialogTitle className="w-full truncate title-2xl-semi-bold text-text-primary">
+ {t(($) => $['detailPanel.endpointDeleteTip'], { ns: 'plugin' })}
+ </AlertDialogTitle>
+ <div className="w-full system-md-regular wrap-break-word whitespace-pre-wrap text-text-tertiary">
+ {t(($) => $['detailPanel.endpointDeleteContent'], {
+ ns: 'plugin',
+ name: data.name,
+ })}
+ </div>
+ </div>
+ <AlertDialogFooter>
+ <AlertDialogCancelButton>
+ {t(($) => $['operation.cancel'], { ns: 'common' })}
+ </AlertDialogCancelButton>
+ <AlertDialogConfirmButton
+ loading={isDeleting}
+ onClick={() => deleteEndpoint({ params: { id: endpointID } })}
+ >
+ {t(($) => $['operation.confirm'], { ns: 'common' })}
+ </AlertDialogConfirmButton>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
</div>
</div>
{(data.declaration?.endpoints ?? [])
@@ -198,29 +228,7 @@ const EndpointCard = ({ pluginDetail, data }: Props) => {
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
- <AlertDialog open={isShowDeleteConfirm} onOpenChange={(open) => !open && hideDeleteConfirm()}>
- <AlertDialogContent backdropProps={{ forceRender: true }}>
- <div className="flex flex-col gap-2 px-6 pt-6 pb-4">
- <AlertDialogTitle className="w-full truncate title-2xl-semi-bold text-text-primary">
- {t(($) => $['detailPanel.endpointDeleteTip'], { ns: 'plugin' })}
- </AlertDialogTitle>
- <div className="w-full system-md-regular wrap-break-word whitespace-pre-wrap text-text-tertiary">
- {t(($) => $['detailPanel.endpointDeleteContent'], { ns: 'plugin', name: data.name })}
- </div>
- </div>
- <AlertDialogFooter>
- <AlertDialogCancelButton>
- {t(($) => $['operation.cancel'], { ns: 'common' })}
- </AlertDialogCancelButton>
- <AlertDialogConfirmButton
- loading={isDeleting}
- onClick={() => deleteEndpoint({ params: { id: endpointID } })}
- >
- {t(($) => $['operation.confirm'], { ns: 'common' })}
- </AlertDialogConfirmButton>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
+
{isShowEndpointModal && (
<EndpointModal
settings={data.declaration?.settings ?? []}
diff --git a/web/features/skills/__tests__/detail-page-publishing.spec.tsx b/web/features/skills/__tests__/detail-page-publishing.spec.tsx
index be300d5603b..a323e1a21f0 100644
--- a/web/features/skills/__tests__/detail-page-publishing.spec.tsx
+++ b/web/features/skills/__tests__/detail-page-publishing.spec.tsx
@@ -1,6 +1,6 @@
import type { SkillReferenceResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import { QueryClient } from '@tanstack/react-query'
-import { screen, waitFor, within } from '@testing-library/react'
+import { act, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import {
@@ -15,6 +15,17 @@ import {
const mocks = getMocks()
+function getVersionRequests(action: 'restore' | 'delete') {
+ return mocks.request.mock.calls
+ .map(([, , options]) => options.request)
+ .filter((request) => {
+ const path = new URL(request.url).pathname
+ return action === 'restore'
+ ? request.method === 'POST' && path.endsWith('/skills/skill-1/restore')
+ : request.method === 'DELETE' && path.endsWith('/skills/skill-1/versions/version-1')
+ })
+}
+
describe('SkillDetailPage publishing', () => {
beforeEach(resetDetailPageFixture)
@@ -390,8 +401,7 @@ describe('SkillDetailPage publishing', () => {
}),
}))
- const { queryClient } = renderSkillDetailPage()
- const invalidateQueries = vi.spyOn(queryClient, 'invalidateQueries')
+ renderSkillDetailPage()
await user.click(
await screen.findByRole('button', { name: 'skill.skillManagement.detail.versionHistory' }),
@@ -409,21 +419,18 @@ describe('SkillDetailPage publishing', () => {
}),
)
- await waitFor(() => {
- expect(mocks.restoreSkillMutationFn).toHaveBeenCalledWith(
- expect.objectContaining({
- body: {
- version_id: 'version-1',
- version_name: 'Rollback target',
- },
- }),
- expect.anything(),
- )
+ await waitFor(() => expect(getVersionRequests('restore')).toHaveLength(1))
+ expect(await getVersionRequests('restore')[0]!.clone().json()).toEqual({
+ version_id: 'version-1',
+ version_name: 'Rollback target',
})
await waitFor(() => {
- expect(invalidateQueries).toHaveBeenCalledWith({
- queryKey: ['skills', { type: 'infinite' }],
- })
+ expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument()
+ expect(
+ screen.queryByRole('button', {
+ name: 'skill.skillManagement.detail.restoreVersion',
+ }),
+ ).not.toBeInTheDocument()
})
})
@@ -479,16 +486,10 @@ describe('SkillDetailPage publishing', () => {
}),
)
- await waitFor(() => {
- expect(mocks.restoreSkillMutationFn).toHaveBeenCalledWith(
- expect.objectContaining({
- body: {
- version_id: 'version-2',
- version_name: '',
- },
- }),
- expect.anything(),
- )
+ await waitFor(() => expect(getVersionRequests('restore')).toHaveLength(1))
+ expect(await getVersionRequests('restore')[0]!.clone().json()).toEqual({
+ version_id: 'version-2',
+ version_name: '',
})
})
@@ -587,40 +588,73 @@ describe('SkillDetailPage publishing', () => {
})
})
- it('deletes a non-latest version from the version menu', async () => {
- const user = userEvent.setup()
- const version = createSkillVersion({
- id: 'version-1',
- is_latest: false,
- version_name: 'Old version',
- })
- mocks.skillVersionsQueryOptions.mockImplementation((options) => ({
- queryKey: ['skill-versions', options],
- queryFn: async () => ({
- data: [version],
- }),
- }))
- renderSkillDetailPage()
-
- await user.click(
- await screen.findByRole('button', { name: 'skill.skillManagement.detail.versionHistory' }),
- )
- await openVersionRowActions(user, 'Old version')
- await user.click(await screen.findByText('common.operation.delete'))
- const dialog = await screen.findByRole('alertdialog')
-
- await user.click(within(dialog).getByRole('button', { name: 'common.operation.delete' }))
-
- await waitFor(() => {
- expect(mocks.versionDeleteMutationFn).toHaveBeenCalledWith(
- {
- params: {
- skill_id: 'skill-1',
- version_id: 'version-1',
- },
- },
- expect.anything(),
+ it.each(['restore button', 'restore menu', 'delete menu'] as const)(
+ 'keeps %s pending and retryable after failure',
+ async (entry) => {
+ const user = userEvent.setup()
+ const action = entry === 'delete menu' ? 'delete' : 'restore'
+ const confirmLabel =
+ action === 'delete'
+ ? 'common.operation.delete'
+ : 'skill.skillManagement.detail.restoreVersion'
+ const version = createSkillVersion({ version_name: 'Target version' })
+ mocks.skillVersionsQueryOptions.mockImplementation(() => ({
+ queryKey: ['skill-versions'],
+ queryFn: async () => ({ data: [version] }),
+ }))
+ mocks.skillVersionDetailQueryOptions.mockImplementation(() => ({
+ queryKey: ['skill-version-detail'],
+ queryFn: async () => ({ ...version, files: createSkillDetail().files }),
+ }))
+ renderSkillDetailPage()
+ await user.click(
+ await screen.findByRole('button', { name: 'skill.skillManagement.detail.versionHistory' }),
)
- })
- })
+ if (entry === 'restore button') {
+ const trigger = await screen.findByRole('button', { name: confirmLabel })
+ expect(trigger).toHaveAttribute('aria-haspopup', 'dialog')
+ expect(trigger).toHaveAttribute('aria-expanded', 'false')
+ await user.click(trigger)
+ expect(trigger).toHaveAttribute('aria-expanded', 'true')
+ await user.click(
+ within(await screen.findByRole('alertdialog')).getByRole('button', {
+ name: 'common.operation.cancel',
+ }),
+ )
+ await waitFor(() => expect(trigger).toHaveFocus())
+ await user.click(trigger)
+ } else {
+ const row = (await screen.findByRole('button', { name: /Target version/ })).closest('li')!
+ await user.click(within(row).getByRole('button', { name: 'common.operation.more' }))
+ await user.click(await screen.findByRole('menuitem', { name: confirmLabel }))
+ }
+ const dialog = await screen.findByRole('alertdialog')
+ const confirm = within(dialog).getByRole('button', { name: confirmLabel })
+ const cancel = within(dialog).getByRole('button', { name: 'common.operation.cancel' })
+ let rejectRequest!: (error: Error) => void
+ mocks.request.mockImplementationOnce(
+ () =>
+ new Promise((_, reject) => {
+ rejectRequest = reject
+ }),
+ )
+ await user.click(confirm)
+ await waitFor(() => expect(confirm).toHaveAttribute('aria-disabled', 'true'))
+ expect(cancel).toBeDisabled()
+ await user.click(confirm)
+ await user.click(cancel)
+ await user.keyboard('{Escape}')
+ expect(screen.getByRole('alertdialog')).toBeInTheDocument()
+ expect(getVersionRequests(action)).toHaveLength(1)
+
+ await act(async () => {
+ rejectRequest(new Error('Request failed'))
+ })
+ await waitFor(() => expect(cancel).toBeEnabled())
+ expect(screen.getByRole('alertdialog')).toBeInTheDocument()
+ await user.click(confirm)
+ await waitFor(() => expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument())
+ expect(getVersionRequests(action)).toHaveLength(2)
+ },
+ )
})
diff --git a/web/features/skills/__tests__/detail-page.fixture.tsx b/web/features/skills/__tests__/detail-page.fixture.tsx
index e7df4a3fa6b..a0ff3dad885 100644
--- a/web/features/skills/__tests__/detail-page.fixture.tsx
+++ b/web/features/skills/__tests__/detail-page.fixture.tsx
@@ -19,6 +19,8 @@ import { SkillDetailPage } from '../detail/page'
export const primaryModifier = detectPlatform() === 'mac' ? { metaKey: true } : { ctrlKey: true }
const mocks = vi.hoisted(() => ({
+ request:
+ vi.fn<(url: string, init: RequestInit, options: { request: Request }) => Promise<Response>>(),
deleteSkillMutationFn: vi.fn(),
copyToClipboard: vi.fn(),
downloadBlob: vi.fn(),
@@ -30,7 +32,6 @@ const mocks = vi.hoisted(() => ({
publishSkillMutationOptions: vi.fn(),
routerPush: vi.fn(),
routeSkillId: 'skill-1',
- restoreSkillMutationFn: vi.fn(),
saveDraftFileMutationFn: vi.fn(),
sendSkillAssistMessage: vi.fn(),
modelParameterRulesFetch: vi.fn<typeof fetch>(),
@@ -61,7 +62,6 @@ const mocks = vi.hoisted(() => ({
toastInfo: vi.fn(),
toastSuccess: vi.fn(),
uploadSkillFile: vi.fn(),
- versionDeleteMutationFn: vi.fn(),
versionPatchMutationFn: vi.fn(),
}))
@@ -179,6 +179,11 @@ vi.mock('@/next/link', () => ({
),
}))
+vi.mock('@/service/base', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('@/service/base')>()),
+ request: mocks.request,
+}))
+
vi.mock('@/next/navigation', () => ({
useParams: () => ({ skillId: mocks.routeSkillId }),
useRouter: () => ({
@@ -256,11 +261,7 @@ vi.mock('@/service/console', async (importOriginal) => {
queryOptions: mocks.skillReferencesQueryOptions,
},
},
- restore: {
- post: {
- mutationOptions: () => ({ mutationFn: mocks.restoreSkillMutationFn }),
- },
- },
+ restore: actual.consoleQuery.workspaces.current.skills.bySkillId.restore,
files: {
check: {
post: {
@@ -283,9 +284,9 @@ vi.mock('@/service/console', async (importOriginal) => {
patch: {
mutationOptions: () => ({ mutationFn: mocks.versionPatchMutationFn }),
},
- delete: {
- mutationOptions: () => ({ mutationFn: mocks.versionDeleteMutationFn }),
- },
+ delete:
+ actual.consoleQuery.workspaces.current.skills.bySkillId.versions.byVersionId
+ .delete,
},
},
},
@@ -688,6 +689,15 @@ export function getMocks() {
export function resetDetailPageFixture() {
vi.useRealTimers()
vi.resetAllMocks()
+ mocks.request.mockImplementation(async (_url, _init, options) => {
+ const req = options.request
+ const pathname = new URL(req.url).pathname
+ if (req.method === 'POST' && /\/skills\/[^/]+\/restore$/.test(pathname))
+ return Response.json(mocks.skillDetail)
+ if (req.method === 'DELETE' && /\/skills\/[^/]+\/versions\/[^/]+$/.test(pathname))
+ return Response.json({ result: 'success' })
+ throw new Error(`Unexpected request: ${req.method} ${pathname}`)
+ })
mocks.modelParameterRulesFetch.mockImplementation(async (input) => {
const url = input instanceof Request ? input.url : String(input)
if (!url.includes('/models/parameter-rules'))
@@ -830,9 +840,7 @@ export function resetDetailPageFixture() {
: mocks.skillDetail
return version
})
- mocks.restoreSkillMutationFn.mockResolvedValue({})
mocks.versionPatchMutationFn.mockResolvedValue({})
- mocks.versionDeleteMutationFn.mockResolvedValue({})
mocks.sendSkillAssistMessage.mockResolvedValue(undefined)
mocks.checkDraftFilesMutationFn.mockImplementation(
async (input: {
diff --git a/web/features/skills/detail/file-editor.tsx b/web/features/skills/detail/file-editor.tsx
index 42a73be9b99..f80d5dd033f 100644
--- a/web/features/skills/detail/file-editor.tsx
+++ b/web/features/skills/detail/file-editor.tsx
@@ -97,7 +97,7 @@ export function FileEditor({
onOpenBuilder,
onOpenVersions,
onPublish,
- onRestoreVersion,
+ onVersionRestored,
onExitVersion,
onCloseFile,
onDraftDetailChange,
@@ -122,7 +122,7 @@ export function FileEditor({
onOpenBuilder?: () => void
onOpenVersions: () => void
onPublish: () => void
- onRestoreVersion: () => void
+ onVersionRestored: () => void
onExitVersion: () => void
onCloseFile: (path: string) => void
onDraftDetailChange: (detail: SkillDetailResponse) => void
@@ -1513,8 +1513,7 @@ export function FileEditor({
{readonly && selectedVersion && (
<VersionActionBar
version={selectedVersion}
- restoring={publishing}
- onRestore={onRestoreVersion}
+ onRestored={onVersionRestored}
onExit={onExitVersion}
/>
)}
diff --git a/web/features/skills/detail/markdown-editor.tsx b/web/features/skills/detail/markdown-editor.tsx
index 0e22edc5a0c..02b4a7405a8 100644
--- a/web/features/skills/detail/markdown-editor.tsx
+++ b/web/features/skills/detail/markdown-editor.tsx
@@ -4,6 +4,7 @@ import type {
SkillFileResponse,
SkillVersionResponse,
} from '@dify/contracts/api/console/workspaces/types.gen'
+import type { AlertDialogActions } from '@langgenius/dify-ui/alert-dialog'
import type {
ChangeEvent,
ComponentPropsWithoutRef,
@@ -15,15 +16,19 @@ import type {
RefObject,
} from 'react'
import type { MarkdownProps } from '@/app/components/base/markdown'
+import { AlertDialog, AlertDialogTrigger } from '@langgenius/dify-ui/alert-dialog'
import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
+import { useMutation } from '@tanstack/react-query'
import { useLayoutEffect, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import Textarea from 'react-textarea-autosize'
import { visit } from 'unist-util-visit'
import { Markdown } from '@/app/components/base/markdown'
import useTimestamp from '@/hooks/use-timestamp'
+import { consoleQuery } from '@/service/console'
import styles from './markdown-editor.module.css'
+import { RestoreVersionDialogContent } from './restore-version-dialog-content'
import {
getMarkdownLiveEditorSelectionOffset,
getPathBaseName,
@@ -1145,15 +1150,22 @@ export function CsvTablePreview({ rows }: { rows: string[][] }) {
export function VersionActionBar({
onExit,
- onRestore,
- restoring,
+ onRestored,
version,
}: {
onExit: () => void
- onRestore: () => void
- restoring: boolean
+ onRestored: () => void
version: SkillVersionResponse
}) {
+ const actionsRef = useRef<AlertDialogActions>(null)
+ const restoreMutation = useMutation(
+ consoleQuery.workspaces.current.skills.bySkillId.restore.post.mutationOptions({
+ onSuccess: () => {
+ actionsRef.current?.close()
+ onRestored()
+ },
+ }),
+ )
const { t } = useTranslation(['skill'])
const { formatTime } = useTimestamp()
const publishedBy = version.published_by_name ?? version.published_by ?? '-'
@@ -1181,9 +1193,31 @@ export function VersionActionBar({
})}
</div>
</div>
- <Button variant="primary" className="h-9 px-5" loading={restoring} onClick={onRestore}>
- {t(($) => $['skillManagement.detail.restoreVersion'])}
- </Button>
+ <AlertDialog
+ actionsRef={actionsRef}
+ onOpenChange={(_open, details) => {
+ if (restoreMutation.isPending && details.reason !== 'imperative-action')
+ details.cancel()
+ }}
+ >
+ <AlertDialogTrigger
+ render={
+ <Button variant="primary" className="h-9 px-5" loading={restoreMutation.isPending} />
+ }
+ >
+ {t(($) => $['skillManagement.detail.restoreVersion'])}
+ </AlertDialogTrigger>
+ <RestoreVersionDialogContent
+ versionTitle={getSkillVersionTitle(version)}
+ isPending={restoreMutation.isPending}
+ onConfirm={() =>
+ restoreMutation.mutate({
+ params: { skill_id: version.skill_id },
+ body: { version_id: version.id, version_name: version.version_name },
+ })
+ }
+ />
+ </AlertDialog>
<Button variant="secondary" className="h-9 px-4" onClick={onExit}>
<span aria-hidden className="i-ri-history-line size-4" />
{t(($) => $['skillManagement.detail.exitVersions'])}
diff --git a/web/features/skills/detail/page.tsx b/web/features/skills/detail/page.tsx
index bf3c30a1684..2128a6e9123 100644
--- a/web/features/skills/detail/page.tsx
+++ b/web/features/skills/detail/page.tsx
@@ -25,13 +25,12 @@ import {
deriveSkillDetailFromDraftFiles,
findFileByPath,
getFirstTextFile,
- getSkillVersionTitle,
isDirectory,
setSkillDetailCache,
showSkillErrorToast,
} from './shared'
import { DetailSkeleton } from './shell'
-import { RestoreVersionDialog, VersionPanel } from './version-panel'
+import { VersionPanel } from './version-panel'
export function SkillDetailPage({ skillId }: { skillId: string }) {
const { t } = useTranslation(['skill'])
@@ -43,7 +42,6 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
const [rightPanelMode, setRightPanelMode] = useState<'builder' | 'hidden' | 'versions'>('builder')
const [sidebarCollapsed, setSidebarCollapsed] = useState(false)
const [selectedVersionId, setSelectedVersionId] = useState<string | null>()
- const [restoreVersionConfirmOpen, setRestoreVersionConfirmOpen] = useState(false)
const [draftDetailOverride, setDraftDetailOverride] = useState<SkillDetailResponse>()
const [hasLocalUnpublishedChanges, setHasLocalUnpublishedChanges] = useState(false)
const [saveConflictConfirm, setSaveConflictConfirm] = useState<
@@ -72,14 +70,6 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
},
},
)
- const skillDetailQueryKey = consoleQuery.workspaces.current.skills.bySkillId.get.key({
- type: 'query',
- input: {
- params: {
- skill_id: skillId,
- },
- },
- })
const detailQuery = useQuery(skillDetailQueryOptions)
const versionsQuery = useQuery(
consoleQuery.workspaces.current.skills.bySkillId.versions.get.queryOptions({
@@ -112,9 +102,6 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
context: { silent: true },
}),
)
- const restoreMutation = useMutation(
- consoleQuery.workspaces.current.skills.bySkillId.restore.post.mutationOptions(),
- )
const queriedDetail = detailQuery.data
const baseDetail = draftDetailOverride ?? queriedDetail
const detail = useMemo<SkillDetailResponse | undefined>(() => {
@@ -277,51 +264,12 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
},
)
}
- const restoreSelectedVersion = async () => {
- if (!selectedVersion || restoreMutation.isPending) return
-
- try {
- await restoreMutation.mutateAsync({
- params: {
- skill_id: skillId,
- },
- body: {
- version_id: selectedVersion.id,
- version_name: selectedVersion.version_name,
- },
- })
- await queryClient.invalidateQueries({ queryKey: skillDetailQueryKey })
- await queryClient.refetchQueries({ queryKey: skillDetailQueryKey, type: 'active' })
- void queryClient.invalidateQueries({
- queryKey: consoleQuery.workspaces.current.skills.bySkillId.versions.get.key({
- type: 'query',
- input: {
- params: {
- skill_id: skillId,
- },
- },
- }),
- })
- void queryClient.invalidateQueries({
- queryKey: consoleQuery.workspaces.current.skills.get.key({ type: 'query' }),
- })
- void queryClient.invalidateQueries({
- queryKey: consoleQuery.workspaces.current.skills.get.key({ type: 'infinite' }),
- })
- toast.success(t(($) => $['skillManagement.detail.restoreVersionSuccess']))
- setSelectedVersionId(null)
- setRightPanelMode('builder')
- setSelectedPath(undefined)
- setOpenFilePaths([])
- setPreviewFilePath(undefined)
- } catch {
- toast.error(t(($) => $['skillManagement.detail.restoreVersionFailed']))
- }
- }
-
- const handleRestoreSelectedVersion = () => {
- if (!selectedVersion || restoreMutation.isPending) return
- setRestoreVersionConfirmOpen(true)
+ const handleVersionRestored = () => {
+ setSelectedVersionId(null)
+ setRightPanelMode('builder')
+ setSelectedPath(undefined)
+ setOpenFilePaths([])
+ setPreviewFilePath(undefined)
}
const handleExitVersion = () => {
@@ -396,12 +344,12 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
}
onOpenVersions={handleOpenVersions}
onPublish={handlePublish}
- onRestoreVersion={handleRestoreSelectedVersion}
+ onVersionRestored={handleVersionRestored}
onExitVersion={handleExitVersion}
onSelectFile={handleOpenFile}
openFiles={openFiles}
previewFilePath={previewFilePath}
- publishing={activeVersionId ? restoreMutation.isPending : publishMutation.isPending}
+ publishing={publishMutation.isPending}
readonly={!!activeVersionId || !canEdit}
selectedPath={activeSelectedPath}
selectedVersion={selectedVersion}
@@ -459,17 +407,6 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
}}
/>
)}
- {selectedVersion && (
- <RestoreVersionDialog
- open={restoreVersionConfirmOpen}
- loading={restoreMutation.isPending}
- versionTitle={getSkillVersionTitle(selectedVersion)}
- onOpenChange={setRestoreVersionConfirmOpen}
- onConfirm={() => {
- void restoreSelectedVersion()
- }}
- />
- )}
</div>
</div>
)
diff --git a/web/features/skills/detail/restore-version-dialog-content.tsx b/web/features/skills/detail/restore-version-dialog-content.tsx
new file mode 100644
index 00000000000..0c4e2ecae0b
--- /dev/null
+++ b/web/features/skills/detail/restore-version-dialog-content.tsx
@@ -0,0 +1,43 @@
+import {
+ AlertDialogCancelButton,
+ AlertDialogConfirmButton,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogTitle,
+} from '@langgenius/dify-ui/alert-dialog'
+import { useTranslation } from 'react-i18next'
+
+export function RestoreVersionDialogContent({
+ isPending,
+ onConfirm,
+ versionTitle,
+}: {
+ isPending: boolean
+ onConfirm: () => void
+ versionTitle: string
+}) {
+ const { t } = useTranslation(['skill'])
+ const { t: tCommon } = useTranslation(['common'])
+
+ return (
+ <AlertDialogContent className="p-6">
+ <AlertDialogTitle className="title-2xl-semi-bold text-text-primary">
+ {t(($) => $['skillManagement.detail.restoreVersionConfirmTitle'])}
+ </AlertDialogTitle>
+ <AlertDialogDescription className="mt-2 system-md-regular whitespace-pre-line text-text-tertiary">
+ {t(($) => $['skillManagement.detail.restoreVersionConfirmDescription'], {
+ version: versionTitle,
+ })}
+ </AlertDialogDescription>
+ <AlertDialogFooter className="p-0 pt-6">
+ <AlertDialogCancelButton disabled={isPending}>
+ {tCommon(($) => $['operation.cancel'])}
+ </AlertDialogCancelButton>
+ <AlertDialogConfirmButton loading={isPending} onClick={onConfirm}>
+ {t(($) => $['skillManagement.detail.restoreVersion'])}
+ </AlertDialogConfirmButton>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ )
+}
diff --git a/web/features/skills/detail/version-panel.tsx b/web/features/skills/detail/version-panel.tsx
index 3564181607b..faa375fd784 100644
--- a/web/features/skills/detail/version-panel.tsx
+++ b/web/features/skills/detail/version-panel.tsx
@@ -1,6 +1,7 @@
'use client'
import type { SkillVersionResponse } from '@dify/contracts/api/console/workspaces/types.gen'
+import type { AlertDialogActions } from '@langgenius/dify-ui/alert-dialog'
import {
AlertDialog,
AlertDialogCancelButton,
@@ -32,55 +33,16 @@ import { Input } from '@langgenius/dify-ui/input'
import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'
import { Textarea } from '@langgenius/dify-ui/textarea'
import { useMutation, useQueryClient } from '@tanstack/react-query'
-import { useId, useState } from 'react'
+import { useId, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { toast } from '@/app/notifications'
import useTimestamp from '@/hooks/use-timestamp'
import { consoleQuery } from '@/service/console'
+import { RestoreVersionDialogContent } from './restore-version-dialog-content'
import { getSkillVersionTitle, invalidateSkillDetail } from './shared'
type VersionFilterValue = 'all' | 'onlyNamed'
-export function RestoreVersionDialog({
- loading,
- onConfirm,
- onOpenChange,
- open,
- versionTitle,
-}: {
- loading: boolean
- onConfirm: () => void
- onOpenChange: (open: boolean) => void
- open: boolean
- versionTitle: string
-}) {
- const { t } = useTranslation(['skill'])
- const { t: tCommon } = useTranslation(['common'])
-
- return (
- <AlertDialog open={open} onOpenChange={onOpenChange}>
- <AlertDialogContent className="p-6">
- <AlertDialogTitle className="title-2xl-semi-bold text-text-primary">
- {t(($) => $['skillManagement.detail.restoreVersionConfirmTitle'])}
- </AlertDialogTitle>
- <AlertDialogDescription className="mt-2 system-md-regular whitespace-pre-line text-text-tertiary">
- {t(($) => $['skillManagement.detail.restoreVersionConfirmDescription'], {
- version: versionTitle,
- })}
- </AlertDialogDescription>
- <AlertDialogFooter className="p-0 pt-6">
- <AlertDialogCancelButton disabled={loading}>
- {tCommon(($) => $['operation.cancel'])}
- </AlertDialogCancelButton>
- <AlertDialogConfirmButton loading={loading} onClick={onConfirm}>
- {t(($) => $['skillManagement.detail.restoreVersion'])}
- </AlertDialogConfirmButton>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
- )
-}
-
function VersionTimelineDot({
isActive,
isFirst,
@@ -233,16 +195,28 @@ function VersionRow({
const [renameOpen, setRenameOpen] = useState(false)
const [deleteOpen, setDeleteOpen] = useState(false)
const [restoreOpen, setRestoreOpen] = useState(false)
+ const restoreActionsRef = useRef<AlertDialogActions>(null)
+ const deleteActionsRef = useRef<AlertDialogActions>(null)
const [versionName, setVersionName] = useState(version.version_name)
const [publishNote, setPublishNote] = useState(version.publish_note)
const renameMutation = useMutation(
consoleQuery.workspaces.current.skills.bySkillId.versions.byVersionId.patch.mutationOptions(),
)
const restoreMutation = useMutation(
- consoleQuery.workspaces.current.skills.bySkillId.restore.post.mutationOptions(),
+ consoleQuery.workspaces.current.skills.bySkillId.restore.post.mutationOptions({
+ onSuccess: () => {
+ restoreActionsRef.current?.close()
+ onSelect(null)
+ },
+ }),
)
const deleteMutation = useMutation(
- consoleQuery.workspaces.current.skills.bySkillId.versions.byVersionId.delete.mutationOptions(),
+ consoleQuery.workspaces.current.skills.bySkillId.versions.byVersionId.delete.mutationOptions({
+ onSuccess: () => {
+ deleteActionsRef.current?.close()
+ onSelect(null)
+ },
+ }),
)
const publishedBy = version.published_by_name ?? version.published_by ?? '-'
const versionTitle = getSkillVersionTitle(version)
@@ -279,49 +253,14 @@ function VersionRow({
}
const handleRestore = () => {
- restoreMutation.mutate(
- {
- params: {
- skill_id: skillId,
- },
- body: {
- version_id: version.id,
- version_name: version.version_name,
- },
- },
- {
- onSuccess: () => {
- toast.success(t(($) => $['skillManagement.detail.restoreVersionSuccess']))
- setRestoreOpen(false)
- invalidateVersions()
- onSelect(null)
- },
- onError: () => {
- toast.error(t(($) => $['skillManagement.detail.restoreVersionFailed']))
- },
- },
- )
+ restoreMutation.mutate({
+ params: { skill_id: skillId },
+ body: { version_id: version.id, version_name: version.version_name },
+ })
}
const handleDelete = () => {
- deleteMutation.mutate(
- {
- params: {
- skill_id: skillId,
- version_id: version.id,
- },
- },
- {
- onSuccess: () => {
- setDeleteOpen(false)
- invalidateVersions()
- onSelect(null)
- },
- onError: () => {
- toast.error(t(($) => $['skillManagement.detail.deleteVersionFailed']))
- },
- },
- )
+ deleteMutation.mutate({ params: { skill_id: skillId, version_id: version.id } })
}
return (
@@ -459,14 +398,34 @@ function VersionRow({
</div>
</DialogContent>
</Dialog>
- <RestoreVersionDialog
+ <AlertDialog
+ actionsRef={restoreActionsRef}
open={restoreOpen}
- loading={restoreMutation.isPending}
- versionTitle={versionTitle}
- onOpenChange={setRestoreOpen}
- onConfirm={handleRestore}
- />
- <AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
+ onOpenChange={(open, details) => {
+ if (!open && restoreMutation.isPending && details.reason !== 'imperative-action') {
+ details.cancel()
+ return
+ }
+ setRestoreOpen(open)
+ }}
+ >
+ <RestoreVersionDialogContent
+ isPending={restoreMutation.isPending}
+ versionTitle={versionTitle}
+ onConfirm={handleRestore}
+ />
+ </AlertDialog>
+ <AlertDialog
+ actionsRef={deleteActionsRef}
+ open={deleteOpen}
+ onOpenChange={(open, details) => {
+ if (!open && deleteMutation.isPending && details.reason !== 'imperative-action') {
+ details.cancel()
+ return
+ }
+ setDeleteOpen(open)
+ }}
+ >
<AlertDialogContent className="p-6">
<AlertDialogTitle className="title-2xl-semi-bold text-text-primary">
{t(($) => $['skillManagement.detail.deleteVersionConfirm'])}
diff --git a/web/i18n/locales/ar-TN/skill.json b/web/i18n/locales/ar-TN/skill.json
index c3cb6d3a477..4d71530b4a6 100644
--- a/web/i18n/locales/ar-TN/skill.json
+++ b/web/i18n/locales/ar-TN/skill.json
@@ -70,7 +70,6 @@
"skillManagement.detail.deleteFileConfirm": "هل تريد حذف هذا الملف؟",
"skillManagement.detail.deleteFileSuccess": "تم حذف الملف.",
"skillManagement.detail.deleteVersionConfirm": "هل تريد حذف هذا الإصدار؟",
- "skillManagement.detail.deleteVersionFailed": "فشل في حذف الإصدار.",
"skillManagement.detail.downloadFile": "تنزيل الملف",
"skillManagement.detail.draft": "مسودة",
"skillManagement.detail.editVersionInfo": "تعديل معلومات الإصدار",
@@ -134,8 +133,6 @@
"skillManagement.detail.restoreVersion": "استعادة",
"skillManagement.detail.restoreVersionConfirmDescription": "سيؤدي هذا إلى استبدال المسودة الحالية بالملفات من \"{{version}}\". لن يقوم بنشر Skill أو إنشاء إصدار جديد.",
"skillManagement.detail.restoreVersionConfirmTitle": "استعادة هذا الإصدار؟",
- "skillManagement.detail.restoreVersionFailed": "فشل في استعادة الإصدار.",
- "skillManagement.detail.restoreVersionSuccess": "تمت استعادة الإصدار للمسودة.",
"skillManagement.detail.saveConflictConfirmDescription": "تم تحديث هذه المهارة في مكان آخر. قم بتحميل أحدث مسودة لمواصلة التحرير. سيتم تجاهل تغييراتك الحالية.",
"skillManagement.detail.saveConflictConfirmTitle": "هل تريد تحميل أحدث مسودة؟",
"skillManagement.detail.saveConflictReload": "تحميل أحدث مسودة",
diff --git a/web/i18n/locales/az-AZ/skill.json b/web/i18n/locales/az-AZ/skill.json
index 0b59873c1fd..0a57011c7f6 100644
--- a/web/i18n/locales/az-AZ/skill.json
+++ b/web/i18n/locales/az-AZ/skill.json
@@ -66,7 +66,6 @@
"skillManagement.detail.deleteFileConfirm": "Bu fayl silinsin?",
"skillManagement.detail.deleteFileSuccess": "Fayl silindi.",
"skillManagement.detail.deleteVersionConfirm": "Bu versiya silinsin?",
- "skillManagement.detail.deleteVersionFailed": "Versiyanı silmək mümkün olmadı.",
"skillManagement.detail.downloadFile": "Faylı yüklə",
"skillManagement.detail.draft": "Qaralama",
"skillManagement.detail.editVersionInfo": "Versiya məlumatlarını redaktə et",
@@ -118,8 +117,6 @@
"skillManagement.detail.restoreVersion": "Bərpa et",
"skillManagement.detail.restoreVersionConfirmDescription": "Bu, cari qaralamanı \"{{version}}\" versiyasındakı fayllarla əvəz edəcək. Bacarığı dərc etməyəcək və yeni versiya yaratmayacaq.",
"skillManagement.detail.restoreVersionConfirmTitle": "Bu versiya bərpa edilsin?",
- "skillManagement.detail.restoreVersionFailed": "Versiyanı bərpa etmək mümkün olmadı.",
- "skillManagement.detail.restoreVersionSuccess": "Versiya qaralama kimi bərpa edildi.",
"skillManagement.detail.saveConflictConfirmDescription": "Bu bacarıq başqa yerdə yenilənib. Redaktəyə davam etmək üçün ən son qaralamanı yükləyin. Cari dəyişiklikləriniz ləğv ediləcək.",
"skillManagement.detail.saveConflictConfirmTitle": "Ən son qaralama yüklənsin?",
"skillManagement.detail.saveConflictReload": "Ən son qaralamanı yüklə",
diff --git a/web/i18n/locales/de-DE/skill.json b/web/i18n/locales/de-DE/skill.json
index a4eb6639cd7..88e1bf67ccf 100644
--- a/web/i18n/locales/de-DE/skill.json
+++ b/web/i18n/locales/de-DE/skill.json
@@ -66,7 +66,6 @@
"skillManagement.detail.deleteFileConfirm": "Diese Datei löschen?",
"skillManagement.detail.deleteFileSuccess": "Datei gelöscht.",
"skillManagement.detail.deleteVersionConfirm": "Diese Version löschen?",
- "skillManagement.detail.deleteVersionFailed": "Die Version konnte nicht gelöscht werden.",
"skillManagement.detail.downloadFile": "Datei herunterladen",
"skillManagement.detail.draft": "Entwurf",
"skillManagement.detail.editVersionInfo": "Versionsinformationen bearbeiten",
@@ -118,8 +117,6 @@
"skillManagement.detail.restoreVersion": "Wiederherstellen",
"skillManagement.detail.restoreVersionConfirmDescription": "Dadurch wird der aktuelle Entwurf durch die Dateien von „{{version}}“ ersetzt. Es wird weder Skill veröffentlicht noch eine neue Version erstellt.",
"skillManagement.detail.restoreVersionConfirmTitle": "Diese Version wiederherstellen?",
- "skillManagement.detail.restoreVersionFailed": "Die Version konnte nicht wiederhergestellt werden.",
- "skillManagement.detail.restoreVersionSuccess": "Version als Entwurf wiederhergestellt.",
"skillManagement.detail.saveConflictConfirmDescription": "Diese Fertigkeit wurde an anderer Stelle aktualisiert. Laden Sie den neuesten Entwurf, um mit der Bearbeitung fortzufahren. Ihre aktuellen Änderungen werden verworfen.",
"skillManagement.detail.saveConflictConfirmTitle": "Den neuesten Entwurf laden?",
"skillManagement.detail.saveConflictReload": "Laden Sie den neuesten Entwurf",
diff --git a/web/i18n/locales/en-US/skill.json b/web/i18n/locales/en-US/skill.json
index 752b0aa2d2d..cd1e2e1e77e 100644
--- a/web/i18n/locales/en-US/skill.json
+++ b/web/i18n/locales/en-US/skill.json
@@ -66,7 +66,6 @@
"skillManagement.detail.deleteFileConfirm": "Delete this file?",
"skillManagement.detail.deleteFileSuccess": "File deleted.",
"skillManagement.detail.deleteVersionConfirm": "Delete this version?",
- "skillManagement.detail.deleteVersionFailed": "Failed to delete version.",
"skillManagement.detail.downloadFile": "Download file",
"skillManagement.detail.draft": "Draft",
"skillManagement.detail.editVersionInfo": "Edit version info",
@@ -118,8 +117,6 @@
"skillManagement.detail.restoreVersion": "Restore",
"skillManagement.detail.restoreVersionConfirmDescription": "This will replace the current draft with the files from \"{{version}}\". It will not publish the Skill or create a new version.",
"skillManagement.detail.restoreVersionConfirmTitle": "Restore this version?",
- "skillManagement.detail.restoreVersionFailed": "Failed to restore version.",
- "skillManagement.detail.restoreVersionSuccess": "Version restored to draft.",
"skillManagement.detail.saveConflictConfirmDescription": "This skill was updated elsewhere. Load the latest draft to continue editing. Your current changes will be discarded.",
"skillManagement.detail.saveConflictConfirmTitle": "Load the latest draft?",
"skillManagement.detail.saveConflictReload": "Load latest draft",
diff --git a/web/i18n/locales/es-ES/skill.json b/web/i18n/locales/es-ES/skill.json
index daedee586fc..8af913bbeb4 100644
--- a/web/i18n/locales/es-ES/skill.json
+++ b/web/i18n/locales/es-ES/skill.json
@@ -67,7 +67,6 @@
"skillManagement.detail.deleteFileConfirm": "¿Eliminar este archivo?",
"skillManagement.detail.deleteFileSuccess": "Archivo eliminado.",
"skillManagement.detail.deleteVersionConfirm": "¿Eliminar esta versión?",
- "skillManagement.detail.deleteVersionFailed": "No se pudo eliminar la versión.",
"skillManagement.detail.downloadFile": "Descargar archivo",
"skillManagement.detail.draft": "Borrador",
"skillManagement.detail.editVersionInfo": "Editar información de la versión",
@@ -122,8 +121,6 @@
"skillManagement.detail.restoreVersion": "Restaurar",
"skillManagement.detail.restoreVersionConfirmDescription": "Esto reemplazará el borrador actual con los archivos de \"{{version}}\". No publicará el Skill ni creará una nueva versión.",
"skillManagement.detail.restoreVersionConfirmTitle": "¿Restaurar esta versión?",
- "skillManagement.detail.restoreVersionFailed": "No se pudo restaurar la versión.",
- "skillManagement.detail.restoreVersionSuccess": "Versión restaurada al borrador.",
"skillManagement.detail.saveConflictConfirmDescription": "Esta habilidad se actualizó en otro lugar. Cargue el último borrador para continuar editando. Sus cambios actuales serán descartados.",
"skillManagement.detail.saveConflictConfirmTitle": "¿Cargar el último borrador?",
"skillManagement.detail.saveConflictReload": "Cargar el último borrador",
diff --git a/web/i18n/locales/fa-IR/skill.json b/web/i18n/locales/fa-IR/skill.json
index 9632eb0374b..9ec211f1785 100644
--- a/web/i18n/locales/fa-IR/skill.json
+++ b/web/i18n/locales/fa-IR/skill.json
@@ -66,7 +66,6 @@
"skillManagement.detail.deleteFileConfirm": "این فایل حذف شود؟",
"skillManagement.detail.deleteFileSuccess": "فایل حذف شد",
"skillManagement.detail.deleteVersionConfirm": "این نسخه حذف شود؟",
- "skillManagement.detail.deleteVersionFailed": "نسخه حذف نشد.",
"skillManagement.detail.downloadFile": "دانلود فایل",
"skillManagement.detail.draft": "پیش‌نویس",
"skillManagement.detail.editVersionInfo": "ویرایش اطلاعات نسخه",
@@ -118,8 +117,6 @@
"skillManagement.detail.restoreVersion": "بازیابی",
"skillManagement.detail.restoreVersionConfirmDescription": "این کار جایگزین پیش‌نویس فعلی با فایل‌های «{{version}}» می‌شود. Skill را منتشر نمی کند یا نسخه جدیدی ایجاد نمی کند.",
"skillManagement.detail.restoreVersionConfirmTitle": "بازیابی این نسخه؟",
- "skillManagement.detail.restoreVersionFailed": "بازیابی نسخه انجام نشد.",
- "skillManagement.detail.restoreVersionSuccess": "نسخه به پیش نویس بازیابی شد.",
"skillManagement.detail.saveConflictConfirmDescription": "این مهارت در جای دیگری به روز شد. برای ادامه ویرایش، آخرین پیش نویس را بارگیری کنید. تغییرات فعلی شما نادیده گرفته خواهد شد.",
"skillManagement.detail.saveConflictConfirmTitle": "آخرین پیش نویس بارگیری شود؟",
"skillManagement.detail.saveConflictReload": "آخرین پیش نویس را بارگیری کنید",
diff --git a/web/i18n/locales/fr-FR/skill.json b/web/i18n/locales/fr-FR/skill.json
index 3c8be166273..1ad10972d84 100644
--- a/web/i18n/locales/fr-FR/skill.json
+++ b/web/i18n/locales/fr-FR/skill.json
@@ -67,7 +67,6 @@
"skillManagement.detail.deleteFileConfirm": "Supprimer ce fichier ?",
"skillManagement.detail.deleteFileSuccess": "Fichier supprimé.",
"skillManagement.detail.deleteVersionConfirm": "Supprimer cette version ?",
- "skillManagement.detail.deleteVersionFailed": "Échec de la suppression de la version.",
"skillManagement.detail.downloadFile": "Télécharger le fichier",
"skillManagement.detail.draft": "Brouillon",
"skillManagement.detail.editVersionInfo": "Modifier les informations de version",
@@ -122,8 +121,6 @@
"skillManagement.detail.restoreVersion": "Restaurer",
"skillManagement.detail.restoreVersionConfirmDescription": "Cela remplacera le brouillon actuel par les fichiers de \"{{version}}\". Il ne publiera pas le Skill ni ne créera de nouvelle version.",
"skillManagement.detail.restoreVersionConfirmTitle": "Restaurer cette version ?",
- "skillManagement.detail.restoreVersionFailed": "Échec de la restauration de la version.",
- "skillManagement.detail.restoreVersionSuccess": "Version restaurée au brouillon.",
"skillManagement.detail.saveConflictConfirmDescription": "Cette compétence a été mise à jour ailleurs. Chargez le dernier brouillon pour continuer l'édition. Vos modifications actuelles seront ignorées.",
"skillManagement.detail.saveConflictConfirmTitle": "Charger le dernier brouillon ?",
"skillManagement.detail.saveConflictReload": "Charger le dernier brouillon",
diff --git a/web/i18n/locales/hi-IN/skill.json b/web/i18n/locales/hi-IN/skill.json
index 55b38b17d97..316bd5a0476 100644
--- a/web/i18n/locales/hi-IN/skill.json
+++ b/web/i18n/locales/hi-IN/skill.json
@@ -66,7 +66,6 @@
"skillManagement.detail.deleteFileConfirm": "यह फ़ाइल हटाएं?",
"skillManagement.detail.deleteFileSuccess": "फ़ाइल हटा दी गई.",
"skillManagement.detail.deleteVersionConfirm": "यह संस्करण हटाएं?",
- "skillManagement.detail.deleteVersionFailed": "संस्करण हटाने में विफल.",
"skillManagement.detail.downloadFile": "डाउनलोड फ़ाइल",
"skillManagement.detail.draft": "ड्राफ्ट",
"skillManagement.detail.editVersionInfo": "संस्करण की जानकारी संपादित करें",
@@ -118,8 +117,6 @@
"skillManagement.detail.restoreVersion": "रीस्टोर करें",
"skillManagement.detail.restoreVersionConfirmDescription": "यह मौजूदा ड्राफ्ट को \"{{version}}\" की फाइलों से बदल देगा। यह Skill को प्रकाशित नहीं करेगा या कोई नया संस्करण नहीं बनाएगा।",
"skillManagement.detail.restoreVersionConfirmTitle": "इस संस्करण को पुनर्स्थापित करें?",
- "skillManagement.detail.restoreVersionFailed": "संस्करण पुनर्स्थापित करने में विफल.",
- "skillManagement.detail.restoreVersionSuccess": "संस्करण को ड्राफ्ट में पुनर्स्थापित किया गया।",
"skillManagement.detail.saveConflictConfirmDescription": "यह कौशल अन्यत्र अद्यतन किया गया था. संपादन जारी रखने के लिए नवीनतम ड्राफ्ट लोड करें। आपके वर्तमान परिवर्तन खारिज कर दिए जाएंगे.",
"skillManagement.detail.saveConflictConfirmTitle": "नवीनतम ड्राफ्ट लोड करें?",
"skillManagement.detail.saveConflictReload": "नवीनतम ड्राफ्ट लोड करें",
diff --git a/web/i18n/locales/id-ID/skill.json b/web/i18n/locales/id-ID/skill.json
index d89b3141c2a..e0d565c8026 100644
--- a/web/i18n/locales/id-ID/skill.json
+++ b/web/i18n/locales/id-ID/skill.json
@@ -66,7 +66,6 @@
"skillManagement.detail.deleteFileConfirm": "Hapus berkas ini?",
"skillManagement.detail.deleteFileSuccess": "Berkas dihapus.",
"skillManagement.detail.deleteVersionConfirm": "Hapus versi ini?",
- "skillManagement.detail.deleteVersionFailed": "Gagal menghapus versi.",
"skillManagement.detail.downloadFile": "Unduh berkas",
"skillManagement.detail.draft": "Draf",
"skillManagement.detail.editVersionInfo": "Mengedit info versi",
@@ -118,8 +117,6 @@
"skillManagement.detail.restoreVersion": "Pulihkan",
"skillManagement.detail.restoreVersionConfirmDescription": "Ini akan mengganti draf saat ini dengan file dari \"{{version}}\". Itu tidak akan mempublikasikan Skill atau membuat versi baru.",
"skillManagement.detail.restoreVersionConfirmTitle": "Pulihkan versi ini?",
- "skillManagement.detail.restoreVersionFailed": "Gagal memulihkan versi.",
- "skillManagement.detail.restoreVersionSuccess": "Versi dikembalikan ke draf.",
"skillManagement.detail.saveConflictConfirmDescription": "Keterampilan ini telah diperbarui di tempat lain. Muat draf terbaru untuk melanjutkan pengeditan. Perubahan Anda saat ini akan dibuang.",
"skillManagement.detail.saveConflictConfirmTitle": "Muat draf terbaru?",
"skillManagement.detail.saveConflictReload": "Muat draf terbaru",
diff --git a/web/i18n/locales/it-IT/skill.json b/web/i18n/locales/it-IT/skill.json
index 211a1ff5087..1627a077c44 100644
--- a/web/i18n/locales/it-IT/skill.json
+++ b/web/i18n/locales/it-IT/skill.json
@@ -67,7 +67,6 @@
"skillManagement.detail.deleteFileConfirm": "Eliminare questo file?",
"skillManagement.detail.deleteFileSuccess": "File eliminato.",
"skillManagement.detail.deleteVersionConfirm": "Eliminare questa versione?",
- "skillManagement.detail.deleteVersionFailed": "Impossibile eliminare la versione.",
"skillManagement.detail.downloadFile": "Scarica file",
"skillManagement.detail.draft": "Bozza",
"skillManagement.detail.editVersionInfo": "Modifica le informazioni sulla versione",
@@ -122,8 +121,6 @@
"skillManagement.detail.restoreVersion": "Ripristina",
"skillManagement.detail.restoreVersionConfirmDescription": "Questo sostituirà la bozza corrente con i file di \"{{version}}\". Non pubblicherà lo Skill né creerà una nuova versione.",
"skillManagement.detail.restoreVersionConfirmTitle": "Ripristinare questa versione?",
- "skillManagement.detail.restoreVersionFailed": "Impossibile ripristinare la versione.",
- "skillManagement.detail.restoreVersionSuccess": "Versione ripristinata alla bozza.",
"skillManagement.detail.saveConflictConfirmDescription": "Questa abilità è stata aggiornata altrove. Carica l'ultima bozza per continuare a modificare. Le modifiche attuali verranno annullate.",
"skillManagement.detail.saveConflictConfirmTitle": "Caricare l'ultima bozza?",
"skillManagement.detail.saveConflictReload": "Carica l'ultima bozza",
diff --git a/web/i18n/locales/ja-JP/skill.json b/web/i18n/locales/ja-JP/skill.json
index 41f5b9fad5c..a3708e12db0 100644
--- a/web/i18n/locales/ja-JP/skill.json
+++ b/web/i18n/locales/ja-JP/skill.json
@@ -66,7 +66,6 @@
"skillManagement.detail.deleteFileConfirm": "このファイルを削除しますか?",
"skillManagement.detail.deleteFileSuccess": "ファイルが削除されました。",
"skillManagement.detail.deleteVersionConfirm": "このバージョンを削除しますか?",
- "skillManagement.detail.deleteVersionFailed": "",
"skillManagement.detail.downloadFile": "ファイルをダウンロードする",
"skillManagement.detail.draft": "ドラフト",
"skillManagement.detail.editVersionInfo": "バージョン情報を編集",
@@ -118,8 +117,6 @@
"skillManagement.detail.restoreVersion": "復元",
"skillManagement.detail.restoreVersionConfirmDescription": "これにより、現在のドラフトが「{{version}}」のファイルに置き換えられます。 Skill を公開したり、新しいバージョンを作成したりすることはありません。",
"skillManagement.detail.restoreVersionConfirmTitle": "このバージョンを復元しますか?",
- "skillManagement.detail.restoreVersionFailed": "バージョンの復元に失敗しました。",
- "skillManagement.detail.restoreVersionSuccess": "バージョンはドラフトに復元されました。",
"skillManagement.detail.saveConflictConfirmDescription": "このスキルは別の場所で更新されました。編集を続けるには、最新のドラフトを読み込んでください。現在の変更内容は破棄されます。",
"skillManagement.detail.saveConflictConfirmTitle": "最新のドラフトをロードしますか?",
"skillManagement.detail.saveConflictReload": "最新のドラフトをロードする",
diff --git a/web/i18n/locales/ko-KR/skill.json b/web/i18n/locales/ko-KR/skill.json
index 6fd70a3d831..545c2086dba 100644
--- a/web/i18n/locales/ko-KR/skill.json
+++ b/web/i18n/locales/ko-KR/skill.json
@@ -66,7 +66,6 @@
"skillManagement.detail.deleteFileConfirm": "이 파일을 삭제하시겠습니까?",
"skillManagement.detail.deleteFileSuccess": "파일이 삭제되었습니다.",
"skillManagement.detail.deleteVersionConfirm": "이 버전을 삭제하시겠습니까?",
- "skillManagement.detail.deleteVersionFailed": "버전을 삭제하지 못했습니다.",
"skillManagement.detail.downloadFile": "파일 다운로드",
"skillManagement.detail.draft": "초안",
"skillManagement.detail.editVersionInfo": "버전 정보 편집",
@@ -118,8 +117,6 @@
"skillManagement.detail.restoreVersion": "복원",
"skillManagement.detail.restoreVersionConfirmDescription": "그러면 현재 초안이 \"{{version}}\"의 파일로 대체됩니다. Skill를 게시하거나 새 버전을 생성하지 않습니다.",
"skillManagement.detail.restoreVersionConfirmTitle": "이 버전을 복원하시겠습니까?",
- "skillManagement.detail.restoreVersionFailed": "버전을 복원하지 못했습니다.",
- "skillManagement.detail.restoreVersionSuccess": "버전이 초안으로 복원되었습니다.",
"skillManagement.detail.saveConflictConfirmDescription": "이 스킬은 다른 곳에서 업데이트되었습니다. 계속 편집하려면 최신 초안을 로드하세요. 현재 변경사항이 삭제됩니다.",
"skillManagement.detail.saveConflictConfirmTitle": "최신 초안을 로드하시겠습니까?",
"skillManagement.detail.saveConflictReload": "최신 초안 로드",
diff --git a/web/i18n/locales/lo-LA/skill.json b/web/i18n/locales/lo-LA/skill.json
index ec554b60af1..5a7da38cf0e 100644
--- a/web/i18n/locales/lo-LA/skill.json
+++ b/web/i18n/locales/lo-LA/skill.json
@@ -66,7 +66,6 @@
"skillManagement.detail.deleteFileConfirm": "ລຶບໄຟລ໌ນີ້ບໍ?",
"skillManagement.detail.deleteFileSuccess": "ລຶບໄຟລ໌ແລ້ວ.",
"skillManagement.detail.deleteVersionConfirm": "ລຶບເວີຊັນນີ້ບໍ?",
- "skillManagement.detail.deleteVersionFailed": "ລົ້ມເຫລວໃນການລຶບເວີຊັນ.",
"skillManagement.detail.downloadFile": "ດາວໂຫຼດໄຟລ໌",
"skillManagement.detail.draft": "ສະບັບຮ່າງ",
"skillManagement.detail.editVersionInfo": "ແກ້ໄຂຂໍ້ມູນເວີຊັນ",
@@ -118,8 +117,6 @@
"skillManagement.detail.restoreVersion": "ຄືນຄ່າ (Restore)",
"skillManagement.detail.restoreVersionConfirmDescription": "ນີ້ຈະປ່ຽນແທນສະບັບຮ່າງປະຈຸບັນດ້ວຍໄຟລ໌ຈາກ \"{{version}}\". ມັນຈະບໍ່ເຜີຍແຜ່ Skill ຫຼືສ້າງສະບັບໃຫມ່.",
"skillManagement.detail.restoreVersionConfirmTitle": "ກູ້ຄືນເວີຊັນນີ້ບໍ?",
- "skillManagement.detail.restoreVersionFailed": "ກູ້ເວີຊັນຄືນມາບໍ່ສຳເລັດ.",
- "skillManagement.detail.restoreVersionSuccess": "ກູ້ເວີຊັນເປັນສະບັບຮ່າງແລ້ວ.",
"skillManagement.detail.saveConflictConfirmDescription": "ທັກສະນີ້ໄດ້ຖືກປັບປຸງຢູ່ບ່ອນອື່ນ. ໂຫຼດສະບັບຮ່າງຫຼ້າສຸດເພື່ອສືບຕໍ່ການແກ້ໄຂ. ການປ່ຽນແປງປັດຈຸບັນຂອງເຈົ້າຈະຖືກຍົກເລີກ.",
"skillManagement.detail.saveConflictConfirmTitle": "ໂຫຼດສະບັບຮ່າງຫຼ້າສຸດບໍ?",
"skillManagement.detail.saveConflictReload": "ໂຫຼດສະບັບຮ່າງຫຼ້າສຸດ",
diff --git a/web/i18n/locales/nl-NL/skill.json b/web/i18n/locales/nl-NL/skill.json
index bb2cab82467..be43b5b70fc 100644
--- a/web/i18n/locales/nl-NL/skill.json
+++ b/web/i18n/locales/nl-NL/skill.json
@@ -66,7 +66,6 @@
"skillManagement.detail.deleteFileConfirm": "Dit bestand verwijderen?",
"skillManagement.detail.deleteFileSuccess": "Bestand verwijderd.",
"skillManagement.detail.deleteVersionConfirm": "Deze versie verwijderen?",
- "skillManagement.detail.deleteVersionFailed": "Kan de versie niet verwijderen.",
"skillManagement.detail.downloadFile": "Bestand downloaden",
"skillManagement.detail.draft": "Concept",
"skillManagement.detail.editVersionInfo": "Versie-informatie bewerken",
@@ -118,8 +117,6 @@
"skillManagement.detail.restoreVersion": "Herstellen",
"skillManagement.detail.restoreVersionConfirmDescription": "Hierdoor wordt het huidige concept vervangen door de bestanden uit \"{{version}}\". Het zal de Skill niet publiceren of een nieuwe versie maken.",
"skillManagement.detail.restoreVersionConfirmTitle": "Deze versie herstellen?",
- "skillManagement.detail.restoreVersionFailed": "Kan de versie niet herstellen.",
- "skillManagement.detail.restoreVersionSuccess": "Versie hersteld naar concept.",
"skillManagement.detail.saveConflictConfirmDescription": "Deze vaardigheid is elders bijgewerkt. Laad het nieuwste concept om door te gaan met bewerken. Uw huidige wijzigingen worden verwijderd.",
"skillManagement.detail.saveConflictConfirmTitle": "Het laatste concept laden?",
"skillManagement.detail.saveConflictReload": "Laad het laatste concept",
diff --git a/web/i18n/locales/pl-PL/skill.json b/web/i18n/locales/pl-PL/skill.json
index c92aefc3892..fd874c6a410 100644
--- a/web/i18n/locales/pl-PL/skill.json
+++ b/web/i18n/locales/pl-PL/skill.json
@@ -68,7 +68,6 @@
"skillManagement.detail.deleteFileConfirm": "Usunąć ten plik?",
"skillManagement.detail.deleteFileSuccess": "Plik usunięty.",
"skillManagement.detail.deleteVersionConfirm": "Usunąć tę wersję?",
- "skillManagement.detail.deleteVersionFailed": "Nie udało się usunąć wersji.",
"skillManagement.detail.downloadFile": "Pobierz plik",
"skillManagement.detail.draft": "Wersja robocza",
"skillManagement.detail.editVersionInfo": "Edytuj informacje o wersji",
@@ -126,8 +125,6 @@
"skillManagement.detail.restoreVersion": "Przywróć",
"skillManagement.detail.restoreVersionConfirmDescription": "Spowoduje to zastąpienie bieżącej wersji roboczej plikami z „{{version}}”. Nie opublikuje Skill ani nie utworzy nowej wersji.",
"skillManagement.detail.restoreVersionConfirmTitle": "Przywrócić tę wersję?",
- "skillManagement.detail.restoreVersionFailed": "Nie udało się przywrócić wersji.",
- "skillManagement.detail.restoreVersionSuccess": "Wersja przywrócona do wersji roboczej.",
"skillManagement.detail.saveConflictConfirmDescription": "Ta umiejętność została zaktualizowana w innym miejscu. Załaduj najnowszą wersję roboczą, aby kontynuować edycję. Twoje obecne zmiany zostaną odrzucone.",
"skillManagement.detail.saveConflictConfirmTitle": "Załadować najnowszą wersję roboczą?",
"skillManagement.detail.saveConflictReload": "Załaduj najnowszą wersję roboczą",
diff --git a/web/i18n/locales/pt-BR/skill.json b/web/i18n/locales/pt-BR/skill.json
index a64762d346b..186f5ba8478 100644
--- a/web/i18n/locales/pt-BR/skill.json
+++ b/web/i18n/locales/pt-BR/skill.json
@@ -67,7 +67,6 @@
"skillManagement.detail.deleteFileConfirm": "Excluir este arquivo?",
"skillManagement.detail.deleteFileSuccess": "Arquivo excluído.",
"skillManagement.detail.deleteVersionConfirm": "Excluir esta versão?",
- "skillManagement.detail.deleteVersionFailed": "Falha ao excluir a versão.",
"skillManagement.detail.downloadFile": "Baixar arquivo",
"skillManagement.detail.draft": "Rascunho",
"skillManagement.detail.editVersionInfo": "Editar informações da versão",
@@ -122,8 +121,6 @@
"skillManagement.detail.restoreVersion": "Restaurar",
"skillManagement.detail.restoreVersionConfirmDescription": "Isso substituirá o rascunho atual pelos arquivos de \"{{version}}\". Não publicará o Skill nem criará uma nova versão.",
"skillManagement.detail.restoreVersionConfirmTitle": "Restaurar esta versão?",
- "skillManagement.detail.restoreVersionFailed": "Falha ao restaurar a versão.",
- "skillManagement.detail.restoreVersionSuccess": "Versão restaurada para rascunho.",
"skillManagement.detail.saveConflictConfirmDescription": "Esta habilidade foi atualizada em outro lugar. Carregue o rascunho mais recente para continuar editando. Suas alterações atuais serão descartadas.",
"skillManagement.detail.saveConflictConfirmTitle": "Carregar o rascunho mais recente?",
"skillManagement.detail.saveConflictReload": "Carregar rascunho mais recente",
diff --git a/web/i18n/locales/ro-RO/skill.json b/web/i18n/locales/ro-RO/skill.json
index bee3d4793fb..3beef671128 100644
--- a/web/i18n/locales/ro-RO/skill.json
+++ b/web/i18n/locales/ro-RO/skill.json
@@ -67,7 +67,6 @@
"skillManagement.detail.deleteFileConfirm": "Ștergeți acest fișier?",
"skillManagement.detail.deleteFileSuccess": "Fișier șters.",
"skillManagement.detail.deleteVersionConfirm": "Ștergeți această versiune?",
- "skillManagement.detail.deleteVersionFailed": "Versiunea a eșuat.",
"skillManagement.detail.downloadFile": "Descărcați fișierul",
"skillManagement.detail.draft": "Ciornă",
"skillManagement.detail.editVersionInfo": "Editează informațiile versiunii",
@@ -122,8 +121,6 @@
"skillManagement.detail.restoreVersion": "Restaurează",
"skillManagement.detail.restoreVersionConfirmDescription": "Aceasta va înlocui schița actuală cu fișierele din „{{version}}”. Nu va publica Skill sau nu va crea o versiune nouă.",
"skillManagement.detail.restoreVersionConfirmTitle": "Restabiliți această versiune?",
- "skillManagement.detail.restoreVersionFailed": "Nu s-a restabilit versiunea.",
- "skillManagement.detail.restoreVersionSuccess": "Versiunea a fost restaurată în versiune nefinalizată.",
"skillManagement.detail.saveConflictConfirmDescription": "Această abilitate a fost actualizată în altă parte. Încărcați cea mai recentă schiță pentru a continua editarea. Modificările dvs. curente vor fi renunțate.",
"skillManagement.detail.saveConflictConfirmTitle": "Încărcați cea mai recentă schiță?",
"skillManagement.detail.saveConflictReload": "Încărcați cea mai recentă schiță",
diff --git a/web/i18n/locales/ru-RU/skill.json b/web/i18n/locales/ru-RU/skill.json
index a3388201409..f032aca9eb6 100644
--- a/web/i18n/locales/ru-RU/skill.json
+++ b/web/i18n/locales/ru-RU/skill.json
@@ -68,7 +68,6 @@
"skillManagement.detail.deleteFileConfirm": "Удалить этот файл?",
"skillManagement.detail.deleteFileSuccess": "Файл удален.",
"skillManagement.detail.deleteVersionConfirm": "Удалить эту версию?",
- "skillManagement.detail.deleteVersionFailed": "Не удалось удалить версию.",
"skillManagement.detail.downloadFile": "Скачать файл",
"skillManagement.detail.draft": "Черновик",
"skillManagement.detail.editVersionInfo": "Редактировать информацию о версии",
@@ -126,8 +125,6 @@
"skillManagement.detail.restoreVersion": "Восстановить",
"skillManagement.detail.restoreVersionConfirmDescription": "Это заменит текущий черновик файлами из «{{version}}». Он не будет публиковать Skill или создавать новую версию.",
"skillManagement.detail.restoreVersionConfirmTitle": "Восстановить эту версию?",
- "skillManagement.detail.restoreVersionFailed": "Не удалось восстановить версию.",
- "skillManagement.detail.restoreVersionSuccess": "Версия восстановлена ​​до черновика.",
"skillManagement.detail.saveConflictConfirmDescription": "Этот навык был обновлен в другом месте. Загрузите последний черновик, чтобы продолжить редактирование. Ваши текущие изменения будут отменены.",
"skillManagement.detail.saveConflictConfirmTitle": "Загрузить последний черновик?",
"skillManagement.detail.saveConflictReload": "Загрузить последний черновик",
diff --git a/web/i18n/locales/sl-SI/skill.json b/web/i18n/locales/sl-SI/skill.json
index 6d22073881a..d90277f5183 100644
--- a/web/i18n/locales/sl-SI/skill.json
+++ b/web/i18n/locales/sl-SI/skill.json
@@ -68,7 +68,6 @@
"skillManagement.detail.deleteFileConfirm": "Želite izbrisati to datoteko?",
"skillManagement.detail.deleteFileSuccess": "Datoteka izbrisana.",
"skillManagement.detail.deleteVersionConfirm": "Želite izbrisati to različico?",
- "skillManagement.detail.deleteVersionFailed": "Brisanje različice ni uspelo.",
"skillManagement.detail.downloadFile": "Prenesi datoteko",
"skillManagement.detail.draft": "Osnutek",
"skillManagement.detail.editVersionInfo": "Uredi informacije o različici",
@@ -126,8 +125,6 @@
"skillManagement.detail.restoreVersion": "Obnovi",
"skillManagement.detail.restoreVersionConfirmDescription": "To bo zamenjalo trenutni osnutek z datotekami iz »{{version}}«. Ne bo objavil Skill ali ustvaril nove različice.",
"skillManagement.detail.restoreVersionConfirmTitle": "Obnoviti to različico?",
- "skillManagement.detail.restoreVersionFailed": "Različice ni bilo mogoče obnoviti.",
- "skillManagement.detail.restoreVersionSuccess": "Različica obnovljena v osnutek.",
"skillManagement.detail.saveConflictConfirmDescription": "Ta veščina je bila posodobljena drugje. Za nadaljevanje urejanja naložite najnovejši osnutek. Vaše trenutne spremembe bodo zavržene.",
"skillManagement.detail.saveConflictConfirmTitle": "Naj naložim najnovejši osnutek?",
"skillManagement.detail.saveConflictReload": "Naloži najnovejši osnutek",
diff --git a/web/i18n/locales/th-TH/skill.json b/web/i18n/locales/th-TH/skill.json
index e3e783a55d6..35125f706a5 100644
--- a/web/i18n/locales/th-TH/skill.json
+++ b/web/i18n/locales/th-TH/skill.json
@@ -66,7 +66,6 @@
"skillManagement.detail.deleteFileConfirm": "ลบไฟล์นี้ใช่ไหม",
"skillManagement.detail.deleteFileSuccess": "ลบไฟล์แล้ว",
"skillManagement.detail.deleteVersionConfirm": "ลบเวอร์ชันนี้ใช่ไหม",
- "skillManagement.detail.deleteVersionFailed": "ลบเวอร์ชันไม่สำเร็จ",
"skillManagement.detail.downloadFile": "ดาวน์โหลดไฟล์",
"skillManagement.detail.draft": "ฉบับร่าง",
"skillManagement.detail.editVersionInfo": "แก้ไขข้อมูลเวอร์ชัน",
@@ -118,8 +117,6 @@
"skillManagement.detail.restoreVersion": "กู้คืน",
"skillManagement.detail.restoreVersionConfirmDescription": "ซึ่งจะแทนที่แบบร่างปัจจุบันด้วยไฟล์จาก \"{{version}}\" จะไม่เผยแพร่ Skill หรือสร้างเวอร์ชันใหม่",
"skillManagement.detail.restoreVersionConfirmTitle": "กู้คืนเวอร์ชันนี้ไหม",
- "skillManagement.detail.restoreVersionFailed": "ไม่สามารถกู้คืนเวอร์ชันได้",
- "skillManagement.detail.restoreVersionSuccess": "กู้คืนเวอร์ชันเป็นฉบับร่างแล้ว",
"skillManagement.detail.saveConflictConfirmDescription": "ทักษะนี้ได้รับการอัปเดตที่อื่น โหลดฉบับร่างล่าสุดเพื่อแก้ไขต่อ การเปลี่ยนแปลงในปัจจุบันของคุณจะถูกยกเลิก",
"skillManagement.detail.saveConflictConfirmTitle": "โหลดฉบับร่างล่าสุดใช่ไหม",
"skillManagement.detail.saveConflictReload": "โหลดฉบับร่างล่าสุด",
diff --git a/web/i18n/locales/tr-TR/skill.json b/web/i18n/locales/tr-TR/skill.json
index 1df9b523861..c16e2d8b8f8 100644
--- a/web/i18n/locales/tr-TR/skill.json
+++ b/web/i18n/locales/tr-TR/skill.json
@@ -66,7 +66,6 @@
"skillManagement.detail.deleteFileConfirm": "Bu dosya silinsin mi?",
"skillManagement.detail.deleteFileSuccess": "Dosya silindi.",
"skillManagement.detail.deleteVersionConfirm": "Bu sürüm silinsin mi?",
- "skillManagement.detail.deleteVersionFailed": "Sürüm silinemedi.",
"skillManagement.detail.downloadFile": "Dosyayı indir",
"skillManagement.detail.draft": "Taslak",
"skillManagement.detail.editVersionInfo": "Sürüm bilgilerini düzenle",
@@ -118,8 +117,6 @@
"skillManagement.detail.restoreVersion": "Geri yükle",
"skillManagement.detail.restoreVersionConfirmDescription": "Bu, mevcut taslağı \"{{version}}\" dosyasındaki dosyalarla değiştirecektir. Skill'yi yayınlamaz veya yeni bir sürüm oluşturmaz.",
"skillManagement.detail.restoreVersionConfirmTitle": "Bu sürüm geri yüklensin mi?",
- "skillManagement.detail.restoreVersionFailed": "Sürüm geri yüklenemedi.",
- "skillManagement.detail.restoreVersionSuccess": "Sürüm taslağa geri yüklendi.",
"skillManagement.detail.saveConflictConfirmDescription": "Bu beceri başka bir yerde güncellendi. Düzenlemeye devam etmek için en son taslağı yükleyin. Mevcut değişiklikleriniz silinecek.",
"skillManagement.detail.saveConflictConfirmTitle": "En son taslak yüklensin mi?",
"skillManagement.detail.saveConflictReload": "En son taslağı yükle",
diff --git a/web/i18n/locales/uk-UA/skill.json b/web/i18n/locales/uk-UA/skill.json
index d601b05d380..bbf36762490 100644
--- a/web/i18n/locales/uk-UA/skill.json
+++ b/web/i18n/locales/uk-UA/skill.json
@@ -68,7 +68,6 @@
"skillManagement.detail.deleteFileConfirm": "Видалити цей файл?",
"skillManagement.detail.deleteFileSuccess": "Файл видалено.",
"skillManagement.detail.deleteVersionConfirm": "Видалити цю версію?",
- "skillManagement.detail.deleteVersionFailed": "Не вдалося видалити версію.",
"skillManagement.detail.downloadFile": "Завантажити файл",
"skillManagement.detail.draft": "Чернетка",
"skillManagement.detail.editVersionInfo": "Редагувати інформацію про версію",
@@ -126,8 +125,6 @@
"skillManagement.detail.restoreVersion": "Відновити",
"skillManagement.detail.restoreVersionConfirmDescription": "Це замінить поточну чернетку на файли з \"{{version}}\". Він не публікуватиме Skill або створюватиме нову версію.",
"skillManagement.detail.restoreVersionConfirmTitle": "Відновити цю версію?",
- "skillManagement.detail.restoreVersionFailed": "Не вдалося відновити версію.",
- "skillManagement.detail.restoreVersionSuccess": "Версію відновлено до чернетки.",
"skillManagement.detail.saveConflictConfirmDescription": "Цей навик було оновлено в іншому місці. Завантажте останню чернетку, щоб продовжити редагування. Ваші поточні зміни буде скасовано.",
"skillManagement.detail.saveConflictConfirmTitle": "Завантажити останню чернетку?",
"skillManagement.detail.saveConflictReload": "Завантажити останню чернетку",
diff --git a/web/i18n/locales/vi-VN/skill.json b/web/i18n/locales/vi-VN/skill.json
index 3b2955b8d5d..77ecc14ba99 100644
--- a/web/i18n/locales/vi-VN/skill.json
+++ b/web/i18n/locales/vi-VN/skill.json
@@ -66,7 +66,6 @@
"skillManagement.detail.deleteFileConfirm": "Xóa tập tin này?",
"skillManagement.detail.deleteFileSuccess": "Tập tin đã bị xóa.",
"skillManagement.detail.deleteVersionConfirm": "Xóa phiên bản này?",
- "skillManagement.detail.deleteVersionFailed": "Không xóa được phiên bản.",
"skillManagement.detail.downloadFile": "Tải tập tin xuống",
"skillManagement.detail.draft": "Bản nháp",
"skillManagement.detail.editVersionInfo": "Chỉnh sửa thông tin phiên bản",
@@ -118,8 +117,6 @@
"skillManagement.detail.restoreVersion": "Khôi phục",
"skillManagement.detail.restoreVersionConfirmDescription": "Điều này sẽ thay thế bản nháp hiện tại bằng các tệp từ \"{{version}}\". Nó sẽ không xuất bản Skill hoặc tạo phiên bản mới.",
"skillManagement.detail.restoreVersionConfirmTitle": "Khôi phục phiên bản này?",
- "skillManagement.detail.restoreVersionFailed": "Không thể khôi phục phiên bản.",
- "skillManagement.detail.restoreVersionSuccess": "Phiên bản được khôi phục về bản nháp.",
"skillManagement.detail.saveConflictConfirmDescription": "Kỹ năng này đã được cập nhật ở nơi khác. Tải bản nháp mới nhất để tiếp tục chỉnh sửa. Những thay đổi hiện tại của bạn sẽ bị loại bỏ.",
"skillManagement.detail.saveConflictConfirmTitle": "Tải bản nháp mới nhất?",
"skillManagement.detail.saveConflictReload": "Tải bản nháp mới nhất",
diff --git a/web/i18n/locales/zh-Hans/skill.json b/web/i18n/locales/zh-Hans/skill.json
index 651c9841d43..4f84b50e237 100644
--- a/web/i18n/locales/zh-Hans/skill.json
+++ b/web/i18n/locales/zh-Hans/skill.json
@@ -66,7 +66,6 @@
"skillManagement.detail.deleteFileConfirm": "删除这个文件?",
"skillManagement.detail.deleteFileSuccess": "文件已删除。",
"skillManagement.detail.deleteVersionConfirm": "删除这个版本?",
- "skillManagement.detail.deleteVersionFailed": "版本删除失败。",
"skillManagement.detail.downloadFile": "下载文件",
"skillManagement.detail.draft": "Draft",
"skillManagement.detail.editVersionInfo": "编辑版本信息",
@@ -118,8 +117,6 @@
"skillManagement.detail.restoreVersion": "恢复",
"skillManagement.detail.restoreVersionConfirmDescription": "这会用“{{version}}”中的文件替换当前草稿,不会发布 Skill,也不会创建新的版本。",
"skillManagement.detail.restoreVersionConfirmTitle": "确认恢复此版本?",
- "skillManagement.detail.restoreVersionFailed": "版本恢复失败。",
- "skillManagement.detail.restoreVersionSuccess": "版本已恢复到草稿。",
"skillManagement.detail.saveConflictConfirmDescription": "此 Skill 已在其他位置更新。请加载最新草稿后继续编辑。当前更改将被丢弃。",
"skillManagement.detail.saveConflictConfirmTitle": "加载最新草稿?",
"skillManagement.detail.saveConflictReload": "加载最新草稿",
diff --git a/web/i18n/locales/zh-Hant/skill.json b/web/i18n/locales/zh-Hant/skill.json
index 3c7db9a0b35..0c6b9600f6c 100644
--- a/web/i18n/locales/zh-Hant/skill.json
+++ b/web/i18n/locales/zh-Hant/skill.json
@@ -66,7 +66,6 @@
"skillManagement.detail.deleteFileConfirm": "刪除這個檔案?",
"skillManagement.detail.deleteFileSuccess": "檔案已刪除。",
"skillManagement.detail.deleteVersionConfirm": "刪除這個版本?",
- "skillManagement.detail.deleteVersionFailed": "版本刪除失敗。",
"skillManagement.detail.downloadFile": "下载文件",
"skillManagement.detail.draft": "草稿",
"skillManagement.detail.editVersionInfo": "編輯版本信息",
@@ -118,8 +117,6 @@
"skillManagement.detail.restoreVersion": "還原",
"skillManagement.detail.restoreVersionConfirmDescription": "這會將目前草稿替換為“{{version}}”中的檔案。它不會發布 Skill 或創建新版本。",
"skillManagement.detail.restoreVersionConfirmTitle": "恢復這個版本嗎?",
- "skillManagement.detail.restoreVersionFailed": "版本還原失敗。",
- "skillManagement.detail.restoreVersionSuccess": "版本已還原到草稿。",
"skillManagement.detail.saveConflictConfirmDescription": "該技能已在其他地方更新。載入最新草稿以繼續編輯。您當前的更改將被放棄。",
"skillManagement.detail.saveConflictConfirmTitle": "加載最新的草稿?",
"skillManagement.detail.saveConflictReload": "載入最新草稿",
diff --git a/web/i18n/resources.generated.d.ts b/web/i18n/resources.generated.d.ts
index 8af5ce951cd..e2841328ab6 100644
--- a/web/i18n/resources.generated.d.ts
+++ b/web/i18n/resources.generated.d.ts
@@ -4378,7 +4378,6 @@ export default interface Resources {
'skillManagement.detail.deleteFileConfirm': 'Delete this file?'
'skillManagement.detail.deleteFileSuccess': 'File deleted.'
'skillManagement.detail.deleteVersionConfirm': 'Delete this version?'
- 'skillManagement.detail.deleteVersionFailed': 'Failed to delete version.'
'skillManagement.detail.downloadFile': 'Download file'
'skillManagement.detail.draft': 'Draft'
'skillManagement.detail.editVersionInfo': 'Edit version info'
@@ -4429,8 +4428,6 @@ export default interface Resources {
'skillManagement.detail.restoreVersion': 'Restore'
'skillManagement.detail.restoreVersionConfirmDescription': 'This will replace the current draft with the files from "{{version}}". It will not publish the Skill or create a new version.'
'skillManagement.detail.restoreVersionConfirmTitle': 'Restore this version?'
- 'skillManagement.detail.restoreVersionFailed': 'Failed to restore version.'
- 'skillManagement.detail.restoreVersionSuccess': 'Version restored to draft.'
'skillManagement.detail.saveConflictConfirmDescription': 'This skill was updated elsewhere. Load the latest draft to continue editing. Your current changes will be discarded.'
'skillManagement.detail.saveConflictConfirmTitle': 'Load the latest draft?'
'skillManagement.detail.saveConflictReload': 'Load latest draft'
diff --git a/web/service/console/query-policies.ts b/web/service/console/query-policies.ts
index 2cd57de4050..8bb994aab71 100644
--- a/web/service/console/query-policies.ts
+++ b/web/service/console/query-policies.ts
@@ -135,6 +135,39 @@ export function createConsoleQuery(consoleClient: ConsoleClient) {
},
skills: {
bySkillId: {
+ restore: {
+ post: {
+ mutationOptions: {
+ onSettled: (_data, error, variables, _result, context) => {
+ if (error) return
+ void invalidateSkillVersionQueries(
+ consoleQuery,
+ context.client,
+ variables.params.skill_id,
+ )
+ void context.client.invalidateQueries({
+ queryKey: consoleQuery.workspaces.current.skills.get.key(),
+ })
+ },
+ },
+ },
+ },
+ versions: {
+ byVersionId: {
+ delete: {
+ mutationOptions: {
+ onSettled: (_data, error, variables, _result, context) => {
+ if (error) return
+ void invalidateSkillVersionQueries(
+ consoleQuery,
+ context.client,
+ variables.params.skill_id,
+ )
+ },
+ },
+ },
+ },
+ },
delete: {
mutationOptions: {
onSettled: (_data, error, _variables, _result, context) => {
@@ -1472,3 +1505,16 @@ function invalidateAgentAccessQueries(
query.agent.byAgentId.get.queryKey({ input: { params: { agent_id: agentId } } }),
])
}
+
+function invalidateSkillVersionQueries(
+ query: RouterUtils<ConsoleClient>,
+ client: QueryClient,
+ skillId: string,
+) {
+ const input = { params: { skill_id: skillId } }
+ return invalidateQueryKeys(client, [
+ query.workspaces.current.skills.bySkillId.get.key({ input }),
+ query.workspaces.current.skills.bySkillId.versions.get.key({ input }),
+ query.workspaces.current.agents.byAgentId.skills.get.key(),
+ ])
+}