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

View File

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

View File

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

View File

@ -7,6 +7,7 @@
<add-list-member></add-list-member>
<mute-confirm></mute-confirm>
<shortcut></shortcut>
<report></report>
</div>
</template>
@ -18,6 +19,7 @@ import ListMembership from './Modals/ListMembership'
import AddListMember from './Modals/AddListMember'
import MuteConfirm from './Modals/MuteConfirm'
import Shortcut from './Modals/Shortcut'
import Report from './Modals/Report'
export default {
name: 'modals',
@ -28,7 +30,8 @@ export default {
ListMembership,
AddListMember,
MuteConfirm,
Shortcut
Shortcut,
Report
}
}
</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 MuteConfirm from './Modals/MuteConfirm'
import Shortcut from './Modals/Shortcut'
import Report from './Modals/Report'
const Modals = {
namespaced: true,
@ -15,7 +16,8 @@ const Modals = {
ListMembership,
AddListMember,
MuteConfirm,
Shortcut
Shortcut,
Report
},
getters: {
modalOpened: (state, getters, rootState) => {
@ -26,7 +28,8 @@ const Modals = {
const addListMember = rootState.TimelineSpace.Modals.AddListMember.modalOpen
const shortcut = rootState.TimelineSpace.Modals.Shortcut.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
})
}
}
}