Skip to content

Commit

Permalink
Merge pull request #473 from google/fix/no-accounts-message
Browse files Browse the repository at this point in the history
set errorCode state to true if no accounts are found
  • Loading branch information
felixarntz authored Aug 29, 2019
2 parents 7698541 + 2edd8fc commit 53179bd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion assets/js/modules/analytics/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ class AnalyticsSetup extends Component {

const responseData = await data.get( 'modules', 'analytics', 'get-accounts', queryArgs, false );
if ( 0 === responseData.accounts.length ) {
newState = {
...newState,
errorCode: 'no_account',
errorReason: 'noAccount',
};

// clear the cache.
data.deleteCache( 'analytics', 'get-accounts' );
} else if ( ! selectedAccount ) {
Expand Down Expand Up @@ -298,7 +304,7 @@ class AnalyticsSetup extends Component {

newState = {
...newState,
errorCode: true,
errorCode: 'insufficient_permissions',
errorReason: 'insufficientPermissions',
};
}
Expand Down Expand Up @@ -860,6 +866,10 @@ class AnalyticsSetup extends Component {
onSettingsPage,
} = this.props;

if ( ! errorCode ) {
return null;
}

let showErrorFormat = true; // default error message.
let message = errorMsg;

Expand Down

0 comments on commit 53179bd

Please sign in to comment.