Skip to content

Commit

Permalink
fix(ui): add safeguard against bad plugin import code to prevent user…
Browse files Browse the repository at this point in the history
… disruption + this will also prevent issues for users who already have bad plugins with both workspaceId & collectionId filled in their workspace (related to #280)
  • Loading branch information
flawiddsouza committed Oct 11, 2024
1 parent dd8fbce commit 4f6afc5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/components/modals/PluginManagerModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export default {
if(!this.activeWorkspace) {
return []
}
return this.$store.state.plugins.workspace.filter(plugin => plugin.workspaceId === this.activeWorkspace._id)
return this.$store.state.plugins.workspace.filter(plugin => plugin.workspaceId === this.activeWorkspace._id && plugin.collectionId === null)
},
activeWorkspace() {
return this.$store.state.activeWorkspace
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export async function getWorkspacePlugins(workspaceId: string) {
const collectionItemPlugins = await db.plugins.where('collectionId').anyOf(collectionIds).toArray()

return [
...workspacePlugins,
...workspacePlugins.filter(plugin => plugin.collectionId === null),
...collectionItemPlugins
]
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ export const store = createStore<State>({
globalPlugins.push(enabledPlugin)
}

if(context.state.activeWorkspace !== null && enabledPlugin.workspaceId === context.state.activeWorkspace._id) {
if(context.state.activeWorkspace !== null && enabledPlugin.workspaceId === context.state.activeWorkspace._id && enabledPlugin.collectionId === null) {
workspacePlugins.push(enabledPlugin)
}

Expand Down

0 comments on commit 4f6afc5

Please sign in to comment.