Skip to content

Commit

Permalink
feat(devtools): allow resetting fromp pinia inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jul 25, 2022
1 parent b01f5c2 commit cee0e16
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/pinia/src/devtools/plugin.ts
Expand Up @@ -114,6 +114,29 @@ export function registerPiniaDevtools(app: DevtoolsApp, pinia: Pinia) {
tooltip: 'Import the state from a JSON file',
},
],
nodeActions: [
{
icon: 'restore',
tooltip: 'Reset the state (option store only)',
action: (nodeId) => {
const store = pinia._s.get(nodeId)
if (!store) {
toastMessage(
`Cannot reset "${nodeId}" store because it wasn't found.`,
'warn'
)
} else if (!store._isOptionsAPI) {
toastMessage(
`Cannot reset "${nodeId}" store because it's a setup store.`,
'warn'
)
} else {
store.$reset()
toastMessage(`Store "${nodeId}" reset.`)
}
},
},
],
})

api.on.inspectComponent((payload, ctx) => {
Expand Down

0 comments on commit cee0e16

Please sign in to comment.