Hide inactive tabs’ refresh button

This commit is contained in:
Samuel Elliott 2018-02-19 18:10:09 +00:00
parent 5931bffca3
commit fca89aaaa6
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
4 changed files with 43 additions and 63 deletions

View File

@ -10,20 +10,12 @@
<template>
<Card :item="plugin">
<SettingSwitch v-if="plugin.type === 'plugin'" slot="toggle" :checked="plugin.enabled" :change="() => plugin.enabled ? plugin.stop() : plugin.start()" />
<SettingSwitch v-if="plugin.type === 'plugin'" slot="toggle" :checked="plugin.enabled" :change="togglePlugin" />
<ButtonGroup slot="controls">
<Button v-tooltip="'Settings'" v-if="plugin.hasSettings" :onClick="() => showSettings(plugin)">
<MiSettings size="18" />
</Button>
<Button v-tooltip="'Reload'" :onClick="() => reloadPlugin(plugin)">
<MiRefresh size="18" />
</Button>
<Button v-tooltip="'Edit'" :onClick="editPlugin">
<MiPencil size="18" />
</Button>
<Button v-tooltip="'Uninstall'" type="err">
<MiDelete size="18" />
</Button>
<Button v-tooltip="'Settings'" v-if="plugin.hasSettings" :onClick="() => showSettings(plugin)"><MiSettings size="18" /></Button>
<Button v-tooltip="'Reload'" :onClick="reloadPlugin"><MiRefresh size="18" /></Button>
<Button v-tooltip="'Edit'" :onClick="editPlugin"><MiPencil size="18" /></Button>
<Button v-tooltip="'Uninstall'" type="err"><MiDelete size="18" /></Button>
</ButtonGroup>
</Card>
</template>
@ -52,6 +44,5 @@
}
}
}
}
</script>

View File

@ -13,17 +13,17 @@
<div class="bd-tabbar" slot="header">
<div class="bd-button" :class="{'bd-active': local}" @click="showLocal">
<h3>Local</h3>
<div class="bd-material-button" @click="refreshLocal"><MiRefresh /></div>
<div class="bd-material-button" v-if="local" @click="refreshLocal"><MiRefresh /></div>
</div>
<div class="bd-button" :class="{'bd-active': !local}" @click="showOnline">
<h3>Online</h3>
<div class="bd-material-button"><MiRefresh /></div>
<div class="bd-material-button" v-if="!local" @click="refreshOnline"><MiRefresh /></div>
</div>
</div>
<div class="bd-flex bd-flex-col bd-pluginsView">
<div v-if="local" class="bd-flex bd-flex-grow bd-flex-col bd-plugins-container bd-local-plugins">
<PluginCard v-for="plugin in localPlugins" :plugin="plugin" :key="plugin.id" :togglePlugin="togglePlugin" :reloadPlugin="reloadPlugin" :showSettings="showSettings" />
<PluginCard v-for="plugin in localPlugins" :plugin="plugin" :key="plugin.id" :togglePlugin="() => togglePlugin(plugin)" :reloadPlugin="() => reloadPlugin(plugin)" :showSettings="() => showSettings(plugin)" />
</div>
<div v-if="!local" class="bd-spinner-container">
<div class="bd-spinner-2"></div>
@ -58,32 +58,31 @@
showOnline() {
this.local = false;
},
refreshLocal() {
(async () => {
await PluginManager.refreshPlugins();
})();
async refreshLocal() {
await PluginManager.refreshPlugins();
},
togglePlugin(plugin) {
async refreshOnline() {
},
async togglePlugin(plugin) {
// TODO Display error if plugin fails to start/stop
try {
if (plugin.enabled) {
PluginManager.stopPlugin(plugin);
await PluginManager.stopPlugin(plugin);
} else {
PluginManager.startPlugin(plugin);
await PluginManager.startPlugin(plugin);
}
} catch (err) {
console.log(err);
}
},
reloadPlugin(plugin) {
(async () => {
try {
await PluginManager.reloadPlugin(plugin);
this.$forceUpdate();
} catch (err) {
console.log(err);
}
})();
async reloadPlugin(plugin) {
try {
await PluginManager.reloadPlugin(plugin);
this.$forceUpdate();
} catch (err) {
console.log(err);
}
},
showSettings(plugin) {
return Modals.contentSettings(plugin);

View File

@ -10,20 +10,12 @@
<template>
<Card :item="theme">
<SettingSwitch slot="toggle" :checked="theme.enabled" :change="() => theme.enabled ? theme.disable() : theme.enable()" />
<SettingSwitch slot="toggle" :checked="theme.enabled" :change="toggleTheme" />
<ButtonGroup slot="controls">
<Button v-tooltip="'Settings'" v-if="theme.hasSettings" :onClick="() => showSettings(theme)">
<MiSettings size="18" />
</Button>
<Button v-tooltip="'Reload'" :onClick="() => reloadTheme(theme)">
<MiRefresh size="18" />
</Button>
<Button v-tooltip="'Edit'" :onClick="editTheme">
<MiPencil size="18" />
</Button>
<Button v-tooltip="'Uninstall'" type="err">
<MiDelete size="18" />
</Button>
<Button v-tooltip="'Settings'" v-if="theme.hasSettings" :onClick="showSettings"><MiSettings size="18" /></Button>
<Button v-tooltip="'Reload'" :onClick="reloadTheme"><MiRefresh size="18" /></Button>
<Button v-tooltip="'Edit'" :onClick="editTheme"><MiPencil size="18" /></Button>
<Button v-tooltip="'Uninstall'" type="err"><MiDelete size="18" /></Button>
</ButtonGroup>
</Card>
</template>
@ -52,6 +44,5 @@
}
}
}
}
</script>

