@grafana/runtime
Version:
Grafana Runtime Library
1 lines • 1.39 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,OAAA,GAA4C,KAAA,CAAA;AAEzC,MAAM,uBAAA,GAA0B,CAAC,IAAA,KAA+B;AACrE,EAAA,OAAA,GAAU,IAAA;AACZ;AAOO,MAAM,sBAA4C,MAAM;AAC7D,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA,EAAc;AACzC,MAAA,MAAM,IAAI,MAAM,wDAAwD,CAAA;AAAA,IAC1E;AACA,IAAA,OAAO,MAAM,OAAA,CAAQ,KAAA,CAAM,iCAAiC,CAAA;AAAA,EAC9D;AAEA,EAAA,OAAO,OAAA,EAAQ;AACjB;;;;"}