From 789fa36e1ac4a92b58400f5fb9db1ccd77c0f522 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Sat, 6 Jun 2020 22:16:25 +0300 Subject: [PATCH] Replace checking if acccount is valid with checking if property exists --- src/components/Status/index.vue | 30 +++++---- src/lang/en.js | 2 +- src/views/reports/components/Report.vue | 63 +++++++++++-------- .../users/components/MultipleUsersMenu.vue | 28 ++++----- src/views/users/index.vue | 15 +++-- src/views/users/show.vue | 38 +++++------ 6 files changed, 96 insertions(+), 80 deletions(-) diff --git a/src/components/Status/index.vue b/src/components/Status/index.vue index 5f430c28..bde254e5 100644 --- a/src/components/Status/index.vue +++ b/src/components/Status/index.vue @@ -6,12 +6,15 @@
@@ -202,8 +205,8 @@ export default { }) }) }, - isValid(account) { - return account.nickname && account.id + handleStatusSelection(account) { + this.$emit('status-selection', account) }, optionPercent(poll, pollOption) { const allVotes = poll.options.reduce((acc, option) => (acc + option.votes_count), 0) @@ -215,8 +218,11 @@ export default { parseTimestamp(timestamp) { return moment(timestamp).format('YYYY-MM-DD HH:mm') }, - handleStatusSelection(account) { - this.$emit('status-selection', account) + propertyExists(account, property, _secondProperty) { + if (_secondProperty) { + return account[property] && account[_secondProperty] + } + return account[property] } } } @@ -232,7 +238,7 @@ export default { } .deactivated { color: gray; - line-height: 32px; + line-height: 28px; vertical-align: middle; } .image { @@ -257,7 +263,9 @@ export default { .status-account-name { display: inline-block; margin: 0; - height: 22px; + height: 28px; + font-size: 15px; + font-weight: 500; } .status-body { display: flex; diff --git a/src/lang/en.js b/src/lang/en.js index 7eee1950..c1f610a1 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -239,7 +239,7 @@ export default { confirmAccount: 'Confirm account', confirmAccounts: 'Confirm accounts', resendConfirmation: 'Resend confirmation email', - invalidUser: 'This account is invalid and can\'t be modified', + invalidAccount: 'This account has invalid nickname and can\'t be modified', invalidNickname: 'invalid nickname' }, statuses: { diff --git a/src/views/reports/components/Report.vue b/src/views/reports/components/Report.vue index cead25a5..cd938c91 100644 --- a/src/views/reports/components/Report.vue +++ b/src/views/reports/components/Report.vue @@ -10,9 +10,9 @@
-

{{ $t('reports.reportOn') }} {{ report.account.nickname }}

+

{{ $t('reports.reportOn') }} {{ report.account.nickname }}

{{ $t('reports.report') }}

-
{{ $t('reports.id') }}: {{ report.id }}
+
{{ $t('reports.id') }}: {{ report.id }}
{{ capitalizeFirstLetter(report.state) }} @@ -24,26 +24,26 @@ {{ $t('reports.close') }} - +
{{ $t('reports.account') }}: - - avatar - - + avatar + + + + - ({{ $t('reports.notFound') }})
@@ -54,16 +54,20 @@
{{ $t('reports.actor') }}: - - avatar - + avatar + + + + - ({{ $t('reports.notFound') }})
@@ -171,12 +175,15 @@ export default { handlePageChange(page) { this.$store.dispatch('FetchReports', page) }, - isValid(account) { - return account.nickname && account.id - }, parseTimestamp(timestamp) { return moment(timestamp).format('L HH:mm') }, + propertyExists(account, property, _secondProperty) { + if (_secondProperty) { + return account[property] && account[_secondProperty] + } + return account[property] + }, showStatuses(statuses = []) { return statuses.length > 0 } @@ -262,6 +269,10 @@ export default { font-style: italic; color: gray; } + .report-account-name { + font-size: 15px; + font-weight: 500; + } .report-row-key { font-size: 14px; font-weight: 500; diff --git a/src/views/users/components/MultipleUsersMenu.vue b/src/views/users/components/MultipleUsersMenu.vue index 70883598..8af223fd 100644 --- a/src/views/users/components/MultipleUsersMenu.vue +++ b/src/views/users/components/MultipleUsersMenu.vue @@ -165,33 +165,33 @@ export default { } return { grantRight: (right) => () => { - const filterUsersFn = user => this.isValid(user) && user.local && !user.roles[right] && this.$store.state.user.id !== user.id + const filterUsersFn = user => this.isLocalUser(user) && !user.roles[right] && this.$store.state.user.id !== user.id const addRightFn = async(users) => await this.$store.dispatch('AddRight', { users, right }) const filtered = this.selectedUsers.filter(filterUsersFn) applyAction(filtered, addRightFn) }, revokeRight: (right) => () => { - const filterUsersFn = user => this.isValid(user) && user.local && user.roles[right] && this.$store.state.user.id !== user.id + const filterUsersFn = user => this.isLocalUser(user) && user.roles[right] && this.$store.state.user.id !== user.id const deleteRightFn = async(users) => await this.$store.dispatch('DeleteRight', { users, right }) const filtered = this.selectedUsers.filter(filterUsersFn) applyAction(filtered, deleteRightFn) }, activate: () => { - const filtered = this.selectedUsers.filter(user => this.isValid(user) && user.deactivated && this.$store.state.user.id !== user.id) + const filtered = this.selectedUsers.filter(user => user.nickname && user.deactivated && this.$store.state.user.id !== user.id) const activateUsersFn = async(users) => await this.$store.dispatch('ActivateUsers', { users }) applyAction(filtered, activateUsersFn) }, deactivate: () => { - const filtered = this.selectedUsers.filter(user => this.isValid(user) && !user.deactivated && this.$store.state.user.id !== user.id) + const filtered = this.selectedUsers.filter(user => user.nickname && !user.deactivated && this.$store.state.user.id !== user.id) const deactivateUsersFn = async(users) => await this.$store.dispatch('DeactivateUsers', { users }) applyAction(filtered, deactivateUsersFn) }, remove: () => { - const filtered = this.selectedUsers.filter(user => this.isValid(user) && this.$store.state.user.id !== user.id) + const filtered = this.selectedUsers.filter(user => user.nickname && this.$store.state.user.id !== user.id) const deleteAccountFn = async(users) => await this.$store.dispatch('DeleteUsers', { users }) applyAction(filtered, deleteAccountFn) @@ -199,42 +199,42 @@ export default { addTag: (tag) => () => { const filtered = this.selectedUsers.filter(user => tag === 'disable_remote_subscription' || tag === 'disable_any_subscription' - ? this.isValid(user) && user.local && !user.tags.includes(tag) - : this.isValid(user) && !user.tags.includes(tag)) + ? this.isLocalUser(user) && !user.tags.includes(tag) + : user.nickname && !user.tags.includes(tag)) const addTagFn = async(users) => await this.$store.dispatch('AddTag', { users, tag }) applyAction(filtered, addTagFn) }, removeTag: (tag) => async() => { const filtered = this.selectedUsers.filter(user => tag === 'disable_remote_subscription' || tag === 'disable_any_subscription' - ? this.isValid(user) && user.local && user.tags.includes(tag) - : this.isValid(user) && user.tags.includes(tag)) + ? this.isLocalUser(user) && user.tags.includes(tag) + : user.nickname && user.tags.includes(tag)) const removeTagFn = async(users) => await this.$store.dispatch('RemoveTag', { users, tag }) applyAction(filtered, removeTagFn) }, requirePasswordReset: () => { - const filtered = this.selectedUsers.filter(user => this.isValid(user) && user.local) + const filtered = this.selectedUsers.filter(user => this.isLocalUser(user)) const requirePasswordResetFn = async(users) => await this.$store.dispatch('RequirePasswordReset', users) applyAction(filtered, requirePasswordResetFn) }, confirmAccounts: () => { - const filtered = this.selectedUsers.filter(user => this.isValid(user) && user.local && user.confirmation_pending) + const filtered = this.selectedUsers.filter(user => this.isLocalUser(user) && user.confirmation_pending) const confirmAccountFn = async(users) => await this.$store.dispatch('ConfirmUsersEmail', { users }) applyAction(filtered, confirmAccountFn) }, resendConfirmation: () => { - const filtered = this.selectedUsers.filter(user => this.isValid(user) && user.local && user.confirmation_pending) + const filtered = this.selectedUsers.filter(user => this.isLocalUser(user) && user.confirmation_pending) const resendConfirmationFn = async(users) => await this.$store.dispatch('ResendConfirmationEmail', users) applyAction(filtered, resendConfirmationFn) } } }, - isValid(user) { - return user.nickname && user.id + isLocalUser(user) { + return user.nickname && user.local }, grantRightToMultipleUsers(right) { const { grantRight } = this.mappers() diff --git a/src/views/users/index.vue b/src/views/users/index.vue index d2f5d00c..91893560 100644 --- a/src/views/users/index.vue +++ b/src/views/users/index.vue @@ -76,11 +76,14 @@ @@ -217,12 +220,12 @@ export default { handleSelectionChange(value) { this.$data.selectedUsers = value }, - isValid(user) { - return user.nickname && user.id - }, openResetPasswordDialog() { this.resetPasswordDialogOpen = true }, + propertyExists(account, property) { + return account[property] + }, showDeactivatedButton(id) { return this.$store.state.user.id !== id } @@ -262,7 +265,7 @@ export default { .create-account > .el-icon-plus { margin-right: 5px; } -.invalid-user { +.invalid-account { color: gray; } .users-header-container { diff --git a/src/views/users/show.vue b/src/views/users/show.vue index c8a71b08..ff8fd75e 100644 --- a/src/views/users/show.vue +++ b/src/views/users/show.vue @@ -2,13 +2,13 @@
- -

{{ user.nickname }}

+ +

{{ user.nickname }}

({{ $t('users.invalidNickname') }})

@@ -18,14 +18,14 @@
- -

{{ user.nickname }}

+ +

{{ user.nickname }}

({{ $t('users.invalidNickname') }})

@@ -46,17 +46,11 @@