-
Notifications
You must be signed in to change notification settings - Fork 108
Add toggle to disable task list auto-refresh #1489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -42,7 +42,16 @@ | |||||
| </details> | ||||||
| <% end %> | ||||||
|
|
||||||
| <%= tag.div(data: { refresh: @task.refresh? || "" }) do %> | ||||||
| <% if @task.refresh? %> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we move this whole block into the refreshed wrapper ( |
||||||
| <div class="is-flex is-justify-content-flex-end mb-2"> | ||||||
| <% if @refresh %> | ||||||
| <%= link_to "Disable auto-refresh", task_path(@task, refresh: false), class: "button is-small" %> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Nit, to differentiate it from the bg a bit more. |
||||||
| <% else %> | ||||||
| <%= link_to "Enable auto-refresh", task_path(@task), class: "button is-small" %> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| <% end %> | ||||||
| </div> | ||||||
| <% end %> | ||||||
| <%= tag.div(data: { refresh: (@task.refresh? && @refresh) || "" }) do %> | ||||||
| <% if @task.active_runs.any? %> | ||||||
| <hr> | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require "test_helper" | ||
|
|
||
| module MaintenanceTasks | ||
| class TasksControllerTest < ActionDispatch::IntegrationTest | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer we follow the convention of the existing system tests and test the toggle behaviour in |
||
| # Maintenance::UpdatePostsTask has a paused (active) run, so its show page | ||
| # refreshes by default. | ||
| ACTIVE_TASK = "Maintenance::UpdatePostsTask" | ||
|
|
||
| test "task page auto-refreshes by default when there are active runs" do | ||
| get maintenance_tasks.task_path(ACTIVE_TASK) | ||
|
|
||
| assert_response :success | ||
| assert_select "[data-refresh=true]" | ||
| end | ||
|
|
||
| test "task page does not auto-refresh when refresh=false is passed" do | ||
| get maintenance_tasks.task_path(ACTIVE_TASK), params: { refresh: "false" } | ||
|
|
||
| assert_response :success | ||
| assert_select "[data-refresh=true]", false | ||
| end | ||
|
|
||
| test "task page shows a link to disable auto-refresh when refreshing" do | ||
| get maintenance_tasks.task_path(ACTIVE_TASK) | ||
|
|
||
| assert_response :success | ||
| assert_select "a[href*='refresh=false']", text: "Disable auto-refresh" | ||
| end | ||
|
|
||
| test "task page shows a link to enable auto-refresh when not refreshing" do | ||
| get maintenance_tasks.task_path(ACTIVE_TASK), params: { refresh: "false" } | ||
|
|
||
| assert_response :success | ||
| assert_select "a", text: "Enable auto-refresh" | ||
| end | ||
|
|
||
| test "task page shows no auto-refresh toggle when there are no active runs" do | ||
| get maintenance_tasks.task_path("Maintenance::ImportPostsTask") | ||
|
|
||
| assert_response :success | ||
| assert_select "a", text: "Disable auto-refresh", count: 0 | ||
| assert_select "a", text: "Enable auto-refresh", count: 0 | ||
| end | ||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could name this something more intention revealing now.