Skip to content
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

create: add shortcut to toggle all switches #3226

Merged
merged 8 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/update-textual-snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Run pytest to update snapshots
id: pytest
run: |
python3 -m pytest tests/test_create_app.py --snapshot-update --color=yes --durations=0
python3 -m pytest tests/pipelines/test_create_app.py --snapshot-update --color=yes --durations=0
continue-on-error: true

# indication that the run has finished
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
### General

- Include .nf-core.yml in `nf-core pipelines bump-version` ([#3220](https://github.com/nf-core/tools/pull/3220))
- create: add shortcut to toggle all switches ([#3226](https://github.com/nf-core/tools/pull/3226))

## [v3.0.2 - Titanium Tapir Patch](https://github.com/nf-core/tools/releases/tag/3.0.2) - [2024-10-11]

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Optionally followed by the description that you want to add to the changelog.

- Update Textual snapshots:

If the Textual snapshots (run by `tests/test_crate_app.py`) fail, an HTML report is generated and uploaded as an artifact.
If the Textual snapshots (run by `tests/pipelines/test_crate_app.py`) fail, an HTML report is generated and uploaded as an artifact.
If you are sure that these changes are correct, you can automatically update the snapshots form the PR by posting a comment with the magic words:

```
Expand Down
17 changes: 13 additions & 4 deletions nf_core/pipelines/create/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
"""A Textual app to create a pipeline."""

import logging
from pathlib import Path

import click
import yaml
from textual.app import App
from textual.widgets import Button
from textual.widgets import Button, Switch

import nf_core
from nf_core.pipelines.create import utils
from nf_core.pipelines.create.basicdetails import BasicDetails
from nf_core.pipelines.create.custompipeline import CustomPipeline
Expand Down Expand Up @@ -46,6 +43,7 @@ class PipelineCreateApp(App[utils.CreateConfig]):
BINDINGS = [
("d", "toggle_dark", "Toggle dark mode"),
("q", "quit", "Quit"),
("a", "toggle_all", "Toggle all"),
]
SCREENS = {
"welcome": WelcomeScreen(),
Expand Down Expand Up @@ -105,3 +103,14 @@ def on_button_pressed(self, event: Button.Pressed) -> None:
def action_toggle_dark(self) -> None:
"""An action to toggle dark mode."""
self.dark: bool = not self.dark

def action_toggle_all(self) -> None:
"""An action to toggle all Switches."""
switches = self.query(Switch)
if not switches:
return # No Switches widgets found
# Determine the new state based on the first switch
new_state = not switches.first().value if switches.first() else True
for switch in switches:
switch.value = new_state
self.refresh()
2 changes: 1 addition & 1 deletion nf_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def fetch_wf_config(wf_path: Path, cache_config: bool = True) -> dict:

# If we can, save a cached copy
# HINT: during testing phase (in test_download, for example) we don't want
# to save configuration copy in $HOME, otherwise the tests/test_download.py::DownloadTest::test_wf_use_local_configs
# to save configuration copy in $HOME, otherwise the tests/pipelines/test_download.py::DownloadTest::test_wf_use_local_configs
# will fail after the first attempt. It's better to not save temporary data
# in others folders than tmp when doing tests in general
if cache_path and cache_config:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
246 changes: 123 additions & 123 deletions tests/pipelines/__snapshots__/test_create_app/test_choose_type.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
258 changes: 129 additions & 129 deletions tests/pipelines/__snapshots__/test_create_app/test_customisation_help.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
246 changes: 123 additions & 123 deletions tests/pipelines/__snapshots__/test_create_app/test_final_details.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
260 changes: 130 additions & 130 deletions tests/pipelines/__snapshots__/test_create_app/test_github_details.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
238 changes: 119 additions & 119 deletions tests/pipelines/__snapshots__/test_create_app/test_github_question.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
254 changes: 127 additions & 127 deletions tests/pipelines/__snapshots__/test_create_app/test_type_custom.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
252 changes: 126 additions & 126 deletions tests/pipelines/__snapshots__/test_create_app/test_type_nfcore.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
250 changes: 125 additions & 125 deletions tests/pipelines/__snapshots__/test_create_app/test_welcome.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading