From da2418d6c385960c7e7a3bac3b486dcb8f737097 Mon Sep 17 00:00:00 2001 From: Tyler Chen Date: Fri, 2 Oct 2020 06:38:39 +0000 Subject: [PATCH 1/2] fix/missing-functionalities (#70) Merge branch 'master' of git.bubblev.org:bubblev/bubble-web into fix/missing-functionalities fix: issues Merge branch 'master' of git.bubblev.org:bubblev/bubble-web into fix/missing-functionalities fix: issues Merge branch 'master' of git.bubblev.org:bubblev/bubble-web into fix/missing-functionalities fix: unnecessary api calls and add missing functionalities on profile page Merge branch 'master' of git.bubblev.org:bubblev/bubble-web into fix/missing-functionalities fix: login Merge branch 'master' of git.bubblev.org:bubblev/bubble-web into fix/missing-functionalities fix: login and sign up stuff Merge branch 'master' of git.bubblev.org:bubblev/bubble-web into fix/missing-functionalities fix: page reloading stuff fix: login stuff Merge branch 'master' of git.bubblev.org:bubblev/bubble-web into fix/missing-functionalities fix: sign up and payment check stuff fix: launch bubble screen Merge branch 'master' of git.bubblev.org:bubblev/bubble-web into fix/missing-functionalities Merge branch 'master' of git.bubblev.org:bubblev/bubble-web into fix/missing-functionalities fix: refreshing issue feat: implement devices screen Merge branch 'master' of git.bubblev.org:bubblev/bubble-web into fix/missing-functionalities feat: implement new layout Merge branch 'master' of git.bubblev.org:bubblev/bubble-web into fix/missing-functionalities feat: implement new layout fix: header fix: showing error on add ssh modal fix: login by enter key Co-authored-by: Tyler Reviewed-on: https://git.bubblev.org/bubblev/bubble-web/pulls/70 --- src/_components/layout/Footer.vue | 3 + .../modals/LaunchBubbleSettingsModal.vue | 98 ++- src/_pages/main/account/Policy.vue | 9 + src/_pages/main/account/Support.vue | 2 +- src/_pages/main/bubble/LaunchBubble.vue | 21 + src/_pages/main/bubble/Network.vue | 7 + src/_router/index.js | 4 + src/_store/account.module.js | 10 +- src/_store/users.module.js | 824 ++++++++++-------- 9 files changed, 582 insertions(+), 396 deletions(-) diff --git a/src/_components/layout/Footer.vue b/src/_components/layout/Footer.vue index 5e68bf9..e3c9fcb 100644 --- a/src/_components/layout/Footer.vue +++ b/src/_components/layout/Footer.vue @@ -22,6 +22,9 @@ v-for="item in footerLinks" :key="item" :href="messages[`link_${item}`]" + :target=" + messages[`link_${item}`].startsWith('http') ? '_blank' : '_self' + " > {{ messages[`title_${item}`] }} diff --git a/src/_components/modals/LaunchBubbleSettingsModal.vue b/src/_components/modals/LaunchBubbleSettingsModal.vue index bff6a14..1bf75e7 100644 --- a/src/_components/modals/LaunchBubbleSettingsModal.vue +++ b/src/_components/modals/LaunchBubbleSettingsModal.vue @@ -89,6 +89,49 @@ +
+ + + + +
+ {{ errors.first('plan') }} +
+
+

{{ messages.field_label_send_errors_description }}

+
{ this.accountPlan.name = this.getDefaultName(); @@ -690,6 +770,22 @@ export default { } } }, + + plans(p) { + if (p) { + if (this.user && this.user.preferredPlan) { + const plans = this.planObjects; + if (plans) { + for (let i = 0; i < plans.length; i++) { + if (plans[i].uuid === this.user.preferredPlan) { + this.defaults.plan = plans[i].name; + this.accountPlan.plan = plans[i].name; + } + } + } + } + } + }, }, }; diff --git a/src/_pages/main/account/Policy.vue b/src/_pages/main/account/Policy.vue index 9c79a07..1b07b1c 100644 --- a/src/_pages/main/account/Policy.vue +++ b/src/_pages/main/account/Policy.vue @@ -1131,6 +1131,7 @@ export default { email: null, sync: null, showBlockStats: null, + admin: null, }, }; }, @@ -1188,6 +1189,7 @@ export default { 'resendVerificationCode', 'requestAccountDownload', 'downloadAccount', + 'checkSession', ]), ...mapActions('users', [ 'getUserById', @@ -1198,6 +1200,7 @@ export default { 'removePolicyContactByUserId', ]), ...mapGetters('users', ['loading']), + isAuthenticator(val) { return window.isAuthenticator(val); }, @@ -1235,6 +1238,11 @@ export default { user: this.profile, messages: this.messages, errors: this.errors, + }).then(() => { + this.checkSession({ + messages: this.messages, + errors: this.errors, + }); }); }, addContact(e) { @@ -1521,6 +1529,7 @@ export default { this.profile.email = this.currentUser.email; this.profile.showBlockStats = this.currentUser.showBlockStats; this.profile.sync = this.currentUser.sync; + this.profile.admin = this.currentUser.admin; }, }; diff --git a/src/_pages/main/account/Support.vue b/src/_pages/main/account/Support.vue index 1064ec1..7715f36 100644 --- a/src/_pages/main/account/Support.vue +++ b/src/_pages/main/account/Support.vue @@ -12,7 +12,7 @@ class="col-lg-6 col-md-6 col-sm-12 my-4 px-3" v-if="configs && configs.support && configs.support.site" > - +
{{ messages.support_site_link }} diff --git a/src/_pages/main/bubble/LaunchBubble.vue b/src/_pages/main/bubble/LaunchBubble.vue index a67f1a8..8badccc 100644 --- a/src/_pages/main/bubble/LaunchBubble.vue +++ b/src/_pages/main/bubble/LaunchBubble.vue @@ -135,6 +135,7 @@ export default { ...mapState('footprints', ['footprints']), ...mapState('users', ['sshKeys']), ...mapState('paymentMethods', ['accountPaymentMethods']), + ...mapState('plans', ['plans']), }, methods: { @@ -143,6 +144,7 @@ export default { ...mapActions('footprints', ['getAllFootprints']), ...mapActions('users', ['listSshKeysByUserId']), ...mapGetters('networks', ['loading']), + ...mapActions('plans', ['getAllPlans']), ...mapActions('paymentMethods', ['getAllAccountPaymentMethods']), openSettingsModal(ev) { @@ -178,6 +180,10 @@ export default { messages: this.messages, errors: this.errors, }); + this.getAllPlans({ + messages: this.messages, + errors: this.errors, + }); }, findRegion(uuid) { @@ -316,6 +322,21 @@ export default { } } }, + plans(p) { + if (p) { + if (this.user && this.user.preferredPlan) { + const plans = this.planObjects; + if (plans) { + for (let i = 0; i < plans.length; i++) { + if (plans[i].uuid === this.user.preferredPlan) { + this.defaults.plan = plans[i].name; + this.accountPlan.plan = plans[i].name; + } + } + } + } + } + }, }, }; diff --git a/src/_pages/main/bubble/Network.vue b/src/_pages/main/bubble/Network.vue index cee9ca8..7b32286 100644 --- a/src/_pages/main/bubble/Network.vue +++ b/src/_pages/main/bubble/Network.vue @@ -627,6 +627,7 @@ export default { ]), ...mapActions('users', ['updateUser']), ...mapGetters('users', { loadingUser: 'loading' }), + ...mapActions('account', ['checkSession']), refreshStatus(userId) { if (!this.lottie && this.$refs.lottie) { @@ -832,9 +833,15 @@ export default { user: { email: this.user.email, autoUpdatePolicy: this.autoUpdatePolicy, + admin: this.user.admin, }, messages: this.messages, errors: this.errors, + }).then(() => { + this.checkSession({ + messages: this.messages, + errors: this.errors, + }); }); }, }, diff --git a/src/_router/index.js b/src/_router/index.js index b624d33..69d794e 100644 --- a/src/_router/index.js +++ b/src/_router/index.js @@ -99,6 +99,10 @@ export const router = new Router({ path: 'bubble/:id', component: () => import('~/_pages/main/bubble/Network'), }, + { + path: 'new_bubble', + component: NewNetworkPage, + }, { path: 'action', component: ActionPage }, { path: 'resetPassword/:code', component: SetPasswordPage }, diff --git a/src/_store/account.module.js b/src/_store/account.module.js index 0cd90c2..3d2c08c 100644 --- a/src/_store/account.module.js +++ b/src/_store/account.module.js @@ -193,7 +193,7 @@ const actions = { userService.register(user, messages, errors).then( (user) => { commit('registerSuccess', user); - router.push('/bubble'); + router.push('/verifyEmail'); setTimeout(() => { // display success message after route change completes dispatch('alert/success', messages.alert_registration_success, { @@ -321,12 +321,8 @@ const mutations = { }, checkSessionRequest(state) {}, checkSessionSuccess(state, user) { - console.log( - 'checkSessionSuccess', - state.user.preferredPlan, - user.preferredPlan - ); - if (user.token) { + console.log('checkSessionSuccess', state.user.preferredPlan, user); + if (user) { if (util.currentUser() === null) { // we must have logged out while this request was in flight... do nothing state.user = null; diff --git a/src/_store/users.module.js b/src/_store/users.module.js index 64307a5..f849d1e 100644 --- a/src/_store/users.module.js +++ b/src/_store/users.module.js @@ -7,414 +7,464 @@ import { account } from '~/_store/account.module'; import { util } from '~/_helpers'; const state = { - loading: { - users: false, user: false, creating: false, updating: false, deleting: false, changingPassword: false, - policy: false, updatingPolicy: false, addPolicyContact: false, removePolicyContact: false, - listSshKeys: false, addSshKey: false, removeSshKey: false, sendingDeleteRequest: false - }, - errors: {}, - users: null, - user: null, - policy: {}, - contact: null, - authenticator: {}, - sshKey: null, - sshKeys: [], - changePasswordResponse: null, - deleteRequestSent: false + loading: { + users: false, + user: false, + creating: false, + updating: false, + deleting: false, + changingPassword: false, + policy: false, + updatingPolicy: false, + addPolicyContact: false, + removePolicyContact: false, + listSshKeys: false, + addSshKey: false, + removeSshKey: false, + sendingDeleteRequest: false, + }, + errors: {}, + users: null, + user: null, + policy: {}, + contact: null, + authenticator: {}, + sshKey: null, + sshKeys: [], + changePasswordResponse: null, + deleteRequestSent: false, }; export const CONTACT_TYPE_AUTHENTICATOR = 'authenticator'; -export function isAuthenticator (val) { - return val === CONTACT_TYPE_AUTHENTICATOR || (val != null && typeof val.type !== 'undefined' && val.type === CONTACT_TYPE_AUTHENTICATOR); +export function isAuthenticator(val) { + return ( + val === CONTACT_TYPE_AUTHENTICATOR || + (val != null && + typeof val.type !== 'undefined' && + val.type === CONTACT_TYPE_AUTHENTICATOR) + ); +} +export function isNotAuthenticator(val) { + return !isAuthenticator(val); } -export function isNotAuthenticator (val) { return !isAuthenticator(val); } const LOCALSTORAGE_AUTHENTICATOR = 'authenticator'; function setAuthenticator(policy) { - const storedAuthJson = localStorage.getItem(LOCALSTORAGE_AUTHENTICATOR); - const storedAuth = storedAuthJson !== null ? JSON.parse(storedAuthJson) : null; - if (policy && policy.accountContacts) { - const contacts = policy.accountContacts; - for (let i=0; i commit('searchAccountsSuccess', users), - error => commit('searchAccountsFailure', error) - ); - }, - - getUserById({ commit }, {userId, messages, errors}) { - commit('getUserByIdRequest'); - userService.getUserById(userId, messages, errors) - .then( - users => commit('getUserByIdSuccess', users), - error => commit('getUserByIdFailure', error) - ); - }, - - createUser({ commit }, {user, messages, errors}) { - commit('createUserRequest', user); - userService.createUser(user, messages, errors) - .then( - user => commit('createUserSuccess', user), - error => commit('createUserFailure', { user, error: error.toString() }) - ); - }, - - updateUser({ commit }, {user, messages, errors}) { - commit('updateUserRequest', user); - userService.updateUser(user, messages, errors) - .then( - user => commit('updateUserSuccess', user), - error => commit('updateUserFailure', { user, error: error.toString() }) - ); - }, - - updateSelf({ commit }, {user, messages, errors}) { - commit('updateSelfRequest', user); - userService.updateUser(user, messages, errors) - .then( - user => commit('updateSelfSuccess', user), - error => commit('updateSelfFailure', { user, error: error.toString() }) - ); - }, - - getPolicyByUserId({ commit }, {userId, messages, errors}) { - commit('getPolicyByUserIdRequest'); - userService.getPolicyByUserId(userId, messages, errors) - .then( - policy => commit('getPolicyByUserIdSuccess', policy), - error => commit('getPolicyByUserIdFailure', error) - ); - }, - - updatePolicyByUserId({ commit }, {userId, policy, messages, errors}) { - commit('updatePolicyByUserIdRequest'); - userService.updatePolicyByUserId(userId, policy, messages, errors) - .then( - policy => commit('updatePolicyByUserIdSuccess', policy), - error => commit('updatePolicyByUserIdFailure', error) - ); - }, - - addPolicyContactByUserId({ commit }, {userId, contact, messages, errors}) { - commit('addPolicyContactByUserIdRequest'); - userService.addPolicyContactById(userId, contact, messages, errors) - .then( - contact => commit('addPolicyContactByUserIdSuccess', contact), - error => commit('addPolicyContactByUserIdFailure', error) - ); - }, - - removePolicyContactByUserId({ commit }, {userId, contactUuid, messages, errors}) { - commit('removePolicyContactByUserIdRequest'); - userService.removePolicyContactByUserId(userId, contactUuid, messages, errors) - .then( - policy => commit('removePolicyContactByUserIdSuccess', policy), - error => commit('removePolicyContactByUserIdFailure', error) - ); - }, - - addSshKeyByUserId({ commit }, {userId, sshKey, messages, errors}) { - commit('addSshKeyByUserIdRequest'); - return userService.addSshKeyByUserId(userId, sshKey, messages, errors) - .then( - key => { - commit('addSshKeyByUserIdSuccess', key); - return Promise.resolve(); - }, - error => { - commit('addSshKeyByUserIdFailure', error); - return Promise.reject(); - } - ); - }, - - removeSshKeyByUserId({ commit }, {userId, sshKeyId, messages, errors}) { - commit('removeSshKeyByUserIdRequest'); - userService.removeSshKeyByUserId(userId, sshKeyId, messages, errors) - .then( - ok => commit('removeSshKeyByUserIdSuccess', sshKeyId), - error => commit('removeSshKeyByUserIdFailure', error) - ); - }, - - listSshKeysByUserId({ commit }, {userId, messages, errors}) { - commit('listSshKeysByUserIdRequest'); - userService.listSshKeysByUserId(userId, messages, errors) - .then( - sshKeys => commit('listSshKeysByUserIdSuccess', sshKeys), - error => commit('listSshKeysByUserIdFailure', error) - ); - }, - - deleteUser({ commit }, {userId, messages, errors}) { - commit('deleteRequest', userId); - userService.deleteUser(userId, messages, errors) - .then( - id => commit('deleteSuccess', id), - error => commit('deleteFailure', { userId, error: error.toString() }) - ); - }, - - requestUserDeletion({ commit }, { userId, messages, errors }) { - commit("requestUserDeletionRequest", userId); - userService.requestUserDeletion(userId, messages, errors) - .then((id) => commit("requestUserDeletionSuccess", id), - (error) => commit("requestUserDeletionFailure", - { userId, error: error.toString() }) - ); - }, - - changePassword({ commit }, {request, messages, errors}) { - commit('changePasswordRequest', request); - userService.changePassword(request, messages, errors) - .then( - response => commit('changePasswordSuccess', response), - error => commit('changePasswordFailure', { error: error.toString() }) - ); - }, - - adminChangePassword({ commit }, {userId, request, messages, errors}) { - commit('changePasswordRequest', userId); - userService.adminChangePassword(userId, request, messages, errors) - .then( - id => commit('changePasswordSuccess', id), - error => commit('changePasswordFailure', { error: error.toString() }) - ); - } - + searchAccounts({ commit }, { query, messages, errors }) { + commit('searchAccountsRequest'); + userService + .searchAccounts(query, messages, errors) + .then( + (users) => commit('searchAccountsSuccess', users), + (error) => commit('searchAccountsFailure', error) + ); + }, + + getUserById({ commit }, { userId, messages, errors }) { + commit('getUserByIdRequest'); + userService + .getUserById(userId, messages, errors) + .then( + (users) => commit('getUserByIdSuccess', users), + (error) => commit('getUserByIdFailure', error) + ); + }, + + createUser({ commit }, { user, messages, errors }) { + commit('createUserRequest', user); + userService + .createUser(user, messages, errors) + .then( + (user) => commit('createUserSuccess', user), + (error) => + commit('createUserFailure', { user, error: error.toString() }) + ); + }, + + updateUser({ commit }, { user, messages, errors }) { + commit('updateUserRequest', user); + return userService + .updateUser(user, messages, errors) + .then( + (user) => commit('updateUserSuccess', user), + (error) => + commit('updateUserFailure', { user, error: error.toString() }) + ); + }, + + updateSelf({ commit }, { user, messages, errors }) { + commit('updateSelfRequest', user); + userService + .updateUser(user, messages, errors) + .then( + (user) => commit('updateSelfSuccess', user), + (error) => + commit('updateSelfFailure', { user, error: error.toString() }) + ); + }, + + getPolicyByUserId({ commit }, { userId, messages, errors }) { + commit('getPolicyByUserIdRequest'); + userService + .getPolicyByUserId(userId, messages, errors) + .then( + (policy) => commit('getPolicyByUserIdSuccess', policy), + (error) => commit('getPolicyByUserIdFailure', error) + ); + }, + + updatePolicyByUserId({ commit }, { userId, policy, messages, errors }) { + commit('updatePolicyByUserIdRequest'); + userService + .updatePolicyByUserId(userId, policy, messages, errors) + .then( + (policy) => commit('updatePolicyByUserIdSuccess', policy), + (error) => commit('updatePolicyByUserIdFailure', error) + ); + }, + + addPolicyContactByUserId({ commit }, { userId, contact, messages, errors }) { + commit('addPolicyContactByUserIdRequest'); + userService + .addPolicyContactById(userId, contact, messages, errors) + .then( + (contact) => commit('addPolicyContactByUserIdSuccess', contact), + (error) => commit('addPolicyContactByUserIdFailure', error) + ); + }, + + removePolicyContactByUserId( + { commit }, + { userId, contactUuid, messages, errors } + ) { + commit('removePolicyContactByUserIdRequest'); + userService + .removePolicyContactByUserId(userId, contactUuid, messages, errors) + .then( + (policy) => commit('removePolicyContactByUserIdSuccess', policy), + (error) => commit('removePolicyContactByUserIdFailure', error) + ); + }, + + addSshKeyByUserId({ commit }, { userId, sshKey, messages, errors }) { + commit('addSshKeyByUserIdRequest'); + return userService.addSshKeyByUserId(userId, sshKey, messages, errors).then( + (key) => { + commit('addSshKeyByUserIdSuccess', key); + return Promise.resolve(); + }, + (error) => { + commit('addSshKeyByUserIdFailure', error); + return Promise.reject(); + } + ); + }, + + removeSshKeyByUserId({ commit }, { userId, sshKeyId, messages, errors }) { + commit('removeSshKeyByUserIdRequest'); + userService + .removeSshKeyByUserId(userId, sshKeyId, messages, errors) + .then( + (ok) => commit('removeSshKeyByUserIdSuccess', sshKeyId), + (error) => commit('removeSshKeyByUserIdFailure', error) + ); + }, + + listSshKeysByUserId({ commit }, { userId, messages, errors }) { + commit('listSshKeysByUserIdRequest'); + userService + .listSshKeysByUserId(userId, messages, errors) + .then( + (sshKeys) => commit('listSshKeysByUserIdSuccess', sshKeys), + (error) => commit('listSshKeysByUserIdFailure', error) + ); + }, + + deleteUser({ commit }, { userId, messages, errors }) { + commit('deleteRequest', userId); + userService + .deleteUser(userId, messages, errors) + .then( + (id) => commit('deleteSuccess', id), + (error) => commit('deleteFailure', { userId, error: error.toString() }) + ); + }, + + requestUserDeletion({ commit }, { userId, messages, errors }) { + commit('requestUserDeletionRequest', userId); + userService + .requestUserDeletion(userId, messages, errors) + .then( + (id) => commit('requestUserDeletionSuccess', id), + (error) => + commit('requestUserDeletionFailure', { + userId, + error: error.toString(), + }) + ); + }, + + changePassword({ commit }, { request, messages, errors }) { + commit('changePasswordRequest', request); + userService + .changePassword(request, messages, errors) + .then( + (response) => commit('changePasswordSuccess', response), + (error) => commit('changePasswordFailure', { error: error.toString() }) + ); + }, + + adminChangePassword({ commit }, { userId, request, messages, errors }) { + commit('changePasswordRequest', userId); + userService + .adminChangePassword(userId, request, messages, errors) + .then( + (id) => commit('changePasswordSuccess', id), + (error) => commit('changePasswordFailure', { error: error.toString() }) + ); + }, }; const mutations = { - searchAccountsRequest(state) { - state.loading.users = true; - }, - searchAccountsSuccess(state, users) { - state.loading.users = false; - state.users = users; - }, - searchAccountsFailure(state, error) { - state.loading.users = false; - state.errors.all = error; - }, - - getUserByIdRequest(state) { - state.loading.user = true; - }, - getUserByIdSuccess(state, user) { - state.loading.user = false; - state.user = user; - }, - getUserByIdFailure(state, error) { - state.loading.user = false; - state.errors.user = error; - }, - - getPolicyByUserIdRequest(state) { - state.loading.policy = true; - }, - getPolicyByUserIdSuccess(state, policy) { - state.loading.policy = false; - state.policy = policy; - setAuthenticator(policy); - }, - getPolicyByUserIdFailure(state, error) { - state.loading.policy = false; - state.errors.policy = error; - }, - - updatePolicyByUserIdRequest(state) { - state.loading.updatingPolicy = true; - }, - updatePolicyByUserIdSuccess(state, policy) { - state.loading.updatingPolicy = false; - state.policy = policy; - setAuthenticator(policy); - }, - updatePolicyByUserIdFailure(state, error) { - state.loading.updatingPolicy = false; - state.errors.policy = { error }; - }, - - addPolicyContactByUserIdRequest(state) { - state.loading.addPolicyContact = true; - }, - addPolicyContactByUserIdSuccess(state, contact) { - state.loading.addPolicyContact = false; - state.contact = contact; - if (isAuthenticator(contact)) { - state.authenticator = JSON.parse(contact.info); - localStorage.setItem(LOCALSTORAGE_AUTHENTICATOR, JSON.stringify(state.authenticator)); - } - }, - addPolicyContactByUserIdFailure(state, error) { - state.loading.addPolicyContact = false; - state.errors.contact = error; - }, - - removePolicyContactByUserIdRequest(state) { - state.loading.removePolicyContact = true; - }, - removePolicyContactByUserIdSuccess(state, policy) { - state.loading.removePolicyContact = false; - state.policy = policy; - }, - removePolicyContactByUserIdFailure(state, error) { - state.loading.removePolicyContact = false; - state.errors.policy = error; - }, - - createUserRequest(state, user) { - state.loading.creating = true; - }, - createUserSuccess(state, user) { - state.loading.creating = false; - state.user = user; - }, - createUserFailure(state, { id, error }) { - state.loading.creating = false; - state.errors.create = error; - }, - - updateUserRequest(state, user) { - state.loading.updating = true; - }, - updateUserSuccess(state, user) { - state.loading.updating = false; - state.user = user; - }, - updateUserFailure(state, { id, error }) { - state.loading.updating = false; - state.errors.update = error; - }, - - updateSelfRequest(state, user) { - state.loading.updating = true; - }, - updateSelfSuccess(state, user) { - state.loading.updating = false; - user.token = account.state.user.token; // preserve token - state.user = account.state.user = user; - localStorage.setItem(util.USER_KEY, JSON.stringify(user)); - }, - updateSelfFailure(state, { id, error }) { - state.loading.updating = false; - state.errors.update = error; - }, - - addSshKeyByUserIdRequest(state) { - state.loading.addSshKey = true; - }, - addSshKeyByUserIdSuccess(state, sshKey) { - state.loading.addSshKey = false; - state.sshKey = sshKey; - state.sshKeys.push(sshKey); - }, - addSshKeyByUserIdFailure(state, error) { - state.loading.addSshKey = false; - state.errors.sshKey = error; - }, - - removeSshKeyByUserIdRequest(state) { - state.loading.removeSshKey = true; - }, - removeSshKeyByUserIdSuccess(state, sshKeyId) { - state.loading.removeSshKey = false; - state.sshKey = null; - state.sshKeys = state.sshKeys.filter(function(k) { return k.uuid !== sshKeyId; }) - }, - removeSshKeyByUserIdFailure(state, error) { - state.loading.removeSshKey = false; - state.errors.sshKey = error; - }, - - listSshKeysByUserIdRequest(state) { - state.loading.listSshKeys = true; - }, - listSshKeysByUserIdSuccess(state, sshKeys) { - state.loading.listSshKeys = false; - state.sshKeys = sshKeys; - }, - listSshKeysByUserIdFailure(state, error) { - state.loading.listSshKeys = false; - state.errors.sshKey = error; - }, - - deleteRequest(state, id) { - // todo: use proper delete API - // add 'deleting:true' property to user being deleted - state.loading.deleting = true; - }, - deleteSuccess(state, id) { - state.loading.deleting = false; - state.users = []; - }, - deleteFailure(state, { id, error }) { - state.loading.deleting = false; - state.errors.deleteUser = error; - }, - - requestUserDeletionRequest(state, id) { - state.loading.sendingDeleteRequest = true; - state.deleteRequestSent = false; - }, - requestUserDeletionSuccess(state, id) { - state.loading.sendingDeleteRequest = false; - state.deleteRequestSent = true; - }, - requestUserDeletionFailure(state, { id, error }) { - state.loading.sendingDeleteRequest = false; - state.deleteRequestSent = false; - state.errors.requestUserDeletion = error; - }, - - changePasswordRequest(state, id) { - state.loading.changingPassword = true; - }, - changePasswordSuccess(state, response) { - state.loading.changingPassword = false; - state.changePasswordResponse = response; - }, - changePasswordFailure(state, { error }) { - state.loading.changingPassword = false; - state.errors.changePassword = error; + searchAccountsRequest(state) { + state.loading.users = true; + }, + searchAccountsSuccess(state, users) { + state.loading.users = false; + state.users = users; + }, + searchAccountsFailure(state, error) { + state.loading.users = false; + state.errors.all = error; + }, + + getUserByIdRequest(state) { + state.loading.user = true; + }, + getUserByIdSuccess(state, user) { + state.loading.user = false; + state.user = user; + }, + getUserByIdFailure(state, error) { + state.loading.user = false; + state.errors.user = error; + }, + + getPolicyByUserIdRequest(state) { + state.loading.policy = true; + }, + getPolicyByUserIdSuccess(state, policy) { + state.loading.policy = false; + state.policy = policy; + setAuthenticator(policy); + }, + getPolicyByUserIdFailure(state, error) { + state.loading.policy = false; + state.errors.policy = error; + }, + + updatePolicyByUserIdRequest(state) { + state.loading.updatingPolicy = true; + }, + updatePolicyByUserIdSuccess(state, policy) { + state.loading.updatingPolicy = false; + state.policy = policy; + setAuthenticator(policy); + }, + updatePolicyByUserIdFailure(state, error) { + state.loading.updatingPolicy = false; + state.errors.policy = { error }; + }, + + addPolicyContactByUserIdRequest(state) { + state.loading.addPolicyContact = true; + }, + addPolicyContactByUserIdSuccess(state, contact) { + state.loading.addPolicyContact = false; + state.contact = contact; + if (isAuthenticator(contact)) { + state.authenticator = JSON.parse(contact.info); + localStorage.setItem( + LOCALSTORAGE_AUTHENTICATOR, + JSON.stringify(state.authenticator) + ); } + }, + addPolicyContactByUserIdFailure(state, error) { + state.loading.addPolicyContact = false; + state.errors.contact = error; + }, + + removePolicyContactByUserIdRequest(state) { + state.loading.removePolicyContact = true; + }, + removePolicyContactByUserIdSuccess(state, policy) { + state.loading.removePolicyContact = false; + state.policy = policy; + }, + removePolicyContactByUserIdFailure(state, error) { + state.loading.removePolicyContact = false; + state.errors.policy = error; + }, + + createUserRequest(state, user) { + state.loading.creating = true; + }, + createUserSuccess(state, user) { + state.loading.creating = false; + state.user = user; + }, + createUserFailure(state, { id, error }) { + state.loading.creating = false; + state.errors.create = error; + }, + + updateUserRequest(state, user) { + state.loading.updating = true; + }, + updateUserSuccess(state, user) { + state.loading.updating = false; + state.user = user; + }, + updateUserFailure(state, { id, error }) { + state.loading.updating = false; + state.errors.update = error; + }, + + updateSelfRequest(state, user) { + state.loading.updating = true; + }, + updateSelfSuccess(state, user) { + state.loading.updating = false; + user.token = account.state.user.token; // preserve token + state.user = account.state.user = user; + localStorage.setItem(util.USER_KEY, JSON.stringify(user)); + }, + updateSelfFailure(state, { id, error }) { + state.loading.updating = false; + state.errors.update = error; + }, + + addSshKeyByUserIdRequest(state) { + state.loading.addSshKey = true; + }, + addSshKeyByUserIdSuccess(state, sshKey) { + state.loading.addSshKey = false; + state.sshKey = sshKey; + state.sshKeys.push(sshKey); + }, + addSshKeyByUserIdFailure(state, error) { + state.loading.addSshKey = false; + state.errors.sshKey = error; + }, + + removeSshKeyByUserIdRequest(state) { + state.loading.removeSshKey = true; + }, + removeSshKeyByUserIdSuccess(state, sshKeyId) { + state.loading.removeSshKey = false; + state.sshKey = null; + state.sshKeys = state.sshKeys.filter(function(k) { + return k.uuid !== sshKeyId; + }); + }, + removeSshKeyByUserIdFailure(state, error) { + state.loading.removeSshKey = false; + state.errors.sshKey = error; + }, + + listSshKeysByUserIdRequest(state) { + state.loading.listSshKeys = true; + }, + listSshKeysByUserIdSuccess(state, sshKeys) { + state.loading.listSshKeys = false; + state.sshKeys = sshKeys; + }, + listSshKeysByUserIdFailure(state, error) { + state.loading.listSshKeys = false; + state.errors.sshKey = error; + }, + + deleteRequest(state, id) { + // todo: use proper delete API + // add 'deleting:true' property to user being deleted + state.loading.deleting = true; + }, + deleteSuccess(state, id) { + state.loading.deleting = false; + state.users = []; + }, + deleteFailure(state, { id, error }) { + state.loading.deleting = false; + state.errors.deleteUser = error; + }, + + requestUserDeletionRequest(state, id) { + state.loading.sendingDeleteRequest = true; + state.deleteRequestSent = false; + }, + requestUserDeletionSuccess(state, id) { + state.loading.sendingDeleteRequest = false; + state.deleteRequestSent = true; + }, + requestUserDeletionFailure(state, { id, error }) { + state.loading.sendingDeleteRequest = false; + state.deleteRequestSent = false; + state.errors.requestUserDeletion = error; + }, + + changePasswordRequest(state, id) { + state.loading.changingPassword = true; + }, + changePasswordSuccess(state, response) { + state.loading.changingPassword = false; + state.changePasswordResponse = response; + }, + changePasswordFailure(state, { error }) { + state.loading.changingPassword = false; + state.errors.changePassword = error; + }, }; const getters = { - loading: util.checkLoading(state.loading, 'users') + loading: util.checkLoading(state.loading, 'users'), }; export const users = { - namespaced: true, - state, - actions, - mutations, - getters + namespaced: true, + state, + actions, + mutations, + getters, }; From 28cce2b771c73e7e2fe26997f68538da6f283079 Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Fri, 2 Oct 2020 04:19:43 -0400 Subject: [PATCH 2/2] fix typo --- src/_pages/main/bubble/LaunchingBubble.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pages/main/bubble/LaunchingBubble.vue b/src/_pages/main/bubble/LaunchingBubble.vue index 4dc99eb..1701c4a 100644 --- a/src/_pages/main/bubble/LaunchingBubble.vue +++ b/src/_pages/main/bubble/LaunchingBubble.vue @@ -43,7 +43,7 @@