fix: add dataset mutation context to Popup component

pull/21398/head
twwu 11 months ago
parent 9be036e0ca
commit 1274aaed5d

@ -26,6 +26,7 @@ import { usePublishWorkflow } from '@/service/use-workflow'
import type { PublishWorkflowParams } from '@/types/workflow' import type { PublishWorkflowParams } from '@/types/workflow'
import { useToastContext } from '@/app/components/base/toast' import { useToastContext } from '@/app/components/base/toast'
import { useParams, useRouter } from 'next/navigation' import { useParams, useRouter } from 'next/navigation'
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
const PUBLISH_SHORTCUT = ['⌘', '⇧', 'P'] const PUBLISH_SHORTCUT = ['⌘', '⇧', 'P']
@ -36,6 +37,7 @@ const Popup = () => {
const publishedAt = useStore(s => s.publishedAt) const publishedAt = useStore(s => s.publishedAt)
const draftUpdatedAt = useStore(s => s.draftUpdatedAt) const draftUpdatedAt = useStore(s => s.draftUpdatedAt)
const pipelineId = useStore(s => s.pipelineId) const pipelineId = useStore(s => s.pipelineId)
const mutateDatasetRes = useDatasetDetailContextWithSelector(s => s.mutateDatasetRes)
const [published, setPublished] = useState(false) const [published, setPublished] = useState(false)
const { formatTimeFromNow } = useFormatTimeFromNow() const { formatTimeFromNow } = useFormatTimeFromNow()
const { handleCheckBeforePublish } = useChecklistBeforePublish() const { handleCheckBeforePublish } = useChecklistBeforePublish()
@ -55,12 +57,13 @@ const Popup = () => {
if (res) { if (res) {
notify({ type: 'success', message: t('common.api.actionSuccess') }) notify({ type: 'success', message: t('common.api.actionSuccess') })
workflowStore.getState().setPublishedAt(res.created_at) workflowStore.getState().setPublishedAt(res.created_at)
mutateDatasetRes?.()
} }
} }
else { else {
throw new Error('Checklist failed') throw new Error('Checklist failed')
} }
}, [workflowStore, notify, t, publishWorkflow, pipelineId, handleCheckBeforePublish]) }, [handleCheckBeforePublish, publishWorkflow, pipelineId, notify, t, workflowStore, mutateDatasetRes])
useKeyPress(`${getKeyboardKeyCodeBySystem('ctrl')}.shift.p`, (e) => { useKeyPress(`${getKeyboardKeyCodeBySystem('ctrl')}.shift.p`, (e) => {
e.preventDefault() e.preventDefault()

Loading…
Cancel
Save