Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

feat(plugins): require permissions to include content on the app #1191

Merged
merged 4 commits into from May 6, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion postcss.config.js
Expand Up @@ -4,4 +4,4 @@ module.exports = {
require('tailwindcss')('./tailwind.js'),
require('autoprefixer')
]
}
}
21 changes: 16 additions & 5 deletions src/renderer/services/plugin-manager.js
Expand Up @@ -2,6 +2,7 @@ import * as fs from 'fs-extra'
import * as os from 'os'
import * as path from 'path'
import * as vm2 from 'vm2'
import { camelCase, partition, uniq, upperFirst } from 'lodash'

class PluginManager {
constructor () {
Expand Down Expand Up @@ -67,11 +68,21 @@ class PluginManager {
profileId
})

await this.loadComponents(pluginObject, plugin)
await this.loadRoutes(pluginObject, plugin)
await this.loadMenuItems(pluginObject, plugin, profileId)
await this.loadAvatars(pluginObject, plugin, profileId)
await this.loadWalletTabs(pluginObject, plugin, profileId)
const permissions = uniq(plugin.config.permissions)
const [first, rest] = partition(permissions, permission => {
// These permissions could be necessary first to load others
// The rest does not have dependencies: 'MENU_ITEMS', 'AVATARS', 'WALLET_TABS'
return ['COMPONENTS', 'ROUTES'].includes(permission)
})

for (const permission of first) {
const method = `load${upperFirst(camelCase(permission))}`
await this[method](pluginObject, plugin, profileId)
}
for (const permission of rest) {
const method = `load${upperFirst(camelCase(permission))}`
await this[method](pluginObject, plugin, profileId)
}
}

async disablePlugin (pluginId) {
Expand Down