Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e39440f

Browse files
authoredAug 3, 2020
Merge pull request #336 from afrisalyp/develop
Remove azure.
2 parents abb5774 + 9f43e31 commit e39440f

18 files changed

+14
-1044
lines changed
 

‎src/common/constants.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ const USER_ROLES = {
3030
// The user types
3131
const USER_TYPES = {
3232
GITHUB: 'github',
33-
GITLAB: 'gitlab',
34-
AZURE: 'azure'
33+
GITLAB: 'gitlab'
3534
};
3635

3736
// The default page size for Gitlab API
@@ -50,15 +49,8 @@ const GITLAB_ACCESS_TOKEN_DEFAULT_EXPIRATION = 3600 * 24 * 14;
5049
// The Gitlab refresh token time in seconds before expiration
5150
const GITLAB_REFRESH_TOKEN_BEFORE_EXPIRATION = 300;
5251

53-
// The Azure access token default expiration in seconds
54-
const AZURE_ACCESS_TOKEN_DEFAULT_EXPIRATION = 3600 * 24 * 14;
55-
56-
// The Azure refresh token time in seconds before expiration
57-
const AZURE_REFRESH_TOKEN_BEFORE_EXPIRATION = 300;
58-
5952
const GITHUB_OWNER_CALLBACK_URL = '/api/v1/github/owneruser/callback';
6053
const GITLAB_OWNER_CALLBACK_URL = '/api/v1/gitlab/owneruser/callback';
61-
const AZURE_OWNER_CALLBACK_URL = '/api/v1/azure/owneruser/callback';
6254

6355
const OWNER_USER_LOGIN_SUCCESS_URL = '/#!/app/settings';
6456
const USER_ADDED_TO_TEAM_SUCCESS_URL = '/#!/members';
@@ -78,11 +70,8 @@ module.exports = {
7870
GITLAB_DEFAULT_GROUP_ACCESS_LEVEL,
7971
GITLAB_ACCESS_TOKEN_DEFAULT_EXPIRATION,
8072
GITLAB_REFRESH_TOKEN_BEFORE_EXPIRATION,
81-
AZURE_ACCESS_TOKEN_DEFAULT_EXPIRATION,
82-
AZURE_REFRESH_TOKEN_BEFORE_EXPIRATION,
8373
GITHUB_OWNER_CALLBACK_URL,
8474
GITLAB_OWNER_CALLBACK_URL,
85-
AZURE_OWNER_CALLBACK_URL,
8675
OWNER_USER_LOGIN_SUCCESS_URL,
8776
USER_ADDED_TO_TEAM_SUCCESS_URL,
8877
TC_LOGIN_CALLBACK_URL,

‎src/common/helper.js

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -159,26 +159,6 @@ function convertGitLabError(err, message) {
159159
return apiError;
160160
}
161161

162-
/**
163-
* Convert azure api error.
164-
* @param {Error} err the azure api error
165-
* @param {String} message the error message
166-
* @returns {Error} converted error
167-
*/
168-
function convertAzureError(err, message) {
169-
let resMsg = `${message}. ${err.message}.\n`;
170-
const detail = _.get(err, 'response.body.message');
171-
if (detail) {
172-
resMsg += ` Detail: ${detail}`;
173-
}
174-
const apiError = new errors.ApiError(
175-
err.status || _.get(err, 'response.status', constants.SERVICE_ERROR_STATUS),
176-
_.get(err, 'response.body.message', constants.SERVICE_ERROR),
177-
resMsg
178-
);
179-
return apiError;
180-
}
181-
182162
/**
183163
* Ensure entity exists for given criteria. Return error if no result.
184164
* @param {Object} Model the mongoose model to query
@@ -216,7 +196,7 @@ async function ensureExists(Model, criteria, modelName) {
216196
async function getProviderType(repoUrl) {
217197
const parsedDomain = await parseDomain(repoUrl);
218198
if (!parsedDomain || !parsedDomain.domain ||
219-
(parsedDomain.domain !== 'github' && parsedDomain.domain !== 'gitlab' && parsedDomain.domain !== 'azure')) {
199+
(parsedDomain.domain !== 'github' && parsedDomain.domain !== 'gitlab')) {
220200
throw new ValidationError('Invalid git repo url');
221201
}
222202
return parsedDomain.domain;
@@ -237,21 +217,15 @@ async function getProjectCopilotOrOwner(models, project, provider, isCopilot) {
237217

238218
if (!userMapping ||
239219
(provider === 'github' && !userMapping.githubUserId)
240-
|| (provider === 'gitlab' && !userMapping.gitlabUserId)
241-
|| (provider === 'azure' && !userMapping.azureUserId)) {
220+
|| (provider === 'gitlab' && !userMapping.gitlabUserId)) {
242221
throw new Error(`Couldn't find ${isCopilot ? 'copilot' : 'owner'} username for '${provider}' for this repository.`);
243222
}
244223

245224
let user = await dbHelper.scanOne(models.User, {
246225
username: provider === 'github' ? userMapping.githubUsername : // eslint-disable-line no-nested-ternary
247-
provider === 'gitlab' ? userMapping.gitlabUsername : userMapping.azureEmail,
226+
userMapping.gitlabUsername,
248227
type: provider,
249228
});
250-
251-
if (provider === 'azure') {
252-
const azureService = require('../services/AzureService'); // eslint-disable-line global-require
253-
user = azureService.refreshAzureUserAccessToken(user);
254-
}
255229

256230
return user;
257231
}
@@ -283,7 +257,6 @@ module.exports = {
283257
buildController,
284258
convertGitHubError,
285259
convertGitLabError,
286-
convertAzureError,
287260
ensureExists,
288261
generateIdentifier,
289262
getProviderType,

‎src/config.js

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,11 @@ module.exports = {
1919
GITHUB_CLIENT_SECRET: process.env.GITHUB_CLIENT_SECRET,
2020
GITLAB_CLIENT_ID: process.env.GITLAB_CLIENT_ID,
2121
GITLAB_CLIENT_SECRET: process.env.GITLAB_CLIENT_SECRET,
22-
AZURE_APP_ID: process.env.AZURE_APP_ID,
23-
AZURE_CLIENT_SECRET: process.env.AZURE_CLIENT_SECRET,
24-
AZURE_USER_APP_ID: process.env.AZURE_APP_ID,
25-
AZURE_USER_CLIENT_SECRET: process.env.AZURE_USER_CLIENT_SECRET,
2622

2723
// used as base to construct various URLs
2824
WEBSITE: process.env.WEBSITE || 'http://topcoderx.topcoder-dev.com',
2925
WEBSITE_SECURE: process.env.WEBSITE_SECURE || 'https://topcoderx.topcoder-dev.com',
3026
GITLAB_API_BASE_URL: process.env.GITLAB_API_BASE_URL || 'https://gitlab.com',
31-
AZURE_API_BASE_URL: process.env.AZURE_API_BASE_URL || 'https://app.vssps.visualstudio.com',
32-
AZURE_DEVOPS_API_BASE_URL: process.env.AZURE_DEVOPS_API_BASE_URL || 'https://dev.azure.com',
3327

3428
// kafka configuration
3529
TOPIC: process.env.TOPIC || 'tc-x-events',
@@ -90,12 +84,9 @@ const frontendConfigs = {
9084
"DIRECT_URL_BASE": "https://www.topcoder-dev/direct/projectOverview?formData.projectId=",
9185
"OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login",
9286
"OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login",
93-
"OWNER_LOGIN_AZURE_URL":"/api/v1/azure/owneruser/login",
9487
"TOPCODER_URL": "https://topcoder-dev.com",
9588
"GITHUB_TEAM_URL": "https://github.com/orgs/",
96-
"GITLAB_GROUP_URL": "https://gitlab.com/groups/",
97-
"AZURE_TEAM_URL": "https://dev.azure.com/"
98-
89+
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
9990
},
10091
"heroku":{
10192
"JWT_V3_NAME":"v3jwt",
@@ -109,11 +100,9 @@ const frontendConfigs = {
109100
"DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=",
110101
"OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login",
111102
"OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login",
112-
"OWNER_LOGIN_AZURE_URL":"/api/v1/azure/owneruser/login",
113103
"TOPCODER_URL": "https://topcoder-dev.com",
114104
"GITHUB_TEAM_URL": "https://github.com/orgs/",
115-
"GITLAB_GROUP_URL": "https://gitlab.com/groups/",
116-
"AZURE_TEAM_URL": "https://dev.azure.com/"
105+
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
117106
},
118107
"dev":{
119108
"JWT_V3_NAME":"v3jwt",
@@ -127,11 +116,9 @@ const frontendConfigs = {
127116
"DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=",
128117
"OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login",
129118
"OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login",
130-
"OWNER_LOGIN_AZURE_URL":"/api/v1/azure/owneruser/login",
131119
"TOPCODER_URL": "https://topcoder-dev.com",
132120
"GITHUB_TEAM_URL": "https://github.com/orgs/",
133-
"GITLAB_GROUP_URL": "https://gitlab.com/groups/",
134-
"AZURE_TEAM_URL": "https://dev.azure.com/"
121+
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
135122
},
136123
"qa":{
137124
"JWT_V3_NAME":"v3jwt",
@@ -145,11 +132,9 @@ const frontendConfigs = {
145132
"DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=",
146133
"OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login",
147134
"OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login",
148-
"OWNER_LOGIN_AZURE_URL":"/api/v1/azure/owneruser/login",
149135
"TOPCODER_URL": "https://topcoder-dev.com",
150136
"GITHUB_TEAM_URL": "https://github.com/orgs/",
151-
"GITLAB_GROUP_URL": "https://gitlab.com/groups/",
152-
"AZURE_TEAM_URL": "https://dev.azure.com/"
137+
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
153138
},
154139
"prod":{
155140
"JWT_V3_NAME":"v3jwt",
@@ -163,11 +148,9 @@ const frontendConfigs = {
163148
"DIRECT_URL_BASE": "https://www.topcoder.com/direct/projectOverview?formData.projectId=",
164149
"OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login",
165150
"OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login",
166-
"OWNER_LOGIN_AZURE_URL":"/api/v1/azure/owneruser/login",
167151
"TOPCODER_URL": "https://topcoder-dev.com",
168152
"GITHUB_TEAM_URL": "https://github.com/orgs/",
169-
"GITLAB_GROUP_URL": "https://gitlab.com/groups/",
170-
"AZURE_TEAM_URL": "https://dev.azure.com/"
153+
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
171154
}
172155
};
173156

@@ -187,9 +170,7 @@ module.exports.frontendConfigs = {
187170
DIRECT_URL_BASE: process.env.DIRECT_URL_BASE || frontendConfigs[activeEnv].DIRECT_URL_BASE,
188171
OWNER_LOGIN_GITHUB_URL: process.env.OWNER_LOGIN_GITHUB_URL || frontendConfigs[activeEnv].OWNER_LOGIN_GITHUB_URL,
189172
OWNER_LOGIN_GITLAB_URL: process.env.OWNER_LOGIN_GITLAB_URL || frontendConfigs[activeEnv].OWNER_LOGIN_GITLAB_URL,
190-
OWNER_LOGIN_AZURE_URL: process.env.OWNER_LOGIN_AZURE_URL || frontendConfigs[activeEnv].OWNER_LOGIN_AZURE_URL,
191173
TOPCODER_URL: process.env.TOPCODER_URL || frontendConfigs[activeEnv].TOPCODER_URL,
192174
GITHUB_TEAM_URL: process.env.GITHUB_TEAM_URL || frontendConfigs[activeEnv].GITHUB_TEAM_URL,
193-
GITLAB_GROUP_URL: process.env.GITLAB_GROUP_URL || frontendConfigs[activeEnv].GITLAB_GROUP_URL,
194-
AZURE_TEAM_URL: process.env.AZURE_TEAM_URL || frontendConfigs[activeEnv].AZURE_TEAM_URL
175+
GITLAB_GROUP_URL: process.env.GITLAB_GROUP_URL || frontendConfigs[activeEnv].GITLAB_GROUP_URL
195176
};

‎src/controllers/AzureController.js

Lines changed: 0 additions & 299 deletions
This file was deleted.

‎src/front/src/app/git-access-control/access-control.html

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -207,102 +207,6 @@ <h2>Git Access Control</h2>
207207
</a>
208208
</div>
209209
</uib-tab>
210-
<uib-tab index="1" heading="Azure DevOps" select="tabChanged('azure')">
211-
<br/>
212-
<div ng-if="settings.azure==true">
213-
<div ng-show="tableConfig.azure.initialized">
214-
<div ng-if="tableConfig.azure.items.length!=0 || tableConfig.azure.allItems.length!=0" class="row">
215-
<div class="col-lg-3">
216-
<div class="input-group custom-search-form">
217-
<input ng-model="searchText" type="text" class="form-control" placeholder="Find teams" ng-change="onSearchChange('azure', this)">
218-
<span class="input-group-btn">
219-
<button class="btn btn-default" type="button" ng-click="onSearchIconClicked('azure')">
220-
<span class="glyphicon glyphicon-search"></span>
221-
</button>
222-
</span>
223-
</div>
224-
</div>
225-
</div>
226-
<table ng-show="tableConfig.azure.items.length!=0 || tableConfig.azure.allItems.length!=0" class="footable table table-stripped toggle-arrow-tiny">
227-
<thead>
228-
<tr>
229-
<th class="col-lg-2" data-sort-ignore="true">Team Name</th>
230-
<th class="col-lg-2" data-sort-ignore="true">Get Link</th>
231-
</tr>
232-
</thead>
233-
<tbody>
234-
<tr ng-repeat="item in tableConfig.azure.items" ng-class-even="'footable-even'" ng-class-odd="'footable-odd'">
235-
<td class="col-lg-2">{{item.name}}</td>
236-
<td class="col-lg-2">
237-
<button class="btn btn-sm btn-success" ng-hide="item.gettingLink" ng-click="getSharableLink(item, 'azure')">
238-
<strong>Get Link</strong>
239-
</button>
240-
<button class="btn btn-sm btn-success disabled" ng-show="item.gettingLink">
241-
<i class="fa fa-spinner fa-spin"></i>
242-
</button>
243-
<p uib-alert class="alert-success" ng-repeat="alert in item.alerts" dismiss-on-timeout="1200" close="item.alerts=[]">{{alert}}</p>
244-
<p uib-alert class="alert-error" ng-repeat="alert in item.errors" dismiss-on-timeout="1200" close="item.errors=[]">{{alert}}</p>
245-
<div ng-if="item.showLink" class="input-group" ng-hide="item.gettingLink">
246-
<input type="text" class="form-control" ng-model="item.accessLink" readonly></input>
247-
<a class="input-group-addon" uib-tooltip="Copy URL to clipboard" clipboard supported="supported" text="item.accessLink"
248-
on-copied="item.alerts=[];item.alerts.push('Link has been copied to the clipboard')"
249-
on-error="item.errors=[];item.errors.push('An error occurred while copying link to clipboard')">
250-
<i class="fa fa-clipboard"></i>
251-
</a>
252-
</div>
253-
</td>
254-
<td class="col-lg-2">
255-
<button class="btn btn-sm btn-danger" ng-hide="item.removingUsers" ng-click="removeAllUsers(item, 'azure')">
256-
<strong>Remove All Users</strong>
257-
</button>
258-
<button class="btn btn-sm btn-success disabled" ng-show="item.removingUsers">
259-
<i class="fa fa-spinner fa-spin"></i>
260-
</button>
261-
</td>
262-
</tr>
263-
</tbody>
264-
<tfoot>
265-
<tr>
266-
<td colspan="4">
267-
<ul class="pagination pull-right">
268-
<li class="footable-page-arrow" ng-class="{'disabled': tableConfig.azure.pageNumber === 1}">
269-
<a ng-click="changePage(1, 'azure')">«</a>
270-
</li>
271-
<li class="footable-page-arrow" ng-class="{'disabled': tableConfig.azure.pageNumber === 1}">
272-
<a ng-click="changePage(tableConfig.azure.pageNumber - 1, 'azure')"></a>
273-
</li>
274-
<li class="footable-page" ng-class="{'active' : item === tableConfig.azure.pageNumber}" ng-repeat="item in getPageArray('azure')">
275-
<a ng-click="changePage(item, 'azure')">{{item}}</a>
276-
</li>
277-
<li class="footable-page-arrow" ng-class="{'disabled': pageNumber === getLastPage('azure')}">
278-
<a ng-click="changePage(tableConfig.azure.pageNumber + 1, 'azure')"></a>
279-
</li>
280-
<li class="footable-page-arrow" ng-class="{'disabled': tableConfig.azure.pageNumber === getLastPage('azure')}">
281-
<a ng-click="changePage(getLastPage('azure'), 'azure')">»</a>
282-
</li>
283-
284-
</ul>
285-
</td>
286-
</tr>
287-
</tfoot>
288-
</table>
289-
</div>
290-
<div ng-if="tableConfig.azure.items.length==0 && tableConfig.azure.allItems.length==0 && tableConfig.azure.initialized">
291-
You don't appear to have any azure groups available to manage through Topcoder X. Topcoder X is used to give Topcoder
292-
members access to specific group using your ownership credentials. If you
293-
don't have any group, Topcoder X won't be able to manage access for you.
294-
Please see this link for information on azure group:
295-
<a href="https://docs.azure.com/ee/user/group/" target="_blank">here</a>
296-
</div>
297-
</div>
298-
<div ng-if="settings.azure==false">
299-
<p>Your account isn't registered in the Topcoder X tool.</p>
300-
<a class="btn btn-primary" ui-sref="app.settings">
301-
<i class="fa fa-cog"></i>
302-
<small> Go To Settings</small>
303-
</a>
304-
</div>
305-
</uib-tab>
306210
</uib-tabset>
307211
</div>
308212
</div>

‎src/front/src/app/git-access-control/access-control.service.js

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,6 @@ angular.module('topcoderX')
3535
});
3636
};
3737

38-
/**
39-
* get azure owner teams
40-
*
41-
*/
42-
service.getAzureOwnerTeams = function (pageNo, pageSize) {
43-
return $http.get(baseUrl + '/api/v1/azure/owneruser/teams?page=' + pageNo + '&perPage=' + pageSize).then(function (response) {
44-
return response;
45-
});
46-
};
47-
48-
/**
49-
* get azure shareable link
50-
*
51-
*/
52-
service.getAzureShareableLink = function (teamId, orgname, projectId) {
53-
return $http.get(baseUrl + '/api/v1/azure/teams/' + teamId + '/registrationurl/' + orgname + '/' + projectId).then(function (response) {
54-
return response;
55-
});
56-
};
57-
5838
/**
5939
* get github owner teams
6040
*
@@ -95,15 +75,5 @@ angular.module('topcoderX')
9575
});
9676
};
9777

98-
/**
99-
* remove all users from a azure team
100-
*
101-
*/
102-
service.removeAllAzureUsers = function (teamId) {
103-
return $http.delete(baseUrl + '/api/v1/azure/teams/' + teamId + '/users').then(function (response) {
104-
return response;
105-
});
106-
};
107-
10878
return service;
10979
}]);

