Skip to content

Commit

Permalink
min_app_version for plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
solvedDev committed Jan 6, 2019
1 parent c2a0afe commit bc5260b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/renderer/components/plugin_install/CloudPlugin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@
<v-list-tile-action>
<v-list-tile-action-text>{{ plugin.version }}</v-list-tile-action-text>
<v-tooltip :right="!is_fullscreen" :left="is_fullscreen" v-if="!is_update">
<v-btn slot="activator" @click.stop="download()" :loading="loading" icon>
<v-btn slot="activator" @click.stop="download()" :disabled="!is_compatible" :loading="loading" icon>
<v-icon>cloud_download</v-icon>
</v-btn>
<span>Download</span>
</v-tooltip>
<v-btn slot="activator" @click.stop="download()" :loading="loading" flat round color="success" v-else>
<v-btn slot="activator" @click.stop="download()" :disabled="!is_compatible" :loading="loading" flat round color="success" v-else>
Update
</v-btn>

</v-list-tile-action>
</v-list-tile>

<div style="padding: 0 16px; cursor: default;" v-if="!is_compatible && !is_update" class="error--text">You cannot install this plugin because it requires a higher version of bridge.</div>
<div style="padding: 0 16px; cursor: default;" v-if="!is_compatible && is_update" class="error--text">You cannot install this update because it requires a higher version of bridge.</div>
<v-divider/>
</div>
</div>
Expand All @@ -32,6 +33,8 @@
<script>
import fs from "fs";
import mkdirp from "mkdirp";
import { APP_VERSION } from "../../scripts/constants";
import * as VersionUtils from "../../scripts/VersionUtils";
export default {
name: "cloud-plugin",
Expand Down Expand Up @@ -92,6 +95,10 @@ export default {
},
base_path() {
return this.$store.state.TabSystem.base_path + this.$store.state.Explorer.project + "/bridge";
},
is_compatible() {
console.log(!VersionUtils.greaterThan(this.plugin.min_app_version || APP_VERSION, APP_VERSION))
return !VersionUtils.greaterThan(this.plugin.min_app_version || APP_VERSION, APP_VERSION);
}
},
methods: {
Expand Down
10 changes: 10 additions & 0 deletions src/renderer/scripts/VersionUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function toNumber(version) {
return Number(version.substr(1, version.length).split(".").join(""));
}

export function greaterThan(v1, v2) {
return toNumber(v1) > toNumber(v2);
}
export function lessThan(v1, v2) {
return toNumber(v1) < toNumber(v2);
}

0 comments on commit bc5260b

Please sign in to comment.