-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from rajbos/extract-js
Extract the first set of javascript into widget specific files
- Loading branch information
Showing
10 changed files
with
198 additions
and
200 deletions.
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,22 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
||
- run: | | ||
npm install | ||
npm install -g tfx-cli | ||
- name: Create extension | ||
run: tfx extension create --manifest-globs vss-extension-dev.json --rev-version | ||
#- run: npm run test |
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
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
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
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
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
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,85 @@ | ||
async function loadWidget(widgetSettings, organization, projectName) { | ||
consoleLog(`WidgetSettings inside loadWidget_1x1: ${JSON.stringify(widgetSettings)}`); | ||
consoleLog(`Running for organization [${organization}], projectName [${projectName}]`); | ||
|
||
// data contains a stringified json object, so we need to make a json object from it | ||
const data = JSON.parse(widgetSettings.customSettings.data); | ||
|
||
// init with default values | ||
let alerts = { | ||
dependencyAlerts: 0, | ||
secretAlerts: 0, | ||
codeAlerts: 0 | ||
}; | ||
let linkBase = 'https://dev.azure.com'; | ||
|
||
if (data && data.repo) { | ||
const repoName = data.repo; | ||
const repoId = data.repoId; | ||
consoleLog(`loaded repoName from widgetSettings_1x1: [${repoName}] and id [${repoId}]`); | ||
|
||
// set the tile | ||
var title = $('h2.ghazdo-title'); | ||
title.text(`${repoName}`); | ||
consoleLog(`title set to [${repoName}]`); | ||
alerts = await getAlerts(organization, projectName, repoId); | ||
consoleLog('alerts: ' + JSON.stringify(alerts)); | ||
|
||
// GHAS is only available on the SaaS version, so we can hardcode the domain | ||
linkBase = `https://dev.azure.com/${organization}/${projectName}/_git/${repoName}/alerts`; | ||
} | ||
else { | ||
consoleLog('configuration_1x1 is needed first, opening with empty values'); | ||
// set the tile to indicate config is needed | ||
var title = $('h2.ghazdo-title'); | ||
title.text(`Configure the widget to get Security Alerts`); | ||
} | ||
|
||
let alertTypeToShow = 1 | ||
if (data && data.repoAlertType) { | ||
alertTypeToShow = data.repoAlertType; | ||
} | ||
|
||
// set the alert count | ||
consoleLog(`Setting the alert count 1x1 for type ${alertTypeToShow}`); | ||
const alertCountEl = $('p.alertCount'); | ||
let alertCount = 0; | ||
let alertTypeLink = "" | ||
let alertTypeDescripion = ""; | ||
switch (alertTypeToShow) { | ||
case "1": | ||
alertCount = alerts.dependencyAlerts; | ||
alertTypeLink = `${linkBase}?_t=dependencies`; | ||
alertTypeDescripion = "Dependency Alerts"; | ||
break; | ||
case "2": | ||
alertCount = alerts.secretAlerts; | ||
alertTypeLink = `${linkBase}?_t=secrets`; | ||
alertTypeDescripion = "Secret Scanning Alerts"; | ||
break; | ||
case "3": | ||
alertCount = alerts.codeAlerts; | ||
alertTypeLink = `${linkBase}?_t=codescanning`; | ||
alertTypeDescripion = "Code Scanning Alerts"; | ||
break; | ||
default: | ||
alertCount = alerts.dependencyAlerts; | ||
alertTypeLink = `${linkBase}?_t=dependencies`; | ||
alertTypeDescripion = "Dependency Alerts"; | ||
break; | ||
} | ||
|
||
consoleLog(`Setting the alert count to [${alertCount}] with description [${alertTypeDescripion}] and link [${alertTypeLink}]`); | ||
try { | ||
alertCountEl.text(alertCount); | ||
const alertLinkEl = $('a.alert-link'); | ||
alertLinkEl.attr('href', alertTypeLink); | ||
|
||
// set the alert type | ||
const alertType = $('h3.alertType'); | ||
alertType.text(alertTypeDescripion); | ||
} | ||
catch (err) { | ||
consoleLog(`Error setting the alert count 1x1: ${err}`); | ||
} | ||
} |
Oops, something went wrong.