-
Notifications
You must be signed in to change notification settings - Fork 0
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: add webview with ability to change settings in runtime #9
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 |
---|---|---|
|
@@ -7,4 +7,4 @@ vscode.d.ts | |
samples/**/.* | ||
.wdio* | ||
.tmp | ||
tests/e2e/screens-on-fail | ||
tests/e2e/**/screens-on-fail |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.section__header { | ||
font-size: 11px; | ||
margin: 10px 0 3px 8px; | ||
font-weight: 700; | ||
color: var(--vscode-editor-inlineValuesForeground); | ||
text-transform: uppercase; | ||
} | ||
|
||
.section__list { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.section__list-item { | ||
height: 22px; | ||
line-height: 22px; | ||
padding-right: 2px; | ||
padding-left: 8px; | ||
display: flex; | ||
align-items: center; | ||
box-sizing: border-box; | ||
width: 100%; | ||
white-space: nowrap; | ||
flex: 0; | ||
cursor: pointer; | ||
} | ||
|
||
.section__list-item:hover { | ||
background-color: #e8e8e8; | ||
} | ||
|
||
body[data-vscode-theme-kind="vscode-dark"] .section__list-item:hover { | ||
background-color: #2a2d2e; | ||
} | ||
|
||
label { | ||
display: flex; | ||
align-items: center; | ||
cursor: inherit; | ||
flex: auto; | ||
} | ||
|
||
input[type="checkbox"] { | ||
margin-right: 4px; | ||
cursor: pointer; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// This script will be run within the webview itself | ||
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. This is js file for new webview in sidebar (in which render setting elements: devtools and repl) |
||
// It cannot access the main VS Code APIs directly. | ||
(function () { | ||
// eslint-disable-next-line no-undef | ||
const vscode = acquireVsCodeApi(); | ||
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. This solution found in vscode example - https://github.com/microsoft/vscode-extension-samples/tree/main/webview-view-sample |
||
listenSettingsCheckbox(); | ||
|
||
// eslint-disable-next-line no-undef | ||
window.addEventListener("message", event => { | ||
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. From vscode extension I send event to webview. Here I listen this event and modify checkboxes |
||
const { method, params } = event.data; | ||
|
||
if (method === "updateSettings") { | ||
for (const [key, value] of Object.entries(params.settings)) { | ||
// eslint-disable-next-line no-undef | ||
const input = document.querySelector(".section_type_settings input[settingName=" + key + "]"); | ||
|
||
if (!input) { | ||
continue; | ||
} | ||
|
||
if (typeof value === "boolean") { | ||
input.checked = value; | ||
} else { | ||
input.value = value; | ||
} | ||
} | ||
} | ||
}); | ||
|
||
function listenSettingsCheckbox() { | ||
// eslint-disable-next-line no-undef | ||
for (const checkbox of document.querySelectorAll(".section_type_settings input[type=checkbox]")) { | ||
checkbox.addEventListener("change", function (event) { | ||
vscode.postMessage({ | ||
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. When checkbox is clicked I send event to vscode in order to use it when run tests |
||
method: "toggleSettingsCheckbox", | ||
params: { | ||
settingName: event.target.getAttribute("settingName"), | ||
value: this.checked, | ||
}, | ||
}); | ||
}); | ||
} | ||
} | ||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,10 @@ export default { | |
httpTimeout: 60000, | ||
testTimeout: 90000, | ||
resetCursor: false, | ||
takeScreenshotOnFails: { | ||
testFail: false, | ||
assertViewFail: false, | ||
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. There is no need to wasting time on it |
||
}, | ||
sets: { | ||
desktop: { | ||
files: ["tests/**/*.testplane.ts"], | ||
|
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.
This is css file for new webview in sidebar