@grafana/runtime
Version:
Grafana Runtime Library
1 lines • 1.38 kB
Source Map (JSON)
{"version":3,"file":"returnToPrevious.mjs","sources":["../../../src/utils/returnToPrevious.ts"],"sourcesContent":["type ReturnToPreviousHook = () => (title: string, href?: string) => void;\n\nlet rtpHook: ReturnToPreviousHook | undefined = undefined;\n\nexport const setReturnToPreviousHook = (hook: ReturnToPreviousHook) => {\n rtpHook = hook;\n};\n\n/**\n * Guidelines:\n * - Only use the ‘Return to previous’ functionality when the user is sent to another context, such as from Alerting to a dashboard.\n * - Specify a button title that identifies the page to return to in the most understandable way. Do not use text such as ‘Back to the previous page’. Be specific.\n */\nexport const useReturnToPrevious: ReturnToPreviousHook = () => {\n if (!rtpHook) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('useReturnToPrevious hook not found in @grafana/runtime');\n }\n return () => console.error('ReturnToPrevious hook not found');\n }\n\n return rtpHook();\n};\n"],"names":[],"mappings":"AAEA,IAAI,OAA4C,GAAA,SAAA;AAEnC,MAAA,uBAAA,GAA0B,CAAC,IAA+B,KAAA;AACrE,EAAU,OAAA,GAAA,IAAA;AACZ;AAOO,MAAM,sBAA4C,MAAM;AAC7D,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAI,IAAA,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,YAAc,EAAA;AACzC,MAAM,MAAA,IAAI,MAAM,wDAAwD,CAAA;AAAA;AAE1E,IAAO,OAAA,MAAM,OAAQ,CAAA,KAAA,CAAM,iCAAiC,CAAA;AAAA;AAG9D,EAAA,OAAO,OAAQ,EAAA;AACjB;;;;"}