Skip to content

Commit bd11a2a

Browse files
mattwr18roschaefer
authored andcommitted
Separate blockButton to own component
Add transform object rest spread babel plugin
1 parent dcc4fca commit bd11a2a

File tree

5 files changed

+68
-19
lines changed

5 files changed

+68
-19
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,63 @@
11
<template>
2+
<div v-if="service === 'users'" class="columns is-mobile field has-text-centered">
3+
<div v-if="BlockButton">
4+
<div class="column control has-text-centered">
5+
<hc-button color="button"
6+
:disabled="blacklistPending"
7+
:isLoading="blacklistPending"
8+
@click="toggleBlacklist">
9+
<template v-if="isBlacklisted">
10+
<hc-icon icon="ban" :class="['icon-left', 'is-danger']" /> {{ $t('component.blacklist.buttonLabelUnblock') }}
11+
</template>
12+
<template v-else>
13+
<hc-icon icon="ban" class="icon-left" /> {{ $t('component.blacklist.buttonLabelBlock') }}
14+
</template>
15+
</hc-button>
16+
</div>
17+
</div>
18+
</div>
219
</template>
320
<script>
21+
import {mapGetters} from 'vuex'
22+
import blacklistable from '../../../mixins/blacklistable'
23+
24+
export default {
25+
name: 'hc-block-button',
26+
mixins: [blacklistable],
27+
props: {
28+
BlockButton: {
29+
type: Boolean,
30+
default: false
31+
},
32+
entity: {
33+
type: Object,
34+
required: true
35+
},
36+
service: {
37+
type: String, // users, organizations
38+
default: 'users'
39+
}
40+
},
41+
data () {
42+
return {
43+
connected: false,
44+
ready: false
45+
}
46+
},
47+
computed: {
48+
...mapGetters({
49+
loggedInUser: 'auth/user'
50+
})
51+
},
52+
methods: {
53+
author(){
54+
return this.entity;
55+
},
56+
}
57+
}
458
</script>
59+
<style lang="scss" scoped>
60+
@import "assets/styles/utilities";
61+
62+
63+
</style>

components/Global/Elements/Follow/FollowButtons.vue

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<hc-button color="button is-fullwidth"
2020
:class="{'is-primary': !follow.isPending && !follow.isFollowing}"
2121
@click="toggleFollow"
22-
:disabled="follow.isPending || isBlacklisted"
22+
:disabled="follow.isPending"
2323
:isLoading="follow.isPending">
2424
<template v-if="follow.isFollowing">
2525
<hc-icon icon="check" class="icon-left" /> {{ $t('component.follow.buttonLabelUnFollow') }}
@@ -40,31 +40,14 @@
4040
</hc-button>
4141
</div>
4242
</div>
43-
<div v-if="service === 'users'" class="columns is-mobile field has-text-centered">
44-
<div class="column control has-text-centered">
45-
<hc-button color="button"
46-
:disabled="blacklistPending || follow.isFollowing"
47-
:isLoading="blacklistPending"
48-
@click="toggleBlacklist">
49-
<template v-if="isBlacklisted">
50-
<hc-icon icon="ban" :class="['icon-left', 'is-danger']" /> {{ $t('component.blacklist.buttonLabelUnblock') }}
51-
</template>
52-
<template v-else>
53-
<hc-icon icon="ban" class="icon-left" /> {{ $t('component.blacklist.buttonLabelBlock') }}
54-
</template>
55-
</hc-button>
56-
</div>
57-
</div>
5843
</div>
5944
</template>
6045

6146
<script>
6247
import { mapGetters } from 'vuex'
63-
import blacklistable from '~/components/mixins/blacklistable'
6448
6549
export default {
6650
name: 'hc-follow-buttons',
67-
mixins: [blacklistable],
6851
props: {
6952
showButtons: {
7053
type: Boolean,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"@nuxtjs/pwa": "~2.0.5",
5252
"axios": "^0.18.0",
5353
"babel-eslint": "~8.2.5",
54+
"babel-plugin-transform-object-rest-spread": "^6.26.0",
5455
"babel-preset-vue-app": "~2.0.0",
5556
"body-parser": "~1.18.3",
5657
"body-scroll-lock": "^2.4.6",

pages/profile/_slug.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
<hc-follow-buttons v-if="user"
4242
:showButtons="!isOwner"
4343
:entity="user" />
44+
45+
<hc-block-button v-if="user"
46+
:BlockButton="!isOwner"
47+
:entity="user" />
4448
<div v-if="false" class="hc-shortcuts level under-construction">
4549
<!-- TODO: replace the cdn images with local hc icons -->
4650
<div class="level-item has-text-centered">
@@ -140,6 +144,7 @@
140144
import {mapGetters} from 'vuex'
141145
import FollowerItem from '~/components/Profile/FollowerItem/FollowerItem.vue'
142146
import FollowButtons from '~/components/Global/Elements/Follow/FollowButtons.vue'
147+
import BlockButton from '~/components/Global/Elements/BlockButton/BlockButton'
143148
import Map from '~/components/Map/Map.vue'
144149
import Timeline from '~/components/layout/Timeline'
145150
import Badges from '~/components/Profile/Badges/Badges'
@@ -150,6 +155,7 @@
150155
components: {
151156
'hc-follower-item': FollowerItem,
152157
'hc-follow-buttons': FollowButtons,
158+
'hc-block-button': BlockButton,
153159
'hc-profile-badges': Badges,
154160
'hc-map': Map,
155161
'hc-timeline': Timeline

test/helpers/setup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ require('browser-env')()
66
// Setup vue files to be processed by `require-extension-hooks-vue`
77
hooks('vue').plugin('vue').push()
88
// Setup vue and js files to be processed by `require-extension-hooks-babel`
9-
hooks(['vue', 'js']).plugin('babel').push()
9+
hooks(['vue', 'js']).plugin('babel', { plugins: ['transform-object-rest-spread'] }).push()

0 commit comments

Comments
 (0)