From cee0e16e0ea343f97fa6b96f80ff32380637110b Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 25 Jul 2022 11:34:13 +0200 Subject: [PATCH] feat(devtools): allow resetting fromp pinia inspector --- packages/pinia/src/devtools/plugin.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/pinia/src/devtools/plugin.ts b/packages/pinia/src/devtools/plugin.ts index 97b08c46..d62ac5f0 100644 --- a/packages/pinia/src/devtools/plugin.ts +++ b/packages/pinia/src/devtools/plugin.ts @@ -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) => { -- 2.47.3