‎src/front/src/app/git-access-control/gitAccessControl.controller.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,6 @@ angular.module('topcoderX').controller('GitAccessController', ['currentUser', '$
3333
accessLinkMethod: GitAccessControlService.getGitlabShareableLink,
3434
removeAllUsersMethod: GitAccessControlService.removeAllGitlabUsers,
3535
query: '',
36-
},
37-
azure: {
38-
pageNumber: 1,
39-
pageSize: 10,
40-
isLoading: false,
41-
items: [],
42-
allItems: [],
43-
totalPages: 1,
44-
searchMethod: GitAccessControlService.getAzureOwnerTeams,
45-
initialized: false,
46-
accessLinkMethod: GitAccessControlService.getAzureShareableLink,
47-
removeAllUsersMethod: GitAccessControlService.removeAllAzureUsers,
48-
query: '',
4936
}
5037
}
5138

@@ -87,19 +74,6 @@ angular.module('topcoderX').controller('GitAccessController', ['currentUser', '$
8774
*/
8875
$scope.getSharableLink = function (team, provider) {
8976
team.gettingLink = true;
90-
if (provider === 'azure') {
91-
var azconfig = $scope.tableConfig[provider];
92-
var azparams = [team.id, team.orgName, team.projectId];
93-
azconfig.accessLinkMethod.apply(vm, azparams).then(function (response) {
94-
team.accessLink = response.data.url;
95-
team.showLink = true;
96-
team.gettingLink = false;
97-
}).catch(function (err) {
98-
team.gettingLink = false;
99-
_handleError(err);
100-
});
101-
return;
102-
}
10377
const modalInstance = $uibModal.open({
10478
size: 'md',
10579
templateUrl: 'app/git-access-control/git-access-dialog.html',

‎src/front/src/app/members/member.controller.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ angular.module('topcoderX')
1313
$scope.link = $rootScope.appConfig.GITHUB_TEAM_URL + org + '/teams/' + team;
1414
} else if (provider === 'github') {
1515
$scope.link = $rootScope.appConfig.GITLAB_GROUP_URL + url;
16-
} else if (provider === 'azure') {
17-
const params = url.split('_');
18-
$scope.link = $rootScope.appConfig.AZURE_TEAM_URL + params[0] + '/' + params[1];
1916
}
2017
};
2118
_getUrl($scope.provider, $stateParams.url);

‎src/front/src/app/members/member.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ <h2>{{title}}</h2>
1919
<p>You were successfully added to the group!</p>
2020
<a href="{{link}}">{{link}}</a>
2121
</div>
22-
<div class="text-center m-t-lg" ng-if="provider==='azure'">
23-
<p>You were successfully added to the Azure DevOps project team!</p>
24-
<a href="{{link}}">{{link}}</a>
25-
</div>
2622
</div>
2723
</div>
2824
</div>

‎src/front/src/app/projects/projects.controller.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ angular.module('topcoderX')
7373
else if (repo.toLocaleLowerCase().indexOf("gitlab") >= 0) {
7474
return "Gitlab";
7575
}
76-
else if (repo.toLocaleLowerCase().indexOf("azure") >= 0) {
77-
return "Azure";
78-
}
7976
else {
8077
return "Other";
8178
}

‎src/front/src/app/settings/settings.controller.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ angular.module('topcoderX').controller('SettingController', ['currentUser', '$sc
2121

2222
$scope.loginUrl = {
2323
github: Helper.baseUrl + $rootScope.appConfig.OWNER_LOGIN_GITHUB_URL,
24-
gitlab: Helper.baseUrl + $rootScope.appConfig.OWNER_LOGIN_GITLAB_URL,
25-
azure: Helper.baseUrl + $rootScope.appConfig.OWNER_LOGIN_AZURE_URL
24+
gitlab: Helper.baseUrl + $rootScope.appConfig.OWNER_LOGIN_GITLAB_URL
2625
}
2726

2827
$scope.$on('dialog.finished', function (event, args) {

‎src/front/src/app/settings/settings.html

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -65,31 +65,6 @@ <h2>Settings</h2>
6565
</div>
6666
</td>
6767
</tr>
68-
<tr height="60px">
69-
<td><h4>Azure DevOps</h4></td>
70-
<td>
71-
<div ng-if='isLoaded'>
72-
<div ng-if='settings.azure'>
73-
<i ng-if='!settings.expired.azure' class="btn fa fa-check green-check-icon"></i>
74-
<i ng-if='settings.expired.azure' class="btn fa fa-warning orange-warning-icon" ng-click="renew('azure')" title="Renew the token"></i>&#09;
75-
</div>
76-
<div ng-if='!settings.azure'>
77-
<a class="btn btn-sm btn-info" ng-href="{{loginUrl.azure}}">
78-
Setup
79-
</a>
80-
</div>
81-
</div>
82-
</td>
83-
<td>
84-
<div ng-if='isLoaded'>
85-
<div ng-if='settings.azure'>
86-
<a class="btn btn-sm btn-danger" ng-click="revoke('azure')">
87-
Revoke
88-
</a>
89-
</div>
90-
</div>
91-
</td>
92-
</tr>
9368
</table>
9469
</div>
9570
</div>

‎src/models/UserMapping.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ const schema = new Schema({
2323
},
2424
githubUsername: String,
2525
gitlabUsername: String,
26-
azureEmail: String,
2726
githubUserId: Number,
28-
gitlabUserId: Number,
29-
azureUserId: String
27+
gitlabUserId: Number
3028
});
3129

3230
module.exports = schema;

‎src/models/UserTeamMapping.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ const schema = new Schema({
4040
rangKey: 'id',
4141
name: 'GithubUserNameIndex',
4242
},
43-
},
44-
azureProjectId: { type: String, required: false },
45-
azureUserId: { type: String, required: false }
43+
}
4644
});
4745

4846
module.exports = schema;

‎src/routes.js

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -115,55 +115,6 @@ module.exports = {
115115
allowAnonymous: true,
116116
},
117117
},
118-
119-
'/azure/owneruser/login': {
120-
get: {
121-
controller: 'AzureController',
122-
method: 'ownerUserLogin',
123-
},
124-
},
125-
'/azure/owneruser/callback': {
126-
get: {
127-
controller: 'AzureController',
128-
method: 'ownerUserLoginCallback',
129-
},
130-
},
131-
'/azure/owneruser/teams': {
132-
get: {
133-
controller: 'AzureController',
134-
method: 'listOwnerUserTeams',
135-
},
136-
},
137-
'/azure/teams/:id/registrationurl/:orgname/:projectId': {
138-
get: {
139-
controller: 'AzureController',
140-
method: 'getTeamRegistrationUrl',
141-
},
142-
},
143-
'/azure/teams/:id/users': {
144-
delete: {
145-
controller: 'AzureController',
146-
method: 'deleteUsersFromTeam',
147-
},
148-
},
149-
'/azure/teams/registration/:identifier': {
150-
get: {
151-
controller: 'AzureController',
152-
method: 'addUserToTeam',
153-
allowNormalUser: true,
154-
tcLogin: true,
155-
allowAnonymous: true,
156-
},
157-
},
158-
'/azure/normaluser/callback': {
159-
get: {
160-
controller: 'AzureController',
161-
method: 'addUserToTeamCallback',
162-
allowNormalUser: true,
163-
allowAnonymous: true,
164-
},
165-
},
166-
167118
'/tclogin': {
168119
get: {
169120
controller: 'TCUserController',

‎src/services/AzureService.js

Lines changed: 0 additions & 279 deletions
This file was deleted.

‎src/services/ProjectService.js

Lines changed: 0 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ const GitHub = require('github-api');
1717
const Gitlab = require('gitlab/dist/es5').default;
1818
const _ = require('lodash');
1919
const guid = require('guid');
20-
const superagent = require('superagent');
21-
const superagentPromise = require('superagent-promise');
2220
const kafka = require('../utils/kafka');
2321
const helper = require('../common/helper');
2422
const dbHelper = require('../common/db-helper');
@@ -29,8 +27,6 @@ const errors = require('../common/errors');
2927
const userService = require('./UserService');
3028
const securityService = require('./SecurityService');
3129

32-
const request = superagentPromise(superagent, Promise);
33-
3430
const currentUserSchema = Joi.object().keys({
3531
handle: Joi.string().required(),
3632
roles: Joi.array().required(),
@@ -130,33 +126,6 @@ async function create(project, currentUser) {
130126
project.copilot = project.copilot ? project.copilot.toLowerCase() : null;
131127
project.id = helper.generateIdentifier();
132128

133-
const provider = await helper.getProviderType(project.repoUrl);
134-
135-
if (provider === 'azure') {
136-
const repoUrlObj = new URL(project.repoUrl);
137-
const pathCount = 3;
138-
const paths = repoUrlObj.pathname.split('/');
139-
if (paths.length > pathCount) {
140-
project.repoUrl = decodeURIComponent(`${repoUrlObj.origin}/${paths[1]}/${paths[2]}`); // eslint-disable-line no-magic-numbers
141-
}
142-
else {
143-
project.repoUrl = decodeURIComponent(`${repoUrlObj.origin}${repoUrlObj.pathname}`);
144-
}
145-
const userRole = await helper.getProjectCopilotOrOwner(models, project, provider, false);
146-
const results = project.repoUrl.split('/');
147-
const index = 1;
148-
const repoName = results[results.length - index];
149-
const repoOwner = _(results).slice(pathCount, results.length - 1).join('/');
150-
151-
let result = await request
152-
.get(`${config.AZURE_DEVOPS_API_BASE_URL}/${repoOwner}/_apis/projects/${repoName}?api-version=5.1`)
153-
.set('Authorization', `Bearer ${userRole.accessToken}`)
154-
.end()
155-
.then((res) => res.body);
156-
157-
project.repoId = result.id;
158-
}
159-
160129
const createdProject = await dbHelper.create(models.Project, project);
161130

162131
try {
@@ -327,35 +296,6 @@ async function createLabel(body, currentUser) {
327296
throw helper.convertGitLabError(err, 'Failed to create labels.');
328297
}
329298
}
330-
} else if (provider === 'azure') {
331-
try {
332-
// POST https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/${type}?api-version=6.0-preview.3
333-
const result = await request
334-
.post(`${config.AZURE_DEVOPS_API_BASE_URL}/${repoOwner}/${repoName}/_apis/wit/workitems/$issue?api-version=6.0-preview.3`)
335-
.send([{
336-
op: 'add',
337-
path: '/fields/System.Title',
338-
from: null,
339-
value: 'Issue For Creating Labels'
340-
}, {
341-
op: 'add',
342-
path: '/fields/System.Tags',
343-
value: _.join(config.LABELS.map((label) => label.name), '; ')
344-
}])
345-
.set('Authorization', `Bearer ${userRole.accessToken}`)
346-
.set('Content-Type', 'application/json-patch+json')
347-
.end()
348-
.then((res) => res.body);
349-
// DELETE https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?api-version=6.0-preview.3
350-
await request
351-
.del(`${config.AZURE_DEVOPS_API_BASE_URL}/${repoOwner}/${repoName}/_apis/wit/workitems/${result.id}?api-version=6.0-preview.3`)
352-
.set('Authorization', `Bearer ${userRole.accessToken}`)
353-
.end();
354-
} catch (err) {
355-
if (_.get(err, 'error.message') !== 'Label already exists') {
356-
throw helper.convertGitLabError(err, 'Failed to create labels.');
357-
}
358-
}
359299
}
360300
return {
361301
success: true,
@@ -474,49 +414,6 @@ async function createHook(body, currentUser) {
474414
}
475415
throw helper.convertGitLabError(err, errMsg);
476416
}
477-
} else if (provider === 'azure') {
478-
try {
479-
// https://dev.azure.com/telagaid/_apis/projects/Test%20Second?api-version=5.1
480-
let project = await request
481-
.get(`${config.AZURE_DEVOPS_API_BASE_URL}/${repoOwner}/_apis/projects/${repoName}?api-version=5.1`)
482-
.set('Authorization', `Bearer ${userRole.accessToken}`)
483-
.end()
484-
.then((res) => res.body);
485-
486-
// https://dev.azure.com/telagaid/_apis/hooks/subscriptions?api-version=5.1
487-
const eventTypes = [
488-
'workitem.created',
489-
'workitem.updated',
490-
'workitem.deleted',
491-
'workitem.restored',
492-
'workitem.commented'
493-
];
494-
for (const eventType of eventTypes) { // eslint-disable-line no-restricted-syntax
495-
await request
496-
.post(`${config.AZURE_DEVOPS_API_BASE_URL}/${repoOwner}/_apis/hooks/subscriptions?api-version=5.1`)
497-
.send({
498-
publisherId: 'tfs',
499-
eventType: eventType,
500-
resourceVersion: '5.1-preview.3',
501-
consumerId: 'webHooks',
502-
consumerActionId: 'httpRequest',
503-
publisherInputs: {
504-
projectId: project.id
505-
},
506-
consumerInputs: {
507-
basicAuthUsername: 'tcx',
508-
url: `${config.HOOK_BASE_URL}/webhooks/azure`,
509-
basicAuthPassword: dbProject.secretWebhookKey
510-
}
511-
})
512-
.set('Authorization', `Bearer ${userRole.accessToken}`)
513-
.set('Content-Type', 'application/json')
514-
.end()
515-
.then((res) => res.body);
516-
}
517-
} catch (err) {
518-
throw helper.convertGitLabError(err, 'Failed to ensure valid owner user.');
519-
}
520417
} else {
521418
return {
522419
success: false
@@ -584,38 +481,6 @@ async function addWikiRules(body, currentUser) {
584481
} catch (err) {
585482
throw helper.convertGitLabError(err, 'Failed to add wiki rules.');
586483
}
587-
} else if (provider === 'azure') {
588-
try {
589-
// PUT https://dev.azure.com/{organization}/{project}/_apis/wiki/wikis/{wikiIdentifier}/pages?path={path}&api-version=5.1
590-
const project = await request
591-
.get(`${config.AZURE_DEVOPS_API_BASE_URL}/${repoOwner}/_apis/projects/${repoName}?api-version=5.1`)
592-
.set('Authorization', `Bearer ${userRole.accessToken}`)
593-
.end()
594-
.then((res) => res.body);
595-
596-
// POST https://dev.azure.com/fabrikam/_apis/wiki/wikis?api-version=5.1
597-
await request
598-
.post(`${config.AZURE_DEVOPS_API_BASE_URL}/${repoOwner}/${repoName}/_apis/wiki/wikis?api-version=5.1`)
599-
.send({
600-
type: 'projectWiki',
601-
name: `${repoName.replace(/ /g, '-')}.wiki`,
602-
projectId: project.id
603-
})
604-
.set('Authorization', `Bearer ${userRole.accessToken}`)
605-
.set('Content-Type', 'application/json')
606-
.end();
607-
608-
await request
609-
.put(`${config.AZURE_DEVOPS_API_BASE_URL}/${repoOwner}/${repoName}/_apis/wiki/wikis/${repoName.replace(/ /g, '-')}.wiki/pages?path=Azure%20ticket%20rules&api-version=5.1`)
610-
.send({
611-
content
612-
})
613-
.set('Authorization', `Bearer ${userRole.accessToken}`)
614-
.set('Content-Type', 'application/json')
615-
.end();
616-
} catch (err) {
617-
throw helper.convertGitLabError(err, 'Failed to add wiki rules.');
618-
}
619484
}
620485
return {
621486
success: true,

‎src/services/UserService.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ async function getUserSetting(handle) {
2929
const setting = {
3030
github: false,
3131
gitlab: false,
32-
azure: false,
3332
expired: {}
3433
};
3534

@@ -58,16 +57,6 @@ async function getUserSetting(handle) {
5857
}
5958
}
6059

61-
if (mapping.azureEmail) {
62-
const azure = await dbHelper.scanOne(User, {
63-
username: mapping.azureEmail,
64-
type: constants.USER_TYPES.AZURE,
65-
});
66-
if (!_.isNil(azure)) {
67-
users.push(azure);
68-
}
69-
}
70-
7160
_.forEach(constants.USER_TYPES, (item) => {
7261
setting[item] = !!users.find((i) => i.type === item && i.accessToken);
7362
if (setting[item]) {
@@ -115,14 +104,6 @@ async function revokeUserSetting(handle, provider) {
115104
return true;
116105
}
117106

118-
if (provider === 'azure' && mapping.azureEmail) {
119-
dbHelper.remove(User, {
120-
username: mapping.azureEmail,
121-
type: constants.USER_TYPES.AZURE,
122-
});
123-
return true;
124-
}
125-
126107
return false;
127108
}
128109

@@ -166,7 +147,7 @@ async function getAccessTokenByHandle(handle, provider) {
166147
let gitUserName;
167148
if (mapping) {
168149
gitUserName = provider === constants.USER_TYPES.GITHUB ? 'githubUsername' : //eslint-disable-line no-nested-ternary
169-
provider === constants.USER_TYPES.GITLAB ? 'gitlabUsername' : 'azureEmail';
150+
'gitlabUsername';
170151
return await dbHelper.scanOne(User, {
171152
username: mapping[gitUserName],
172153
type: provider,

0 commit comments

Comments
 (0)
This repository has been archived.