From: Eduardo San Martin Morote Date: Mon, 25 Jul 2022 09:34:13 +0000 (+0200) Subject: feat(devtools): allow resetting fromp pinia inspector X-Git-Tag: @pinia/nuxt@0.3.1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cee0e16e0ea343f97fa6b96f80ff32380637110b;p=thirdparty%2Fvuejs%2Fpinia.git feat(devtools): allow resetting fromp pinia inspector --- 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) => {