From ad656b925f32941b9d0ec3c3903de46b13a912cb Mon Sep 17 00:00:00 2001 From: axolotle Date: Tue, 15 Nov 2022 12:40:15 +0100 Subject: [PATCH] AppInstall: display warning/danger depending on potential several problems --- app/src/i18n/locales/en.json | 16 +++++ app/src/views/app/AppInstall.vue | 105 +++++++++++++++++++++++++++++-- 2 files changed, 117 insertions(+), 4 deletions(-) diff --git a/app/src/i18n/locales/en.json b/app/src/i18n/locales/en.json index e940ab97..43c49f1d 100644 --- a/app/src/i18n/locales/en.json +++ b/app/src/i18n/locales/en.json @@ -57,6 +57,22 @@ "app": { "antifeatures": "Antifeatures:", "install": { + "before_install": { + "warning": "Things to know before installation", + "danger": "The installation of the application will most likely lead to issues", + "critical": "The application cannot be installed" + }, + "problems": { + "arch": "It is incompatible with your system architecture", + "broken": "This application is broken according to YunoHost's automatic tests and it is likely to break your system! You should probably NOT install it unless you know what you are doing.", + "thirdparty": "This application is not part of the official YunoHost catalog, installing 3rd party applications may compromise the integrity and security of your system. You should probably NOT install it unless you know what you are doing.", + "ignore": "I understand that this installation may break my system but i still want to try.", + "inprogress": "This application is still experimental (if not explicitly not working) and it is likely to break your system! You should probably NOT install it unless you know what you are doing.", + "install": "It is already installed and can't be installed more than once.", + "lowquality": "This application may work but is not well-integrated in YunoHost. Some features such as single sign-on and backup/restore might not be available, or it does not respect the good practices.", + "ram": "This application requires {required} of RAM to install/upgrade but only {current} is available right now. Even if this app could run, its installation process requires a large amount of RAM so your server may freeze and fail miserably.", + "version": "It is not compatible with your current YunoHost version, consider first upgrading YunoHost." + }, "try_demo": "Try the demo", "version": "Current version: {version}" }, diff --git a/app/src/views/app/AppInstall.vue b/app/src/views/app/AppInstall.vue index bcbb03d3..1b85d948 100644 --- a/app/src/views/app/AppInstall.vue +++ b/app/src/views/app/AppInstall.vue @@ -58,8 +58,60 @@ + +

{{ $t('app.install.before_install.warning') }}

+ + + +

+ + + + + +

{{ $t('app.install.before_install.critical') }}

+ +

+ {{ $t('app.install.problems.arch') }} +

+

+ {{ $t('app.install.problems.install') }} +

+

+ {{ $t('app.install.problems.version') }} +

+
+ + +

{{ $t('app.install.before_install.danger') }}

+ +

+

+ {{ $t('app.install.problems.ram', app.requirements.ram.values) }} +

+ + +
+ ([af.id, af]))) + + const { id, name, version, requirements } = _app const _archs = _app.integration.architectures + const quality = { state: _app.quality.state, variant: 'danger' } + if (quality.state === 'working') { + if (_app.quality.level <= 0) { + quality.state = 'broken' + } else if (_app.quality.level <= 4) { + quality.state = 'lowquality' + quality.variant = 'warning' + } else { + quality.variant = 'success' + quality.state = _app.quality.level >= 8 ? 'highquality' : 'goodquality' + } + } + const preInstall = formatI18nField(_app.notifications.pre_install.main) + const antifeatures = _app.antifeatures?.length + ? _app.antifeatures.map((af) => antifeaturesList[af]) + : null + + const hasDanger = quality.variant === 'danger' || !requirements.ram.pass + const hasSupport = Object.keys(requirements).every((key) => { + // ram support is non-blocking requirement and handled on its own. + return key === 'ram' || requirements[key].pass + }) + const app = { id, name, @@ -154,7 +233,15 @@ export default { ...['website', 'admindoc', 'code'].map((key) => ([key, _app.upstream[key]])), ['package', _app.remote.url], ['forum', `https://forum.yunohost.org/tag/${id}`] - ].filter(([key, val]) => !!val) + ].filter(([key, val]) => !!val), + preInstall, + antifeatures, + quality, + requirements, + hasWarning: !!preInstall || antifeatures || quality.variant === 'warning', + hasDanger, + hasSupport, + canInstall: hasSupport && !hasDanger } // FIXME yunohost should add the label field by default @@ -205,3 +292,13 @@ export default { } } + +