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

Commit

Permalink
feat: add additional filters to the plugin manager (#1871)
Browse files Browse the repository at this point in the history
Co-authored-by: Breno Polanski <[email protected]>
Co-authored-by: Alex Barnsley <[email protected]>
  • Loading branch information
3 people authored Apr 1, 2020
1 parent c27086c commit e561f7b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
44 changes: 44 additions & 0 deletions __tests__/unit/store/modules/plugin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,50 @@ describe('PluginModule', () => {
})

describe('filtered', () => {
describe.only('when given a filter', () => {
beforeAll(() => {
store.replaceState(merge(
JSON.parse(JSON.stringify(initialState)),
{
plugin: {
available: {
[availablePlugins[0].config.id]: {
config: {
...availablePlugins[0].config,
isOfficial: true
}
},
[availablePlugins[1].config.id]: availablePlugins[1]
},
whitelisted: {
global: {
[availablePlugins[0].config.id]: {
version: availablePlugins[0].config.version
},
[availablePlugins[1].config.id]: {
isGrant: true,
version: availablePlugins[1].config.version
}
}
}
}
}
))
})

it('should filter official plugins only', () => {
expect(store.getters['plugin/filtered'](null, null, 'official').map(plugin => {
return plugin.config.id
})).toEqual([availablePlugins[0].config.id])
})

it('should filter funded plugins only', () => {
expect(store.getters['plugin/filtered'](null, null, 'funded').map(plugin => {
return plugin.config.id
})).toEqual([availablePlugins[1].config.id])
})
})

describe('blacklisted plugins', () => {
it('should filter out globally blacklisted plugins', () => {
store.replaceState(merge(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export default {
isOpen: false,
filters: [
'all',
'installed'
'installed',
'official',
'funded'
]
}),
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/i18n/locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,9 @@ export default {
},
FILTERS: {
ALL: 'all',
INSTALLED: 'installed'
INSTALLED: 'installed',
OFFICIAL: 'official',
FUNDED: 'funded'
},
NO_SEARCH_RESULTS: 'Unfortunately, searching for "{query}" returned no results',
NO_RESULTS: 'There are no {filter} plugins with the category {category}',
Expand Down
8 changes: 8 additions & 0 deletions src/renderer/store/modules/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ export default {
return uniqBy([...getters.installed, ...getters.available], 'config.id')
},

official: (_, getters) => {
return getters.all.filter(plugin => plugin.config.isOfficial)
},

funded: (_, getters) => {
return getters.all.filter(plugin => getters.isGrant(plugin.config.id))
},

filtered: (_, getters, __, rootGetters) => (query, category, filter) => {
let plugins = getters[filter || 'all']

Expand Down

0 comments on commit e561f7b

Please sign in to comment.