[extensions-web] extensions: properly handle system extensions upgrade.
- From: Yuri Konotopov <ykonotopov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] extensions: properly handle system extensions upgrade.
- Date: Sun, 12 Feb 2017 07:39:31 +0000 (UTC)
commit f0fac87678daa2736e397cd9451ac6e401b1c955
Author: Yuri Konotopov <ykonotopov gnome org>
Date: Sun Feb 12 11:38:58 2017 +0400
extensions: properly handle system extensions upgrade.
Do not try to uninstall system extension instead just install new version.
Fixes: https://github.com/nE0sIghT/chrome-gnome-shell-mirror/issues/31
sweettooth/static/css/sweettooth.css | 9 +++
sweettooth/static/js/extensions.js | 70 ++++++++++++++++---
.../js/templates/extensions/info_contents.mustache | 6 +--
sweettooth/static/js/templates/templatedata.js | 2 +-
4 files changed, 70 insertions(+), 17 deletions(-)
---
diff --git a/sweettooth/static/css/sweettooth.css b/sweettooth/static/css/sweettooth.css
index 2edd3ce..7cdcc72 100644
--- a/sweettooth/static/css/sweettooth.css
+++ b/sweettooth/static/css/sweettooth.css
@@ -360,6 +360,11 @@ li.extension:last-child, #local_extensions div.extension:last-child {
margin-left: 44px;
font-size: 0.8em;
cursor: help;
+ display: none;
+}
+
+.extension.system .system-extension {
+ display: block;
}
.extension .author, .extension .author a {
@@ -414,6 +419,10 @@ li.extension:last-child, #local_extensions div.extension:last-child {
cursor: pointer;
}
+.extension.installed.system .uninstall-button {
+ display: none;
+}
+
.extension.configurable .configure-button {
background-color: #4a90d9;
background-image: url(../images/configure-extension.png);
diff --git a/sweettooth/static/js/extensions.js b/sweettooth/static/js/extensions.js
index a75e00f..3ee058a 100644
--- a/sweettooth/static/js/extensions.js
+++ b/sweettooth/static/js/extensions.js
@@ -83,12 +83,23 @@ define(['jquery', 'messages', 'dbus!_', 'extensionUtils', 'templates', 'paginato
}
}
+ function extensionTypeChanged(uuid, newType) {
+ if (elems[uuid] !== undefined)
+ {
+ if(elems[uuid].data('type') != newType)
+ {
+ elems[uuid].trigger('type-changed', newState);
+ }
+ }
+ }
+
dbusProxy.extensionStateChangedHandler = extensionStateChanged;
dbusProxy.shellRestartHandler = function () {
dbusProxy.ListExtensions().then(function (extensions) {
$.each(extensions, function () {
extensionStateChanged(this.uuid, this.state);
+ extensionTypeChanged(this.uuid, this.type);
});
});
};
@@ -110,15 +121,7 @@ define(['jquery', 'messages', 'dbus!_', 'extensionUtils', 'templates', 'paginato
});
$elem.find('.upgrade-button').on('click', function () {
- $elem.removeClass('upgradable');
- dbusProxy.UninstallExtension(uuid).then(function (result) {
- // If we weren't able to uninstall the extension, don't
- // do anything more.
- if (!result)
- {
- return;
- }
-
+ function installExtension() {
dbusProxy.InstallExtension(uuid).then(function (result) {
if (result === 'cancelled')
{
@@ -126,8 +129,33 @@ define(['jquery', 'messages', 'dbus!_', 'extensionUtils', 'templates', 'paginato
// thing uninstalled.
$switch.switchify('activate', false);
}
+ // GNOME Shell bug
https://bugzilla.gnome.org/show_bug.cgi?id=777544
+ else if (['s', 'successful'].indexOf(result) != -1)
+ {
+ // It should always became "per user" extension if
installed from repository.
+ $elem.trigger('type-changed',
extensionUtils.ExtensionType.PER_USER);
+ }
});
- });
+ }
+
+ $elem.removeClass('upgradable');
+ if($elem.data('type') == extensionUtils.ExtensionType.PER_USER)
+ {
+ dbusProxy.UninstallExtension(uuid).then(function (result) {
+ // If we weren't able to uninstall the extension, don't
+ // do anything more.
+ if (!result)
+ {
+ return;
+ }
+
+ installExtension();
+ });
+ }
+ else
+ {
+ installExtension();
+ }
});
$elem.find('.uninstall-button').on('click', function () {
@@ -145,9 +173,15 @@ define(['jquery', 'messages', 'dbus!_', 'extensionUtils', 'templates', 'paginato
$elem.addClass('installed');
}
+ if(meta.type == extensionUtils.ExtensionType.SYSTEM)
+ {
+ $elem.addClass('system');
+ }
+
$elem.data({
'elem': $elem,
- 'state': _state
+ 'state': _state,
+ 'type': meta.type
});
$switch.data('elem', $elem);
@@ -237,6 +271,20 @@ define(['jquery', 'messages', 'dbus!_', 'extensionUtils', 'templates', 'paginato
$switch.switchify('customize', "OUTDATED", 'outdated');
}
});
+
+ $elem.on('type-changed', function (e, newType) {
+ if(newType == extensionUtils.ExtensionType.SYSTEM)
+ {
+ $elem.addClass('system');
+ }
+ else
+ {
+ $elem.removeClass('system');
+ }
+
+ $elem.data('type', newType);
+ });
+
$elem.trigger('state-changed', _state);
elems[uuid] = $elem;
}
diff --git a/sweettooth/static/js/templates/extensions/info_contents.mustache
b/sweettooth/static/js/templates/extensions/info_contents.mustache
index bef036f..c7b022e 100644
--- a/sweettooth/static/js/templates/extensions/info_contents.mustache
+++ b/sweettooth/static/js/templates/extensions/info_contents.mustache
@@ -14,13 +14,9 @@
<div class="extra-buttons">
<div class="upgrade-button" title="Upgrade this extension"></div>
<div class="configure-button" title="Configure this extension"></div>
- {{^system}}
<div class="uninstall-button" title="Uninstall this extension"></div>
- {{/system}}
</div>
</div>
<div style="clear: both"></div>
-{{#system}}
- <div class='system-extension' title='System extension should be uninstalled using package manager. See
«About» page for more details.'>System extension</div>
-{{/system}}
+<div class='system-extension' title='System extension should be uninstalled using package manager. See
«About» page for more details.'>System extension</div>
<p class="description">{{first_line_of_description}}</p>
diff --git a/sweettooth/static/js/templates/templatedata.js b/sweettooth/static/js/templates/templatedata.js
index 70a372d..8514a8a 100644
--- a/sweettooth/static/js/templates/templatedata.js
+++ b/sweettooth/static/js/templates/templatedata.js
@@ -6,7 +6,7 @@ define({
"extensions/comments_list": "{{#comments}}\n {{>extensions/comment}}\n
<hr>\n{{/comments}}\n{{^show_all}}\n<p class=\"show-all\">Show more
reviews</p>\n{{/show_all}}\n\n{{^comments}}\n <p>There are no comments. Be the first!</p>\n{{/comments}}",
"extensions/error_report_template": "What's wrong?\n\n\n\nWhat have you tried?\n\n\n\nAutomatically
detected errors:\n\n{{#errors}}\n {{.}}\n\n================\n{{/errors}}\n{{^errors}}\nGNOME Shell
Extensions did not detect any errors with this extension.\n{{/errors}}\n\nVersion information:\n\n Shell
version: {{sv}}\n Extension version: {{#ev}}{{ev}}{{/ev}}{{^ev}}Unknown{{/ev}}",
"extensions/info": "<div class=\"extension\" data-uuid=\"{{uuid}}\">\n
{{>extensions/info_contents}}\n</div>",
- "extensions/info_contents": "<h3 class=\"extension-name\">\n {{#link}}\n <a href=\"{{link}}\"
class=\"title-link\"><img src=\"{{icon}}\" class=\"icon\">{{name}}</a>\n {{/link}}\n {{^link}}\n <span
class=\"icon plugin-unknown\"></span>{{name}}\n {{/link}}\n</h3>\n{{#creator}}\n <span class=\"author\">by
<a href=\"{{creator_url}}\">{{creator}}</a></span>\n{{/creator}}\n<div class=\"controls\">\n <div
class=\"switch\"></div>\n <div class=\"extra-buttons\">\n <div class=\"upgrade-button\" title=\"Upgrade
this extension\"></div>\n <div class=\"configure-button\" title=\"Configure this extension\"></div>\n
{{^system}}\n <div class=\"uninstall-button\" title=\"Uninstall this extension\"></div>\n {{/system}}\n
</div>\n</div>\n<div style=\"clear: both\"></div>\n{{#system}}\n <div class='system-extension' title='System
extension should be uninstalled using package manager. See \u00abAbout\u00bb page for more details.'>System
extension</div>\n{{/system}}\n<p
class=\"description\">{{first_line_of_description}}</p>",
+ "extensions/info_contents": "<h3 class=\"extension-name\">\n {{#link}}\n <a href=\"{{link}}\"
class=\"title-link\"><img src=\"{{icon}}\" class=\"icon\">{{name}}</a>\n {{/link}}\n {{^link}}\n <span
class=\"icon plugin-unknown\"></span>{{name}}\n {{/link}}\n</h3>\n{{#creator}}\n <span class=\"author\">by
<a href=\"{{creator_url}}\">{{creator}}</a></span>\n{{/creator}}\n<div class=\"controls\">\n <div
class=\"switch\"></div>\n <div class=\"extra-buttons\">\n <div class=\"upgrade-button\" title=\"Upgrade
this extension\"></div>\n <div class=\"configure-button\" title=\"Configure this extension\"></div>\n
<div class=\"uninstall-button\" title=\"Uninstall this extension\"></div>\n </div>\n</div>\n<div
style=\"clear: both\"></div>\n<div class='system-extension' title='System extension should be uninstalled
using package manager. See \u00abAbout\u00bb page for more details.'>System extension</div>\n<p
class=\"description\">{{first_line_of_description}}</p>",
"extensions/info_list": "<ul class=\"extensions\">\n{{#extensions}}\n <li class=\"extension\"
data-svm=\"{{shell_version_map}}\">\n {{>extensions/info_contents}}\n </li>\n{{/extensions}}\n</ul>",
"extensions/uninstall": "You uninstalled <b>{{name}}</b>.",
"messages/cannot_list_errors": "GNOME Shell Extensions cannot automatically detect any errors.",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]