diff --git a/resources/assets/js/helpers/utilities.js b/resources/assets/js/helpers/utilities.js index 9bbae1d9..994a7a8e 100644 --- a/resources/assets/js/helpers/utilities.js +++ b/resources/assets/js/helpers/utilities.js @@ -182,4 +182,40 @@ export default { } ) }, + compareVersion(v1, v2, options) { + const lexicographical = options && options.lexicographical + const zeroExtend = options && options.zeroExtend + let v1parts = v1.split('.') + let v2parts = v2.split('.') + function isValidPart(x) { + return (lexicographical ? /^\d+[A-Za-z]*$/ : /^\d+$/).test(x) + } + if (!v1parts.every(isValidPart) || !v2parts.every(isValidPart)) { + return NaN + } + if (zeroExtend) { + while (v1parts.length < v2parts.length) v1parts.push('0') + while (v2parts.length < v1parts.length) v2parts.push('0') + } + if (!lexicographical) { + v1parts = v1parts.map(Number) + v2parts = v2parts.map(Number) + } + for (let i = 0; i < v1parts.length; ++i) { + if (v2parts.length == i) { + return 1 + } + if (v1parts[i] == v2parts[i]) { + continue + } else if (v1parts[i] > v2parts[i]) { + return 1 + } else { + return -1 + } + } + if (v1parts.length != v2parts.length) { + return -1 + } + return 0 + }, } diff --git a/resources/assets/js/plugins/en.json b/resources/assets/js/plugins/en.json index 650a8e6e..defc054a 100644 --- a/resources/assets/js/plugins/en.json +++ b/resources/assets/js/plugins/en.json @@ -790,6 +790,7 @@ "check_update": "Check for updates", "avail_update": "New Update available", "next_version": "Next version", + "requirements": "Requirements", "update": "Update Now", "update_progress": "Update in progress...", "progress_text": "It will just take a few minutes. Please do not refresh the screen or close the window before the update finishes", @@ -802,7 +803,7 @@ "running_migrations": "Running Migrations", "finishing_update": "Finishing Update", "update_failed": "Update Failed", - "update_failed_text": "Sorry! Your update failed on : {step} step" + "update_failed_text": "Sorry! Your update failed on : {step} step" } }, "wizard": { diff --git a/resources/assets/js/views/settings/UpdateApp.vue b/resources/assets/js/views/settings/UpdateApp.vue index 96763a77..ea517f57 100644 --- a/resources/assets/js/views/settings/UpdateApp.vue +++ b/resources/assets/js/views/settings/UpdateApp.vue @@ -36,16 +36,44 @@ }}
-

{{ description }}

+

+ {{ description }} +

+ +
+
+
+ {{ i }}({{ minPhpVesrion }}) + + +
+
+ {{ i }} + + +
+
+
{{ $t('settings.update_app.update') }} +
@@ -131,6 +159,8 @@ export default { installed: '', version: '', }, + requiredExtentions: null, + minPhpVesrion: null, } }, created() { @@ -177,6 +207,8 @@ export default { this.updateData.version = response.data.version.version this.description = response.data.version.description this.isUpdateAvailable = true + this.requiredExtentions = response.data.version.extensions + this.minPhpVesrion = response.data.version.minimum_php_version } } catch (e) { this.isUpdateAvailable = false @@ -186,7 +218,17 @@ export default { }, async onUpdateApp() { let path = null - + if ( + this.$utils.compareVersion( + this.requiredExtentions.php, + this.minPhpVesrion + ) == -1 + ) { + window.toastr['error']( + 'Your current configuration does not match the update requirements. Please try again after all the requirements are fulfilled. ' + ) + return true + } for (let index = 0; index < this.updateSteps.length; index++) { let currentStep = this.updateSteps[index] try { @@ -230,15 +272,17 @@ export default { } }, onUpdateFailed(translationKey) { - let stepName = this.$t(translationKey) + let stepName = this.$t(translationKey) swal({ title: this.$t('settings.update_app.update_failed'), - text: this.$tc('settings.update_app.update_failed_text', stepName, {step: stepName}), + text: this.$tc('settings.update_app.update_failed_text', stepName, { + step: stepName, + }), buttons: [this.$t('general.cancel'), this.$t('general.retry')], }).then(async (value) => { if (value) { this.onUpdateApp() - return + return } this.isUpdating = false }) @@ -248,6 +292,12 @@ export default {