From 44b22c092f8c58a6ff299d75c59530a858e3f502 Mon Sep 17 00:00:00 2001 From: Tiago Evangelista Pinto Date: Fri, 19 Jan 2024 13:49:02 -0300 Subject: [PATCH] fix qa --- .../client/views/marketplace/AppInstallPage.tsx | 6 ++++-- .../views/marketplace/hooks/useInstallApp.tsx | 13 +++++++++---- .../packages/rocketchat-i18n/i18n/en.i18n.json | 1 + yarn.lock | 12 ------------ 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/apps/meteor/client/views/marketplace/AppInstallPage.tsx b/apps/meteor/client/views/marketplace/AppInstallPage.tsx index 3570c6719486..5168f978b4bc 100644 --- a/apps/meteor/client/views/marketplace/AppInstallPage.tsx +++ b/apps/meteor/client/views/marketplace/AppInstallPage.tsx @@ -42,7 +42,9 @@ const AppInstallPage = () => { {t('App_Url_to_Install_From')} - + + {t('App_Installation_Deprecation')} + { - diff --git a/apps/meteor/client/views/marketplace/hooks/useInstallApp.tsx b/apps/meteor/client/views/marketplace/hooks/useInstallApp.tsx index ba96470490f9..78a0283ef8a9 100644 --- a/apps/meteor/client/views/marketplace/hooks/useInstallApp.tsx +++ b/apps/meteor/client/views/marketplace/hooks/useInstallApp.tsx @@ -26,6 +26,7 @@ export const useInstallApp = (file: File, url: string): { install: () => void; i const manageSubscriptionUrl = useCheckoutUrl()({ target: 'marketplace-app-install', action: 'Enable_unlimited_apps' }); const uploadAppEndpoint = useUpload('/apps'); + const uploadUpdateEndpoint = useUpload('/apps/update'); // TODO: This function should not be called in a next major version, it will be changed by an endpoint deprecation. const downloadPrivateAppFromUrl = useEndpoint('POST', '/apps'); @@ -34,11 +35,15 @@ export const useInstallApp = (file: File, url: string): { install: () => void; i const { mutate: sendFile } = useMutation( ['apps/installPrivateApp'], - ({ permissionsGranted, appFile }: { permissionsGranted: AppPermission[]; appFile: File }) => { + ({ permissionsGranted, appFile, appId }: { permissionsGranted: AppPermission[]; appFile: File; appId?: string }) => { const fileData = new FormData(); fileData.append('app', appFile, appFile.name); fileData.append('permissions', JSON.stringify(permissionsGranted)); + if (appId) { + return uploadUpdateEndpoint(fileData); + } + return uploadAppEndpoint(fileData) as any; }, { @@ -77,12 +82,12 @@ export const useInstallApp = (file: File, url: string): { install: () => void; i } }; - const handleAppPermissionsReview = async (permissions: AppPermission[], appFile: File) => { + const handleAppPermissionsReview = async (permissions: AppPermission[], appFile: File, appId?: string) => { setModal( sendFile({ permissionsGranted, appFile })} + onConfirm={(permissionsGranted) => sendFile({ permissionsGranted, appFile, appId })} />, ); }; @@ -91,7 +96,7 @@ export const useInstallApp = (file: File, url: string): { install: () => void; i const isInstalled = await isAppInstalled(id); if (isInstalled) { - return setModal( handleAppPermissionsReview(permissions, appFile)} />); + return setModal( handleAppPermissionsReview(permissions, appFile, id)} />); } await handleAppPermissionsReview(permissions, appFile); diff --git a/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json b/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json index b7298f318367..b157de26916a 100644 --- a/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json @@ -506,6 +506,7 @@ "App_Information": "App Information", "Apps_context_enterprise": "Enterprise", "App_Installation": "App Installation", + "App_Installation_Deprecation_Title": "Deprecation Warning", "App_Installation_Deprecation": "Install apps from URL is deprecated and will be removed in the next major release.", "App_not_enabled": "App not enabled", "App_not_found": "App not found", diff --git a/yarn.lock b/yarn.lock index 5953649266f6..93ace4f75e01 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9147,18 +9147,6 @@ __metadata: languageName: node linkType: hard -"@rocket.chat/fuselage-hooks@npm:^0.33.0": - version: 0.33.0 - resolution: "@rocket.chat/fuselage-hooks@npm:0.33.0" - dependencies: - use-sync-external-store: ~1.2.0 - peerDependencies: - "@rocket.chat/fuselage-tokens": "*" - react: ^17.0.2 - checksum: addf78db893c3185d4d5fc347e1aa81710e0939505a08db77e524740d05555c5e8556d2b6f0e6425270621bdd7230d13278add77ce38197c048af30207cce853 - languageName: node - linkType: hard - "@rocket.chat/fuselage-polyfills@npm:~0.31.25": version: 0.31.25 resolution: "@rocket.chat/fuselage-polyfills@npm:0.31.25"