Skip to content

Commit 8e686aa

Browse files
committed
Improve Error Handling and package updates
1 parent e38debc commit 8e686aa

9 files changed

Lines changed: 967 additions & 2254 deletions

azure-devops-extension-dev.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id":"RestDataMappingPicklistDev",
3-
"version": "0.2.6",
3+
"version": "0.2.7",
44
"baseUri": "https://localhost:44300",
55
"public": false,
66
"private":true

azure-devops-extension.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifestVersion": 1.0,
33
"id": "RestDataMappingPicklist",
44
"publisher": "dedac",
5-
"version": "0.2.6",
5+
"version": "0.2.7",
66
"name": "Rest Data Mapping Picklist",
77
"description": "Load work item values from a specified REST endpoint and map additional REST data to your work item",
88
"public": true,
@@ -93,8 +93,8 @@
9393
},
9494
{
9595
"id": "RestServiceUserName",
96-
"name": "Rest Service User Name / 'Bearer'",
97-
"description": "The name of the property to load from the rest service, use 'Bearer' for token auth",
96+
"name": "Rest Service User Name / 'Bearer' / 'Basic'",
97+
"description": "The name of the property to load from the rest service, use 'Bearer' or 'Basic' for token auth",
9898
"validation": {
9999
"dataType": "String",
100100
"isRequired": false

overview.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Use this with the ServiceNow table api, or any other Rest API.
66

77
You can now use basic auth by adding the username and password, or use token authentication by using the username "Bearer", and use the token in the password field
88

9+
For Azure DevOps rest calls, you can also use the username 'Basic' with the PAT in the password field
10+
911
The rest data that is returned can be used to automatically update other fields in the work item.
1012
Use the field mapping configuration illustrated below to map fields from the rest service to field names in Azure DevOps
1113

@@ -43,5 +45,5 @@ Sample Settigns for Calling this Service
4345

4446
'Custom.' are custom field names in Azure DevOps, use the fields names that you want data from the rest service mapped to.
4547

46-
Add https://dedac.gallerycdn.vsassets.io to the CORS allowed domains to use the extension
48+
You may have to Add https://dedac.gallerycdn.vsassets.io to the CORS allowed domains on the rest service that you are calling to use the extension. This isn't necessary for calling back into the Azure DevOps API
4749

package-lock.json

Lines changed: 934 additions & 2229 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rest-data-mapping-picklist",
3-
"version": "0.2.6",
3+
"version": "0.2.7",
44
"description": "An Azure DevOps Work Item Control for loading values from a Rest endpoint",
55
"main": "index.js",
66
"scripts": {
@@ -44,15 +44,15 @@
4444
"eslint-plugin-react-hooks": "^1.6.0",
4545
"file-loader": "^6.2.0",
4646
"html-webpack-plugin": "^4.5.2",
47-
"lodash-webpack-plugin": "^0.11.5",
4847
"prettier": "^2.2.1",
4948
"source-map-loader": "^1.1.3",
5049
"style-loader": "^2.0.0",
5150
"tfx-cli": "^0.9.2",
5251
"ts-loader": "^6.0.2",
5352
"typescript": "^3.5.2",
5453
"typescript-styled-plugin": "^0.18.0",
55-
"webpack": "^4.46.0",
54+
"underscore": "^1.12.1",
55+
"webpack": "^5.49.0",
5656
"webpack-cli": "^3.3.3",
5757
"webpack-dev-server": "^3.11.2"
5858
}

src/RestServiceData.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import * as SDK from 'azure-devops-extension-sdk';
22
import { WorkItemTrackingServiceIds, IWorkItemFormService } from "azure-devops-extension-api/WorkItemTracking/WorkItemTrackingServices";
33
import { LoadDataFromService } from './rest-call';
4-
import get from 'lodash/get';
4+
import get from 'lodash/get';
5+
import { AxiosResponse } from 'axios';
56

67
export class RestServiceData {
78

89
public data = [];
910

1011
public async getSuggestedValues(): Promise<string[]> {
11-
const resp = await LoadDataFromService();
12+
var resp: AxiosResponse<any>;
13+
try {
14+
resp = await LoadDataFromService();
15+
} catch (error) {
16+
return Promise.resolve([]);
17+
}
1218
const keyFieldName = SDK.getConfiguration().witInputs.RestServiceKeyField;
1319
const arrayPath = SDK.getConfiguration().witInputs.PathToArray;
1420

src/SelectorEvents.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class SelectorEvents {
3131
}
3232
catch (e) {
3333
console.info("Error parsing the field map " + e);
34-
//we dont' have to do anything if the map isn't valid json
34+
//we don't have to do anything if the map isn't valid json
3535
this.fieldMap = null;
3636
}
3737
}
@@ -41,7 +41,7 @@ export class SelectorEvents {
4141
fieldName={friendlyName}
4242
selected={this.valueObservable}
4343
options={this.serviceData.getSuggestedValues()}
44-
placeholder="Select"
44+
placeholder=""
4545
message={this.messageObservable}
4646
/>, this._container);
4747
}

src/rest-call.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,37 @@ export async function LoadDataFromService() {
66
const address = inputs.RestServiceAddress;
77
const username = inputs.RestServiceUserName;
88
const password = inputs.RestServicePassword;
9-
var params:any = {}
10-
if (inputs.RestCallParameters){
9+
var params: any = {}
10+
if (inputs.RestCallParameters) {
1111
try {
1212
params = JSON.parse(inputs.RestCallParameters);
13-
} catch(e) {
13+
} catch (err) {
14+
console.log(err)
1415
return;
15-
//TODO: return error message
1616
}
1717
}
18-
19-
var reqConfig = {
18+
19+
var reqConfig = {
2020
headers: {
2121
'Content-Type': 'application/json'
2222
}
2323
};
24-
25-
if (username || password)
26-
{
24+
25+
if (username || password) {
2726
if (username == "Bearer" || username == "bearer")
2827
reqConfig.headers["Authorization"] = username + " " + password;
2928
else
3029
reqConfig['auth'] = { username: username, password: password };
3130
}
32-
31+
3332
var req = axios.create(reqConfig);
3433

3534
return req.get(address,
3635
{
3736
params: params
3837
}
39-
);
38+
).catch(err => {
39+
console.log(err);
40+
throw err;
41+
});
4042
}

webpack.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const path = require('path');
22
const webpack = require('webpack');
3-
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
43
const HtmlWebpackPlugin = require('html-webpack-plugin');
54
var CopyWebpackPlugin = require('copy-webpack-plugin');
65

@@ -39,7 +38,6 @@ const controlConfig = {
3938
},
4039
plugins: [
4140
new webpack.optimize.ModuleConcatenationPlugin(),
42-
new LodashModuleReplacementPlugin(),
4341
new HtmlWebpackPlugin({
4442
template: 'src/selector.html',
4543
filename: 'selector.html',

0 commit comments

Comments
 (0)