View File

@ -13,17 +13,17 @@
<div class="bd-tabbar" slot="header">
<div class="bd-button" :class="{'bd-active': local}" @click="showLocal">
<h3>Local</h3>
<div class="bd-material-button" @click="refreshLocal"><MiRefresh /></div>
<div class="bd-material-button" v-if="local" @click="refreshLocal"><MiRefresh /></div>
</div>
<div class="bd-button" :class="{'bd-active': !local}" @click="showOnline">
<h3>Online</h3>
<div class="bd-material-button"><MiRefresh /></div>
<div class="bd-material-button" v-if="!local" @click="refreshOnline"><MiRefresh /></div>
</div>
</div>
<div class="bd-flex bd-flex-col bd-themesView">
<div v-if="local" class="bd-flex bd-flex-grow bd-flex-col bd-themes-container bd-local-themes">
<ThemeCard v-for="theme in localThemes" :theme="theme" :key="theme.id" :toggleTheme="toggleTheme" :reloadTheme="reloadTheme" :showSettings="showSettings" />
<ThemeCard v-for="theme in localThemes" :theme="theme" :key="theme.id" :toggleTheme="() => toggleTheme(theme)" :reloadTheme="() => reloadTheme(theme)" :showSettings="() => showSettings(theme)" />
</div>
<div v-if="!local" class="bd-spinner-container">
<div class="bd-spinner-2"></div>
@ -58,10 +58,11 @@
showOnline() {
this.local = false;
},
refreshLocal() {
(async () => {
await ThemeManager.refreshTheme();
})();
async refreshLocal() {
await ThemeManager.refreshTheme();
},
async refreshOnline() {
},
toggleTheme(theme) {
// TODO Display error if theme fails to enable/disable
@ -75,15 +76,13 @@
console.log(err);
}
},
reloadTheme(theme) {
(async () => {
try {
await ThemeManager.reloadTheme(theme);
this.$forceUpdate();
} catch (err) {
console.log(err);
}
})();
async reloadTheme(theme) {
try {
await ThemeManager.reloadTheme(theme);
this.$forceUpdate();
} catch (err) {
console.log(err);
}
},
showSettings(theme) {
return Modals.contentSettings(theme);