Skip to content

Commit

Permalink
fix qa
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoevanp committed Jan 19, 2024
1 parent 97d34e5 commit 44b22c0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
6 changes: 4 additions & 2 deletions apps/meteor/client/views/marketplace/AppInstallPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ const AppInstallPage = () => {
<FieldGroup display='flex' flexDirection='column' alignSelf='center' maxWidth='x600' w='full'>
<Field>
<FieldLabel htmlFor={urlField}>{t('App_Url_to_Install_From')}</FieldLabel>
<Callout type='warning' title={t('App_Installation_Deprecation')} />
<Callout type='warning' title={t('App_Installation_Deprecation_Title')}>
{t('App_Installation_Deprecation')}
</Callout>
<FieldRow>
<Controller
name='url'
Expand Down Expand Up @@ -77,7 +79,7 @@ const AppInstallPage = () => {
</Field>
<Field>
<ButtonGroup>
<Button disabled={!url || !file?.name} loading={isInstalling} onClick={install}>
<Button disabled={!url && !file?.name} loading={isInstalling} onClick={install}>
{t('Install')}
</Button>
<Button onClick={handleCancel}>{t('Cancel')}</Button>
Expand Down
13 changes: 9 additions & 4 deletions apps/meteor/client/views/marketplace/hooks/useInstallApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;
},
{
Expand Down Expand Up @@ -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(
<AppPermissionsReviewModal
appPermissions={permissions}
onCancel={cancelAction}
onConfirm={(permissionsGranted) => sendFile({ permissionsGranted, appFile })}
onConfirm={(permissionsGranted) => sendFile({ permissionsGranted, appFile, appId })}
/>,
);
};
Expand All @@ -91,7 +96,7 @@ export const useInstallApp = (file: File, url: string): { install: () => void; i
const isInstalled = await isAppInstalled(id);

if (isInstalled) {
return setModal(<AppUpdateModal cancel={cancelAction} confirm={() => handleAppPermissionsReview(permissions, appFile)} />);
return setModal(<AppUpdateModal cancel={cancelAction} confirm={() => handleAppPermissionsReview(permissions, appFile, id)} />);
}

await handleAppPermissionsReview(permissions, appFile);
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 0 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 44b22c0

Please sign in to comment.