diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index c291d34..8cad635 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -9,7 +9,7 @@ jobs: name: Playwright runs-on: ubuntu-latest container: - image: mcr.microsoft.com/playwright:v1.54.0-noble + image: mcr.microsoft.com/playwright:v1.58.2-noble options: --user 1001 steps: - uses: actions/checkout@v4 diff --git a/README.md b/README.md index 9741c9e..22a7d36 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=green-code-initiative_creedengo-dashboard&metric=coverage)](https://sonarcloud.io/summary/new_code?id=green-code-initiative_creedengo-dashboard) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=green-code-initiative_creedengo-dashboard&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=green-code-initiative_creedengo-dashboard) -This project is meant to provide Sustainable Code Dashboards to +This project is meant to provide Sustainable Code Dashboard to - show potential impact on sustainability of unffollowed recommendations - help decisions regarding code enhancement priorisation diff --git a/apps/vscode-sonar-extension/.vscode/launch.json b/apps/vscode-sonar-extension/.vscode/launch.json new file mode 100644 index 0000000..c42edc0 --- /dev/null +++ b/apps/vscode-sonar-extension/.vscode/launch.json @@ -0,0 +1,21 @@ +// A launch configuration that compiles the extension and then opens it inside a new window +// Use IntelliSense to learn about possible attributes. +// Hover to view descriptions of existing attributes. +// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Run Extension", + "type": "extensionHost", + "request": "launch", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}" + ], + "outFiles": [ + "${workspaceFolder}/dist/**/*.js" + ], + "preLaunchTask": "${defaultBuildTask}" + } + ] +} diff --git a/apps/vscode-sonar-extension/.vscode/tasks.json b/apps/vscode-sonar-extension/.vscode/tasks.json index e9cbb20..3b17e53 100644 --- a/apps/vscode-sonar-extension/.vscode/tasks.json +++ b/apps/vscode-sonar-extension/.vscode/tasks.json @@ -1,17 +1,20 @@ +// See https://go.microsoft.com/fwlink/?LinkId=733558 +// for the documentation about the tasks.json format { - "version": "2.0.0", - "tasks": [ - { - "label": "watch", - "type": "npm", - "script": "watch", - "presentation": { - "reveal": "never" - }, - "group": { - "kind": "build", - "isDefault": true - } - }, - ] + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "watch", + "problemMatcher": "$tsc-watch", + "isBackground": true, + "presentation": { + "reveal": "never" + }, + "group": { + "kind": "build", + "isDefault": true + } + } + ] } diff --git a/apps/vscode-sonar-extension/package.json b/apps/vscode-sonar-extension/package.json index 4f1d725..e626a53 100644 --- a/apps/vscode-sonar-extension/package.json +++ b/apps/vscode-sonar-extension/package.json @@ -62,6 +62,14 @@ { "command": "creedengo.updateScore", "title": "Update Creedengo Sustainability Score" + }, + { + "command": "creedengo.updatePriorityRule", + "title": "Update Creedengo Priority Rule" + }, + { + "command": "creedengo.updateFootPrint", + "title": "Update Creedengo Footprint" } ], "views": { diff --git a/apps/vscode-sonar-extension/src/extension.mjs b/apps/vscode-sonar-extension/src/extension.mjs index b22c923..6857dcd 100644 --- a/apps/vscode-sonar-extension/src/extension.mjs +++ b/apps/vscode-sonar-extension/src/extension.mjs @@ -20,6 +20,12 @@ export function activate(context) { subscriptions.push( commands.registerCommand('creedengo.updateScore', () => provider.updateScore()) ); + subscriptions.push( + commands.registerCommand('creedengo.updatePriorityRule', () => provider.updatePriorityRule()) + ); + subscriptions.push( + commands.registerCommand('creedengo.updateFootPrint', () => provider.updateFootPrint()) + ); subscriptions.push( commands.registerCommand('creedengo.refresh', () => provider.refresh()) ); diff --git a/apps/vscode-sonar-extension/src/services/configuration.service.mjs b/apps/vscode-sonar-extension/src/services/configuration.service.mjs index 8e3b595..e7dacff 100644 --- a/apps/vscode-sonar-extension/src/services/configuration.service.mjs +++ b/apps/vscode-sonar-extension/src/services/configuration.service.mjs @@ -104,7 +104,7 @@ function readCreedengoVsCodeConfiguration() { /** * @returns {Promise} */ -async function getSonarConfiguration() { +export async function getSonarConfiguration() { const configuration = readCreedengoVsCodeConfiguration() const properties = await readSonarProjectProperties() Object.assign(configuration, properties) diff --git a/apps/vscode-sonar-extension/src/views/score/score.script.mjs b/apps/vscode-sonar-extension/src/views/score/score.script.mjs index 219deb3..04d6545 100644 --- a/apps/vscode-sonar-extension/src/views/score/score.script.mjs +++ b/apps/vscode-sonar-extension/src/views/score/score.script.mjs @@ -11,16 +11,20 @@ import { addMessageHandler } from '../../services/message.service.mjs' let errorCount = 0; const scoreOutput = document.querySelector('.score'); + const priorityRuleNameElem = document.querySelector('.priority-rule'); + const footPrintElem = document.querySelector('.footprint'); const branchFields = document.forms['branch-selection'].elements; const branchesSelect = branchFields['branch']; try { - const oldState = vscode.getState() || { score: '', branch: '' }; - let { score, branch } = oldState; + const oldState = vscode.getState() || { score: '', priorityRule: '', footPrint: '', branch: '' }; + let { score, priorityRule, footPrint, branch } = oldState; const messageHandler = addMessageHandler({ updateScore: data => updateScore(data.value), updateBranches: data => updateBranches(data.value), + updatePriorityRule: data => updatePriorityRule(data.value), + updateFootPrint: data => updateFootPrint(data.value), clearScore: () => updateScore(''), }, logError) @@ -32,8 +36,30 @@ import { addMessageHandler } from '../../services/message.service.mjs' */ function updateScore(newScore) { score = newScore; - scoreOutput.textContent = `Score: ${score || 'Cleared'}`; - vscode.setState({ score, branch }); + scoreOutput.textContent = `${score || 'Cleared'}`; + vscode.setState({ score, priorityRule, footPrint, branch }); + } + + /** + * @param {any} priorityRuleData + */ + function updatePriorityRule(priorityRuleData) { + priorityRule = priorityRuleData; + if (priorityRule) { + const link = document.createElement('a'); + link.href = priorityRule.url; + link.textContent = priorityRule.priorityRule.name; + priorityRuleNameElem.replaceChildren(link); + } else { + priorityRuleNameElem.textContent = 'None'; + } + vscode.setState({ score, priorityRule, footPrint, branch }); + } + + function updateFootPrint(footPrintData) { + footPrint = footPrintData; + footPrintElem.textContent = footPrint ? `${footPrint} kgCO2eq` : 'None'; + vscode.setState({ score, priorityRule, footPrint, branch }); } /** @@ -53,7 +79,7 @@ import { addMessageHandler } from '../../services/message.service.mjs' branches.forEach(branchData => { const { name, isMain } = branchData; const option = new Option(name, name); - Object.assign(option.dataset, branch); + Object.assign(option.dataset, branchData); options.add(option); if ((isMain && !newSelected) || (name === previousSelected)) { newSelected = option; @@ -63,7 +89,7 @@ import { addMessageHandler } from '../../services/message.service.mjs' newSelected.selected = true; } branch = newSelected.dataset.name; - vscode.setState({ score, branch }); + vscode.setState({ score, priorityRule, footPrint, branch }); vscode.postMessage({ type: 'selectBranch', message: branch }); } diff --git a/apps/vscode-sonar-extension/src/views/score/score.view.html b/apps/vscode-sonar-extension/src/views/score/score.view.html index 28c710e..d84f7b2 100644 --- a/apps/vscode-sonar-extension/src/views/score/score.view.html +++ b/apps/vscode-sonar-extension/src/views/score/score.view.html @@ -13,7 +13,20 @@
- Score: Not Loaded +