Skip to content

Commit

Permalink
[FIX] Resolve 'app already exists' error on app update (#17544)
Browse files Browse the repository at this point in the history
* fix: resolve 'app already exists' error on app update

The 'Apps' and 'Marketplace' admin pages were using the function
`installApp` from the `AppClientOrchestrator` class instead of `updateApp` to
update apps. As a result, the 'app already exists' error was being thrown and
apps were not being updated.

* fix: remove `install app` handle from apps admin page

As the `install app` handle is only needed in the marketplace page,
there's no need to have it in the apps admin page.
  • Loading branch information
thassiov committed May 12, 2020
1 parent 960bed4 commit 8b380ab
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/apps/client/admin/apps.js
Expand Up @@ -226,7 +226,7 @@ Template.apps.events({
} = instance.state.get('apps').find(({ id }) => id === currentTarget.dataset.id);
FlowRouter.go('app-manage', { appId }, { version });
},
async 'click .js-install, click .js-update'(event, instance) {
async 'click .js-update'(event, instance) {
event.preventDefault();
event.stopPropagation();

Expand All @@ -240,7 +240,7 @@ Template.apps.events({
instance.startAppWorking(app.id);

try {
const { status } = await Apps.installApp(app.id, app.marketplaceVersion);
const { status } = await Apps.updateApp(app.id, app.marketplaceVersion);
warnStatusChange(app.name, status);
} catch (error) {
handleAPIError(error);
Expand Down
28 changes: 27 additions & 1 deletion app/apps/client/admin/marketplace.js
Expand Up @@ -273,7 +273,7 @@ Template.marketplace.events({
} = instance.state.get('apps').find(({ id }) => id === currentTarget.dataset.id);
FlowRouter.go('marketplace-app', { appId }, { version: version || marketplaceVersion });
},
async 'click .js-install, click .js-update'(event, instance) {
async 'click .js-install'(event, instance) {
event.preventDefault();
event.stopPropagation();

Expand All @@ -284,6 +284,7 @@ Template.marketplace.events({
}

const { currentTarget: button } = event;

const app = instance.state.get('apps').find(({ id }) => id === button.dataset.id);

instance.startAppWorking(app.id);
Expand All @@ -297,6 +298,31 @@ Template.marketplace.events({
instance.stopAppWorking(app.id);
}
},
async 'click .js-update'(event, instance) {
event.preventDefault();
event.stopPropagation();

const isLoggedInCloud = await checkCloudLogin();
instance.state.set('isLoggedInCloud', isLoggedInCloud);
if (!isLoggedInCloud) {
return;
}

const { currentTarget: button } = event;

const app = instance.state.get('apps').find(({ id }) => id === button.dataset.id);

instance.startAppWorking(app.id);

try {
const { status } = await Apps.updateApp(app.id, app.marketplaceVersion);
warnStatusChange(app.name, status);
} catch (error) {
handleAPIError(error);
} finally {
instance.stopAppWorking(app.id);
}
},
async 'click .js-purchase'(event, instance) {
event.preventDefault();
event.stopPropagation();
Expand Down

0 comments on commit 8b380ab

Please sign in to comment.