-
Notifications
You must be signed in to change notification settings - Fork 53
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
Dependency View Extension #672
Merged
Merged
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
c14e576
trying to get vendordeps
jasondaming 7deb720
working with temp data
jasondaming 747f44e
work on the dependencyView populating from online
jasondaming 793be26
need to debug js not sure how
jasondaming 7c0177f
need to start creating everything in main.js
jasondaming 8675214
version and button correctly populated
jasondaming f550629
closer
jasondaming 166e72a
update version working well
jasondaming 1b86e6e
working need to find that trashcan image
jasondaming f0907cb
refresh now broken
jasondaming 5f4e1f9
fully working needs install warning
jasondaming ef5b2eb
lint changes
jasondaming 4e76ba7
context not used lint
jasondaming b6a47c8
added build warning in bottom right used i18n
jasondaming 33990ee
removed unneeded added offer to uninstall
jasondaming 33068bf
add eslint.config.js file
jasondaming 6f54e95
trying module.exports?
jasondaming 39f83f2
add the resources and out folders
jasondaming 81fd561
try without the .
jasondaming dda18ad
update Github URL base path
jasondaming File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// eslint.config.js | ||
module.exports = | ||
{ | ||
ignores: ["media/", "out/", "resources/"] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
body { | ||
background-color: transparent; | ||
} | ||
|
||
.color-list { | ||
list-style: none; | ||
padding: 0; | ||
} | ||
|
||
.color-entry { | ||
width: 100%; | ||
display: flex; | ||
margin-bottom: 0.4em; | ||
border: 1px solid var(--vscode-input-border); | ||
} | ||
|
||
.color-preview { | ||
width: 2em; | ||
height: 2em; | ||
} | ||
|
||
.color-preview:hover { | ||
outline: inset white; | ||
} | ||
|
||
.color-input { | ||
display: block; | ||
flex: 1; | ||
width: 100%; | ||
color: var(--vscode-input-foreground); | ||
background-color: var(--vscode-input-background); | ||
border: none; | ||
padding: 0 0.6em; | ||
} | ||
|
||
.add-color-button { | ||
display: block; | ||
border: none; | ||
margin: 0 auto; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
//@ts-check | ||
|
||
// This script will be run within the webview itself | ||
// It cannot access the main VS Code APIs directly. | ||
(function () { | ||
const vscode = acquireVsCodeApi(); | ||
let dropdowns; | ||
let buttons; | ||
let message; | ||
let uninstalls; | ||
let installs; | ||
|
||
function populateDropDowns(data) { | ||
dropdowns.forEach((dropdown, index) => { | ||
const versions = data[index].versionInfo; | ||
versions.forEach((versionTuple, i) => { | ||
const option = document.createElement('option'); | ||
option.value = versionTuple.version; | ||
option.textContent = versionTuple.version; | ||
if (data[index].currentVersion === versionTuple.version) { | ||
option.selected = true; | ||
buttons[index].textContent = versionTuple.buttonText; | ||
if (i === 0) { | ||
//This is the first element of the version array thus the most current | ||
buttons[index].setAttribute('disabled', 'true'); | ||
} | ||
} | ||
dropdown.appendChild(option); | ||
}); | ||
}); | ||
} | ||
|
||
// Function to generate HTML for installed dependencies | ||
function generateInstalledHTML(installed) { | ||
const trash = document.getElementById('trashicon')?.innerHTML | ||
// Create HTML for installed dependencies | ||
let installedHtml = '<h2>Installed VendorDeps</h2>'; | ||
installed.forEach((dep, index) => { | ||
installedHtml += ` | ||
<div class="installed-dependency"> | ||
<div class="top-line"> | ||
<span>${dep.name}</span><span>${dep.currentVersion}</span> | ||
</div> | ||
<div class="update"> | ||
<select id="version-select-${index}"></select> | ||
<button id="version-action-${index}"></button> | ||
<button id="uninstall-action-${index}" class="uninstall-button" data-dependency="${dep.name}"> | ||
<img src=${trash} alt="Uninstall"> | ||
</button> | ||
</div> | ||
</div> | ||
`; | ||
}); | ||
return installedHtml; | ||
} | ||
|
||
// Function to generate HTML for available dependencies | ||
function generateAvailableHTML(available) { | ||
// Create HTML for available dependencies | ||
let availableHtml = '<h2>Available Dependencies</h2>'; | ||
available.forEach((dep, index) => { | ||
availableHtml += ` | ||
<div class="available-dependency"> | ||
<div class="top-line"> | ||
<span class="name">${dep.name}</span><button id="install-action-${index}">Install</button> | ||
</div> | ||
<div class="details">${dep.version} - ${dep.description}</div> | ||
</div> | ||
`; | ||
}); | ||
return availableHtml; | ||
} | ||
|
||
// Add event listeners to the buttons | ||
function addEventListeners() { | ||
// Handle messages sent from the extension to the webview | ||
window.addEventListener('message', event => { | ||
message = event.data; // The json data that the extension sent | ||
switch (message.type) { | ||
case 'updateDependencies': | ||
{ | ||
const installedHTML = generateInstalledHTML(message.installed); | ||
const availableHTML = generateAvailableHTML(message.available); | ||
|
||
const installedContainer = document.getElementById('installed-dependencies'); | ||
const availableContainer = document.getElementById('available-dependencies'); | ||
|
||
if (installedContainer) { | ||
installedContainer.innerHTML = installedHTML; | ||
} else { | ||
console.error('Element with ID "installed-dependencies" not found.'); | ||
} | ||
|
||
if (availableContainer) { | ||
availableContainer.innerHTML = availableHTML; | ||
} else { | ||
console.error('Element with ID "available-dependencies" not found.'); | ||
} | ||
|
||
dropdowns = document.querySelectorAll('select[id^="version-select-"]'); | ||
buttons = document.querySelectorAll('button[id^="version-action-"]'); | ||
uninstalls = document.querySelectorAll('button[id^="uninstall-action-"]'); | ||
installs = document.querySelectorAll('button[id^="install-action-"]'); | ||
addDropdownListeners(); | ||
populateDropDowns(message.installed); | ||
break; | ||
} | ||
} | ||
}); | ||
|
||
document.getElementById('updateall-action')?.addEventListener('click', () => { | ||
vscode.postMessage({ type: 'updateall' }) | ||
}); | ||
|
||
document.getElementById('refresh-action')?.addEventListener('click', () => { | ||
vscode.postMessage({ type: 'refresh' }) | ||
}); | ||
} | ||
|
||
function addDropdownListeners() { | ||
// Add event listener for the dropdown | ||
dropdowns.forEach((dropdown, index) => | ||
dropdown.addEventListener('change', () => { | ||
const versions = message.installed[index].versionInfo; | ||
var selectedText = dropdown.options[dropdown.selectedIndex].text; | ||
const version = versions.find(versionTuple => versionTuple.version === selectedText); | ||
// Change button text based on selected dropdown value | ||
buttons[index].textContent = version.buttonText; | ||
|
||
if (dropdown.selectedIndex === 0 && version.version === message.installed[index].currentVersion) { | ||
//This is the first element of the version array thus the most current | ||
buttons[index].disabled = true; | ||
} else { | ||
buttons[index].disabled = false; | ||
} | ||
}) | ||
); | ||
|
||
buttons.forEach(button => { | ||
button.addEventListener('click', () => { | ||
const action = button.getAttribute('id'); | ||
const index = getStringUntilFirstDashFromRight(action); | ||
const drop = document.getElementById("version-select-" + index); | ||
if (drop && drop instanceof HTMLSelectElement) { | ||
var selectedText = drop.options[drop.selectedIndex].text; | ||
// Handle update logic here | ||
vscode.postMessage({ type: 'update', version: selectedText, index: index }); | ||
} | ||
}); | ||
}); | ||
|
||
uninstalls.forEach(uninstall => { | ||
uninstall.addEventListener('click', () => { | ||
const action = uninstall.getAttribute('id'); | ||
const index = getStringUntilFirstDashFromRight(action); | ||
vscode.postMessage({ type: 'uninstall', index: index }); | ||
}); | ||
}); | ||
|
||
installs.forEach(install => { | ||
install.addEventListener('click', () => { | ||
const action = install.getAttribute('id'); | ||
const index = getStringUntilFirstDashFromRight(action); | ||
vscode.postMessage({ type: 'install', index: index }); | ||
}); | ||
}); | ||
} | ||
|
||
function getStringUntilFirstDashFromRight(str) { | ||
const index = str.lastIndexOf("-"); | ||
if (index === -1) { | ||
return str; // No dash found, return the whole string | ||
} | ||
return str.substring(index + 1); | ||
} | ||
|
||
addEventListeners(); | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
html { | ||
box-sizing: border-box; | ||
font-size: 13px; | ||
} | ||
|
||
*, | ||
*:before, | ||
*:after { | ||
box-sizing: inherit; | ||
} | ||
|
||
body, | ||
h1, | ||
h2, | ||
h3, | ||
h4, | ||
h5, | ||
h6, | ||
p, | ||
ol, | ||
ul { | ||
margin: 0; | ||
padding: 0; | ||
font-weight: normal; | ||
} | ||
|
||
img { | ||
max-width: 100%; | ||
height: auto; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
:root { | ||
--container-paddding: 20px; | ||
--input-padding-vertical: 6px; | ||
--input-padding-horizontal: 4px; | ||
--input-margin-vertical: 4px; | ||
--input-margin-horizontal: 0; | ||
} | ||
|
||
body { | ||
padding: 0 var(--container-paddding); | ||
color: var(--vscode-foreground); | ||
font-size: var(--vscode-font-size); | ||
font-weight: var(--vscode-font-weight); | ||
font-family: var(--vscode-font-family); | ||
background-color: var(--vscode-editor-background); | ||
} | ||
|
||
ol, | ||
ul { | ||
padding-left: var(--container-paddding); | ||
} | ||
|
||
body > *, | ||
form > * { | ||
margin-block-start: var(--input-margin-vertical); | ||
margin-block-end: var(--input-margin-vertical); | ||
} | ||
|
||
*:focus { | ||
outline-color: var(--vscode-focusBorder) !important; | ||
} | ||
|
||
a { | ||
color: var(--vscode-textLink-foreground); | ||
} | ||
|
||
a:hover, | ||
a:active { | ||
color: var(--vscode-textLink-activeForeground); | ||
} | ||
|
||
code { | ||
font-size: var(--vscode-editor-font-size); | ||
font-family: var(--vscode-editor-font-family); | ||
} | ||
|
||
button { | ||
border: none; | ||
padding: var(--input-padding-vertical) var(--input-padding-horizontal); | ||
width: 100%; | ||
text-align: center; | ||
outline: 1px solid transparent; | ||
outline-offset: 2px !important; | ||
color: var(--vscode-button-foreground); | ||
background: var(--vscode-button-background); | ||
} | ||
|
||
button:hover { | ||
cursor: pointer; | ||
background: var(--vscode-button-hoverBackground); | ||
} | ||
|
||
button:focus { | ||
outline-color: var(--vscode-focusBorder); | ||
} | ||
|
||
button.secondary { | ||
color: var(--vscode-button-secondaryForeground); | ||
background: var(--vscode-button-secondaryBackground); | ||
} | ||
|
||
button.secondary:hover { | ||
background: var(--vscode-button-secondaryHoverBackground); | ||
} | ||
|
||
input:not([type='checkbox']), | ||
textarea { | ||
display: block; | ||
width: 100%; | ||
border: none; | ||
font-family: var(--vscode-font-family); | ||
padding: var(--input-padding-vertical) var(--input-padding-horizontal); | ||
color: var(--vscode-input-foreground); | ||
outline-color: var(--vscode-input-border); | ||
background-color: var(--vscode-input-background); | ||
} | ||
|
||
input::placeholder, | ||
textarea::placeholder { | ||
color: var(--vscode-input-placeholderForeground); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
#683 adds the logo in the resources directory, so shouldn't need to add this one