allow disabling individual providers and commands through config

This commit is contained in:
Eugene Pankov 2023-04-22 13:41:15 -07:00
parent 6997c24dfa
commit 19d59a4cfb
No known key found for this signature in database
GPG key ID: 5896FCBBDD1CF4F4
5 changed files with 9 additions and 3 deletions

View file

@ -27,7 +27,7 @@ export class CoreCommandProvider extends CommandProvider {
async provide (): Promise<Command[]> {
return [
{
id: 'profile-selector',
id: 'core:profile-selector',
locations: [CommandLocation.LeftToolbar, CommandLocation.StartPage],
label: this.translate.instant('Profiles & connections'),
icon: this.hostApp.platform === Platform.Web
@ -35,7 +35,8 @@ export class CoreCommandProvider extends CommandProvider {
: require('./icons/profiles.svg'),
run: async () => this.activate(),
},
...this.profilesService.getRecentProfiles().map(profile => ({
...this.profilesService.getRecentProfiles().map((profile, index) => ({
id: `core:recent-profile-${index}`,
label: profile.name,
locations: [CommandLocation.StartPage],
icon: require('./icons/history.svg'),

View file

@ -46,6 +46,8 @@ vault: null
encrypted: false
enableExperimentalFeatures: false
pluginBlacklist: []
commandBlacklist: []
providerBlacklist: []
hacks:
disableGPU: false
disableVibrancyWhileDragging: false

View file

@ -193,7 +193,7 @@ export default class AppModule { // eslint-disable-line @typescript-eslint/no-ex
}
if (hotkey === 'profile-selector') {
commands.run('profile-selector', {})
commands.run('core:profile-selector', {})
}
})
}

View file

@ -71,6 +71,7 @@ export class CommandService {
}
return commands
.filter(c => !this.config.store.commandBlacklist.includes(c.id))
.sort((a, b) => (a.weight ?? 0) - (b.weight ?? 0))
.map(command => {
const run = command.run

View file

@ -254,7 +254,9 @@ export class ConfigService {
return services.filter(service => {
for (const pluginName in this.servicesCache) {
if (this.servicesCache[pluginName].includes(service.constructor)) {
const id = `${pluginName}:${service.constructor.name}`
return !this.store?.pluginBlacklist?.includes(pluginName)
&& !this.store?.providerBlacklist?.includes(id)
}
}
return true