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

Commit

Permalink
fix: plugin grid sorting (#1829)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbarnsley committed Mar 14, 2020
1 parent 7d8582e commit cc82944
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
Expand Up @@ -6,7 +6,26 @@ const i18n = useI18nGlobally()
let wrapper

const plugins = [
{ id: 'test' }
{
id: 'test 4',
title: 'plugin 4'
},
{
id: 'test 3',
title: 'plugin 3'
},
{
id: 'test 2',
title: 'plugin 2'
},
{
id: 'test 1',
title: 'plugin 1'
},
{
id: 'first test',
title: 'first plugin'
}
]

beforeEach(() => {
Expand Down Expand Up @@ -38,4 +57,17 @@ describe('PluginManagerGrid', () => {
expect(wrapper.emitted('show-details', plugins[0])).toBeTruthy()
})
})

describe('computed', () => {
it('sortedPlugins', () => {
expect(wrapper.vm.sortedPlugins[0].title).toBe('first plugin')
expect(wrapper.vm.sortedPlugins).toEqual([
plugins[4],
plugins[3],
plugins[2],
plugins[1],
plugins[0]
])
})
})
})
8 changes: 7 additions & 1 deletion src/renderer/components/PluginManager/PluginManagerGrid.vue
@@ -1,7 +1,7 @@
<template>
<div class="PluginManagerGrid mt-10">
<div
v-for="plugin in plugins"
v-for="plugin in sortedPlugins"
:key="plugin.id"
class="PluginManagerGrid__plugin"
>
Expand Down Expand Up @@ -76,6 +76,12 @@ export default {
}
},
computed: {
sortedPlugins () {
return this.plugins.concat().sort((a, b) => a.title.localeCompare(b.title))
}
},
methods: {
emitShowDetails (plugin) {
this.$emit('show-details', plugin)
Expand Down

0 comments on commit cc82944

Please sign in to comment.