Skip to content

Commit

Permalink
chore: remove unused modal from app install (#33522)
Browse files Browse the repository at this point in the history
* chore: remove unused modal from app install

* test: update tests

* fix: unused translation keys
  • Loading branch information
MartinSchoeler authored and ggazzo committed Oct 17, 2024
1 parent 8c605ab commit 13c906f
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { useTranslation } from '@rocket.chat/ui-contexts';
import React from 'react';

import MarkdownText from '../../../../components/MarkdownText';
import type { MarketplaceRouteContext } from '../../hooks/useAppsCountQuery';

type AppsInstallationModalProps = {
context: MarketplaceRouteContext;
enabled: number;
limit: number;
appName: string;
Expand All @@ -16,7 +14,6 @@ type AppsInstallationModalProps = {
};

const AppInstallationModal = ({
context,
enabled,
limit,
appName,
Expand All @@ -28,35 +25,34 @@ const AppInstallationModal = ({

const getTitle = () => {
if (enabled === limit) {
return context === 'private' ? t('Private_apps_limit_reached') : t('App_limit_reached');
return t('App_limit_reached');
}

if (enabled > limit) {
return context === 'private' ? t('Private_apps_limit_exceeded') : t('App_limit_exceeded');
return t('App_limit_exceeded');
}

return t('Apps_Currently_Enabled', { context: context === 'private' ? context : '', enabled, limit });
return t('Apps_Currently_Enabled', { context: '', enabled, limit });
};

const getContent = () => {
if (enabled === limit) {
return t('Enable_of_limit_apps_currently_enabled', { context: context === 'private' ? context : '', enabled, limit, appName });
return t('Enable_of_limit_apps_currently_enabled', { context: '', enabled, limit, appName });
}

if (enabled > limit) {
return t('Enable_of_limit_apps_currently_enabled_exceeded', {
...(context === 'private' && { context }),
enabled,
limit,
exceed: enabled - limit + 1,
appName,
});
}

return t('Workspaces_on_Community_edition_install_app', { context: context === 'private' ? context : '', enabled, limit });
return t('Workspaces_on_Community_edition_install_app', { context: '', enabled, limit });
};

const confirmButtonOverlimitLabel = context === 'private' ? t('Upload_anyway') : t('Install_anyway');
const confirmButtonOverLimitLabel = t('Install_anyway');

return (
<>
Expand All @@ -76,7 +72,7 @@ const AppInstallationModal = ({
<Modal.FooterControllers>
<Button onClick={handleEnableUnlimitedApps}>{t('Enable_unlimited_apps')}</Button>
<Button {...(enabled < limit && { primary: true })} onClick={handleConfirm}>
{enabled < limit ? t('Next') : confirmButtonOverlimitLabel}
{enabled < limit ? t('Next') : confirmButtonOverLimitLabel}
</Button>
</Modal.FooterControllers>
</Modal.Footer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export function useAppInstallationHandler({

setModal(
<AppInstallModal
context={context}
enabled={appCountQuery.data.enabled}
limit={appCountQuery.data.limit}
appName={app.name}
Expand All @@ -143,17 +142,16 @@ export function useAppInstallationHandler({
);
}, [
app,
appsOrchestrator,
action,
appCountQuery.data,
setModal,
context,
closeModal,
acquireApp,
openIncompatibleModal,
dispatchToastMessage,
notifyAdmins,
success,
appsOrchestrator,
onDismiss,
openExternalLink,
manageSubscriptionUrl,
Expand Down
25 changes: 1 addition & 24 deletions apps/meteor/client/views/marketplace/hooks/useInstallApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,20 @@ import React, { useCallback, useState } from 'react';

import { AppClientOrchestratorInstance } from '../../../apps/orchestrator';
import { useAppsReload } from '../../../contexts/hooks/useAppsReload';
import { useExternalLink } from '../../../hooks/useExternalLink';
import { useCheckoutUrl } from '../../admin/subscription/hooks/useCheckoutUrl';
import AppPermissionsReviewModal from '../AppPermissionsReviewModal';
import AppUpdateModal from '../AppUpdateModal';
import AppInstallationModal from '../components/AppInstallModal/AppInstallModal';
import { handleAPIError } from '../helpers/handleAPIError';
import { handleInstallError } from '../helpers/handleInstallError';
import { getManifestFromZippedApp } from '../lib/getManifestFromZippedApp';
import { useAppsCountQuery } from './useAppsCountQuery';

export const useInstallApp = (file: File): { install: () => void; isInstalling: boolean } => {
const reloadAppsList = useAppsReload();
const openExternalLink = useExternalLink();
const setModal = useSetModal();

const router = useRouter();

const appCountQuery = useAppsCountQuery('private');
const manageSubscriptionUrl = useCheckoutUrl()({ target: 'marketplace-app-install', action: 'Enable_unlimited_apps' });

const uploadAppEndpoint = useUpload('/apps');
const uploadUpdateEndpoint = useUpload('/apps/update');
Expand Down Expand Up @@ -126,25 +121,7 @@ export const useInstallApp = (file: File): { install: () => void; isInstalling:
return cancelAction();
}

if (appCountQuery.data.hasUnlimitedApps) {
return uploadFile(appFile, manifest);
}

setModal(
<AppInstallationModal
context='private'
enabled={appCountQuery.data.enabled}
limit={appCountQuery.data.limit}
appName={manifest.name}
handleClose={cancelAction}
handleConfirm={() => uploadFile(appFile, manifest)}
handleEnableUnlimitedApps={() => {
openExternalLink(manageSubscriptionUrl);
setModal(null);
setInstalling(false);
}}
/>,
);
return uploadFile(appFile, manifest);
};

return { install, isInstalling };
Expand Down
8 changes: 0 additions & 8 deletions apps/meteor/tests/e2e/apps/private-apps-upload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ test.describe.serial('Private apps upload', () => {
await expect(poMarketplace.btnInstallPrivateApp).toBeEnabled();
await poMarketplace.btnInstallPrivateApp.click();

await expect(poMarketplace.confirmAppUploadModalTitle).toHaveText('Private apps limit reached');
await expect(poMarketplace.btnConfirmAppUploadModal).toBeEnabled();
await poMarketplace.btnConfirmAppUploadModal.click();

await page.getByRole('button', { name: 'Agree' }).click();
await expect(poMarketplace.appStatusTag).toHaveText('Disabled');
});
Expand All @@ -132,10 +128,6 @@ test.describe.serial('Private apps upload', () => {
await expect(poMarketplace.btnInstallPrivateApp).toBeEnabled();
await poMarketplace.btnInstallPrivateApp.click();

await expect(poMarketplace.confirmAppUploadModalTitle).toHaveText('Private apps limit reached');
await expect(poMarketplace.btnConfirmAppUploadModal).toBeEnabled();
await poMarketplace.btnConfirmAppUploadModal.click();

await poMarketplace.btnConfirmAppUpdate.click();

await page.getByRole('button', { name: 'Agree' }).click();
Expand Down
2 changes: 0 additions & 2 deletions packages/i18n/src/locales/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -6354,8 +6354,6 @@
"Upload_anyway": "Upload anyway",
"App_limit_reached": "App limit reached",
"App_limit_exceeded": "App limit exceeded",
"Private_apps_limit_reached": "Private apps limit reached",
"Private_apps_limit_exceeded": "Private apps limit exceeded",
"Disable_at_least_more_apps": "You will need to disable at least {{numberOfExceededApps}} other apps or upgrade to a Premium plan to enable this app.",
"Community_Private_apps_limit_exceeded": "Community app limit has been exceeded.",
"Theme_match_system": "Match system",
Expand Down
2 changes: 0 additions & 2 deletions packages/i18n/src/locales/es.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -4918,8 +4918,6 @@
"Theme_dark": "Oscuro",
"Theme_dark_description": "Reduzca la fatiga ocular en condiciones de poca luz minimizando la cantidad de luz emitida por la pantalla.",
"Workspaces_on_Community_edition_install_app": "Los espacios de trabajo comunitarios pueden tener hasta {{limit}} {{context}} aplicaciones habilitadas. Actualiza a un plan Premium para habilitar un número ilimitado de aplicaciones.",
"Private_apps_limit_reached": "Límite de aplicaciones privadas alcanzado",
"Private_apps_limit_exceeded": "Límite de aplicaciones privadas superado",
"Disable_at_least_more_apps": "Tendrás que desactivar al menos {{numberOfExceededApps}} aplicaciones o actualizar a un plan Premium para activar esta aplicación.",
"Join_your_team": "Únete a tu equipo",
"Create_a_password": "Crear una contraseña",
Expand Down
2 changes: 0 additions & 2 deletions packages/i18n/src/locales/fi.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -5638,8 +5638,6 @@
"Upload_anyway": "Lataa silti",
"App_limit_reached": "Sovellusraja saavutettu",
"App_limit_exceeded": "Sovellusraja ylitetty",
"Private_apps_limit_reached": "Yksityisten sovellusten raja saavutettu",
"Private_apps_limit_exceeded": "Yksityisten sovellusten raja ylitetty",
"Disable_at_least_more_apps": "Poista käytöstä vähintään {{numberOfExceededApps}} muuta sovellusta tai päivitä yritysversioon, jotta voit ottaa tämän sovelluksen käyttöön.",
"Community_Private_apps_limit_exceeded": "Yhteisöversion sovellusraja on ylitetty.",
"Theme_match_system": "Järjestelmän mukaan",
Expand Down
2 changes: 0 additions & 2 deletions packages/i18n/src/locales/hi-IN.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -5932,8 +5932,6 @@
"Upload_anyway": "फिर भी अपलोड करें",
"App_limit_reached": "ऐप की सीमा पूरी हो गई",
"App_limit_exceeded": "ऐप की सीमा पार हो गई",
"Private_apps_limit_reached": "निजी ऐप्स की सीमा पूरी हो गई",
"Private_apps_limit_exceeded": "निजी ऐप्स की सीमा पार हो गई",
"Disable_at_least_more_apps": "इस ऐप को सक्षम करने के लिए आपको कम से कम {{numberOfExceededApps}} अन्य ऐप्स को अक्षम करना होगा या प्रीमियम प्लान में अपग्रेड करना होगा।",
"Community_Private_apps_limit_exceeded": "सामुदायिक ऐप की सीमा पार हो गई है.",
"Theme_match_system": "मिलान प्रणाली",
Expand Down
2 changes: 0 additions & 2 deletions packages/i18n/src/locales/it.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -3366,8 +3366,6 @@
"subscription.callout.privateApps": "applicazioni private installate",
"subscription.callout.marketplaceApps": "applicazioni del marketplace installate",
"subscription.callout.monthlyActiveContacts": "contatti attivi mensili",
"Private_apps_limit_reached": "Limite di app private raggiunto",
"Private_apps_limit_exceeded": "Limite di app private superato",
"Time": "Tempo",
"This_attachment_is_not_supported": "Formato dell'allegato non supportato",
"Send_transcript": "Invia la trascrizione",
Expand Down
4 changes: 0 additions & 4 deletions packages/i18n/src/locales/nn.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -4523,10 +4523,6 @@
"subscription.callout.monthlyActiveContacts": "månedlige aktive kontakter",
"Upload_anyway": "Last opp allikevel",
"App_limit_reached": "Appgrensen er nådd",
"App_limit_exceeded": "Appgrensen er overskredet",
"Private_apps_limit_reached": "Grensen for private apper er nådd",
"Private_apps_limit_exceeded": "Grensen for private apper er overskredet",
"Community_Private_apps_limit_exceeded": "Grensen for Community-apper er overskredet.",
"Theme_high_contrast": "Høy kontrast",
"Highlighted_chosen_word": "Uthevet valgt ord",
"Join_your_team": "Bli med teamet ditt",
Expand Down
2 changes: 0 additions & 2 deletions packages/i18n/src/locales/no.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -4524,8 +4524,6 @@
"Upload_anyway": "Last opp allikevel",
"App_limit_reached": "Appgrensen er nådd",
"App_limit_exceeded": "Appgrensen er overskredet",
"Private_apps_limit_reached": "Grensen for private apper er nådd",
"Private_apps_limit_exceeded": "Grensen for private apper er overskredet",
"Community_Private_apps_limit_exceeded": "Grensen for Community-apper er overskredet.",
"Theme_high_contrast": "Høy kontrast",
"Highlighted_chosen_word": "Uthevet valgt ord",
Expand Down
2 changes: 0 additions & 2 deletions packages/i18n/src/locales/se.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -6337,8 +6337,6 @@
"Upload_anyway": "Upload anyway",
"App_limit_reached": "App limit reached",
"App_limit_exceeded": "App limit exceeded",
"Private_apps_limit_reached": "Private apps limit reached",
"Private_apps_limit_exceeded": "Private apps limit exceeded",
"Disable_at_least_more_apps": "You will need to disable at least {{numberOfExceededApps}} other apps or upgrade to a Premium plan to enable this app.",
"Community_Private_apps_limit_exceeded": "Community app limit has been exceeded.",
"Theme_match_system": "Match system",
Expand Down
2 changes: 0 additions & 2 deletions packages/i18n/src/locales/sv.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -5646,8 +5646,6 @@
"Upload_anyway": "Ladda upp ändå",
"App_limit_reached": "App-gränsen har nåtts",
"App_limit_exceeded": "App-gränsen har överskridits",
"Private_apps_limit_reached": "Gränsen för privata appar har nåtts",
"Private_apps_limit_exceeded": "Gränsen för privata appar har överskridits",
"Disable_at_least_more_apps": "Du måste inaktivera minst {{numberOfExceededApps}} andra appar eller uppgradera till Enterprise för att aktivera den här appen.",
"Community_Private_apps_limit_exceeded": "Gränsen för appar i Community Edition har överskridits.",
"Theme_match_system": "Matchningssystem",
Expand Down

0 comments on commit 13c906f

Please sign in to comment.