Skip to content

Commit

Permalink
SW-19502 - Improve update notification for plugin updates in the updater
Browse files Browse the repository at this point in the history
  • Loading branch information
janbuecker committed Aug 17, 2017
1 parent 5287078 commit 0e6acfc
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,23 @@ public function checkInstalledPluginsAvailableForNewVersion($version)
try {
$results = [];
foreach ($installedPlugins as $plugin) {
$technicalName = $plugin['name'];
$key = strtolower($plugin['name']);
$name = $plugin['label'];

$inStore = array_key_exists($key, $storePlugins);
$available = array_key_exists($key, $updatesAvailable);
$updatable = $available && version_compare($plugin['version'], $updatesAvailable[$key]->getVersion(), '<');
$technicalName = $plugin['name'];
$description = $this->getPluginStateDescription($inStore, $available);
$targetVersionUpdateAvailable = array_key_exists($key, $updatesAvailable);
$description = $this->getPluginStateDescription($inStore, $targetVersionUpdateAvailable);

$results[] = [
'inStore' => $inStore,
'name' => $name,
'message' => $description,
'updatable' => $updatable,
'updatable' => $inStore && version_compare($plugin['version'], $storePlugins[$key]->getVersion(), '<'),
'updatableAfterUpgrade' => $inStore && $targetVersionUpdateAvailable && $storePlugins[$key]->getVersion() !== $updatesAvailable[$key]->getVersion(),
'id' => sprintf('plugin_incompatible-%s', $name),
'technicalName' => $technicalName,
'errorLevel' => ($available) ? Validation::REQUIREMENT_VALID : Validation::REQUIREMENT_WARNING,
'errorLevel' => ($targetVersionUpdateAvailable) ? Validation::REQUIREMENT_VALID : Validation::REQUIREMENT_WARNING,
];
}
} catch (\Exception $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ columns/is_latest_version = "Version"
plugin/update/message = "Currently, there are [0] pending update(s) for plugins. We strongly recommend to update these plugins before updating the shop. After updating your shop, please check if further updates are also available for your plugins."
plugin/update/message/title = "Attention"
plugin/update/quick_tip = "An update is available for this plugin"
plugin/update/update_after_upgrade = "After the Shopware update, an update is available for this plugin"

[de_DE]
cancel = "Abbrechen"
Expand Down Expand Up @@ -144,4 +145,5 @@ controller/check_emotiontemplate_success = "Kein Emotion Template verwendet."
columns/is_latest_version = "Version"
plugin/update/message = "Aktuell gibt es noch [0] austehende(s) Update(s) für Plugins. Wir raten dringend, die Updates vor dem Shopupdate einzuspielen. Bitte vergewissern Sie sich zudem nach dem Shopupdate, ob weitere Updates für Plugins zur Verfügung stehen."
plugin/update/message/title = "Achtung"
plugin/update/quick_tip = "Für dieses Plugin steht ein Update zur Verfügung"
plugin/update/quick_tip = "Für dieses Plugin steht ein Update zur Verfügung"
plugin/update/update_after_upgrade = "Nach dem Shopware-Update steht für dieses Plugin ein Update zur Verfügung"
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,29 @@ Ext.define('Shopware.apps.SwagUpdate.controller.Main', {

onPluginStoreLoaded: function() {
var me = this,
pluginCount = 0;
updatablePlugins = 0,
updatablePluginsAfterUpgrade = 0;

me.pluginsStore.each(function(plugin) {
if (plugin.get('updatable')) {
pluginCount++;
updatablePlugins++;
}

if (plugin.get('updatableAfterUpgrade')) {
updatablePluginsAfterUpgrade++;
}
});

if (pluginCount == 0) {
if (updatablePlugins === 0 && updatablePluginsAfterUpgrade === 0) {
return;
}

me.mainWindow.showHintContainer(pluginCount);
me.changeTabIcon(me.mainWindow.down('#update-plugin-tab'), 10);
me.mainWindow.hintContainer.update();
if (updatablePlugins) {
me.changeTabIcon(me.mainWindow.down('#update-plugin-tab'), 10);
me.mainWindow.showHintContainer(updatablePlugins);
me.mainWindow.hintContainer.update();
}

me.addQuickTips();
},

Expand All @@ -139,13 +147,26 @@ Ext.define('Shopware.apps.SwagUpdate.controller.Main', {
Ext.tip.QuickTipManager.init();
me.mainWindow.pluginsGrid.getStore().each(function(plugin) {

if(plugin.get('updatable') === true) {
if (plugin.get('updatable') === true) {
Ext.tip.QuickTipManager.register({
target: Ext.get(plugin.get('technicalName')),
text: '{s name="plugin/update/quick_tip"}{/s}',
width: 180,
dismissDelay: 10000
});
} else if (plugin.get('updatableAfterUpgrade') === true) {
var node = Ext.get(me.mainWindow.pluginsGrid.getView().getNode(plugin));

if (!node) {
return;
}

Ext.tip.QuickTipManager.register({
target: node.down('.x-action-col-cell'),
text: '{s name="plugin/update/update_after_upgrade"}{/s}',
width: 180,
dismissDelay: 10000
});
}
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Ext.define('Shopware.apps.SwagUpdate.model.Plugins', {
{ name: 'requiredVersion', type: 'string' },
{ name: 'message', type: 'string' },
{ name: 'errorLevel', type: 'int' },
{ name: 'updatable', type: 'boolean'},
{ name: 'updatable', type: 'boolean' },
{ name: 'updatableAfterUpgrade', type: 'boolean' },
{ name: 'technicalName', type: 'string' }
],

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,15 @@ Ext.define('Shopware.apps.SwagUpdate.view.Window', {
/**
* @param { Ext.grid.Panel } grid
* @param { number } index
* @param { number } colIndex
* @param { object } eOpts
* @param { event } event
* @param { Ext.data.Model } record
*/
onClickShowPluginUpdateDetails: function(grid, index) {
this.fireEvent('showPluginUpdateDetails', grid, index);
onClickShowPluginUpdateDetails: function(grid, index, colIndex, eOpts, event, record) {
if (record.get('updatable')) {
this.fireEvent('showPluginUpdateDetails', grid, index);
}
},

/**
Expand All @@ -304,11 +310,14 @@ Ext.define('Shopware.apps.SwagUpdate.view.Window', {
*/
onGetClass: function(value, metadata, record) {
if (record.get('updatable')) {
metadata.style = 'margin: 0 auto;';
return 'sprite-arrow-circle-315'
return 'sprite-arrow-circle-315';
}

if (record.get('updatableAfterUpgrade')) {
return 'sprite-exclamation';
}

metadata.style = "display:none;"
return 'x-hide-display';
},

/**
Expand Down

0 comments on commit 0e6acfc

Please sign in to comment.