Skip to content

Commit

Permalink
[FIX] Error when re-installing an App (#17789)
Browse files Browse the repository at this point in the history
* Fix wrong method call on app installation

* Update subscription check to take cancelled state into account
  • Loading branch information
d-gubert authored and sampaiodiego committed Jun 10, 2020
1 parent aedce8c commit af7b42d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/apps/client/admin/appManage.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ Template.appManage.events({
_app.set('working', true);

try {
const { status } = await Apps.updateApp(appId, _app.get('marketplaceVersion'));
const method = _app.get('installed') ? 'updateApp' : 'installApp';
const { status } = await Apps[method](appId, _app.get('marketplaceVersion'));
warnStatusChange(_app.get('name'), status);
} catch (error) {
handleAPIError(error);
Expand Down
7 changes: 6 additions & 1 deletion app/apps/client/admin/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ const appErroredStatuses = [
AppStatus.INVALID_LICENSE_DISABLED,
];

const subscriptionActiveStatuses = [
'trialing',
'active',
];

export const handleAPIError = (error) => {
console.error(error);
const message = (error.xhr && error.xhr.responseJSON && error.xhr.responseJSON.error) || error.message;
Expand Down Expand Up @@ -298,7 +303,7 @@ export const appButtonProps = ({
};
}

const canTrial = purchaseType === 'subscription' && !subscriptionInfo.status;
const canTrial = purchaseType === 'subscription' && !subscriptionActiveStatuses.includes(subscriptionInfo.status);
if (canTrial) {
return {
action: 'purchase',
Expand Down

0 comments on commit af7b42d

Please sign in to comment.