platform/plugins/questions-resources/src/actions/questionDeleteAction.ts
Alexey Zinoviev 48e1ca9849
UBERF-7090: Add QMS plugins (#5716)
Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
2024-06-03 19:55:54 +04:00

27 lines
742 B
TypeScript

//
// Copyright © 2023 Hardcore Engineering Inc.
//
import type { Question } from '@hcengineering/questions'
import { getClient } from '@hcengineering/presentation'
import { canUpdateQuestion } from '../utils'
import { eachItemActionWithAvailability } from './ActionWithAvailability'
export const questionDeleteAction = eachItemActionWithAvailability<Question<unknown>>(
async (object: Question<unknown>) => {
return canUpdateQuestion(object)
},
async (object: Question<unknown>) => {
// TODO: Do we need a confirmation popup?
await getClient().removeCollection(
object._class,
object.space,
object._id,
object.attachedTo,
object.attachedToClass,
object.collection
)
},
true
)