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

feat: Select all projects checkbox #569

Merged
merged 8 commits into from
Dec 13, 2024
Merged

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Dec 13, 2024

Works towards microsoft/playwright#33865. Once we have a "unselect all" button, we can automatically select all projects by default.

Screen.Recording.2024-12-13.at.15.30.12.mov

@Skn0tt Skn0tt requested review from agg23 and Copilot December 13, 2024 14:31
@Skn0tt Skn0tt self-assigned this Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (3)

src/settingsView.ts:304

  • The variable 'selectConfig' is declared but never used. It should be removed to clean up the code.
let selectConfig;

src/settingsView.ts:301

  • The 'projectsElement' and 'selectAllCheckbox' should be defined before they are used in the 'updateProjects' function to avoid potential issues.
const projectsElement = document.getElementById('projects');

src/settingsView.ts:337

  • The 'updateProjects' function should have test coverage to ensure the 'selectAllCheckbox' behavior is correctly implemented.
selectAllCheckbox.addEventListener('change', event => {
@@ -316,12 +319,34 @@ function htmlForWebview(vscode: vscodeTypes.VSCode, extensionUri: vscodeTypes.Ur
div.appendChild(label);
projectsElement.appendChild(div);
}

const allEnabled = projects.every(p => p.enabled);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You set this to a variable, then never use it, and redo the same calculation in the next line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops!

const vscode = acquireVsCodeApi();
for (const input of document.querySelectorAll('input[type=checkbox]')) {
input.addEventListener('change', event => {
vscode.postMessage({ method: 'toggle', params: { setting: event.target.getAttribute('setting') } });
const setting = event.target.getAttribute('setting');
if (setting)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if there's no setting (I don't know this VSCode API)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's standard DOM. We have some input elements in the HTML that have a setting attribute, e.g. this:

https://github.com/Skn0tt/playwright-vscode/blob/9f109ef3ce9af487b00136196fc67810cb0e1ee2/src/settingsView.ts#L276

Before this change, there were no elements without a setting. But i've added a new input element that doesn't have it, so we need to check this here. Makes me think we shouldn't attach the event listener in the first place, letb me change that!

Copy link
Member Author

@Skn0tt Skn0tt Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding it to the css selector is smoother I think: a1e1a82

@Skn0tt Skn0tt merged commit 5ba09b8 into microsoft:main Dec 13, 2024
6 checks passed
Skn0tt added a commit that referenced this pull request Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants