Skip to content

Commit

Permalink
simplify account get/check flow in pro admin #2608
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Pollock committed Jun 25, 2018
1 parent 2a151be commit 1c9aa9a
Show file tree
Hide file tree
Showing 14 changed files with 8,316 additions and 7,078 deletions.
2 changes: 1 addition & 1 deletion clients/blocks/build/index.min.js.map

Large diffs are not rendered by default.

472 changes: 304 additions & 168 deletions clients/privacy/build/index.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clients/privacy/build/index.min.js.map

Large diffs are not rendered by default.

95 changes: 64 additions & 31 deletions clients/pro/build/index.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clients/pro/build/index.min.js.map

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions clients/pro/components/Account/Edit.vue
Expand Up @@ -43,8 +43,8 @@
computed: {
publicKey:{
get(){
return this.$store.getters.publicKey;
get() {
return this.$store.getters.publicKey;
},
set(newValue){
this.$store.commit('publicKey',newValue);
Expand All @@ -65,9 +65,6 @@
},
methods: {
...mapMutations({
secretKey: 'secretKey',
}),
publicKeyChange(ev){
this.$store.commit('publicKey',ev.target.value);
},
Expand Down
13 changes: 6 additions & 7 deletions clients/pro/store/actions.js
Expand Up @@ -19,7 +19,6 @@ export const ACTIONS = {
r = response.data;
}
context.commit('forms', r.forms);
context.commit('connected',false);//prevents next line form dispatching getLayouts
context.commit('apiKeys', r.apiKeys);
context.commit('connected',true);
context.commit('accountId', r.account_id);
Expand Down Expand Up @@ -83,7 +82,8 @@ export const ACTIONS = {
if( state.connected ){
resolve('Already Connected');
}
if (state.account.apiKeys.public && state.account.apiKeys.secret) {

if ('string' === typeof state.account.apiKeys.public && 'string' === typeof state.account.apiKeys.secret) {
return appAPI.get(
urlString(
{
Expand All @@ -93,21 +93,20 @@ export const ACTIONS = {
'/account/verify'
)
).then(r => {
commit( 'connected', true );
state.account.plan = r.plan;
state.account.id = r.id;
commit( 'connected', true );
resolve(r);
},
error => {
console.log(101);

context.commit('connected',false);
commit('connected',false);
reject(error);
});

}else{
reject( 'Not Connected' );
}

});

},
Expand All @@ -118,7 +117,7 @@ export const ACTIONS = {
{
simple: true,
public: state.account.apiKeys.public,
token: state.account.apiKeys.token,
token: appToken( state.account.apiKeys ),
},
'/layouts/list'
)
Expand Down
2 changes: 1 addition & 1 deletion clients/pro/store/getters.js
Expand Up @@ -5,7 +5,7 @@ export const GETTERS = {
return state.account.apiKeys.public;
},
secretKey: state => {
return state.account.apiKeys.secret;
return state.account.apiKeys.secret;
},
apiKeys: state => {
return state.account.apiKeys;
Expand Down
8 changes: 4 additions & 4 deletions clients/pro/store/index.js
Expand Up @@ -16,15 +16,15 @@ const STATE = {
logLevel: 250
},
layouts : [
{name:''}

],
account: {
plan: String,
id: Number,
apiKeys: {
public: String,
secret: String,
token: String
public: CFProConfig.public,
secret: CFProConfig.secret,
token: CFProConfig.token
}
},
strings: CFProConfig.strings,
Expand Down
24 changes: 18 additions & 6 deletions clients/pro/store/plugins.js
Expand Up @@ -6,11 +6,12 @@ export const accountSaver = store => {
case 'apiKeys' :
case 'secretKey':
case 'publicKey':
if (!state.connected && state.account.apiKeys.secret && state.account.apiKeys.public) {
if( 'string' === typeof state.account.apiKeys.public
&& 'string' === typeof state.account.apiKeys.secret ) {
store.dispatch('testConnection');
store.dispatch('getLayouts');
if (state.connected && state.account.apiKeys.secret && state.account.apiKeys.public ) {
store.commit('connected', 1);
}else if (!state.connected && state.account.apiKeys.secret && state.account.apiKeys.public) {
if ('string' === typeof state.account.apiKeys.public
&& 'string' === typeof state.account.apiKeys.secret) {
store.dispatch('testConnection' );
}

} else if (!state.account.apiKeys.public || !state.account.apiKeys.secret) {
Expand All @@ -21,7 +22,18 @@ export const accountSaver = store => {
break;
case 'connected' :
if (state.connected) {
store.dispatch('getLayouts')
if( ! Array.isArray( state.layouts ) || ! state.layouts.length ){
store.dispatch('getLayouts');

}

if( ! Array.isArray( state.forms ) || ! state.forms.length ){
store.dispatch('getAccount');

}



}
break;
}
Expand Down
34 changes: 34 additions & 0 deletions clients/pro/store/util/wpConfig.js
Expand Up @@ -57,4 +57,38 @@ export default {
*/
logLevels: CF_PRO_ADMIN.logLevels,

/**
* Levels of Monolog logs
*
* Created by "logLevels" index of generated in calderawp\calderaforms\pro\admin\scripts::data()
*
* @since 1.5.9
*
* @type array
*/
public: CF_PRO_ADMIN.settings.apiKeys.public,


/**
* Levels of Monolog logs
*
* Created by "logLevels" index of generated in calderawp\calderaforms\pro\admin\scripts::data()
*
* @since 1.5.9
*
* @type array
*/
secret: CF_PRO_ADMIN.settings.apiKeys.secret,

/**
* Levels of Monolog logs
*
* Created by "logLevels" index of generated in calderawp\calderaforms\pro\admin\scripts::data()
*
* @since 1.5.9
*
* @type array
*/
token: CF_PRO_ADMIN.settings.apiKeys.token,

};
4 changes: 3 additions & 1 deletion clients/pro/views/Settings.vue
Expand Up @@ -88,7 +88,9 @@
e.parentNode.removeChild(e);
});
this.$store.dispatch( 'getAccount' );
this.$store.dispatch( 'testConnection' );
},
methods:{
save(){
Expand Down

0 comments on commit 1c9aa9a

Please sign in to comment.