非ログイン時の警告処理 (#5219)

* Update note-mixin.ts

* Update note-mixin.ts

* ✌️

* Update note-mixin.ts

* Update note-menu.vue
This commit is contained in:
syuilo 2019-07-28 10:35:53 +09:00 committed by GitHub
parent 8ec6b2ec11
commit 66409029e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 104 additions and 65 deletions

View file

@ -37,6 +37,7 @@ common:
reload-to-apply-the-setting: "この設定を反映するにはページをリロードする必要があります。今すぐリロードしますか?" reload-to-apply-the-setting: "この設定を反映するにはページをリロードする必要があります。今すぐリロードしますか?"
fetching-as-ap-object: "連合に照会中" fetching-as-ap-object: "連合に照会中"
unfollow-confirm: "{name}さんをフォロー解除しますか?" unfollow-confirm: "{name}さんをフォロー解除しますか?"
signin-required: "ログインしてください"
notification-type: "通知の種類" notification-type: "通知の種類"
notification-types: notification-types:
all: "すべて" all: "すべて"

View file

@ -3,6 +3,7 @@ import { sum, unique } from '../../../../prelude/array';
import shouldMuteNote from './should-mute-note'; import shouldMuteNote from './should-mute-note';
import MkNoteMenu from '../views/components/note-menu.vue'; import MkNoteMenu from '../views/components/note-menu.vue';
import MkReactionPicker from '../views/components/reaction-picker.vue'; import MkReactionPicker from '../views/components/reaction-picker.vue';
import pleaseLogin from './please-login';
function focus(el, fn) { function focus(el, fn) {
const target = fn(el); const target = fn(el);
@ -108,6 +109,7 @@ export default (opts: Opts = {}) => ({
methods: { methods: {
reply(viaKeyboard = false) { reply(viaKeyboard = false) {
pleaseLogin(this.$root);
this.$root.$post({ this.$root.$post({
reply: this.appearNote, reply: this.appearNote,
animation: !viaKeyboard, animation: !viaKeyboard,
@ -118,6 +120,7 @@ export default (opts: Opts = {}) => ({
}, },
renote(viaKeyboard = false) { renote(viaKeyboard = false) {
pleaseLogin(this.$root);
this.$root.$post({ this.$root.$post({
renote: this.appearNote, renote: this.appearNote,
animation: !viaKeyboard, animation: !viaKeyboard,
@ -134,6 +137,7 @@ export default (opts: Opts = {}) => ({
}, },
react(viaKeyboard = false) { react(viaKeyboard = false) {
pleaseLogin(this.$root);
this.blur(); this.blur();
this.$root.new(MkReactionPicker, { this.$root.new(MkReactionPicker, {
source: this.$refs.reactButton, source: this.$refs.reactButton,
@ -159,6 +163,7 @@ export default (opts: Opts = {}) => ({
}, },
favorite() { favorite() {
pleaseLogin(this.$root);
this.$root.api('notes/favorites/create', { this.$root.api('notes/favorites/create', {
noteId: this.appearNote.id noteId: this.appearNote.id
}).then(() => { }).then(() => {

View file

@ -0,0 +1,10 @@
export default ($root: any) => {
if ($root.$store.getters.isSignedIn) return;
$root.dialog({
title: $root.$t('@.signin-required'),
text: null
});
throw new Error('signin required');
};

View file

@ -22,72 +22,95 @@ export default Vue.extend({
}, },
computed: { computed: {
items(): any[] { items(): any[] {
return [{ if (this.$store.getters.isSignedIn) {
icon: 'at', return [{
text: this.$t('mention'), icon: 'at',
action: this.mention text: this.$t('mention'),
}, null, { action: this.mention
icon: 'info-circle', }, null, {
text: this.$t('detail'), icon: 'info-circle',
action: this.detail text: this.$t('detail'),
}, { action: this.detail
icon: faCopy, }, {
text: this.$t('copy-content'), icon: faCopy,
action: this.copyContent text: this.$t('copy-content'),
}, { action: this.copyContent
icon: 'link', }, {
text: this.$t('copy-link'), icon: 'link',
action: this.copyLink text: this.$t('copy-link'),
}, this.note.uri ? { action: this.copyLink
icon: 'external-link-square-alt', }, this.note.uri ? {
text: this.$t('remote'), icon: 'external-link-square-alt',
action: () => { text: this.$t('remote'),
window.open(this.note.uri, '_blank'); action: () => {
} window.open(this.note.uri, '_blank');
} : undefined, }
null,
this.isFavorited ? {
icon: 'star',
text: this.$t('unfavorite'),
action: () => this.toggleFavorite(false)
} : {
icon: 'star',
text: this.$t('favorite'),
action: () => this.toggleFavorite(true)
},
this.note.userId != this.$store.state.i.id ? this.isWatching ? {
icon: faEyeSlash,
text: this.$t('unwatch'),
action: () => this.toggleWatch(false)
} : {
icon: faEye,
text: this.$t('watch'),
action: () => this.toggleWatch(true)
} : undefined,
this.note.userId == this.$store.state.i.id ? (this.$store.state.i.pinnedNoteIds || []).includes(this.note.id) ? {
icon: 'thumbtack',
text: this.$t('unpin'),
action: () => this.togglePin(false)
} : {
icon: 'thumbtack',
text: this.$t('pin'),
action: () => this.togglePin(true)
} : undefined,
...(this.note.userId == this.$store.state.i.id || this.$store.state.i.isAdmin || this.$store.state.i.isModerator ? [
null,
this.note.userId == this.$store.state.i.id ? {
icon: 'undo-alt',
text: this.$t('delete-and-edit'),
action: this.deleteAndEdit
} : undefined, } : undefined,
{ null,
icon: ['far', 'trash-alt'], this.isFavorited ? {
text: this.$t('delete'), icon: 'star',
action: this.del text: this.$t('unfavorite'),
}] action: () => this.toggleFavorite(false)
: [] } : {
)] icon: 'star',
.filter(x => x !== undefined) text: this.$t('favorite'),
action: () => this.toggleFavorite(true)
},
this.note.userId != this.$store.state.i.id ? this.isWatching ? {
icon: faEyeSlash,
text: this.$t('unwatch'),
action: () => this.toggleWatch(false)
} : {
icon: faEye,
text: this.$t('watch'),
action: () => this.toggleWatch(true)
} : undefined,
this.note.userId == this.$store.state.i.id ? (this.$store.state.i.pinnedNoteIds || []).includes(this.note.id) ? {
icon: 'thumbtack',
text: this.$t('unpin'),
action: () => this.togglePin(false)
} : {
icon: 'thumbtack',
text: this.$t('pin'),
action: () => this.togglePin(true)
} : undefined,
...(this.note.userId == this.$store.state.i.id || this.$store.state.i.isAdmin || this.$store.state.i.isModerator ? [
null,
this.note.userId == this.$store.state.i.id ? {
icon: 'undo-alt',
text: this.$t('delete-and-edit'),
action: this.deleteAndEdit
} : undefined,
{
icon: ['far', 'trash-alt'],
text: this.$t('delete'),
action: this.del
}]
: []
)]
.filter(x => x !== undefined);
} else {
return [{
icon: 'info-circle',
text: this.$t('detail'),
action: this.detail
}, {
icon: faCopy,
text: this.$t('copy-content'),
action: this.copyContent
}, {
icon: 'link',
text: this.$t('copy-link'),
action: this.copyLink
}, this.note.uri ? {
icon: 'external-link-square-alt',
text: this.$t('remote'),
action: () => {
window.open(this.note.uri, '_blank');
}
} : undefined]
.filter(x => x !== undefined);
}
} }
}, },