Skip to content

Commit

Permalink
Fix UX for incompatible plugins (#816)
Browse files Browse the repository at this point in the history
  • Loading branch information
karaggeorge authored Mar 26, 2020
1 parent 98f3d40 commit 9917c3c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions main/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class InstalledPlugin extends BasePlugin {
const {homepage, links} = this.json;
this.link = homepage || (links && links.homepage);
this.isCompatible = semver.satisfies(app.getVersion(), this.json.kapVersion || '*');
this.kapVersion = this.json.kapVersion;

try {
this.plugin = require(this.pluginPath);
Expand Down
8 changes: 7 additions & 1 deletion renderer/components/preferences/categories/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ class Plugins extends React.Component {
const allPlugins = [
...pluginsInstalled,
...pluginsFromNpm
].sort((a, b) => a.prettyName.localeCompare(b.prettyName));
].sort((a, b) => {
if (a.isCompatible !== b.isCompatible) {
return b.isCompatible - a.isCompatible;
}

return a.prettyName.localeCompare(b.prettyName);
});

return (
<Category>
Expand Down
6 changes: 4 additions & 2 deletions renderer/components/preferences/categories/plugins/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ PluginTitle.propTypes = {
};

const Plugin = ({plugin, checked, disabled, onTransitionEnd, onClick, loading, openConfig, tabIndex}) => {
const requiredVersion = !plugin.isCompatible && `Requires Kap version ${plugin.kapVersion}.`;

const error = !plugin.isCompatible && (
<div className="invalid" title={`This plugin is not supported by the current Kap version. Requires ${plugin.kapVersion}`}>
<div className="invalid" title={`This plugin is not supported. ${requiredVersion}`}>
<ErrorIcon fill="#ff6059" hoverFill="#ff6059" onClick={openConfig}/>
<style jsx>{`
.invalid {
Expand Down Expand Up @@ -94,7 +96,7 @@ const Plugin = ({plugin, checked, disabled, onTransitionEnd, onClick, loading, o
label={plugin.version}
onClick={onTitleClick}/>
}
subtitle={plugin.description}
subtitle={[plugin.description, requiredVersion].filter(Boolean)}
>
{
openConfig && plugin.isCompatible && (
Expand Down

0 comments on commit 9917c3c

Please sign in to comment.