If runner feature disabled, don't show 'runner' navlink or pages#262
If runner feature disabled, don't show 'runner' navlink or pages#262david-mears-2 wants to merge 10 commits intomainfrom
Conversation
71ad1bc to
03239a0
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #262 +/- ##
=======================================
Coverage 99.26% 99.26%
=======================================
Files 201 203 +2
Lines 5820 5882 +62
Branches 974 994 +20
=======================================
+ Hits 5777 5839 +62
Misses 42 42
Partials 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
absternator
left a comment
There was a problem hiding this comment.
good change to make!! just a few comments
| throw PackitException("runnerDisabled", HttpStatus.FORBIDDEN) | ||
| } | ||
|
|
||
| override fun getEnabled(): Boolean = false |
There was a problem hiding this comment.
should we not be getting from appconfig? and have this set in application.properties?
There was a problem hiding this comment.
It's set in application.properties already, and I think this line is what reads it (setting config), though it bypasses AppConfig.kt itself. Then this line checks if config was set, returns RunnerService if it is, and if not it returns the DisabledRunnerService.
My changes just add a property to the RunnerService and DisabledRunnerService which is static (enabled -> true for RunnerService, enabled -> false for DisabledRunnerService)
| if (!hasPacketRunPermission(authorities)) { | ||
| const { isRunnerEnabled } = useGetRunnerEnabled(hasPacketRunPermission(authorities)); | ||
|
|
||
| if (!hasPacketRunPermission(authorities) || isRunnerEnabled === false) { |
There was a problem hiding this comment.
| if (!hasPacketRunPermission(authorities) || isRunnerEnabled === false) { | |
| if (!hasPacketRunPermission(authorities) || !isRunnerEnabled ) { |
should probs not show if cant get this config as well.
Also this is pretty static so we can probably just fetch once and store in local storage like we do with other instance related stuff. (i think auth type)
There was a problem hiding this comment.
Refer to app/src/app/components/providers/hooks/useGetAuthConfig.ts, app/src/app/components/providers/AuthConfigProvider.tsx, app/src/lib/localStorageManager.ts. Branch off this PR to make the fetch to the /runner/enabled endpoint happen only once, since it's a static value.
There was a problem hiding this comment.
I'm actually not convinced this is the best idea, because what if the instance decides they want to change the setting from enabled to disabled or vice versa? The setting would be cached in localStorage, unable to change.
Maybe sessionStorage would be a better place than localStorage. You'd do one fetch per session rather than once per browser.
There was a problem hiding this comment.
Done in d123fc8. Created a RunnerConfigProvider following the same pattern as AuthConfigProvider — it fetches /runner/enabled once, caches the result in localStorage, and exposes it via a useRunnerConfig() context hook. NavMenu and PacketRunnerLayout now use the context directly instead of calling the fetch hook themselves.
There was a problem hiding this comment.
Done in d123fc8. Created a
RunnerConfigProviderfollowing the same pattern asAuthConfigProvider— it fetches/runner/enabledonce, caches the result in localStorage, and exposes it via auseRunnerConfig()context hook.NavMenuandPacketRunnerLayoutnow use the context directly instead of calling the fetch hook themselves.
This has since been changed to use sessionStorage instead of localStorage.
| ); | ||
|
|
||
| return { | ||
| isRunnerEnabled: data === true, |
There was a problem hiding this comment.
| isRunnerEnabled: data === true, | |
| isRunnerEnabled: data, |
There was a problem hiding this comment.
Done in d123fc8. useGetRunnerEnabled now returns data directly. The isRunnerEnabled naming is now handled by the consuming RunnerConfigProvider context.
Agent-Logs-Url: https://github.com/mrc-ide/packit/sessions/d290d227-25fc-4955-8a7d-17ddd839abe5 Co-authored-by: david-mears-2 <60350599+david-mears-2@users.noreply.github.com>
|
@copilot Address my comments |
Agent-Logs-Url: https://github.com/mrc-ide/packit/sessions/8efa4b2c-ccfa-4578-8277-c833c64a5a98 Co-authored-by: david-mears-2 <60350599+david-mears-2@users.noreply.github.com>
Addressed in cfe611a. All requested follow-up comments have been implemented, with updated tests (including new Screenshot: https://github.com/user-attachments/assets/98cf2297-297a-4f7d-9967-69ccef0eeb01 |
Agent-Logs-Url: https://github.com/mrc-ide/packit/sessions/29d1ef26-e960-4ccb-8a9a-4c7e1792b052 Co-authored-by: david-mears-2 <60350599+david-mears-2@users.noreply.github.com>
david-mears-2
left a comment
There was a problem hiding this comment.
Updating package-lock.json prevents automated tests. Use git to revert this file to its state in the last human-authored commit.
|
@copilot address comments |
Agent-Logs-Url: https://github.com/mrc-ide/packit/sessions/514dca54-ce7b-406a-ba50-5e23fbc4cd71 Co-authored-by: david-mears-2 <60350599+david-mears-2@users.noreply.github.com>
Done in 48d4b57. Screenshot: https://github.com/user-attachments/assets/90c74593-b29f-4c1b-a645-7b9f8e24b68a
Done in 48d4b57. I addressed the open comments: restored Screenshot: https://github.com/user-attachments/assets/90c74593-b29f-4c1b-a645-7b9f8e24b68a |
|
@copilot Test coverage is missing for most of useGetRunnerEnabled. Please unit test this file for all three possibilities: runnerEnabled as true, false, or null. |
Agent-Logs-Url: https://github.com/mrc-ide/packit/sessions/8f5be384-9f88-4210-8807-e7615aca9e4b Co-authored-by: david-mears-2 <60350599+david-mears-2@users.noreply.github.com>
Done in 06c93d7. I added unit tests for Screenshot (no UI changes in this update): https://github.com/user-attachments/assets/90c74593-b29f-4c1b-a645-7b9f8e24b68a |
Removed loading and error states from TestComponent rendering.
Non-VIMC Packit instances have the option to be read-only, i.e. no runner (this would be configured by setting the environment variable orderly.runner.enabled). If there's no runner we shouldn't show a link to the runner in the nav menu, nor show the runner pages.