regression: Get add-on information from installed app version (#33841)

Co-authored-by: Douglas Gubert <1810309+d-gubert@users.noreply.github.com>
pull/33847/head
Tiago Evangelista Pinto 1 year ago committed by GitHub
parent 0ba1b70000
commit d7aa8eb10a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      apps/meteor/client/providers/AppsProvider/storeQueryFunction.ts
  2. 6
      apps/meteor/client/views/marketplace/AppDetailsPage/tabs/AppDetails/AppDetails.tsx
  3. 5
      apps/meteor/client/views/marketplace/AppDetailsPage/tabs/AppStatus/AppStatus.tsx
  4. 6
      apps/meteor/client/views/marketplace/AppsList/AddonRequiredModal.tsx
  5. 16
      apps/meteor/client/views/marketplace/hooks/useAppMenu.tsx
  6. 1
      packages/core-typings/src/Apps.ts
  7. 1
      packages/i18n/src/locales/en.i18n.json

@ -35,6 +35,7 @@ export function storeQueryFunction(
version: installedApp.version,
licenseValidation: installedApp.licenseValidation,
migrated: installedApp.migrated,
installedAddon: installedApp.addon,
}),
bundledIn: app.bundledIn,
marketplaceVersion: app.version,

@ -28,7 +28,9 @@ const AppDetails = ({ app }: AppDetailsProps) => {
screenshots,
apis,
documentationUrl: documentation,
addon: appAddon,
addon,
installedAddon,
installed,
} = app;
const isMarkdown = detailedDescription && Object.keys(detailedDescription).length !== 0 && detailedDescription.rendered;
@ -38,6 +40,8 @@ const AppDetails = ({ app }: AppDetailsProps) => {
const normalizedSupportUrl = support ? normalizeUrl(support) : undefined;
const normalizedDocumentationUrl = documentation ? normalizeUrl(documentation) : undefined;
const appAddon = installed ? installedAddon : addon;
const workspaceHasAddon = useHasLicenseModule(appAddon);
const openExternalLink = useExternalLink();

@ -88,11 +88,12 @@ const AppStatus = ({ app, showStatus = true, isAppDetailsPage, installed, ...pro
setLoading(true);
if (isAdminUser && appAddon && !workspaceHasAddon) {
return setModal(<AddonRequiredModal actionType='install' onDismiss={cancelAction} onInstallAnyway={appInstallationHandler} />);
const actionType = button?.action === 'update' ? 'update' : 'install';
return setModal(<AddonRequiredModal actionType={actionType} onDismiss={cancelAction} onInstallAnyway={appInstallationHandler} />);
}
appInstallationHandler();
}, [appAddon, appInstallationHandler, cancelAction, isAdminUser, setLoading, setModal, workspaceHasAddon]);
}, [button?.action, appAddon, appInstallationHandler, cancelAction, isAdminUser, setLoading, setModal, workspaceHasAddon]);
// @TODO we should refactor this to not use the label to determine the variant
const getStatusVariant = (status: appStatusSpanResponseProps) => {

@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
import { useExternalLink } from '../../../hooks/useExternalLink';
import { GET_ADDONS_LINK } from '../../admin/subscription/utils/links';
export type AddonActionType = 'install' | 'enable';
export type AddonActionType = 'install' | 'enable' | 'update';
type AddonRequiredModalProps = {
actionType: AddonActionType;
@ -29,7 +29,9 @@ const AddonRequiredModal = ({ actionType, onDismiss, onInstallAnyway }: AddonReq
<Modal.Content>{t('Add-on_required_modal_enable_content')}</Modal.Content>
<Modal.Footer>
<Modal.FooterControllers>
{actionType === 'install' && <Button onClick={onInstallAnyway}>{t('Install_anyway')}</Button>}
{['install', 'update'].includes(actionType) && (
<Button onClick={onInstallAnyway}>{actionType === 'install' ? t('Install_anyway') : t('Update_anyway')}</Button>
)}
<Button primary onClick={() => handleOpenLink(GET_ADDONS_LINK)}>
{t('Contact_sales')}
</Button>

@ -59,8 +59,8 @@ export const useAppMenu = (app: App, isAppDetailsPage: boolean) => {
const { data } = useIsEnterprise();
const isEnterpriseLicense = !!data?.isEnterprise;
const appAddon = app.addon;
const workspaceHasAddon = useHasLicenseModule(appAddon);
const workspaceHasMarketplaceAddon = useHasLicenseModule(app.addon);
const workspaceHasInstalledAddon = useHasLicenseModule(app.installedAddon);
const [isLoading, setLoading] = useState(false);
const [requestedEndUser, setRequestedEndUser] = useState(app.requestedEndUser);
@ -135,13 +135,17 @@ export const useAppMenu = (app: App, isAppDetailsPage: boolean) => {
const handleAddon = useCallback(
(actionType: AddonActionType, callback: () => void) => {
if (isAdminUser && appAddon && !workspaceHasAddon) {
if (actionType === 'enable' && isAdminUser && app.installedAddon && !workspaceHasInstalledAddon) {
return missingAddonHandler(actionType);
}
if (actionType !== 'enable' && isAdminUser && app.addon && !workspaceHasMarketplaceAddon) {
return missingAddonHandler(actionType);
}
callback();
},
[appAddon, isAdminUser, missingAddonHandler, workspaceHasAddon],
[app.addon, app.installedAddon, isAdminUser, missingAddonHandler, workspaceHasInstalledAddon, workspaceHasMarketplaceAddon],
);
const handleAcquireApp = useCallback(() => {
@ -325,8 +329,8 @@ export const useAppMenu = (app: App, isAppDetailsPage: boolean) => {
return;
}
openPermissionModal();
}, [app, openPermissionModal, openIncompatibleModal, closeModal]);
handleAddon('update', openPermissionModal);
}, [app, handleAddon, openPermissionModal, openIncompatibleModal, closeModal]);
const canUpdate = app.installed && app.version && app.marketplaceVersion && semver.lt(app.version, app.marketplaceVersion);

@ -95,6 +95,7 @@ export type App = {
version: string;
versionIncompatible?: boolean;
addon?: ExternalModuleName;
installedAddon?: ExternalModuleName;
price: number;
purchaseType: PurchaseType;
pricingPlans: AppPricingPlan[];

@ -2788,6 +2788,7 @@
"Inline_code": "Inline code",
"Install": "Install",
"Install_anyway": "Install anyway",
"Update_anyway": "Update anyway",
"Install_Extension": "Install Extension",
"Install_FxOs": "Install Rocket.Chat on your Firefox",
"Install_FxOs_done": "Great! You can now use Rocket.Chat via the icon on your homescreen. Have fun with Rocket.Chat!",

Loading…
Cancel
Save