refs #567 Add reporting method on toot

This commit is contained in:
AkiraFukushima 2018-09-30 23:01:40 +09:00
parent ca1e74e263
commit ede18f50a2
7 changed files with 129 additions and 32 deletions

41
package-lock.json generated
View File

@ -6995,14 +6995,12 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -7017,20 +7015,17 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -7147,8 +7142,7 @@
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -7160,7 +7154,6 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -7175,7 +7168,6 @@
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
@ -7183,14 +7175,12 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.2.4", "version": "2.2.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.1", "safe-buffer": "^5.1.1",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -7209,7 +7199,6 @@
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -7290,8 +7279,7 @@
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -7303,7 +7291,6 @@
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -7425,7 +7412,6 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -15914,13 +15900,8 @@
"resolved": "https://registry.npmjs.org/system-font-families/-/system-font-families-0.4.1.tgz", "resolved": "https://registry.npmjs.org/system-font-families/-/system-font-families-0.4.1.tgz",
"integrity": "sha512-XQK5qAYsbEI6SkCEwezRDsPV44T2G4NNQ/xcx7D/8XM3S+rqYlNxsGcLT7vO6vdT4hc/mlRef7S6+KGIetTwdg==", "integrity": "sha512-XQK5qAYsbEI6SkCEwezRDsPV44T2G4NNQ/xcx7D/8XM3S+rqYlNxsGcLT7vO6vdT4hc/mlRef7S6+KGIetTwdg==",
"requires": { "requires": {
"babel-polyfill": "^6.23.0" "babel-polyfill": "^6.23.0",
}, "ttfinfo": "git+https://github.com/rBurgett/ttfinfo.git#f00e43e2a6d4c8a12a677df20b7804492d50863c"
"dependencies": {
"ttfinfo": {
"version": "git+https://github.com/rBurgett/ttfinfo.git#f00e43e2a6d4c8a12a677df20b7804492d50863c",
"from": "git+https://github.com/rBurgett/ttfinfo.git#f00e43e2a6d4c8a12a677df20b7804492d50863c"
}
} }
}, },
"table": { "table": {
@ -16339,6 +16320,10 @@
"integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==", "integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==",
"dev": true "dev": true
}, },
"ttfinfo": {
"version": "git+https://github.com/rBurgett/ttfinfo.git#f00e43e2a6d4c8a12a677df20b7804492d50863c",
"from": "git+https://github.com/rBurgett/ttfinfo.git"
},
"tty-browserify": { "tty-browserify": {
"version": "0.0.0", "version": "0.0.0",
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",

View File

@ -212,6 +212,12 @@
"i": "Open the images", "i": "Open the images",
"x": "Show/hide CW and NSFW", "x": "Show/hide CW and NSFW",
"esc": "Close current page" "esc": "Close current page"
},
"report": {
"title": "Reporting this user",
"comment": "Additional comments",
"cancel": "Cancel",
"ok": "Report"
} }
}, },
"cards": { "cards": {
@ -222,6 +228,9 @@
"view_toot_detail": "View Toot Detail", "view_toot_detail": "View Toot Detail",
"open_in_browser": "Open in Browser", "open_in_browser": "Open in Browser",
"copy_link_to_toot": "Copy Link to Toot", "copy_link_to_toot": "Copy Link to Toot",
"mute": "Mute",
"block": "Block",
"report": "Report",
"delete": "Delete", "delete": "Delete",
"via": "via {{application}}", "via": "via {{application}}",
"reply": "Reply", "reply": "Reply",

View File

@ -94,7 +94,10 @@
<li role="button" @click="copyLink(originalMessage(message))"> <li role="button" @click="copyLink(originalMessage(message))">
{{ $t('cards.toot.copy_link_to_toot') }} {{ $t('cards.toot.copy_link_to_toot') }}
</li> </li>
<li role="button" class="separate" @click="deleteToot(message)" v-show="isMyMessage(message)"> <li role="button" class="separate" @click="reportUser(message)" v-if="!isMyMessage(message)">
{{ $t('cards.toot.report') }}
</li>
<li role="button" class="separate" @click="deleteToot(message)" v-if="isMyMessage(message)">
{{ $t('cards.toot.delete') }} {{ $t('cards.toot.delete') }}
</li> </li>
</ul> </ul>
@ -266,6 +269,10 @@ export default {
clipboard.writeText(message.url, 'toot-link') clipboard.writeText(message.url, 'toot-link')
this.$refs.popper.doClose() this.$refs.popper.doClose()
}, },
reportUser (message) {
this.$store.dispatch('TimelineSpace/Modals/Report/openReport', this.originalMessage(message))
this.$refs.popper.doClose()
},
changeReblog (message) { changeReblog (message) {
if (message.reblogged) { if (message.reblogged) {
this.$store.dispatch('TimelineSpace/Contents/Cards/Toot/unreblog', message) this.$store.dispatch('TimelineSpace/Contents/Cards/Toot/unreblog', message)

View File

@ -7,6 +7,7 @@
<add-list-member></add-list-member> <add-list-member></add-list-member>
<mute-confirm></mute-confirm> <mute-confirm></mute-confirm>
<shortcut></shortcut> <shortcut></shortcut>
<report></report>
</div> </div>
</template> </template>
@ -18,6 +19,7 @@ import ListMembership from './Modals/ListMembership'
import AddListMember from './Modals/AddListMember' import AddListMember from './Modals/AddListMember'
import MuteConfirm from './Modals/MuteConfirm' import MuteConfirm from './Modals/MuteConfirm'
import Shortcut from './Modals/Shortcut' import Shortcut from './Modals/Shortcut'
import Report from './Modals/Report'
export default { export default {
name: 'modals', name: 'modals',
@ -28,7 +30,8 @@ export default {
ListMembership, ListMembership,
AddListMember, AddListMember,
MuteConfirm, MuteConfirm,
Shortcut Shortcut,
Report
} }
} }
</script> </script>

View File

@ -0,0 +1,56 @@
<template>
<el-dialog
:title="$t('modals.report.title')"
:visible.sync="reportModal"
width="400px"
custom-class="report"
>
<el-input type="textarea" v-model="comment" :placeholder="$t('modals.report.comment')"></el-input>
<span slot="footer" class="dialog-footer">
<el-button @click="closeModal">{{ $t('modals.report.cancel') }}</el-button>
<el-button type="primary" @click="submit">{{ $t('modals.report.ok') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'Report',
data () {
return {
comment: ''
}
},
computed: {
...mapState('TimelineSpace/Modals/Report', {
toot: state => state.message
}),
reportModal: {
get () {
return this.$store.state.TimelineSpace.Modals.Report.modalOpen
},
set (value) {
this.$store.commit('TimelineSpace/Modals/Report/changeModalOpen', value)
}
}
},
methods: {
closeModal () {
this.reportModal = false
},
async submit () {
this.closeModal()
await this.$store.dispatch('TimelineSpace/Modals/Report/submit', {
account_id: this.toot.account.id,
status_id: this.toot.id,
comment: this.comment
})
}
}
}
</script>
<style lang="scss" scoped>
</style>

View File

@ -5,6 +5,7 @@ import ListMembership from './Modals/ListMembership'
import AddListMember from './Modals/AddListMember' import AddListMember from './Modals/AddListMember'
import MuteConfirm from './Modals/MuteConfirm' import MuteConfirm from './Modals/MuteConfirm'
import Shortcut from './Modals/Shortcut' import Shortcut from './Modals/Shortcut'
import Report from './Modals/Report'
const Modals = { const Modals = {
namespaced: true, namespaced: true,
@ -15,7 +16,8 @@ const Modals = {
ListMembership, ListMembership,
AddListMember, AddListMember,
MuteConfirm, MuteConfirm,
Shortcut Shortcut,
Report
}, },
getters: { getters: {
modalOpened: (state, getters, rootState) => { modalOpened: (state, getters, rootState) => {
@ -26,7 +28,8 @@ const Modals = {
const addListMember = rootState.TimelineSpace.Modals.AddListMember.modalOpen const addListMember = rootState.TimelineSpace.Modals.AddListMember.modalOpen
const shortcut = rootState.TimelineSpace.Modals.Shortcut.modalOpen const shortcut = rootState.TimelineSpace.Modals.Shortcut.modalOpen
const muteConfirm = rootState.TimelineSpace.Modals.MuteConfirm.modalOpen const muteConfirm = rootState.TimelineSpace.Modals.MuteConfirm.modalOpen
return imageViewer || newToot || jump || listMembership || addListMember || shortcut || muteConfirm const report = rootState.TimelineSpace.Modals.Report.modalOpen
return imageViewer || newToot || jump || listMembership || addListMember || shortcut || muteConfirm || report
} }
} }
} }

View File

@ -0,0 +1,34 @@
import Mastodon from 'megalodon'
export default {
namespaced: true,
state: {
modalOpen: false,
message: {}
},
mutations: {
changeModalOpen (state, value) {
state.modalOpen = value
},
changeMessage (state, value) {
state.message = value
}
},
actions: {
openReport ({ commit }, message) {
commit('changeMessage', message)
commit('changeModalOpen', true)
},
submit ({ rootState }, payload) {
const client = new Mastodon(
rootState.TimelineSpace.account.accessToken,
rootState.TimelineSpace.account.baseURL + '/api/v1'
)
return client.post(`/reports`, {
account_id: payload.account_id,
status_ids: [payload.status_id],
comment: payload.comment
})
}
}
}