Simplified plugin management logic, switched default manage plugins switch state to positive; finalized for merging into develop
This commit is contained in:
parent
61914666f8
commit
e64a280cee
|
|
@ -735,28 +735,6 @@ class Updates extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollback and remove plugins from the system.
|
||||
* @return void
|
||||
*/
|
||||
public function onRemovePlugins()
|
||||
{
|
||||
if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
|
||||
|
||||
foreach ($checkedIds as $objectId) {
|
||||
if (!$object = PluginVersion::find($objectId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginManager::instance()->deletePlugin($object->code);
|
||||
}
|
||||
|
||||
Flash::success(Lang::get('system::lang.plugins.remove_success'));
|
||||
}
|
||||
|
||||
return $this->listRefresh('manage');
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollback and remove a single plugin from the system.
|
||||
* @return void
|
||||
|
|
@ -764,9 +742,7 @@ class Updates extends Controller
|
|||
public function onRemovePlugin()
|
||||
{
|
||||
if ($pluginCode = post('code')) {
|
||||
|
||||
PluginManager::instance()->deletePlugin($pluginCode);
|
||||
|
||||
Flash::success(Lang::get('system::lang.plugins.remove_success'));
|
||||
}
|
||||
|
||||
|
|
@ -774,114 +750,67 @@ class Updates extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Rebuilds plugin database migrations.
|
||||
* Perform a bulk action on the provided plugins
|
||||
* @return void
|
||||
*/
|
||||
public function onRefreshPlugins()
|
||||
{
|
||||
if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
|
||||
|
||||
foreach ($checkedIds as $objectId) {
|
||||
if (!$object = PluginVersion::find($objectId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginManager::instance()->refreshPlugin($object->code);
|
||||
}
|
||||
|
||||
Flash::success(Lang::get('system::lang.plugins.refresh_success'));
|
||||
}
|
||||
|
||||
return $this->listRefresh('manage');
|
||||
}
|
||||
|
||||
public function onBulkAction()
|
||||
{
|
||||
if (($bulkAction = post('action')) && ($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
|
||||
|
||||
if (($bulkAction = post('action')) &&
|
||||
($checkedIds = post('checked')) &&
|
||||
is_array($checkedIds) &&
|
||||
count($checkedIds)
|
||||
) {
|
||||
$manager = PluginManager::instance();
|
||||
|
||||
foreach ($checkedIds as $pluginId) {
|
||||
|
||||
if (!$plugin = PluginVersion::find($pluginId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$savePlugin = true;
|
||||
switch ($bulkAction) {
|
||||
// Enables plugin's updates.
|
||||
case 'freeze':
|
||||
$plugin->is_frozen = 1;
|
||||
Flash::success(Lang::get('system::lang.plugins.freeze_success'));
|
||||
break;
|
||||
|
||||
// Disables plugin's updates.
|
||||
case 'unfreeze':
|
||||
$plugin->is_frozen = 0;
|
||||
Flash::success(Lang::get('system::lang.plugins.unfreeze_success'));
|
||||
break;
|
||||
|
||||
// Disables plugin on the system.
|
||||
case 'disable':
|
||||
$plugin->is_disabled = 1;
|
||||
$manager->disablePlugin($plugin->code, true);
|
||||
Flash::success(Lang::get('system::lang.plugins.disable_success'));
|
||||
break;
|
||||
|
||||
// Enables plugin on the system.
|
||||
case 'enable':
|
||||
$plugin->is_disabled = 0;
|
||||
$manager->enablePlugin($plugin->code, true);
|
||||
Flash::success(Lang::get('system::lang.plugins.enable_success'));
|
||||
break;
|
||||
|
||||
// Rebuilds plugin database migrations.
|
||||
case 'refresh':
|
||||
$savePlugin = false;
|
||||
$manager->refreshPlugin($plugin->code);
|
||||
break;
|
||||
|
||||
// Rollback and remove plugins from the system.
|
||||
case 'remove':
|
||||
$savePlugin = false;
|
||||
$manager->deletePlugin($plugin->code);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($savePlugin) {
|
||||
$plugin->save();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->listRefresh('manage');
|
||||
}
|
||||
|
||||
public function onToggleFreeze()
|
||||
{
|
||||
$plugin = PluginVersion::find(post('plugin_id'));
|
||||
|
||||
$freeze = post('freeze_' . $plugin->id);
|
||||
|
||||
$plugin->is_frozen = $freeze;
|
||||
$plugin->save();
|
||||
|
||||
if($freeze) {
|
||||
Flash::success(Lang::get('system::lang.plugins.freeze_success'));
|
||||
} else {
|
||||
Flash::success(Lang::get('system::lang.plugins.unfreeze_success'));
|
||||
}
|
||||
|
||||
return $this->listRefresh('manage');
|
||||
}
|
||||
|
||||
public function onToggleDisable()
|
||||
{
|
||||
$manager = PluginManager::instance();
|
||||
$plugin = PluginVersion::find(post('plugin_id'));
|
||||
|
||||
$disable = post('disable_' . $plugin->id);
|
||||
|
||||
if ($disable) {
|
||||
$manager->disablePlugin($plugin->code, true);
|
||||
}
|
||||
else {
|
||||
$manager->enablePlugin($plugin->code, true);
|
||||
}
|
||||
|
||||
$plugin->is_disabled = $disable;
|
||||
$plugin->save();
|
||||
|
||||
if ($disable) {
|
||||
Flash::success(Lang::get('system::lang.plugins.disable_success'));
|
||||
}
|
||||
else{
|
||||
Flash::success(Lang::get('system::lang.plugins.enable_success'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Flash::success(Lang::get("system::lang.plugins.{$bulkAction}_success"));
|
||||
return $this->listRefresh('manage');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
<label class="custom-switch" data-check="oc-disable-<?= $record->id ?>" style="margin-bottom:0">
|
||||
<input data-request="onToggleDisable"
|
||||
data-request-data="plugin_id: <?= $record->id ?>"
|
||||
data-request-update="list_manage_toolbar: '#plugin-toolbar'"
|
||||
type="checkbox"
|
||||
name="disable_<?= $record->id ?>"
|
||||
value="<?= $record->is_disabled ?>"
|
||||
<?php if($record->is_disabled): ?>checked=checked<?php endif ?>>
|
||||
|
||||
<span>
|
||||
<span><?= e(trans('system::lang.plugins.check_yes')) ?></span>
|
||||
<span><?= e(trans('system::lang.plugins.check_no')) ?></span>
|
||||
</span>
|
||||
<a class="slide-button"></a>
|
||||
</label>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?php $action = $record->is_disabled ? 'enable' : 'disable'; ?>
|
||||
<label class="custom-switch" data-check="oc-disable-<?= $record->id ?>" style="margin-bottom:0">
|
||||
<input data-request="onBulkAction"
|
||||
data-request-data="action: '<?= $action ?>', checked: [<?= $record->id ?>]"
|
||||
data-request-update="list_manage_toolbar: '#plugin-toolbar'"
|
||||
type="checkbox"
|
||||
name="disable_<?= $record->id ?>"
|
||||
value="<?= !$record->is_disabled ?>"
|
||||
<?php if (!$record->is_disabled) : ?>checked=checked<?php endif; ?>
|
||||
data-stripe-load-indicator
|
||||
>
|
||||
|
||||
<span>
|
||||
<span><?= e(trans('system::lang.plugins.check_yes')) ?></span>
|
||||
<span><?= e(trans('system::lang.plugins.check_no')) ?></span>
|
||||
</span>
|
||||
<a class="slide-button"></a>
|
||||
</label>
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<label class="custom-switch" data-check="oc-freeze-<?= $record->id ?>" style="margin-bottom:0">
|
||||
<input data-request="onToggleFreeze"
|
||||
data-request-data="plugin_id: <?= $record->id ?>"
|
||||
data-request-update="list_manage_toolbar: '#plugin-toolbar'"
|
||||
type="checkbox"
|
||||
name="freeze_<?= $record->id ?>"
|
||||
value="<?= $record->is_frozen ?>"
|
||||
<?php if($record->is_frozen): ?>checked=checked<?php endif ?>>
|
||||
|
||||
<span>
|
||||
<span><?= e(trans('system::lang.plugins.check_yes')) ?></span>
|
||||
<span><?= e(trans('system::lang.plugins.check_no')) ?></span>
|
||||
</span>
|
||||
<a class="slide-button"></a>
|
||||
</label>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?php $action = $record->is_frozen ? 'unfreeze' : 'freeze'; ?>
|
||||
<label class="custom-switch" data-check="oc-freeze-<?= $record->id ?>" style="margin-bottom:0">
|
||||
<input data-request="onBulkAction"
|
||||
data-request-data="action: '<?= $action ?>', checked: [<?= $record->id ?>]"
|
||||
data-request-update="list_manage_toolbar: '#plugin-toolbar'"
|
||||
type="checkbox"
|
||||
name="freeze_<?= $record->id ?>"
|
||||
value="<?= !$record->is_frozen ?>"
|
||||
<?php if (!$record->is_frozen) : ?>checked=checked<?php endif; ?>
|
||||
data-stripe-load-indicator
|
||||
>
|
||||
|
||||
<span>
|
||||
<span><?= e(trans('system::lang.plugins.check_yes')) ?></span>
|
||||
<span><?= e(trans('system::lang.plugins.check_no')) ?></span>
|
||||
</span>
|
||||
<a class="slide-button"></a>
|
||||
</label>
|
||||
|
|
@ -76,8 +76,8 @@
|
|||
<button
|
||||
class="btn btn-danger oc-icon-trash-o"
|
||||
disabled="disabled"
|
||||
data-request="onRemovePlugins"
|
||||
data-request-data="checked: $('.control-list').listWidget('getChecked')"
|
||||
data-request="onBulkAction"
|
||||
data-request-data="action: 'remove', checked: $('.control-list').listWidget('getChecked')"
|
||||
data-request-update="list_manage_toolbar: '#plugin-toolbar'"
|
||||
data-request-confirm="<?= e(trans('system::lang.plugins.remove_confirm')) ?>"
|
||||
data-trigger-action="enable"
|
||||
|
|
|
|||
|
|
@ -110,6 +110,8 @@ return [
|
|||
'select_label' => 'Select Action...',
|
||||
'check_yes' => 'Yes',
|
||||
'check_no' => 'No',
|
||||
'unfrozen' => 'Updates Enabled',
|
||||
'enabled' => 'Plugin Enabled',
|
||||
'freeze' => 'disable updates for',
|
||||
'unfreeze' => 'enable updates for',
|
||||
'enable' => 'enable',
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ columns:
|
|||
label: system::lang.updates.plugin_version
|
||||
sortable: false
|
||||
|
||||
is_frozen:
|
||||
label: system::lang.plugins.freeze_label
|
||||
is_unfrozen:
|
||||
label: system::lang.plugins.unfrozen
|
||||
type: partial
|
||||
path: is_frozen
|
||||
path: is_unfrozen
|
||||
sortable: false
|
||||
|
||||
is_disabled:
|
||||
label: system::lang.plugins.disable_label
|
||||
is_enabled:
|
||||
label: system::lang.plugins.enabled
|
||||
type: partial
|
||||
path: is_disabled
|
||||
path: is_enabled
|
||||
sortable: false
|
||||
|
|
|
|||
Loading…
Reference in New Issue