feat: warn danger actions for dev
parent
ef0173a356
commit
259e11c097
|
@ -97,6 +97,12 @@ const deleteStatus = async () => {
|
||||||
|
|
||||||
const deleteAndRedraft = async () => {
|
const deleteAndRedraft = async () => {
|
||||||
// TODO confirm to delete
|
// TODO confirm to delete
|
||||||
|
if (process.dev) {
|
||||||
|
// eslint-disable-next-line no-alert
|
||||||
|
const result = confirm('[DEV] Are you sure you want to delete and re-draft this post?')
|
||||||
|
if (!result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const { text } = await useMasto().statuses.remove(status.id)
|
const { text } = await useMasto().statuses.remove(status.id)
|
||||||
openPublishDialog('dialog', getDraftFromStatus(status, text), true)
|
openPublishDialog('dialog', getDraftFromStatus(status, text), true)
|
||||||
|
|
|
@ -21,11 +21,22 @@ export function openSigninDialog() {
|
||||||
|
|
||||||
export function openPublishDialog(draftKey = 'dialog', draft?: Draft, overwrite = false): void {
|
export function openPublishDialog(draftKey = 'dialog', draft?: Draft, overwrite = false): void {
|
||||||
dialogDraftKey.value = draftKey
|
dialogDraftKey.value = draftKey
|
||||||
if (overwrite) {
|
|
||||||
|
if (draft) {
|
||||||
|
if (overwrite && !isEmptyDraft(currentUserDrafts.value[draftKey])) {
|
||||||
// TODO overwrite warning
|
// TODO overwrite warning
|
||||||
|
// TODO don't overwrite, have a draft list
|
||||||
|
if (process.dev) {
|
||||||
|
// eslint-disable-next-line no-alert
|
||||||
|
const result = confirm('[DEV] Are you sure you overwrite draft content?')
|
||||||
|
if (!result)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if (draft && (overwrite || !currentUserDrafts.value[draftKey]))
|
}
|
||||||
|
|
||||||
|
if (overwrite || !currentUserDrafts.value[draftKey])
|
||||||
currentUserDrafts.value[draftKey] = draft
|
currentUserDrafts.value[draftKey] = draft
|
||||||
|
}
|
||||||
isPublishDialogOpen.value = true
|
isPublishDialogOpen.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,9 @@ export function getReplyDraft(status: Status) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isEmptyDraft = (draft: Draft) => {
|
export const isEmptyDraft = (draft: Draft | null | undefined) => {
|
||||||
|
if (!draft)
|
||||||
|
return true
|
||||||
const { params, attachments } = draft
|
const { params, attachments } = draft
|
||||||
const status = params.status || ''
|
const status = params.status || ''
|
||||||
return (status.length === 0 || status === '<p></p>')
|
return (status.length === 0 || status === '<p></p>')
|
||||||
|
|
Loading…
Reference in New Issue