From 1cec2b696952ef2c472219329961bc102ed315df Mon Sep 17 00:00:00 2001 From: taehoon Date: Wed, 3 Apr 2019 22:17:42 -0400 Subject: use reusable List vue component instead of withList hoc Using slot is the preferred way in vue --- src/components/user_settings/user_settings.js | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index dd931e67..057d1cec 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -10,29 +10,24 @@ import ScopeSelector from '../scope_selector/scope_selector.vue' import fileSizeFormatService from '../../services/file_size_format/file_size_format.js' import BlockCard from '../block_card/block_card.vue' import MuteCard from '../mute_card/mute_card.vue' +import List from '../list/list.vue' import EmojiInput from '../emoji-input/emoji-input.vue' import Autosuggest from '../autosuggest/autosuggest.vue' import withSubscription from '../../hocs/with_subscription/with_subscription' import withList from '../../hocs/with_list/with_list' import userSearchApi from '../../services/new_api/user_search.js' -const BlockList = compose( - withSubscription({ - fetch: (props, $store) => $store.dispatch('fetchBlocks'), - select: (props, $store) => get($store.state.users.currentUser, 'blockIds', []), - childPropName: 'entries' - }), - withList({ getEntryProps: userId => ({ userId }) }) -)(BlockCard) +const BlockList = withSubscription({ + fetch: (props, $store) => $store.dispatch('fetchBlocks'), + select: (props, $store) => get($store.state.users.currentUser, 'blockIds', []), + childPropName: 'items' +})(List) -const MuteList = compose( - withSubscription({ - fetch: (props, $store) => $store.dispatch('fetchMutes'), - select: (props, $store) => get($store.state.users.currentUser, 'muteIds', []), - childPropName: 'entries' - }), - withList({ getEntryProps: userId => ({ userId }) }) -)(MuteCard) +const MuteList = withSubscription({ + fetch: (props, $store) => $store.dispatch('fetchMutes'), + select: (props, $store) => get($store.state.users.currentUser, 'muteIds', []), + childPropName: 'items' +})(List) const UserSettings = { data () { -- cgit v1.2.3-70-g09d2 From 0bf451bb36c888fe98aa186239ba35d72e533cc7 Mon Sep 17 00:00:00 2001 From: taehoon Date: Wed, 3 Apr 2019 22:31:17 -0400 Subject: remove withList hoc --- src/components/user_profile/user_profile.js | 2 -- src/components/user_settings/user_settings.js | 2 -- src/hocs/with_list/with_list.js | 40 --------------------------- src/hocs/with_list/with_list.scss | 6 ---- 4 files changed, 50 deletions(-) delete mode 100644 src/hocs/with_list/with_list.js delete mode 100644 src/hocs/with_list/with_list.scss (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js index 8dbf8dac..1ef247cd 100644 --- a/src/components/user_profile/user_profile.js +++ b/src/components/user_profile/user_profile.js @@ -1,4 +1,3 @@ -import { compose } from 'vue-compose' import get from 'lodash/get' import UserCard from '../user_card/user_card.vue' import FollowCard from '../follow_card/follow_card.vue' @@ -6,7 +5,6 @@ import Timeline from '../timeline/timeline.vue' import ModerationTools from '../moderation_tools/moderation_tools.vue' import List from '../list/list.vue' import withLoadMore from '../../hocs/with_load_more/with_load_more' -import withList from '../../hocs/with_list/with_list' const FollowerList = withLoadMore({ fetch: (props, $store) => $store.dispatch('fetchFollowers', props.userId), diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 057d1cec..2bbb01db 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -1,4 +1,3 @@ -import { compose } from 'vue-compose' import unescape from 'lodash/unescape' import get from 'lodash/get' import map from 'lodash/map' @@ -14,7 +13,6 @@ import List from '../list/list.vue' import EmojiInput from '../emoji-input/emoji-input.vue' import Autosuggest from '../autosuggest/autosuggest.vue' import withSubscription from '../../hocs/with_subscription/with_subscription' -import withList from '../../hocs/with_list/with_list' import userSearchApi from '../../services/new_api/user_search.js' const BlockList = withSubscription({ diff --git a/src/hocs/with_list/with_list.js b/src/hocs/with_list/with_list.js deleted file mode 100644 index 896f8fc8..00000000 --- a/src/hocs/with_list/with_list.js +++ /dev/null @@ -1,40 +0,0 @@ -import Vue from 'vue' -import map from 'lodash/map' -import isEmpty from 'lodash/isEmpty' -import './with_list.scss' - -const defaultEntryPropsGetter = entry => ({ entry }) -const defaultKeyGetter = entry => entry.id - -const withList = ({ - getEntryProps = defaultEntryPropsGetter, // function to accept entry and index values and return props to be passed into the item component - getKey = defaultKeyGetter // funciton to accept entry and index values and return key prop value -}) => (ItemComponent) => ( - Vue.component('withList', { - props: [ - 'entries', // array of entry - 'entryProps', // additional props to be passed into each entry - 'entryListeners' // additional event listeners to be passed into each entry - ], - render (createElement) { - return ( -
- {map(this.entries, (entry, index) => { - const props = { - key: getKey(entry, index), - props: { - ...this.$props.entryProps, - ...getEntryProps(entry, index) - }, - on: this.$props.entryListeners - } - return - })} - {isEmpty(this.entries) && this.$slots.empty &&
{this.$slots.empty}
} -
- ) - } - }) -) - -export default withList diff --git a/src/hocs/with_list/with_list.scss b/src/hocs/with_list/with_list.scss deleted file mode 100644 index c6e13d5b..00000000 --- a/src/hocs/with_list/with_list.scss +++ /dev/null @@ -1,6 +0,0 @@ -.with-list { - &-empty-content { - text-align: center; - padding: 10px; - } -} \ No newline at end of file -- cgit v1.2.3-70-g09d2 From d9b3f5be4733f0eef4d3c8dff982224cd1a5303e Mon Sep 17 00:00:00 2001 From: taehoon Date: Wed, 3 Apr 2019 22:48:00 -0400 Subject: use SelectableList for blocks/mutes list --- src/components/selectable_list/selectable_list.js | 11 +++++------ src/components/selectable_list/selectable_list.vue | 18 +++++++++++++++--- src/components/user_settings/user_settings.js | 6 +++--- 3 files changed, 23 insertions(+), 12 deletions(-) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/selectable_list/selectable_list.js b/src/components/selectable_list/selectable_list.js index cd431eeb..138e63ab 100644 --- a/src/components/selectable_list/selectable_list.js +++ b/src/components/selectable_list/selectable_list.js @@ -4,12 +4,11 @@ const SelectableList = { components: { Checkbox }, - props: ['checked'], - data () { - }, - computed: { - }, - methods: { + props: { + items: { + type: Array, + default: () => [] + } } } diff --git a/src/components/selectable_list/selectable_list.vue b/src/components/selectable_list/selectable_list.vue index 11853672..2e0671ef 100644 --- a/src/components/selectable_list/selectable_list.vue +++ b/src/components/selectable_list/selectable_list.vue @@ -1,10 +1,22 @@ - + diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 2bbb01db..f8742cd4 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -9,7 +9,7 @@ import ScopeSelector from '../scope_selector/scope_selector.vue' import fileSizeFormatService from '../../services/file_size_format/file_size_format.js' import BlockCard from '../block_card/block_card.vue' import MuteCard from '../mute_card/mute_card.vue' -import List from '../list/list.vue' +import SelectableList from '../selectable_list/selectable_list.vue' import EmojiInput from '../emoji-input/emoji-input.vue' import Autosuggest from '../autosuggest/autosuggest.vue' import withSubscription from '../../hocs/with_subscription/with_subscription' @@ -19,13 +19,13 @@ const BlockList = withSubscription({ fetch: (props, $store) => $store.dispatch('fetchBlocks'), select: (props, $store) => get($store.state.users.currentUser, 'blockIds', []), childPropName: 'items' -})(List) +})(SelectableList) const MuteList = withSubscription({ fetch: (props, $store) => $store.dispatch('fetchMutes'), select: (props, $store) => get($store.state.users.currentUser, 'muteIds', []), childPropName: 'items' -})(List) +})(SelectableList) const UserSettings = { data () { -- cgit v1.2.3-70-g09d2 From 8fa639f252b20ddb550fe0cf71ba7ea2dfe47168 Mon Sep 17 00:00:00 2001 From: taehoon Date: Thu, 4 Apr 2019 13:30:34 -0400 Subject: add bulk action buttons --- src/components/user_settings/user_settings.js | 4 +++- src/components/user_settings/user_settings.vue | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index f8742cd4..022c847b 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -10,6 +10,7 @@ import fileSizeFormatService from '../../services/file_size_format/file_size_for import BlockCard from '../block_card/block_card.vue' import MuteCard from '../mute_card/mute_card.vue' import SelectableList from '../selectable_list/selectable_list.vue' +import ProgressButton from '../progress_button/progress_button.vue' import EmojiInput from '../emoji-input/emoji-input.vue' import Autosuggest from '../autosuggest/autosuggest.vue' import withSubscription from '../../hocs/with_subscription/with_subscription' @@ -73,7 +74,8 @@ const UserSettings = { EmojiInput, Autosuggest, BlockCard, - MuteCard + MuteCard, + ProgressButton }, computed: { user () { diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue index e6100ced..8bce431a 100644 --- a/src/components/user_settings/user_settings.vue +++ b/src/components/user_settings/user_settings.vue @@ -201,6 +201,22 @@ + @@ -282,5 +298,15 @@ &-usersearch-wrapper { padding: 1em; } + + .bulk-actions-wrapper { + text-align: right; + padding: 0 1em; + min-height: 28px; + + button { + width: 10em; + } + } } -- cgit v1.2.3-70-g09d2 From 13c8f10f4b42c1d698bc99694cd3556c691ac880 Mon Sep 17 00:00:00 2001 From: taehoon Date: Thu, 4 Apr 2019 13:54:52 -0400 Subject: wire up bulk action buttons to vuex --- src/components/user_settings/user_settings.js | 6 +++++ src/components/user_settings/user_settings.vue | 4 +-- src/modules/users.js | 36 ++++++++++++++++++-------- 3 files changed, 33 insertions(+), 13 deletions(-) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 022c847b..a9fe84b8 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -355,6 +355,12 @@ const UserSettings = { this.$store.dispatch('addNewUsers', users) return map(users, 'id') }) + }, + blockUsers (ids) { + return this.$store.dispatch('blockUsers', ids) + }, + unblockUsers (ids) { + return this.$store.dispatch('unblockUsers', ids) } } } diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue index 8bce431a..5e0b71bf 100644 --- a/src/components/user_settings/user_settings.vue +++ b/src/components/user_settings/user_settings.vue @@ -203,13 +203,13 @@