From 188b6f56ed2f983d8f0fba4dc8f7327ebbee321d Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Mon, 30 Sep 2019 20:34:51 +0300 Subject: [PATCH] added acccount_actions component --- .../account_actions/account_actions.js | 59 ++++++++ .../account_actions/account_actions.vue | 133 +++++++++++++++++ src/components/follow_button/follow_button.js | 58 ++++++++ .../follow_button/follow_button.vue | 13 ++ src/components/user_card/user_card.js | 48 +------ src/components/user_card/user_card.vue | 135 +----------------- 6 files changed, 268 insertions(+), 178 deletions(-) create mode 100644 src/components/account_actions/account_actions.js create mode 100644 src/components/account_actions/account_actions.vue create mode 100644 src/components/follow_button/follow_button.js create mode 100644 src/components/follow_button/follow_button.vue diff --git a/src/components/account_actions/account_actions.js b/src/components/account_actions/account_actions.js new file mode 100644 index 00000000..1092a96a --- /dev/null +++ b/src/components/account_actions/account_actions.js @@ -0,0 +1,59 @@ +import FollowButton from '../follow_button/follow_button.vue' +import ProgressButton from '../progress_button/progress_button.vue' + +const AccountActions = { + props: [ + 'user' + ], + data () { + return { + showDropDown: false + } + }, + components: { + FollowButton, + ProgressButton + }, + computed: { + tagsSet () { + return new Set(this.user.tags) + }, + hasTagPolicy () { + return this.$store.state.instance.tagPolicyAvailable + } + }, + methods: { + subscribeUser () { + return this.$store.dispatch('subscribeUser', this.user.id) + }, + unsubscribeUser () { + return this.$store.dispatch('unsubscribeUser', this.user.id) + }, + showRepeats () { + this.$store.dispatch('showReblogs', this.user.id) + }, + hideRepeats () { + this.$store.dispatch('hideReblogs', this.user.id) + }, + muteUser () { + this.$store.dispatch('muteUser', this.user.id) + }, + unmuteUser () { + this.$store.dispatch('unmuteUser', this.user.id) + }, + blockUser () { + this.$store.dispatch('blockUser', this.user.id) + }, + unblockUser () { + this.$store.dispatch('unblockUser', this.user.id) + }, + reportUser () { + this.$store.dispatch('openUserReportingModal', this.user.id) + }, + mentionUser () { + this.$store.dispatch('openPostStatusModal', { replyTo: true, repliedUser: this.user }) + } + } +} + +export default AccountActions diff --git a/src/components/account_actions/account_actions.vue b/src/components/account_actions/account_actions.vue new file mode 100644 index 00000000..ce508b0a --- /dev/null +++ b/src/components/account_actions/account_actions.vue @@ -0,0 +1,133 @@ + + + + + diff --git a/src/components/follow_button/follow_button.js b/src/components/follow_button/follow_button.js new file mode 100644 index 00000000..9d2834ab --- /dev/null +++ b/src/components/follow_button/follow_button.js @@ -0,0 +1,58 @@ +import { requestFollow, requestUnfollow } from '../../services/follow_manipulate/follow_manipulate' +export default { + props: ['user'], + data () { + return { + inProgress: false + } + }, + computed: { + isPressed () { + return this.inProgress || this.user.following + }, + title () { + if (this.inProgress || this.user.following) { + return 'user_card.follow_unfollow' + } else if (this.user.requested) { + return 'user_card.follow_again' + } else { + return '' + } + }, + label () { + if (this.inProgress) { + return 'user_card.follow_progress' + } else if (this.user.following) { + return 'user_card.following' + } else if (this.user.requested) { + return 'user_card.follow_sent' + } else { + return 'user_card.follow' + } + } + }, + methods: { + doClick () { + if (this.user.following) { + this.unfollowUser() + } else { + this.followUser() + } + }, + followUser () { + const store = this.$store + this.inProgress = true + requestFollow(this.user, store).then(() => { + this.inProgress = false + }) + }, + unfollowUser () { + const store = this.$store + this.inProgress = true + requestUnfollow(this.user, store).then(() => { + this.inProgress = false + store.commit('removeStatus', { timeline: 'friends', userId: this.user.id }) + }) + } + } +} diff --git a/src/components/follow_button/follow_button.vue b/src/components/follow_button/follow_button.vue new file mode 100644 index 00000000..61aa75a0 --- /dev/null +++ b/src/components/follow_button/follow_button.vue @@ -0,0 +1,13 @@ + + + diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js index 015a5762..c09e5654 100644 --- a/src/components/user_card/user_card.js +++ b/src/components/user_card/user_card.js @@ -2,8 +2,8 @@ import UserAvatar from '../user_avatar/user_avatar.vue' import RemoteFollow from '../remote_follow/remote_follow.vue' import ProgressButton from '../progress_button/progress_button.vue' import ModerationTools from '../moderation_tools/moderation_tools.vue' +import AccountActions from '../account_actions/account_actions.vue' import { hex2rgb } from '../../services/color_convert/color_convert.js' -import { requestFollow, requestUnfollow } from '../../services/follow_manipulate/follow_manipulate' import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' export default { @@ -98,48 +98,10 @@ export default { UserAvatar, RemoteFollow, ModerationTools, + AccountActions, ProgressButton }, methods: { - showRepeats () { - this.$store.dispatch('showReblogs', this.user.id) - }, - hideRepeats () { - this.$store.dispatch('hideReblogs', this.user.id) - }, - followUser () { - const store = this.$store - this.followRequestInProgress = true - requestFollow(this.user, store).then(() => { - this.followRequestInProgress = false - }) - }, - unfollowUser () { - const store = this.$store - this.followRequestInProgress = true - requestUnfollow(this.user, store).then(() => { - this.followRequestInProgress = false - store.commit('removeStatus', { timeline: 'friends', userId: this.user.id }) - }) - }, - blockUser () { - this.$store.dispatch('blockUser', this.user.id) - }, - unblockUser () { - this.$store.dispatch('unblockUser', this.user.id) - }, - muteUser () { - this.$store.dispatch('muteUser', this.user.id) - }, - unmuteUser () { - this.$store.dispatch('unmuteUser', this.user.id) - }, - subscribeUser () { - return this.$store.dispatch('subscribeUser', this.user.id) - }, - unsubscribeUser () { - return this.$store.dispatch('unsubscribeUser', this.user.id) - }, setProfileView (v) { if (this.switcher) { const store = this.$store @@ -160,9 +122,6 @@ export default { this.$store.state.instance.restrictedNicknames ) }, - reportUser () { - this.$store.dispatch('openUserReportingModal', this.user.id) - }, zoomAvatar () { const attachment = { url: this.user.profile_image_url_original, @@ -170,9 +129,6 @@ export default { } this.$store.dispatch('setMedia', [attachment]) this.$store.dispatch('setCurrent', attachment) - }, - mentionUser () { - this.$store.dispatch('openPostStatusModal', { replyTo: true, repliedUser: this.user }) } } } diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue index f465467c..abaef85f 100644 --- a/src/components/user_card/user_card.vue +++ b/src/components/user_card/user_card.vue @@ -131,135 +131,12 @@ +
-
- -
-
- -
-
- - - - - - - - - -
- -
- -
- -
- - -
- -
- - -
- -
- -
- + * { - flex: 1 0 0; - margin: 0 .75em .6em 0; - white-space: nowrap; - } - button { margin: 0;