Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Error when re-installing an App #17789

Merged
merged 2 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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