1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2024-11-24 19:33:07 +01:00

Merge pull request #760 from cloudron-io/disable-updates

WIP: Add config variable to disable update checks
This commit is contained in:
FreeScout 2020-09-24 13:55:48 +03:00 committed by GitHub
commit 069a44774e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 36 deletions

View File

@ -85,7 +85,7 @@ class SystemController extends Controller
// Commands
$commands_list = [
'freescout:fetch-emails' => 'freescout:fetch-emails',
'freescout:fetch-emails' => 'freescout:fetch-emails',
\Helper::getWorkerIdentifier() => 'queue:work'
];
foreach ($commands_list as $command_identifier => $command_name) {
@ -174,19 +174,23 @@ class SystemController extends Controller
];
}
// Check new version
// Check new version if enabled
$new_version_available = false;
$latest_version = \Cache::remember('latest_version', 15, function () {
try {
return \Updater::getVersionAvailable();
} catch (\Exception $e) {
SystemController::$latest_version_error = $e->getMessage();
return '';
}
});
if (!\Config::get('app.disable_updating')) {
$latest_version = \Cache::remember('latest_version', 15, function () {
try {
return \Updater::getVersionAvailable();
} catch (\Exception $e) {
SystemController::$latest_version_error = $e->getMessage();
return '';
}
});
if ($latest_version && version_compare($latest_version, \Config::get('app.version'), '>')) {
$new_version_available = true;
if ($latest_version && version_compare($latest_version, \Config::get('app.version'), '>')) {
$new_version_available = true;
}
} else {
$latest_version = \Config::get('app.version');
}
return view('system/status', [
@ -303,7 +307,7 @@ class SystemController extends Controller
case 'update':
try {
$status = \Updater::update();
// Artisan::output()
} catch (\Exception $e) {
$response['msg'] = __('Error occured. Please try again or try another :%a_start%update method:%a_end%', ['%a_start%' => '<a href="'.config('app.freescout_url').'/docs/update/" target="_blank">', '%a_end%' => '</a>']);
@ -319,14 +323,18 @@ class SystemController extends Controller
break;
case 'check_updates':
try {
$response['new_version_available'] = \Updater::isNewVersionAvailable(config('app.version'));
$response['status'] = 'success';
} catch (\Exception $e) {
$response['msg'] = __('Error occured').': '.$e->getMessage();
}
if (!$response['msg'] && !$response['new_version_available']) {
// Adding session flash is useless as cache is cleated
if (!\Config::get('app.disable_updating')) {
try {
$response['new_version_available'] = \Updater::isNewVersionAvailable(config('app.version'));
$response['status'] = 'success';
} catch (\Exception $e) {
$response['msg'] = __('Error occured').': '.$e->getMessage();
}
if (!$response['msg'] && !$response['new_version_available']) {
// Adding session flash is useless as cache is cleated
$response['msg_success'] = __('You have the latest version installed');
}
} else {
$response['msg_success'] = __('You have the latest version installed');
}
break;

View File

@ -268,9 +268,9 @@ return [
/*
|--------------------------------------------------------------------------
| none - send to the customer only agent's reply in the email.
|
|
| last - send to the customer the last message in the email.
|
|
| full - send to the customer full conversation history in the email.
|
|-------------------------------------------------------------------------
@ -280,7 +280,7 @@ return [
/*
|--------------------------------------------------------------------------
| none - send to the user only agent's reply in the email.
|
|
| last - send to the user the last message in the email.
|
| full - send to the user full conversation history in the email.
@ -289,6 +289,13 @@ return [
*/
'email_user_history' => env('APP_EMAIL_USER_HISTORY', 'full'),
/*
|--------------------------------------------------------------------------
| Disable update checker
|--------------------------------------------------------------------------
*/
'disable_updating' => env('APP_DISABLE_UPDATING', false),
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers

View File

@ -22,19 +22,23 @@
<tr id="version">
<th>{{ __('App Version') }}</th>
<td class="table-main-col">
@if ($new_version_available)
<strong class="text-danger">{{ \Config::get('app.version') }}</strong>
<div class="alert alert-danger margin-top-10">
{{ __('A new version is available') }}: <strong>{{ $latest_version }}</strong> <a href="{{ config('app.freescout_repo') }}/releases" target="_blank">({{ __('View details') }})</a>
<button class="btn btn-default btn-sm update-trigger margin-left-10" data-loading-text="{{ __('Updating') }}…{{ __('This may take several minutes') }}"><small class="glyphicon glyphicon-refresh"></small> {{ __('Update Now') }}</button>
</div>
@else
<strong class="text-success">{{ \Config::get('app.version') }}</strong>
&nbsp;&nbsp;
<a href="#" class="btn btn-default btn-xs check-updates-trigger" data-loading-text="{{ __('Checking') }}…">{{ __('Check for updates') }}</a>
@if ($latest_version_error)
<div class="text-danger margin-top">{{ $latest_version_error }}</div>
@if (!\Config::get('app.disable_updating'))
@if ($new_version_available)
<strong class="text-danger">{{ \Config::get('app.version') }}</strong>
<div class="alert alert-danger margin-top-10">
{{ __('A new version is available') }}: <strong>{{ $latest_version }}</strong> <a href="{{ config('app.freescout_repo') }}/releases" target="_blank">({{ __('View details') }})</a>
<button class="btn btn-default btn-sm update-trigger margin-left-10" data-loading-text="{{ __('Updating') }}…{{ __('This may take several minutes') }}"><small class="glyphicon glyphicon-refresh"></small> {{ __('Update Now') }}</button>
</div>
@else
<strong class="text-success">{{ \Config::get('app.version') }}</strong>
&nbsp;&nbsp;
<a href="#" class="btn btn-default btn-xs check-updates-trigger" data-loading-text="{{ __('Checking') }}…">{{ __('Check for updates') }}</a>
@if ($latest_version_error)
<div class="text-danger margin-top">{{ $latest_version_error }}</div>
@endif
@endif
@else
<strong class="text-success">{{ \Config::get('app.version') }}</strong>
@endif
</td>
</tr>