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

refactor: grant icon & fetching plugin config #1860

Merged
merged 17 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 5 additions & 24 deletions __tests__/unit/services/plugin-manager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const app = {
getters: {
'plugin/isEnabled': jest.fn((pluginId) => pluginId === 'plugin-test'),
'plugin/isInstalledSupported': jest.fn(() => true),
'plugin/isGrant': jest.fn(() => true),
'plugin/lastFetched': jest.fn(() => 0),
'profile/byId': jest.fn(() => {}),
'session/pluginAdapter': 'npm'
Expand Down Expand Up @@ -241,40 +242,20 @@ describe('Plugin Manager', () => {
})
})

describe('fetchBlacklist', () => {
describe('fetchPluginsList', () => {
it('should fetch using cache-busted url', async () => {
const spy = jest.spyOn(Date.prototype, 'getTime').mockReturnValue(1234)
const spyError = jest.spyOn(console, 'error')

nock('https://raw.githubusercontent.com')
.get('/ark-ecosystem-desktop-plugins/config/master/blacklist.json')
// .get('/ark-ecosystem-desktop-plugins/config/master/plugins.json')
.get('/ark-ecosystem-desktop-plugins/config/chore/single-config-file/plugins.json')
.query({
ts: 1234
})
.reply(200, [])

await pluginManager.fetchBlacklist()

expect(spyError).not.toHaveBeenCalled()

spy.mockRestore()
spyError.mockRestore()
})
})

describe('fetchWhitelist', () => {
it('should fetch using cache-busted url', async () => {
const spy = jest.spyOn(Date.prototype, 'getTime').mockReturnValue(1234)
const spyError = jest.spyOn(console, 'error')

nock('https://raw.githubusercontent.com')
.get('/ark-ecosystem-desktop-plugins/config/master/whitelist.json')
.query({
ts: 1234
})
.reply(200, [])

await pluginManager.fetchWhitelist()
await pluginManager.fetchPluginsList()

expect(spyError).not.toHaveBeenCalled()

Expand Down
65 changes: 57 additions & 8 deletions __tests__/unit/store/modules/plugin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ describe('PluginModule', () => {
},
whitelisted: {
global: {
[availablePlugins[0].config.id]: availablePlugins[0].config.version
[availablePlugins[0].config.id]: {
version: availablePlugins[0].config.version
}
}
}
}
Expand Down Expand Up @@ -203,8 +205,12 @@ describe('PluginModule', () => {
},
whitelisted: {
global: {
[plugin1.config.id]: plugin1.config.version,
[plugin2.config.id]: plugin2.config.version
[plugin1.config.id]: {
version: plugin1.config.version
},
[plugin2.config.id]: {
version: plugin2.config.version
}
}
}
}
Expand Down Expand Up @@ -242,8 +248,12 @@ describe('PluginModule', () => {
},
whitelisted: {
global: {
[plugin1.config.id]: plugin1.config.version,
[plugin2.config.id]: plugin2.config.version
[plugin1.config.id]: {
version: plugin1.config.version
},
[plugin2.config.id]: {
version: plugin2.config.version
}
}
}
}
Expand Down Expand Up @@ -282,8 +292,12 @@ describe('PluginModule', () => {
},
whitelisted: {
global: {
[plugin1.config.id]: plugin1.config.version,
[plugin2.config.id]: plugin2.config.version
[plugin1.config.id]: {
version: plugin1.config.version
},
[plugin2.config.id]: {
version: plugin2.config.version
}
}
}
}
Expand Down Expand Up @@ -626,7 +640,9 @@ describe('PluginModule', () => {
store.dispatch('plugin/setWhitelisted', {
scope: 'global',
plugins: {
[availablePlugins[0].config.id]: availablePlugins[0].config.version
[availablePlugins[0].config.id]: {
version: availablePlugins[0].config.version
}
}
})
})
Expand Down Expand Up @@ -656,6 +672,39 @@ describe('PluginModule', () => {
})
})

describe('isGrant', () => {
beforeAll(() => {
store.replaceState(JSON.parse(JSON.stringify(initialState)))

store.dispatch('plugin/setWhitelisted', {
scope: 'global',
plugins: {
[availablePlugins[0].config.id]: {
isGrant: true,
version: availablePlugins[0].config.version
},
[availablePlugins[1].config.id]: {
version: availablePlugins[1].config.version
}
}
})
})

it('should return true if the plugin is whitelisted and is a funded by ark grants', () => {
const pluginId = availablePlugins[0].config.id
expect(store.getters['plugin/isGrant'](pluginId)).toBe(true)
})

it('should return false if the plugin is whitelisted and is a not funded by ark grants', () => {
const pluginId = availablePlugins[1].config.id
expect(store.getters['plugin/isGrant'](pluginId)).toBe(false)
})

it('should return false if the plugin is not whitelisted and is a not funded by ark grants', () => {
expect(store.getters['plugin/isGrant']('plugin-not-grants')).toBe(false)
})
})

describe('isInstalledSupported', () => {
let spy

Expand Down
4 changes: 2 additions & 2 deletions config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ exports.MARKET = {

exports.PLUGINS = {
adapters: ['npm'],
blacklistUrl: 'https://raw.githubusercontent.com/ark-ecosystem-desktop-plugins/config/master/blacklist.json',
whitelistUrl: 'https://raw.githubusercontent.com/ark-ecosystem-desktop-plugins/config/master/whitelist.json',
// pluginsUrl: 'https://raw.githubusercontent.com/ark-ecosystem-desktop-plugins/config/master/plugins.json',
brenopolanski marked this conversation as resolved.
Show resolved Hide resolved
pluginsUrl: 'https://raw.githubusercontent.com/ark-ecosystem-desktop-plugins/config/chore/single-config-file/plugins.json',
brenopolanski marked this conversation as resolved.
Show resolved Hide resolved
categories: [
'gaming',
'theme',
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export default {

ipcRenderer.send('splashscreen:app-ready')

await Promise.all([this.$plugins.fetchPluginsFromAdapter(), this.$plugins.fetchBlacklist(), this.$plugins.fetchWhitelist()])
await Promise.all([this.$plugins.fetchPluginsFromAdapter(), this.$plugins.fetchPluginsList()])
},

__watchProfile () {
Expand Down
23 changes: 23 additions & 0 deletions src/renderer/assets/svg/ark-checkmark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/renderer/assets/svg/ark-grants.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
class="PluginManagerCheckmark"
>
<SvgIcon
name="checkmark"
view-box="0 0 6 6"
name="ark-checkmark"
view-box="0 0 16 16"
/>
</div>
</template>
Expand All @@ -34,6 +34,7 @@ export default {

<style lang="postcss" scoped>
.PluginManagerCheckmark {
@apply flex items-center justify-center text-white mr-1 rounded-full w-3 h-3 bg-blue
@apply flex items-center ml-1 w-4 h-4;
color: #007cff;
}
</style>
33 changes: 33 additions & 0 deletions src/renderer/components/PluginManager/PluginManagerGrants.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template>
<div
v-tooltip="{
content: $t('PAGES.PLUGIN_MANAGER.GRANTS'),
placement: 'bottom'
}"
class="PluginManagerGrants"
>
<SvgIcon
name="ark-grants"
view-box="0 0 16 16"
/>
</div>
</template>

<script>
import SvgIcon from '@/components/SvgIcon'

export default {
name: 'PluginManagerGrants',

components: {
SvgIcon
}
}
</script>

<style lang="postcss" scoped>
.PluginManagerGrants {
@apply flex items-center ml-1 w-4 h-4;
color: #ffae10;
}
</style>
21 changes: 12 additions & 9 deletions src/renderer/components/PluginManager/PluginManagerGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@

<div class="pl-4">
<div class="flex flex-col justify-center h-20">
<span
class="PluginManagerGrid__plugin__name"
@click="emitShowDetails(plugin)"
>
{{ plugin.title }}
</span>

<div class="flex items-center">
<span
class="PluginManagerGrid__plugin__name"
@click="emitShowDetails(plugin)"
>
{{ plugin.title }}
</span>
<PluginManagerCheckmark v-if="plugin.isOfficial && !plugin.isGrant" />
<PluginManagerGrants v-else-if="plugin.isGrant" />
</div>
<div class="PluginManagerGrid__plugin__details">
<PluginManagerCheckmark v-if="plugin.isOfficial" />

<span>{{ plugin.author }}</span>
<span class="ml-2">v{{ plugin.version }}</span>
<span class="ml-2">{{ formatter_bytes(plugin.size) }}</span>
Expand All @@ -57,6 +58,7 @@
<script>
import { ButtonGeneric, ButtonIconGeneric } from '@/components/Button'
import PluginManagerCheckmark from '@/components/PluginManager/PluginManagerCheckmark'
import PluginManagerGrants from '@/components/PluginManager/PluginManagerGrants'
import PluginLogo from '@/components/PluginManager/PluginLogo'

export default {
Expand All @@ -66,6 +68,7 @@ export default {
ButtonGeneric,
ButtonIconGeneric,
PluginManagerCheckmark,
PluginManagerGrants,
PluginLogo
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@

<div class="flex flex-col ml-5 justify-between">
<div>
<span class="text-theme-page-text font-semibold text-xl">
{{ plugin.title }}
</span>
<div class="flex items-center">
<span class="text-theme-page-text font-semibold text-xl">
{{ plugin.title }}
</span>
<PluginManagerCheckmark v-if="plugin.isOfficial && !plugin.isGrant" />
<PluginManagerGrants v-else-if="plugin.isGrant" />
</div>

<span
class="PluginDetailsModal__header__details"
>
<PluginManagerCheckmark v-if="plugin.isOfficial" />

<span>
{{ plugin.author }}
</span>
Expand Down Expand Up @@ -179,7 +181,7 @@
<script>
import { PLUGINS } from '@config'
import { ButtonGeneric, ButtonIconGeneric } from '@/components/Button'
import { PluginLogo, PluginManagerCheckmark, PluginSlider } from '@/components/PluginManager'
import { PluginLogo, PluginManagerCheckmark, PluginManagerGrants, PluginSlider } from '@/components/PluginManager'
import { ModalWindow } from '@/components/Modal'
import { PluginManagerButtonSwitch } from '@/components/PluginManager/PluginManagerButtons'
import SvgIcon from '@/components/SvgIcon'
Expand All @@ -192,6 +194,7 @@ export default {
ButtonGeneric,
ButtonIconGeneric,
PluginManagerCheckmark,
PluginManagerGrants,
PluginManagerButtonSwitch,
ModalWindow,
PluginLogo,
Expand Down
Loading