From bcebec478e43b3851e85c94335940e8fc7546cc8 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 10 May 2020 06:46:06 +0300 Subject: moved stuff from settings, cleaned up naming for tabs, added close and peek --- src/components/user_settings/confirm.js | 9 -- src/components/user_settings/confirm.vue | 22 --- src/components/user_settings/mfa.js | 155 ------------------- src/components/user_settings/mfa.vue | 173 ---------------------- src/components/user_settings/mfa_backup_codes.js | 17 --- src/components/user_settings/mfa_backup_codes.vue | 33 ----- src/components/user_settings/mfa_totp.js | 49 ------ src/components/user_settings/mfa_totp.vue | 43 ------ src/components/user_settings/user_settings.js | 140 ----------------- src/components/user_settings/user_settings.vue | 119 --------------- 10 files changed, 760 deletions(-) delete mode 100644 src/components/user_settings/confirm.js delete mode 100644 src/components/user_settings/confirm.vue delete mode 100644 src/components/user_settings/mfa.js delete mode 100644 src/components/user_settings/mfa.vue delete mode 100644 src/components/user_settings/mfa_backup_codes.js delete mode 100644 src/components/user_settings/mfa_backup_codes.vue delete mode 100644 src/components/user_settings/mfa_totp.js delete mode 100644 src/components/user_settings/mfa_totp.vue delete mode 100644 src/components/user_settings/user_settings.js delete mode 100644 src/components/user_settings/user_settings.vue (limited to 'src/components/user_settings') diff --git a/src/components/user_settings/confirm.js b/src/components/user_settings/confirm.js deleted file mode 100644 index 0f4ddfc9..00000000 --- a/src/components/user_settings/confirm.js +++ /dev/null @@ -1,9 +0,0 @@ -const Confirm = { - props: ['disabled'], - data: () => ({}), - methods: { - confirm () { this.$emit('confirm') }, - cancel () { this.$emit('cancel') } - } -} -export default Confirm diff --git a/src/components/user_settings/confirm.vue b/src/components/user_settings/confirm.vue deleted file mode 100644 index 69b3811b..00000000 --- a/src/components/user_settings/confirm.vue +++ /dev/null @@ -1,22 +0,0 @@ - - - diff --git a/src/components/user_settings/mfa.js b/src/components/user_settings/mfa.js deleted file mode 100644 index abf37062..00000000 --- a/src/components/user_settings/mfa.js +++ /dev/null @@ -1,155 +0,0 @@ -import RecoveryCodes from './mfa_backup_codes.vue' -import TOTP from './mfa_totp.vue' -import Confirm from './confirm.vue' -import VueQrcode from '@chenfengyuan/vue-qrcode' -import { mapState } from 'vuex' - -const Mfa = { - data: () => ({ - settings: { // current settings of MFA - available: false, - enabled: false, - totp: false - }, - setupState: { // setup mfa - state: '', // state of setup. '' -> 'getBackupCodes' -> 'setupOTP' -> 'complete' - setupOTPState: '' // state of setup otp. '' -> 'prepare' -> 'confirm' -> 'complete' - }, - backupCodes: { - getNewCodes: false, - inProgress: false, // progress of fetch codes - codes: [] - }, - otpSettings: { // pre-setup setting of OTP. secret key, qrcode url. - provisioning_uri: '', - key: '' - }, - currentPassword: null, - otpConfirmToken: null, - error: null, - readyInit: false - }), - components: { - 'recovery-codes': RecoveryCodes, - 'totp-item': TOTP, - 'qrcode': VueQrcode, - 'confirm': Confirm - }, - computed: { - canSetupOTP () { - return ( - (this.setupInProgress && this.backupCodesPrepared) || - this.settings.enabled - ) && !this.settings.totp && !this.setupOTPInProgress - }, - setupInProgress () { - return this.setupState.state !== '' && this.setupState.state !== 'complete' - }, - setupOTPInProgress () { - return this.setupState.state === 'setupOTP' && !this.completedOTP - }, - prepareOTP () { - return this.setupState.setupOTPState === 'prepare' - }, - confirmOTP () { - return this.setupState.setupOTPState === 'confirm' - }, - completedOTP () { - return this.setupState.setupOTPState === 'completed' - }, - backupCodesPrepared () { - return !this.backupCodes.inProgress && this.backupCodes.codes.length > 0 - }, - confirmNewBackupCodes () { - return this.backupCodes.getNewCodes - }, - ...mapState({ - backendInteractor: (state) => state.api.backendInteractor - }) - }, - - methods: { - activateOTP () { - if (!this.settings.enabled) { - this.setupState.state = 'getBackupcodes' - this.fetchBackupCodes() - } - }, - fetchBackupCodes () { - this.backupCodes.inProgress = true - this.backupCodes.codes = [] - - return this.backendInteractor.generateMfaBackupCodes() - .then((res) => { - this.backupCodes.codes = res.codes - this.backupCodes.inProgress = false - }) - }, - getBackupCodes () { // get a new backup codes - this.backupCodes.getNewCodes = true - }, - confirmBackupCodes () { // confirm getting new backup codes - this.fetchBackupCodes().then((res) => { - this.backupCodes.getNewCodes = false - }) - }, - cancelBackupCodes () { // cancel confirm form of new backup codes - this.backupCodes.getNewCodes = false - }, - - // Setup OTP - setupOTP () { // prepare setup OTP - this.setupState.state = 'setupOTP' - this.setupState.setupOTPState = 'prepare' - this.backendInteractor.mfaSetupOTP() - .then((res) => { - this.otpSettings = res - this.setupState.setupOTPState = 'confirm' - }) - }, - doConfirmOTP () { // handler confirm enable OTP - this.error = null - this.backendInteractor.mfaConfirmOTP({ - token: this.otpConfirmToken, - password: this.currentPassword - }) - .then((res) => { - if (res.error) { - this.error = res.error - return - } - this.completeSetup() - }) - }, - - completeSetup () { - this.setupState.setupOTPState = 'complete' - this.setupState.state = 'complete' - this.currentPassword = null - this.error = null - this.fetchSettings() - }, - cancelSetup () { // cancel setup - this.setupState.setupOTPState = '' - this.setupState.state = '' - this.currentPassword = null - this.error = null - }, - // end Setup OTP - - // fetch settings from server - async fetchSettings () { - let result = await this.backendInteractor.settingsMFA() - if (result.error) return - this.settings = result.settings - this.settings.available = true - return result - } - }, - mounted () { - this.fetchSettings().then(() => { - this.readyInit = true - }) - } -} -export default Mfa diff --git a/src/components/user_settings/mfa.vue b/src/components/user_settings/mfa.vue deleted file mode 100644 index 14ea10a1..00000000 --- a/src/components/user_settings/mfa.vue +++ /dev/null @@ -1,173 +0,0 @@ - - - - diff --git a/src/components/user_settings/mfa_backup_codes.js b/src/components/user_settings/mfa_backup_codes.js deleted file mode 100644 index f0a984ec..00000000 --- a/src/components/user_settings/mfa_backup_codes.js +++ /dev/null @@ -1,17 +0,0 @@ -export default { - props: { - backupCodes: { - type: Object, - default: () => ({ - inProgress: false, - codes: [] - }) - } - }, - data: () => ({}), - computed: { - inProgress () { return this.backupCodes.inProgress }, - ready () { return this.backupCodes.codes.length > 0 }, - displayTitle () { return this.inProgress || this.ready } - } -} diff --git a/src/components/user_settings/mfa_backup_codes.vue b/src/components/user_settings/mfa_backup_codes.vue deleted file mode 100644 index e6c8ede2..00000000 --- a/src/components/user_settings/mfa_backup_codes.vue +++ /dev/null @@ -1,33 +0,0 @@ - - - diff --git a/src/components/user_settings/mfa_totp.js b/src/components/user_settings/mfa_totp.js deleted file mode 100644 index 8408d8e9..00000000 --- a/src/components/user_settings/mfa_totp.js +++ /dev/null @@ -1,49 +0,0 @@ -import Confirm from './confirm.vue' -import { mapState } from 'vuex' - -export default { - props: ['settings'], - data: () => ({ - error: false, - currentPassword: '', - deactivate: false, - inProgress: false // progress peform request to disable otp method - }), - components: { - 'confirm': Confirm - }, - computed: { - isActivated () { - return this.settings.totp - }, - ...mapState({ - backendInteractor: (state) => state.api.backendInteractor - }) - }, - methods: { - doActivate () { - this.$emit('activate') - }, - cancelDeactivate () { this.deactivate = false }, - doDeactivate () { - this.error = null - this.deactivate = true - }, - confirmDeactivate () { // confirm deactivate TOTP method - this.error = null - this.inProgress = true - this.backendInteractor.mfaDisableOTP({ - password: this.currentPassword - }) - .then((res) => { - this.inProgress = false - if (res.error) { - this.error = res.error - return - } - this.deactivate = false - this.$emit('deactivate') - }) - } - } -} diff --git a/src/components/user_settings/mfa_totp.vue b/src/components/user_settings/mfa_totp.vue deleted file mode 100644 index c6f2cc7b..00000000 --- a/src/components/user_settings/mfa_totp.vue +++ /dev/null @@ -1,43 +0,0 @@ - - diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js deleted file mode 100644 index e07d4e56..00000000 --- a/src/components/user_settings/user_settings.js +++ /dev/null @@ -1,140 +0,0 @@ -import get from 'lodash/get' -import map from 'lodash/map' -import reject from 'lodash/reject' -import Autosuggest from '../autosuggest/autosuggest.vue' -import TabSwitcher from '../tab_switcher/tab_switcher.js' -import BlockCard from '../block_card/block_card.vue' -import MuteCard from '../mute_card/mute_card.vue' -import DomainMuteCard from '../domain_mute_card/domain_mute_card.vue' -import SelectableList from '../selectable_list/selectable_list.vue' -import ProgressButton from '../progress_button/progress_button.vue' -import Importer from '../importer/importer.vue' -import Exporter from '../exporter/exporter.vue' -import withSubscription from '../../hocs/with_subscription/with_subscription' -import Checkbox from '../checkbox/checkbox.vue' - -const BlockList = withSubscription({ - fetch: (props, $store) => $store.dispatch('fetchBlocks'), - select: (props, $store) => get($store.state.users.currentUser, 'blockIds', []), - childPropName: 'items' -})(SelectableList) - -const MuteList = withSubscription({ - fetch: (props, $store) => $store.dispatch('fetchMutes'), - select: (props, $store) => get($store.state.users.currentUser, 'muteIds', []), - childPropName: 'items' -})(SelectableList) - -const DomainMuteList = withSubscription({ - fetch: (props, $store) => $store.dispatch('fetchDomainMutes'), - select: (props, $store) => get($store.state.users.currentUser, 'domainMutes', []), - childPropName: 'items' -})(SelectableList) - -const UserSettings = { - data () { - return { - activeTab: 'profile', - newDomainToMute: '' - } - }, - created () { - this.$store.dispatch('fetchTokens') - }, - components: { - TabSwitcher, - BlockList, - MuteList, - DomainMuteList, - BlockCard, - MuteCard, - DomainMuteCard, - ProgressButton, - Autosuggest, - Checkbox - }, - computed: { - user () { - return this.$store.state.users.currentUser - }, - pleromaBackend () { - return this.$store.state.instance.pleromaBackend - }, - currentSaveStateNotice () { - return this.$store.state.interface.settings.currentSaveStateNotice - } - }, - methods: { - importFollows (file) { - return this.$store.state.api.backendInteractor.importFollows({ file }) - .then((status) => { - if (!status) { - throw new Error('failed') - } - }) - }, - importBlocks (file) { - return this.$store.state.api.backendInteractor.importBlocks({ file }) - .then((status) => { - if (!status) { - throw new Error('failed') - } - }) - }, - generateExportableUsersContent (users) { - // Get addresses - return users.map((user) => { - // check is it's a local user - if (user && user.is_local) { - // append the instance address - // eslint-disable-next-line no-undef - return user.screen_name + '@' + location.hostname - } - return user.screen_name - }).join('\n') - }, - activateTab (tabName) { - this.activeTab = tabName - }, - filterUnblockedUsers (userIds) { - return reject(userIds, (userId) => { - const user = this.$store.getters.findUser(userId) - return !user || user.statusnet_blocking || user.id === this.$store.state.users.currentUser.id - }) - }, - filterUnMutedUsers (userIds) { - return reject(userIds, (userId) => { - const user = this.$store.getters.findUser(userId) - return !user || user.muted || user.id === this.$store.state.users.currentUser.id - }) - }, - queryUserIds (query) { - return this.$store.dispatch('searchUsers', query) - .then((users) => map(users, 'id')) - }, - blockUsers (ids) { - return this.$store.dispatch('blockUsers', ids) - }, - unblockUsers (ids) { - return this.$store.dispatch('unblockUsers', ids) - }, - muteUsers (ids) { - return this.$store.dispatch('muteUsers', ids) - }, - unmuteUsers (ids) { - return this.$store.dispatch('unmuteUsers', ids) - }, - unmuteDomains (domains) { - return this.$store.dispatch('unmuteDomains', domains) - }, - muteDomain () { - return this.$store.dispatch('muteDomain', this.newDomainToMute) - .then(() => { this.newDomainToMute = '' }) - }, - identity (value) { - return value - } - } -} - -export default UserSettings diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue deleted file mode 100644 index 2a88714f..00000000 --- a/src/components/user_settings/user_settings.vue +++ /dev/null @@ -1,119 +0,0 @@ - - - - - -- cgit v1.2.3-70-g09d2