feat(github-actions-grafana-jump): make the jump button fully generic - #24
Open
nsheaps-oura wants to merge 1 commit into
Open
feat(github-actions-grafana-jump): make the jump button fully generic#24nsheaps-oura wants to merge 1 commit into
nsheaps-oura wants to merge 1 commit into
Conversation
Reworks the Grafana jump button so no Grafana instance, dashboard UID, or template-variable name is baked into the script. This also removes the reason the script's header previously said it was intentionally NOT published to GreasyFork (baked-in internal Oura infra links) - that constraint is gone now that it's fully user-configured, though whether/how to actually publish is a separate decision. Behavior: - Not configured yet -> the jump button opens an in-page config panel (not a native prompt) to set a Grafana base URL and one or more dashboards, each with whichever template-variable names it uses for filtering by branch/PR/workflow/runner. - Configured -> jumps straight to the first applicable dashboard for the current page, with a small "▾" menu to jump to a different configured dashboard or reopen the config panel. - Config persists via GM.setValue/GM.getValue (@grant changed from `none` to GM.setValue/GM.getValue accordingly), scoped to this script/browser. The existing context-detection logic (parsePrContext, parseBranchContext, parseRunnerContext, parseWorkflowContext, resolveJumpContext, extractBranchFromQuery) is untouched. New pure, unit-tested logic: contextVarKey/contextFilterValue (map a context to its filter field/value), applicableDashboards (which configured dashboards can handle this context), buildJumpUrl (per-dashboard URL building), defaultConfig/normalizeConfig/isConfigured (config lifecycle). test/grafana-jump.test.js updated accordingly - all 22 tests pass against the built dist/. tsconfig.json: added an explicit "types": ["node", "greasemonkey"] override. Under this repo's moduleResolution setting, tsc doesn't reliably auto-discover @types packages from node_modules/@types the way it does under other resolution modes, and this is now the one package that references both @types/node's `module` (existing test-export guard) and @types/greasemonkey's `GM` global. Deliberately left alone per the task: the still-unconfirmed TODO(nathan) about the two Oura dashboards' real template-variable names is moot for the shipped script now (no dashboard config ships by default at all - users fill in their own), but is not being resolved as a general finding one way or the other; it just no longer applies to this file's own contents. Not touched, pending a separate decision: @downloadURL/@updateURL and the changeset/publish wiring. Generic now, but publishing is a follow-up call, not assumed here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reworks the Grafana jump button (merged via #4) so no Grafana instance, dashboard UID, or template-variable name is baked in:
prompt()) to set a Grafana base URL and one or more dashboards, each with whichever template-variable names it uses for filtering by branch/PR/workflow/runner.GM.setValue/GM.getValue(@grantchanged fromnonetoGM.setValue/GM.getValue).This also resolves the reason the script's header said it was intentionally not published to GreasyFork (baked-in internal Oura infra links) — that constraint no longer applies now that it's fully user-configured. Not touched here:
@downloadURL/@updateURLand the changeset/publish wiring — whether/how to actually publish is a separate decision, left for follow-up per the task.The existing context-detection logic (
parsePrContext,parseBranchContext,parseRunnerContext,parseWorkflowContext,resolveJumpContext,extractBranchFromQuery) is untouched. The still-unconfirmedTODO(nathan)about the two Oura dashboards' real template-variable names is now moot for this file's own contents (no dashboard config ships by default at all), not resolved as a general finding.This branch is based on pre-#23
main, so its own CI will fail on the same pre-existingmoduleResolution/TypeScript-6.0.3 issue that #23 (#23) fixes — unrelated to this PR's actual changes. Will rebase ontomainonce #23 merges to get a clean CI run here.Test plan
tsc --buildsucceeds for this package (verified against a real TypeScript 6.0.3 install, with fix(ci): restore main's ability to build under typescript 6.0.3 #23's fixes applied locally for verification purposes)node --test test/*.test.js), including new coverage forcontextVarKey,contextFilterValue,applicableDashboards,buildJumpUrl,defaultConfig,normalizeConfig,isConfiguredGMshim since no userscript manager is installed in the test browser): confirmed the unconfigured state renders "⚙️ Set up Grafana jump", the config panel opens and accepts a base URL + dashboard (name/UID/slug/var-names), Save persists it and immediately re-renders the button as "Grafana: PR feat(github-actions-grafana-jump): make the jump button fully generic #24 CIhttps://grafana.test.local/d/abc123/test-dashboard?var-pr_number=24— matched the live PR number), the "▾" menu lists the configured dashboard plus "⚙️ Edit dashboards...", and reopening via that entry shows the panel correctly pre-filled with the saved config.🤖 Generated with Claude Code