From ca646822f62ff136d34e62944d15deaf841938ad Mon Sep 17 00:00:00 2001 From: Sol Fisher Romanoff Date: Sun, 25 Sep 2022 20:50:03 +0300 Subject: [PATCH] Add delete & redraft button to posts --- package.json | 2 +- src/components/extra_buttons/extra_buttons.js | 37 +- .../extra_buttons/extra_buttons.vue | 21 + .../post_status_form/post_status_form.js | 7 +- .../post_status_modal/post_status_modal.js | 3 +- src/i18n/en.json | 5 + yarn.lock | 17828 ++++++++-------- 7 files changed, 9196 insertions(+), 8707 deletions(-) diff --git a/package.json b/package.json index 336cabce..6712bf76 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@chenfengyuan/vue-qrcode": "2.0.0", "@fortawesome/fontawesome-svg-core": "1.3.0", "@fortawesome/free-regular-svg-icons": "^6.1.2", - "@fortawesome/free-solid-svg-icons": "5.15.4", + "@fortawesome/free-solid-svg-icons": "^6.2.0", "@fortawesome/vue-fontawesome": "3.0.1", "@kazvmoe-infra/pinch-zoom-element": "1.2.0", "@vuelidate/core": "2.0.0-alpha.42", diff --git a/src/components/extra_buttons/extra_buttons.js b/src/components/extra_buttons/extra_buttons.js index f24e261b..4bc6144c 100644 --- a/src/components/extra_buttons/extra_buttons.js +++ b/src/components/extra_buttons/extra_buttons.js @@ -8,7 +8,8 @@ import { faThumbtack, faShareAlt, faExternalLinkAlt, - faHistory + faHistory, + faFilePen } from '@fortawesome/free-solid-svg-icons' import { faBookmark as faBookmarkReg, @@ -24,7 +25,8 @@ library.add( faShareAlt, faExternalLinkAlt, faFlag, - faHistory + faHistory, + faFilePen ) const ExtraButtons = { @@ -36,7 +38,8 @@ const ExtraButtons = { data () { return { expanded: false, - showingDeleteDialog: false + showingDeleteDialog: false, + showingRedraftDialog: false } }, methods: { @@ -122,6 +125,34 @@ const ExtraButtons = { const stripFieldsList = ['attachments', 'created_at', 'emojis', 'text', 'raw_html', 'nsfw', 'poll', 'summary', 'summary_raw_html'] stripFieldsList.forEach(p => delete originalStatus[p]) this.$store.dispatch('openStatusHistoryModal', originalStatus) + }, + redraftStatus () { + if (this.shouldConfirmDelete) { + this.showRedraftStatusConfirmDialog() + } else { + this.doRedraftStatus() + } + }, + doRedraftStatus () { + this.$store.dispatch('fetchStatusSource', { id: this.status.id }) + .then(data => this.$store.dispatch('openPostStatusModal', { + isRedraft: true, + statusId: this.status.id, + subject: data.spoiler_text, + statusText: data.text, + statusIsSensitive: this.status.nsfw, + statusPoll: this.status.poll, + statusFiles: [...this.status.attachments], + statusScope: this.status.visibility, + statusContentType: data.content_type + })) + this.doDeleteStatus() + }, + showRedraftStatusConfirmDialog () { + this.showingRedraftDialog = true + }, + hideRedraftStatusConfirmDialog () { + this.showingRedraftDialog = false } }, computed: { diff --git a/src/components/extra_buttons/extra_buttons.vue b/src/components/extra_buttons/extra_buttons.vue index a15f0bf2..9da2ad8c 100644 --- a/src/components/extra_buttons/extra_buttons.vue +++ b/src/components/extra_buttons/extra_buttons.vue @@ -95,6 +95,17 @@ icon="history" />{{ $t("status.edit_history") }} +